Debian Codegraph @

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