This repository has been archived by the owner on Jul 6, 2023. It is now read-only.
/
tether.py
253 lines (205 loc) · 8.04 KB
/
tether.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
# -*- coding: utf-8 -*-
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import proto # type: ignore
from google.protobuf import duration_pb2 # type: ignore
from google.rpc import status_pb2 # type: ignore
__protobuf__ = proto.module(
package="google.cloud.apigeeconnect.v1",
manifest={
"Action",
"TetherEndpoint",
"Scheme",
"EgressRequest",
"Payload",
"StreamInfo",
"EgressResponse",
"HttpRequest",
"Url",
"Header",
"HttpResponse",
},
)
class Action(proto.Enum):
r"""The action taken by agent."""
ACTION_UNSPECIFIED = 0
OPEN_NEW_STREAM = 1
class TetherEndpoint(proto.Enum):
r"""Endpoint indicates where the messages will be delivered."""
TETHER_ENDPOINT_UNSPECIFIED = 0
APIGEE_MART = 1
APIGEE_RUNTIME = 2
APIGEE_MINT_RATING = 3
class Scheme(proto.Enum):
r"""HTTP Scheme."""
SCHEME_UNSPECIFIED = 0
HTTPS = 1
class EgressRequest(proto.Message):
r"""gRPC request payload for tether.
Attributes:
id (str):
Unique identifier for the request.
payload (google.cloud.apigeeconnect_v1.types.Payload):
Actual payload to send to agent.
endpoint (google.cloud.apigeeconnect_v1.types.TetherEndpoint):
Tether Endpoint.
project (str):
GCP Project. Format: ``projects/{project_number}``.
trace_id (str):
Unique identifier for clients to trace their
request/response.
timeout (google.protobuf.duration_pb2.Duration):
Timeout for the HTTP request.
"""
id = proto.Field(proto.STRING, number=1,)
payload = proto.Field(proto.MESSAGE, number=2, message="Payload",)
endpoint = proto.Field(proto.ENUM, number=3, enum="TetherEndpoint",)
project = proto.Field(proto.STRING, number=4,)
trace_id = proto.Field(proto.STRING, number=5,)
timeout = proto.Field(proto.MESSAGE, number=6, message=duration_pb2.Duration,)
class Payload(proto.Message):
r"""Payload for EgressRequest.
This message has `oneof`_ fields (mutually exclusive fields).
For each oneof, at most one member field can be set at the same time.
Setting any member of the oneof automatically clears all other
members.
.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
Attributes:
http_request (google.cloud.apigeeconnect_v1.types.HttpRequest):
The HttpRequest proto.
This field is a member of `oneof`_ ``kind``.
stream_info (google.cloud.apigeeconnect_v1.types.StreamInfo):
The information of stream.
This field is a member of `oneof`_ ``kind``.
action (google.cloud.apigeeconnect_v1.types.Action):
The action taken by agent.
This field is a member of `oneof`_ ``kind``.
"""
http_request = proto.Field(
proto.MESSAGE, number=1, oneof="kind", message="HttpRequest",
)
stream_info = proto.Field(
proto.MESSAGE, number=2, oneof="kind", message="StreamInfo",
)
action = proto.Field(proto.ENUM, number=3, oneof="kind", enum="Action",)
class StreamInfo(proto.Message):
r"""The Information of bi-directional stream.
Attributes:
id (str):
Unique identifier for the stream.
"""
id = proto.Field(proto.STRING, number=1,)
class EgressResponse(proto.Message):
r"""gRPC response payload for tether.
Attributes:
id (str):
Unique identifier for the response. Matches
the EgressRequest's id.
http_response (google.cloud.apigeeconnect_v1.types.HttpResponse):
HttpResponse.
status (google.rpc.status_pb2.Status):
Errors from application when handling the
http request.
project (str):
GCP Project. Format: ``projects/{project_number}``.
trace_id (str):
Unique identifier for clients to trace their
request/response. Matches the EgressRequest's
trace id
endpoint (google.cloud.apigeeconnect_v1.types.TetherEndpoint):
Tether Endpoint.
name (str):
Name is the full resource path of endpoint. Format:
``projects/{project_number or project_id}/endpoints/{endpoint}``
"""
id = proto.Field(proto.STRING, number=1,)
http_response = proto.Field(proto.MESSAGE, number=2, message="HttpResponse",)
status = proto.Field(proto.MESSAGE, number=3, message=status_pb2.Status,)
project = proto.Field(proto.STRING, number=4,)
trace_id = proto.Field(proto.STRING, number=5,)
endpoint = proto.Field(proto.ENUM, number=6, enum="TetherEndpoint",)
name = proto.Field(proto.STRING, number=7,)
class HttpRequest(proto.Message):
r"""The proto definition of http request.
Attributes:
id (str):
A unique identifier for the request.
method (str):
The HTTP request method.
Valid methods: "GET", "HEAD", "POST", "PUT",
"PATCH","DELETE".
url (google.cloud.apigeeconnect_v1.types.Url):
The HTTP request URL.
headers (Sequence[google.cloud.apigeeconnect_v1.types.Header]):
The HTTP request headers.
body (bytes):
HTTP request body.
"""
id = proto.Field(proto.STRING, number=1,)
method = proto.Field(proto.STRING, number=2,)
url = proto.Field(proto.MESSAGE, number=3, message="Url",)
headers = proto.RepeatedField(proto.MESSAGE, number=4, message="Header",)
body = proto.Field(proto.BYTES, number=5,)
class Url(proto.Message):
r"""The proto definition of url. A url represents a URL and the general
form represented is:
``[scheme://][google.cloud.apigeeconnect.v1.Url.host][path]``
Attributes:
scheme (google.cloud.apigeeconnect_v1.types.Scheme):
Scheme.
host (str):
Host or Host:Port.
path (str):
Path starts with ``/``.
"""
scheme = proto.Field(proto.ENUM, number=1, enum="Scheme",)
host = proto.Field(proto.STRING, number=2,)
path = proto.Field(proto.STRING, number=3,)
class Header(proto.Message):
r"""The http headers.
Attributes:
key (str):
values (Sequence[str]):
"""
key = proto.Field(proto.STRING, number=1,)
values = proto.RepeatedField(proto.STRING, number=2,)
class HttpResponse(proto.Message):
r"""The proto definition of http response.
Attributes:
id (str):
A unique identifier that matches the request
ID.
status (str):
Status of http response, e.g. "200 OK".
status_code (int):
Status code of http response, e.g. 200.
body (bytes):
The HTTP 1.1 response body.
headers (Sequence[google.cloud.apigeeconnect_v1.types.Header]):
The HTTP response headers.
content_length (int):
Content length records the length of the
associated content. The value -1 indicates that
the length is unknown. Unless http method is
"HEAD", values >= 0 indicate that the given
number of bytes may be read from Body.
"""
id = proto.Field(proto.STRING, number=1,)
status = proto.Field(proto.STRING, number=2,)
status_code = proto.Field(proto.INT32, number=3,)
body = proto.Field(proto.BYTES, number=4,)
headers = proto.RepeatedField(proto.MESSAGE, number=5, message="Header",)
content_length = proto.Field(proto.INT64, number=6,)
__all__ = tuple(sorted(__protobuf__.manifest))