Debian Codegraph @

pubsub/v2/apiv1/schema_client.go

raw
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 pubsub
18
19 import (
20 "bytes"
21 "context"
22 "fmt"
23 "log/slog"
24 "math"
25 "net/http"
26 "net/url"
27 "time"
28
29 iampb "cloud.google.com/go/iam/apiv1/iampb"
30 pubsubpb "cloud.google.com/go/pubsub/v2/apiv1/pubsubpb"
31 gax "github.com/googleapis/gax-go/v2"
32 "google.golang.org/api/iterator"
33 "google.golang.org/api/option"
34 "google.golang.org/api/option/internaloption"
35 gtransport "google.golang.org/api/transport/grpc"
36 httptransport "google.golang.org/api/transport/http"
37 "google.golang.org/grpc"
38 "google.golang.org/grpc/codes"
39 "google.golang.org/protobuf/encoding/protojson"
40 "google.golang.org/protobuf/proto"
41 )
42
43 var newSchemaClientHook clientHook
44
45 // SchemaCallOptions contains the retry settings for each method of SchemaClient.
46 type SchemaCallOptions struct {
47 CreateSchema []gax.CallOption
48 GetSchema []gax.CallOption
49 ListSchemas []gax.CallOption
50 ListSchemaRevisions []gax.CallOption
51 CommitSchema []gax.CallOption
52 RollbackSchema []gax.CallOption
53 DeleteSchemaRevision []gax.CallOption
54 DeleteSchema []gax.CallOption
55 ValidateSchema []gax.CallOption
56 ValidateMessage []gax.CallOption
57 GetIamPolicy []gax.CallOption
58 SetIamPolicy []gax.CallOption
59 TestIamPermissions []gax.CallOption
60 }
61
62 func defaultSchemaGRPCClientOptions() []option.ClientOption {
63 return []option.ClientOption{
64 internaloption.WithDefaultEndpoint("pubsub.googleapis.com:443"),
65 internaloption.WithDefaultEndpointTemplate("pubsub.UNIVERSE_DOMAIN:443"),
66 internaloption.WithDefaultMTLSEndpoint("pubsub.mtls.googleapis.com:443"),
67 internaloption.WithDefaultUniverseDomain("googleapis.com"),
68 internaloption.WithDefaultAudience("https://pubsub.googleapis.com/"),
69 internaloption.WithDefaultScopes(DefaultAuthScopes()...),
70 internaloption.EnableJwtWithScope(),
71 internaloption.EnableNewAuthLibrary(),
72 option.WithGRPCDialOption(grpc.WithDefaultCallOptions(
73 grpc.MaxCallRecvMsgSize(math.MaxInt32))),
74 }
75 }
76
77 func defaultSchemaCallOptions() *SchemaCallOptions {
78 return &SchemaCallOptions{
79 CreateSchema: []gax.CallOption{
80 gax.WithTimeout(60000 * time.Millisecond),
81 gax.WithRetry(func() gax.Retryer {
82 return gax.OnCodes([]codes.Code{
83 codes.Unavailable,
84 }, gax.Backoff{
85 Initial: 100 * time.Millisecond,
86 Max: 60000 * time.Millisecond,
87 Multiplier: 1.30,
88 })
89 }),
90 },
91 GetSchema: []gax.CallOption{
92 gax.WithTimeout(60000 * time.Millisecond),
93 gax.WithRetry(func() gax.Retryer {
94 return gax.OnCodes([]codes.Code{
95 codes.Unavailable,
96 }, gax.Backoff{
97 Initial: 100 * time.Millisecond,
98 Max: 60000 * time.Millisecond,
99 Multiplier: 1.30,
100 })
101 }),
102 },
103 ListSchemas: []gax.CallOption{
104 gax.WithTimeout(60000 * time.Millisecond),
105 gax.WithRetry(func() gax.Retryer {
106 return gax.OnCodes([]codes.Code{
107 codes.Unavailable,
108 }, gax.Backoff{
109 Initial: 100 * time.Millisecond,
110 Max: 60000 * time.Millisecond,
111 Multiplier: 1.30,
112 })
113 }),
114 },
115 ListSchemaRevisions: []gax.CallOption{
116 gax.WithTimeout(60000 * time.Millisecond),
117 gax.WithRetry(func() gax.Retryer {
118 return gax.OnCodes([]codes.Code{
119 codes.Unavailable,
120 }, gax.Backoff{
121 Initial: 100 * time.Millisecond,
122 Max: 60000 * time.Millisecond,
123 Multiplier: 1.30,
124 })
125 }),
126 },
127 CommitSchema: []gax.CallOption{
128 gax.WithTimeout(60000 * time.Millisecond),
129 gax.WithRetry(func() gax.Retryer {
130 return gax.OnCodes([]codes.Code{
131 codes.Unavailable,
132 }, gax.Backoff{
133 Initial: 100 * time.Millisecond,
134 Max: 60000 * time.Millisecond,
135 Multiplier: 1.30,
136 })
137 }),
138 },
139 RollbackSchema: []gax.CallOption{
140 gax.WithTimeout(60000 * time.Millisecond),
141 gax.WithRetry(func() gax.Retryer {
142 return gax.OnCodes([]codes.Code{
143 codes.Unavailable,
144 }, gax.Backoff{
145 Initial: 100 * time.Millisecond,
146 Max: 60000 * time.Millisecond,
147 Multiplier: 1.30,
148 })
149 }),
150 },
151 DeleteSchemaRevision: []gax.CallOption{
152 gax.WithTimeout(60000 * time.Millisecond),
153 gax.WithRetry(func() gax.Retryer {
154 return gax.OnCodes([]codes.Code{
155 codes.Unavailable,
156 }, gax.Backoff{
157 Initial: 100 * time.Millisecond,
158 Max: 60000 * time.Millisecond,
159 Multiplier: 1.30,
160 })
161 }),
162 },
163 DeleteSchema: []gax.CallOption{
164 gax.WithTimeout(60000 * time.Millisecond),
165 gax.WithRetry(func() gax.Retryer {
166 return gax.OnCodes([]codes.Code{
167 codes.Unavailable,
168 }, gax.Backoff{
169 Initial: 100 * time.Millisecond,
170 Max: 60000 * time.Millisecond,
171 Multiplier: 1.30,
172 })
173 }),
174 },
175 ValidateSchema: []gax.CallOption{
176 gax.WithTimeout(60000 * time.Millisecond),
177 gax.WithRetry(func() gax.Retryer {
178 return gax.OnCodes([]codes.Code{
179 codes.Unavailable,
180 }, gax.Backoff{
181 Initial: 100 * time.Millisecond,
182 Max: 60000 * time.Millisecond,
183 Multiplier: 1.30,
184 })
185 }),
186 },
187 ValidateMessage: []gax.CallOption{
188 gax.WithTimeout(60000 * time.Millisecond),
189 gax.WithRetry(func() gax.Retryer {
190 return gax.OnCodes([]codes.Code{
191 codes.Unavailable,
192 }, gax.Backoff{
193 Initial: 100 * time.Millisecond,
194 Max: 60000 * time.Millisecond,
195 Multiplier: 1.30,
196 })
197 }),
198 },
199 GetIamPolicy: []gax.CallOption{},
200 SetIamPolicy: []gax.CallOption{},
201 TestIamPermissions: []gax.CallOption{},
202 }
203 }
204
205 func defaultSchemaRESTCallOptions() *SchemaCallOptions {
206 return &SchemaCallOptions{
207 CreateSchema: []gax.CallOption{
208 gax.WithTimeout(60000 * time.Millisecond),
209 gax.WithRetry(func() gax.Retryer {
210 return gax.OnHTTPCodes(gax.Backoff{
211 Initial: 100 * time.Millisecond,
212 Max: 60000 * time.Millisecond,
213 Multiplier: 1.30,
214 },
215 http.StatusServiceUnavailable)
216 }),
217 },
218 GetSchema: []gax.CallOption{
219 gax.WithTimeout(60000 * time.Millisecond),
220 gax.WithRetry(func() gax.Retryer {
221 return gax.OnHTTPCodes(gax.Backoff{
222 Initial: 100 * time.Millisecond,
223 Max: 60000 * time.Millisecond,
224 Multiplier: 1.30,
225 },
226 http.StatusServiceUnavailable)
227 }),
228 },
229 ListSchemas: []gax.CallOption{
230 gax.WithTimeout(60000 * time.Millisecond),
231 gax.WithRetry(func() gax.Retryer {
232 return gax.OnHTTPCodes(gax.Backoff{
233 Initial: 100 * time.Millisecond,
234 Max: 60000 * time.Millisecond,
235 Multiplier: 1.30,
236 },
237 http.StatusServiceUnavailable)
238 }),
239 },
240 ListSchemaRevisions: []gax.CallOption{
241 gax.WithTimeout(60000 * time.Millisecond),
242 gax.WithRetry(func() gax.Retryer {
243 return gax.OnHTTPCodes(gax.Backoff{
244 Initial: 100 * time.Millisecond,
245 Max: 60000 * time.Millisecond,
246 Multiplier: 1.30,
247 },
248 http.StatusServiceUnavailable)
249 }),
250 },
251 CommitSchema: []gax.CallOption{
252 gax.WithTimeout(60000 * time.Millisecond),
253 gax.WithRetry(func() gax.Retryer {
254 return gax.OnHTTPCodes(gax.Backoff{
255 Initial: 100 * time.Millisecond,
256 Max: 60000 * time.Millisecond,
257 Multiplier: 1.30,
258 },
259 http.StatusServiceUnavailable)
260 }),
261 },
262 RollbackSchema: []gax.CallOption{
263 gax.WithTimeout(60000 * time.Millisecond),
264 gax.WithRetry(func() gax.Retryer {
265 return gax.OnHTTPCodes(gax.Backoff{
266 Initial: 100 * time.Millisecond,
267 Max: 60000 * time.Millisecond,
268 Multiplier: 1.30,
269 },
270 http.StatusServiceUnavailable)
271 }),
272 },
273 DeleteSchemaRevision: []gax.CallOption{
274 gax.WithTimeout(60000 * time.Millisecond),
275 gax.WithRetry(func() gax.Retryer {
276 return gax.OnHTTPCodes(gax.Backoff{
277 Initial: 100 * time.Millisecond,
278 Max: 60000 * time.Millisecond,
279 Multiplier: 1.30,
280 },
281 http.StatusServiceUnavailable)
282 }),
283 },
284 DeleteSchema: []gax.CallOption{
285 gax.WithTimeout(60000 * time.Millisecond),
286 gax.WithRetry(func() gax.Retryer {
287 return gax.OnHTTPCodes(gax.Backoff{
288 Initial: 100 * time.Millisecond,
289 Max: 60000 * time.Millisecond,
290 Multiplier: 1.30,
291 },
292 http.StatusServiceUnavailable)
293 }),
294 },
295 ValidateSchema: []gax.CallOption{
296 gax.WithTimeout(60000 * time.Millisecond),
297 gax.WithRetry(func() gax.Retryer {
298 return gax.OnHTTPCodes(gax.Backoff{
299 Initial: 100 * time.Millisecond,
300 Max: 60000 * time.Millisecond,
301 Multiplier: 1.30,
302 },
303 http.StatusServiceUnavailable)
304 }),
305 },
306 ValidateMessage: []gax.CallOption{
307 gax.WithTimeout(60000 * time.Millisecond),
308 gax.WithRetry(func() gax.Retryer {
309 return gax.OnHTTPCodes(gax.Backoff{
310 Initial: 100 * time.Millisecond,
311 Max: 60000 * time.Millisecond,
312 Multiplier: 1.30,
313 },
314 http.StatusServiceUnavailable)
315 }),
316 },
317 GetIamPolicy: []gax.CallOption{},
318 SetIamPolicy: []gax.CallOption{},
319 TestIamPermissions: []gax.CallOption{},
320 }
321 }
322
323 // internalSchemaClient is an interface that defines the methods available from Cloud Pub/Sub API.
324 type internalSchemaClient interface {
325 Close() error
326 setGoogleClientInfo(...string)
327 Connection() *grpc.ClientConn
328 CreateSchema(context.Context, *pubsubpb.CreateSchemaRequest, ...gax.CallOption) (*pubsubpb.Schema, error)
329 GetSchema(context.Context, *pubsubpb.GetSchemaRequest, ...gax.CallOption) (*pubsubpb.Schema, error)
330 ListSchemas(context.Context, *pubsubpb.ListSchemasRequest, ...gax.CallOption) *SchemaIterator
331 ListSchemaRevisions(context.Context, *pubsubpb.ListSchemaRevisionsRequest, ...gax.CallOption) *SchemaIterator
332 CommitSchema(context.Context, *pubsubpb.CommitSchemaRequest, ...gax.CallOption) (*pubsubpb.Schema, error)
333 RollbackSchema(context.Context, *pubsubpb.RollbackSchemaRequest, ...gax.CallOption) (*pubsubpb.Schema, error)
334 DeleteSchemaRevision(context.Context, *pubsubpb.DeleteSchemaRevisionRequest, ...gax.CallOption) (*pubsubpb.Schema, error)
335 DeleteSchema(context.Context, *pubsubpb.DeleteSchemaRequest, ...gax.CallOption) error
336 ValidateSchema(context.Context, *pubsubpb.ValidateSchemaRequest, ...gax.CallOption) (*pubsubpb.ValidateSchemaResponse, error)
337 ValidateMessage(context.Context, *pubsubpb.ValidateMessageRequest, ...gax.CallOption) (*pubsubpb.ValidateMessageResponse, error)
338 GetIamPolicy(context.Context, *iampb.GetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error)
339 SetIamPolicy(context.Context, *iampb.SetIamPolicyRequest, ...gax.CallOption) (*iampb.Policy, error)
340 TestIamPermissions(context.Context, *iampb.TestIamPermissionsRequest, ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error)
341 }
342
343 // SchemaClient is a client for interacting with Cloud Pub/Sub API.
344 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
345 //
346 // Service for doing schema-related operations.
347 type SchemaClient struct {
348 // The internal transport-dependent client.
349 internalClient internalSchemaClient
350
351 // The call options for this service.
352 CallOptions *SchemaCallOptions
353 }
354
355 // Wrapper methods routed to the internal client.
356
357 // Close closes the connection to the API service. The user should invoke this when
358 // the client is no longer required.
359 func (c *SchemaClient) Close() error {
360 return c.internalClient.Close()
361 }
362
363 // setGoogleClientInfo sets the name and version of the application in
364 // the `x-goog-api-client` header passed on each request. Intended for
365 // use by Google-written clients.
366 func (c *SchemaClient) setGoogleClientInfo(keyval ...string) {
367 c.internalClient.setGoogleClientInfo(keyval...)
368 }
369
370 // Connection returns a connection to the API service.
371 //
372 // Deprecated: Connections are now pooled so this method does not always
373 // return the same resource.
374 func (c *SchemaClient) Connection() *grpc.ClientConn {
375 return c.internalClient.Connection()
376 }
377
378 // CreateSchema creates a schema.
379 func (c *SchemaClient) CreateSchema(ctx context.Context, req *pubsubpb.CreateSchemaRequest, opts ...gax.CallOption) (*pubsubpb.Schema, error) {
380 return c.internalClient.CreateSchema(ctx, req, opts...)
381 }
382
383 // GetSchema gets a schema.
384 func (c *SchemaClient) GetSchema(ctx context.Context, req *pubsubpb.GetSchemaRequest, opts ...gax.CallOption) (*pubsubpb.Schema, error) {
385 return c.internalClient.GetSchema(ctx, req, opts...)
386 }
387
388 // ListSchemas lists schemas in a project.
389 func (c *SchemaClient) ListSchemas(ctx context.Context, req *pubsubpb.ListSchemasRequest, opts ...gax.CallOption) *SchemaIterator {
390 return c.internalClient.ListSchemas(ctx, req, opts...)
391 }
392
393 // ListSchemaRevisions lists all schema revisions for the named schema.
394 func (c *SchemaClient) ListSchemaRevisions(ctx context.Context, req *pubsubpb.ListSchemaRevisionsRequest, opts ...gax.CallOption) *SchemaIterator {
395 return c.internalClient.ListSchemaRevisions(ctx, req, opts...)
396 }
397
398 // CommitSchema commits a new schema revision to an existing schema.
399 func (c *SchemaClient) CommitSchema(ctx context.Context, req *pubsubpb.CommitSchemaRequest, opts ...gax.CallOption) (*pubsubpb.Schema, error) {
400 return c.internalClient.CommitSchema(ctx, req, opts...)
401 }
402
403 // RollbackSchema creates a new schema revision that is a copy of the provided revision_id.
404 func (c *SchemaClient) RollbackSchema(ctx context.Context, req *pubsubpb.RollbackSchemaRequest, opts ...gax.CallOption) (*pubsubpb.Schema, error) {
405 return c.internalClient.RollbackSchema(ctx, req, opts...)
406 }
407
408 // DeleteSchemaRevision deletes a specific schema revision.
409 func (c *SchemaClient) DeleteSchemaRevision(ctx context.Context, req *pubsubpb.DeleteSchemaRevisionRequest, opts ...gax.CallOption) (*pubsubpb.Schema, error) {
410 return c.internalClient.DeleteSchemaRevision(ctx, req, opts...)
411 }
412
413 // DeleteSchema deletes a schema.
414 func (c *SchemaClient) DeleteSchema(ctx context.Context, req *pubsubpb.DeleteSchemaRequest, opts ...gax.CallOption) error {
415 return c.internalClient.DeleteSchema(ctx, req, opts...)
416 }
417
418 // ValidateSchema validates a schema.
419 func (c *SchemaClient) ValidateSchema(ctx context.Context, req *pubsubpb.ValidateSchemaRequest, opts ...gax.CallOption) (*pubsubpb.ValidateSchemaResponse, error) {
420 return c.internalClient.ValidateSchema(ctx, req, opts...)
421 }
422
423 // ValidateMessage validates a message against a schema.
424 func (c *SchemaClient) ValidateMessage(ctx context.Context, req *pubsubpb.ValidateMessageRequest, opts ...gax.CallOption) (*pubsubpb.ValidateMessageResponse, error) {
425 return c.internalClient.ValidateMessage(ctx, req, opts...)
426 }
427
428 // GetIamPolicy gets the access control policy for a resource. Returns an empty policy
429 // if the resource exists and does not have a policy set.
430 func (c *SchemaClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
431 return c.internalClient.GetIamPolicy(ctx, req, opts...)
432 }
433
434 // SetIamPolicy sets the access control policy on the specified resource. Replaces
435 // any existing policy.
436 //
437 // Can return NOT_FOUND, INVALID_ARGUMENT, and PERMISSION_DENIED
438 // errors.
439 func (c *SchemaClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
440 return c.internalClient.SetIamPolicy(ctx, req, opts...)
441 }
442
443 // TestIamPermissions returns permissions that a caller has on the specified resource. If the
444 // resource does not exist, this will return an empty set of
445 // permissions, not a NOT_FOUND error.
446 //
447 // Note: This operation is designed to be used for building
448 // permission-aware UIs and command-line tools, not for authorization
449 // checking. This operation may “fail open” without warning.
450 func (c *SchemaClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
451 return c.internalClient.TestIamPermissions(ctx, req, opts...)
452 }
453
454 // schemaGRPCClient is a client for interacting with Cloud Pub/Sub API over gRPC transport.
455 //
456 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
457 type schemaGRPCClient struct {
458 // Connection pool of gRPC connections to the service.
459 connPool gtransport.ConnPool
460
461 // Points back to the CallOptions field of the containing SchemaClient
462 CallOptions **SchemaCallOptions
463
464 // The gRPC API client.
465 schemaClient pubsubpb.SchemaServiceClient
466
467 iamPolicyClient iampb.IAMPolicyClient
468
469 // The x-goog-* metadata to be sent with each request.
470 xGoogHeaders []string
471
472 logger *slog.Logger
473 }
474
475 // NewSchemaClient creates a new schema service client based on gRPC.
476 // The returned client must be Closed when it is done being used to clean up its underlying connections.
477 //
478 // Service for doing schema-related operations.
479 func NewSchemaClient(ctx context.Context, opts ...option.ClientOption) (*SchemaClient, error) {
480 clientOpts := defaultSchemaGRPCClientOptions()
481 if newSchemaClientHook != nil {
482 hookOpts, err := newSchemaClientHook(ctx, clientHookParams{})
483 if err != nil {
484 return nil, err
485 }
486 clientOpts = append(clientOpts, hookOpts...)
487 }
488
489 connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...)
490 if err != nil {
491 return nil, err
492 }
493 client := SchemaClient{CallOptions: defaultSchemaCallOptions()}
494
495 c := &schemaGRPCClient{
496 connPool: connPool,
497 schemaClient: pubsubpb.NewSchemaServiceClient(connPool),
498 CallOptions: &client.CallOptions,
499 logger: internaloption.GetLogger(opts),
500 iamPolicyClient: iampb.NewIAMPolicyClient(connPool),
501 }
502 c.setGoogleClientInfo()
503
504 client.internalClient = c
505
506 return &client, nil
507 }
508
509 // Connection returns a connection to the API service.
510 //
511 // Deprecated: Connections are now pooled so this method does not always
512 // return the same resource.
513 func (c *schemaGRPCClient) Connection() *grpc.ClientConn {
514 return c.connPool.Conn()
515 }
516
517 // setGoogleClientInfo sets the name and version of the application in
518 // the `x-goog-api-client` header passed on each request. Intended for
519 // use by Google-written clients.
520 func (c *schemaGRPCClient) setGoogleClientInfo(keyval ...string) {
521 kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
522 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "grpc", grpc.Version, "pb", protoVersion)
523 c.xGoogHeaders = []string{
524 "x-goog-api-client", gax.XGoogHeader(kv...),
525 }
526 }
527
528 // Close closes the connection to the API service. The user should invoke this when
529 // the client is no longer required.
530 func (c *schemaGRPCClient) Close() error {
531 return c.connPool.Close()
532 }
533
534 // Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
535 type schemaRESTClient struct {
536 // The http endpoint to connect to.
537 endpoint string
538
539 // The http client.
540 httpClient *http.Client
541
542 // The x-goog-* headers to be sent with each request.
543 xGoogHeaders []string
544
545 // Points back to the CallOptions field of the containing SchemaClient
546 CallOptions **SchemaCallOptions
547
548 logger *slog.Logger
549 }
550
551 // NewSchemaRESTClient creates a new schema service rest client.
552 //
553 // Service for doing schema-related operations.
554 func NewSchemaRESTClient(ctx context.Context, opts ...option.ClientOption) (*SchemaClient, error) {
555 clientOpts := append(defaultSchemaRESTClientOptions(), opts...)
556 httpClient, endpoint, err := httptransport.NewClient(ctx, clientOpts...)
557 if err != nil {
558 return nil, err
559 }
560
561 callOpts := defaultSchemaRESTCallOptions()
562 c := &schemaRESTClient{
563 endpoint: endpoint,
564 httpClient: httpClient,
565 CallOptions: &callOpts,
566 logger: internaloption.GetLogger(opts),
567 }
568 c.setGoogleClientInfo()
569
570 return &SchemaClient{internalClient: c, CallOptions: callOpts}, nil
571 }
572
573 func defaultSchemaRESTClientOptions() []option.ClientOption {
574 return []option.ClientOption{
575 internaloption.WithDefaultEndpoint("https://pubsub.googleapis.com"),
576 internaloption.WithDefaultEndpointTemplate("https://pubsub.UNIVERSE_DOMAIN"),
577 internaloption.WithDefaultMTLSEndpoint("https://pubsub.mtls.googleapis.com"),
578 internaloption.WithDefaultUniverseDomain("googleapis.com"),
579 internaloption.WithDefaultAudience("https://pubsub.googleapis.com/"),
580 internaloption.WithDefaultScopes(DefaultAuthScopes()...),
581 internaloption.EnableNewAuthLibrary(),
582 }
583 }
584
585 // setGoogleClientInfo sets the name and version of the application in
586 // the `x-goog-api-client` header passed on each request. Intended for
587 // use by Google-written clients.
588 func (c *schemaRESTClient) setGoogleClientInfo(keyval ...string) {
589 kv := append([]string{"gl-go", gax.GoVersion}, keyval...)
590 kv = append(kv, "gapic", getVersionClient(), "gax", gax.Version, "rest", "UNKNOWN", "pb", protoVersion)
591 c.xGoogHeaders = []string{
592 "x-goog-api-client", gax.XGoogHeader(kv...),
593 }
594 }
595
596 // Close closes the connection to the API service. The user should invoke this when
597 // the client is no longer required.
598 func (c *schemaRESTClient) Close() error {
599 // Replace httpClient with nil to force cleanup.
600 c.httpClient = nil
601 return nil
602 }
603
604 // Connection returns a connection to the API service.
605 //
606 // Deprecated: This method always returns nil.
607 func (c *schemaRESTClient) Connection() *grpc.ClientConn {
608 return nil
609 }
610 func (c *schemaGRPCClient) CreateSchema(ctx context.Context, req *pubsubpb.CreateSchemaRequest, opts ...gax.CallOption) (*pubsubpb.Schema, error) {
611 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
612
613 hds = append(c.xGoogHeaders, hds...)
614 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
615 opts = append((*c.CallOptions).CreateSchema[0:len((*c.CallOptions).CreateSchema):len((*c.CallOptions).CreateSchema)], opts...)
616 var resp *pubsubpb.Schema
617 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
618 var err error
619 resp, err = executeRPC(ctx, c.schemaClient.CreateSchema, req, settings.GRPC, c.logger, "CreateSchema")
620 return err
621 }, opts...)
622 if err != nil {
623 return nil, err
624 }
625 return resp, nil
626 }
627
628 func (c *schemaGRPCClient) GetSchema(ctx context.Context, req *pubsubpb.GetSchemaRequest, opts ...gax.CallOption) (*pubsubpb.Schema, error) {
629 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
630
631 hds = append(c.xGoogHeaders, hds...)
632 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
633 opts = append((*c.CallOptions).GetSchema[0:len((*c.CallOptions).GetSchema):len((*c.CallOptions).GetSchema)], opts...)
634 var resp *pubsubpb.Schema
635 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
636 var err error
637 resp, err = executeRPC(ctx, c.schemaClient.GetSchema, req, settings.GRPC, c.logger, "GetSchema")
638 return err
639 }, opts...)
640 if err != nil {
641 return nil, err
642 }
643 return resp, nil
644 }
645
646 func (c *schemaGRPCClient) ListSchemas(ctx context.Context, req *pubsubpb.ListSchemasRequest, opts ...gax.CallOption) *SchemaIterator {
647 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
648
649 hds = append(c.xGoogHeaders, hds...)
650 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
651 opts = append((*c.CallOptions).ListSchemas[0:len((*c.CallOptions).ListSchemas):len((*c.CallOptions).ListSchemas)], opts...)
652 it := &SchemaIterator{}
653 req = proto.Clone(req).(*pubsubpb.ListSchemasRequest)
654 it.InternalFetch = func(pageSize int, pageToken string) ([]*pubsubpb.Schema, string, error) {
655 resp := &pubsubpb.ListSchemasResponse{}
656 if pageToken != "" {
657 req.PageToken = pageToken
658 }
659 if pageSize > math.MaxInt32 {
660 req.PageSize = math.MaxInt32
661 } else if pageSize != 0 {
662 req.PageSize = int32(pageSize)
663 }
664 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
665 var err error
666 resp, err = executeRPC(ctx, c.schemaClient.ListSchemas, req, settings.GRPC, c.logger, "ListSchemas")
667 return err
668 }, opts...)
669 if err != nil {
670 return nil, "", err
671 }
672
673 it.Response = resp
674 return resp.GetSchemas(), resp.GetNextPageToken(), nil
675 }
676 fetch := func(pageSize int, pageToken string) (string, error) {
677 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
678 if err != nil {
679 return "", err
680 }
681 it.items = append(it.items, items...)
682 return nextPageToken, nil
683 }
684
685 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
686 it.pageInfo.MaxSize = int(req.GetPageSize())
687 it.pageInfo.Token = req.GetPageToken()
688
689 return it
690 }
691
692 func (c *schemaGRPCClient) ListSchemaRevisions(ctx context.Context, req *pubsubpb.ListSchemaRevisionsRequest, opts ...gax.CallOption) *SchemaIterator {
693 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
694
695 hds = append(c.xGoogHeaders, hds...)
696 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
697 opts = append((*c.CallOptions).ListSchemaRevisions[0:len((*c.CallOptions).ListSchemaRevisions):len((*c.CallOptions).ListSchemaRevisions)], opts...)
698 it := &SchemaIterator{}
699 req = proto.Clone(req).(*pubsubpb.ListSchemaRevisionsRequest)
700 it.InternalFetch = func(pageSize int, pageToken string) ([]*pubsubpb.Schema, string, error) {
701 resp := &pubsubpb.ListSchemaRevisionsResponse{}
702 if pageToken != "" {
703 req.PageToken = pageToken
704 }
705 if pageSize > math.MaxInt32 {
706 req.PageSize = math.MaxInt32
707 } else if pageSize != 0 {
708 req.PageSize = int32(pageSize)
709 }
710 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
711 var err error
712 resp, err = executeRPC(ctx, c.schemaClient.ListSchemaRevisions, req, settings.GRPC, c.logger, "ListSchemaRevisions")
713 return err
714 }, opts...)
715 if err != nil {
716 return nil, "", err
717 }
718
719 it.Response = resp
720 return resp.GetSchemas(), resp.GetNextPageToken(), nil
721 }
722 fetch := func(pageSize int, pageToken string) (string, error) {
723 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
724 if err != nil {
725 return "", err
726 }
727 it.items = append(it.items, items...)
728 return nextPageToken, nil
729 }
730
731 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
732 it.pageInfo.MaxSize = int(req.GetPageSize())
733 it.pageInfo.Token = req.GetPageToken()
734
735 return it
736 }
737
738 func (c *schemaGRPCClient) CommitSchema(ctx context.Context, req *pubsubpb.CommitSchemaRequest, opts ...gax.CallOption) (*pubsubpb.Schema, error) {
739 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
740
741 hds = append(c.xGoogHeaders, hds...)
742 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
743 opts = append((*c.CallOptions).CommitSchema[0:len((*c.CallOptions).CommitSchema):len((*c.CallOptions).CommitSchema)], opts...)
744 var resp *pubsubpb.Schema
745 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
746 var err error
747 resp, err = executeRPC(ctx, c.schemaClient.CommitSchema, req, settings.GRPC, c.logger, "CommitSchema")
748 return err
749 }, opts...)
750 if err != nil {
751 return nil, err
752 }
753 return resp, nil
754 }
755
756 func (c *schemaGRPCClient) RollbackSchema(ctx context.Context, req *pubsubpb.RollbackSchemaRequest, opts ...gax.CallOption) (*pubsubpb.Schema, 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).RollbackSchema[0:len((*c.CallOptions).RollbackSchema):len((*c.CallOptions).RollbackSchema)], opts...)
762 var resp *pubsubpb.Schema
763 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
764 var err error
765 resp, err = executeRPC(ctx, c.schemaClient.RollbackSchema, req, settings.GRPC, c.logger, "RollbackSchema")
766 return err
767 }, opts...)
768 if err != nil {
769 return nil, err
770 }
771 return resp, nil
772 }
773
774 func (c *schemaGRPCClient) DeleteSchemaRevision(ctx context.Context, req *pubsubpb.DeleteSchemaRevisionRequest, opts ...gax.CallOption) (*pubsubpb.Schema, error) {
775 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
776
777 hds = append(c.xGoogHeaders, hds...)
778 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
779 opts = append((*c.CallOptions).DeleteSchemaRevision[0:len((*c.CallOptions).DeleteSchemaRevision):len((*c.CallOptions).DeleteSchemaRevision)], opts...)
780 var resp *pubsubpb.Schema
781 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
782 var err error
783 resp, err = executeRPC(ctx, c.schemaClient.DeleteSchemaRevision, req, settings.GRPC, c.logger, "DeleteSchemaRevision")
784 return err
785 }, opts...)
786 if err != nil {
787 return nil, err
788 }
789 return resp, nil
790 }
791
792 func (c *schemaGRPCClient) DeleteSchema(ctx context.Context, req *pubsubpb.DeleteSchemaRequest, opts ...gax.CallOption) error {
793 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
794
795 hds = append(c.xGoogHeaders, hds...)
796 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
797 opts = append((*c.CallOptions).DeleteSchema[0:len((*c.CallOptions).DeleteSchema):len((*c.CallOptions).DeleteSchema)], opts...)
798 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
799 var err error
800 _, err = executeRPC(ctx, c.schemaClient.DeleteSchema, req, settings.GRPC, c.logger, "DeleteSchema")
801 return err
802 }, opts...)
803 return err
804 }
805
806 func (c *schemaGRPCClient) ValidateSchema(ctx context.Context, req *pubsubpb.ValidateSchemaRequest, opts ...gax.CallOption) (*pubsubpb.ValidateSchemaResponse, error) {
807 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
808
809 hds = append(c.xGoogHeaders, hds...)
810 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
811 opts = append((*c.CallOptions).ValidateSchema[0:len((*c.CallOptions).ValidateSchema):len((*c.CallOptions).ValidateSchema)], opts...)
812 var resp *pubsubpb.ValidateSchemaResponse
813 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
814 var err error
815 resp, err = executeRPC(ctx, c.schemaClient.ValidateSchema, req, settings.GRPC, c.logger, "ValidateSchema")
816 return err
817 }, opts...)
818 if err != nil {
819 return nil, err
820 }
821 return resp, nil
822 }
823
824 func (c *schemaGRPCClient) ValidateMessage(ctx context.Context, req *pubsubpb.ValidateMessageRequest, opts ...gax.CallOption) (*pubsubpb.ValidateMessageResponse, error) {
825 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
826
827 hds = append(c.xGoogHeaders, hds...)
828 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
829 opts = append((*c.CallOptions).ValidateMessage[0:len((*c.CallOptions).ValidateMessage):len((*c.CallOptions).ValidateMessage)], opts...)
830 var resp *pubsubpb.ValidateMessageResponse
831 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
832 var err error
833 resp, err = executeRPC(ctx, c.schemaClient.ValidateMessage, req, settings.GRPC, c.logger, "ValidateMessage")
834 return err
835 }, opts...)
836 if err != nil {
837 return nil, err
838 }
839 return resp, nil
840 }
841
842 func (c *schemaGRPCClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
843 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
844
845 hds = append(c.xGoogHeaders, hds...)
846 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
847 opts = append((*c.CallOptions).GetIamPolicy[0:len((*c.CallOptions).GetIamPolicy):len((*c.CallOptions).GetIamPolicy)], opts...)
848 var resp *iampb.Policy
849 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
850 var err error
851 resp, err = executeRPC(ctx, c.iamPolicyClient.GetIamPolicy, req, settings.GRPC, c.logger, "GetIamPolicy")
852 return err
853 }, opts...)
854 if err != nil {
855 return nil, err
856 }
857 return resp, nil
858 }
859
860 func (c *schemaGRPCClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
861 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
862
863 hds = append(c.xGoogHeaders, hds...)
864 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
865 opts = append((*c.CallOptions).SetIamPolicy[0:len((*c.CallOptions).SetIamPolicy):len((*c.CallOptions).SetIamPolicy)], opts...)
866 var resp *iampb.Policy
867 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
868 var err error
869 resp, err = executeRPC(ctx, c.iamPolicyClient.SetIamPolicy, req, settings.GRPC, c.logger, "SetIamPolicy")
870 return err
871 }, opts...)
872 if err != nil {
873 return nil, err
874 }
875 return resp, nil
876 }
877
878 func (c *schemaGRPCClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
879 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
880
881 hds = append(c.xGoogHeaders, hds...)
882 ctx = gax.InsertMetadataIntoOutgoingContext(ctx, hds...)
883 opts = append((*c.CallOptions).TestIamPermissions[0:len((*c.CallOptions).TestIamPermissions):len((*c.CallOptions).TestIamPermissions)], opts...)
884 var resp *iampb.TestIamPermissionsResponse
885 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
886 var err error
887 resp, err = executeRPC(ctx, c.iamPolicyClient.TestIamPermissions, req, settings.GRPC, c.logger, "TestIamPermissions")
888 return err
889 }, opts...)
890 if err != nil {
891 return nil, err
892 }
893 return resp, nil
894 }
895
896 // CreateSchema creates a schema.
897 func (c *schemaRESTClient) CreateSchema(ctx context.Context, req *pubsubpb.CreateSchemaRequest, opts ...gax.CallOption) (*pubsubpb.Schema, error) {
898 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
899 body := req.GetSchema()
900 jsonReq, err := m.Marshal(body)
901 if err != nil {
902 return nil, err
903 }
904
905 baseUrl, err := url.Parse(c.endpoint)
906 if err != nil {
907 return nil, err
908 }
909 baseUrl.Path += fmt.Sprintf("/v1/%v/schemas", req.GetParent())
910
911 params := url.Values{}
912 params.Add("$alt", "json;enum-encoding=int")
913 if req.GetSchemaId() != "" {
914 params.Add("schemaId", fmt.Sprintf("%v", req.GetSchemaId()))
915 }
916
917 baseUrl.RawQuery = params.Encode()
918
919 // Build HTTP headers from client and context metadata.
920 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
921
922 hds = append(c.xGoogHeaders, hds...)
923 hds = append(hds, "Content-Type", "application/json")
924 headers := gax.BuildHeaders(ctx, hds...)
925 opts = append((*c.CallOptions).CreateSchema[0:len((*c.CallOptions).CreateSchema):len((*c.CallOptions).CreateSchema)], opts...)
926 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
927 resp := &pubsubpb.Schema{}
928 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
929 if settings.Path != "" {
930 baseUrl.Path = settings.Path
931 }
932 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
933 if err != nil {
934 return err
935 }
936 httpReq = httpReq.WithContext(ctx)
937 httpReq.Header = headers
938
939 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CreateSchema")
940 if err != nil {
941 return err
942 }
943
944 if err := unm.Unmarshal(buf, resp); err != nil {
945 return err
946 }
947
948 return nil
949 }, opts...)
950 if e != nil {
951 return nil, e
952 }
953 return resp, nil
954 }
955
956 // GetSchema gets a schema.
957 func (c *schemaRESTClient) GetSchema(ctx context.Context, req *pubsubpb.GetSchemaRequest, opts ...gax.CallOption) (*pubsubpb.Schema, error) {
958 baseUrl, err := url.Parse(c.endpoint)
959 if err != nil {
960 return nil, err
961 }
962 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
963
964 params := url.Values{}
965 params.Add("$alt", "json;enum-encoding=int")
966 if req.GetView() != 0 {
967 params.Add("view", fmt.Sprintf("%v", req.GetView()))
968 }
969
970 baseUrl.RawQuery = params.Encode()
971
972 // Build HTTP headers from client and context metadata.
973 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
974
975 hds = append(c.xGoogHeaders, hds...)
976 hds = append(hds, "Content-Type", "application/json")
977 headers := gax.BuildHeaders(ctx, hds...)
978 opts = append((*c.CallOptions).GetSchema[0:len((*c.CallOptions).GetSchema):len((*c.CallOptions).GetSchema)], opts...)
979 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
980 resp := &pubsubpb.Schema{}
981 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
982 if settings.Path != "" {
983 baseUrl.Path = settings.Path
984 }
985 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
986 if err != nil {
987 return err
988 }
989 httpReq = httpReq.WithContext(ctx)
990 httpReq.Header = headers
991
992 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetSchema")
993 if err != nil {
994 return err
995 }
996
997 if err := unm.Unmarshal(buf, resp); err != nil {
998 return err
999 }
1000
1001 return nil
1002 }, opts...)
1003 if e != nil {
1004 return nil, e
1005 }
1006 return resp, nil
1007 }
1008
1009 // ListSchemas lists schemas in a project.
1010 func (c *schemaRESTClient) ListSchemas(ctx context.Context, req *pubsubpb.ListSchemasRequest, opts ...gax.CallOption) *SchemaIterator {
1011 it := &SchemaIterator{}
1012 req = proto.Clone(req).(*pubsubpb.ListSchemasRequest)
1013 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1014 it.InternalFetch = func(pageSize int, pageToken string) ([]*pubsubpb.Schema, string, error) {
1015 resp := &pubsubpb.ListSchemasResponse{}
1016 if pageToken != "" {
1017 req.PageToken = pageToken
1018 }
1019 if pageSize > math.MaxInt32 {
1020 req.PageSize = math.MaxInt32
1021 } else if pageSize != 0 {
1022 req.PageSize = int32(pageSize)
1023 }
1024 baseUrl, err := url.Parse(c.endpoint)
1025 if err != nil {
1026 return nil, "", err
1027 }
1028 baseUrl.Path += fmt.Sprintf("/v1/%v/schemas", req.GetParent())
1029
1030 params := url.Values{}
1031 params.Add("$alt", "json;enum-encoding=int")
1032 if req.GetPageSize() != 0 {
1033 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
1034 }
1035 if req.GetPageToken() != "" {
1036 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
1037 }
1038 if req.GetView() != 0 {
1039 params.Add("view", fmt.Sprintf("%v", req.GetView()))
1040 }
1041
1042 baseUrl.RawQuery = params.Encode()
1043
1044 // Build HTTP headers from client and context metadata.
1045 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
1046 headers := gax.BuildHeaders(ctx, hds...)
1047 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1048 if settings.Path != "" {
1049 baseUrl.Path = settings.Path
1050 }
1051 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1052 if err != nil {
1053 return err
1054 }
1055 httpReq.Header = headers
1056
1057 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListSchemas")
1058 if err != nil {
1059 return err
1060 }
1061 if err := unm.Unmarshal(buf, resp); err != nil {
1062 return err
1063 }
1064
1065 return nil
1066 }, opts...)
1067 if e != nil {
1068 return nil, "", e
1069 }
1070 it.Response = resp
1071 return resp.GetSchemas(), resp.GetNextPageToken(), nil
1072 }
1073
1074 fetch := func(pageSize int, pageToken string) (string, error) {
1075 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1076 if err != nil {
1077 return "", err
1078 }
1079 it.items = append(it.items, items...)
1080 return nextPageToken, nil
1081 }
1082
1083 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1084 it.pageInfo.MaxSize = int(req.GetPageSize())
1085 it.pageInfo.Token = req.GetPageToken()
1086
1087 return it
1088 }
1089
1090 // ListSchemaRevisions lists all schema revisions for the named schema.
1091 func (c *schemaRESTClient) ListSchemaRevisions(ctx context.Context, req *pubsubpb.ListSchemaRevisionsRequest, opts ...gax.CallOption) *SchemaIterator {
1092 it := &SchemaIterator{}
1093 req = proto.Clone(req).(*pubsubpb.ListSchemaRevisionsRequest)
1094 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1095 it.InternalFetch = func(pageSize int, pageToken string) ([]*pubsubpb.Schema, string, error) {
1096 resp := &pubsubpb.ListSchemaRevisionsResponse{}
1097 if pageToken != "" {
1098 req.PageToken = pageToken
1099 }
1100 if pageSize > math.MaxInt32 {
1101 req.PageSize = math.MaxInt32
1102 } else if pageSize != 0 {
1103 req.PageSize = int32(pageSize)
1104 }
1105 baseUrl, err := url.Parse(c.endpoint)
1106 if err != nil {
1107 return nil, "", err
1108 }
1109 baseUrl.Path += fmt.Sprintf("/v1/%v:listRevisions", req.GetName())
1110
1111 params := url.Values{}
1112 params.Add("$alt", "json;enum-encoding=int")
1113 if req.GetPageSize() != 0 {
1114 params.Add("pageSize", fmt.Sprintf("%v", req.GetPageSize()))
1115 }
1116 if req.GetPageToken() != "" {
1117 params.Add("pageToken", fmt.Sprintf("%v", req.GetPageToken()))
1118 }
1119 if req.GetView() != 0 {
1120 params.Add("view", fmt.Sprintf("%v", req.GetView()))
1121 }
1122
1123 baseUrl.RawQuery = params.Encode()
1124
1125 // Build HTTP headers from client and context metadata.
1126 hds := append(c.xGoogHeaders, "Content-Type", "application/json")
1127 headers := gax.BuildHeaders(ctx, hds...)
1128 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1129 if settings.Path != "" {
1130 baseUrl.Path = settings.Path
1131 }
1132 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1133 if err != nil {
1134 return err
1135 }
1136 httpReq.Header = headers
1137
1138 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "ListSchemaRevisions")
1139 if err != nil {
1140 return err
1141 }
1142 if err := unm.Unmarshal(buf, resp); err != nil {
1143 return err
1144 }
1145
1146 return nil
1147 }, opts...)
1148 if e != nil {
1149 return nil, "", e
1150 }
1151 it.Response = resp
1152 return resp.GetSchemas(), resp.GetNextPageToken(), nil
1153 }
1154
1155 fetch := func(pageSize int, pageToken string) (string, error) {
1156 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken)
1157 if err != nil {
1158 return "", err
1159 }
1160 it.items = append(it.items, items...)
1161 return nextPageToken, nil
1162 }
1163
1164 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf)
1165 it.pageInfo.MaxSize = int(req.GetPageSize())
1166 it.pageInfo.Token = req.GetPageToken()
1167
1168 return it
1169 }
1170
1171 // CommitSchema commits a new schema revision to an existing schema.
1172 func (c *schemaRESTClient) CommitSchema(ctx context.Context, req *pubsubpb.CommitSchemaRequest, opts ...gax.CallOption) (*pubsubpb.Schema, error) {
1173 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1174 jsonReq, err := m.Marshal(req)
1175 if err != nil {
1176 return nil, err
1177 }
1178
1179 baseUrl, err := url.Parse(c.endpoint)
1180 if err != nil {
1181 return nil, err
1182 }
1183 baseUrl.Path += fmt.Sprintf("/v1/%v:commit", req.GetName())
1184
1185 params := url.Values{}
1186 params.Add("$alt", "json;enum-encoding=int")
1187
1188 baseUrl.RawQuery = params.Encode()
1189
1190 // Build HTTP headers from client and context metadata.
1191 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1192
1193 hds = append(c.xGoogHeaders, hds...)
1194 hds = append(hds, "Content-Type", "application/json")
1195 headers := gax.BuildHeaders(ctx, hds...)
1196 opts = append((*c.CallOptions).CommitSchema[0:len((*c.CallOptions).CommitSchema):len((*c.CallOptions).CommitSchema)], opts...)
1197 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1198 resp := &pubsubpb.Schema{}
1199 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1200 if settings.Path != "" {
1201 baseUrl.Path = settings.Path
1202 }
1203 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
1204 if err != nil {
1205 return err
1206 }
1207 httpReq = httpReq.WithContext(ctx)
1208 httpReq.Header = headers
1209
1210 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "CommitSchema")
1211 if err != nil {
1212 return err
1213 }
1214
1215 if err := unm.Unmarshal(buf, resp); err != nil {
1216 return err
1217 }
1218
1219 return nil
1220 }, opts...)
1221 if e != nil {
1222 return nil, e
1223 }
1224 return resp, nil
1225 }
1226
1227 // RollbackSchema creates a new schema revision that is a copy of the provided revision_id.
1228 func (c *schemaRESTClient) RollbackSchema(ctx context.Context, req *pubsubpb.RollbackSchemaRequest, opts ...gax.CallOption) (*pubsubpb.Schema, error) {
1229 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1230 jsonReq, err := m.Marshal(req)
1231 if err != nil {
1232 return nil, err
1233 }
1234
1235 baseUrl, err := url.Parse(c.endpoint)
1236 if err != nil {
1237 return nil, err
1238 }
1239 baseUrl.Path += fmt.Sprintf("/v1/%v:rollback", req.GetName())
1240
1241 params := url.Values{}
1242 params.Add("$alt", "json;enum-encoding=int")
1243
1244 baseUrl.RawQuery = params.Encode()
1245
1246 // Build HTTP headers from client and context metadata.
1247 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1248
1249 hds = append(c.xGoogHeaders, hds...)
1250 hds = append(hds, "Content-Type", "application/json")
1251 headers := gax.BuildHeaders(ctx, hds...)
1252 opts = append((*c.CallOptions).RollbackSchema[0:len((*c.CallOptions).RollbackSchema):len((*c.CallOptions).RollbackSchema)], opts...)
1253 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1254 resp := &pubsubpb.Schema{}
1255 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1256 if settings.Path != "" {
1257 baseUrl.Path = settings.Path
1258 }
1259 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
1260 if err != nil {
1261 return err
1262 }
1263 httpReq = httpReq.WithContext(ctx)
1264 httpReq.Header = headers
1265
1266 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "RollbackSchema")
1267 if err != nil {
1268 return err
1269 }
1270
1271 if err := unm.Unmarshal(buf, resp); err != nil {
1272 return err
1273 }
1274
1275 return nil
1276 }, opts...)
1277 if e != nil {
1278 return nil, e
1279 }
1280 return resp, nil
1281 }
1282
1283 // DeleteSchemaRevision deletes a specific schema revision.
1284 func (c *schemaRESTClient) DeleteSchemaRevision(ctx context.Context, req *pubsubpb.DeleteSchemaRevisionRequest, opts ...gax.CallOption) (*pubsubpb.Schema, error) {
1285 baseUrl, err := url.Parse(c.endpoint)
1286 if err != nil {
1287 return nil, err
1288 }
1289 baseUrl.Path += fmt.Sprintf("/v1/%v:deleteRevision", req.GetName())
1290
1291 params := url.Values{}
1292 params.Add("$alt", "json;enum-encoding=int")
1293 if req.GetRevisionId() != "" {
1294 params.Add("revisionId", fmt.Sprintf("%v", req.GetRevisionId()))
1295 }
1296
1297 baseUrl.RawQuery = params.Encode()
1298
1299 // Build HTTP headers from client and context metadata.
1300 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1301
1302 hds = append(c.xGoogHeaders, hds...)
1303 hds = append(hds, "Content-Type", "application/json")
1304 headers := gax.BuildHeaders(ctx, hds...)
1305 opts = append((*c.CallOptions).DeleteSchemaRevision[0:len((*c.CallOptions).DeleteSchemaRevision):len((*c.CallOptions).DeleteSchemaRevision)], opts...)
1306 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1307 resp := &pubsubpb.Schema{}
1308 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1309 if settings.Path != "" {
1310 baseUrl.Path = settings.Path
1311 }
1312 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
1313 if err != nil {
1314 return err
1315 }
1316 httpReq = httpReq.WithContext(ctx)
1317 httpReq.Header = headers
1318
1319 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteSchemaRevision")
1320 if err != nil {
1321 return err
1322 }
1323
1324 if err := unm.Unmarshal(buf, resp); err != nil {
1325 return err
1326 }
1327
1328 return nil
1329 }, opts...)
1330 if e != nil {
1331 return nil, e
1332 }
1333 return resp, nil
1334 }
1335
1336 // DeleteSchema deletes a schema.
1337 func (c *schemaRESTClient) DeleteSchema(ctx context.Context, req *pubsubpb.DeleteSchemaRequest, opts ...gax.CallOption) error {
1338 baseUrl, err := url.Parse(c.endpoint)
1339 if err != nil {
1340 return err
1341 }
1342 baseUrl.Path += fmt.Sprintf("/v1/%v", req.GetName())
1343
1344 params := url.Values{}
1345 params.Add("$alt", "json;enum-encoding=int")
1346
1347 baseUrl.RawQuery = params.Encode()
1348
1349 // Build HTTP headers from client and context metadata.
1350 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))}
1351
1352 hds = append(c.xGoogHeaders, hds...)
1353 hds = append(hds, "Content-Type", "application/json")
1354 headers := gax.BuildHeaders(ctx, hds...)
1355 return gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1356 if settings.Path != "" {
1357 baseUrl.Path = settings.Path
1358 }
1359 httpReq, err := http.NewRequest("DELETE", baseUrl.String(), nil)
1360 if err != nil {
1361 return err
1362 }
1363 httpReq = httpReq.WithContext(ctx)
1364 httpReq.Header = headers
1365
1366 _, err = executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "DeleteSchema")
1367 return err
1368 }, opts...)
1369 }
1370
1371 // ValidateSchema validates a schema.
1372 func (c *schemaRESTClient) ValidateSchema(ctx context.Context, req *pubsubpb.ValidateSchemaRequest, opts ...gax.CallOption) (*pubsubpb.ValidateSchemaResponse, error) {
1373 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1374 jsonReq, err := m.Marshal(req)
1375 if err != nil {
1376 return nil, err
1377 }
1378
1379 baseUrl, err := url.Parse(c.endpoint)
1380 if err != nil {
1381 return nil, err
1382 }
1383 baseUrl.Path += fmt.Sprintf("/v1/%v/schemas:validate", req.GetParent())
1384
1385 params := url.Values{}
1386 params.Add("$alt", "json;enum-encoding=int")
1387
1388 baseUrl.RawQuery = params.Encode()
1389
1390 // Build HTTP headers from client and context metadata.
1391 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1392
1393 hds = append(c.xGoogHeaders, hds...)
1394 hds = append(hds, "Content-Type", "application/json")
1395 headers := gax.BuildHeaders(ctx, hds...)
1396 opts = append((*c.CallOptions).ValidateSchema[0:len((*c.CallOptions).ValidateSchema):len((*c.CallOptions).ValidateSchema)], opts...)
1397 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1398 resp := &pubsubpb.ValidateSchemaResponse{}
1399 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1400 if settings.Path != "" {
1401 baseUrl.Path = settings.Path
1402 }
1403 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
1404 if err != nil {
1405 return err
1406 }
1407 httpReq = httpReq.WithContext(ctx)
1408 httpReq.Header = headers
1409
1410 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "ValidateSchema")
1411 if err != nil {
1412 return err
1413 }
1414
1415 if err := unm.Unmarshal(buf, resp); err != nil {
1416 return err
1417 }
1418
1419 return nil
1420 }, opts...)
1421 if e != nil {
1422 return nil, e
1423 }
1424 return resp, nil
1425 }
1426
1427 // ValidateMessage validates a message against a schema.
1428 func (c *schemaRESTClient) ValidateMessage(ctx context.Context, req *pubsubpb.ValidateMessageRequest, opts ...gax.CallOption) (*pubsubpb.ValidateMessageResponse, error) {
1429 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1430 jsonReq, err := m.Marshal(req)
1431 if err != nil {
1432 return nil, err
1433 }
1434
1435 baseUrl, err := url.Parse(c.endpoint)
1436 if err != nil {
1437 return nil, err
1438 }
1439 baseUrl.Path += fmt.Sprintf("/v1/%v/schemas:validateMessage", req.GetParent())
1440
1441 params := url.Values{}
1442 params.Add("$alt", "json;enum-encoding=int")
1443
1444 baseUrl.RawQuery = params.Encode()
1445
1446 // Build HTTP headers from client and context metadata.
1447 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))}
1448
1449 hds = append(c.xGoogHeaders, hds...)
1450 hds = append(hds, "Content-Type", "application/json")
1451 headers := gax.BuildHeaders(ctx, hds...)
1452 opts = append((*c.CallOptions).ValidateMessage[0:len((*c.CallOptions).ValidateMessage):len((*c.CallOptions).ValidateMessage)], opts...)
1453 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1454 resp := &pubsubpb.ValidateMessageResponse{}
1455 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1456 if settings.Path != "" {
1457 baseUrl.Path = settings.Path
1458 }
1459 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
1460 if err != nil {
1461 return err
1462 }
1463 httpReq = httpReq.WithContext(ctx)
1464 httpReq.Header = headers
1465
1466 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "ValidateMessage")
1467 if err != nil {
1468 return err
1469 }
1470
1471 if err := unm.Unmarshal(buf, resp); err != nil {
1472 return err
1473 }
1474
1475 return nil
1476 }, opts...)
1477 if e != nil {
1478 return nil, e
1479 }
1480 return resp, nil
1481 }
1482
1483 // GetIamPolicy gets the access control policy for a resource. Returns an empty policy
1484 // if the resource exists and does not have a policy set.
1485 func (c *schemaRESTClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
1486 baseUrl, err := url.Parse(c.endpoint)
1487 if err != nil {
1488 return nil, err
1489 }
1490 baseUrl.Path += fmt.Sprintf("/v1/%v:getIamPolicy", req.GetResource())
1491
1492 params := url.Values{}
1493 params.Add("$alt", "json;enum-encoding=int")
1494 if req.GetOptions().GetRequestedPolicyVersion() != 0 {
1495 params.Add("options.requestedPolicyVersion", fmt.Sprintf("%v", req.GetOptions().GetRequestedPolicyVersion()))
1496 }
1497
1498 baseUrl.RawQuery = params.Encode()
1499
1500 // Build HTTP headers from client and context metadata.
1501 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
1502
1503 hds = append(c.xGoogHeaders, hds...)
1504 hds = append(hds, "Content-Type", "application/json")
1505 headers := gax.BuildHeaders(ctx, hds...)
1506 opts = append((*c.CallOptions).GetIamPolicy[0:len((*c.CallOptions).GetIamPolicy):len((*c.CallOptions).GetIamPolicy)], opts...)
1507 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1508 resp := &iampb.Policy{}
1509 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1510 if settings.Path != "" {
1511 baseUrl.Path = settings.Path
1512 }
1513 httpReq, err := http.NewRequest("GET", baseUrl.String(), nil)
1514 if err != nil {
1515 return err
1516 }
1517 httpReq = httpReq.WithContext(ctx)
1518 httpReq.Header = headers
1519
1520 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, nil, "GetIamPolicy")
1521 if err != nil {
1522 return err
1523 }
1524
1525 if err := unm.Unmarshal(buf, resp); err != nil {
1526 return err
1527 }
1528
1529 return nil
1530 }, opts...)
1531 if e != nil {
1532 return nil, e
1533 }
1534 return resp, nil
1535 }
1536
1537 // SetIamPolicy sets the access control policy on the specified resource. Replaces
1538 // any existing policy.
1539 //
1540 // Can return NOT_FOUND, INVALID_ARGUMENT, and PERMISSION_DENIED
1541 // errors.
1542 func (c *schemaRESTClient) SetIamPolicy(ctx context.Context, req *iampb.SetIamPolicyRequest, opts ...gax.CallOption) (*iampb.Policy, error) {
1543 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1544 jsonReq, err := m.Marshal(req)
1545 if err != nil {
1546 return nil, err
1547 }
1548
1549 baseUrl, err := url.Parse(c.endpoint)
1550 if err != nil {
1551 return nil, err
1552 }
1553 baseUrl.Path += fmt.Sprintf("/v1/%v:setIamPolicy", req.GetResource())
1554
1555 params := url.Values{}
1556 params.Add("$alt", "json;enum-encoding=int")
1557
1558 baseUrl.RawQuery = params.Encode()
1559
1560 // Build HTTP headers from client and context metadata.
1561 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
1562
1563 hds = append(c.xGoogHeaders, hds...)
1564 hds = append(hds, "Content-Type", "application/json")
1565 headers := gax.BuildHeaders(ctx, hds...)
1566 opts = append((*c.CallOptions).SetIamPolicy[0:len((*c.CallOptions).SetIamPolicy):len((*c.CallOptions).SetIamPolicy)], opts...)
1567 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1568 resp := &iampb.Policy{}
1569 e := 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("POST", baseUrl.String(), bytes.NewReader(jsonReq))
1574 if err != nil {
1575 return err
1576 }
1577 httpReq = httpReq.WithContext(ctx)
1578 httpReq.Header = headers
1579
1580 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "SetIamPolicy")
1581 if err != nil {
1582 return err
1583 }
1584
1585 if err := unm.Unmarshal(buf, resp); err != nil {
1586 return err
1587 }
1588
1589 return nil
1590 }, opts...)
1591 if e != nil {
1592 return nil, e
1593 }
1594 return resp, nil
1595 }
1596
1597 // TestIamPermissions returns permissions that a caller has on the specified resource. If the
1598 // resource does not exist, this will return an empty set of
1599 // permissions, not a NOT_FOUND error.
1600 //
1601 // Note: This operation is designed to be used for building
1602 // permission-aware UIs and command-line tools, not for authorization
1603 // checking. This operation may “fail open” without warning.
1604 func (c *schemaRESTClient) TestIamPermissions(ctx context.Context, req *iampb.TestIamPermissionsRequest, opts ...gax.CallOption) (*iampb.TestIamPermissionsResponse, error) {
1605 m := protojson.MarshalOptions{AllowPartial: true, UseEnumNumbers: true}
1606 jsonReq, err := m.Marshal(req)
1607 if err != nil {
1608 return nil, err
1609 }
1610
1611 baseUrl, err := url.Parse(c.endpoint)
1612 if err != nil {
1613 return nil, err
1614 }
1615 baseUrl.Path += fmt.Sprintf("/v1/%v:testIamPermissions", req.GetResource())
1616
1617 params := url.Values{}
1618 params.Add("$alt", "json;enum-encoding=int")
1619
1620 baseUrl.RawQuery = params.Encode()
1621
1622 // Build HTTP headers from client and context metadata.
1623 hds := []string{"x-goog-request-params", fmt.Sprintf("%s=%v", "resource", url.QueryEscape(req.GetResource()))}
1624
1625 hds = append(c.xGoogHeaders, hds...)
1626 hds = append(hds, "Content-Type", "application/json")
1627 headers := gax.BuildHeaders(ctx, hds...)
1628 opts = append((*c.CallOptions).TestIamPermissions[0:len((*c.CallOptions).TestIamPermissions):len((*c.CallOptions).TestIamPermissions)], opts...)
1629 unm := protojson.UnmarshalOptions{AllowPartial: true, DiscardUnknown: true}
1630 resp := &iampb.TestIamPermissionsResponse{}
1631 e := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
1632 if settings.Path != "" {
1633 baseUrl.Path = settings.Path
1634 }
1635 httpReq, err := http.NewRequest("POST", baseUrl.String(), bytes.NewReader(jsonReq))
1636 if err != nil {
1637 return err
1638 }
1639 httpReq = httpReq.WithContext(ctx)
1640 httpReq.Header = headers
1641
1642 buf, err := executeHTTPRequest(ctx, c.httpClient, httpReq, c.logger, jsonReq, "TestIamPermissions")
1643 if err != nil {
1644 return err
1645 }
1646
1647 if err := unm.Unmarshal(buf, resp); err != nil {
1648 return err
1649 }
1650
1651 return nil
1652 }, opts...)
1653 if e != nil {
1654 return nil, e
1655 }
1656 return resp, nil
1657 }