Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/google/pubsub_v1/types/schema.py: 96%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

76 statements  

1# -*- coding: utf-8 -*- 

2# Copyright 2025 Google LLC 

3# 

4# Licensed under the Apache License, Version 2.0 (the "License"); 

5# you may not use this file except in compliance with the License. 

6# You may obtain a copy of the License at 

7# 

8# http://www.apache.org/licenses/LICENSE-2.0 

9# 

10# Unless required by applicable law or agreed to in writing, software 

11# distributed under the License is distributed on an "AS IS" BASIS, 

12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 

13# See the License for the specific language governing permissions and 

14# limitations under the License. 

15# 

16from __future__ import annotations 

17 

18from typing import MutableMapping, MutableSequence 

19 

20import proto # type: ignore 

21 

22from google.protobuf import timestamp_pb2 # type: ignore 

23 

24 

25__protobuf__ = proto.module( 

26 package="google.pubsub.v1", 

27 manifest={ 

28 "SchemaView", 

29 "Encoding", 

30 "Schema", 

31 "CreateSchemaRequest", 

32 "GetSchemaRequest", 

33 "ListSchemasRequest", 

34 "ListSchemasResponse", 

35 "ListSchemaRevisionsRequest", 

36 "ListSchemaRevisionsResponse", 

37 "CommitSchemaRequest", 

38 "RollbackSchemaRequest", 

39 "DeleteSchemaRevisionRequest", 

40 "DeleteSchemaRequest", 

41 "ValidateSchemaRequest", 

42 "ValidateSchemaResponse", 

43 "ValidateMessageRequest", 

44 "ValidateMessageResponse", 

45 }, 

46) 

47 

48 

49class SchemaView(proto.Enum): 

50 r"""View of Schema object fields to be returned by GetSchema and 

51 ListSchemas. 

52 

53 Values: 

54 SCHEMA_VIEW_UNSPECIFIED (0): 

55 The default / unset value. 

56 The API will default to the BASIC view. 

57 BASIC (1): 

58 Include the name and type of the schema, but 

59 not the definition. 

60 FULL (2): 

61 Include all Schema object fields. 

62 """ 

63 SCHEMA_VIEW_UNSPECIFIED = 0 

64 BASIC = 1 

65 FULL = 2 

66 

67 

68class Encoding(proto.Enum): 

69 r"""Possible encoding types for messages. 

70 

71 Values: 

72 ENCODING_UNSPECIFIED (0): 

73 Unspecified 

74 JSON (1): 

75 JSON encoding 

76 BINARY (2): 

77 Binary encoding, as defined by the schema 

78 type. For some schema types, binary encoding may 

79 not be available. 

80 """ 

81 ENCODING_UNSPECIFIED = 0 

82 JSON = 1 

83 BINARY = 2 

84 

85 

86class Schema(proto.Message): 

87 r"""A schema resource. 

88 

89 Attributes: 

90 name (str): 

91 Required. Name of the schema. Format is 

92 ``projects/{project}/schemas/{schema}``. 

93 type_ (google.pubsub_v1.types.Schema.Type): 

94 The type of the schema definition. 

95 definition (str): 

96 The definition of the schema. This should contain a string 

97 representing the full definition of the schema that is a 

98 valid schema definition of the type specified in ``type``. 

99 revision_id (str): 

100 Output only. Immutable. The revision ID of 

101 the schema. 

102 revision_create_time (google.protobuf.timestamp_pb2.Timestamp): 

103 Output only. The timestamp that the revision 

104 was created. 

105 """ 

106 

107 class Type(proto.Enum): 

108 r"""Possible schema definition types. 

109 

110 Values: 

111 TYPE_UNSPECIFIED (0): 

112 Default value. This value is unused. 

113 PROTOCOL_BUFFER (1): 

114 A Protocol Buffer schema definition. 

115 AVRO (2): 

116 An Avro schema definition. 

117 """ 

118 TYPE_UNSPECIFIED = 0 

119 PROTOCOL_BUFFER = 1 

120 AVRO = 2 

121 

122 name: str = proto.Field( 

123 proto.STRING, 

124 number=1, 

125 ) 

126 type_: Type = proto.Field( 

127 proto.ENUM, 

128 number=2, 

129 enum=Type, 

130 ) 

131 definition: str = proto.Field( 

132 proto.STRING, 

133 number=3, 

134 ) 

135 revision_id: str = proto.Field( 

136 proto.STRING, 

137 number=4, 

138 ) 

139 revision_create_time: timestamp_pb2.Timestamp = proto.Field( 

140 proto.MESSAGE, 

141 number=6, 

142 message=timestamp_pb2.Timestamp, 

143 ) 

144 

145 

146class CreateSchemaRequest(proto.Message): 

147 r"""Request for the CreateSchema method. 

148 

149 Attributes: 

150 parent (str): 

151 Required. The name of the project in which to create the 

152 schema. Format is ``projects/{project-id}``. 

153 schema (google.pubsub_v1.types.Schema): 

154 Required. The schema object to create. 

155 

156 This schema's ``name`` parameter is ignored. The schema 

157 object returned by CreateSchema will have a ``name`` made 

158 using the given ``parent`` and ``schema_id``. 

159 schema_id (str): 

160 The ID to use for the schema, which will become the final 

161 component of the schema's resource name. 

162 

163 See 

164 https://cloud.google.com/pubsub/docs/pubsub-basics#resource_names 

165 for resource name constraints. 

166 """ 

167 

168 parent: str = proto.Field( 

169 proto.STRING, 

170 number=1, 

171 ) 

172 schema: "Schema" = proto.Field( 

173 proto.MESSAGE, 

174 number=2, 

175 message="Schema", 

176 ) 

177 schema_id: str = proto.Field( 

178 proto.STRING, 

179 number=3, 

180 ) 

181 

182 

183class GetSchemaRequest(proto.Message): 

184 r"""Request for the GetSchema method. 

185 

186 Attributes: 

187 name (str): 

188 Required. The name of the schema to get. Format is 

189 ``projects/{project}/schemas/{schema}``. 

190 view (google.pubsub_v1.types.SchemaView): 

191 The set of fields to return in the response. If not set, 

192 returns a Schema with all fields filled out. Set to 

193 ``BASIC`` to omit the ``definition``. 

194 """ 

195 

196 name: str = proto.Field( 

197 proto.STRING, 

198 number=1, 

199 ) 

200 view: "SchemaView" = proto.Field( 

201 proto.ENUM, 

202 number=2, 

203 enum="SchemaView", 

204 ) 

205 

206 

207class ListSchemasRequest(proto.Message): 

208 r"""Request for the ``ListSchemas`` method. 

209 

210 Attributes: 

211 parent (str): 

212 Required. The name of the project in which to list schemas. 

213 Format is ``projects/{project-id}``. 

214 view (google.pubsub_v1.types.SchemaView): 

215 The set of Schema fields to return in the response. If not 

216 set, returns Schemas with ``name`` and ``type``, but not 

217 ``definition``. Set to ``FULL`` to retrieve all fields. 

218 page_size (int): 

219 Maximum number of schemas to return. 

220 page_token (str): 

221 The value returned by the last ``ListSchemasResponse``; 

222 indicates that this is a continuation of a prior 

223 ``ListSchemas`` call, and that the system should return the 

224 next page of data. 

225 """ 

226 

227 parent: str = proto.Field( 

228 proto.STRING, 

229 number=1, 

230 ) 

231 view: "SchemaView" = proto.Field( 

232 proto.ENUM, 

233 number=2, 

234 enum="SchemaView", 

235 ) 

236 page_size: int = proto.Field( 

237 proto.INT32, 

238 number=3, 

239 ) 

240 page_token: str = proto.Field( 

241 proto.STRING, 

242 number=4, 

243 ) 

244 

245 

246class ListSchemasResponse(proto.Message): 

247 r"""Response for the ``ListSchemas`` method. 

248 

249 Attributes: 

250 schemas (MutableSequence[google.pubsub_v1.types.Schema]): 

251 The resulting schemas. 

252 next_page_token (str): 

253 If not empty, indicates that there may be more schemas that 

254 match the request; this value should be passed in a new 

255 ``ListSchemasRequest``. 

256 """ 

257 

258 @property 

259 def raw_page(self): 

260 return self 

261 

262 schemas: MutableSequence["Schema"] = proto.RepeatedField( 

263 proto.MESSAGE, 

264 number=1, 

265 message="Schema", 

266 ) 

267 next_page_token: str = proto.Field( 

268 proto.STRING, 

269 number=2, 

270 ) 

271 

272 

273class ListSchemaRevisionsRequest(proto.Message): 

274 r"""Request for the ``ListSchemaRevisions`` method. 

275 

276 Attributes: 

277 name (str): 

278 Required. The name of the schema to list 

279 revisions for. 

280 view (google.pubsub_v1.types.SchemaView): 

281 The set of Schema fields to return in the response. If not 

282 set, returns Schemas with ``name`` and ``type``, but not 

283 ``definition``. Set to ``FULL`` to retrieve all fields. 

284 page_size (int): 

285 The maximum number of revisions to return per 

286 page. 

287 page_token (str): 

288 The page token, received from a previous 

289 ListSchemaRevisions call. Provide this to 

290 retrieve the subsequent page. 

291 """ 

292 

293 name: str = proto.Field( 

294 proto.STRING, 

295 number=1, 

296 ) 

297 view: "SchemaView" = proto.Field( 

298 proto.ENUM, 

299 number=2, 

300 enum="SchemaView", 

301 ) 

302 page_size: int = proto.Field( 

303 proto.INT32, 

304 number=3, 

305 ) 

306 page_token: str = proto.Field( 

307 proto.STRING, 

308 number=4, 

309 ) 

310 

311 

312class ListSchemaRevisionsResponse(proto.Message): 

313 r"""Response for the ``ListSchemaRevisions`` method. 

314 

315 Attributes: 

316 schemas (MutableSequence[google.pubsub_v1.types.Schema]): 

317 The revisions of the schema. 

318 next_page_token (str): 

319 A token that can be sent as ``page_token`` to retrieve the 

320 next page. If this field is empty, there are no subsequent 

321 pages. 

322 """ 

323 

324 @property 

325 def raw_page(self): 

326 return self 

327 

328 schemas: MutableSequence["Schema"] = proto.RepeatedField( 

329 proto.MESSAGE, 

330 number=1, 

331 message="Schema", 

332 ) 

333 next_page_token: str = proto.Field( 

334 proto.STRING, 

335 number=2, 

336 ) 

337 

338 

339class CommitSchemaRequest(proto.Message): 

340 r"""Request for CommitSchema method. 

341 

342 Attributes: 

343 name (str): 

344 Required. The name of the schema we are revising. Format is 

345 ``projects/{project}/schemas/{schema}``. 

346 schema (google.pubsub_v1.types.Schema): 

347 Required. The schema revision to commit. 

348 """ 

349 

350 name: str = proto.Field( 

351 proto.STRING, 

352 number=1, 

353 ) 

354 schema: "Schema" = proto.Field( 

355 proto.MESSAGE, 

356 number=2, 

357 message="Schema", 

358 ) 

359 

360 

361class RollbackSchemaRequest(proto.Message): 

362 r"""Request for the ``RollbackSchema`` method. 

363 

364 Attributes: 

365 name (str): 

366 Required. The schema being rolled back with 

367 revision id. 

368 revision_id (str): 

369 Required. The revision ID to roll back to. 

370 It must be a revision of the same schema. 

371 

372 Example: c7cfa2a8 

373 """ 

374 

375 name: str = proto.Field( 

376 proto.STRING, 

377 number=1, 

378 ) 

379 revision_id: str = proto.Field( 

380 proto.STRING, 

381 number=2, 

382 ) 

383 

384 

385class DeleteSchemaRevisionRequest(proto.Message): 

386 r"""Request for the ``DeleteSchemaRevision`` method. 

387 

388 Attributes: 

389 name (str): 

390 Required. The name of the schema revision to be deleted, 

391 with a revision ID explicitly included. 

392 

393 Example: ``projects/123/schemas/my-schema@c7cfa2a8`` 

394 revision_id (str): 

395 Optional. This field is deprecated and should not be used 

396 for specifying the revision ID. The revision ID should be 

397 specified via the ``name`` parameter. 

398 """ 

399 

400 name: str = proto.Field( 

401 proto.STRING, 

402 number=1, 

403 ) 

404 revision_id: str = proto.Field( 

405 proto.STRING, 

406 number=2, 

407 ) 

408 

409 

410class DeleteSchemaRequest(proto.Message): 

411 r"""Request for the ``DeleteSchema`` method. 

412 

413 Attributes: 

414 name (str): 

415 Required. Name of the schema to delete. Format is 

416 ``projects/{project}/schemas/{schema}``. 

417 """ 

418 

419 name: str = proto.Field( 

420 proto.STRING, 

421 number=1, 

422 ) 

423 

424 

425class ValidateSchemaRequest(proto.Message): 

426 r"""Request for the ``ValidateSchema`` method. 

427 

428 Attributes: 

429 parent (str): 

430 Required. The name of the project in which to validate 

431 schemas. Format is ``projects/{project-id}``. 

432 schema (google.pubsub_v1.types.Schema): 

433 Required. The schema object to validate. 

434 """ 

435 

436 parent: str = proto.Field( 

437 proto.STRING, 

438 number=1, 

439 ) 

440 schema: "Schema" = proto.Field( 

441 proto.MESSAGE, 

442 number=2, 

443 message="Schema", 

444 ) 

445 

446 

447class ValidateSchemaResponse(proto.Message): 

448 r"""Response for the ``ValidateSchema`` method. Empty for now.""" 

449 

450 

451class ValidateMessageRequest(proto.Message): 

452 r"""Request for the ``ValidateMessage`` method. 

453 

454 This message has `oneof`_ fields (mutually exclusive fields). 

455 For each oneof, at most one member field can be set at the same time. 

456 Setting any member of the oneof automatically clears all other 

457 members. 

458 

459 .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields 

460 

461 Attributes: 

462 parent (str): 

463 Required. The name of the project in which to validate 

464 schemas. Format is ``projects/{project-id}``. 

465 name (str): 

466 Name of the schema against which to validate. 

467 

468 Format is ``projects/{project}/schemas/{schema}``. 

469 

470 This field is a member of `oneof`_ ``schema_spec``. 

471 schema (google.pubsub_v1.types.Schema): 

472 Ad-hoc schema against which to validate 

473 

474 This field is a member of `oneof`_ ``schema_spec``. 

475 message (bytes): 

476 Message to validate against the provided ``schema_spec``. 

477 encoding (google.pubsub_v1.types.Encoding): 

478 The encoding expected for messages 

479 """ 

480 

481 parent: str = proto.Field( 

482 proto.STRING, 

483 number=1, 

484 ) 

485 name: str = proto.Field( 

486 proto.STRING, 

487 number=2, 

488 oneof="schema_spec", 

489 ) 

490 schema: "Schema" = proto.Field( 

491 proto.MESSAGE, 

492 number=3, 

493 oneof="schema_spec", 

494 message="Schema", 

495 ) 

496 message: bytes = proto.Field( 

497 proto.BYTES, 

498 number=4, 

499 ) 

500 encoding: "Encoding" = proto.Field( 

501 proto.ENUM, 

502 number=5, 

503 enum="Encoding", 

504 ) 

505 

506 

507class ValidateMessageResponse(proto.Message): 

508 r"""Response for the ``ValidateMessage`` method. Empty for now.""" 

509 

510 

511__all__ = tuple(sorted(__protobuf__.manifest))