-
Notifications
You must be signed in to change notification settings - Fork 197
/
schema.py
511 lines (429 loc) · 13.8 KB
/
schema.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
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
# -*- coding: utf-8 -*-
# Copyright 2024 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.
#
from __future__ import annotations
from typing import MutableMapping, MutableSequence
import proto # type: ignore
from google.protobuf import timestamp_pb2 # type: ignore
__protobuf__ = proto.module(
package="google.pubsub.v1",
manifest={
"SchemaView",
"Encoding",
"Schema",
"CreateSchemaRequest",
"GetSchemaRequest",
"ListSchemasRequest",
"ListSchemasResponse",
"ListSchemaRevisionsRequest",
"ListSchemaRevisionsResponse",
"CommitSchemaRequest",
"RollbackSchemaRequest",
"DeleteSchemaRevisionRequest",
"DeleteSchemaRequest",
"ValidateSchemaRequest",
"ValidateSchemaResponse",
"ValidateMessageRequest",
"ValidateMessageResponse",
},
)
class SchemaView(proto.Enum):
r"""View of Schema object fields to be returned by GetSchema and
ListSchemas.
Values:
SCHEMA_VIEW_UNSPECIFIED (0):
The default / unset value.
The API will default to the BASIC view.
BASIC (1):
Include the name and type of the schema, but
not the definition.
FULL (2):
Include all Schema object fields.
"""
SCHEMA_VIEW_UNSPECIFIED = 0
BASIC = 1
FULL = 2
class Encoding(proto.Enum):
r"""Possible encoding types for messages.
Values:
ENCODING_UNSPECIFIED (0):
Unspecified
JSON (1):
JSON encoding
BINARY (2):
Binary encoding, as defined by the schema
type. For some schema types, binary encoding may
not be available.
"""
ENCODING_UNSPECIFIED = 0
JSON = 1
BINARY = 2
class Schema(proto.Message):
r"""A schema resource.
Attributes:
name (str):
Required. Name of the schema. Format is
``projects/{project}/schemas/{schema}``.
type_ (google.pubsub_v1.types.Schema.Type):
The type of the schema definition.
definition (str):
The definition of the schema. This should contain a string
representing the full definition of the schema that is a
valid schema definition of the type specified in ``type``.
revision_id (str):
Output only. Immutable. The revision ID of
the schema.
revision_create_time (google.protobuf.timestamp_pb2.Timestamp):
Output only. The timestamp that the revision
was created.
"""
class Type(proto.Enum):
r"""Possible schema definition types.
Values:
TYPE_UNSPECIFIED (0):
Default value. This value is unused.
PROTOCOL_BUFFER (1):
A Protocol Buffer schema definition.
AVRO (2):
An Avro schema definition.
"""
TYPE_UNSPECIFIED = 0
PROTOCOL_BUFFER = 1
AVRO = 2
name: str = proto.Field(
proto.STRING,
number=1,
)
type_: Type = proto.Field(
proto.ENUM,
number=2,
enum=Type,
)
definition: str = proto.Field(
proto.STRING,
number=3,
)
revision_id: str = proto.Field(
proto.STRING,
number=4,
)
revision_create_time: timestamp_pb2.Timestamp = proto.Field(
proto.MESSAGE,
number=6,
message=timestamp_pb2.Timestamp,
)
class CreateSchemaRequest(proto.Message):
r"""Request for the CreateSchema method.
Attributes:
parent (str):
Required. The name of the project in which to create the
schema. Format is ``projects/{project-id}``.
schema (google.pubsub_v1.types.Schema):
Required. The schema object to create.
This schema's ``name`` parameter is ignored. The schema
object returned by CreateSchema will have a ``name`` made
using the given ``parent`` and ``schema_id``.
schema_id (str):
The ID to use for the schema, which will become the final
component of the schema's resource name.
See
https://cloud.google.com/pubsub/docs/pubsub-basics#resource_names
for resource name constraints.
"""
parent: str = proto.Field(
proto.STRING,
number=1,
)
schema: "Schema" = proto.Field(
proto.MESSAGE,
number=2,
message="Schema",
)
schema_id: str = proto.Field(
proto.STRING,
number=3,
)
class GetSchemaRequest(proto.Message):
r"""Request for the GetSchema method.
Attributes:
name (str):
Required. The name of the schema to get. Format is
``projects/{project}/schemas/{schema}``.
view (google.pubsub_v1.types.SchemaView):
The set of fields to return in the response. If not set,
returns a Schema with all fields filled out. Set to
``BASIC`` to omit the ``definition``.
"""
name: str = proto.Field(
proto.STRING,
number=1,
)
view: "SchemaView" = proto.Field(
proto.ENUM,
number=2,
enum="SchemaView",
)
class ListSchemasRequest(proto.Message):
r"""Request for the ``ListSchemas`` method.
Attributes:
parent (str):
Required. The name of the project in which to list schemas.
Format is ``projects/{project-id}``.
view (google.pubsub_v1.types.SchemaView):
The set of Schema fields to return in the response. If not
set, returns Schemas with ``name`` and ``type``, but not
``definition``. Set to ``FULL`` to retrieve all fields.
page_size (int):
Maximum number of schemas to return.
page_token (str):
The value returned by the last ``ListSchemasResponse``;
indicates that this is a continuation of a prior
``ListSchemas`` call, and that the system should return the
next page of data.
"""
parent: str = proto.Field(
proto.STRING,
number=1,
)
view: "SchemaView" = proto.Field(
proto.ENUM,
number=2,
enum="SchemaView",
)
page_size: int = proto.Field(
proto.INT32,
number=3,
)
page_token: str = proto.Field(
proto.STRING,
number=4,
)
class ListSchemasResponse(proto.Message):
r"""Response for the ``ListSchemas`` method.
Attributes:
schemas (MutableSequence[google.pubsub_v1.types.Schema]):
The resulting schemas.
next_page_token (str):
If not empty, indicates that there may be more schemas that
match the request; this value should be passed in a new
``ListSchemasRequest``.
"""
@property
def raw_page(self):
return self
schemas: MutableSequence["Schema"] = proto.RepeatedField(
proto.MESSAGE,
number=1,
message="Schema",
)
next_page_token: str = proto.Field(
proto.STRING,
number=2,
)
class ListSchemaRevisionsRequest(proto.Message):
r"""Request for the ``ListSchemaRevisions`` method.
Attributes:
name (str):
Required. The name of the schema to list
revisions for.
view (google.pubsub_v1.types.SchemaView):
The set of Schema fields to return in the response. If not
set, returns Schemas with ``name`` and ``type``, but not
``definition``. Set to ``FULL`` to retrieve all fields.
page_size (int):
The maximum number of revisions to return per
page.
page_token (str):
The page token, received from a previous
ListSchemaRevisions call. Provide this to
retrieve the subsequent page.
"""
name: str = proto.Field(
proto.STRING,
number=1,
)
view: "SchemaView" = proto.Field(
proto.ENUM,
number=2,
enum="SchemaView",
)
page_size: int = proto.Field(
proto.INT32,
number=3,
)
page_token: str = proto.Field(
proto.STRING,
number=4,
)
class ListSchemaRevisionsResponse(proto.Message):
r"""Response for the ``ListSchemaRevisions`` method.
Attributes:
schemas (MutableSequence[google.pubsub_v1.types.Schema]):
The revisions of the schema.
next_page_token (str):
A token that can be sent as ``page_token`` to retrieve the
next page. If this field is empty, there are no subsequent
pages.
"""
@property
def raw_page(self):
return self
schemas: MutableSequence["Schema"] = proto.RepeatedField(
proto.MESSAGE,
number=1,
message="Schema",
)
next_page_token: str = proto.Field(
proto.STRING,
number=2,
)
class CommitSchemaRequest(proto.Message):
r"""Request for CommitSchema method.
Attributes:
name (str):
Required. The name of the schema we are revising. Format is
``projects/{project}/schemas/{schema}``.
schema (google.pubsub_v1.types.Schema):
Required. The schema revision to commit.
"""
name: str = proto.Field(
proto.STRING,
number=1,
)
schema: "Schema" = proto.Field(
proto.MESSAGE,
number=2,
message="Schema",
)
class RollbackSchemaRequest(proto.Message):
r"""Request for the ``RollbackSchema`` method.
Attributes:
name (str):
Required. The schema being rolled back with
revision id.
revision_id (str):
Required. The revision ID to roll back to.
It must be a revision of the same schema.
Example: c7cfa2a8
"""
name: str = proto.Field(
proto.STRING,
number=1,
)
revision_id: str = proto.Field(
proto.STRING,
number=2,
)
class DeleteSchemaRevisionRequest(proto.Message):
r"""Request for the ``DeleteSchemaRevision`` method.
Attributes:
name (str):
Required. The name of the schema revision to be deleted,
with a revision ID explicitly included.
Example: ``projects/123/schemas/my-schema@c7cfa2a8``
revision_id (str):
Optional. This field is deprecated and should not be used
for specifying the revision ID. The revision ID should be
specified via the ``name`` parameter.
"""
name: str = proto.Field(
proto.STRING,
number=1,
)
revision_id: str = proto.Field(
proto.STRING,
number=2,
)
class DeleteSchemaRequest(proto.Message):
r"""Request for the ``DeleteSchema`` method.
Attributes:
name (str):
Required. Name of the schema to delete. Format is
``projects/{project}/schemas/{schema}``.
"""
name: str = proto.Field(
proto.STRING,
number=1,
)
class ValidateSchemaRequest(proto.Message):
r"""Request for the ``ValidateSchema`` method.
Attributes:
parent (str):
Required. The name of the project in which to validate
schemas. Format is ``projects/{project-id}``.
schema (google.pubsub_v1.types.Schema):
Required. The schema object to validate.
"""
parent: str = proto.Field(
proto.STRING,
number=1,
)
schema: "Schema" = proto.Field(
proto.MESSAGE,
number=2,
message="Schema",
)
class ValidateSchemaResponse(proto.Message):
r"""Response for the ``ValidateSchema`` method. Empty for now."""
class ValidateMessageRequest(proto.Message):
r"""Request for the ``ValidateMessage`` method.
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:
parent (str):
Required. The name of the project in which to validate
schemas. Format is ``projects/{project-id}``.
name (str):
Name of the schema against which to validate.
Format is ``projects/{project}/schemas/{schema}``.
This field is a member of `oneof`_ ``schema_spec``.
schema (google.pubsub_v1.types.Schema):
Ad-hoc schema against which to validate
This field is a member of `oneof`_ ``schema_spec``.
message (bytes):
Message to validate against the provided ``schema_spec``.
encoding (google.pubsub_v1.types.Encoding):
The encoding expected for messages
"""
parent: str = proto.Field(
proto.STRING,
number=1,
)
name: str = proto.Field(
proto.STRING,
number=2,
oneof="schema_spec",
)
schema: "Schema" = proto.Field(
proto.MESSAGE,
number=3,
oneof="schema_spec",
message="Schema",
)
message: bytes = proto.Field(
proto.BYTES,
number=4,
)
encoding: "Encoding" = proto.Field(
proto.ENUM,
number=5,
enum="Encoding",
)
class ValidateMessageResponse(proto.Message):
r"""Response for the ``ValidateMessage`` method. Empty for now."""
__all__ = tuple(sorted(__protobuf__.manifest))