Debian Codegraph @

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