Debian Codegraph @

managedkafka/schemaregistry/apiv1/managed_schema_registry_client.go

raw symbols SCIP
1 // Copyright 2025 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 // Code generated by protoc-gen-go_gapic. DO NOT EDIT.
16
17 package schemaregistry
18
19 import (
20 "bytes"
21 "context"
22 "fmt"
23 "log/slog"
24 "math"
25 "net/http"
26 "net/url"
27
28 longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
29 schemaregistrypb "cloud.google.com/go/managedkafka/schemaregistry/apiv1/schemaregistrypb"
30 gax "github.com/googleapis/gax-go/v2"
31 "google.golang.org/api/iterator"
32 "google.golang.org/api/option"
33 "google.golang.org/api/option/internaloption"
34 gtransport "google.golang.org/api/transport/grpc"
35 httptransport "google.golang.org/api/transport/http"
36 httpbodypb "google.golang.org/genproto/googleapis/api/httpbody"
37 locationpb "google.golang.org/genproto/googleapis/cloud/location"
38 "google.golang.org/grpc"
39 "google.golang.org/protobuf/encoding/protojson"
40 "google.golang.org/protobuf/proto"
41 )
42
43 var newManagedSchemaRegistryClientHook clientHook
44
45 // ManagedSchemaRegistryCallOptions contains the retry settings for each method of ManagedSchemaRegistryClient.
46 type ManagedSchemaRegistryCallOptions struct {
47 GetSchemaRegistry []gax.CallOption
48 ListSchemaRegistries []gax.CallOption
49 CreateSchemaRegistry []gax.CallOption
50 DeleteSchemaRegistry []gax.CallOption
51 GetContext []gax.CallOption
52 ListContexts []gax.CallOption
53 GetSchema []gax.CallOption
54 GetRawSchema []gax.CallOption
55 ListSchemaVersions []gax.CallOption
56 ListSchemaTypes []gax.CallOption
57 ListSubjects []gax.CallOption
58 ListSubjectsBySchemaId []gax.CallOption
59 DeleteSubject []gax.CallOption
60 LookupVersion []gax.CallOption
61 GetVersion []gax.CallOption
62 GetRawSchemaVersion []gax.CallOption
63 ListVersions []gax.CallOption
64 CreateVersion []gax.CallOption
65 DeleteVersion []gax.CallOption
66 ListReferencedSchemas []gax.CallOption
67 CheckCompatibility []gax.CallOption
68 GetSchemaConfig []gax.CallOption
69 UpdateSchemaConfig []gax.CallOption
70 DeleteSchemaConfig []gax.CallOption
71 GetSchemaMode []gax.CallOption
72 UpdateSchemaMode []gax.CallOption
73 DeleteSchemaMode []gax.CallOption
74 GetLocation []gax.CallOption
75 ListLocations []gax.CallOption
76 CancelOperation []gax.CallOption
77 DeleteOperation []gax.CallOption
78 GetOperation []gax.CallOption
79 ListOperations []gax.CallOption
80 }
81
82 func defaultManagedSchemaRegistryGRPCClientOptions() []option.ClientOption {
83 return []option.ClientOption{
84 internaloption.WithDefaultEndpoint("managedkafka.googleapis.com:443"),
85 internaloption.WithDefaultEndpointTemplate("managedkafka.UNIVERSE_DOMAIN:443"),
86 internaloption.WithDefaultMTLSEndpoint("managedkafka.mtls.googleapis.com:443"),
87 internaloption.WithDefaultUniverseDomain("googleapis.com"),
88 internaloption.WithDefaultAudience("https://managedkafka.googleapis.com/"),
89 internaloption.WithDefaultScopes(DefaultAuthScopes()...),
90 internaloption.EnableJwtWithScope(),
91 internaloption.EnableNewAuthLibrary(),
92 option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
93 grpc.MaxCallRecvMsgSize(math.MaxInt32))),
94 }
95 }
96
97 func defaultManagedSchemaRegistryCallOptions() *ManagedSchemaRegistryCallOptions {
98 return &ManagedSchemaRegistryCallOptions{
99 GetSchemaRegistry: []gax.CallOption{},
100 ListSchemaRegistries: []gax.CallOption{},
101 CreateSchemaRegistry: []gax.CallOption{},
102 DeleteSchemaRegistry: []gax.CallOption{},
103 GetContext: []gax.CallOption{},
104 ListContexts: []gax.CallOption{},
105 GetSchema: []gax.CallOption{},
106 GetRawSchema: []gax.CallOption{},
107 ListSchemaVersions: []gax.CallOption{},
108 ListSchemaTypes: []gax.CallOption{},
109 ListSubjects: []gax.CallOption{},
110 ListSubjectsBySchemaId: []gax.CallOption{},
111 DeleteSubject: []gax.CallOption{},
112 LookupVersion: []gax.CallOption{},
113 GetVersion: []gax.CallOption{},
114 GetRawSchemaVersion: []gax.CallOption{},
115 ListVersions: []gax.CallOption{},
116 CreateVersion: []gax.CallOption{},
117 DeleteVersion: []gax.CallOption{},
118 ListReferencedSchemas: []gax.CallOption{},
119 CheckCompatibility: []gax.CallOption{},
120 GetSchemaConfig: []gax.CallOption{},
121 UpdateSchemaConfig: []gax.CallOption{},
122 DeleteSchemaConfig: []gax.CallOption{},
123 GetSchemaMode: []gax.CallOption{},
124 UpdateSchemaMode: []gax.CallOption{},
125 DeleteSchemaMode: []gax.CallOption{},
126 GetLocation: []gax.CallOption{},
127 ListLocations: []gax.CallOption{},
128 CancelOperation: []gax.CallOption{},
129 DeleteOperation: []gax.CallOption{},
130 GetOperation: []gax.CallOption{},
131 ListOperations: []gax.CallOption{},
132 }
133 }
134
135 func defaultManagedSchemaRegistryRESTCallOptions() *ManagedSchemaRegistryCallOptions {
136 return &ManagedSchemaRegistryCallOptions{
137 GetSchemaRegistry: []gax.CallOption{},
138 ListSchemaRegistries: []gax.CallOption{},
139 CreateSchemaRegistry: []gax.CallOption{},
140 DeleteSchemaRegistry: []gax.CallOption{},
141 GetContext: []gax.CallOption{},
142 ListContexts: []gax.CallOption{},
143 GetSchema: []gax.CallOption{},
144 GetRawSchema: []gax.CallOption{},
145 ListSchemaVersions: []gax.CallOption{},
146 ListSchemaTypes: []gax.CallOption{},
147 ListSubjects: []gax.CallOption{},
148 ListSubjectsBySchemaId: []gax.CallOption{},
149 DeleteSubject: []gax.CallOption{},
150 LookupVersion: []gax.CallOption{},
151 GetVersion: []gax.CallOption{},
152 GetRawSchemaVersion: []gax.CallOption{},
153 ListVersions: []gax.CallOption{},
154 CreateVersion: []gax.CallOption{},
155 DeleteVersion: []gax.CallOption{},
156 ListReferencedSchemas: []gax.CallOption{},
157 CheckCompatibility: []gax.CallOption{},
158 GetSchemaConfig: []gax.CallOption{},
159 UpdateSchemaConfig: []gax.CallOption{},
160 DeleteSchemaConfig: []gax.CallOption{},
161 GetSchemaMode: []gax.CallOption{},
162 UpdateSchemaMode: []gax.CallOption{},
163 DeleteSchemaMode: []gax.CallOption{},
164 GetLocation: []gax.CallOption{},
165 ListLocations: []gax.CallOption{},
166 CancelOperation: []gax.CallOption{},
167 DeleteOperation: []gax.CallOption{},
168 GetOperation: []gax.CallOption{},
169 ListOperations: []gax.CallOption{},
170 }
171 }
172
173 // internalManagedSchemaRegistryClient is an interface that defines the methods available from Managed Service for Apache Kafka API.
174 type internalManagedSchemaRegistryClient interface {
175 Close() error
176 setGoogleClientInfo(...string)
177 Connection() *grpc.ClientConn
178 GetSchemaRegistry(context.Context, *schemaregistrypb.GetSchemaRegistryRequest, ...gax.CallOption) (*schemaregistrypb.SchemaRegistry, error)
179 ListSchemaRegistries(context.Context, *schemaregistrypb.ListSchemaRegistriesRequest, ...gax.CallOption) (*schemaregistrypb.ListSchemaRegistriesResponse, error)
180 CreateSchemaRegistry(context.Context, *schemaregistrypb.CreateSchemaRegistryRequest, ...gax.CallOption) (*schemaregistrypb.SchemaRegistry, error)
181 DeleteSchemaRegistry(context.Context, *schemaregistrypb.DeleteSchemaRegistryRequest, ...gax.CallOption) error
182 GetContext(context.Context, *schemaregistrypb.GetContextRequest, ...gax.CallOption) (*schemaregistrypb.Context, error)
183 ListContexts(context.Context, *schemaregistrypb.ListContextsRequest, ...gax.CallOption) (*httpbodypb.HttpBody, error)
184 GetSchema(context.Context, *schemaregistrypb.GetSchemaRequest, ...gax.CallOption) (*schemaregistrypb.Schema, error)
185 GetRawSchema(context.Context, *schemaregistrypb.GetSchemaRequest, ...gax.CallOption) (*httpbodypb.HttpBody, error)
186 ListSchemaVersions(context.Context, *schemaregistrypb.ListSchemaVersionsRequest, ...gax.CallOption) (*httpbodypb.HttpBody, error)
187 ListSchemaTypes(context.Context, *schemaregistrypb.ListSchemaTypesRequest, ...gax.CallOption) (*httpbodypb.HttpBody, error)
188 ListSubjects(context.Context, *schemaregistrypb.ListSubjectsRequest, ...gax.CallOption) (*httpbodypb.HttpBody, error)
189 ListSubjectsBySchemaId(context.Context, *schemaregistrypb.ListSubjectsBySchemaIdRequest, ...gax.CallOption) (*httpbodypb.HttpBody, error)
190 DeleteSubject(context.Context, *schemaregistrypb.DeleteSubjectRequest, ...gax.CallOption) (*httpbodypb.HttpBody, error)
191 LookupVersion(context.Context, *schemaregistrypb.LookupVersionRequest, ...gax.CallOption) (*schemaregistrypb.SchemaVersion, error)
192 GetVersion(context.Context, *schemaregistrypb.GetVersionRequest, ...gax.CallOption) (*schemaregistrypb.SchemaVersion, error)
193 GetRawSchemaVersion(context.Context, *schemaregistrypb.GetVersionRequest, ...gax.CallOption) (*httpbodypb.HttpBody, error)
194 ListVersions(context.Context, *schemaregistrypb.ListVersionsRequest, ...gax.CallOption) (*httpbodypb.HttpBody, error)
195 CreateVersion(context.Context, *schemaregistrypb.CreateVersionRequest, ...gax.CallOption) (*schemaregistrypb.CreateVersionResponse, error)
196 DeleteVersion(context.Context, *schemaregistrypb.DeleteVersionRequest, ...gax.CallOption) (*httpbodypb.HttpBody, error)
197 ListReferencedSchemas(context.Context, *schemaregistrypb.ListReferencedSchemasRequest, ...gax.CallOption) (*httpbodypb.HttpBody, error)
198 CheckCompatibility(context.Context, *schemaregistrypb.CheckCompatibilityRequest, ...gax.CallOption) (*schemaregistrypb.CheckCompatibilityResponse, error)
199 GetSchemaConfig(context.Context, *schemaregistrypb.GetSchemaConfigRequest, ...gax.CallOption) (*schemaregistrypb.SchemaConfig, error)
200 UpdateSchemaConfig(context.Context, *schemaregistrypb.UpdateSchemaConfigRequest, ...gax.CallOption) (*schemaregistrypb.SchemaConfig, error)
201 DeleteSchemaConfig(context.Context, *schemaregistrypb.DeleteSchemaConfigRequest, ...gax.CallOption) (*schemaregistrypb.SchemaConfig, error)
202 GetSchemaMode(context.Context, *schemaregistrypb.GetSchemaModeRequest, ...gax.CallOption) (*schemaregistrypb.SchemaMode, error)
203 UpdateSchemaMode(context.Context, *schemaregistrypb.UpdateSchemaModeRequest, ...gax.CallOption) (*schemaregistrypb.SchemaMode, error)
204 DeleteSchemaMode(context.Context, *schemaregistrypb.DeleteSchemaModeRequest, ...gax.CallOption) (*schemaregistrypb.SchemaMode, error)
205 GetLocation(context.Context, *locationpb.GetLocationRequest, ...gax.CallOption) (*locationpb.Location, error)
206 ListLocations(context.Context, *locationpb.ListLocationsRequest, ...gax.CallOption) *LocationIterator
207 CancelOperation(context.Context, *longrunningpb.CancelOperationRequest, ...gax.CallOption) error
208 DeleteOperation(context.Context, *longrunningpb.DeleteOperationRequest, ...gax.CallOption) error
209 GetOperation(context.Context, *longrunningpb.GetOperationRequest, ...gax.CallOption) (*longrunningpb.Operation, error)
210 ListOperations(context.Context, *longrunningpb.ListOperationsRequest, ...gax.CallOption) *OperationIterator
211 }
212
213 // ManagedSchemaRegistryClient is a client for interacting with Managed Service for Apache Kafka API.
214 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
215 //
216 // SchemaRegistry is a service that allows users to manage schemas for their
217 // Kafka clusters. It provides APIs to register, list, and delete schemas, as
218 // well as to get the schema for a given schema id or a given version id under a
219 // subject, to update the global or subject-specific compatibility mode, and to
220 // check the compatibility of a schema against a subject or a version. The main
221 // resource hierarchy is as follows:
222 //
223 // SchemaRegistry
224 //
225 // SchemaRegistry/Context
226 //
227 // SchemaRegistry/Context/Schema
228 //
229 // SchemaRegistry/Context/Subject
230 //
231 // SchemaRegistry/Context/Subject/Version
232 //
233 // SchemaRegistry/Config
234 //
235 // SchemaRegistry/Mode
236 //
237 // SchemaRegistry is the root resource to represent a schema registry
238 // instance. A customer can have multiple schema registry instances in a
239 // project.
240 //
241 // Context is a context resource that represents a group of
242 // schemas, subjects and versions. A schema registry instance can have multiple
243 // contexts and always has a ‘default’ context. Contexts are independent of each
244 // other. Context is optional and if not specified, it falls back to the
245 // ‘default’ context.
246 //
247 // Schema is a schema resource that represents a unique schema in a context
248 // of a schema registry instance. Each schema has a unique schema id, and can be
249 // referenced by a version of a subject.
250 //
251 // Subject refers to the name under which the schema is registered. A
252 // typical subject is the Kafka topic name. A schema registry instance can have
253 // multiple subjects.
254 //
255 // Version represents a version of a subject. A subject can have multiple
256 // versions. Creation of new version of a subject is guarded by the
257 // compatibility mode configured globally or for the subject specifically.
258 //
259 // Config represents a config at global level cross all registry
260 // instances or at subject level. Currently, only compatibility is supported in
261 // config.
262 //
263 // Mode represents the mode of a schema registry or a specific subject.
264 // Three modes are supported:
265 //
266 // READONLY: The schema registry is in read-only mode, no write operations
267 // allowed…
268 //
269 // READWRITE: The schema registry is in read-write mode, which allows limited
270 // write operations on the schema.
271 //
272 // IMPORT: The schema registry is in import mode, which allows more editing
273 // operations on the schema for data importing purposes.
274 type ManagedSchemaRegistryClient struct {
275 // The internal transport-dependent client.
276 internalClient internalManagedSchemaRegistryClient
277
278 // The call options for this service.
279 CallOptions *ManagedSchemaRegistryCallOptions
280 }
281
282 // Wrapper methods routed to the internal client.
283
284 // Close closes the connection to the API service. The user should invoke this when
285 // the client is no longer required.
286 func (c *ManagedSchemaRegistryClient) Close() error {
287 return c.internalClient.Close()
288 }
289
290 // setGoogleClientInfo sets the name and version of the application in
291 // the `x-goog-api-client` header passed on each request. Intended for
292 // use by Google-written clients.
293 func (c *ManagedSchemaRegistryClient) setGoogleClientInfo(keyval ...string) {
294 c.internalClient.setGoogleClientInfo(keyval...)
295 }
296
297 // Connection returns a connection to the API service.
298 //
299 // Deprecated: Connections are now pooled so this method does not always
300 // return the same resource.
301 func (c *ManagedSchemaRegistryClient) Connection() *grpc.ClientConn {
302 return c.internalClient.Connection()
303 }
304
305 // GetSchemaRegistry get the schema registry instance.
306 func (c *ManagedSchemaRegistryClient) GetSchemaRegistry(ctx context.Context, req *schemaregistrypb.GetSchemaRegistryRequest, opts ...gax.CallOption) (*schemaregistrypb.SchemaRegistry, error) {
307 return c.internalClient.GetSchemaRegistry(ctx, req, opts...)
308 }
309
310 // ListSchemaRegistries list schema registries.
311 func (c *ManagedSchemaRegistryClient) ListSchemaRegistries(ctx context.Context, req *schemaregistrypb.ListSchemaRegistriesRequest, opts ...gax.CallOption) (*schemaregistrypb.ListSchemaRegistriesResponse, error) {
312 return c.internalClient.ListSchemaRegistries(ctx, req, opts...)
313 }
314
315 // CreateSchemaRegistry create a schema registry instance.
316 func (c *ManagedSchemaRegistryClient) CreateSchemaRegistry(ctx context.Context, req *schemaregistrypb.CreateSchemaRegistryRequest, opts ...gax.CallOption) (*schemaregistrypb.SchemaRegistry, error) {
317 return c.internalClient.CreateSchemaRegistry(ctx, req, opts...)
318 }
319
320 // DeleteSchemaRegistry delete a schema registry instance.
321 func (c *ManagedSchemaRegistryClient) DeleteSchemaRegistry(ctx context.Context, req *schemaregistrypb.DeleteSchemaRegistryRequest, opts ...gax.CallOption) error {
322 return c.internalClient.DeleteSchemaRegistry(ctx, req, opts...)
323 }
324
325 // GetContext get the context.
326 func (c *ManagedSchemaRegistryClient) GetContext(ctx context.Context, req *schemaregistrypb.GetContextRequest, opts ...gax.CallOption) (*schemaregistrypb.Context, error) {
327 return c.internalClient.GetContext(ctx, req, opts...)
328 }
329
330 // ListContexts list contexts for a schema registry.
331 func (c *ManagedSchemaRegistryClient) ListContexts(ctx context.Context, req *schemaregistrypb.ListContextsRequest, opts ...gax.CallOption) (*httpbodypb.HttpBody, error) {
332 return c.internalClient.ListContexts(ctx, req, opts...)
333 }
334
335 // GetSchema get the schema for the given schema id.
336 func (c *ManagedSchemaRegistryClient) GetSchema(ctx context.Context, req *schemaregistrypb.GetSchemaRequest, opts ...gax.CallOption) (*schemaregistrypb.Schema, error) {
337 return c.internalClient.GetSchema(ctx, req, opts...)
338 }
339
340 // GetRawSchema get the schema string for the given schema id.
341 // The response will be the schema string.
342 func (c *ManagedSchemaRegistryClient) GetRawSchema(ctx context.Context, req *schemaregistrypb.GetSchemaRequest, opts ...gax.CallOption) (*httpbodypb.HttpBody, error) {
343 return c.internalClient.GetRawSchema(ctx, req, opts...)
344 }
345
346 // ListSchemaVersions list the schema versions for the given schema id.
347 // The response will be an array of subject-version pairs as:
348 // [{“subject”:“subject1”, “version”:1}, {“subject”:“subject2”, “version”:2}].
349 func (c *ManagedSchemaRegistryClient) ListSchemaVersions(ctx context.Context, req *schemaregistrypb.ListSchemaVersionsRequest, opts ...gax.CallOption) (*httpbodypb.HttpBody, error) {
350 return c.internalClient.ListSchemaVersions(ctx, req, opts...)
351 }
352
353 // ListSchemaTypes list the supported schema types.
354 // The response will be an array of schema types.
355 func (c *ManagedSchemaRegistryClient) ListSchemaTypes(ctx context.Context, req *schemaregistrypb.ListSchemaTypesRequest, opts ...gax.CallOption) (*httpbodypb.HttpBody, error) {
356 return c.internalClient.ListSchemaTypes(ctx, req, opts...)
357 }
358
359 // ListSubjects list subjects in the schema registry.
360 // The response will be an array of subject names.
361 func (c *ManagedSchemaRegistryClient) ListSubjects(ctx context.Context, req *schemaregistrypb.ListSubjectsRequest, opts ...gax.CallOption) (*httpbodypb.HttpBody, error) {
362 return c.internalClient.ListSubjects(ctx, req, opts...)
363 }
364
365 // ListSubjectsBySchemaId list subjects which reference a particular schema id.
366 // The response will be an array of subject names.
367 func (c *ManagedSchemaRegistryClient) ListSubjectsBySchemaId(ctx context.Context, req *schemaregistrypb.ListSubjectsBySchemaIdRequest, opts ...gax.CallOption) (*httpbodypb.HttpBody, error) {
368 return c.internalClient.ListSubjectsBySchemaId(ctx, req, opts...)
369 }
370
371 // DeleteSubject delete a subject.
372 // The response will be an array of versions of the deleted subject.
373 func (c *ManagedSchemaRegistryClient) DeleteSubject(ctx context.Context, req *schemaregistrypb.DeleteSubjectRequest, opts ...gax.CallOption) (*httpbodypb.HttpBody, error) {
374 return c.internalClient.DeleteSubject(ctx, req, opts...)
375 }
376
377 // LookupVersion lookup a schema under the specified subject.
378 func (c *ManagedSchemaRegistryClient) LookupVersion(ctx context.Context, req *schemaregistrypb.LookupVersionRequest, opts ...gax.CallOption) (*schemaregistrypb.SchemaVersion, error) {
379 return c.internalClient.LookupVersion(ctx, req, opts...)
380 }
381
382 // GetVersion get a versioned schema (schema with subject/version) of a subject.
383 func (c *ManagedSchemaRegistryClient) GetVersion(ctx context.Context, req *schemaregistrypb.GetVersionRequest, opts ...gax.CallOption) (*schemaregistrypb.SchemaVersion, error) {
384 return c.internalClient.GetVersion(ctx, req, opts...)
385 }
386
387 // GetRawSchemaVersion get the schema string only for a version of a subject.
388 // The response will be the schema string.
389 func (c *ManagedSchemaRegistryClient) GetRawSchemaVersion(ctx context.Context, req *schemaregistrypb.GetVersionRequest, opts ...gax.CallOption) (*httpbodypb.HttpBody, error) {
390 return c.internalClient.GetRawSchemaVersion(ctx, req, opts...)
391 }
392
393 // ListVersions get all versions of a subject.
394 // The response will be an array of versions of the subject.
395 func (c *ManagedSchemaRegistryClient) ListVersions(ctx context.Context, req *schemaregistrypb.ListVersionsRequest, opts ...gax.CallOption) (*httpbodypb.HttpBody, error) {
396 return c.internalClient.ListVersions(ctx, req, opts...)
397 }
398
399 // CreateVersion register a new version under a given subject with the given schema.
400 func (c *ManagedSchemaRegistryClient) CreateVersion(ctx context.Context, req *schemaregistrypb.CreateVersionRequest, opts ...gax.CallOption) (*schemaregistrypb.CreateVersionResponse, error) {
401 return c.internalClient.CreateVersion(ctx, req, opts...)
402 }
403
404 // DeleteVersion delete a version of a subject.
405 // The response will be the deleted version id.
406 func (c *ManagedSchemaRegistryClient) DeleteVersion(ctx context.Context, req *schemaregistrypb.DeleteVersionRequest, opts ...gax.CallOption) (*httpbodypb.HttpBody, error) {
407 return c.internalClient.DeleteVersion(ctx, req, opts...)
408 }
409
410 // ListReferencedSchemas get a list of IDs of schemas that reference the schema with the given
411 // subject and version.
412 func (c *ManagedSchemaRegistryClient) ListReferencedSchemas(ctx context.Context, req *schemaregistrypb.ListReferencedSchemasRequest, opts ...gax.CallOption) (*httpbodypb.HttpBody, error) {
413 return c.internalClient.ListReferencedSchemas(ctx, req, opts...)
414 }
415
416 // CheckCompatibility check compatibility of a schema with all versions or a specific version of
417 // a subject.
418 func (c *ManagedSchemaRegistryClient) CheckCompatibility(ctx context.Context, req *schemaregistrypb.CheckCompatibilityRequest, opts ...gax.CallOption) (*schemaregistrypb.CheckCompatibilityResponse, error) {
419 return c.internalClient.CheckCompatibility(ctx, req, opts...)
420 }
421
422 // GetSchemaConfig get schema config at global level or for a subject.
423 func (c *ManagedSchemaRegistryClient) GetSchemaConfig(ctx context.Context, req *schemaregistrypb.GetSchemaConfigRequest, opts ...gax.CallOption) (*schemaregistrypb.SchemaConfig, error) {
424 return c.internalClient.GetSchemaConfig(ctx, req, opts...)
425 }
426
427 // UpdateSchemaConfig update config at global level or for a subject.
428 // Creates a SchemaSubject-level SchemaConfig if it does not exist.
429 func (c *ManagedSchemaRegistryClient) UpdateSchemaConfig(ctx context.Context, req *schemaregistrypb.UpdateSchemaConfigRequest, opts ...gax.CallOption) (*schemaregistrypb.SchemaConfig, error) {
430 return c.internalClient.UpdateSchemaConfig(ctx, req, opts...)
431 }
432
433 // DeleteSchemaConfig delete schema config for a subject.
434 func (c *ManagedSchemaRegistryClient) DeleteSchemaConfig(ctx context.Context, req *schemaregistrypb.DeleteSchemaConfigRequest, opts ...gax.CallOption) (*schemaregistrypb.SchemaConfig, error) {
435 return c.internalClient.DeleteSchemaConfig(ctx, req, opts...)
436 }
437
438 // GetSchemaMode get mode at global level or for a subject.
439 func (c *ManagedSchemaRegistryClient) GetSchemaMode(ctx context.Context, req *schemaregistrypb.GetSchemaModeRequest, opts ...gax.CallOption) (*schemaregistrypb.SchemaMode, error) {
440 return c.internalClient.GetSchemaMode(ctx, req, opts...)
441 }
442
443 // UpdateSchemaMode update mode at global level or for a subject.
444 func (c *ManagedSchemaRegistryClient) UpdateSchemaMode(ctx context.Context, req *schemaregistrypb.UpdateSchemaModeRequest, opts ...gax.CallOption) (*schemaregistrypb.SchemaMode, error) {
445 return c.internalClient.UpdateSchemaMode(ctx, req, opts...)
446 }
447
448 // DeleteSchemaMode delete schema mode for a subject.
449 func (c *ManagedSchemaRegistryClient) DeleteSchemaMode(ctx context.Context, req *schemaregistrypb.DeleteSchemaModeRequest, opts ...gax.CallOption) (*schemaregistrypb.SchemaMode, error) {
450 return c.internalClient.DeleteSchemaMode(ctx, req, opts...)
451 }
452
453 // GetLocation gets information about a location.
454 func (c *ManagedSchemaRegistryClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
455 return c.internalClient.GetLocation(ctx, req, opts...)
456 }
457
458 // ListLocations lists information about the supported locations for this service.
459 func (c *ManagedSchemaRegistryClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
460 return c.internalClient.ListLocations(ctx, req, opts...)
461 }
462
463 // CancelOperation is a utility method from google.longrunning.Operations.
464 func (c *ManagedSchemaRegistryClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
465 return c.internalClient.CancelOperation(ctx, req, opts...)
466 }
467
468 // DeleteOperation is a utility method from google.longrunning.Operations.
469 func (c *ManagedSchemaRegistryClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error {
470 return c.internalClient.DeleteOperation(ctx, req, opts...)
471 }
472
473 // GetOperation is a utility method from google.longrunning.Operations.
474 func (c *ManagedSchemaRegistryClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
475 return c.internalClient.GetOperation(ctx, req, opts...)
476 }
477
478 // ListOperations is a utility method from google.longrunning.Operations.
479 func (c *ManagedSchemaRegistryClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
480 return c.internalClient.ListOperations(ctx, req, opts...)
481 }
482
483 // managedSchemaRegistryGRPCClient is a client for interacting with Managed Service for Apache Kafka API over gRPC transport.
484 //
485 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
486 type managedSchemaRegistryGRPCClient struct {
487 // Connection pool of gRPC connections to the service.
488 connPool gtransport.ConnPool
489
490 // Points back to the CallOptions field of the containing ManagedSchemaRegistryClient
491 CallOptions **ManagedSchemaRegistryCallOptions
492
493 // The gRPC API client.
494 managedSchemaRegistryClient schemaregistrypb.ManagedSchemaRegistryClient
495
496 operationsClient longrunningpb.OperationsClient
497
498 locationsClient locationpb.LocationsClient
499
500 // The x-goog-* metadata to be sent with each request.
501 xGoogHeaders []string
502
503 logger *slog.Logger
504 }
505
506 // NewManagedSchemaRegistryClient creates a new managed schema registry client based on gRPC.
507 // The returned client must be Closed when it is done being used to clean up its underlying connections.
508 //
509 // SchemaRegistry is a service that allows users to manage schemas for their
510 // Kafka clusters. It provides APIs to register, list, and delete schemas, as
511 // well as to get the schema for a given schema id or a given version id under a
512 // subject, to update the global or subject-specific compatibility mode, and to
513 // check the compatibility of a schema against a subject or a version. The main
514 // resource hierarchy is as follows:
515 //
516 // SchemaRegistry
517 //
518 // SchemaRegistry/Context
519 //
520 // SchemaRegistry/Context/Schema
521 //
522 // SchemaRegistry/Context/Subject
523 //
524 // SchemaRegistry/Context/Subject/Version
525 //
526 // SchemaRegistry/Config
527 //
528 // SchemaRegistry/Mode
529 //
530 // SchemaRegistry is the root resource to represent a schema registry
531 // instance. A customer can have multiple schema registry instances in a
532 // project.
533 //
534 // Context is a context resource that represents a group of
535 // schemas, subjects and versions. A schema registry instance can have multiple
536 // contexts and always has a ‘default’ context. Contexts are independent of each
537 // other. Context is optional and if not specified, it falls back to the
538 // ‘default’ context.
539 //
540 // Schema is a schema resource that represents a unique schema in a context
541 // of a schema registry instance. Each schema has a unique schema id, and can be
542 // referenced by a version of a subject.
543 //
544 // Subject refers to the name under which the schema is registered. A
545 // typical subject is the Kafka topic name. A schema registry instance can have
546 // multiple subjects.
547 //
548 // Version represents a version of a subject. A subject can have multiple
549 // versions. Creation of new version of a subject is guarded by the
550 // compatibility mode configured globally or for the subject specifically.
551 //
552 // Config represents a config at global level cross all registry
553 // instances or at subject level. Currently, only compatibility is supported in
554 // config.
555 //
556 // Mode represents the mode of a schema registry or a specific subject.
557 // Three modes are supported:
558 //
559 // READONLY: The schema registry is in read-only mode, no write operations
560 // allowed…
561 //
562 // READWRITE: The schema registry is in read-write mode, which allows limited
563 // write operations on the schema.
564 //
565 // IMPORT: The schema registry is in import mode, which allows more editing
566 // operations on the schema for data importing purposes.
567 func NewManagedSchemaRegistryClient(ctx context.Context, opts ...option.ClientOption) (*ManagedSchemaRegistryClient, error) {
568 clientOpts := defaultManagedSchemaRegistryGRPCClientOptions()
569 if newManagedSchemaRegistryClientHook != nil {
570 hookOpts, err := newManagedSchemaRegistryClientHook(ctx, clientHookParams{})
571 if err != nil {
572 return nil, err
573 }
574 clientOpts = append(clientOpts, hookOpts...)
575 }
576
577 connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)
578 if err != nil {
579 return nil, err
580 }
581 client := ManagedSchemaRegistryClient{CallOptions: defaultManagedSchemaRegistryCallOptions()}
582
583 c := &managedSchemaRegistryGRPCClient{
584 connPool: connPool,
585 managedSchemaRegistryClient: schemaregistrypb.NewManagedSchemaRegistryClient(connPool),
586 CallOptions: &client.CallOptions,
587 logger: internaloption.GetLogger(opts),
588 operationsClient: longrunningpb.NewOperationsClient(connPool),
589 locationsClient: locationpb.NewLocationsClient(connPool),
590 }
591 c.setGoogleClientInfo()
592
593 client.internalClient = c
594
595 return &client, nil
596 }
597
598 // Connection returns a connection to the API service.
599 //
600 // Deprecated: Connections are now pooled so this method does not always
601 // return the same resource.
602 func (c *managedSchemaRegistryGRPCClient) Connection() *grpc.ClientConn {
603 return c.connPool.Conn()
604 }
605
606 // setGoogleClientInfo sets the name and version of the application in
607 // the `x-goog-api-client` header passed on each request. Intended for
608 // use by Google-written clients.
609 func (c *managedSchemaRegistryGRPCClient) setGoogleClientInfo(keyval ...string) {
610 kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
611 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version, "pb", protoVersion)
612 c.xGoogHeaders = []string{
613 "x-goog-api-client", gax.XGoogHeader(kv...),
614 }
615 }
616
617 // Close closes the connection to the API service. The user should invoke this when
618 // the client is no longer required.
619 func (c *managedSchemaRegistryGRPCClient) Close() error {
620 return c.connPool.Close()
621 }
622
623 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
624 type managedSchemaRegistryRESTClient struct {
625 // The http endpoint to connect to.
626 endpoint string
627
628 // The http client.
629 httpClient *http.Client
630
631 // The x-goog-* headers to be sent with each request.
632 xGoogHeaders []string
633
634 // Points back to the CallOptions field of the containing ManagedSchemaRegistryClient
635 CallOptions **ManagedSchemaRegistryCallOptions
636
637 logger *slog.Logger
638 }
639
640 // NewManagedSchemaRegistryRESTClient creates a new managed schema registry rest client.
641 //
642 // SchemaRegistry is a service that allows users to manage schemas for their
643 // Kafka clusters. It provides APIs to register, list, and delete schemas, as
644 // well as to get the schema for a given schema id or a given version id under a
645 // subject, to update the global or subject-specific compatibility mode, and to
646 // check the compatibility of a schema against a subject or a version. The main
647 // resource hierarchy is as follows:
648 //
649 // SchemaRegistry
650 //
651 // SchemaRegistry/Context
652 //
653 // SchemaRegistry/Context/Schema
654 //
655 // SchemaRegistry/Context/Subject
656 //
657 // SchemaRegistry/Context/Subject/Version
658 //
659 // SchemaRegistry/Config
660 //
661 // SchemaRegistry/Mode
662 //
663 // SchemaRegistry is the root resource to represent a schema registry
664 // instance. A customer can have multiple schema registry instances in a
665 // project.
666 //
667 // Context is a context resource that represents a group of
668 // schemas, subjects and versions. A schema registry instance can have multiple
669 // contexts and always has a ‘default’ context. Contexts are independent of each
670 // other. Context is optional and if not specified, it falls back to the
671 // ‘default’ context.
672 //
673 // Schema is a schema resource that represents a unique schema in a context
674 // of a schema registry instance. Each schema has a unique schema id, and can be
675 // referenced by a version of a subject.
676 //
677 // Subject refers to the name under which the schema is registered. A
678 // typical subject is the Kafka topic name. A schema registry instance can have
679 // multiple subjects.
680 //
681 // Version represents a version of a subject. A subject can have multiple
682 // versions. Creation of new version of a subject is guarded by the
683 // compatibility mode configured globally or for the subject specifically.
684 //
685 // Config represents a config at global level cross all registry
686 // instances or at subject level. Currently, only compatibility is supported in
687 // config.
688 //
689 // Mode represents the mode of a schema registry or a specific subject.
690 // Three modes are supported:
691 //
692 // READONLY: The schema registry is in read-only mode, no write operations
693 // allowed…
694 //
695 // READWRITE: The schema registry is in read-write mode, which allows limited
696 // write operations on the schema.
697 //
698 // IMPORT: The schema registry is in import mode, which allows more editing
699 // operations on the schema for data importing purposes.
700 func NewManagedSchemaRegistryRESTClient(ctx context.Context, opts ...option.ClientOption) (*ManagedSchemaRegistryClient, error) {
701 clientOpts := append(defaultManagedSchemaRegistryRESTClientOptions(), opts...)
702 httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...)
703 if err != nil {
704 return nil, err
705 }
706
707 callOpts := defaultManagedSchemaRegistryRESTCallOptions()
708 c := &managedSchemaRegistryRESTClient{
709 endpoint: endpoint,
710 httpClient: httpClient,
711 CallOptions: &callOpts,
712 logger: internaloption.GetLogger(opts),
713 }
714 c.setGoogleClientInfo()
715
716 return &ManagedSchemaRegistryClient{internalClient: c, CallOptions: callOpts}, nil
717 }
718
719 func defaultManagedSchemaRegistryRESTClientOptions() []option.ClientOption {
720 return []option.ClientOption{
721 internaloption.WithDefaultEndpoint("https://managedkafka.googleapis.com"),
722 internaloption.WithDefaultEndpointTemplate("https://managedkafka.UNIVERSE_DOMAIN"),
723 internaloption.WithDefaultMTLSEndpoint("https://managedkafka.mtls.googleapis.com"),
724 internaloption.WithDefaultUniverseDomain("googleapis.com"),
725 internaloption.WithDefaultAudience("https://managedkafka.googleapis.com/"),
726 internaloption.WithDefaultScopes(DefaultAuthScopes()...),
727 internaloption.EnableNewAuthLibrary(),
728 }
729 }
730
731 // setGoogleClientInfo sets the name and version of the application in
732 // the `x-goog-api-client` header passed on each request. Intended for
733 // use by Google-written clients.
734 func (c *managedSchemaRegistryRESTClient) setGoogleClientInfo(keyval ...string) {
735 kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
736 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
737 c.xGoogHeaders = []string{
738 "x-goog-api-client", gax.XGoogHeader(kv...),
739 }
740 }
741
742 // Close closes the connection to the API service. The user should invoke this when
743 // the client is no longer required.
744 func (c *managedSchemaRegistryRESTClient) Close() error {
745 // Replace httpClient with nil to force cleanup.
746 c.httpClient = nil
747 return nil
748 }
749
750 // Connection returns a connection to the API service.
751 //
752 // Deprecated: This method always returns nil.
753 func (c *managedSchemaRegistryRESTClient) Connection() *grpc.ClientConn {
754 return nil
755 }
756 func (c *managedSchemaRegistryGRPCClient) GetSchemaRegistry(ctx context.Context, req *schemaregistrypb.GetSchemaRegistryRequest, opts ...gax.CallOption) (*schemaregistrypb.SchemaRegistry, error) {
757 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
758
759 hds = append(c.xGoogHeaders, hds...)
760 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
761 opts = append((*c.CallOptions).GetSchemaRegistry[0:len((*c.CallOptions).GetSchemaRegistry):len((*c.CallOptions).GetSchemaRegistry)], opts...)
762 var resp *schemaregistrypb.SchemaRegistry
763 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
764 var err error
765 resp, err = executeRPC(ctx, c.managedSchemaRegistryClient.GetSchemaRegistry, req, settings.GRPC, c.logger, "GetSchemaRegistry")
766 return err
767 }, opts...)
768 if err != nil {
769 return nil, err
770 }
771 return resp, nil
772 }
773
774 func (c *managedSchemaRegistryGRPCClient) ListSchemaRegistries(ctx context.Context, req *schemaregistrypb.ListSchemaRegistriesRequest, opts ...gax.CallOption) (*schemaregistrypb.ListSchemaRegistriesResponse, error) {
775 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
776
777 hds = append(c.xGoogHeaders, hds...)
778 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
779 opts = append((*c.CallOptions).ListSchemaRegistries[0:len((*c.CallOptions).ListSchemaRegistries):len((*c.CallOptions).ListSchemaRegistries)], opts...)
780 var resp *schemaregistrypb.ListSchemaRegistriesResponse
781 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
782 var err error
783 resp, err = executeRPC(ctx, c.managedSchemaRegistryClient.ListSchemaRegistries, req, settings.GRPC, c.logger, "ListSchemaRegistries")
784 return err
785 }, opts...)
786 if err != nil {
787 return nil, err
788 }
789 return resp, nil
790 }
791
792 func (c *managedSchemaRegistryGRPCClient) CreateSchemaRegistry(ctx context.Context, req *schemaregistrypb.CreateSchemaRegistryRequest, opts ...gax.CallOption) (*schemaregistrypb.SchemaRegistry, error) {
793 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
794
795 hds = append(c.xGoogHeaders, hds...)
796 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
797 opts = append((*c.CallOptions).CreateSchemaRegistry[0:len((*c.CallOptions).CreateSchemaRegistry):len((*c.CallOptions).CreateSchemaRegistry)], opts...)
798 var resp *schemaregistrypb.SchemaRegistry
799 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
800 var err error
801 resp, err = executeRPC(ctx, c.managedSchemaRegistryClient.CreateSchemaRegistry, req, settings.GRPC, c.logger, "CreateSchemaRegistry")
802 return err
803 }, opts...)
804 if err != nil {
805 return nil, err
806 }
807 return resp, nil
808 }
809
810 func (c *managedSchemaRegistryGRPCClient) DeleteSchemaRegistry(ctx context.Context, req *schemaregistrypb.DeleteSchemaRegistryRequest, opts ...gax.CallOption) error {
811 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
812
813 hds = append(c.xGoogHeaders, hds...)
814 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
815 opts = append((*c.CallOptions).DeleteSchemaRegistry[0:len((*c.CallOptions).DeleteSchemaRegistry):len((*c.CallOptions).DeleteSchemaRegistry)], opts...)
816 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
817 var err error
818 _, err = executeRPC(ctx, c.managedSchemaRegistryClient.DeleteSchemaRegistry, req, settings.GRPC, c.logger, "DeleteSchemaRegistry")
819 return err
820 }, opts...)
821 return err
822 }
823
824 func (c *managedSchemaRegistryGRPCClient) GetContext(ctx context.Context, req *schemaregistrypb.GetContextRequest, opts ...gax.CallOption) (*schemaregistrypb.Context, error) {
825 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
826
827 hds = append(c.xGoogHeaders, hds...)
828 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
829 opts = append((*c.CallOptions).GetContext[0:len((*c.CallOptions).GetContext):len((*c.CallOptions).GetContext)], opts...)
830 var resp *schemaregistrypb.Context
831 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
832 var err error
833 resp, err = executeRPC(ctx, c.managedSchemaRegistryClient.GetContext, req, settings.GRPC, c.logger, "GetContext")
834 return err
835 }, opts...)
836 if err != nil {
837 return nil, err
838 }
839 return resp, nil
840 }
841
842 func (c *managedSchemaRegistryGRPCClient) ListContexts(ctx context.Context, req *schemaregistrypb.ListContextsRequest, opts ...gax.CallOption) (*httpbodypb.HttpBody, error) {
843 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
844
845 hds = append(c.xGoogHeaders, hds...)
846 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
847 opts = append((*c.CallOptions).ListContexts[0:len((*c.CallOptions).ListContexts):len((*c.CallOptions).ListContexts)], opts...)
848 var resp *httpbodypb.HttpBody
849 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
850 var err error
851 resp, err = executeRPC(ctx, c.managedSchemaRegistryClient.ListContexts, req, settings.GRPC, c.logger, "ListContexts")
852 return err
853 }, opts...)
854 if err != nil {
855 return nil, err
856 }
857 return resp, nil
858 }
859
860 func (c *managedSchemaRegistryGRPCClient) GetSchema(ctx context.Context, req *schemaregistrypb.GetSchemaRequest, opts ...gax.CallOption) (*schemaregistrypb.Schema, error) {
861 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
862
863 hds = append(c.xGoogHeaders, hds...)
864 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
865 opts = append((*c.CallOptions).GetSchema[0:len((*c.CallOptions).GetSchema):len((*c.CallOptions).GetSchema)], opts...)
866 var resp *schemaregistrypb.Schema
867 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
868 var err error
869 resp, err = executeRPC(ctx, c.managedSchemaRegistryClient.GetSchema, req, settings.GRPC, c.logger, "GetSchema")
870 return err
871 }, opts...)
872 if err != nil {
873 return nil, err
874 }
875 return resp, nil
876 }
877
878 func (c *managedSchemaRegistryGRPCClient) GetRawSchema(ctx context.Context, req *schemaregistrypb.GetSchemaRequest, opts ...gax.CallOption) (*httpbodypb.HttpBody, error) {
879 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
880
881 hds = append(c.xGoogHeaders, hds...)
882 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
883 opts = append((*c.CallOptions).GetRawSchema[0:len((*c.CallOptions).GetRawSchema):len((*c.CallOptions).GetRawSchema)], opts...)
884 var resp *httpbodypb.HttpBody
885 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
886 var err error
887 resp, err = executeRPC(ctx, c.managedSchemaRegistryClient.GetRawSchema, req, settings.GRPC, c.logger, "GetRawSchema")
888 return err
889 }, opts...)
890 if err != nil {
891 return nil, err
892 }
893 return resp, nil
894 }
895
896 func (c *managedSchemaRegistryGRPCClient) ListSchemaVersions(ctx context.Context, req *schemaregistrypb.ListSchemaVersionsRequest, opts ...gax.CallOption) (*httpbodypb.HttpBody, error) {
897 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
898
899 hds = append(c.xGoogHeaders, hds...)
900 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
901 opts = append((*c.CallOptions).ListSchemaVersions[0:len((*c.CallOptions).ListSchemaVersions):len((*c.CallOptions).ListSchemaVersions)], opts...)
902 var resp *httpbodypb.HttpBody
903 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
904 var err error
905 resp, err = executeRPC(ctx, c.managedSchemaRegistryClient.ListSchemaVersions, req, settings.GRPC, c.logger, "ListSchemaVersions")
906 return err
907 }, opts...)
908 if err != nil {
909 return nil, err
910 }
911 return resp, nil
912 }
913
914 func (c *managedSchemaRegistryGRPCClient) ListSchemaTypes(ctx context.Context, req *schemaregistrypb.ListSchemaTypesRequest, opts ...gax.CallOption) (*httpbodypb.HttpBody, error) {
915 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
916
917 hds = append(c.xGoogHeaders, hds...)
918 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
919 opts = append((*c.CallOptions).ListSchemaTypes[0:len((*c.CallOptions).ListSchemaTypes):len((*c.CallOptions).ListSchemaTypes)], opts...)
920 var resp *httpbodypb.HttpBody
921 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
922 var err error
923 resp, err = executeRPC(ctx, c.managedSchemaRegistryClient.ListSchemaTypes, req, settings.GRPC, c.logger, "ListSchemaTypes")
924 return err
925 }, opts...)
926 if err != nil {
927 return nil, err
928 }
929 return resp, nil
930 }
931
932 func (c *managedSchemaRegistryGRPCClient) ListSubjects(ctx context.Context, req *schemaregistrypb.ListSubjectsRequest, opts ...gax.CallOption) (*httpbodypb.HttpBody, error) {
933 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
934
935 hds = append(c.xGoogHeaders, hds...)
936 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
937 opts = append((*c.CallOptions).ListSubjects[0:len((*c.CallOptions).ListSubjects):len((*c.CallOptions).ListSubjects)], opts...)
938 var resp *httpbodypb.HttpBody
939 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
940 var err error
941 resp, err = executeRPC(ctx, c.managedSchemaRegistryClient.ListSubjects, req, settings.GRPC, c.logger, "ListSubjects")
942 return err
943 }, opts...)
944 if err != nil {
945 return nil, err
946 }
947 return resp, nil
948 }
949
950 func (c *managedSchemaRegistryGRPCClient) ListSubjectsBySchemaId(ctx context.Context, req *schemaregistrypb.ListSubjectsBySchemaIdRequest, opts ...gax.CallOption) (*httpbodypb.HttpBody, error) {
951 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
952
953 hds = append(c.xGoogHeaders, hds...)
954 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
955 opts = append((*c.CallOptions).ListSubjectsBySchemaId[0:len((*c.CallOptions).ListSubjectsBySchemaId):len((*c.CallOptions).ListSubjectsBySchemaId)], opts...)
956 var resp *httpbodypb.HttpBody
957 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
958 var err error
959 resp, err = executeRPC(ctx, c.managedSchemaRegistryClient.ListSubjectsBySchemaId, req, settings.GRPC, c.logger, "ListSubjectsBySchemaId")
960 return err
961 }, opts...)
962 if err != nil {
963 return nil, err
964 }
965 return resp, nil
966 }
967
968 func (c *managedSchemaRegistryGRPCClient) DeleteSubject(ctx context.Context, req *schemaregistrypb.DeleteSubjectRequest, opts ...gax.CallOption) (*httpbodypb.HttpBody, error) {
969 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
970
971 hds = append(c.xGoogHeaders, hds...)
972 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
973 opts = append((*c.CallOptions).DeleteSubject[0:len((*c.CallOptions).DeleteSubject):len((*c.CallOptions).DeleteSubject)], opts...)
974 var resp *httpbodypb.HttpBody
975 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
976 var err error
977 resp, err = executeRPC(ctx, c.managedSchemaRegistryClient.DeleteSubject, req, settings.GRPC, c.logger, "DeleteSubject")
978 return err
979 }, opts...)
980 if err != nil {
981 return nil, err
982 }
983 return resp, nil
984 }
985
986 func (c *managedSchemaRegistryGRPCClient) LookupVersion(ctx context.Context, req *schemaregistrypb.LookupVersionRequest, opts ...gax.CallOption) (*schemaregistrypb.SchemaVersion, error) {
987 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
988
989 hds = append(c.xGoogHeaders, hds...)
990 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
991 opts = append((*c.CallOptions).LookupVersion[0:len((*c.CallOptions).LookupVersion):len((*c.CallOptions).LookupVersion)], opts...)
992 var resp *schemaregistrypb.SchemaVersion
993 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
994 var err error
995 resp, err = executeRPC(ctx, c.managedSchemaRegistryClient.LookupVersion, req, settings.GRPC, c.logger, "LookupVersion")
996 return err
997 }, opts...)
998 if err != nil {
999 return nil, err
1000 }
1001 return resp, nil
1002 }
1003
1004 func (c *managedSchemaRegistryGRPCClient) GetVersion(ctx context.Context, req *schemaregistrypb.GetVersionRequest, opts ...gax.CallOption) (*schemaregistrypb.SchemaVersion, error) {
1005 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1006
1007 hds = append(c.xGoogHeaders, hds...)
1008 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1009 opts = append((*c.CallOptions).GetVersion[0:len((*c.CallOptions).GetVersion):len((*c.CallOptions).GetVersion)], opts...)
1010 var resp *schemaregistrypb.SchemaVersion
1011 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1012 var err error
1013 resp, err = executeRPC(ctx, c.managedSchemaRegistryClient.GetVersion, req, settings.GRPC, c.logger, "GetVersion")
1014 return err
1015 }, opts...)
1016 if err != nil {
1017 return nil, err
1018 }
1019 return resp, nil
1020 }
1021
1022 func (c *managedSchemaRegistryGRPCClient) GetRawSchemaVersion(ctx context.Context, req *schemaregistrypb.GetVersionRequest, opts ...gax.CallOption) (*httpbodypb.HttpBody, error) {
1023 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1024
1025 hds = append(c.xGoogHeaders, hds...)
1026 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1027 opts = append((*c.CallOptions).GetRawSchemaVersion[0:len((*c.CallOptions).GetRawSchemaVersion):len((*c.CallOptions).GetRawSchemaVersion)], opts...)
1028 var resp *httpbodypb.HttpBody
1029 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1030 var err error
1031 resp, err = executeRPC(ctx, c.managedSchemaRegistryClient.GetRawSchemaVersion, req, settings.GRPC, c.logger, "GetRawSchemaVersion")
1032 return err
1033 }, opts...)
1034 if err != nil {
1035 return nil, err
1036 }
1037 return resp, nil
1038 }
1039
1040 func (c *managedSchemaRegistryGRPCClient) ListVersions(ctx context.Context, req *schemaregistrypb.ListVersionsRequest, opts ...gax.CallOption) (*httpbodypb.HttpBody, error) {
1041 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1042
1043 hds = append(c.xGoogHeaders, hds...)
1044 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1045 opts = append((*c.CallOptions).ListVersions[0:len((*c.CallOptions).ListVersions):len((*c.CallOptions).ListVersions)], opts...)
1046 var resp *httpbodypb.HttpBody
1047 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1048 var err error
1049 resp, err = executeRPC(ctx, c.managedSchemaRegistryClient.ListVersions, req, settings.GRPC, c.logger, "ListVersions")
1050 return err
1051 }, opts...)
1052 if err != nil {
1053 return nil, err
1054 }
1055 return resp, nil
1056 }
1057
1058 func (c *managedSchemaRegistryGRPCClient) CreateVersion(ctx context.Context, req *schemaregistrypb.CreateVersionRequest, opts ...gax.CallOption) (*schemaregistrypb.CreateVersionResponse, error) {
1059 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1060
1061 hds = append(c.xGoogHeaders, hds...)
1062 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1063 opts = append((*c.CallOptions).CreateVersion[0:len((*c.CallOptions).CreateVersion):len((*c.CallOptions).CreateVersion)], opts...)
1064 var resp *schemaregistrypb.CreateVersionResponse
1065 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1066 var err error
1067 resp, err = executeRPC(ctx, c.managedSchemaRegistryClient.CreateVersion, req, settings.GRPC, c.logger, "CreateVersion")
1068 return err
1069 }, opts...)
1070 if err != nil {
1071 return nil, err
1072 }
1073 return resp, nil
1074 }
1075
1076 func (c *managedSchemaRegistryGRPCClient) DeleteVersion(ctx context.Context, req *schemaregistrypb.DeleteVersionRequest, opts ...gax.CallOption) (*httpbodypb.HttpBody, error) {
1077 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1078
1079 hds = append(c.xGoogHeaders, hds...)
1080 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1081 opts = append((*c.CallOptions).DeleteVersion[0:len((*c.CallOptions).DeleteVersion):len((*c.CallOptions).DeleteVersion)], opts...)
1082 var resp *httpbodypb.HttpBody
1083 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1084 var err error
1085 resp, err = executeRPC(ctx, c.managedSchemaRegistryClient.DeleteVersion, req, settings.GRPC, c.logger, "DeleteVersion")
1086 return err
1087 }, opts...)
1088 if err != nil {
1089 return nil, err
1090 }
1091 return resp, nil
1092 }
1093
1094 func (c *managedSchemaRegistryGRPCClient) ListReferencedSchemas(ctx context.Context, req *schemaregistrypb.ListReferencedSchemasRequest, opts ...gax.CallOption) (*httpbodypb.HttpBody, error) {
1095 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1096
1097 hds = append(c.xGoogHeaders, hds...)
1098 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1099 opts = append((*c.CallOptions).ListReferencedSchemas[0:len((*c.CallOptions).ListReferencedSchemas):len((*c.CallOptions).ListReferencedSchemas)], opts...)
1100 var resp *httpbodypb.HttpBody
1101 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1102 var err error
1103 resp, err = executeRPC(ctx, c.managedSchemaRegistryClient.ListReferencedSchemas, req, settings.GRPC, c.logger, "ListReferencedSchemas")
1104 return err
1105 }, opts...)
1106 if err != nil {
1107 return nil, err
1108 }
1109 return resp, nil
1110 }
1111
1112 func (c *managedSchemaRegistryGRPCClient) CheckCompatibility(ctx context.Context, req *schemaregistrypb.CheckCompatibilityRequest, opts ...gax.CallOption) (*schemaregistrypb.CheckCompatibilityResponse, error) {
1113 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1114
1115 hds = append(c.xGoogHeaders, hds...)
1116 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1117 opts = append((*c.CallOptions).CheckCompatibility[0:len((*c.CallOptions).CheckCompatibility):len((*c.CallOptions).CheckCompatibility)], opts...)
1118 var resp *schemaregistrypb.CheckCompatibilityResponse
1119 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1120 var err error
1121 resp, err = executeRPC(ctx, c.managedSchemaRegistryClient.CheckCompatibility, req, settings.GRPC, c.logger, "CheckCompatibility")
1122 return err
1123 }, opts...)
1124 if err != nil {
1125 return nil, err
1126 }
1127 return resp, nil
1128 }
1129
1130 func (c *managedSchemaRegistryGRPCClient) GetSchemaConfig(ctx context.Context, req *schemaregistrypb.GetSchemaConfigRequest, opts ...gax.CallOption) (*schemaregistrypb.SchemaConfig, error) {
1131 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1132
1133 hds = append(c.xGoogHeaders, hds...)
1134 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1135 opts = append((*c.CallOptions).GetSchemaConfig[0:len((*c.CallOptions).GetSchemaConfig):len((*c.CallOptions).GetSchemaConfig)], opts...)
1136 var resp *schemaregistrypb.SchemaConfig
1137 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1138 var err error
1139 resp, err = executeRPC(ctx, c.managedSchemaRegistryClient.GetSchemaConfig, req, settings.GRPC, c.logger, "GetSchemaConfig")
1140 return err
1141 }, opts...)
1142 if err != nil {
1143 return nil, err
1144 }
1145 return resp, nil
1146 }
1147
1148 func (c *managedSchemaRegistryGRPCClient) UpdateSchemaConfig(ctx context.Context, req *schemaregistrypb.UpdateSchemaConfigRequest, opts ...gax.CallOption) (*schemaregistrypb.SchemaConfig, error) {
1149 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1150
1151 hds = append(c.xGoogHeaders, hds...)
1152 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1153 opts = append((*c.CallOptions).UpdateSchemaConfig[0:len((*c.CallOptions).UpdateSchemaConfig):len((*c.CallOptions).UpdateSchemaConfig)], opts...)
1154 var resp *schemaregistrypb.SchemaConfig
1155 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1156 var err error
1157 resp, err = executeRPC(ctx, c.managedSchemaRegistryClient.UpdateSchemaConfig, req, settings.GRPC, c.logger, "UpdateSchemaConfig")
1158 return err
1159 }, opts...)
1160 if err != nil {
1161 return nil, err
1162 }
1163 return resp, nil
1164 }
1165
1166 func (c *managedSchemaRegistryGRPCClient) DeleteSchemaConfig(ctx context.Context, req *schemaregistrypb.DeleteSchemaConfigRequest, opts ...gax.CallOption) (*schemaregistrypb.SchemaConfig, error) {
1167 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1168
1169 hds = append(c.xGoogHeaders, hds...)
1170 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1171 opts = append((*c.CallOptions).DeleteSchemaConfig[0:len((*c.CallOptions).DeleteSchemaConfig):len((*c.CallOptions).DeleteSchemaConfig)], opts...)
1172 var resp *schemaregistrypb.SchemaConfig
1173 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1174 var err error
1175 resp, err = executeRPC(ctx, c.managedSchemaRegistryClient.DeleteSchemaConfig, req, settings.GRPC, c.logger, "DeleteSchemaConfig")
1176 return err
1177 }, opts...)
1178 if err != nil {
1179 return nil, err
1180 }
1181 return resp, nil
1182 }
1183
1184 func (c *managedSchemaRegistryGRPCClient) GetSchemaMode(ctx context.Context, req *schemaregistrypb.GetSchemaModeRequest, opts ...gax.CallOption) (*schemaregistrypb.SchemaMode, error) {
1185 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1186
1187 hds = append(c.xGoogHeaders, hds...)
1188 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1189 opts = append((*c.CallOptions).GetSchemaMode[0:len((*c.CallOptions).GetSchemaMode):len((*c.CallOptions).GetSchemaMode)], opts...)
1190 var resp *schemaregistrypb.SchemaMode
1191 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1192 var err error
1193 resp, err = executeRPC(ctx, c.managedSchemaRegistryClient.GetSchemaMode, req, settings.GRPC, c.logger, "GetSchemaMode")
1194 return err
1195 }, opts...)
1196 if err != nil {
1197 return nil, err
1198 }
1199 return resp, nil
1200 }
1201
1202 func (c *managedSchemaRegistryGRPCClient) UpdateSchemaMode(ctx context.Context, req *schemaregistrypb.UpdateSchemaModeRequest, opts ...gax.CallOption) (*schemaregistrypb.SchemaMode, error) {
1203 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1204
1205 hds = append(c.xGoogHeaders, hds...)
1206 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1207 opts = append((*c.CallOptions).UpdateSchemaMode[0:len((*c.CallOptions).UpdateSchemaMode):len((*c.CallOptions).UpdateSchemaMode)], opts...)
1208 var resp *schemaregistrypb.SchemaMode
1209 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1210 var err error
1211 resp, err = executeRPC(ctx, c.managedSchemaRegistryClient.UpdateSchemaMode, req, settings.GRPC, c.logger, "UpdateSchemaMode")
1212 return err
1213 }, opts...)
1214 if err != nil {
1215 return nil, err
1216 }
1217 return resp, nil
1218 }
1219
1220 func (c *managedSchemaRegistryGRPCClient) DeleteSchemaMode(ctx context.Context, req *schemaregistrypb.DeleteSchemaModeRequest, opts ...gax.CallOption) (*schemaregistrypb.SchemaMode, error) {
1221 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1222
1223 hds = append(c.xGoogHeaders, hds...)
1224 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1225 opts = append((*c.CallOptions).DeleteSchemaMode[0:len((*c.CallOptions).DeleteSchemaMode):len((*c.CallOptions).DeleteSchemaMode)], opts...)
1226 var resp *schemaregistrypb.SchemaMode
1227 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1228 var err error
1229 resp, err = executeRPC(ctx, c.managedSchemaRegistryClient.DeleteSchemaMode, req, settings.GRPC, c.logger, "DeleteSchemaMode")
1230 return err
1231 }, opts...)
1232 if err != nil {
1233 return nil, err
1234 }
1235 return resp, nil
1236 }
1237
1238 func (c *managedSchemaRegistryGRPCClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
1239 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1240
1241 hds = append(c.xGoogHeaders, hds...)
1242 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1243 opts = append((*c.CallOptions).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...)
1244 var resp *locationpb.Location
1245 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1246 var err error
1247 resp, err = executeRPC(ctx, c.locationsClient.GetLocation, req, settings.GRPC, c.logger, "GetLocation")
1248 return err
1249 }, opts...)
1250 if err != nil {
1251 return nil, err
1252 }
1253 return resp, nil
1254 }
1255
1256 func (c *managedSchemaRegistryGRPCClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
1257 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1258
1259 hds = append(c.xGoogHeaders, hds...)
1260 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1261 opts = append((*c.CallOptions).ListLocations[0:len((*c.CallOptions).ListLocations):len((*c.CallOptions).ListLocations)], opts...)
1262 it := &LocationIterator{}
1263 req = proto.Clone(req).(*locationpb.ListLocationsRequest)
1264 it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) {
1265 resp := &locationpb.ListLocationsResponse{}
1266 if pageToken != "" {
1267 req.PageToken = pageToken
1268 }
1269 if pageSize > math.MaxInt32 {
1270 req.PageSize = math.MaxInt32
1271 } else if pageSize != 0 {
1272 req.PageSize = int32(pageSize)
1273 }
1274 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1275 var err error
1276 resp, err = executeRPC(ctx, c.locationsClient.ListLocations, req, settings.GRPC, c.logger, "ListLocations")
1277 return err
1278 }, opts...)
1279 if err != nil {
1280 return nil, "", err
1281 }
1282
1283 it.Response = resp
1284 return resp.GetLocations(), resp.GetNextPageToken(), nil
1285 }
1286 fetch := func(pageSize int, pageToken string) (string, error) {
1287 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1288 if err != nil {
1289 return "", err
1290 }
1291 it.items = append(it.items, items...)
1292 return nextPageToken, nil
1293 }
1294
1295 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1296 it.pageInfo.MaxSize = int(req.GetPageSize())
1297 it.pageInfo.Token = req.GetPageToken()
1298
1299 return it
1300 }
1301
1302 func (c *managedSchemaRegistryGRPCClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
1303 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1304
1305 hds = append(c.xGoogHeaders, hds...)
1306 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1307 opts = append((*c.CallOptions).CancelOperation[0:len((*c.CallOptions).CancelOperation):len((*c.CallOptions).CancelOperation)], opts...)
1308 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1309 var err error
1310 _, err = executeRPC(ctx, c.operationsClient.CancelOperation, req, settings.GRPC, c.logger, "CancelOperation")
1311 return err
1312 }, opts...)
1313 return err
1314 }
1315
1316 func (c *managedSchemaRegistryGRPCClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error {
1317 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1318
1319 hds = append(c.xGoogHeaders, hds...)
1320 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1321 opts = append((*c.CallOptions).DeleteOperation[0:len((*c.CallOptions).DeleteOperation):len((*c.CallOptions).DeleteOperation)], opts...)
1322 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1323 var err error
1324 _, err = executeRPC(ctx, c.operationsClient.DeleteOperation, req, settings.GRPC, c.logger, "DeleteOperation")
1325 return err
1326 }, opts...)
1327 return err
1328 }
1329
1330 func (c *managedSchemaRegistryGRPCClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
1331 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1332
1333 hds = append(c.xGoogHeaders, hds...)
1334 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1335 opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...)
1336 var resp *longrunningpb.Operation
1337 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1338 var err error
1339 resp, err = executeRPC(ctx, c.operationsClient.GetOperation, req, settings.GRPC, c.logger, "GetOperation")
1340 return err
1341 }, opts...)
1342 if err != nil {
1343 return nil, err
1344 }
1345 return resp, nil
1346 }
1347
1348 func (c *managedSchemaRegistryGRPCClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
1349 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1350
1351 hds = append(c.xGoogHeaders, hds...)
1352 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
1353 opts = append((*c.CallOptions).ListOperations[0:len((*c.CallOptions).ListOperations):len((*c.CallOptions).ListOperations)], opts...)
1354 it := &OperationIterator{}
1355 req = proto.Clone(req).(*longrunningpb.ListOperationsRequest)
1356 it.InternalFetch = func(pageSize int, pageToken string) ([]*longrunningpb.Operation, string, error) {
1357 resp := &longrunningpb.ListOperationsResponse{}
1358 if pageToken != "" {
1359 req.PageToken = pageToken
1360 }
1361 if pageSize > math.MaxInt32 {
1362 req.PageSize = math.MaxInt32
1363 } else if pageSize != 0 {
1364 req.PageSize = int32(pageSize)
1365 }
1366 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1367 var err error
1368 resp, err = executeRPC(ctx, c.operationsClient.ListOperations, req, settings.GRPC, c.logger, "ListOperations")
1369 return err
1370 }, opts...)
1371 if err != nil {
1372 return nil, "", err
1373 }
1374
1375 it.Response = resp
1376 return resp.GetOperations(), resp.GetNextPageToken(), nil
1377 }
1378 fetch := func(pageSize int, pageToken string) (string, error) {
1379 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1380 if err != nil {
1381 return "", err
1382 }
1383 it.items = append(it.items, items...)
1384 return nextPageToken, nil
1385 }
1386
1387 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1388 it.pageInfo.MaxSize = int(req.GetPageSize())
1389 it.pageInfo.Token = req.GetPageToken()
1390
1391 return it
1392 }
1393
1394 // GetSchemaRegistry get the schema registry instance.
1395 func (c *managedSchemaRegistryRESTClient) GetSchemaRegistry(ctx context.Context, req *schemaregistrypb.GetSchemaRegistryRequest, opts ...gax.CallOption) (*schemaregistrypb.SchemaRegistry, error) {
1396 baseUrl, err := url.Parse(c.endpoint)
1397 if err != nil {
1398 return nil, err
1399 }
1400 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
1401
1402 params := url.Values{}
1403 params.Add("$alt", "json;enum-encoding=int")
1404
1405 baseUrl.RawQuery = params.Encode()
1406
1407 // Build HTTP headers from client and context metadata.
1408 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1409
1410 hds = append(c.xGoogHeaders, hds...)
1411 hds = append(hds, "Content-Type", "application/json")
1412 headers := gax.BuildHeaders(ctx, hds...)
1413 opts = append((*c.CallOptions).GetSchemaRegistry[0:len((*c.CallOptions).GetSchemaRegistry):len((*c.CallOptions).GetSchemaRegistry)], opts...)
1414 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1415 resp := &schemaregistrypb.SchemaRegistry{}
1416 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1417 if settings.Path != "" {
1418 baseUrl.Path = settings.Path
1419 }
1420 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1421 if err != nil {
1422 return err
1423 }
1424 httpReq = httpReq.WithContext(ctx)
1425 httpReq.Header = headers
1426
1427 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetSchemaRegistry")
1428 if err != nil {
1429 return err
1430 }
1431
1432 if err := unm.Unmarshal(buf, resp); err != nil {
1433 return err
1434 }
1435
1436 return nil
1437 }, opts...)
1438 if e != nil {
1439 return nil, e
1440 }
1441 return resp, nil
1442 }
1443
1444 // ListSchemaRegistries list schema registries.
1445 func (c *managedSchemaRegistryRESTClient) ListSchemaRegistries(ctx context.Context, req *schemaregistrypb.ListSchemaRegistriesRequest, opts ...gax.CallOption) (*schemaregistrypb.ListSchemaRegistriesResponse, error) {
1446 baseUrl, err := url.Parse(c.endpoint)
1447 if err != nil {
1448 return nil, err
1449 }
1450 baseUrl.Path += fmt.Sprintf("/v1/%v/schemaRegistries", req.GetParent())
1451
1452 params := url.Values{}
1453 params.Add("$alt", "json;enum-encoding=int")
1454
1455 baseUrl.RawQuery = params.Encode()
1456
1457 // Build HTTP headers from client and context metadata.
1458 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1459
1460 hds = append(c.xGoogHeaders, hds...)
1461 hds = append(hds, "Content-Type", "application/json")
1462 headers := gax.BuildHeaders(ctx, hds...)
1463 opts = append((*c.CallOptions).ListSchemaRegistries[0:len((*c.CallOptions).ListSchemaRegistries):len((*c.CallOptions).ListSchemaRegistries)], opts...)
1464 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1465 resp := &schemaregistrypb.ListSchemaRegistriesResponse{}
1466 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1467 if settings.Path != "" {
1468 baseUrl.Path = settings.Path
1469 }
1470 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1471 if err != nil {
1472 return err
1473 }
1474 httpReq = httpReq.WithContext(ctx)
1475 httpReq.Header = headers
1476
1477 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListSchemaRegistries")
1478 if err != nil {
1479 return err
1480 }
1481
1482 if err := unm.Unmarshal(buf, resp); err != nil {
1483 return err
1484 }
1485
1486 return nil
1487 }, opts...)
1488 if e != nil {
1489 return nil, e
1490 }
1491 return resp, nil
1492 }
1493
1494 // CreateSchemaRegistry create a schema registry instance.
1495 func (c *managedSchemaRegistryRESTClient) CreateSchemaRegistry(ctx context.Context, req *schemaregistrypb.CreateSchemaRegistryRequest, opts ...gax.CallOption) (*schemaregistrypb.SchemaRegistry, error) {
1496 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1497 jsonReq, err := m.Marshal(req)
1498 if err != nil {
1499 return nil, err
1500 }
1501
1502 baseUrl, err := url.Parse(c.endpoint)
1503 if err != nil {
1504 return nil, err
1505 }
1506 baseUrl.Path += fmt.Sprintf("/v1/%v/schemaRegistries", req.GetParent())
1507
1508 params := url.Values{}
1509 params.Add("$alt", "json;enum-encoding=int")
1510
1511 baseUrl.RawQuery = params.Encode()
1512
1513 // Build HTTP headers from client and context metadata.
1514 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1515
1516 hds = append(c.xGoogHeaders, hds...)
1517 hds = append(hds, "Content-Type", "application/json")
1518 headers := gax.BuildHeaders(ctx, hds...)
1519 opts = append((*c.CallOptions).CreateSchemaRegistry[0:len((*c.CallOptions).CreateSchemaRegistry):len((*c.CallOptions).CreateSchemaRegistry)], opts...)
1520 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1521 resp := &schemaregistrypb.SchemaRegistry{}
1522 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1523 if settings.Path != "" {
1524 baseUrl.Path = settings.Path
1525 }
1526 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
1527 if err != nil {
1528 return err
1529 }
1530 httpReq = httpReq.WithContext(ctx)
1531 httpReq.Header = headers
1532
1533 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateSchemaRegistry")
1534 if err != nil {
1535 return err
1536 }
1537
1538 if err := unm.Unmarshal(buf, resp); err != nil {
1539 return err
1540 }
1541
1542 return nil
1543 }, opts...)
1544 if e != nil {
1545 return nil, e
1546 }
1547 return resp, nil
1548 }
1549
1550 // DeleteSchemaRegistry delete a schema registry instance.
1551 func (c *managedSchemaRegistryRESTClient) DeleteSchemaRegistry(ctx context.Context, req *schemaregistrypb.DeleteSchemaRegistryRequest, opts ...gax.CallOption) error {
1552 baseUrl, err := url.Parse(c.endpoint)
1553 if err != nil {
1554 return err
1555 }
1556 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
1557
1558 params := url.Values{}
1559 params.Add("$alt", "json;enum-encoding=int")
1560
1561 baseUrl.RawQuery = params.Encode()
1562
1563 // Build HTTP headers from client and context metadata.
1564 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1565
1566 hds = append(c.xGoogHeaders, hds...)
1567 hds = append(hds, "Content-Type", "application/json")
1568 headers := gax.BuildHeaders(ctx, hds...)
1569 return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1570 if settings.Path != "" {
1571 baseUrl.Path = settings.Path
1572 }
1573 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
1574 if err != nil {
1575 return err
1576 }
1577 httpReq = httpReq.WithContext(ctx)
1578 httpReq.Header = headers
1579
1580 _, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteSchemaRegistry")
1581 return err
1582 }, opts...)
1583 }
1584
1585 // GetContext get the context.
1586 func (c *managedSchemaRegistryRESTClient) GetContext(ctx context.Context, req *schemaregistrypb.GetContextRequest, opts ...gax.CallOption) (*schemaregistrypb.Context, error) {
1587 baseUrl, err := url.Parse(c.endpoint)
1588 if err != nil {
1589 return nil, err
1590 }
1591 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
1592
1593 params := url.Values{}
1594 params.Add("$alt", "json;enum-encoding=int")
1595
1596 baseUrl.RawQuery = params.Encode()
1597
1598 // Build HTTP headers from client and context metadata.
1599 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1600
1601 hds = append(c.xGoogHeaders, hds...)
1602 hds = append(hds, "Content-Type", "application/json")
1603 headers := gax.BuildHeaders(ctx, hds...)
1604 opts = append((*c.CallOptions).GetContext[0:len((*c.CallOptions).GetContext):len((*c.CallOptions).GetContext)], opts...)
1605 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1606 resp := &schemaregistrypb.Context{}
1607 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1608 if settings.Path != "" {
1609 baseUrl.Path = settings.Path
1610 }
1611 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1612 if err != nil {
1613 return err
1614 }
1615 httpReq = httpReq.WithContext(ctx)
1616 httpReq.Header = headers
1617
1618 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetContext")
1619 if err != nil {
1620 return err
1621 }
1622
1623 if err := unm.Unmarshal(buf, resp); err != nil {
1624 return err
1625 }
1626
1627 return nil
1628 }, opts...)
1629 if e != nil {
1630 return nil, e
1631 }
1632 return resp, nil
1633 }
1634
1635 // ListContexts list contexts for a schema registry.
1636 func (c *managedSchemaRegistryRESTClient) ListContexts(ctx context.Context, req *schemaregistrypb.ListContextsRequest, opts ...gax.CallOption) (*httpbodypb.HttpBody, error) {
1637 baseUrl, err := url.Parse(c.endpoint)
1638 if err != nil {
1639 return nil, err
1640 }
1641 baseUrl.Path += fmt.Sprintf("/v1/%v/contexts", req.GetParent())
1642
1643 params := url.Values{}
1644 params.Add("$alt", "json;enum-encoding=int")
1645
1646 baseUrl.RawQuery = params.Encode()
1647
1648 // Build HTTP headers from client and context metadata.
1649 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1650
1651 hds = append(c.xGoogHeaders, hds...)
1652 hds = append(hds, "Content-Type", "application/json")
1653 headers := gax.BuildHeaders(ctx, hds...)
1654 opts = append((*c.CallOptions).ListContexts[0:len((*c.CallOptions).ListContexts):len((*c.CallOptions).ListContexts)], opts...)
1655 resp := &httpbodypb.HttpBody{}
1656 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1657 if settings.Path != "" {
1658 baseUrl.Path = settings.Path
1659 }
1660 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1661 if err != nil {
1662 return err
1663 }
1664 httpReq = httpReq.WithContext(ctx)
1665 httpReq.Header = headers
1666
1667 buf, httpRsp, err := executeHTTPRequestWithResponse(ctx, c.httpClient, httpReq, c.logger, nil, "ListContexts")
1668 if err != nil {
1669 return err
1670 }
1671
1672 resp.Data = buf
1673 if headers := httpRsp.Header; len(headers["Content-Type"]) > 0 {
1674 resp.ContentType = headers["Content-Type"][0]
1675 }
1676
1677 return nil
1678 }, opts...)
1679 if e != nil {
1680 return nil, e
1681 }
1682 return resp, nil
1683 }
1684
1685 // GetSchema get the schema for the given schema id.
1686 func (c *managedSchemaRegistryRESTClient) GetSchema(ctx context.Context, req *schemaregistrypb.GetSchemaRequest, opts ...gax.CallOption) (*schemaregistrypb.Schema, error) {
1687 baseUrl, err := url.Parse(c.endpoint)
1688 if err != nil {
1689 return nil, err
1690 }
1691 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
1692
1693 params := url.Values{}
1694 params.Add("$alt", "json;enum-encoding=int")
1695 if req != nil && req.Subject != nil {
1696 params.Add("subject", fmt.Sprintf("%v", req.GetSubject()))
1697 }
1698
1699 baseUrl.RawQuery = params.Encode()
1700
1701 // Build HTTP headers from client and context metadata.
1702 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1703
1704 hds = append(c.xGoogHeaders, hds...)
1705 hds = append(hds, "Content-Type", "application/json")
1706 headers := gax.BuildHeaders(ctx, hds...)
1707 opts = append((*c.CallOptions).GetSchema[0:len((*c.CallOptions).GetSchema):len((*c.CallOptions).GetSchema)], opts...)
1708 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1709 resp := &schemaregistrypb.Schema{}
1710 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1711 if settings.Path != "" {
1712 baseUrl.Path = settings.Path
1713 }
1714 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1715 if err != nil {
1716 return err
1717 }
1718 httpReq = httpReq.WithContext(ctx)
1719 httpReq.Header = headers
1720
1721 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetSchema")
1722 if err != nil {
1723 return err
1724 }
1725
1726 if err := unm.Unmarshal(buf, resp); err != nil {
1727 return err
1728 }
1729
1730 return nil
1731 }, opts...)
1732 if e != nil {
1733 return nil, e
1734 }
1735 return resp, nil
1736 }
1737
1738 // GetRawSchema get the schema string for the given schema id.
1739 // The response will be the schema string.
1740 func (c *managedSchemaRegistryRESTClient) GetRawSchema(ctx context.Context, req *schemaregistrypb.GetSchemaRequest, opts ...gax.CallOption) (*httpbodypb.HttpBody, error) {
1741 baseUrl, err := url.Parse(c.endpoint)
1742 if err != nil {
1743 return nil, err
1744 }
1745 baseUrl.Path += fmt.Sprintf("/v1/%v/schema", req.GetName())
1746
1747 params := url.Values{}
1748 params.Add("$alt", "json;enum-encoding=int")
1749 if req != nil && req.Subject != nil {
1750 params.Add("subject", fmt.Sprintf("%v", req.GetSubject()))
1751 }
1752
1753 baseUrl.RawQuery = params.Encode()
1754
1755 // Build HTTP headers from client and context metadata.
1756 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1757
1758 hds = append(c.xGoogHeaders, hds...)
1759 hds = append(hds, "Content-Type", "application/json")
1760 headers := gax.BuildHeaders(ctx, hds...)
1761 opts = append((*c.CallOptions).GetRawSchema[0:len((*c.CallOptions).GetRawSchema):len((*c.CallOptions).GetRawSchema)], opts...)
1762 resp := &httpbodypb.HttpBody{}
1763 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1764 if settings.Path != "" {
1765 baseUrl.Path = settings.Path
1766 }
1767 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1768 if err != nil {
1769 return err
1770 }
1771 httpReq = httpReq.WithContext(ctx)
1772 httpReq.Header = headers
1773
1774 buf, httpRsp, err := executeHTTPRequestWithResponse(ctx, c.httpClient, httpReq, c.logger, nil, "GetRawSchema")
1775 if err != nil {
1776 return err
1777 }
1778
1779 resp.Data = buf
1780 if headers := httpRsp.Header; len(headers["Content-Type"]) > 0 {
1781 resp.ContentType = headers["Content-Type"][0]
1782 }
1783
1784 return nil
1785 }, opts...)
1786 if e != nil {
1787 return nil, e
1788 }
1789 return resp, nil
1790 }
1791
1792 // ListSchemaVersions list the schema versions for the given schema id.
1793 // The response will be an array of subject-version pairs as:
1794 // [{“subject”:“subject1”, “version”:1}, {“subject”:“subject2”, “version”:2}].
1795 func (c *managedSchemaRegistryRESTClient) ListSchemaVersions(ctx context.Context, req *schemaregistrypb.ListSchemaVersionsRequest, opts ...gax.CallOption) (*httpbodypb.HttpBody, error) {
1796 baseUrl, err := url.Parse(c.endpoint)
1797 if err != nil {
1798 return nil, err
1799 }
1800 baseUrl.Path += fmt.Sprintf("/v1/%v/versions", req.GetParent())
1801
1802 params := url.Values{}
1803 params.Add("$alt", "json;enum-encoding=int")
1804 if req != nil && req.Deleted != nil {
1805 params.Add("deleted", fmt.Sprintf("%v", req.GetDeleted()))
1806 }
1807 if req != nil && req.Subject != nil {
1808 params.Add("subject", fmt.Sprintf("%v", req.GetSubject()))
1809 }
1810
1811 baseUrl.RawQuery = params.Encode()
1812
1813 // Build HTTP headers from client and context metadata.
1814 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1815
1816 hds = append(c.xGoogHeaders, hds...)
1817 hds = append(hds, "Content-Type", "application/json")
1818 headers := gax.BuildHeaders(ctx, hds...)
1819 opts = append((*c.CallOptions).ListSchemaVersions[0:len((*c.CallOptions).ListSchemaVersions):len((*c.CallOptions).ListSchemaVersions)], opts...)
1820 resp := &httpbodypb.HttpBody{}
1821 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1822 if settings.Path != "" {
1823 baseUrl.Path = settings.Path
1824 }
1825 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1826 if err != nil {
1827 return err
1828 }
1829 httpReq = httpReq.WithContext(ctx)
1830 httpReq.Header = headers
1831
1832 buf, httpRsp, err := executeHTTPRequestWithResponse(ctx, c.httpClient, httpReq, c.logger, nil, "ListSchemaVersions")
1833 if err != nil {
1834 return err
1835 }
1836
1837 resp.Data = buf
1838 if headers := httpRsp.Header; len(headers["Content-Type"]) > 0 {
1839 resp.ContentType = headers["Content-Type"][0]
1840 }
1841
1842 return nil
1843 }, opts...)
1844 if e != nil {
1845 return nil, e
1846 }
1847 return resp, nil
1848 }
1849
1850 // ListSchemaTypes list the supported schema types.
1851 // The response will be an array of schema types.
1852 func (c *managedSchemaRegistryRESTClient) ListSchemaTypes(ctx context.Context, req *schemaregistrypb.ListSchemaTypesRequest, opts ...gax.CallOption) (*httpbodypb.HttpBody, error) {
1853 baseUrl, err := url.Parse(c.endpoint)
1854 if err != nil {
1855 return nil, err
1856 }
1857 baseUrl.Path += fmt.Sprintf("/v1/%v/schemas/types", req.GetParent())
1858
1859 params := url.Values{}
1860 params.Add("$alt", "json;enum-encoding=int")
1861
1862 baseUrl.RawQuery = params.Encode()
1863
1864 // Build HTTP headers from client and context metadata.
1865 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1866
1867 hds = append(c.xGoogHeaders, hds...)
1868 hds = append(hds, "Content-Type", "application/json")
1869 headers := gax.BuildHeaders(ctx, hds...)
1870 opts = append((*c.CallOptions).ListSchemaTypes[0:len((*c.CallOptions).ListSchemaTypes):len((*c.CallOptions).ListSchemaTypes)], opts...)
1871 resp := &httpbodypb.HttpBody{}
1872 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1873 if settings.Path != "" {
1874 baseUrl.Path = settings.Path
1875 }
1876 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1877 if err != nil {
1878 return err
1879 }
1880 httpReq = httpReq.WithContext(ctx)
1881 httpReq.Header = headers
1882
1883 buf, httpRsp, err := executeHTTPRequestWithResponse(ctx, c.httpClient, httpReq, c.logger, nil, "ListSchemaTypes")
1884 if err != nil {
1885 return err
1886 }
1887
1888 resp.Data = buf
1889 if headers := httpRsp.Header; len(headers["Content-Type"]) > 0 {
1890 resp.ContentType = headers["Content-Type"][0]
1891 }
1892
1893 return nil
1894 }, opts...)
1895 if e != nil {
1896 return nil, e
1897 }
1898 return resp, nil
1899 }
1900
1901 // ListSubjects list subjects in the schema registry.
1902 // The response will be an array of subject names.
1903 func (c *managedSchemaRegistryRESTClient) ListSubjects(ctx context.Context, req *schemaregistrypb.ListSubjectsRequest, opts ...gax.CallOption) (*httpbodypb.HttpBody, error) {
1904 baseUrl, err := url.Parse(c.endpoint)
1905 if err != nil {
1906 return nil, err
1907 }
1908 baseUrl.Path += fmt.Sprintf("/v1/%v/subjects", req.GetParent())
1909
1910 params := url.Values{}
1911 params.Add("$alt", "json;enum-encoding=int")
1912 if req != nil && req.Deleted != nil {
1913 params.Add("deleted", fmt.Sprintf("%v", req.GetDeleted()))
1914 }
1915 if req != nil && req.SubjectPrefix != nil {
1916 params.Add("subjectPrefix", fmt.Sprintf("%v", req.GetSubjectPrefix()))
1917 }
1918
1919 baseUrl.RawQuery = params.Encode()
1920
1921 // Build HTTP headers from client and context metadata.
1922 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1923
1924 hds = append(c.xGoogHeaders, hds...)
1925 hds = append(hds, "Content-Type", "application/json")
1926 headers := gax.BuildHeaders(ctx, hds...)
1927 opts = append((*c.CallOptions).ListSubjects[0:len((*c.CallOptions).ListSubjects):len((*c.CallOptions).ListSubjects)], opts...)
1928 resp := &httpbodypb.HttpBody{}
1929 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1930 if settings.Path != "" {
1931 baseUrl.Path = settings.Path
1932 }
1933 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1934 if err != nil {
1935 return err
1936 }
1937 httpReq = httpReq.WithContext(ctx)
1938 httpReq.Header = headers
1939
1940 buf, httpRsp, err := executeHTTPRequestWithResponse(ctx, c.httpClient, httpReq, c.logger, nil, "ListSubjects")
1941 if err != nil {
1942 return err
1943 }
1944
1945 resp.Data = buf
1946 if headers := httpRsp.Header; len(headers["Content-Type"]) > 0 {
1947 resp.ContentType = headers["Content-Type"][0]
1948 }
1949
1950 return nil
1951 }, opts...)
1952 if e != nil {
1953 return nil, e
1954 }
1955 return resp, nil
1956 }
1957
1958 // ListSubjectsBySchemaId list subjects which reference a particular schema id.
1959 // The response will be an array of subject names.
1960 func (c *managedSchemaRegistryRESTClient) ListSubjectsBySchemaId(ctx context.Context, req *schemaregistrypb.ListSubjectsBySchemaIdRequest, opts ...gax.CallOption) (*httpbodypb.HttpBody, error) {
1961 baseUrl, err := url.Parse(c.endpoint)
1962 if err != nil {
1963 return nil, err
1964 }
1965 baseUrl.Path += fmt.Sprintf("/v1/%v/subjects", req.GetParent())
1966
1967 params := url.Values{}
1968 params.Add("$alt", "json;enum-encoding=int")
1969 if req != nil && req.Deleted != nil {
1970 params.Add("deleted", fmt.Sprintf("%v", req.GetDeleted()))
1971 }
1972 if req != nil && req.Subject != nil {
1973 params.Add("subject", fmt.Sprintf("%v", req.GetSubject()))
1974 }
1975
1976 baseUrl.RawQuery = params.Encode()
1977
1978 // Build HTTP headers from client and context metadata.
1979 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1980
1981 hds = append(c.xGoogHeaders, hds...)
1982 hds = append(hds, "Content-Type", "application/json")
1983 headers := gax.BuildHeaders(ctx, hds...)
1984 opts = append((*c.CallOptions).ListSubjectsBySchemaId[0:len((*c.CallOptions).ListSubjectsBySchemaId):len((*c.CallOptions).ListSubjectsBySchemaId)], opts...)
1985 resp := &httpbodypb.HttpBody{}
1986 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1987 if settings.Path != "" {
1988 baseUrl.Path = settings.Path
1989 }
1990 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1991 if err != nil {
1992 return err
1993 }
1994 httpReq = httpReq.WithContext(ctx)
1995 httpReq.Header = headers
1996
1997 buf, httpRsp, err := executeHTTPRequestWithResponse(ctx, c.httpClient, httpReq, c.logger, nil, "ListSubjectsBySchemaId")
1998 if err != nil {
1999 return err
2000 }
2001
2002 resp.Data = buf
2003 if headers := httpRsp.Header; len(headers["Content-Type"]) > 0 {
2004 resp.ContentType = headers["Content-Type"][0]
2005 }
2006
2007 return nil
2008 }, opts...)
2009 if e != nil {
2010 return nil, e
2011 }
2012 return resp, nil
2013 }
2014
2015 // DeleteSubject delete a subject.
2016 // The response will be an array of versions of the deleted subject.
2017 func (c *managedSchemaRegistryRESTClient) DeleteSubject(ctx context.Context, req *schemaregistrypb.DeleteSubjectRequest, opts ...gax.CallOption) (*httpbodypb.HttpBody, error) {
2018 baseUrl, err := url.Parse(c.endpoint)
2019 if err != nil {
2020 return nil, err
2021 }
2022 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
2023
2024 params := url.Values{}
2025 params.Add("$alt", "json;enum-encoding=int")
2026 if req != nil && req.Permanent != nil {
2027 params.Add("permanent", fmt.Sprintf("%v", req.GetPermanent()))
2028 }
2029
2030 baseUrl.RawQuery = params.Encode()
2031
2032 // Build HTTP headers from client and context metadata.
2033 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2034
2035 hds = append(c.xGoogHeaders, hds...)
2036 hds = append(hds, "Content-Type", "application/json")
2037 headers := gax.BuildHeaders(ctx, hds...)
2038 opts = append((*c.CallOptions).DeleteSubject[0:len((*c.CallOptions).DeleteSubject):len((*c.CallOptions).DeleteSubject)], opts...)
2039 resp := &httpbodypb.HttpBody{}
2040 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2041 if settings.Path != "" {
2042 baseUrl.Path = settings.Path
2043 }
2044 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
2045 if err != nil {
2046 return err
2047 }
2048 httpReq = httpReq.WithContext(ctx)
2049 httpReq.Header = headers
2050
2051 buf, httpRsp, err := executeHTTPRequestWithResponse(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteSubject")
2052 if err != nil {
2053 return err
2054 }
2055
2056 resp.Data = buf
2057 if headers := httpRsp.Header; len(headers["Content-Type"]) > 0 {
2058 resp.ContentType = headers["Content-Type"][0]
2059 }
2060
2061 return nil
2062 }, opts...)
2063 if e != nil {
2064 return nil, e
2065 }
2066 return resp, nil
2067 }
2068
2069 // LookupVersion lookup a schema under the specified subject.
2070 func (c *managedSchemaRegistryRESTClient) LookupVersion(ctx context.Context, req *schemaregistrypb.LookupVersionRequest, opts ...gax.CallOption) (*schemaregistrypb.SchemaVersion, error) {
2071 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2072 jsonReq, err := m.Marshal(req)
2073 if err != nil {
2074 return nil, err
2075 }
2076
2077 baseUrl, err := url.Parse(c.endpoint)
2078 if err != nil {
2079 return nil, err
2080 }
2081 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetParent())
2082
2083 params := url.Values{}
2084 params.Add("$alt", "json;enum-encoding=int")
2085
2086 baseUrl.RawQuery = params.Encode()
2087
2088 // Build HTTP headers from client and context metadata.
2089 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
2090
2091 hds = append(c.xGoogHeaders, hds...)
2092 hds = append(hds, "Content-Type", "application/json")
2093 headers := gax.BuildHeaders(ctx, hds...)
2094 opts = append((*c.CallOptions).LookupVersion[0:len((*c.CallOptions).LookupVersion):len((*c.CallOptions).LookupVersion)], opts...)
2095 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2096 resp := &schemaregistrypb.SchemaVersion{}
2097 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2098 if settings.Path != "" {
2099 baseUrl.Path = settings.Path
2100 }
2101 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
2102 if err != nil {
2103 return err
2104 }
2105 httpReq = httpReq.WithContext(ctx)
2106 httpReq.Header = headers
2107
2108 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "LookupVersion")
2109 if err != nil {
2110 return err
2111 }
2112
2113 if err := unm.Unmarshal(buf, resp); err != nil {
2114 return err
2115 }
2116
2117 return nil
2118 }, opts...)
2119 if e != nil {
2120 return nil, e
2121 }
2122 return resp, nil
2123 }
2124
2125 // GetVersion get a versioned schema (schema with subject/version) of a subject.
2126 func (c *managedSchemaRegistryRESTClient) GetVersion(ctx context.Context, req *schemaregistrypb.GetVersionRequest, opts ...gax.CallOption) (*schemaregistrypb.SchemaVersion, error) {
2127 baseUrl, err := url.Parse(c.endpoint)
2128 if err != nil {
2129 return nil, err
2130 }
2131 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
2132
2133 params := url.Values{}
2134 params.Add("$alt", "json;enum-encoding=int")
2135 if req != nil && req.Deleted != nil {
2136 params.Add("deleted", fmt.Sprintf("%v", req.GetDeleted()))
2137 }
2138
2139 baseUrl.RawQuery = params.Encode()
2140
2141 // Build HTTP headers from client and context metadata.
2142 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2143
2144 hds = append(c.xGoogHeaders, hds...)
2145 hds = append(hds, "Content-Type", "application/json")
2146 headers := gax.BuildHeaders(ctx, hds...)
2147 opts = append((*c.CallOptions).GetVersion[0:len((*c.CallOptions).GetVersion):len((*c.CallOptions).GetVersion)], opts...)
2148 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2149 resp := &schemaregistrypb.SchemaVersion{}
2150 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2151 if settings.Path != "" {
2152 baseUrl.Path = settings.Path
2153 }
2154 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2155 if err != nil {
2156 return err
2157 }
2158 httpReq = httpReq.WithContext(ctx)
2159 httpReq.Header = headers
2160
2161 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetVersion")
2162 if err != nil {
2163 return err
2164 }
2165
2166 if err := unm.Unmarshal(buf, resp); err != nil {
2167 return err
2168 }
2169
2170 return nil
2171 }, opts...)
2172 if e != nil {
2173 return nil, e
2174 }
2175 return resp, nil
2176 }
2177
2178 // GetRawSchemaVersion get the schema string only for a version of a subject.
2179 // The response will be the schema string.
2180 func (c *managedSchemaRegistryRESTClient) GetRawSchemaVersion(ctx context.Context, req *schemaregistrypb.GetVersionRequest, opts ...gax.CallOption) (*httpbodypb.HttpBody, error) {
2181 baseUrl, err := url.Parse(c.endpoint)
2182 if err != nil {
2183 return nil, err
2184 }
2185 baseUrl.Path += fmt.Sprintf("/v1/%v/schema", req.GetName())
2186
2187 params := url.Values{}
2188 params.Add("$alt", "json;enum-encoding=int")
2189 if req != nil && req.Deleted != nil {
2190 params.Add("deleted", fmt.Sprintf("%v", req.GetDeleted()))
2191 }
2192
2193 baseUrl.RawQuery = params.Encode()
2194
2195 // Build HTTP headers from client and context metadata.
2196 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2197
2198 hds = append(c.xGoogHeaders, hds...)
2199 hds = append(hds, "Content-Type", "application/json")
2200 headers := gax.BuildHeaders(ctx, hds...)
2201 opts = append((*c.CallOptions).GetRawSchemaVersion[0:len((*c.CallOptions).GetRawSchemaVersion):len((*c.CallOptions).GetRawSchemaVersion)], opts...)
2202 resp := &httpbodypb.HttpBody{}
2203 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2204 if settings.Path != "" {
2205 baseUrl.Path = settings.Path
2206 }
2207 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2208 if err != nil {
2209 return err
2210 }
2211 httpReq = httpReq.WithContext(ctx)
2212 httpReq.Header = headers
2213
2214 buf, httpRsp, err := executeHTTPRequestWithResponse(ctx, c.httpClient, httpReq, c.logger, nil, "GetRawSchemaVersion")
2215 if err != nil {
2216 return err
2217 }
2218
2219 resp.Data = buf
2220 if headers := httpRsp.Header; len(headers["Content-Type"]) > 0 {
2221 resp.ContentType = headers["Content-Type"][0]
2222 }
2223
2224 return nil
2225 }, opts...)
2226 if e != nil {
2227 return nil, e
2228 }
2229 return resp, nil
2230 }
2231
2232 // ListVersions get all versions of a subject.
2233 // The response will be an array of versions of the subject.
2234 func (c *managedSchemaRegistryRESTClient) ListVersions(ctx context.Context, req *schemaregistrypb.ListVersionsRequest, opts ...gax.CallOption) (*httpbodypb.HttpBody, error) {
2235 baseUrl, err := url.Parse(c.endpoint)
2236 if err != nil {
2237 return nil, err
2238 }
2239 baseUrl.Path += fmt.Sprintf("/v1/%v/versions", req.GetParent())
2240
2241 params := url.Values{}
2242 params.Add("$alt", "json;enum-encoding=int")
2243 if req != nil && req.Deleted != nil {
2244 params.Add("deleted", fmt.Sprintf("%v", req.GetDeleted()))
2245 }
2246
2247 baseUrl.RawQuery = params.Encode()
2248
2249 // Build HTTP headers from client and context metadata.
2250 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
2251
2252 hds = append(c.xGoogHeaders, hds...)
2253 hds = append(hds, "Content-Type", "application/json")
2254 headers := gax.BuildHeaders(ctx, hds...)
2255 opts = append((*c.CallOptions).ListVersions[0:len((*c.CallOptions).ListVersions):len((*c.CallOptions).ListVersions)], opts...)
2256 resp := &httpbodypb.HttpBody{}
2257 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2258 if settings.Path != "" {
2259 baseUrl.Path = settings.Path
2260 }
2261 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2262 if err != nil {
2263 return err
2264 }
2265 httpReq = httpReq.WithContext(ctx)
2266 httpReq.Header = headers
2267
2268 buf, httpRsp, err := executeHTTPRequestWithResponse(ctx, c.httpClient, httpReq, c.logger, nil, "ListVersions")
2269 if err != nil {
2270 return err
2271 }
2272
2273 resp.Data = buf
2274 if headers := httpRsp.Header; len(headers["Content-Type"]) > 0 {
2275 resp.ContentType = headers["Content-Type"][0]
2276 }
2277
2278 return nil
2279 }, opts...)
2280 if e != nil {
2281 return nil, e
2282 }
2283 return resp, nil
2284 }
2285
2286 // CreateVersion register a new version under a given subject with the given schema.
2287 func (c *managedSchemaRegistryRESTClient) CreateVersion(ctx context.Context, req *schemaregistrypb.CreateVersionRequest, opts ...gax.CallOption) (*schemaregistrypb.CreateVersionResponse, error) {
2288 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2289 jsonReq, err := m.Marshal(req)
2290 if err != nil {
2291 return nil, err
2292 }
2293
2294 baseUrl, err := url.Parse(c.endpoint)
2295 if err != nil {
2296 return nil, err
2297 }
2298 baseUrl.Path += fmt.Sprintf("/v1/%v/versions", req.GetParent())
2299
2300 params := url.Values{}
2301 params.Add("$alt", "json;enum-encoding=int")
2302
2303 baseUrl.RawQuery = params.Encode()
2304
2305 // Build HTTP headers from client and context metadata.
2306 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
2307
2308 hds = append(c.xGoogHeaders, hds...)
2309 hds = append(hds, "Content-Type", "application/json")
2310 headers := gax.BuildHeaders(ctx, hds...)
2311 opts = append((*c.CallOptions).CreateVersion[0:len((*c.CallOptions).CreateVersion):len((*c.CallOptions).CreateVersion)], opts...)
2312 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2313 resp := &schemaregistrypb.CreateVersionResponse{}
2314 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2315 if settings.Path != "" {
2316 baseUrl.Path = settings.Path
2317 }
2318 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
2319 if err != nil {
2320 return err
2321 }
2322 httpReq = httpReq.WithContext(ctx)
2323 httpReq.Header = headers
2324
2325 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateVersion")
2326 if err != nil {
2327 return err
2328 }
2329
2330 if err := unm.Unmarshal(buf, resp); err != nil {
2331 return err
2332 }
2333
2334 return nil
2335 }, opts...)
2336 if e != nil {
2337 return nil, e
2338 }
2339 return resp, nil
2340 }
2341
2342 // DeleteVersion delete a version of a subject.
2343 // The response will be the deleted version id.
2344 func (c *managedSchemaRegistryRESTClient) DeleteVersion(ctx context.Context, req *schemaregistrypb.DeleteVersionRequest, opts ...gax.CallOption) (*httpbodypb.HttpBody, error) {
2345 baseUrl, err := url.Parse(c.endpoint)
2346 if err != nil {
2347 return nil, err
2348 }
2349 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
2350
2351 params := url.Values{}
2352 params.Add("$alt", "json;enum-encoding=int")
2353 if req != nil && req.Permanent != nil {
2354 params.Add("permanent", fmt.Sprintf("%v", req.GetPermanent()))
2355 }
2356
2357 baseUrl.RawQuery = params.Encode()
2358
2359 // Build HTTP headers from client and context metadata.
2360 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2361
2362 hds = append(c.xGoogHeaders, hds...)
2363 hds = append(hds, "Content-Type", "application/json")
2364 headers := gax.BuildHeaders(ctx, hds...)
2365 opts = append((*c.CallOptions).DeleteVersion[0:len((*c.CallOptions).DeleteVersion):len((*c.CallOptions).DeleteVersion)], opts...)
2366 resp := &httpbodypb.HttpBody{}
2367 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2368 if settings.Path != "" {
2369 baseUrl.Path = settings.Path
2370 }
2371 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
2372 if err != nil {
2373 return err
2374 }
2375 httpReq = httpReq.WithContext(ctx)
2376 httpReq.Header = headers
2377
2378 buf, httpRsp, err := executeHTTPRequestWithResponse(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteVersion")
2379 if err != nil {
2380 return err
2381 }
2382
2383 resp.Data = buf
2384 if headers := httpRsp.Header; len(headers["Content-Type"]) > 0 {
2385 resp.ContentType = headers["Content-Type"][0]
2386 }
2387
2388 return nil
2389 }, opts...)
2390 if e != nil {
2391 return nil, e
2392 }
2393 return resp, nil
2394 }
2395
2396 // ListReferencedSchemas get a list of IDs of schemas that reference the schema with the given
2397 // subject and version.
2398 func (c *managedSchemaRegistryRESTClient) ListReferencedSchemas(ctx context.Context, req *schemaregistrypb.ListReferencedSchemasRequest, opts ...gax.CallOption) (*httpbodypb.HttpBody, error) {
2399 baseUrl, err := url.Parse(c.endpoint)
2400 if err != nil {
2401 return nil, err
2402 }
2403 baseUrl.Path += fmt.Sprintf("/v1/%v/referencedby", req.GetParent())
2404
2405 params := url.Values{}
2406 params.Add("$alt", "json;enum-encoding=int")
2407
2408 baseUrl.RawQuery = params.Encode()
2409
2410 // Build HTTP headers from client and context metadata.
2411 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
2412
2413 hds = append(c.xGoogHeaders, hds...)
2414 hds = append(hds, "Content-Type", "application/json")
2415 headers := gax.BuildHeaders(ctx, hds...)
2416 opts = append((*c.CallOptions).ListReferencedSchemas[0:len((*c.CallOptions).ListReferencedSchemas):len((*c.CallOptions).ListReferencedSchemas)], opts...)
2417 resp := &httpbodypb.HttpBody{}
2418 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2419 if settings.Path != "" {
2420 baseUrl.Path = settings.Path
2421 }
2422 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2423 if err != nil {
2424 return err
2425 }
2426 httpReq = httpReq.WithContext(ctx)
2427 httpReq.Header = headers
2428
2429 buf, httpRsp, err := executeHTTPRequestWithResponse(ctx, c.httpClient, httpReq, c.logger, nil, "ListReferencedSchemas")
2430 if err != nil {
2431 return err
2432 }
2433
2434 resp.Data = buf
2435 if headers := httpRsp.Header; len(headers["Content-Type"]) > 0 {
2436 resp.ContentType = headers["Content-Type"][0]
2437 }
2438
2439 return nil
2440 }, opts...)
2441 if e != nil {
2442 return nil, e
2443 }
2444 return resp, nil
2445 }
2446
2447 // CheckCompatibility check compatibility of a schema with all versions or a specific version of
2448 // a subject.
2449 func (c *managedSchemaRegistryRESTClient) CheckCompatibility(ctx context.Context, req *schemaregistrypb.CheckCompatibilityRequest, opts ...gax.CallOption) (*schemaregistrypb.CheckCompatibilityResponse, error) {
2450 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2451 jsonReq, err := m.Marshal(req)
2452 if err != nil {
2453 return nil, err
2454 }
2455
2456 baseUrl, err := url.Parse(c.endpoint)
2457 if err != nil {
2458 return nil, err
2459 }
2460 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
2461
2462 params := url.Values{}
2463 params.Add("$alt", "json;enum-encoding=int")
2464
2465 baseUrl.RawQuery = params.Encode()
2466
2467 // Build HTTP headers from client and context metadata.
2468 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2469
2470 hds = append(c.xGoogHeaders, hds...)
2471 hds = append(hds, "Content-Type", "application/json")
2472 headers := gax.BuildHeaders(ctx, hds...)
2473 opts = append((*c.CallOptions).CheckCompatibility[0:len((*c.CallOptions).CheckCompatibility):len((*c.CallOptions).CheckCompatibility)], opts...)
2474 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2475 resp := &schemaregistrypb.CheckCompatibilityResponse{}
2476 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2477 if settings.Path != "" {
2478 baseUrl.Path = settings.Path
2479 }
2480 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
2481 if err != nil {
2482 return err
2483 }
2484 httpReq = httpReq.WithContext(ctx)
2485 httpReq.Header = headers
2486
2487 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CheckCompatibility")
2488 if err != nil {
2489 return err
2490 }
2491
2492 if err := unm.Unmarshal(buf, resp); err != nil {
2493 return err
2494 }
2495
2496 return nil
2497 }, opts...)
2498 if e != nil {
2499 return nil, e
2500 }
2501 return resp, nil
2502 }
2503
2504 // GetSchemaConfig get schema config at global level or for a subject.
2505 func (c *managedSchemaRegistryRESTClient) GetSchemaConfig(ctx context.Context, req *schemaregistrypb.GetSchemaConfigRequest, opts ...gax.CallOption) (*schemaregistrypb.SchemaConfig, error) {
2506 baseUrl, err := url.Parse(c.endpoint)
2507 if err != nil {
2508 return nil, err
2509 }
2510 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
2511
2512 params := url.Values{}
2513 params.Add("$alt", "json;enum-encoding=int")
2514 if req != nil && req.DefaultToGlobal != nil {
2515 params.Add("defaultToGlobal", fmt.Sprintf("%v", req.GetDefaultToGlobal()))
2516 }
2517
2518 baseUrl.RawQuery = params.Encode()
2519
2520 // Build HTTP headers from client and context metadata.
2521 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2522
2523 hds = append(c.xGoogHeaders, hds...)
2524 hds = append(hds, "Content-Type", "application/json")
2525 headers := gax.BuildHeaders(ctx, hds...)
2526 opts = append((*c.CallOptions).GetSchemaConfig[0:len((*c.CallOptions).GetSchemaConfig):len((*c.CallOptions).GetSchemaConfig)], opts...)
2527 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2528 resp := &schemaregistrypb.SchemaConfig{}
2529 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2530 if settings.Path != "" {
2531 baseUrl.Path = settings.Path
2532 }
2533 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2534 if err != nil {
2535 return err
2536 }
2537 httpReq = httpReq.WithContext(ctx)
2538 httpReq.Header = headers
2539
2540 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetSchemaConfig")
2541 if err != nil {
2542 return err
2543 }
2544
2545 if err := unm.Unmarshal(buf, resp); err != nil {
2546 return err
2547 }
2548
2549 return nil
2550 }, opts...)
2551 if e != nil {
2552 return nil, e
2553 }
2554 return resp, nil
2555 }
2556
2557 // UpdateSchemaConfig update config at global level or for a subject.
2558 // Creates a SchemaSubject-level SchemaConfig if it does not exist.
2559 func (c *managedSchemaRegistryRESTClient) UpdateSchemaConfig(ctx context.Context, req *schemaregistrypb.UpdateSchemaConfigRequest, opts ...gax.CallOption) (*schemaregistrypb.SchemaConfig, error) {
2560 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2561 jsonReq, err := m.Marshal(req)
2562 if err != nil {
2563 return nil, err
2564 }
2565
2566 baseUrl, err := url.Parse(c.endpoint)
2567 if err != nil {
2568 return nil, err
2569 }
2570 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
2571
2572 params := url.Values{}
2573 params.Add("$alt", "json;enum-encoding=int")
2574
2575 baseUrl.RawQuery = params.Encode()
2576
2577 // Build HTTP headers from client and context metadata.
2578 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2579
2580 hds = append(c.xGoogHeaders, hds...)
2581 hds = append(hds, "Content-Type", "application/json")
2582 headers := gax.BuildHeaders(ctx, hds...)
2583 opts = append((*c.CallOptions).UpdateSchemaConfig[0:len((*c.CallOptions).UpdateSchemaConfig):len((*c.CallOptions).UpdateSchemaConfig)], opts...)
2584 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2585 resp := &schemaregistrypb.SchemaConfig{}
2586 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2587 if settings.Path != "" {
2588 baseUrl.Path = settings.Path
2589 }
2590 httpReq, err := http.NewRequest("PUT", baseUrl.String(), bytes.NewReader(jsonReq))
2591 if err != nil {
2592 return err
2593 }
2594 httpReq = httpReq.WithContext(ctx)
2595 httpReq.Header = headers
2596
2597 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateSchemaConfig")
2598 if err != nil {
2599 return err
2600 }
2601
2602 if err := unm.Unmarshal(buf, resp); err != nil {
2603 return err
2604 }
2605
2606 return nil
2607 }, opts...)
2608 if e != nil {
2609 return nil, e
2610 }
2611 return resp, nil
2612 }
2613
2614 // DeleteSchemaConfig delete schema config for a subject.
2615 func (c *managedSchemaRegistryRESTClient) DeleteSchemaConfig(ctx context.Context, req *schemaregistrypb.DeleteSchemaConfigRequest, opts ...gax.CallOption) (*schemaregistrypb.SchemaConfig, error) {
2616 baseUrl, err := url.Parse(c.endpoint)
2617 if err != nil {
2618 return nil, err
2619 }
2620 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
2621
2622 params := url.Values{}
2623 params.Add("$alt", "json;enum-encoding=int")
2624
2625 baseUrl.RawQuery = params.Encode()
2626
2627 // Build HTTP headers from client and context metadata.
2628 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2629
2630 hds = append(c.xGoogHeaders, hds...)
2631 hds = append(hds, "Content-Type", "application/json")
2632 headers := gax.BuildHeaders(ctx, hds...)
2633 opts = append((*c.CallOptions).DeleteSchemaConfig[0:len((*c.CallOptions).DeleteSchemaConfig):len((*c.CallOptions).DeleteSchemaConfig)], opts...)
2634 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2635 resp := &schemaregistrypb.SchemaConfig{}
2636 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2637 if settings.Path != "" {
2638 baseUrl.Path = settings.Path
2639 }
2640 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
2641 if err != nil {
2642 return err
2643 }
2644 httpReq = httpReq.WithContext(ctx)
2645 httpReq.Header = headers
2646
2647 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteSchemaConfig")
2648 if err != nil {
2649 return err
2650 }
2651
2652 if err := unm.Unmarshal(buf, resp); err != nil {
2653 return err
2654 }
2655
2656 return nil
2657 }, opts...)
2658 if e != nil {
2659 return nil, e
2660 }
2661 return resp, nil
2662 }
2663
2664 // GetSchemaMode get mode at global level or for a subject.
2665 func (c *managedSchemaRegistryRESTClient) GetSchemaMode(ctx context.Context, req *schemaregistrypb.GetSchemaModeRequest, opts ...gax.CallOption) (*schemaregistrypb.SchemaMode, error) {
2666 baseUrl, err := url.Parse(c.endpoint)
2667 if err != nil {
2668 return nil, err
2669 }
2670 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
2671
2672 params := url.Values{}
2673 params.Add("$alt", "json;enum-encoding=int")
2674
2675 baseUrl.RawQuery = params.Encode()
2676
2677 // Build HTTP headers from client and context metadata.
2678 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2679
2680 hds = append(c.xGoogHeaders, hds...)
2681 hds = append(hds, "Content-Type", "application/json")
2682 headers := gax.BuildHeaders(ctx, hds...)
2683 opts = append((*c.CallOptions).GetSchemaMode[0:len((*c.CallOptions).GetSchemaMode):len((*c.CallOptions).GetSchemaMode)], opts...)
2684 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2685 resp := &schemaregistrypb.SchemaMode{}
2686 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2687 if settings.Path != "" {
2688 baseUrl.Path = settings.Path
2689 }
2690 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2691 if err != nil {
2692 return err
2693 }
2694 httpReq = httpReq.WithContext(ctx)
2695 httpReq.Header = headers
2696
2697 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetSchemaMode")
2698 if err != nil {
2699 return err
2700 }
2701
2702 if err := unm.Unmarshal(buf, resp); err != nil {
2703 return err
2704 }
2705
2706 return nil
2707 }, opts...)
2708 if e != nil {
2709 return nil, e
2710 }
2711 return resp, nil
2712 }
2713
2714 // UpdateSchemaMode update mode at global level or for a subject.
2715 func (c *managedSchemaRegistryRESTClient) UpdateSchemaMode(ctx context.Context, req *schemaregistrypb.UpdateSchemaModeRequest, opts ...gax.CallOption) (*schemaregistrypb.SchemaMode, error) {
2716 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2717 jsonReq, err := m.Marshal(req)
2718 if err != nil {
2719 return nil, err
2720 }
2721
2722 baseUrl, err := url.Parse(c.endpoint)
2723 if err != nil {
2724 return nil, err
2725 }
2726 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
2727
2728 params := url.Values{}
2729 params.Add("$alt", "json;enum-encoding=int")
2730
2731 baseUrl.RawQuery = params.Encode()
2732
2733 // Build HTTP headers from client and context metadata.
2734 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2735
2736 hds = append(c.xGoogHeaders, hds...)
2737 hds = append(hds, "Content-Type", "application/json")
2738 headers := gax.BuildHeaders(ctx, hds...)
2739 opts = append((*c.CallOptions).UpdateSchemaMode[0:len((*c.CallOptions).UpdateSchemaMode):len((*c.CallOptions).UpdateSchemaMode)], opts...)
2740 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2741 resp := &schemaregistrypb.SchemaMode{}
2742 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2743 if settings.Path != "" {
2744 baseUrl.Path = settings.Path
2745 }
2746 httpReq, err := http.NewRequest("PUT", baseUrl.String(), bytes.NewReader(jsonReq))
2747 if err != nil {
2748 return err
2749 }
2750 httpReq = httpReq.WithContext(ctx)
2751 httpReq.Header = headers
2752
2753 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "UpdateSchemaMode")
2754 if err != nil {
2755 return err
2756 }
2757
2758 if err := unm.Unmarshal(buf, resp); err != nil {
2759 return err
2760 }
2761
2762 return nil
2763 }, opts...)
2764 if e != nil {
2765 return nil, e
2766 }
2767 return resp, nil
2768 }
2769
2770 // DeleteSchemaMode delete schema mode for a subject.
2771 func (c *managedSchemaRegistryRESTClient) DeleteSchemaMode(ctx context.Context, req *schemaregistrypb.DeleteSchemaModeRequest, opts ...gax.CallOption) (*schemaregistrypb.SchemaMode, error) {
2772 baseUrl, err := url.Parse(c.endpoint)
2773 if err != nil {
2774 return nil, err
2775 }
2776 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
2777
2778 params := url.Values{}
2779 params.Add("$alt", "json;enum-encoding=int")
2780
2781 baseUrl.RawQuery = params.Encode()
2782
2783 // Build HTTP headers from client and context metadata.
2784 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2785
2786 hds = append(c.xGoogHeaders, hds...)
2787 hds = append(hds, "Content-Type", "application/json")
2788 headers := gax.BuildHeaders(ctx, hds...)
2789 opts = append((*c.CallOptions).DeleteSchemaMode[0:len((*c.CallOptions).DeleteSchemaMode):len((*c.CallOptions).DeleteSchemaMode)], opts...)
2790 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2791 resp := &schemaregistrypb.SchemaMode{}
2792 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2793 if settings.Path != "" {
2794 baseUrl.Path = settings.Path
2795 }
2796 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
2797 if err != nil {
2798 return err
2799 }
2800 httpReq = httpReq.WithContext(ctx)
2801 httpReq.Header = headers
2802
2803 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteSchemaMode")
2804 if err != nil {
2805 return err
2806 }
2807
2808 if err := unm.Unmarshal(buf, resp); err != nil {
2809 return err
2810 }
2811
2812 return nil
2813 }, opts...)
2814 if e != nil {
2815 return nil, e
2816 }
2817 return resp, nil
2818 }
2819
2820 // GetLocation gets information about a location.
2821 func (c *managedSchemaRegistryRESTClient) GetLocation(ctx context.Context, req *locationpb.GetLocationRequest, opts ...gax.CallOption) (*locationpb.Location, error) {
2822 baseUrl, err := url.Parse(c.endpoint)
2823 if err != nil {
2824 return nil, err
2825 }
2826 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
2827
2828 params := url.Values{}
2829 params.Add("$alt", "json;enum-encoding=int")
2830
2831 baseUrl.RawQuery = params.Encode()
2832
2833 // Build HTTP headers from client and context metadata.
2834 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2835
2836 hds = append(c.xGoogHeaders, hds...)
2837 hds = append(hds, "Content-Type", "application/json")
2838 headers := gax.BuildHeaders(ctx, hds...)
2839 opts = append((*c.CallOptions).GetLocation[0:len((*c.CallOptions).GetLocation):len((*c.CallOptions).GetLocation)], opts...)
2840 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2841 resp := &locationpb.Location{}
2842 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2843 if settings.Path != "" {
2844 baseUrl.Path = settings.Path
2845 }
2846 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2847 if err != nil {
2848 return err
2849 }
2850 httpReq = httpReq.WithContext(ctx)
2851 httpReq.Header = headers
2852
2853 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetLocation")
2854 if err != nil {
2855 return err
2856 }
2857
2858 if err := unm.Unmarshal(buf, resp); err != nil {
2859 return err
2860 }
2861
2862 return nil
2863 }, opts...)
2864 if e != nil {
2865 return nil, e
2866 }
2867 return resp, nil
2868 }
2869
2870 // ListLocations lists information about the supported locations for this service.
2871 func (c *managedSchemaRegistryRESTClient) ListLocations(ctx context.Context, req *locationpb.ListLocationsRequest, opts ...gax.CallOption) *LocationIterator {
2872 it := &LocationIterator{}
2873 req = proto.Clone(req).(*locationpb.ListLocationsRequest)
2874 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
2875 it.InternalFetch = func(pageSize int, pageToken string) ([]*locationpb.Location, string, error) {
2876 resp := &locationpb.ListLocationsResponse{}
2877 if pageToken != "" {
2878 req.PageToken = pageToken
2879 }
2880 if pageSize > math.MaxInt32 {
2881 req.PageSize = math.MaxInt32
2882 } else if pageSize != 0 {
2883 req.PageSize = int32(pageSize)
2884 }
2885 baseUrl, err := url.Parse(c.endpoint)
2886 if err != nil {
2887 return nil, "", err
2888 }
2889 baseUrl.Path += fmt.Sprintf("/v1/%v/locations", req.GetName())
2890
2891 params := url.Values{}
2892 params.Add("$alt", "json;enum-encoding=int")
2893 if req.GetFilter() != "" {
2894 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
2895 }
2896 if req.GetPageSize() != 0 {
2897 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
2898 }
2899 if req.GetPageToken() != "" {
2900 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
2901 }
2902
2903 baseUrl.RawQuery = params.Encode()
2904
2905 // Build HTTP headers from client and context metadata.
2906 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
2907 headers := gax.BuildHeaders(ctx, hds...)
2908 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2909 if settings.Path != "" {
2910 baseUrl.Path = settings.Path
2911 }
2912 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
2913 if err != nil {
2914 return err
2915 }
2916 httpReq.Header = headers
2917
2918 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListLocations")
2919 if err != nil {
2920 return err
2921 }
2922 if err := unm.Unmarshal(buf, resp); err != nil {
2923 return err
2924 }
2925
2926 return nil
2927 }, opts...)
2928 if e != nil {
2929 return nil, "", e
2930 }
2931 it.Response = resp
2932 return resp.GetLocations(), resp.GetNextPageToken(), nil
2933 }
2934
2935 fetch := func(pageSize int, pageToken string) (string, error) {
2936 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
2937 if err != nil {
2938 return "", err
2939 }
2940 it.items = append(it.items, items...)
2941 return nextPageToken, nil
2942 }
2943
2944 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
2945 it.pageInfo.MaxSize = int(req.GetPageSize())
2946 it.pageInfo.Token = req.GetPageToken()
2947
2948 return it
2949 }
2950
2951 // CancelOperation is a utility method from google.longrunning.Operations.
2952 func (c *managedSchemaRegistryRESTClient) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest, opts ...gax.CallOption) error {
2953 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
2954 jsonReq, err := m.Marshal(req)
2955 if err != nil {
2956 return err
2957 }
2958
2959 baseUrl, err := url.Parse(c.endpoint)
2960 if err != nil {
2961 return err
2962 }
2963 baseUrl.Path += fmt.Sprintf("/v1/%v:cancel", req.GetName())
2964
2965 params := url.Values{}
2966 params.Add("$alt", "json;enum-encoding=int")
2967
2968 baseUrl.RawQuery = params.Encode()
2969
2970 // Build HTTP headers from client and context metadata.
2971 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
2972
2973 hds = append(c.xGoogHeaders, hds...)
2974 hds = append(hds, "Content-Type", "application/json")
2975 headers := gax.BuildHeaders(ctx, hds...)
2976 return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
2977 if settings.Path != "" {
2978 baseUrl.Path = settings.Path
2979 }
2980 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
2981 if err != nil {
2982 return err
2983 }
2984 httpReq = httpReq.WithContext(ctx)
2985 httpReq.Header = headers
2986
2987 _, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CancelOperation")
2988 return err
2989 }, opts...)
2990 }
2991
2992 // DeleteOperation is a utility method from google.longrunning.Operations.
2993 func (c *managedSchemaRegistryRESTClient) DeleteOperation(ctx context.Context, req *longrunningpb.DeleteOperationRequest, opts ...gax.CallOption) error {
2994 baseUrl, err := url.Parse(c.endpoint)
2995 if err != nil {
2996 return err
2997 }
2998 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
2999
3000 params := url.Values{}
3001 params.Add("$alt", "json;enum-encoding=int")
3002
3003 baseUrl.RawQuery = params.Encode()
3004
3005 // Build HTTP headers from client and context metadata.
3006 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
3007
3008 hds = append(c.xGoogHeaders, hds...)
3009 hds = append(hds, "Content-Type", "application/json")
3010 headers := gax.BuildHeaders(ctx, hds...)
3011 return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3012 if settings.Path != "" {
3013 baseUrl.Path = settings.Path
3014 }
3015 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
3016 if err != nil {
3017 return err
3018 }
3019 httpReq = httpReq.WithContext(ctx)
3020 httpReq.Header = headers
3021
3022 _, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteOperation")
3023 return err
3024 }, opts...)
3025 }
3026
3027 // GetOperation is a utility method from google.longrunning.Operations.
3028 func (c *managedSchemaRegistryRESTClient) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest, opts ...gax.CallOption) (*longrunningpb.Operation, error) {
3029 baseUrl, err := url.Parse(c.endpoint)
3030 if err != nil {
3031 return nil, err
3032 }
3033 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
3034
3035 params := url.Values{}
3036 params.Add("$alt", "json;enum-encoding=int")
3037
3038 baseUrl.RawQuery = params.Encode()
3039
3040 // Build HTTP headers from client and context metadata.
3041 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
3042
3043 hds = append(c.xGoogHeaders, hds...)
3044 hds = append(hds, "Content-Type", "application/json")
3045 headers := gax.BuildHeaders(ctx, hds...)
3046 opts = append((*c.CallOptions).GetOperation[0:len((*c.CallOptions).GetOperation):len((*c.CallOptions).GetOperation)], opts...)
3047 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
3048 resp := &longrunningpb.Operation{}
3049 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3050 if settings.Path != "" {
3051 baseUrl.Path = settings.Path
3052 }
3053 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
3054 if err != nil {
3055 return err
3056 }
3057 httpReq = httpReq.WithContext(ctx)
3058 httpReq.Header = headers
3059
3060 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetOperation")
3061 if err != nil {
3062 return err
3063 }
3064
3065 if err := unm.Unmarshal(buf, resp); err != nil {
3066 return err
3067 }
3068
3069 return nil
3070 }, opts...)
3071 if e != nil {
3072 return nil, e
3073 }
3074 return resp, nil
3075 }
3076
3077 // ListOperations is a utility method from google.longrunning.Operations.
3078 func (c *managedSchemaRegistryRESTClient) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest, opts ...gax.CallOption) *OperationIterator {
3079 it := &OperationIterator{}
3080 req = proto.Clone(req).(*longrunningpb.ListOperationsRequest)
3081 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
3082 it.InternalFetch = func(pageSize int, pageToken string) ([]*longrunningpb.Operation, string, error) {
3083 resp := &longrunningpb.ListOperationsResponse{}
3084 if pageToken != "" {
3085 req.PageToken = pageToken
3086 }
3087 if pageSize > math.MaxInt32 {
3088 req.PageSize = math.MaxInt32
3089 } else if pageSize != 0 {
3090 req.PageSize = int32(pageSize)
3091 }
3092 baseUrl, err := url.Parse(c.endpoint)
3093 if err != nil {
3094 return nil, "", err
3095 }
3096 baseUrl.Path += fmt.Sprintf("/v1/%v/operations", req.GetName())
3097
3098 params := url.Values{}
3099 params.Add("$alt", "json;enum-encoding=int")
3100 if req.GetFilter() != "" {
3101 params.Add("filter", fmt.Sprintf("%v", req.GetFilter()))
3102 }
3103 if req.GetPageSize() != 0 {
3104 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
3105 }
3106 if req.GetPageToken() != "" {
3107 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
3108 }
3109
3110 baseUrl.RawQuery = params.Encode()
3111
3112 // Build HTTP headers from client and context metadata.
3113 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
3114 headers := gax.BuildHeaders(ctx, hds...)
3115 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
3116 if settings.Path != "" {
3117 baseUrl.Path = settings.Path
3118 }
3119 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
3120 if err != nil {
3121 return err
3122 }
3123 httpReq.Header = headers
3124
3125 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListOperations")
3126 if err != nil {
3127 return err
3128 }
3129 if err := unm.Unmarshal(buf, resp); err != nil {
3130 return err
3131 }
3132
3133 return nil
3134 }, opts...)
3135 if e != nil {
3136 return nil, "", e
3137 }
3138 it.Response = resp
3139 return resp.GetOperations(), resp.GetNextPageToken(), nil
3140 }
3141
3142 fetch := func(pageSize int, pageToken string) (string, error) {
3143 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
3144 if err != nil {
3145 return "", err
3146 }
3147 it.items = append(it.items, items...)
3148 return nextPageToken, nil
3149 }
3150
3151 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
3152 it.pageInfo.MaxSize = int(req.GetPageSize())
3153 it.pageInfo.Token = req.GetPageToken()
3154
3155 return it
3156 }