diff --git a/compute/apiv1/accelerator_types_client.go b/compute/apiv1/accelerator_types_client.go index e369967f982..c3a75ea2271 100644 --- a/compute/apiv1/accelerator_types_client.go +++ b/compute/apiv1/accelerator_types_client.go @@ -507,13 +507,3 @@ func (it *AcceleratorTypesScopedListPairIterator) takeBuf() interface{} { it.items = nil return b } - -// Operation represents a long running operation for this API. -type Operation struct { - proto *computepb.Operation -} - -// Proto returns the raw type this wraps. -func (o *Operation) Proto() *computepb.Operation { - return o.proto -} diff --git a/compute/apiv1/addresses_client.go b/compute/apiv1/addresses_client.go index 34f88f810d8..40a042ad00a 100644 --- a/compute/apiv1/addresses_client.go +++ b/compute/apiv1/addresses_client.go @@ -129,6 +129,9 @@ type addressesRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *RegionOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -149,6 +152,16 @@ func NewAddressesRESTClient(ctx context.Context, opts ...option.ClientOption) (* } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewRegionOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &AddressesClient{internalClient: c, CallOptions: &AddressesCallOptions{}}, nil } @@ -175,6 +188,9 @@ func (c *addressesRESTClient) setGoogleClientInfo(keyval ...string) { func (c *addressesRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -333,7 +349,14 @@ func (c *addressesRESTClient) Delete(ctx context.Context, req *computepb.DeleteA if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -436,7 +459,14 @@ func (c *addressesRESTClient) Insert(ctx context.Context, req *computepb.InsertA if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } diff --git a/compute/apiv1/addresses_client_example_test.go b/compute/apiv1/addresses_client_example_test.go index 68a8c4a6583..e7d5083cac9 100644 --- a/compute/apiv1/addresses_client_example_test.go +++ b/compute/apiv1/addresses_client_example_test.go @@ -74,12 +74,15 @@ func ExampleAddressesClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteAddressRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleAddressesClient_Get() { @@ -114,12 +117,15 @@ func ExampleAddressesClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertAddressRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleAddressesClient_List() { diff --git a/compute/apiv1/autoscalers_client.go b/compute/apiv1/autoscalers_client.go index 7f4994152bd..21b8ca10ace 100644 --- a/compute/apiv1/autoscalers_client.go +++ b/compute/apiv1/autoscalers_client.go @@ -143,6 +143,9 @@ type autoscalersRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *ZoneOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -163,6 +166,16 @@ func NewAutoscalersRESTClient(ctx context.Context, opts ...option.ClientOption) } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewZoneOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &AutoscalersClient{internalClient: c, CallOptions: &AutoscalersCallOptions{}}, nil } @@ -189,6 +202,9 @@ func (c *autoscalersRESTClient) setGoogleClientInfo(keyval ...string) { func (c *autoscalersRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -347,7 +363,14 @@ func (c *autoscalersRESTClient) Delete(ctx context.Context, req *computepb.Delet if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -450,7 +473,14 @@ func (c *autoscalersRESTClient) Insert(ctx context.Context, req *computepb.Inser if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -602,7 +632,14 @@ func (c *autoscalersRESTClient) Patch(ctx context.Context, req *computepb.PatchA if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -664,7 +701,14 @@ func (c *autoscalersRESTClient) Update(ctx context.Context, req *computepb.Updat if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } diff --git a/compute/apiv1/autoscalers_client_example_test.go b/compute/apiv1/autoscalers_client_example_test.go index 5a2c3842ba3..e299bd42125 100644 --- a/compute/apiv1/autoscalers_client_example_test.go +++ b/compute/apiv1/autoscalers_client_example_test.go @@ -74,12 +74,15 @@ func ExampleAutoscalersClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteAutoscalerRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleAutoscalersClient_Get() { @@ -114,12 +117,15 @@ func ExampleAutoscalersClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertAutoscalerRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleAutoscalersClient_List() { @@ -160,12 +166,15 @@ func ExampleAutoscalersClient_Patch() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#PatchAutoscalerRequest. } - resp, err := c.Patch(ctx, req) + op, err := c.Patch(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleAutoscalersClient_Update() { @@ -180,10 +189,13 @@ func ExampleAutoscalersClient_Update() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#UpdateAutoscalerRequest. } - resp, err := c.Update(ctx, req) + op, err := c.Update(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } diff --git a/compute/apiv1/backend_buckets_client.go b/compute/apiv1/backend_buckets_client.go index 44fd9c39382..9c674c8897b 100644 --- a/compute/apiv1/backend_buckets_client.go +++ b/compute/apiv1/backend_buckets_client.go @@ -149,6 +149,9 @@ type backendBucketsRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *GlobalOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -169,6 +172,16 @@ func NewBackendBucketsRESTClient(ctx context.Context, opts ...option.ClientOptio } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewGlobalOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &BackendBucketsClient{internalClient: c, CallOptions: &BackendBucketsCallOptions{}}, nil } @@ -195,6 +208,9 @@ func (c *backendBucketsRESTClient) setGoogleClientInfo(keyval ...string) { func (c *backendBucketsRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -260,7 +276,13 @@ func (c *backendBucketsRESTClient) AddSignedUrlKey(ctx context.Context, req *com if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -312,7 +334,13 @@ func (c *backendBucketsRESTClient) Delete(ctx context.Context, req *computepb.De if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -365,7 +393,13 @@ func (c *backendBucketsRESTClient) DeleteSignedUrlKey(ctx context.Context, req * if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -468,7 +502,13 @@ func (c *backendBucketsRESTClient) Insert(ctx context.Context, req *computepb.In if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -617,7 +657,13 @@ func (c *backendBucketsRESTClient) Patch(ctx context.Context, req *computepb.Pat if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -676,7 +722,13 @@ func (c *backendBucketsRESTClient) Update(ctx context.Context, req *computepb.Up if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } diff --git a/compute/apiv1/backend_buckets_client_example_test.go b/compute/apiv1/backend_buckets_client_example_test.go index 778a320652c..8756a27b669 100644 --- a/compute/apiv1/backend_buckets_client_example_test.go +++ b/compute/apiv1/backend_buckets_client_example_test.go @@ -48,12 +48,15 @@ func ExampleBackendBucketsClient_AddSignedUrlKey() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#AddSignedUrlKeyBackendBucketRequest. } - resp, err := c.AddSignedUrlKey(ctx, req) + op, err := c.AddSignedUrlKey(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleBackendBucketsClient_Delete() { @@ -68,12 +71,15 @@ func ExampleBackendBucketsClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteBackendBucketRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleBackendBucketsClient_DeleteSignedUrlKey() { @@ -88,12 +94,15 @@ func ExampleBackendBucketsClient_DeleteSignedUrlKey() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteSignedUrlKeyBackendBucketRequest. } - resp, err := c.DeleteSignedUrlKey(ctx, req) + op, err := c.DeleteSignedUrlKey(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleBackendBucketsClient_Get() { @@ -128,12 +137,15 @@ func ExampleBackendBucketsClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertBackendBucketRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleBackendBucketsClient_List() { @@ -174,12 +186,15 @@ func ExampleBackendBucketsClient_Patch() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#PatchBackendBucketRequest. } - resp, err := c.Patch(ctx, req) + op, err := c.Patch(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleBackendBucketsClient_Update() { @@ -194,10 +209,13 @@ func ExampleBackendBucketsClient_Update() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#UpdateBackendBucketRequest. } - resp, err := c.Update(ctx, req) + op, err := c.Update(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } diff --git a/compute/apiv1/backend_services_client.go b/compute/apiv1/backend_services_client.go index f560861383a..ea4f5715560 100644 --- a/compute/apiv1/backend_services_client.go +++ b/compute/apiv1/backend_services_client.go @@ -171,6 +171,9 @@ type backendServicesRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *GlobalOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -191,6 +194,16 @@ func NewBackendServicesRESTClient(ctx context.Context, opts ...option.ClientOpti } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewGlobalOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &BackendServicesClient{internalClient: c, CallOptions: &BackendServicesCallOptions{}}, nil } @@ -217,6 +230,9 @@ func (c *backendServicesRESTClient) setGoogleClientInfo(keyval ...string) { func (c *backendServicesRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -282,7 +298,13 @@ func (c *backendServicesRESTClient) AddSignedUrlKey(ctx context.Context, req *co if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -434,7 +456,13 @@ func (c *backendServicesRESTClient) Delete(ctx context.Context, req *computepb.D if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -487,7 +515,13 @@ func (c *backendServicesRESTClient) DeleteSignedUrlKey(ctx context.Context, req if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -641,7 +675,13 @@ func (c *backendServicesRESTClient) Insert(ctx context.Context, req *computepb.I if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -790,7 +830,13 @@ func (c *backendServicesRESTClient) Patch(ctx context.Context, req *computepb.Pa if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -849,7 +895,13 @@ func (c *backendServicesRESTClient) SetSecurityPolicy(ctx context.Context, req * if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -908,7 +960,13 @@ func (c *backendServicesRESTClient) Update(ctx context.Context, req *computepb.U if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } diff --git a/compute/apiv1/backend_services_client_example_test.go b/compute/apiv1/backend_services_client_example_test.go index 2dea8e18c52..ce3a822d89f 100644 --- a/compute/apiv1/backend_services_client_example_test.go +++ b/compute/apiv1/backend_services_client_example_test.go @@ -48,12 +48,15 @@ func ExampleBackendServicesClient_AddSignedUrlKey() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#AddSignedUrlKeyBackendServiceRequest. } - resp, err := c.AddSignedUrlKey(ctx, req) + op, err := c.AddSignedUrlKey(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleBackendServicesClient_AggregatedList() { @@ -94,12 +97,15 @@ func ExampleBackendServicesClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteBackendServiceRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleBackendServicesClient_DeleteSignedUrlKey() { @@ -114,12 +120,15 @@ func ExampleBackendServicesClient_DeleteSignedUrlKey() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteSignedUrlKeyBackendServiceRequest. } - resp, err := c.DeleteSignedUrlKey(ctx, req) + op, err := c.DeleteSignedUrlKey(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleBackendServicesClient_Get() { @@ -174,12 +183,15 @@ func ExampleBackendServicesClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertBackendServiceRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleBackendServicesClient_List() { @@ -220,12 +232,15 @@ func ExampleBackendServicesClient_Patch() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#PatchBackendServiceRequest. } - resp, err := c.Patch(ctx, req) + op, err := c.Patch(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleBackendServicesClient_SetSecurityPolicy() { @@ -240,12 +255,15 @@ func ExampleBackendServicesClient_SetSecurityPolicy() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#SetSecurityPolicyBackendServiceRequest. } - resp, err := c.SetSecurityPolicy(ctx, req) + op, err := c.SetSecurityPolicy(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleBackendServicesClient_Update() { @@ -260,10 +278,13 @@ func ExampleBackendServicesClient_Update() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#UpdateBackendServiceRequest. } - resp, err := c.Update(ctx, req) + op, err := c.Update(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } diff --git a/compute/apiv1/disks_client.go b/compute/apiv1/disks_client.go index c64a2bf98a3..1084dedea6d 100644 --- a/compute/apiv1/disks_client.go +++ b/compute/apiv1/disks_client.go @@ -185,6 +185,9 @@ type disksRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *ZoneOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -205,6 +208,16 @@ func NewDisksRESTClient(ctx context.Context, opts ...option.ClientOption) (*Disk } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewZoneOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &DisksClient{internalClient: c, CallOptions: &DisksCallOptions{}}, nil } @@ -231,6 +244,9 @@ func (c *disksRESTClient) setGoogleClientInfo(keyval ...string) { func (c *disksRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -296,7 +312,14 @@ func (c *disksRESTClient) AddResourcePolicies(ctx context.Context, req *computep if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -458,7 +481,14 @@ func (c *disksRESTClient) CreateSnapshot(ctx context.Context, req *computepb.Cre if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -510,7 +540,14 @@ func (c *disksRESTClient) Delete(ctx context.Context, req *computepb.DeleteDiskR if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -667,7 +704,14 @@ func (c *disksRESTClient) Insert(ctx context.Context, req *computepb.InsertDiskR if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -816,7 +860,14 @@ func (c *disksRESTClient) RemoveResourcePolicies(ctx context.Context, req *compu if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -875,7 +926,14 @@ func (c *disksRESTClient) Resize(ctx context.Context, req *computepb.ResizeDiskR if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -985,7 +1043,14 @@ func (c *disksRESTClient) SetLabels(ctx context.Context, req *computepb.SetLabel if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } diff --git a/compute/apiv1/disks_client_example_test.go b/compute/apiv1/disks_client_example_test.go index 9315fcc8d22..03e7c2ffaf3 100644 --- a/compute/apiv1/disks_client_example_test.go +++ b/compute/apiv1/disks_client_example_test.go @@ -48,12 +48,15 @@ func ExampleDisksClient_AddResourcePolicies() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#AddResourcePoliciesDiskRequest. } - resp, err := c.AddResourcePolicies(ctx, req) + op, err := c.AddResourcePolicies(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleDisksClient_AggregatedList() { @@ -94,12 +97,15 @@ func ExampleDisksClient_CreateSnapshot() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#CreateSnapshotDiskRequest. } - resp, err := c.CreateSnapshot(ctx, req) + op, err := c.CreateSnapshot(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleDisksClient_Delete() { @@ -114,12 +120,15 @@ func ExampleDisksClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteDiskRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleDisksClient_Get() { @@ -174,12 +183,15 @@ func ExampleDisksClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertDiskRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleDisksClient_List() { @@ -220,12 +232,15 @@ func ExampleDisksClient_RemoveResourcePolicies() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#RemoveResourcePoliciesDiskRequest. } - resp, err := c.RemoveResourcePolicies(ctx, req) + op, err := c.RemoveResourcePolicies(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleDisksClient_Resize() { @@ -240,12 +255,15 @@ func ExampleDisksClient_Resize() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#ResizeDiskRequest. } - resp, err := c.Resize(ctx, req) + op, err := c.Resize(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleDisksClient_SetIamPolicy() { @@ -280,12 +298,15 @@ func ExampleDisksClient_SetLabels() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#SetLabelsDiskRequest. } - resp, err := c.SetLabels(ctx, req) + op, err := c.SetLabels(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleDisksClient_TestIamPermissions() { diff --git a/compute/apiv1/doc.go b/compute/apiv1/doc.go index 19cd8171715..1439157ebc9 100644 --- a/compute/apiv1/doc.go +++ b/compute/apiv1/doc.go @@ -90,7 +90,7 @@ import ( type clientHookParams struct{} type clientHook func(context.Context, clientHookParams) ([]option.ClientOption, error) -const versionClient = "20220201" +const versionClient = "20220202" func insertMetadata(ctx context.Context, mds ...metadata.MD) context.Context { out, _ := metadata.FromOutgoingContext(ctx) diff --git a/compute/apiv1/external_vpn_gateways_client.go b/compute/apiv1/external_vpn_gateways_client.go index ec1d849eba0..1a2f0e5ce19 100644 --- a/compute/apiv1/external_vpn_gateways_client.go +++ b/compute/apiv1/external_vpn_gateways_client.go @@ -135,6 +135,9 @@ type externalVpnGatewaysRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *GlobalOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -155,6 +158,16 @@ func NewExternalVpnGatewaysRESTClient(ctx context.Context, opts ...option.Client } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewGlobalOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &ExternalVpnGatewaysClient{internalClient: c, CallOptions: &ExternalVpnGatewaysCallOptions{}}, nil } @@ -181,6 +194,9 @@ func (c *externalVpnGatewaysRESTClient) setGoogleClientInfo(keyval ...string) { func (c *externalVpnGatewaysRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -239,7 +255,13 @@ func (c *externalVpnGatewaysRESTClient) Delete(ctx context.Context, req *compute if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -342,7 +364,13 @@ func (c *externalVpnGatewaysRESTClient) Insert(ctx context.Context, req *compute if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -484,7 +512,13 @@ func (c *externalVpnGatewaysRESTClient) SetLabels(ctx context.Context, req *comp if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } diff --git a/compute/apiv1/external_vpn_gateways_client_example_test.go b/compute/apiv1/external_vpn_gateways_client_example_test.go index 75870aa59e8..2eb14356dcb 100644 --- a/compute/apiv1/external_vpn_gateways_client_example_test.go +++ b/compute/apiv1/external_vpn_gateways_client_example_test.go @@ -48,12 +48,15 @@ func ExampleExternalVpnGatewaysClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteExternalVpnGatewayRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleExternalVpnGatewaysClient_Get() { @@ -88,12 +91,15 @@ func ExampleExternalVpnGatewaysClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertExternalVpnGatewayRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleExternalVpnGatewaysClient_List() { @@ -134,12 +140,15 @@ func ExampleExternalVpnGatewaysClient_SetLabels() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#SetLabelsExternalVpnGatewayRequest. } - resp, err := c.SetLabels(ctx, req) + op, err := c.SetLabels(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleExternalVpnGatewaysClient_TestIamPermissions() { diff --git a/compute/apiv1/firewall_policies_client.go b/compute/apiv1/firewall_policies_client.go index 5786f3adc1a..89c2f6457a7 100644 --- a/compute/apiv1/firewall_policies_client.go +++ b/compute/apiv1/firewall_policies_client.go @@ -219,6 +219,9 @@ type firewallPoliciesRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *GlobalOrganizationOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -239,6 +242,16 @@ func NewFirewallPoliciesRESTClient(ctx context.Context, opts ...option.ClientOpt } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewGlobalOrganizationOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &FirewallPoliciesClient{internalClient: c, CallOptions: &FirewallPoliciesCallOptions{}}, nil } @@ -265,6 +278,9 @@ func (c *firewallPoliciesRESTClient) setGoogleClientInfo(keyval ...string) { func (c *firewallPoliciesRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -333,7 +349,12 @@ func (c *firewallPoliciesRESTClient) AddAssociation(ctx context.Context, req *co if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOrganizationOperationsHandle{ + c: c.operationClient, + proto: resp, + }, + } return op, nil } @@ -392,7 +413,12 @@ func (c *firewallPoliciesRESTClient) AddRule(ctx context.Context, req *computepb if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOrganizationOperationsHandle{ + c: c.operationClient, + proto: resp, + }, + } return op, nil } @@ -447,7 +473,12 @@ func (c *firewallPoliciesRESTClient) CloneRules(ctx context.Context, req *comput if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOrganizationOperationsHandle{ + c: c.operationClient, + proto: resp, + }, + } return op, nil } @@ -499,7 +530,12 @@ func (c *firewallPoliciesRESTClient) Delete(ctx context.Context, req *computepb. if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOrganizationOperationsHandle{ + c: c.operationClient, + proto: resp, + }, + } return op, nil } @@ -756,7 +792,12 @@ func (c *firewallPoliciesRESTClient) Insert(ctx context.Context, req *computepb. if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOrganizationOperationsHandle{ + c: c.operationClient, + proto: resp, + }, + } return op, nil } @@ -953,7 +994,12 @@ func (c *firewallPoliciesRESTClient) Move(ctx context.Context, req *computepb.Mo if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOrganizationOperationsHandle{ + c: c.operationClient, + proto: resp, + }, + } return op, nil } @@ -1012,7 +1058,12 @@ func (c *firewallPoliciesRESTClient) Patch(ctx context.Context, req *computepb.P if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOrganizationOperationsHandle{ + c: c.operationClient, + proto: resp, + }, + } return op, nil } @@ -1074,7 +1125,12 @@ func (c *firewallPoliciesRESTClient) PatchRule(ctx context.Context, req *compute if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOrganizationOperationsHandle{ + c: c.operationClient, + proto: resp, + }, + } return op, nil } @@ -1129,7 +1185,12 @@ func (c *firewallPoliciesRESTClient) RemoveAssociation(ctx context.Context, req if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOrganizationOperationsHandle{ + c: c.operationClient, + proto: resp, + }, + } return op, nil } @@ -1184,7 +1245,12 @@ func (c *firewallPoliciesRESTClient) RemoveRule(ctx context.Context, req *comput if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOrganizationOperationsHandle{ + c: c.operationClient, + proto: resp, + }, + } return op, nil } diff --git a/compute/apiv1/firewall_policies_client_example_test.go b/compute/apiv1/firewall_policies_client_example_test.go index 1cda3eb5a94..b6dd3ece8ff 100644 --- a/compute/apiv1/firewall_policies_client_example_test.go +++ b/compute/apiv1/firewall_policies_client_example_test.go @@ -48,12 +48,15 @@ func ExampleFirewallPoliciesClient_AddAssociation() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#AddAssociationFirewallPolicyRequest. } - resp, err := c.AddAssociation(ctx, req) + op, err := c.AddAssociation(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleFirewallPoliciesClient_AddRule() { @@ -68,12 +71,15 @@ func ExampleFirewallPoliciesClient_AddRule() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#AddRuleFirewallPolicyRequest. } - resp, err := c.AddRule(ctx, req) + op, err := c.AddRule(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleFirewallPoliciesClient_CloneRules() { @@ -88,12 +94,15 @@ func ExampleFirewallPoliciesClient_CloneRules() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#CloneRulesFirewallPolicyRequest. } - resp, err := c.CloneRules(ctx, req) + op, err := c.CloneRules(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleFirewallPoliciesClient_Delete() { @@ -108,12 +117,15 @@ func ExampleFirewallPoliciesClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteFirewallPolicyRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleFirewallPoliciesClient_Get() { @@ -208,12 +220,15 @@ func ExampleFirewallPoliciesClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertFirewallPolicyRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleFirewallPoliciesClient_List() { @@ -274,12 +289,15 @@ func ExampleFirewallPoliciesClient_Move() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#MoveFirewallPolicyRequest. } - resp, err := c.Move(ctx, req) + op, err := c.Move(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleFirewallPoliciesClient_Patch() { @@ -294,12 +312,15 @@ func ExampleFirewallPoliciesClient_Patch() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#PatchFirewallPolicyRequest. } - resp, err := c.Patch(ctx, req) + op, err := c.Patch(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleFirewallPoliciesClient_PatchRule() { @@ -314,12 +335,15 @@ func ExampleFirewallPoliciesClient_PatchRule() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#PatchRuleFirewallPolicyRequest. } - resp, err := c.PatchRule(ctx, req) + op, err := c.PatchRule(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleFirewallPoliciesClient_RemoveAssociation() { @@ -334,12 +358,15 @@ func ExampleFirewallPoliciesClient_RemoveAssociation() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#RemoveAssociationFirewallPolicyRequest. } - resp, err := c.RemoveAssociation(ctx, req) + op, err := c.RemoveAssociation(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleFirewallPoliciesClient_RemoveRule() { @@ -354,12 +381,15 @@ func ExampleFirewallPoliciesClient_RemoveRule() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#RemoveRuleFirewallPolicyRequest. } - resp, err := c.RemoveRule(ctx, req) + op, err := c.RemoveRule(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleFirewallPoliciesClient_SetIamPolicy() { diff --git a/compute/apiv1/firewalls_client.go b/compute/apiv1/firewalls_client.go index c7e319e56e2..199a84aeda8 100644 --- a/compute/apiv1/firewalls_client.go +++ b/compute/apiv1/firewalls_client.go @@ -135,6 +135,9 @@ type firewallsRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *GlobalOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -155,6 +158,16 @@ func NewFirewallsRESTClient(ctx context.Context, opts ...option.ClientOption) (* } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewGlobalOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &FirewallsClient{internalClient: c, CallOptions: &FirewallsCallOptions{}}, nil } @@ -181,6 +194,9 @@ func (c *firewallsRESTClient) setGoogleClientInfo(keyval ...string) { func (c *firewallsRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -239,7 +255,13 @@ func (c *firewallsRESTClient) Delete(ctx context.Context, req *computepb.DeleteF if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -342,7 +364,13 @@ func (c *firewallsRESTClient) Insert(ctx context.Context, req *computepb.InsertF if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -491,7 +519,13 @@ func (c *firewallsRESTClient) Patch(ctx context.Context, req *computepb.PatchFir if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -550,7 +584,13 @@ func (c *firewallsRESTClient) Update(ctx context.Context, req *computepb.UpdateF if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } diff --git a/compute/apiv1/firewalls_client_example_test.go b/compute/apiv1/firewalls_client_example_test.go index 86a064aab9a..a0b53514acb 100644 --- a/compute/apiv1/firewalls_client_example_test.go +++ b/compute/apiv1/firewalls_client_example_test.go @@ -48,12 +48,15 @@ func ExampleFirewallsClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteFirewallRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleFirewallsClient_Get() { @@ -88,12 +91,15 @@ func ExampleFirewallsClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertFirewallRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleFirewallsClient_List() { @@ -134,12 +140,15 @@ func ExampleFirewallsClient_Patch() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#PatchFirewallRequest. } - resp, err := c.Patch(ctx, req) + op, err := c.Patch(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleFirewallsClient_Update() { @@ -154,10 +163,13 @@ func ExampleFirewallsClient_Update() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#UpdateFirewallRequest. } - resp, err := c.Update(ctx, req) + op, err := c.Update(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } diff --git a/compute/apiv1/forwarding_rules_client.go b/compute/apiv1/forwarding_rules_client.go index d11244c4ec4..9bc9120f87b 100644 --- a/compute/apiv1/forwarding_rules_client.go +++ b/compute/apiv1/forwarding_rules_client.go @@ -150,6 +150,9 @@ type forwardingRulesRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *RegionOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -170,6 +173,16 @@ func NewForwardingRulesRESTClient(ctx context.Context, opts ...option.ClientOpti } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewRegionOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &ForwardingRulesClient{internalClient: c, CallOptions: &ForwardingRulesCallOptions{}}, nil } @@ -196,6 +209,9 @@ func (c *forwardingRulesRESTClient) setGoogleClientInfo(keyval ...string) { func (c *forwardingRulesRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -354,7 +370,14 @@ func (c *forwardingRulesRESTClient) Delete(ctx context.Context, req *computepb.D if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -457,7 +480,14 @@ func (c *forwardingRulesRESTClient) Insert(ctx context.Context, req *computepb.I if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -606,7 +636,14 @@ func (c *forwardingRulesRESTClient) Patch(ctx context.Context, req *computepb.Pa if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -665,7 +702,14 @@ func (c *forwardingRulesRESTClient) SetLabels(ctx context.Context, req *computep if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -724,7 +768,14 @@ func (c *forwardingRulesRESTClient) SetTarget(ctx context.Context, req *computep if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } diff --git a/compute/apiv1/forwarding_rules_client_example_test.go b/compute/apiv1/forwarding_rules_client_example_test.go index d07ae97201d..7937a576062 100644 --- a/compute/apiv1/forwarding_rules_client_example_test.go +++ b/compute/apiv1/forwarding_rules_client_example_test.go @@ -74,12 +74,15 @@ func ExampleForwardingRulesClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteForwardingRuleRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleForwardingRulesClient_Get() { @@ -114,12 +117,15 @@ func ExampleForwardingRulesClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertForwardingRuleRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleForwardingRulesClient_List() { @@ -160,12 +166,15 @@ func ExampleForwardingRulesClient_Patch() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#PatchForwardingRuleRequest. } - resp, err := c.Patch(ctx, req) + op, err := c.Patch(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleForwardingRulesClient_SetLabels() { @@ -180,12 +189,15 @@ func ExampleForwardingRulesClient_SetLabels() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#SetLabelsForwardingRuleRequest. } - resp, err := c.SetLabels(ctx, req) + op, err := c.SetLabels(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleForwardingRulesClient_SetTarget() { @@ -200,10 +212,13 @@ func ExampleForwardingRulesClient_SetTarget() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#SetTargetForwardingRuleRequest. } - resp, err := c.SetTarget(ctx, req) + op, err := c.SetTarget(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } diff --git a/compute/apiv1/global_addresses_client.go b/compute/apiv1/global_addresses_client.go index fd5dd7e4c9a..afd5f7ce716 100644 --- a/compute/apiv1/global_addresses_client.go +++ b/compute/apiv1/global_addresses_client.go @@ -121,6 +121,9 @@ type globalAddressesRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *GlobalOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -141,6 +144,16 @@ func NewGlobalAddressesRESTClient(ctx context.Context, opts ...option.ClientOpti } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewGlobalOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &GlobalAddressesClient{internalClient: c, CallOptions: &GlobalAddressesCallOptions{}}, nil } @@ -167,6 +180,9 @@ func (c *globalAddressesRESTClient) setGoogleClientInfo(keyval ...string) { func (c *globalAddressesRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -225,7 +241,13 @@ func (c *globalAddressesRESTClient) Delete(ctx context.Context, req *computepb.D if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -328,7 +350,13 @@ func (c *globalAddressesRESTClient) Insert(ctx context.Context, req *computepb.I if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } diff --git a/compute/apiv1/global_addresses_client_example_test.go b/compute/apiv1/global_addresses_client_example_test.go index bda93018ab4..53b23f003e8 100644 --- a/compute/apiv1/global_addresses_client_example_test.go +++ b/compute/apiv1/global_addresses_client_example_test.go @@ -48,12 +48,15 @@ func ExampleGlobalAddressesClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteGlobalAddressRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleGlobalAddressesClient_Get() { @@ -88,12 +91,15 @@ func ExampleGlobalAddressesClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertGlobalAddressRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleGlobalAddressesClient_List() { diff --git a/compute/apiv1/global_forwarding_rules_client.go b/compute/apiv1/global_forwarding_rules_client.go index d94eefe4d63..8a42bcb97fd 100644 --- a/compute/apiv1/global_forwarding_rules_client.go +++ b/compute/apiv1/global_forwarding_rules_client.go @@ -142,6 +142,9 @@ type globalForwardingRulesRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *GlobalOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -162,6 +165,16 @@ func NewGlobalForwardingRulesRESTClient(ctx context.Context, opts ...option.Clie } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewGlobalOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &GlobalForwardingRulesClient{internalClient: c, CallOptions: &GlobalForwardingRulesCallOptions{}}, nil } @@ -188,6 +201,9 @@ func (c *globalForwardingRulesRESTClient) setGoogleClientInfo(keyval ...string) func (c *globalForwardingRulesRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -246,7 +262,13 @@ func (c *globalForwardingRulesRESTClient) Delete(ctx context.Context, req *compu if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -349,7 +371,13 @@ func (c *globalForwardingRulesRESTClient) Insert(ctx context.Context, req *compu if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -498,7 +526,13 @@ func (c *globalForwardingRulesRESTClient) Patch(ctx context.Context, req *comput if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -550,7 +584,13 @@ func (c *globalForwardingRulesRESTClient) SetLabels(ctx context.Context, req *co if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -609,6 +649,12 @@ func (c *globalForwardingRulesRESTClient) SetTarget(ctx context.Context, req *co if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } diff --git a/compute/apiv1/global_forwarding_rules_client_example_test.go b/compute/apiv1/global_forwarding_rules_client_example_test.go index c8418882751..062142cffc7 100644 --- a/compute/apiv1/global_forwarding_rules_client_example_test.go +++ b/compute/apiv1/global_forwarding_rules_client_example_test.go @@ -48,12 +48,15 @@ func ExampleGlobalForwardingRulesClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteGlobalForwardingRuleRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleGlobalForwardingRulesClient_Get() { @@ -88,12 +91,15 @@ func ExampleGlobalForwardingRulesClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertGlobalForwardingRuleRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleGlobalForwardingRulesClient_List() { @@ -134,12 +140,15 @@ func ExampleGlobalForwardingRulesClient_Patch() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#PatchGlobalForwardingRuleRequest. } - resp, err := c.Patch(ctx, req) + op, err := c.Patch(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleGlobalForwardingRulesClient_SetLabels() { @@ -154,12 +163,15 @@ func ExampleGlobalForwardingRulesClient_SetLabels() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#SetLabelsGlobalForwardingRuleRequest. } - resp, err := c.SetLabels(ctx, req) + op, err := c.SetLabels(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleGlobalForwardingRulesClient_SetTarget() { @@ -174,10 +186,13 @@ func ExampleGlobalForwardingRulesClient_SetTarget() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#SetTargetGlobalForwardingRuleRequest. } - resp, err := c.SetTarget(ctx, req) + op, err := c.SetTarget(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } diff --git a/compute/apiv1/global_network_endpoint_groups_client.go b/compute/apiv1/global_network_endpoint_groups_client.go index fe94bc38ae3..12ad8e037c4 100644 --- a/compute/apiv1/global_network_endpoint_groups_client.go +++ b/compute/apiv1/global_network_endpoint_groups_client.go @@ -142,6 +142,9 @@ type globalNetworkEndpointGroupsRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *GlobalOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -162,6 +165,16 @@ func NewGlobalNetworkEndpointGroupsRESTClient(ctx context.Context, opts ...optio } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewGlobalOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &GlobalNetworkEndpointGroupsClient{internalClient: c, CallOptions: &GlobalNetworkEndpointGroupsCallOptions{}}, nil } @@ -188,6 +201,9 @@ func (c *globalNetworkEndpointGroupsRESTClient) setGoogleClientInfo(keyval ...st func (c *globalNetworkEndpointGroupsRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -253,7 +269,13 @@ func (c *globalNetworkEndpointGroupsRESTClient) AttachNetworkEndpoints(ctx conte if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -305,7 +327,13 @@ func (c *globalNetworkEndpointGroupsRESTClient) Delete(ctx context.Context, req if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -364,7 +392,13 @@ func (c *globalNetworkEndpointGroupsRESTClient) DetachNetworkEndpoints(ctx conte if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -467,7 +501,13 @@ func (c *globalNetworkEndpointGroupsRESTClient) Insert(ctx context.Context, req if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } diff --git a/compute/apiv1/global_network_endpoint_groups_client_example_test.go b/compute/apiv1/global_network_endpoint_groups_client_example_test.go index 5c589584326..c1f1c3809ef 100644 --- a/compute/apiv1/global_network_endpoint_groups_client_example_test.go +++ b/compute/apiv1/global_network_endpoint_groups_client_example_test.go @@ -48,12 +48,15 @@ func ExampleGlobalNetworkEndpointGroupsClient_AttachNetworkEndpoints() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#AttachNetworkEndpointsGlobalNetworkEndpointGroupRequest. } - resp, err := c.AttachNetworkEndpoints(ctx, req) + op, err := c.AttachNetworkEndpoints(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleGlobalNetworkEndpointGroupsClient_Delete() { @@ -68,12 +71,15 @@ func ExampleGlobalNetworkEndpointGroupsClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteGlobalNetworkEndpointGroupRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleGlobalNetworkEndpointGroupsClient_DetachNetworkEndpoints() { @@ -88,12 +94,15 @@ func ExampleGlobalNetworkEndpointGroupsClient_DetachNetworkEndpoints() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DetachNetworkEndpointsGlobalNetworkEndpointGroupRequest. } - resp, err := c.DetachNetworkEndpoints(ctx, req) + op, err := c.DetachNetworkEndpoints(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleGlobalNetworkEndpointGroupsClient_Get() { @@ -128,12 +137,15 @@ func ExampleGlobalNetworkEndpointGroupsClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertGlobalNetworkEndpointGroupRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleGlobalNetworkEndpointGroupsClient_List() { diff --git a/compute/apiv1/global_public_delegated_prefixes_client.go b/compute/apiv1/global_public_delegated_prefixes_client.go index cd3073dd076..b7f469c57dd 100644 --- a/compute/apiv1/global_public_delegated_prefixes_client.go +++ b/compute/apiv1/global_public_delegated_prefixes_client.go @@ -128,6 +128,9 @@ type globalPublicDelegatedPrefixesRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *GlobalOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -148,6 +151,16 @@ func NewGlobalPublicDelegatedPrefixesRESTClient(ctx context.Context, opts ...opt } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewGlobalOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &GlobalPublicDelegatedPrefixesClient{internalClient: c, CallOptions: &GlobalPublicDelegatedPrefixesCallOptions{}}, nil } @@ -174,6 +187,9 @@ func (c *globalPublicDelegatedPrefixesRESTClient) setGoogleClientInfo(keyval ... func (c *globalPublicDelegatedPrefixesRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -232,7 +248,13 @@ func (c *globalPublicDelegatedPrefixesRESTClient) Delete(ctx context.Context, re if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -335,7 +357,13 @@ func (c *globalPublicDelegatedPrefixesRESTClient) Insert(ctx context.Context, re if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -484,7 +512,13 @@ func (c *globalPublicDelegatedPrefixesRESTClient) Patch(ctx context.Context, req if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } diff --git a/compute/apiv1/global_public_delegated_prefixes_client_example_test.go b/compute/apiv1/global_public_delegated_prefixes_client_example_test.go index f7d5b2cdb45..398a6edd138 100644 --- a/compute/apiv1/global_public_delegated_prefixes_client_example_test.go +++ b/compute/apiv1/global_public_delegated_prefixes_client_example_test.go @@ -48,12 +48,15 @@ func ExampleGlobalPublicDelegatedPrefixesClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteGlobalPublicDelegatedPrefixeRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleGlobalPublicDelegatedPrefixesClient_Get() { @@ -88,12 +91,15 @@ func ExampleGlobalPublicDelegatedPrefixesClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertGlobalPublicDelegatedPrefixeRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleGlobalPublicDelegatedPrefixesClient_List() { @@ -134,10 +140,13 @@ func ExampleGlobalPublicDelegatedPrefixesClient_Patch() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#PatchGlobalPublicDelegatedPrefixeRequest. } - resp, err := c.Patch(ctx, req) + op, err := c.Patch(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } diff --git a/compute/apiv1/health_checks_client.go b/compute/apiv1/health_checks_client.go index dba1f910aff..fc508d14920 100644 --- a/compute/apiv1/health_checks_client.go +++ b/compute/apiv1/health_checks_client.go @@ -143,6 +143,9 @@ type healthChecksRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *GlobalOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -163,6 +166,16 @@ func NewHealthChecksRESTClient(ctx context.Context, opts ...option.ClientOption) } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewGlobalOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &HealthChecksClient{internalClient: c, CallOptions: &HealthChecksCallOptions{}}, nil } @@ -189,6 +202,9 @@ func (c *healthChecksRESTClient) setGoogleClientInfo(keyval ...string) { func (c *healthChecksRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -347,7 +363,13 @@ func (c *healthChecksRESTClient) Delete(ctx context.Context, req *computepb.Dele if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -450,7 +472,13 @@ func (c *healthChecksRESTClient) Insert(ctx context.Context, req *computepb.Inse if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -599,7 +627,13 @@ func (c *healthChecksRESTClient) Patch(ctx context.Context, req *computepb.Patch if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -658,7 +692,13 @@ func (c *healthChecksRESTClient) Update(ctx context.Context, req *computepb.Upda if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } diff --git a/compute/apiv1/health_checks_client_example_test.go b/compute/apiv1/health_checks_client_example_test.go index 923fd0c525c..c628e4ab3e1 100644 --- a/compute/apiv1/health_checks_client_example_test.go +++ b/compute/apiv1/health_checks_client_example_test.go @@ -74,12 +74,15 @@ func ExampleHealthChecksClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteHealthCheckRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleHealthChecksClient_Get() { @@ -114,12 +117,15 @@ func ExampleHealthChecksClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertHealthCheckRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleHealthChecksClient_List() { @@ -160,12 +166,15 @@ func ExampleHealthChecksClient_Patch() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#PatchHealthCheckRequest. } - resp, err := c.Patch(ctx, req) + op, err := c.Patch(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleHealthChecksClient_Update() { @@ -180,10 +189,13 @@ func ExampleHealthChecksClient_Update() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#UpdateHealthCheckRequest. } - resp, err := c.Update(ctx, req) + op, err := c.Update(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } diff --git a/compute/apiv1/images_client.go b/compute/apiv1/images_client.go index 2bdcb5584e6..669beec77c7 100644 --- a/compute/apiv1/images_client.go +++ b/compute/apiv1/images_client.go @@ -170,6 +170,9 @@ type imagesRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *GlobalOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -190,6 +193,16 @@ func NewImagesRESTClient(ctx context.Context, opts ...option.ClientOption) (*Ima } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewGlobalOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &ImagesClient{internalClient: c, CallOptions: &ImagesCallOptions{}}, nil } @@ -216,6 +229,9 @@ func (c *imagesRESTClient) setGoogleClientInfo(keyval ...string) { func (c *imagesRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -274,7 +290,13 @@ func (c *imagesRESTClient) Delete(ctx context.Context, req *computepb.DeleteImag if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -333,7 +355,13 @@ func (c *imagesRESTClient) Deprecate(ctx context.Context, req *computepb.Depreca if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -534,7 +562,13 @@ func (c *imagesRESTClient) Insert(ctx context.Context, req *computepb.InsertImag if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -683,7 +717,13 @@ func (c *imagesRESTClient) Patch(ctx context.Context, req *computepb.PatchImageR if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -786,7 +826,13 @@ func (c *imagesRESTClient) SetLabels(ctx context.Context, req *computepb.SetLabe if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } diff --git a/compute/apiv1/images_client_example_test.go b/compute/apiv1/images_client_example_test.go index 898d14708d8..32c3f678a51 100644 --- a/compute/apiv1/images_client_example_test.go +++ b/compute/apiv1/images_client_example_test.go @@ -48,12 +48,15 @@ func ExampleImagesClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteImageRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleImagesClient_Deprecate() { @@ -68,12 +71,15 @@ func ExampleImagesClient_Deprecate() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeprecateImageRequest. } - resp, err := c.Deprecate(ctx, req) + op, err := c.Deprecate(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleImagesClient_Get() { @@ -148,12 +154,15 @@ func ExampleImagesClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertImageRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleImagesClient_List() { @@ -194,12 +203,15 @@ func ExampleImagesClient_Patch() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#PatchImageRequest. } - resp, err := c.Patch(ctx, req) + op, err := c.Patch(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleImagesClient_SetIamPolicy() { @@ -234,12 +246,15 @@ func ExampleImagesClient_SetLabels() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#SetLabelsImageRequest. } - resp, err := c.SetLabels(ctx, req) + op, err := c.SetLabels(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleImagesClient_TestIamPermissions() { diff --git a/compute/apiv1/instance_group_managers_client.go b/compute/apiv1/instance_group_managers_client.go index 44c5bc5ac84..933e9e0ba16 100644 --- a/compute/apiv1/instance_group_managers_client.go +++ b/compute/apiv1/instance_group_managers_client.go @@ -234,6 +234,9 @@ type instanceGroupManagersRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *ZoneOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -254,6 +257,16 @@ func NewInstanceGroupManagersRESTClient(ctx context.Context, opts ...option.Clie } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewZoneOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &InstanceGroupManagersClient{internalClient: c, CallOptions: &InstanceGroupManagersCallOptions{}}, nil } @@ -280,6 +293,9 @@ func (c *instanceGroupManagersRESTClient) setGoogleClientInfo(keyval ...string) func (c *instanceGroupManagersRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -345,7 +361,14 @@ func (c *instanceGroupManagersRESTClient) AbandonInstances(ctx context.Context, if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -497,7 +520,14 @@ func (c *instanceGroupManagersRESTClient) ApplyUpdatesToInstances(ctx context.Co if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -556,7 +586,14 @@ func (c *instanceGroupManagersRESTClient) CreateInstances(ctx context.Context, r if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -608,7 +645,14 @@ func (c *instanceGroupManagersRESTClient) Delete(ctx context.Context, req *compu if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -667,7 +711,14 @@ func (c *instanceGroupManagersRESTClient) DeleteInstances(ctx context.Context, r if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -719,7 +770,14 @@ func (c *instanceGroupManagersRESTClient) DeletePerInstanceConfigs(ctx context.C if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -822,7 +880,14 @@ func (c *instanceGroupManagersRESTClient) Insert(ctx context.Context, req *compu if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -1241,7 +1306,14 @@ func (c *instanceGroupManagersRESTClient) Patch(ctx context.Context, req *comput if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -1300,7 +1372,14 @@ func (c *instanceGroupManagersRESTClient) PatchPerInstanceConfigs(ctx context.Co if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -1359,7 +1438,14 @@ func (c *instanceGroupManagersRESTClient) RecreateInstances(ctx context.Context, if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -1412,7 +1498,14 @@ func (c *instanceGroupManagersRESTClient) Resize(ctx context.Context, req *compu if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -1471,7 +1564,14 @@ func (c *instanceGroupManagersRESTClient) SetInstanceTemplate(ctx context.Contex if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -1530,7 +1630,14 @@ func (c *instanceGroupManagersRESTClient) SetTargetPools(ctx context.Context, re if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -1589,7 +1696,14 @@ func (c *instanceGroupManagersRESTClient) UpdatePerInstanceConfigs(ctx context.C if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } diff --git a/compute/apiv1/instance_group_managers_client_example_test.go b/compute/apiv1/instance_group_managers_client_example_test.go index 9fa248fdea0..9b42406b42e 100644 --- a/compute/apiv1/instance_group_managers_client_example_test.go +++ b/compute/apiv1/instance_group_managers_client_example_test.go @@ -48,12 +48,15 @@ func ExampleInstanceGroupManagersClient_AbandonInstances() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#AbandonInstancesInstanceGroupManagerRequest. } - resp, err := c.AbandonInstances(ctx, req) + op, err := c.AbandonInstances(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleInstanceGroupManagersClient_AggregatedList() { @@ -94,12 +97,15 @@ func ExampleInstanceGroupManagersClient_ApplyUpdatesToInstances() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#ApplyUpdatesToInstancesInstanceGroupManagerRequest. } - resp, err := c.ApplyUpdatesToInstances(ctx, req) + op, err := c.ApplyUpdatesToInstances(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleInstanceGroupManagersClient_CreateInstances() { @@ -114,12 +120,15 @@ func ExampleInstanceGroupManagersClient_CreateInstances() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#CreateInstancesInstanceGroupManagerRequest. } - resp, err := c.CreateInstances(ctx, req) + op, err := c.CreateInstances(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleInstanceGroupManagersClient_Delete() { @@ -134,12 +143,15 @@ func ExampleInstanceGroupManagersClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteInstanceGroupManagerRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleInstanceGroupManagersClient_DeleteInstances() { @@ -154,12 +166,15 @@ func ExampleInstanceGroupManagersClient_DeleteInstances() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteInstancesInstanceGroupManagerRequest. } - resp, err := c.DeleteInstances(ctx, req) + op, err := c.DeleteInstances(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleInstanceGroupManagersClient_DeletePerInstanceConfigs() { @@ -174,12 +189,15 @@ func ExampleInstanceGroupManagersClient_DeletePerInstanceConfigs() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeletePerInstanceConfigsInstanceGroupManagerRequest. } - resp, err := c.DeletePerInstanceConfigs(ctx, req) + op, err := c.DeletePerInstanceConfigs(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleInstanceGroupManagersClient_Get() { @@ -214,12 +232,15 @@ func ExampleInstanceGroupManagersClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertInstanceGroupManagerRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleInstanceGroupManagersClient_List() { @@ -338,12 +359,15 @@ func ExampleInstanceGroupManagersClient_Patch() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#PatchInstanceGroupManagerRequest. } - resp, err := c.Patch(ctx, req) + op, err := c.Patch(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleInstanceGroupManagersClient_PatchPerInstanceConfigs() { @@ -358,12 +382,15 @@ func ExampleInstanceGroupManagersClient_PatchPerInstanceConfigs() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#PatchPerInstanceConfigsInstanceGroupManagerRequest. } - resp, err := c.PatchPerInstanceConfigs(ctx, req) + op, err := c.PatchPerInstanceConfigs(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleInstanceGroupManagersClient_RecreateInstances() { @@ -378,12 +405,15 @@ func ExampleInstanceGroupManagersClient_RecreateInstances() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#RecreateInstancesInstanceGroupManagerRequest. } - resp, err := c.RecreateInstances(ctx, req) + op, err := c.RecreateInstances(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleInstanceGroupManagersClient_Resize() { @@ -398,12 +428,15 @@ func ExampleInstanceGroupManagersClient_Resize() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#ResizeInstanceGroupManagerRequest. } - resp, err := c.Resize(ctx, req) + op, err := c.Resize(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleInstanceGroupManagersClient_SetInstanceTemplate() { @@ -418,12 +451,15 @@ func ExampleInstanceGroupManagersClient_SetInstanceTemplate() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#SetInstanceTemplateInstanceGroupManagerRequest. } - resp, err := c.SetInstanceTemplate(ctx, req) + op, err := c.SetInstanceTemplate(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleInstanceGroupManagersClient_SetTargetPools() { @@ -438,12 +474,15 @@ func ExampleInstanceGroupManagersClient_SetTargetPools() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#SetTargetPoolsInstanceGroupManagerRequest. } - resp, err := c.SetTargetPools(ctx, req) + op, err := c.SetTargetPools(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleInstanceGroupManagersClient_UpdatePerInstanceConfigs() { @@ -458,10 +497,13 @@ func ExampleInstanceGroupManagersClient_UpdatePerInstanceConfigs() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#UpdatePerInstanceConfigsInstanceGroupManagerRequest. } - resp, err := c.UpdatePerInstanceConfigs(ctx, req) + op, err := c.UpdatePerInstanceConfigs(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } diff --git a/compute/apiv1/instance_groups_client.go b/compute/apiv1/instance_groups_client.go index 3ffe1930d35..44148f3954e 100644 --- a/compute/apiv1/instance_groups_client.go +++ b/compute/apiv1/instance_groups_client.go @@ -157,6 +157,9 @@ type instanceGroupsRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *ZoneOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -177,6 +180,16 @@ func NewInstanceGroupsRESTClient(ctx context.Context, opts ...option.ClientOptio } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewZoneOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &InstanceGroupsClient{internalClient: c, CallOptions: &InstanceGroupsCallOptions{}}, nil } @@ -203,6 +216,9 @@ func (c *instanceGroupsRESTClient) setGoogleClientInfo(keyval ...string) { func (c *instanceGroupsRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -268,7 +284,14 @@ func (c *instanceGroupsRESTClient) AddInstances(ctx context.Context, req *comput if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -420,7 +443,14 @@ func (c *instanceGroupsRESTClient) Delete(ctx context.Context, req *computepb.De if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -523,7 +553,14 @@ func (c *instanceGroupsRESTClient) Insert(ctx context.Context, req *computepb.In if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -768,7 +805,14 @@ func (c *instanceGroupsRESTClient) RemoveInstances(ctx context.Context, req *com if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -827,7 +871,14 @@ func (c *instanceGroupsRESTClient) SetNamedPorts(ctx context.Context, req *compu if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } diff --git a/compute/apiv1/instance_groups_client_example_test.go b/compute/apiv1/instance_groups_client_example_test.go index f7eeb4a5eb9..856c83895a9 100644 --- a/compute/apiv1/instance_groups_client_example_test.go +++ b/compute/apiv1/instance_groups_client_example_test.go @@ -48,12 +48,15 @@ func ExampleInstanceGroupsClient_AddInstances() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#AddInstancesInstanceGroupRequest. } - resp, err := c.AddInstances(ctx, req) + op, err := c.AddInstances(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleInstanceGroupsClient_AggregatedList() { @@ -94,12 +97,15 @@ func ExampleInstanceGroupsClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteInstanceGroupRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleInstanceGroupsClient_Get() { @@ -134,12 +140,15 @@ func ExampleInstanceGroupsClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertInstanceGroupRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleInstanceGroupsClient_List() { @@ -206,12 +215,15 @@ func ExampleInstanceGroupsClient_RemoveInstances() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#RemoveInstancesInstanceGroupRequest. } - resp, err := c.RemoveInstances(ctx, req) + op, err := c.RemoveInstances(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleInstanceGroupsClient_SetNamedPorts() { @@ -226,10 +238,13 @@ func ExampleInstanceGroupsClient_SetNamedPorts() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#SetNamedPortsInstanceGroupRequest. } - resp, err := c.SetNamedPorts(ctx, req) + op, err := c.SetNamedPorts(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } diff --git a/compute/apiv1/instance_templates_client.go b/compute/apiv1/instance_templates_client.go index 555fa105b2d..7347e960f5c 100644 --- a/compute/apiv1/instance_templates_client.go +++ b/compute/apiv1/instance_templates_client.go @@ -142,6 +142,9 @@ type instanceTemplatesRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *GlobalOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -162,6 +165,16 @@ func NewInstanceTemplatesRESTClient(ctx context.Context, opts ...option.ClientOp } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewGlobalOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &InstanceTemplatesClient{internalClient: c, CallOptions: &InstanceTemplatesCallOptions{}}, nil } @@ -188,6 +201,9 @@ func (c *instanceTemplatesRESTClient) setGoogleClientInfo(keyval ...string) { func (c *instanceTemplatesRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -246,7 +262,13 @@ func (c *instanceTemplatesRESTClient) Delete(ctx context.Context, req *computepb if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -400,7 +422,13 @@ func (c *instanceTemplatesRESTClient) Insert(ctx context.Context, req *computepb if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } diff --git a/compute/apiv1/instance_templates_client_example_test.go b/compute/apiv1/instance_templates_client_example_test.go index 901b2e1a1f3..11a4789bc78 100644 --- a/compute/apiv1/instance_templates_client_example_test.go +++ b/compute/apiv1/instance_templates_client_example_test.go @@ -48,12 +48,15 @@ func ExampleInstanceTemplatesClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteInstanceTemplateRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleInstanceTemplatesClient_Get() { @@ -108,12 +111,15 @@ func ExampleInstanceTemplatesClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertInstanceTemplateRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleInstanceTemplatesClient_List() { diff --git a/compute/apiv1/instances_client.go b/compute/apiv1/instances_client.go index e38a8441ef5..c831487a1cd 100644 --- a/compute/apiv1/instances_client.go +++ b/compute/apiv1/instances_client.go @@ -395,6 +395,9 @@ type instancesRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *ZoneOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -415,6 +418,16 @@ func NewInstancesRESTClient(ctx context.Context, opts ...option.ClientOption) (* } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewZoneOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &InstancesClient{internalClient: c, CallOptions: &InstancesCallOptions{}}, nil } @@ -441,6 +454,9 @@ func (c *instancesRESTClient) setGoogleClientInfo(keyval ...string) { func (c *instancesRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -507,7 +523,14 @@ func (c *instancesRESTClient) AddAccessConfig(ctx context.Context, req *computep if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -566,7 +589,14 @@ func (c *instancesRESTClient) AddResourcePolicies(ctx context.Context, req *comp if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -728,7 +758,14 @@ func (c *instancesRESTClient) AttachDisk(ctx context.Context, req *computepb.Att if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -787,7 +824,14 @@ func (c *instancesRESTClient) BulkInsert(ctx context.Context, req *computepb.Bul if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -839,7 +883,14 @@ func (c *instancesRESTClient) Delete(ctx context.Context, req *computepb.DeleteI if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -893,7 +944,14 @@ func (c *instancesRESTClient) DeleteAccessConfig(ctx context.Context, req *compu if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -946,7 +1004,14 @@ func (c *instancesRESTClient) DetachDisk(ctx context.Context, req *computepb.Det if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -1348,7 +1413,14 @@ func (c *instancesRESTClient) Insert(ctx context.Context, req *computepb.InsertI if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -1587,7 +1659,14 @@ func (c *instancesRESTClient) RemoveResourcePolicies(ctx context.Context, req *c if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -1639,7 +1718,14 @@ func (c *instancesRESTClient) Reset(ctx context.Context, req *computepb.ResetIns if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -1738,7 +1824,14 @@ func (c *instancesRESTClient) SetDeletionProtection(ctx context.Context, req *co if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -1792,7 +1885,14 @@ func (c *instancesRESTClient) SetDiskAutoDelete(ctx context.Context, req *comput if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -1902,7 +2002,14 @@ func (c *instancesRESTClient) SetLabels(ctx context.Context, req *computepb.SetL if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -1961,7 +2068,14 @@ func (c *instancesRESTClient) SetMachineResources(ctx context.Context, req *comp if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -2020,7 +2134,14 @@ func (c *instancesRESTClient) SetMachineType(ctx context.Context, req *computepb if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -2079,7 +2200,14 @@ func (c *instancesRESTClient) SetMetadata(ctx context.Context, req *computepb.Se if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -2138,7 +2266,14 @@ func (c *instancesRESTClient) SetMinCpuPlatform(ctx context.Context, req *comput if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -2197,7 +2332,14 @@ func (c *instancesRESTClient) SetScheduling(ctx context.Context, req *computepb. if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -2256,7 +2398,14 @@ func (c *instancesRESTClient) SetServiceAccount(ctx context.Context, req *comput if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -2315,7 +2464,14 @@ func (c *instancesRESTClient) SetShieldedInstanceIntegrityPolicy(ctx context.Con if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -2374,7 +2530,14 @@ func (c *instancesRESTClient) SetTags(ctx context.Context, req *computepb.SetTag if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -2419,7 +2582,14 @@ func (c *instancesRESTClient) SimulateMaintenanceEvent(ctx context.Context, req if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -2471,7 +2641,14 @@ func (c *instancesRESTClient) Start(ctx context.Context, req *computepb.StartIns if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -2530,7 +2707,14 @@ func (c *instancesRESTClient) StartWithEncryptionKey(ctx context.Context, req *c if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -2582,7 +2766,14 @@ func (c *instancesRESTClient) Stop(ctx context.Context, req *computepb.StopInsta if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -2698,7 +2889,14 @@ func (c *instancesRESTClient) Update(ctx context.Context, req *computepb.UpdateI if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -2758,7 +2956,14 @@ func (c *instancesRESTClient) UpdateAccessConfig(ctx context.Context, req *compu if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -2817,7 +3022,14 @@ func (c *instancesRESTClient) UpdateDisplayDevice(ctx context.Context, req *comp if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -2877,7 +3089,14 @@ func (c *instancesRESTClient) UpdateNetworkInterface(ctx context.Context, req *c if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -2936,7 +3155,14 @@ func (c *instancesRESTClient) UpdateShieldedInstanceConfig(ctx context.Context, if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } diff --git a/compute/apiv1/instances_client_example_test.go b/compute/apiv1/instances_client_example_test.go index b3bc2d0d1a5..7275fb06f15 100644 --- a/compute/apiv1/instances_client_example_test.go +++ b/compute/apiv1/instances_client_example_test.go @@ -48,12 +48,15 @@ func ExampleInstancesClient_AddAccessConfig() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#AddAccessConfigInstanceRequest. } - resp, err := c.AddAccessConfig(ctx, req) + op, err := c.AddAccessConfig(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleInstancesClient_AddResourcePolicies() { @@ -68,12 +71,15 @@ func ExampleInstancesClient_AddResourcePolicies() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#AddResourcePoliciesInstanceRequest. } - resp, err := c.AddResourcePolicies(ctx, req) + op, err := c.AddResourcePolicies(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleInstancesClient_AggregatedList() { @@ -114,12 +120,15 @@ func ExampleInstancesClient_AttachDisk() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#AttachDiskInstanceRequest. } - resp, err := c.AttachDisk(ctx, req) + op, err := c.AttachDisk(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleInstancesClient_BulkInsert() { @@ -134,12 +143,15 @@ func ExampleInstancesClient_BulkInsert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#BulkInsertInstanceRequest. } - resp, err := c.BulkInsert(ctx, req) + op, err := c.BulkInsert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleInstancesClient_Delete() { @@ -154,12 +166,15 @@ func ExampleInstancesClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteInstanceRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleInstancesClient_DeleteAccessConfig() { @@ -174,12 +189,15 @@ func ExampleInstancesClient_DeleteAccessConfig() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteAccessConfigInstanceRequest. } - resp, err := c.DeleteAccessConfig(ctx, req) + op, err := c.DeleteAccessConfig(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleInstancesClient_DetachDisk() { @@ -194,12 +212,15 @@ func ExampleInstancesClient_DetachDisk() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DetachDiskInstanceRequest. } - resp, err := c.DetachDisk(ctx, req) + op, err := c.DetachDisk(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleInstancesClient_Get() { @@ -354,12 +375,15 @@ func ExampleInstancesClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertInstanceRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleInstancesClient_List() { @@ -426,12 +450,15 @@ func ExampleInstancesClient_RemoveResourcePolicies() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#RemoveResourcePoliciesInstanceRequest. } - resp, err := c.RemoveResourcePolicies(ctx, req) + op, err := c.RemoveResourcePolicies(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleInstancesClient_Reset() { @@ -446,12 +473,15 @@ func ExampleInstancesClient_Reset() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#ResetInstanceRequest. } - resp, err := c.Reset(ctx, req) + op, err := c.Reset(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleInstancesClient_SendDiagnosticInterrupt() { @@ -486,12 +516,15 @@ func ExampleInstancesClient_SetDeletionProtection() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#SetDeletionProtectionInstanceRequest. } - resp, err := c.SetDeletionProtection(ctx, req) + op, err := c.SetDeletionProtection(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleInstancesClient_SetDiskAutoDelete() { @@ -506,12 +539,15 @@ func ExampleInstancesClient_SetDiskAutoDelete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#SetDiskAutoDeleteInstanceRequest. } - resp, err := c.SetDiskAutoDelete(ctx, req) + op, err := c.SetDiskAutoDelete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleInstancesClient_SetIamPolicy() { @@ -546,12 +582,15 @@ func ExampleInstancesClient_SetLabels() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#SetLabelsInstanceRequest. } - resp, err := c.SetLabels(ctx, req) + op, err := c.SetLabels(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleInstancesClient_SetMachineResources() { @@ -566,12 +605,15 @@ func ExampleInstancesClient_SetMachineResources() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#SetMachineResourcesInstanceRequest. } - resp, err := c.SetMachineResources(ctx, req) + op, err := c.SetMachineResources(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleInstancesClient_SetMachineType() { @@ -586,12 +628,15 @@ func ExampleInstancesClient_SetMachineType() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#SetMachineTypeInstanceRequest. } - resp, err := c.SetMachineType(ctx, req) + op, err := c.SetMachineType(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleInstancesClient_SetMetadata() { @@ -606,12 +651,15 @@ func ExampleInstancesClient_SetMetadata() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#SetMetadataInstanceRequest. } - resp, err := c.SetMetadata(ctx, req) + op, err := c.SetMetadata(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleInstancesClient_SetMinCpuPlatform() { @@ -626,12 +674,15 @@ func ExampleInstancesClient_SetMinCpuPlatform() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#SetMinCpuPlatformInstanceRequest. } - resp, err := c.SetMinCpuPlatform(ctx, req) + op, err := c.SetMinCpuPlatform(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleInstancesClient_SetScheduling() { @@ -646,12 +697,15 @@ func ExampleInstancesClient_SetScheduling() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#SetSchedulingInstanceRequest. } - resp, err := c.SetScheduling(ctx, req) + op, err := c.SetScheduling(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleInstancesClient_SetServiceAccount() { @@ -666,12 +720,15 @@ func ExampleInstancesClient_SetServiceAccount() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#SetServiceAccountInstanceRequest. } - resp, err := c.SetServiceAccount(ctx, req) + op, err := c.SetServiceAccount(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleInstancesClient_SetShieldedInstanceIntegrityPolicy() { @@ -686,12 +743,15 @@ func ExampleInstancesClient_SetShieldedInstanceIntegrityPolicy() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#SetShieldedInstanceIntegrityPolicyInstanceRequest. } - resp, err := c.SetShieldedInstanceIntegrityPolicy(ctx, req) + op, err := c.SetShieldedInstanceIntegrityPolicy(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleInstancesClient_SetTags() { @@ -706,12 +766,15 @@ func ExampleInstancesClient_SetTags() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#SetTagsInstanceRequest. } - resp, err := c.SetTags(ctx, req) + op, err := c.SetTags(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleInstancesClient_SimulateMaintenanceEvent() { @@ -726,12 +789,15 @@ func ExampleInstancesClient_SimulateMaintenanceEvent() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#SimulateMaintenanceEventInstanceRequest. } - resp, err := c.SimulateMaintenanceEvent(ctx, req) + op, err := c.SimulateMaintenanceEvent(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleInstancesClient_Start() { @@ -746,12 +812,15 @@ func ExampleInstancesClient_Start() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#StartInstanceRequest. } - resp, err := c.Start(ctx, req) + op, err := c.Start(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleInstancesClient_StartWithEncryptionKey() { @@ -766,12 +835,15 @@ func ExampleInstancesClient_StartWithEncryptionKey() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#StartWithEncryptionKeyInstanceRequest. } - resp, err := c.StartWithEncryptionKey(ctx, req) + op, err := c.StartWithEncryptionKey(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleInstancesClient_Stop() { @@ -786,12 +858,15 @@ func ExampleInstancesClient_Stop() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#StopInstanceRequest. } - resp, err := c.Stop(ctx, req) + op, err := c.Stop(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleInstancesClient_TestIamPermissions() { @@ -826,12 +901,15 @@ func ExampleInstancesClient_Update() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#UpdateInstanceRequest. } - resp, err := c.Update(ctx, req) + op, err := c.Update(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleInstancesClient_UpdateAccessConfig() { @@ -846,12 +924,15 @@ func ExampleInstancesClient_UpdateAccessConfig() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#UpdateAccessConfigInstanceRequest. } - resp, err := c.UpdateAccessConfig(ctx, req) + op, err := c.UpdateAccessConfig(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleInstancesClient_UpdateDisplayDevice() { @@ -866,12 +947,15 @@ func ExampleInstancesClient_UpdateDisplayDevice() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#UpdateDisplayDeviceInstanceRequest. } - resp, err := c.UpdateDisplayDevice(ctx, req) + op, err := c.UpdateDisplayDevice(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleInstancesClient_UpdateNetworkInterface() { @@ -886,12 +970,15 @@ func ExampleInstancesClient_UpdateNetworkInterface() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#UpdateNetworkInterfaceInstanceRequest. } - resp, err := c.UpdateNetworkInterface(ctx, req) + op, err := c.UpdateNetworkInterface(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleInstancesClient_UpdateShieldedInstanceConfig() { @@ -906,10 +993,13 @@ func ExampleInstancesClient_UpdateShieldedInstanceConfig() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#UpdateShieldedInstanceConfigInstanceRequest. } - resp, err := c.UpdateShieldedInstanceConfig(ctx, req) + op, err := c.UpdateShieldedInstanceConfig(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } diff --git a/compute/apiv1/interconnect_attachments_client.go b/compute/apiv1/interconnect_attachments_client.go index c04acb0838e..2be90c8d989 100644 --- a/compute/apiv1/interconnect_attachments_client.go +++ b/compute/apiv1/interconnect_attachments_client.go @@ -136,6 +136,9 @@ type interconnectAttachmentsRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *RegionOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -156,6 +159,16 @@ func NewInterconnectAttachmentsRESTClient(ctx context.Context, opts ...option.Cl } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewRegionOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &InterconnectAttachmentsClient{internalClient: c, CallOptions: &InterconnectAttachmentsCallOptions{}}, nil } @@ -182,6 +195,9 @@ func (c *interconnectAttachmentsRESTClient) setGoogleClientInfo(keyval ...string func (c *interconnectAttachmentsRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -340,7 +356,14 @@ func (c *interconnectAttachmentsRESTClient) Delete(ctx context.Context, req *com if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -446,7 +469,14 @@ func (c *interconnectAttachmentsRESTClient) Insert(ctx context.Context, req *com if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -595,7 +625,14 @@ func (c *interconnectAttachmentsRESTClient) Patch(ctx context.Context, req *comp if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } diff --git a/compute/apiv1/interconnect_attachments_client_example_test.go b/compute/apiv1/interconnect_attachments_client_example_test.go index d244156f08a..8562e677477 100644 --- a/compute/apiv1/interconnect_attachments_client_example_test.go +++ b/compute/apiv1/interconnect_attachments_client_example_test.go @@ -74,12 +74,15 @@ func ExampleInterconnectAttachmentsClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteInterconnectAttachmentRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleInterconnectAttachmentsClient_Get() { @@ -114,12 +117,15 @@ func ExampleInterconnectAttachmentsClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertInterconnectAttachmentRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleInterconnectAttachmentsClient_List() { @@ -160,10 +166,13 @@ func ExampleInterconnectAttachmentsClient_Patch() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#PatchInterconnectAttachmentRequest. } - resp, err := c.Patch(ctx, req) + op, err := c.Patch(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } diff --git a/compute/apiv1/interconnects_client.go b/compute/apiv1/interconnects_client.go index 2b1854d8430..e471e8f38f5 100644 --- a/compute/apiv1/interconnects_client.go +++ b/compute/apiv1/interconnects_client.go @@ -135,6 +135,9 @@ type interconnectsRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *GlobalOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -155,6 +158,16 @@ func NewInterconnectsRESTClient(ctx context.Context, opts ...option.ClientOption } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewGlobalOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &InterconnectsClient{internalClient: c, CallOptions: &InterconnectsCallOptions{}}, nil } @@ -181,6 +194,9 @@ func (c *interconnectsRESTClient) setGoogleClientInfo(keyval ...string) { func (c *interconnectsRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -239,7 +255,13 @@ func (c *interconnectsRESTClient) Delete(ctx context.Context, req *computepb.Del if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -386,7 +408,13 @@ func (c *interconnectsRESTClient) Insert(ctx context.Context, req *computepb.Ins if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -535,7 +563,13 @@ func (c *interconnectsRESTClient) Patch(ctx context.Context, req *computepb.Patc if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } diff --git a/compute/apiv1/interconnects_client_example_test.go b/compute/apiv1/interconnects_client_example_test.go index 72aec4d7aa1..65e736fb691 100644 --- a/compute/apiv1/interconnects_client_example_test.go +++ b/compute/apiv1/interconnects_client_example_test.go @@ -48,12 +48,15 @@ func ExampleInterconnectsClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteInterconnectRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleInterconnectsClient_Get() { @@ -108,12 +111,15 @@ func ExampleInterconnectsClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertInterconnectRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleInterconnectsClient_List() { @@ -154,10 +160,13 @@ func ExampleInterconnectsClient_Patch() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#PatchInterconnectRequest. } - resp, err := c.Patch(ctx, req) + op, err := c.Patch(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } diff --git a/compute/apiv1/licenses_client.go b/compute/apiv1/licenses_client.go index 4562d4221b8..8769bc55756 100644 --- a/compute/apiv1/licenses_client.go +++ b/compute/apiv1/licenses_client.go @@ -142,6 +142,9 @@ type licensesRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *GlobalOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -162,6 +165,16 @@ func NewLicensesRESTClient(ctx context.Context, opts ...option.ClientOption) (*L } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewGlobalOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &LicensesClient{internalClient: c, CallOptions: &LicensesCallOptions{}}, nil } @@ -188,6 +201,9 @@ func (c *licensesRESTClient) setGoogleClientInfo(keyval ...string) { func (c *licensesRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -246,7 +262,13 @@ func (c *licensesRESTClient) Delete(ctx context.Context, req *computepb.DeleteLi if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -400,7 +422,13 @@ func (c *licensesRESTClient) Insert(ctx context.Context, req *computepb.InsertLi if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } diff --git a/compute/apiv1/licenses_client_example_test.go b/compute/apiv1/licenses_client_example_test.go index d69ea02c5b7..e88b2f058e3 100644 --- a/compute/apiv1/licenses_client_example_test.go +++ b/compute/apiv1/licenses_client_example_test.go @@ -48,12 +48,15 @@ func ExampleLicensesClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteLicenseRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleLicensesClient_Get() { @@ -108,12 +111,15 @@ func ExampleLicensesClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertLicenseRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleLicensesClient_List() { diff --git a/compute/apiv1/network_endpoint_groups_client.go b/compute/apiv1/network_endpoint_groups_client.go index 569c3f64540..f20b0371831 100644 --- a/compute/apiv1/network_endpoint_groups_client.go +++ b/compute/apiv1/network_endpoint_groups_client.go @@ -157,6 +157,9 @@ type networkEndpointGroupsRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *ZoneOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -177,6 +180,16 @@ func NewNetworkEndpointGroupsRESTClient(ctx context.Context, opts ...option.Clie } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewZoneOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &NetworkEndpointGroupsClient{internalClient: c, CallOptions: &NetworkEndpointGroupsCallOptions{}}, nil } @@ -203,6 +216,9 @@ func (c *networkEndpointGroupsRESTClient) setGoogleClientInfo(keyval ...string) func (c *networkEndpointGroupsRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -368,7 +384,14 @@ func (c *networkEndpointGroupsRESTClient) AttachNetworkEndpoints(ctx context.Con if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -420,7 +443,14 @@ func (c *networkEndpointGroupsRESTClient) Delete(ctx context.Context, req *compu if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -479,7 +509,14 @@ func (c *networkEndpointGroupsRESTClient) DetachNetworkEndpoints(ctx context.Con if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -582,7 +619,14 @@ func (c *networkEndpointGroupsRESTClient) Insert(ctx context.Context, req *compu if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } diff --git a/compute/apiv1/network_endpoint_groups_client_example_test.go b/compute/apiv1/network_endpoint_groups_client_example_test.go index 9c8ae7a7545..a73ad44940c 100644 --- a/compute/apiv1/network_endpoint_groups_client_example_test.go +++ b/compute/apiv1/network_endpoint_groups_client_example_test.go @@ -74,12 +74,15 @@ func ExampleNetworkEndpointGroupsClient_AttachNetworkEndpoints() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#AttachNetworkEndpointsNetworkEndpointGroupRequest. } - resp, err := c.AttachNetworkEndpoints(ctx, req) + op, err := c.AttachNetworkEndpoints(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleNetworkEndpointGroupsClient_Delete() { @@ -94,12 +97,15 @@ func ExampleNetworkEndpointGroupsClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteNetworkEndpointGroupRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleNetworkEndpointGroupsClient_DetachNetworkEndpoints() { @@ -114,12 +120,15 @@ func ExampleNetworkEndpointGroupsClient_DetachNetworkEndpoints() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DetachNetworkEndpointsNetworkEndpointGroupRequest. } - resp, err := c.DetachNetworkEndpoints(ctx, req) + op, err := c.DetachNetworkEndpoints(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleNetworkEndpointGroupsClient_Get() { @@ -154,12 +163,15 @@ func ExampleNetworkEndpointGroupsClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertNetworkEndpointGroupRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleNetworkEndpointGroupsClient_List() { diff --git a/compute/apiv1/networks_client.go b/compute/apiv1/networks_client.go index 20f680f0752..cbfcce4be91 100644 --- a/compute/apiv1/networks_client.go +++ b/compute/apiv1/networks_client.go @@ -170,6 +170,9 @@ type networksRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *GlobalOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -190,6 +193,16 @@ func NewNetworksRESTClient(ctx context.Context, opts ...option.ClientOption) (*N } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewGlobalOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &NetworksClient{internalClient: c, CallOptions: &NetworksCallOptions{}}, nil } @@ -216,6 +229,9 @@ func (c *networksRESTClient) setGoogleClientInfo(keyval ...string) { func (c *networksRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -281,7 +297,13 @@ func (c *networksRESTClient) AddPeering(ctx context.Context, req *computepb.AddP if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -333,7 +355,13 @@ func (c *networksRESTClient) Delete(ctx context.Context, req *computepb.DeleteNe if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -480,7 +508,13 @@ func (c *networksRESTClient) Insert(ctx context.Context, req *computepb.InsertNe if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -728,7 +762,13 @@ func (c *networksRESTClient) Patch(ctx context.Context, req *computepb.PatchNetw if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -787,7 +827,13 @@ func (c *networksRESTClient) RemovePeering(ctx context.Context, req *computepb.R if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -839,7 +885,13 @@ func (c *networksRESTClient) SwitchToCustomMode(ctx context.Context, req *comput if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -898,7 +950,13 @@ func (c *networksRESTClient) UpdatePeering(ctx context.Context, req *computepb.U if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } diff --git a/compute/apiv1/networks_client_example_test.go b/compute/apiv1/networks_client_example_test.go index d08339fe8d5..8d5a4c9405d 100644 --- a/compute/apiv1/networks_client_example_test.go +++ b/compute/apiv1/networks_client_example_test.go @@ -48,12 +48,15 @@ func ExampleNetworksClient_AddPeering() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#AddPeeringNetworkRequest. } - resp, err := c.AddPeering(ctx, req) + op, err := c.AddPeering(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleNetworksClient_Delete() { @@ -68,12 +71,15 @@ func ExampleNetworksClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteNetworkRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleNetworksClient_Get() { @@ -128,12 +134,15 @@ func ExampleNetworksClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertNetworkRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleNetworksClient_List() { @@ -200,12 +209,15 @@ func ExampleNetworksClient_Patch() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#PatchNetworkRequest. } - resp, err := c.Patch(ctx, req) + op, err := c.Patch(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleNetworksClient_RemovePeering() { @@ -220,12 +232,15 @@ func ExampleNetworksClient_RemovePeering() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#RemovePeeringNetworkRequest. } - resp, err := c.RemovePeering(ctx, req) + op, err := c.RemovePeering(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleNetworksClient_SwitchToCustomMode() { @@ -240,12 +255,15 @@ func ExampleNetworksClient_SwitchToCustomMode() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#SwitchToCustomModeNetworkRequest. } - resp, err := c.SwitchToCustomMode(ctx, req) + op, err := c.SwitchToCustomMode(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleNetworksClient_UpdatePeering() { @@ -260,10 +278,13 @@ func ExampleNetworksClient_UpdatePeering() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#UpdatePeeringNetworkRequest. } - resp, err := c.UpdatePeering(ctx, req) + op, err := c.UpdatePeering(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } diff --git a/compute/apiv1/node_groups_client.go b/compute/apiv1/node_groups_client.go index d68ff9e5d35..665ed5d1c57 100644 --- a/compute/apiv1/node_groups_client.go +++ b/compute/apiv1/node_groups_client.go @@ -185,6 +185,9 @@ type nodeGroupsRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *ZoneOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -205,6 +208,16 @@ func NewNodeGroupsRESTClient(ctx context.Context, opts ...option.ClientOption) ( } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewZoneOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &NodeGroupsClient{internalClient: c, CallOptions: &NodeGroupsCallOptions{}}, nil } @@ -231,6 +244,9 @@ func (c *nodeGroupsRESTClient) setGoogleClientInfo(keyval ...string) { func (c *nodeGroupsRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -296,7 +312,14 @@ func (c *nodeGroupsRESTClient) AddNodes(ctx context.Context, req *computepb.AddN if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -448,7 +471,14 @@ func (c *nodeGroupsRESTClient) Delete(ctx context.Context, req *computepb.Delete if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -507,7 +537,14 @@ func (c *nodeGroupsRESTClient) DeleteNodes(ctx context.Context, req *computepb.D if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -662,7 +699,14 @@ func (c *nodeGroupsRESTClient) Insert(ctx context.Context, req *computepb.Insert if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -901,7 +945,14 @@ func (c *nodeGroupsRESTClient) Patch(ctx context.Context, req *computepb.PatchNo if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -1011,7 +1062,14 @@ func (c *nodeGroupsRESTClient) SetNodeTemplate(ctx context.Context, req *compute if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } diff --git a/compute/apiv1/node_groups_client_example_test.go b/compute/apiv1/node_groups_client_example_test.go index 377bcc82b28..88accce8720 100644 --- a/compute/apiv1/node_groups_client_example_test.go +++ b/compute/apiv1/node_groups_client_example_test.go @@ -48,12 +48,15 @@ func ExampleNodeGroupsClient_AddNodes() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#AddNodesNodeGroupRequest. } - resp, err := c.AddNodes(ctx, req) + op, err := c.AddNodes(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleNodeGroupsClient_AggregatedList() { @@ -94,12 +97,15 @@ func ExampleNodeGroupsClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteNodeGroupRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleNodeGroupsClient_DeleteNodes() { @@ -114,12 +120,15 @@ func ExampleNodeGroupsClient_DeleteNodes() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteNodesNodeGroupRequest. } - resp, err := c.DeleteNodes(ctx, req) + op, err := c.DeleteNodes(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleNodeGroupsClient_Get() { @@ -174,12 +183,15 @@ func ExampleNodeGroupsClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertNodeGroupRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleNodeGroupsClient_List() { @@ -246,12 +258,15 @@ func ExampleNodeGroupsClient_Patch() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#PatchNodeGroupRequest. } - resp, err := c.Patch(ctx, req) + op, err := c.Patch(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleNodeGroupsClient_SetIamPolicy() { @@ -286,12 +301,15 @@ func ExampleNodeGroupsClient_SetNodeTemplate() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#SetNodeTemplateNodeGroupRequest. } - resp, err := c.SetNodeTemplate(ctx, req) + op, err := c.SetNodeTemplate(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleNodeGroupsClient_TestIamPermissions() { diff --git a/compute/apiv1/node_templates_client.go b/compute/apiv1/node_templates_client.go index 9d3c5d2c00a..6b870e57492 100644 --- a/compute/apiv1/node_templates_client.go +++ b/compute/apiv1/node_templates_client.go @@ -150,6 +150,9 @@ type nodeTemplatesRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *RegionOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -170,6 +173,16 @@ func NewNodeTemplatesRESTClient(ctx context.Context, opts ...option.ClientOption } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewRegionOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &NodeTemplatesClient{internalClient: c, CallOptions: &NodeTemplatesCallOptions{}}, nil } @@ -196,6 +209,9 @@ func (c *nodeTemplatesRESTClient) setGoogleClientInfo(keyval ...string) { func (c *nodeTemplatesRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -354,7 +370,14 @@ func (c *nodeTemplatesRESTClient) Delete(ctx context.Context, req *computepb.Del if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -508,7 +531,14 @@ func (c *nodeTemplatesRESTClient) Insert(ctx context.Context, req *computepb.Ins if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } diff --git a/compute/apiv1/node_templates_client_example_test.go b/compute/apiv1/node_templates_client_example_test.go index 3c1e3e1e593..b18990e985a 100644 --- a/compute/apiv1/node_templates_client_example_test.go +++ b/compute/apiv1/node_templates_client_example_test.go @@ -74,12 +74,15 @@ func ExampleNodeTemplatesClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteNodeTemplateRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleNodeTemplatesClient_Get() { @@ -134,12 +137,15 @@ func ExampleNodeTemplatesClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertNodeTemplateRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleNodeTemplatesClient_List() { diff --git a/compute/apiv1/operations.go b/compute/apiv1/operations.go new file mode 100644 index 00000000000..4f66a20ae3f --- /dev/null +++ b/compute/apiv1/operations.go @@ -0,0 +1,171 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by protoc-gen-go_gapic. DO NOT EDIT. + +package compute + +import ( + "context" + "time" + + gax "github.com/googleapis/gax-go/v2" + computepb "google.golang.org/genproto/googleapis/cloud/compute/v1" +) + +// Operation represents a long-running operation for this API. +type Operation struct { + operationHandle +} + +// Done reports whether the long-running operation has completed. +func (o *Operation) Done() bool { + return o.Proto().GetStatus() == computepb.Operation_DONE +} + +// Name returns the name of the long-running operation. +// The name is assigned by the server and is unique within the service from which the operation is created. +func (o *Operation) Name() string { + return o.Proto().GetName() +} + +// Wait blocks until the operation is complete, polling regularly +// after an intial period of backing off between attempts. +func (o *Operation) Wait(ctx context.Context, opts ...gax.CallOption) error { + bo := gax.Backoff{ + Initial: time.Second, + Max: time.Minute, + } + for { + if err := o.Poll(ctx, opts...); err != nil { + return err + } + if o.Done() { + return nil + } + if err := gax.Sleep(ctx, bo.Pause()); err != nil { + return err + } + } +} + +type operationHandle interface { + // Poll retrieves the operation. + Poll(ctx context.Context, opts ...gax.CallOption) error + + // Proto returns the long-running operation message. + Proto() *computepb.Operation +} + +// Implements the operationHandle interface for RegionOperations. +type regionOperationsHandle struct { + c *RegionOperationsClient + proto *computepb.Operation + project string + region string +} + +// Poll retrieves the latest data for the long-running operation. +func (h *regionOperationsHandle) Poll(ctx context.Context, opts ...gax.CallOption) error { + resp, err := h.c.Get(ctx, &computepb.GetRegionOperationRequest{ + Operation: h.proto.GetName(), + Project: h.project, + Region: h.region, + }, opts...) + if err != nil { + return err + } + h.proto = resp + return nil +} + +// Proto returns the raw type this wraps. +func (h *regionOperationsHandle) Proto() *computepb.Operation { + return h.proto +} + +// Implements the operationHandle interface for ZoneOperations. +type zoneOperationsHandle struct { + c *ZoneOperationsClient + proto *computepb.Operation + project string + zone string +} + +// Poll retrieves the latest data for the long-running operation. +func (h *zoneOperationsHandle) Poll(ctx context.Context, opts ...gax.CallOption) error { + resp, err := h.c.Get(ctx, &computepb.GetZoneOperationRequest{ + Operation: h.proto.GetName(), + Project: h.project, + Zone: h.zone, + }, opts...) + if err != nil { + return err + } + h.proto = resp + return nil +} + +// Proto returns the raw type this wraps. +func (h *zoneOperationsHandle) Proto() *computepb.Operation { + return h.proto +} + +// Implements the operationHandle interface for GlobalOperations. +type globalOperationsHandle struct { + c *GlobalOperationsClient + proto *computepb.Operation + project string +} + +// Poll retrieves the latest data for the long-running operation. +func (h *globalOperationsHandle) Poll(ctx context.Context, opts ...gax.CallOption) error { + resp, err := h.c.Get(ctx, &computepb.GetGlobalOperationRequest{ + Operation: h.proto.GetName(), + Project: h.project, + }, opts...) + if err != nil { + return err + } + h.proto = resp + return nil +} + +// Proto returns the raw type this wraps. +func (h *globalOperationsHandle) Proto() *computepb.Operation { + return h.proto +} + +// Implements the operationHandle interface for GlobalOrganizationOperations. +type globalOrganizationOperationsHandle struct { + c *GlobalOrganizationOperationsClient + proto *computepb.Operation +} + +// Poll retrieves the latest data for the long-running operation. +func (h *globalOrganizationOperationsHandle) Poll(ctx context.Context, opts ...gax.CallOption) error { + resp, err := h.c.Get(ctx, &computepb.GetGlobalOrganizationOperationRequest{ + Operation: h.proto.GetName(), + }, opts...) + if err != nil { + return err + } + h.proto = resp + return nil +} + +// Proto returns the raw type this wraps. +func (h *globalOrganizationOperationsHandle) Proto() *computepb.Operation { + return h.proto +} diff --git a/compute/apiv1/packet_mirrorings_client.go b/compute/apiv1/packet_mirrorings_client.go index 92a5de7a4ee..9c843531170 100644 --- a/compute/apiv1/packet_mirrorings_client.go +++ b/compute/apiv1/packet_mirrorings_client.go @@ -143,6 +143,9 @@ type packetMirroringsRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *RegionOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -163,6 +166,16 @@ func NewPacketMirroringsRESTClient(ctx context.Context, opts ...option.ClientOpt } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewRegionOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &PacketMirroringsClient{internalClient: c, CallOptions: &PacketMirroringsCallOptions{}}, nil } @@ -189,6 +202,9 @@ func (c *packetMirroringsRESTClient) setGoogleClientInfo(keyval ...string) { func (c *packetMirroringsRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -347,7 +363,14 @@ func (c *packetMirroringsRESTClient) Delete(ctx context.Context, req *computepb. if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -450,7 +473,14 @@ func (c *packetMirroringsRESTClient) Insert(ctx context.Context, req *computepb. if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -599,7 +629,14 @@ func (c *packetMirroringsRESTClient) Patch(ctx context.Context, req *computepb.P if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } diff --git a/compute/apiv1/packet_mirrorings_client_example_test.go b/compute/apiv1/packet_mirrorings_client_example_test.go index 2464185f9ed..d0178de22f3 100644 --- a/compute/apiv1/packet_mirrorings_client_example_test.go +++ b/compute/apiv1/packet_mirrorings_client_example_test.go @@ -74,12 +74,15 @@ func ExamplePacketMirroringsClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeletePacketMirroringRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExamplePacketMirroringsClient_Get() { @@ -114,12 +117,15 @@ func ExamplePacketMirroringsClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertPacketMirroringRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExamplePacketMirroringsClient_List() { @@ -160,12 +166,15 @@ func ExamplePacketMirroringsClient_Patch() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#PatchPacketMirroringRequest. } - resp, err := c.Patch(ctx, req) + op, err := c.Patch(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExamplePacketMirroringsClient_TestIamPermissions() { diff --git a/compute/apiv1/projects_client.go b/compute/apiv1/projects_client.go index 7fe25cebb21..279e5bda76e 100644 --- a/compute/apiv1/projects_client.go +++ b/compute/apiv1/projects_client.go @@ -184,6 +184,9 @@ type projectsRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *GlobalOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -204,6 +207,16 @@ func NewProjectsRESTClient(ctx context.Context, opts ...option.ClientOption) (*P } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewGlobalOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &ProjectsClient{internalClient: c, CallOptions: &ProjectsCallOptions{}}, nil } @@ -230,6 +243,9 @@ func (c *projectsRESTClient) setGoogleClientInfo(keyval ...string) { func (c *projectsRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -288,7 +304,13 @@ func (c *projectsRESTClient) DisableXpnHost(ctx context.Context, req *computepb. if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -347,7 +369,13 @@ func (c *projectsRESTClient) DisableXpnResource(ctx context.Context, req *comput if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -399,7 +427,13 @@ func (c *projectsRESTClient) EnableXpnHost(ctx context.Context, req *computepb.E if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -458,7 +492,13 @@ func (c *projectsRESTClient) EnableXpnResource(ctx context.Context, req *compute if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -791,7 +831,13 @@ func (c *projectsRESTClient) MoveDisk(ctx context.Context, req *computepb.MoveDi if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -850,7 +896,13 @@ func (c *projectsRESTClient) MoveInstance(ctx context.Context, req *computepb.Mo if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -909,7 +961,13 @@ func (c *projectsRESTClient) SetCommonInstanceMetadata(ctx context.Context, req if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -968,7 +1026,13 @@ func (c *projectsRESTClient) SetDefaultNetworkTier(ctx context.Context, req *com if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -1027,7 +1091,13 @@ func (c *projectsRESTClient) SetUsageExportBucket(ctx context.Context, req *comp if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } diff --git a/compute/apiv1/projects_client_example_test.go b/compute/apiv1/projects_client_example_test.go index 0ba313a6167..0012c42d7ea 100644 --- a/compute/apiv1/projects_client_example_test.go +++ b/compute/apiv1/projects_client_example_test.go @@ -48,12 +48,15 @@ func ExampleProjectsClient_DisableXpnHost() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DisableXpnHostProjectRequest. } - resp, err := c.DisableXpnHost(ctx, req) + op, err := c.DisableXpnHost(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleProjectsClient_DisableXpnResource() { @@ -68,12 +71,15 @@ func ExampleProjectsClient_DisableXpnResource() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DisableXpnResourceProjectRequest. } - resp, err := c.DisableXpnResource(ctx, req) + op, err := c.DisableXpnResource(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleProjectsClient_EnableXpnHost() { @@ -88,12 +94,15 @@ func ExampleProjectsClient_EnableXpnHost() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#EnableXpnHostProjectRequest. } - resp, err := c.EnableXpnHost(ctx, req) + op, err := c.EnableXpnHost(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleProjectsClient_EnableXpnResource() { @@ -108,12 +117,15 @@ func ExampleProjectsClient_EnableXpnResource() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#EnableXpnResourceProjectRequest. } - resp, err := c.EnableXpnResource(ctx, req) + op, err := c.EnableXpnResource(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleProjectsClient_Get() { @@ -220,12 +232,15 @@ func ExampleProjectsClient_MoveDisk() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#MoveDiskProjectRequest. } - resp, err := c.MoveDisk(ctx, req) + op, err := c.MoveDisk(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleProjectsClient_MoveInstance() { @@ -240,12 +255,15 @@ func ExampleProjectsClient_MoveInstance() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#MoveInstanceProjectRequest. } - resp, err := c.MoveInstance(ctx, req) + op, err := c.MoveInstance(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleProjectsClient_SetCommonInstanceMetadata() { @@ -260,12 +278,15 @@ func ExampleProjectsClient_SetCommonInstanceMetadata() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#SetCommonInstanceMetadataProjectRequest. } - resp, err := c.SetCommonInstanceMetadata(ctx, req) + op, err := c.SetCommonInstanceMetadata(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleProjectsClient_SetDefaultNetworkTier() { @@ -280,12 +301,15 @@ func ExampleProjectsClient_SetDefaultNetworkTier() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#SetDefaultNetworkTierProjectRequest. } - resp, err := c.SetDefaultNetworkTier(ctx, req) + op, err := c.SetDefaultNetworkTier(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleProjectsClient_SetUsageExportBucket() { @@ -300,10 +324,13 @@ func ExampleProjectsClient_SetUsageExportBucket() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#SetUsageExportBucketProjectRequest. } - resp, err := c.SetUsageExportBucket(ctx, req) + op, err := c.SetUsageExportBucket(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } diff --git a/compute/apiv1/public_advertised_prefixes_client.go b/compute/apiv1/public_advertised_prefixes_client.go index 2527b4fd92a..7e7b80c531e 100644 --- a/compute/apiv1/public_advertised_prefixes_client.go +++ b/compute/apiv1/public_advertised_prefixes_client.go @@ -128,6 +128,9 @@ type publicAdvertisedPrefixesRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *GlobalOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -148,6 +151,16 @@ func NewPublicAdvertisedPrefixesRESTClient(ctx context.Context, opts ...option.C } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewGlobalOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &PublicAdvertisedPrefixesClient{internalClient: c, CallOptions: &PublicAdvertisedPrefixesCallOptions{}}, nil } @@ -174,6 +187,9 @@ func (c *publicAdvertisedPrefixesRESTClient) setGoogleClientInfo(keyval ...strin func (c *publicAdvertisedPrefixesRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -232,7 +248,13 @@ func (c *publicAdvertisedPrefixesRESTClient) Delete(ctx context.Context, req *co if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -335,7 +357,13 @@ func (c *publicAdvertisedPrefixesRESTClient) Insert(ctx context.Context, req *co if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -484,7 +512,13 @@ func (c *publicAdvertisedPrefixesRESTClient) Patch(ctx context.Context, req *com if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } diff --git a/compute/apiv1/public_advertised_prefixes_client_example_test.go b/compute/apiv1/public_advertised_prefixes_client_example_test.go index 2364d86be33..07f23cd7e5d 100644 --- a/compute/apiv1/public_advertised_prefixes_client_example_test.go +++ b/compute/apiv1/public_advertised_prefixes_client_example_test.go @@ -48,12 +48,15 @@ func ExamplePublicAdvertisedPrefixesClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeletePublicAdvertisedPrefixeRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExamplePublicAdvertisedPrefixesClient_Get() { @@ -88,12 +91,15 @@ func ExamplePublicAdvertisedPrefixesClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertPublicAdvertisedPrefixeRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExamplePublicAdvertisedPrefixesClient_List() { @@ -134,10 +140,13 @@ func ExamplePublicAdvertisedPrefixesClient_Patch() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#PatchPublicAdvertisedPrefixeRequest. } - resp, err := c.Patch(ctx, req) + op, err := c.Patch(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } diff --git a/compute/apiv1/public_delegated_prefixes_client.go b/compute/apiv1/public_delegated_prefixes_client.go index fd232bf53f8..2fbf1945efa 100644 --- a/compute/apiv1/public_delegated_prefixes_client.go +++ b/compute/apiv1/public_delegated_prefixes_client.go @@ -136,6 +136,9 @@ type publicDelegatedPrefixesRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *RegionOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -156,6 +159,16 @@ func NewPublicDelegatedPrefixesRESTClient(ctx context.Context, opts ...option.Cl } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewRegionOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &PublicDelegatedPrefixesClient{internalClient: c, CallOptions: &PublicDelegatedPrefixesCallOptions{}}, nil } @@ -182,6 +195,9 @@ func (c *publicDelegatedPrefixesRESTClient) setGoogleClientInfo(keyval ...string func (c *publicDelegatedPrefixesRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -340,7 +356,14 @@ func (c *publicDelegatedPrefixesRESTClient) Delete(ctx context.Context, req *com if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -443,7 +466,14 @@ func (c *publicDelegatedPrefixesRESTClient) Insert(ctx context.Context, req *com if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -592,7 +622,14 @@ func (c *publicDelegatedPrefixesRESTClient) Patch(ctx context.Context, req *comp if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } diff --git a/compute/apiv1/public_delegated_prefixes_client_example_test.go b/compute/apiv1/public_delegated_prefixes_client_example_test.go index c84b6fdd085..4f5c60ce085 100644 --- a/compute/apiv1/public_delegated_prefixes_client_example_test.go +++ b/compute/apiv1/public_delegated_prefixes_client_example_test.go @@ -74,12 +74,15 @@ func ExamplePublicDelegatedPrefixesClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeletePublicDelegatedPrefixeRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExamplePublicDelegatedPrefixesClient_Get() { @@ -114,12 +117,15 @@ func ExamplePublicDelegatedPrefixesClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertPublicDelegatedPrefixeRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExamplePublicDelegatedPrefixesClient_List() { @@ -160,10 +166,13 @@ func ExamplePublicDelegatedPrefixesClient_Patch() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#PatchPublicDelegatedPrefixeRequest. } - resp, err := c.Patch(ctx, req) + op, err := c.Patch(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } diff --git a/compute/apiv1/region_autoscalers_client.go b/compute/apiv1/region_autoscalers_client.go index 4d210415bf4..2075dc24c38 100644 --- a/compute/apiv1/region_autoscalers_client.go +++ b/compute/apiv1/region_autoscalers_client.go @@ -135,6 +135,9 @@ type regionAutoscalersRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *RegionOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -155,6 +158,16 @@ func NewRegionAutoscalersRESTClient(ctx context.Context, opts ...option.ClientOp } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewRegionOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &RegionAutoscalersClient{internalClient: c, CallOptions: &RegionAutoscalersCallOptions{}}, nil } @@ -181,6 +194,9 @@ func (c *regionAutoscalersRESTClient) setGoogleClientInfo(keyval ...string) { func (c *regionAutoscalersRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -239,7 +255,14 @@ func (c *regionAutoscalersRESTClient) Delete(ctx context.Context, req *computepb if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -342,7 +365,14 @@ func (c *regionAutoscalersRESTClient) Insert(ctx context.Context, req *computepb if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -494,7 +524,14 @@ func (c *regionAutoscalersRESTClient) Patch(ctx context.Context, req *computepb. if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -556,6 +593,13 @@ func (c *regionAutoscalersRESTClient) Update(ctx context.Context, req *computepb if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } diff --git a/compute/apiv1/region_autoscalers_client_example_test.go b/compute/apiv1/region_autoscalers_client_example_test.go index 46d17bb97aa..21a554391cc 100644 --- a/compute/apiv1/region_autoscalers_client_example_test.go +++ b/compute/apiv1/region_autoscalers_client_example_test.go @@ -48,12 +48,15 @@ func ExampleRegionAutoscalersClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteRegionAutoscalerRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleRegionAutoscalersClient_Get() { @@ -88,12 +91,15 @@ func ExampleRegionAutoscalersClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertRegionAutoscalerRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleRegionAutoscalersClient_List() { @@ -134,12 +140,15 @@ func ExampleRegionAutoscalersClient_Patch() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#PatchRegionAutoscalerRequest. } - resp, err := c.Patch(ctx, req) + op, err := c.Patch(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleRegionAutoscalersClient_Update() { @@ -154,10 +163,13 @@ func ExampleRegionAutoscalersClient_Update() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#UpdateRegionAutoscalerRequest. } - resp, err := c.Update(ctx, req) + op, err := c.Update(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } diff --git a/compute/apiv1/region_backend_services_client.go b/compute/apiv1/region_backend_services_client.go index 618b8d72af6..9ee24677a07 100644 --- a/compute/apiv1/region_backend_services_client.go +++ b/compute/apiv1/region_backend_services_client.go @@ -142,6 +142,9 @@ type regionBackendServicesRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *RegionOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -162,6 +165,16 @@ func NewRegionBackendServicesRESTClient(ctx context.Context, opts ...option.Clie } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewRegionOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &RegionBackendServicesClient{internalClient: c, CallOptions: &RegionBackendServicesCallOptions{}}, nil } @@ -188,6 +201,9 @@ func (c *regionBackendServicesRESTClient) setGoogleClientInfo(keyval ...string) func (c *regionBackendServicesRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -246,7 +262,14 @@ func (c *regionBackendServicesRESTClient) Delete(ctx context.Context, req *compu if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -400,7 +423,14 @@ func (c *regionBackendServicesRESTClient) Insert(ctx context.Context, req *compu if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -549,7 +579,14 @@ func (c *regionBackendServicesRESTClient) Patch(ctx context.Context, req *comput if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -608,6 +645,13 @@ func (c *regionBackendServicesRESTClient) Update(ctx context.Context, req *compu if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } diff --git a/compute/apiv1/region_backend_services_client_example_test.go b/compute/apiv1/region_backend_services_client_example_test.go index 565708e13d1..14aeebed616 100644 --- a/compute/apiv1/region_backend_services_client_example_test.go +++ b/compute/apiv1/region_backend_services_client_example_test.go @@ -48,12 +48,15 @@ func ExampleRegionBackendServicesClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteRegionBackendServiceRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleRegionBackendServicesClient_Get() { @@ -108,12 +111,15 @@ func ExampleRegionBackendServicesClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertRegionBackendServiceRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleRegionBackendServicesClient_List() { @@ -154,12 +160,15 @@ func ExampleRegionBackendServicesClient_Patch() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#PatchRegionBackendServiceRequest. } - resp, err := c.Patch(ctx, req) + op, err := c.Patch(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleRegionBackendServicesClient_Update() { @@ -174,10 +183,13 @@ func ExampleRegionBackendServicesClient_Update() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#UpdateRegionBackendServiceRequest. } - resp, err := c.Update(ctx, req) + op, err := c.Update(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } diff --git a/compute/apiv1/region_commitments_client.go b/compute/apiv1/region_commitments_client.go index cddbbd750bb..c868fc1da34 100644 --- a/compute/apiv1/region_commitments_client.go +++ b/compute/apiv1/region_commitments_client.go @@ -122,6 +122,9 @@ type regionCommitmentsRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *RegionOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -142,6 +145,16 @@ func NewRegionCommitmentsRESTClient(ctx context.Context, opts ...option.ClientOp } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewRegionOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &RegionCommitmentsClient{internalClient: c, CallOptions: &RegionCommitmentsCallOptions{}}, nil } @@ -168,6 +181,9 @@ func (c *regionCommitmentsRESTClient) setGoogleClientInfo(keyval ...string) { func (c *regionCommitmentsRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -377,7 +393,14 @@ func (c *regionCommitmentsRESTClient) Insert(ctx context.Context, req *computepb if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } diff --git a/compute/apiv1/region_commitments_client_example_test.go b/compute/apiv1/region_commitments_client_example_test.go index fbaa73ca157..0e3747f9a10 100644 --- a/compute/apiv1/region_commitments_client_example_test.go +++ b/compute/apiv1/region_commitments_client_example_test.go @@ -94,12 +94,15 @@ func ExampleRegionCommitmentsClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertRegionCommitmentRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleRegionCommitmentsClient_List() { diff --git a/compute/apiv1/region_disks_client.go b/compute/apiv1/region_disks_client.go index 5305914f117..ca8bdd9e561 100644 --- a/compute/apiv1/region_disks_client.go +++ b/compute/apiv1/region_disks_client.go @@ -177,6 +177,9 @@ type regionDisksRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *RegionOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -197,6 +200,16 @@ func NewRegionDisksRESTClient(ctx context.Context, opts ...option.ClientOption) } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewRegionOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &RegionDisksClient{internalClient: c, CallOptions: &RegionDisksCallOptions{}}, nil } @@ -223,6 +236,9 @@ func (c *regionDisksRESTClient) setGoogleClientInfo(keyval ...string) { func (c *regionDisksRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -288,7 +304,14 @@ func (c *regionDisksRESTClient) AddResourcePolicies(ctx context.Context, req *co if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -347,7 +370,14 @@ func (c *regionDisksRESTClient) CreateSnapshot(ctx context.Context, req *compute if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -399,7 +429,14 @@ func (c *regionDisksRESTClient) Delete(ctx context.Context, req *computepb.Delet if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -556,7 +593,14 @@ func (c *regionDisksRESTClient) Insert(ctx context.Context, req *computepb.Inser if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -705,7 +749,14 @@ func (c *regionDisksRESTClient) RemoveResourcePolicies(ctx context.Context, req if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -764,7 +815,14 @@ func (c *regionDisksRESTClient) Resize(ctx context.Context, req *computepb.Resiz if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -874,7 +932,14 @@ func (c *regionDisksRESTClient) SetLabels(ctx context.Context, req *computepb.Se if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } diff --git a/compute/apiv1/region_disks_client_example_test.go b/compute/apiv1/region_disks_client_example_test.go index 1aa8f628d81..e75bb8935ff 100644 --- a/compute/apiv1/region_disks_client_example_test.go +++ b/compute/apiv1/region_disks_client_example_test.go @@ -48,12 +48,15 @@ func ExampleRegionDisksClient_AddResourcePolicies() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#AddResourcePoliciesRegionDiskRequest. } - resp, err := c.AddResourcePolicies(ctx, req) + op, err := c.AddResourcePolicies(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleRegionDisksClient_CreateSnapshot() { @@ -68,12 +71,15 @@ func ExampleRegionDisksClient_CreateSnapshot() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#CreateSnapshotRegionDiskRequest. } - resp, err := c.CreateSnapshot(ctx, req) + op, err := c.CreateSnapshot(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleRegionDisksClient_Delete() { @@ -88,12 +94,15 @@ func ExampleRegionDisksClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteRegionDiskRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleRegionDisksClient_Get() { @@ -148,12 +157,15 @@ func ExampleRegionDisksClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertRegionDiskRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleRegionDisksClient_List() { @@ -194,12 +206,15 @@ func ExampleRegionDisksClient_RemoveResourcePolicies() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#RemoveResourcePoliciesRegionDiskRequest. } - resp, err := c.RemoveResourcePolicies(ctx, req) + op, err := c.RemoveResourcePolicies(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleRegionDisksClient_Resize() { @@ -214,12 +229,15 @@ func ExampleRegionDisksClient_Resize() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#ResizeRegionDiskRequest. } - resp, err := c.Resize(ctx, req) + op, err := c.Resize(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleRegionDisksClient_SetIamPolicy() { @@ -254,12 +272,15 @@ func ExampleRegionDisksClient_SetLabels() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#SetLabelsRegionDiskRequest. } - resp, err := c.SetLabels(ctx, req) + op, err := c.SetLabels(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleRegionDisksClient_TestIamPermissions() { diff --git a/compute/apiv1/region_health_check_services_client.go b/compute/apiv1/region_health_check_services_client.go index a5005198c19..4027d0b4aeb 100644 --- a/compute/apiv1/region_health_check_services_client.go +++ b/compute/apiv1/region_health_check_services_client.go @@ -128,6 +128,9 @@ type regionHealthCheckServicesRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *RegionOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -148,6 +151,16 @@ func NewRegionHealthCheckServicesRESTClient(ctx context.Context, opts ...option. } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewRegionOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &RegionHealthCheckServicesClient{internalClient: c, CallOptions: &RegionHealthCheckServicesCallOptions{}}, nil } @@ -174,6 +187,9 @@ func (c *regionHealthCheckServicesRESTClient) setGoogleClientInfo(keyval ...stri func (c *regionHealthCheckServicesRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -232,7 +248,14 @@ func (c *regionHealthCheckServicesRESTClient) Delete(ctx context.Context, req *c if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -335,7 +358,14 @@ func (c *regionHealthCheckServicesRESTClient) Insert(ctx context.Context, req *c if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -484,7 +514,14 @@ func (c *regionHealthCheckServicesRESTClient) Patch(ctx context.Context, req *co if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } diff --git a/compute/apiv1/region_health_check_services_client_example_test.go b/compute/apiv1/region_health_check_services_client_example_test.go index 21cca028a71..846ea0876df 100644 --- a/compute/apiv1/region_health_check_services_client_example_test.go +++ b/compute/apiv1/region_health_check_services_client_example_test.go @@ -48,12 +48,15 @@ func ExampleRegionHealthCheckServicesClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteRegionHealthCheckServiceRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleRegionHealthCheckServicesClient_Get() { @@ -88,12 +91,15 @@ func ExampleRegionHealthCheckServicesClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertRegionHealthCheckServiceRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleRegionHealthCheckServicesClient_List() { @@ -134,10 +140,13 @@ func ExampleRegionHealthCheckServicesClient_Patch() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#PatchRegionHealthCheckServiceRequest. } - resp, err := c.Patch(ctx, req) + op, err := c.Patch(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } diff --git a/compute/apiv1/region_health_checks_client.go b/compute/apiv1/region_health_checks_client.go index 2defdf3efd1..091d23234aa 100644 --- a/compute/apiv1/region_health_checks_client.go +++ b/compute/apiv1/region_health_checks_client.go @@ -135,6 +135,9 @@ type regionHealthChecksRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *RegionOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -155,6 +158,16 @@ func NewRegionHealthChecksRESTClient(ctx context.Context, opts ...option.ClientO } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewRegionOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &RegionHealthChecksClient{internalClient: c, CallOptions: &RegionHealthChecksCallOptions{}}, nil } @@ -181,6 +194,9 @@ func (c *regionHealthChecksRESTClient) setGoogleClientInfo(keyval ...string) { func (c *regionHealthChecksRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -239,7 +255,14 @@ func (c *regionHealthChecksRESTClient) Delete(ctx context.Context, req *computep if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -342,7 +365,14 @@ func (c *regionHealthChecksRESTClient) Insert(ctx context.Context, req *computep if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -491,7 +521,14 @@ func (c *regionHealthChecksRESTClient) Patch(ctx context.Context, req *computepb if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -550,6 +587,13 @@ func (c *regionHealthChecksRESTClient) Update(ctx context.Context, req *computep if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } diff --git a/compute/apiv1/region_health_checks_client_example_test.go b/compute/apiv1/region_health_checks_client_example_test.go index ee48027cc5a..24f1e7fb562 100644 --- a/compute/apiv1/region_health_checks_client_example_test.go +++ b/compute/apiv1/region_health_checks_client_example_test.go @@ -48,12 +48,15 @@ func ExampleRegionHealthChecksClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteRegionHealthCheckRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleRegionHealthChecksClient_Get() { @@ -88,12 +91,15 @@ func ExampleRegionHealthChecksClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertRegionHealthCheckRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleRegionHealthChecksClient_List() { @@ -134,12 +140,15 @@ func ExampleRegionHealthChecksClient_Patch() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#PatchRegionHealthCheckRequest. } - resp, err := c.Patch(ctx, req) + op, err := c.Patch(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleRegionHealthChecksClient_Update() { @@ -154,10 +163,13 @@ func ExampleRegionHealthChecksClient_Update() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#UpdateRegionHealthCheckRequest. } - resp, err := c.Update(ctx, req) + op, err := c.Update(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } diff --git a/compute/apiv1/region_instance_group_managers_client.go b/compute/apiv1/region_instance_group_managers_client.go index 3eb5f6d558b..9a55a641f08 100644 --- a/compute/apiv1/region_instance_group_managers_client.go +++ b/compute/apiv1/region_instance_group_managers_client.go @@ -226,6 +226,9 @@ type regionInstanceGroupManagersRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *RegionOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -246,6 +249,16 @@ func NewRegionInstanceGroupManagersRESTClient(ctx context.Context, opts ...optio } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewRegionOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &RegionInstanceGroupManagersClient{internalClient: c, CallOptions: &RegionInstanceGroupManagersCallOptions{}}, nil } @@ -272,6 +285,9 @@ func (c *regionInstanceGroupManagersRESTClient) setGoogleClientInfo(keyval ...st func (c *regionInstanceGroupManagersRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -337,7 +353,14 @@ func (c *regionInstanceGroupManagersRESTClient) AbandonInstances(ctx context.Con if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -389,7 +412,14 @@ func (c *regionInstanceGroupManagersRESTClient) ApplyUpdatesToInstances(ctx cont if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -448,7 +478,14 @@ func (c *regionInstanceGroupManagersRESTClient) CreateInstances(ctx context.Cont if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -500,7 +537,14 @@ func (c *regionInstanceGroupManagersRESTClient) Delete(ctx context.Context, req if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -559,7 +603,14 @@ func (c *regionInstanceGroupManagersRESTClient) DeleteInstances(ctx context.Cont if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -611,7 +662,14 @@ func (c *regionInstanceGroupManagersRESTClient) DeletePerInstanceConfigs(ctx con if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -714,7 +772,14 @@ func (c *regionInstanceGroupManagersRESTClient) Insert(ctx context.Context, req if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -1133,7 +1198,14 @@ func (c *regionInstanceGroupManagersRESTClient) Patch(ctx context.Context, req * if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -1192,7 +1264,14 @@ func (c *regionInstanceGroupManagersRESTClient) PatchPerInstanceConfigs(ctx cont if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -1251,7 +1330,14 @@ func (c *regionInstanceGroupManagersRESTClient) RecreateInstances(ctx context.Co if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -1304,7 +1390,14 @@ func (c *regionInstanceGroupManagersRESTClient) Resize(ctx context.Context, req if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -1363,7 +1456,14 @@ func (c *regionInstanceGroupManagersRESTClient) SetInstanceTemplate(ctx context. if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -1422,7 +1522,14 @@ func (c *regionInstanceGroupManagersRESTClient) SetTargetPools(ctx context.Conte if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -1481,6 +1588,13 @@ func (c *regionInstanceGroupManagersRESTClient) UpdatePerInstanceConfigs(ctx con if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } diff --git a/compute/apiv1/region_instance_group_managers_client_example_test.go b/compute/apiv1/region_instance_group_managers_client_example_test.go index cac68eb9a63..724a5ed068f 100644 --- a/compute/apiv1/region_instance_group_managers_client_example_test.go +++ b/compute/apiv1/region_instance_group_managers_client_example_test.go @@ -48,12 +48,15 @@ func ExampleRegionInstanceGroupManagersClient_AbandonInstances() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#AbandonInstancesRegionInstanceGroupManagerRequest. } - resp, err := c.AbandonInstances(ctx, req) + op, err := c.AbandonInstances(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleRegionInstanceGroupManagersClient_ApplyUpdatesToInstances() { @@ -68,12 +71,15 @@ func ExampleRegionInstanceGroupManagersClient_ApplyUpdatesToInstances() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#ApplyUpdatesToInstancesRegionInstanceGroupManagerRequest. } - resp, err := c.ApplyUpdatesToInstances(ctx, req) + op, err := c.ApplyUpdatesToInstances(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleRegionInstanceGroupManagersClient_CreateInstances() { @@ -88,12 +94,15 @@ func ExampleRegionInstanceGroupManagersClient_CreateInstances() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#CreateInstancesRegionInstanceGroupManagerRequest. } - resp, err := c.CreateInstances(ctx, req) + op, err := c.CreateInstances(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleRegionInstanceGroupManagersClient_Delete() { @@ -108,12 +117,15 @@ func ExampleRegionInstanceGroupManagersClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteRegionInstanceGroupManagerRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleRegionInstanceGroupManagersClient_DeleteInstances() { @@ -128,12 +140,15 @@ func ExampleRegionInstanceGroupManagersClient_DeleteInstances() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteInstancesRegionInstanceGroupManagerRequest. } - resp, err := c.DeleteInstances(ctx, req) + op, err := c.DeleteInstances(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleRegionInstanceGroupManagersClient_DeletePerInstanceConfigs() { @@ -148,12 +163,15 @@ func ExampleRegionInstanceGroupManagersClient_DeletePerInstanceConfigs() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeletePerInstanceConfigsRegionInstanceGroupManagerRequest. } - resp, err := c.DeletePerInstanceConfigs(ctx, req) + op, err := c.DeletePerInstanceConfigs(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleRegionInstanceGroupManagersClient_Get() { @@ -188,12 +206,15 @@ func ExampleRegionInstanceGroupManagersClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertRegionInstanceGroupManagerRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleRegionInstanceGroupManagersClient_List() { @@ -312,12 +333,15 @@ func ExampleRegionInstanceGroupManagersClient_Patch() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#PatchRegionInstanceGroupManagerRequest. } - resp, err := c.Patch(ctx, req) + op, err := c.Patch(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleRegionInstanceGroupManagersClient_PatchPerInstanceConfigs() { @@ -332,12 +356,15 @@ func ExampleRegionInstanceGroupManagersClient_PatchPerInstanceConfigs() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#PatchPerInstanceConfigsRegionInstanceGroupManagerRequest. } - resp, err := c.PatchPerInstanceConfigs(ctx, req) + op, err := c.PatchPerInstanceConfigs(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleRegionInstanceGroupManagersClient_RecreateInstances() { @@ -352,12 +379,15 @@ func ExampleRegionInstanceGroupManagersClient_RecreateInstances() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#RecreateInstancesRegionInstanceGroupManagerRequest. } - resp, err := c.RecreateInstances(ctx, req) + op, err := c.RecreateInstances(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleRegionInstanceGroupManagersClient_Resize() { @@ -372,12 +402,15 @@ func ExampleRegionInstanceGroupManagersClient_Resize() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#ResizeRegionInstanceGroupManagerRequest. } - resp, err := c.Resize(ctx, req) + op, err := c.Resize(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleRegionInstanceGroupManagersClient_SetInstanceTemplate() { @@ -392,12 +425,15 @@ func ExampleRegionInstanceGroupManagersClient_SetInstanceTemplate() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#SetInstanceTemplateRegionInstanceGroupManagerRequest. } - resp, err := c.SetInstanceTemplate(ctx, req) + op, err := c.SetInstanceTemplate(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleRegionInstanceGroupManagersClient_SetTargetPools() { @@ -412,12 +448,15 @@ func ExampleRegionInstanceGroupManagersClient_SetTargetPools() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#SetTargetPoolsRegionInstanceGroupManagerRequest. } - resp, err := c.SetTargetPools(ctx, req) + op, err := c.SetTargetPools(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleRegionInstanceGroupManagersClient_UpdatePerInstanceConfigs() { @@ -432,10 +471,13 @@ func ExampleRegionInstanceGroupManagersClient_UpdatePerInstanceConfigs() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#UpdatePerInstanceConfigsRegionInstanceGroupManagerRequest. } - resp, err := c.UpdatePerInstanceConfigs(ctx, req) + op, err := c.UpdatePerInstanceConfigs(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } diff --git a/compute/apiv1/region_instance_groups_client.go b/compute/apiv1/region_instance_groups_client.go index c4434f19d39..f74f9f6331b 100644 --- a/compute/apiv1/region_instance_groups_client.go +++ b/compute/apiv1/region_instance_groups_client.go @@ -121,6 +121,9 @@ type regionInstanceGroupsRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *RegionOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -141,6 +144,16 @@ func NewRegionInstanceGroupsRESTClient(ctx context.Context, opts ...option.Clien } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewRegionOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &RegionInstanceGroupsClient{internalClient: c, CallOptions: &RegionInstanceGroupsCallOptions{}}, nil } @@ -167,6 +180,9 @@ func (c *regionInstanceGroupsRESTClient) setGoogleClientInfo(keyval ...string) { func (c *regionInstanceGroupsRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -462,6 +478,13 @@ func (c *regionInstanceGroupsRESTClient) SetNamedPorts(ctx context.Context, req if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } diff --git a/compute/apiv1/region_instance_groups_client_example_test.go b/compute/apiv1/region_instance_groups_client_example_test.go index f7c9b3165e0..f2e1b8f144b 100644 --- a/compute/apiv1/region_instance_groups_client_example_test.go +++ b/compute/apiv1/region_instance_groups_client_example_test.go @@ -120,10 +120,13 @@ func ExampleRegionInstanceGroupsClient_SetNamedPorts() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#SetNamedPortsRegionInstanceGroupRequest. } - resp, err := c.SetNamedPorts(ctx, req) + op, err := c.SetNamedPorts(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } diff --git a/compute/apiv1/region_instances_client.go b/compute/apiv1/region_instances_client.go index e2665e63bf1..a2dc639d5ed 100644 --- a/compute/apiv1/region_instances_client.go +++ b/compute/apiv1/region_instances_client.go @@ -97,6 +97,9 @@ type regionInstancesRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *RegionOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -117,6 +120,16 @@ func NewRegionInstancesRESTClient(ctx context.Context, opts ...option.ClientOpti } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewRegionOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &RegionInstancesClient{internalClient: c, CallOptions: &RegionInstancesCallOptions{}}, nil } @@ -143,6 +156,9 @@ func (c *regionInstancesRESTClient) setGoogleClientInfo(keyval ...string) { func (c *regionInstancesRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -208,6 +224,13 @@ func (c *regionInstancesRESTClient) BulkInsert(ctx context.Context, req *compute if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } diff --git a/compute/apiv1/region_instances_client_example_test.go b/compute/apiv1/region_instances_client_example_test.go index d8496d687e2..61baa64c6af 100644 --- a/compute/apiv1/region_instances_client_example_test.go +++ b/compute/apiv1/region_instances_client_example_test.go @@ -47,10 +47,13 @@ func ExampleRegionInstancesClient_BulkInsert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#BulkInsertRegionInstanceRequest. } - resp, err := c.BulkInsert(ctx, req) + op, err := c.BulkInsert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } diff --git a/compute/apiv1/region_network_endpoint_groups_client.go b/compute/apiv1/region_network_endpoint_groups_client.go index 79a2c5cb9d0..663361b5b9d 100644 --- a/compute/apiv1/region_network_endpoint_groups_client.go +++ b/compute/apiv1/region_network_endpoint_groups_client.go @@ -121,6 +121,9 @@ type regionNetworkEndpointGroupsRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *RegionOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -141,6 +144,16 @@ func NewRegionNetworkEndpointGroupsRESTClient(ctx context.Context, opts ...optio } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewRegionOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &RegionNetworkEndpointGroupsClient{internalClient: c, CallOptions: &RegionNetworkEndpointGroupsCallOptions{}}, nil } @@ -167,6 +180,9 @@ func (c *regionNetworkEndpointGroupsRESTClient) setGoogleClientInfo(keyval ...st func (c *regionNetworkEndpointGroupsRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -225,7 +241,14 @@ func (c *regionNetworkEndpointGroupsRESTClient) Delete(ctx context.Context, req if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -328,7 +351,14 @@ func (c *regionNetworkEndpointGroupsRESTClient) Insert(ctx context.Context, req if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } diff --git a/compute/apiv1/region_network_endpoint_groups_client_example_test.go b/compute/apiv1/region_network_endpoint_groups_client_example_test.go index 02e9f1ac56b..3d00aea023c 100644 --- a/compute/apiv1/region_network_endpoint_groups_client_example_test.go +++ b/compute/apiv1/region_network_endpoint_groups_client_example_test.go @@ -48,12 +48,15 @@ func ExampleRegionNetworkEndpointGroupsClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteRegionNetworkEndpointGroupRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleRegionNetworkEndpointGroupsClient_Get() { @@ -88,12 +91,15 @@ func ExampleRegionNetworkEndpointGroupsClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertRegionNetworkEndpointGroupRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleRegionNetworkEndpointGroupsClient_List() { diff --git a/compute/apiv1/region_notification_endpoints_client.go b/compute/apiv1/region_notification_endpoints_client.go index d4488b722f7..54ba6bd933c 100644 --- a/compute/apiv1/region_notification_endpoints_client.go +++ b/compute/apiv1/region_notification_endpoints_client.go @@ -121,6 +121,9 @@ type regionNotificationEndpointsRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *RegionOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -141,6 +144,16 @@ func NewRegionNotificationEndpointsRESTClient(ctx context.Context, opts ...optio } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewRegionOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &RegionNotificationEndpointsClient{internalClient: c, CallOptions: &RegionNotificationEndpointsCallOptions{}}, nil } @@ -167,6 +180,9 @@ func (c *regionNotificationEndpointsRESTClient) setGoogleClientInfo(keyval ...st func (c *regionNotificationEndpointsRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -225,7 +241,14 @@ func (c *regionNotificationEndpointsRESTClient) Delete(ctx context.Context, req if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -328,7 +351,14 @@ func (c *regionNotificationEndpointsRESTClient) Insert(ctx context.Context, req if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } diff --git a/compute/apiv1/region_notification_endpoints_client_example_test.go b/compute/apiv1/region_notification_endpoints_client_example_test.go index d75d607168d..b382c5e4053 100644 --- a/compute/apiv1/region_notification_endpoints_client_example_test.go +++ b/compute/apiv1/region_notification_endpoints_client_example_test.go @@ -48,12 +48,15 @@ func ExampleRegionNotificationEndpointsClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteRegionNotificationEndpointRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleRegionNotificationEndpointsClient_Get() { @@ -88,12 +91,15 @@ func ExampleRegionNotificationEndpointsClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertRegionNotificationEndpointRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleRegionNotificationEndpointsClient_List() { diff --git a/compute/apiv1/region_ssl_certificates_client.go b/compute/apiv1/region_ssl_certificates_client.go index 09574f797a2..843be476e68 100644 --- a/compute/apiv1/region_ssl_certificates_client.go +++ b/compute/apiv1/region_ssl_certificates_client.go @@ -121,6 +121,9 @@ type regionSslCertificatesRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *RegionOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -141,6 +144,16 @@ func NewRegionSslCertificatesRESTClient(ctx context.Context, opts ...option.Clie } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewRegionOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &RegionSslCertificatesClient{internalClient: c, CallOptions: &RegionSslCertificatesCallOptions{}}, nil } @@ -167,6 +180,9 @@ func (c *regionSslCertificatesRESTClient) setGoogleClientInfo(keyval ...string) func (c *regionSslCertificatesRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -225,7 +241,14 @@ func (c *regionSslCertificatesRESTClient) Delete(ctx context.Context, req *compu if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -328,7 +351,14 @@ func (c *regionSslCertificatesRESTClient) Insert(ctx context.Context, req *compu if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } diff --git a/compute/apiv1/region_ssl_certificates_client_example_test.go b/compute/apiv1/region_ssl_certificates_client_example_test.go index aef06b0fcbe..3d90f002e6d 100644 --- a/compute/apiv1/region_ssl_certificates_client_example_test.go +++ b/compute/apiv1/region_ssl_certificates_client_example_test.go @@ -48,12 +48,15 @@ func ExampleRegionSslCertificatesClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteRegionSslCertificateRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleRegionSslCertificatesClient_Get() { @@ -88,12 +91,15 @@ func ExampleRegionSslCertificatesClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertRegionSslCertificateRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleRegionSslCertificatesClient_List() { diff --git a/compute/apiv1/region_target_http_proxies_client.go b/compute/apiv1/region_target_http_proxies_client.go index b2b58022df3..87372515ed2 100644 --- a/compute/apiv1/region_target_http_proxies_client.go +++ b/compute/apiv1/region_target_http_proxies_client.go @@ -128,6 +128,9 @@ type regionTargetHttpProxiesRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *RegionOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -148,6 +151,16 @@ func NewRegionTargetHttpProxiesRESTClient(ctx context.Context, opts ...option.Cl } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewRegionOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &RegionTargetHttpProxiesClient{internalClient: c, CallOptions: &RegionTargetHttpProxiesCallOptions{}}, nil } @@ -174,6 +187,9 @@ func (c *regionTargetHttpProxiesRESTClient) setGoogleClientInfo(keyval ...string func (c *regionTargetHttpProxiesRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -232,7 +248,14 @@ func (c *regionTargetHttpProxiesRESTClient) Delete(ctx context.Context, req *com if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -335,7 +358,14 @@ func (c *regionTargetHttpProxiesRESTClient) Insert(ctx context.Context, req *com if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -484,7 +514,14 @@ func (c *regionTargetHttpProxiesRESTClient) SetUrlMap(ctx context.Context, req * if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } diff --git a/compute/apiv1/region_target_http_proxies_client_example_test.go b/compute/apiv1/region_target_http_proxies_client_example_test.go index 6cafaef3596..7551c3a5b3d 100644 --- a/compute/apiv1/region_target_http_proxies_client_example_test.go +++ b/compute/apiv1/region_target_http_proxies_client_example_test.go @@ -48,12 +48,15 @@ func ExampleRegionTargetHttpProxiesClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteRegionTargetHttpProxyRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleRegionTargetHttpProxiesClient_Get() { @@ -88,12 +91,15 @@ func ExampleRegionTargetHttpProxiesClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertRegionTargetHttpProxyRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleRegionTargetHttpProxiesClient_List() { @@ -134,10 +140,13 @@ func ExampleRegionTargetHttpProxiesClient_SetUrlMap() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#SetUrlMapRegionTargetHttpProxyRequest. } - resp, err := c.SetUrlMap(ctx, req) + op, err := c.SetUrlMap(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } diff --git a/compute/apiv1/region_target_https_proxies_client.go b/compute/apiv1/region_target_https_proxies_client.go index 9becf808794..70a4d05fb0d 100644 --- a/compute/apiv1/region_target_https_proxies_client.go +++ b/compute/apiv1/region_target_https_proxies_client.go @@ -135,6 +135,9 @@ type regionTargetHttpsProxiesRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *RegionOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -155,6 +158,16 @@ func NewRegionTargetHttpsProxiesRESTClient(ctx context.Context, opts ...option.C } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewRegionOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &RegionTargetHttpsProxiesClient{internalClient: c, CallOptions: &RegionTargetHttpsProxiesCallOptions{}}, nil } @@ -181,6 +194,9 @@ func (c *regionTargetHttpsProxiesRESTClient) setGoogleClientInfo(keyval ...strin func (c *regionTargetHttpsProxiesRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -239,7 +255,14 @@ func (c *regionTargetHttpsProxiesRESTClient) Delete(ctx context.Context, req *co if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -342,7 +365,14 @@ func (c *regionTargetHttpsProxiesRESTClient) Insert(ctx context.Context, req *co if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -491,7 +521,14 @@ func (c *regionTargetHttpsProxiesRESTClient) SetSslCertificates(ctx context.Cont if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -550,7 +587,14 @@ func (c *regionTargetHttpsProxiesRESTClient) SetUrlMap(ctx context.Context, req if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } diff --git a/compute/apiv1/region_target_https_proxies_client_example_test.go b/compute/apiv1/region_target_https_proxies_client_example_test.go index 8b79b1b5f35..a679eea2b52 100644 --- a/compute/apiv1/region_target_https_proxies_client_example_test.go +++ b/compute/apiv1/region_target_https_proxies_client_example_test.go @@ -48,12 +48,15 @@ func ExampleRegionTargetHttpsProxiesClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteRegionTargetHttpsProxyRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleRegionTargetHttpsProxiesClient_Get() { @@ -88,12 +91,15 @@ func ExampleRegionTargetHttpsProxiesClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertRegionTargetHttpsProxyRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleRegionTargetHttpsProxiesClient_List() { @@ -134,12 +140,15 @@ func ExampleRegionTargetHttpsProxiesClient_SetSslCertificates() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#SetSslCertificatesRegionTargetHttpsProxyRequest. } - resp, err := c.SetSslCertificates(ctx, req) + op, err := c.SetSslCertificates(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleRegionTargetHttpsProxiesClient_SetUrlMap() { @@ -154,10 +163,13 @@ func ExampleRegionTargetHttpsProxiesClient_SetUrlMap() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#SetUrlMapRegionTargetHttpsProxyRequest. } - resp, err := c.SetUrlMap(ctx, req) + op, err := c.SetUrlMap(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } diff --git a/compute/apiv1/region_url_maps_client.go b/compute/apiv1/region_url_maps_client.go index 9fb2e87cd1f..5b81a94e1e1 100644 --- a/compute/apiv1/region_url_maps_client.go +++ b/compute/apiv1/region_url_maps_client.go @@ -142,6 +142,9 @@ type regionUrlMapsRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *RegionOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -162,6 +165,16 @@ func NewRegionUrlMapsRESTClient(ctx context.Context, opts ...option.ClientOption } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewRegionOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &RegionUrlMapsClient{internalClient: c, CallOptions: &RegionUrlMapsCallOptions{}}, nil } @@ -188,6 +201,9 @@ func (c *regionUrlMapsRESTClient) setGoogleClientInfo(keyval ...string) { func (c *regionUrlMapsRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -246,7 +262,14 @@ func (c *regionUrlMapsRESTClient) Delete(ctx context.Context, req *computepb.Del if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -349,7 +372,14 @@ func (c *regionUrlMapsRESTClient) Insert(ctx context.Context, req *computepb.Ins if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -498,7 +528,14 @@ func (c *regionUrlMapsRESTClient) Patch(ctx context.Context, req *computepb.Patc if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -557,7 +594,14 @@ func (c *regionUrlMapsRESTClient) Update(ctx context.Context, req *computepb.Upd if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } diff --git a/compute/apiv1/region_url_maps_client_example_test.go b/compute/apiv1/region_url_maps_client_example_test.go index 0d548333cbe..683370d37fe 100644 --- a/compute/apiv1/region_url_maps_client_example_test.go +++ b/compute/apiv1/region_url_maps_client_example_test.go @@ -48,12 +48,15 @@ func ExampleRegionUrlMapsClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteRegionUrlMapRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleRegionUrlMapsClient_Get() { @@ -88,12 +91,15 @@ func ExampleRegionUrlMapsClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertRegionUrlMapRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleRegionUrlMapsClient_List() { @@ -134,12 +140,15 @@ func ExampleRegionUrlMapsClient_Patch() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#PatchRegionUrlMapRequest. } - resp, err := c.Patch(ctx, req) + op, err := c.Patch(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleRegionUrlMapsClient_Update() { @@ -154,12 +163,15 @@ func ExampleRegionUrlMapsClient_Update() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#UpdateRegionUrlMapRequest. } - resp, err := c.Update(ctx, req) + op, err := c.Update(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleRegionUrlMapsClient_Validate() { diff --git a/compute/apiv1/reservations_client.go b/compute/apiv1/reservations_client.go index a2a6b8a4425..00a2acaf4a5 100644 --- a/compute/apiv1/reservations_client.go +++ b/compute/apiv1/reservations_client.go @@ -157,6 +157,9 @@ type reservationsRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *ZoneOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -177,6 +180,16 @@ func NewReservationsRESTClient(ctx context.Context, opts ...option.ClientOption) } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewZoneOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &ReservationsClient{internalClient: c, CallOptions: &ReservationsCallOptions{}}, nil } @@ -203,6 +216,9 @@ func (c *reservationsRESTClient) setGoogleClientInfo(keyval ...string) { func (c *reservationsRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -361,7 +377,14 @@ func (c *reservationsRESTClient) Delete(ctx context.Context, req *computepb.Dele if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -515,7 +538,14 @@ func (c *reservationsRESTClient) Insert(ctx context.Context, req *computepb.Inse if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -664,7 +694,14 @@ func (c *reservationsRESTClient) Resize(ctx context.Context, req *computepb.Resi if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } diff --git a/compute/apiv1/reservations_client_example_test.go b/compute/apiv1/reservations_client_example_test.go index 8cadb0f37a4..89a78d5c256 100644 --- a/compute/apiv1/reservations_client_example_test.go +++ b/compute/apiv1/reservations_client_example_test.go @@ -74,12 +74,15 @@ func ExampleReservationsClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteReservationRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleReservationsClient_Get() { @@ -134,12 +137,15 @@ func ExampleReservationsClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertReservationRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleReservationsClient_List() { @@ -180,12 +186,15 @@ func ExampleReservationsClient_Resize() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#ResizeReservationRequest. } - resp, err := c.Resize(ctx, req) + op, err := c.Resize(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleReservationsClient_SetIamPolicy() { diff --git a/compute/apiv1/resource_policies_client.go b/compute/apiv1/resource_policies_client.go index 49121cedf15..de52267cd55 100644 --- a/compute/apiv1/resource_policies_client.go +++ b/compute/apiv1/resource_policies_client.go @@ -150,6 +150,9 @@ type resourcePoliciesRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *RegionOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -170,6 +173,16 @@ func NewResourcePoliciesRESTClient(ctx context.Context, opts ...option.ClientOpt } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewRegionOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &ResourcePoliciesClient{internalClient: c, CallOptions: &ResourcePoliciesCallOptions{}}, nil } @@ -196,6 +209,9 @@ func (c *resourcePoliciesRESTClient) setGoogleClientInfo(keyval ...string) { func (c *resourcePoliciesRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -354,7 +370,14 @@ func (c *resourcePoliciesRESTClient) Delete(ctx context.Context, req *computepb. if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -508,7 +531,14 @@ func (c *resourcePoliciesRESTClient) Insert(ctx context.Context, req *computepb. if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } diff --git a/compute/apiv1/resource_policies_client_example_test.go b/compute/apiv1/resource_policies_client_example_test.go index d26c696fd91..7f183618a61 100644 --- a/compute/apiv1/resource_policies_client_example_test.go +++ b/compute/apiv1/resource_policies_client_example_test.go @@ -74,12 +74,15 @@ func ExampleResourcePoliciesClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteResourcePolicyRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleResourcePoliciesClient_Get() { @@ -134,12 +137,15 @@ func ExampleResourcePoliciesClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertResourcePolicyRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleResourcePoliciesClient_List() { diff --git a/compute/apiv1/routers_client.go b/compute/apiv1/routers_client.go index ab43fbe1561..ae93ab26833 100644 --- a/compute/apiv1/routers_client.go +++ b/compute/apiv1/routers_client.go @@ -164,6 +164,9 @@ type routersRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *RegionOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -184,6 +187,16 @@ func NewRoutersRESTClient(ctx context.Context, opts ...option.ClientOption) (*Ro } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewRegionOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &RoutersClient{internalClient: c, CallOptions: &RoutersCallOptions{}}, nil } @@ -210,6 +223,9 @@ func (c *routersRESTClient) setGoogleClientInfo(keyval ...string) { func (c *routersRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -368,7 +384,14 @@ func (c *routersRESTClient) Delete(ctx context.Context, req *computepb.DeleteRou if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -605,7 +628,14 @@ func (c *routersRESTClient) Insert(ctx context.Context, req *computepb.InsertRou if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -754,7 +784,14 @@ func (c *routersRESTClient) Patch(ctx context.Context, req *computepb.PatchRoute if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -864,7 +901,14 @@ func (c *routersRESTClient) Update(ctx context.Context, req *computepb.UpdateRou if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } diff --git a/compute/apiv1/routers_client_example_test.go b/compute/apiv1/routers_client_example_test.go index 1fb42661fa3..0c0bf657dcc 100644 --- a/compute/apiv1/routers_client_example_test.go +++ b/compute/apiv1/routers_client_example_test.go @@ -74,12 +74,15 @@ func ExampleRoutersClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteRouterRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleRoutersClient_Get() { @@ -160,12 +163,15 @@ func ExampleRoutersClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertRouterRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleRoutersClient_List() { @@ -206,12 +212,15 @@ func ExampleRoutersClient_Patch() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#PatchRouterRequest. } - resp, err := c.Patch(ctx, req) + op, err := c.Patch(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleRoutersClient_Preview() { @@ -246,10 +255,13 @@ func ExampleRoutersClient_Update() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#UpdateRouterRequest. } - resp, err := c.Update(ctx, req) + op, err := c.Update(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } diff --git a/compute/apiv1/routes_client.go b/compute/apiv1/routes_client.go index d3c1e115798..4155a3825d4 100644 --- a/compute/apiv1/routes_client.go +++ b/compute/apiv1/routes_client.go @@ -121,6 +121,9 @@ type routesRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *GlobalOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -141,6 +144,16 @@ func NewRoutesRESTClient(ctx context.Context, opts ...option.ClientOption) (*Rou } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewGlobalOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &RoutesClient{internalClient: c, CallOptions: &RoutesCallOptions{}}, nil } @@ -167,6 +180,9 @@ func (c *routesRESTClient) setGoogleClientInfo(keyval ...string) { func (c *routesRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -225,7 +241,13 @@ func (c *routesRESTClient) Delete(ctx context.Context, req *computepb.DeleteRout if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -328,7 +350,13 @@ func (c *routesRESTClient) Insert(ctx context.Context, req *computepb.InsertRout if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } diff --git a/compute/apiv1/routes_client_example_test.go b/compute/apiv1/routes_client_example_test.go index a2e89c069f3..b8ed6e4975a 100644 --- a/compute/apiv1/routes_client_example_test.go +++ b/compute/apiv1/routes_client_example_test.go @@ -48,12 +48,15 @@ func ExampleRoutesClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteRouteRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleRoutesClient_Get() { @@ -88,12 +91,15 @@ func ExampleRoutesClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertRouteRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleRoutesClient_List() { diff --git a/compute/apiv1/security_policies_client.go b/compute/apiv1/security_policies_client.go index de934a8d828..0b8a11d4409 100644 --- a/compute/apiv1/security_policies_client.go +++ b/compute/apiv1/security_policies_client.go @@ -163,6 +163,9 @@ type securityPoliciesRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *GlobalOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -183,6 +186,16 @@ func NewSecurityPoliciesRESTClient(ctx context.Context, opts ...option.ClientOpt } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewGlobalOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &SecurityPoliciesClient{internalClient: c, CallOptions: &SecurityPoliciesCallOptions{}}, nil } @@ -209,6 +222,9 @@ func (c *securityPoliciesRESTClient) setGoogleClientInfo(keyval ...string) { func (c *securityPoliciesRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -267,7 +283,13 @@ func (c *securityPoliciesRESTClient) AddRule(ctx context.Context, req *computepb if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -319,7 +341,13 @@ func (c *securityPoliciesRESTClient) Delete(ctx context.Context, req *computepb. if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -473,7 +501,13 @@ func (c *securityPoliciesRESTClient) Insert(ctx context.Context, req *computepb. if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -685,7 +719,13 @@ func (c *securityPoliciesRESTClient) Patch(ctx context.Context, req *computepb.P if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -744,7 +784,13 @@ func (c *securityPoliciesRESTClient) PatchRule(ctx context.Context, req *compute if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -796,7 +842,13 @@ func (c *securityPoliciesRESTClient) RemoveRule(ctx context.Context, req *comput if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } diff --git a/compute/apiv1/security_policies_client_example_test.go b/compute/apiv1/security_policies_client_example_test.go index 79168ff0e53..022901f93f9 100644 --- a/compute/apiv1/security_policies_client_example_test.go +++ b/compute/apiv1/security_policies_client_example_test.go @@ -48,12 +48,15 @@ func ExampleSecurityPoliciesClient_AddRule() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#AddRuleSecurityPolicyRequest. } - resp, err := c.AddRule(ctx, req) + op, err := c.AddRule(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleSecurityPoliciesClient_Delete() { @@ -68,12 +71,15 @@ func ExampleSecurityPoliciesClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteSecurityPolicyRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleSecurityPoliciesClient_Get() { @@ -128,12 +134,15 @@ func ExampleSecurityPoliciesClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertSecurityPolicyRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleSecurityPoliciesClient_List() { @@ -194,12 +203,15 @@ func ExampleSecurityPoliciesClient_Patch() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#PatchSecurityPolicyRequest. } - resp, err := c.Patch(ctx, req) + op, err := c.Patch(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleSecurityPoliciesClient_PatchRule() { @@ -214,12 +226,15 @@ func ExampleSecurityPoliciesClient_PatchRule() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#PatchRuleSecurityPolicyRequest. } - resp, err := c.PatchRule(ctx, req) + op, err := c.PatchRule(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleSecurityPoliciesClient_RemoveRule() { @@ -234,10 +249,13 @@ func ExampleSecurityPoliciesClient_RemoveRule() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#RemoveRuleSecurityPolicyRequest. } - resp, err := c.RemoveRule(ctx, req) + op, err := c.RemoveRule(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } diff --git a/compute/apiv1/service_attachments_client.go b/compute/apiv1/service_attachments_client.go index a112c0baf2e..4de77dd2234 100644 --- a/compute/apiv1/service_attachments_client.go +++ b/compute/apiv1/service_attachments_client.go @@ -157,6 +157,9 @@ type serviceAttachmentsRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *RegionOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -177,6 +180,16 @@ func NewServiceAttachmentsRESTClient(ctx context.Context, opts ...option.ClientO } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewRegionOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &ServiceAttachmentsClient{internalClient: c, CallOptions: &ServiceAttachmentsCallOptions{}}, nil } @@ -203,6 +216,9 @@ func (c *serviceAttachmentsRESTClient) setGoogleClientInfo(keyval ...string) { func (c *serviceAttachmentsRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -361,7 +377,14 @@ func (c *serviceAttachmentsRESTClient) Delete(ctx context.Context, req *computep if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -515,7 +538,14 @@ func (c *serviceAttachmentsRESTClient) Insert(ctx context.Context, req *computep if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -664,7 +694,14 @@ func (c *serviceAttachmentsRESTClient) Patch(ctx context.Context, req *computepb if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } diff --git a/compute/apiv1/service_attachments_client_example_test.go b/compute/apiv1/service_attachments_client_example_test.go index 56a77bebcfd..d2a1a92f09b 100644 --- a/compute/apiv1/service_attachments_client_example_test.go +++ b/compute/apiv1/service_attachments_client_example_test.go @@ -74,12 +74,15 @@ func ExampleServiceAttachmentsClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteServiceAttachmentRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleServiceAttachmentsClient_Get() { @@ -134,12 +137,15 @@ func ExampleServiceAttachmentsClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertServiceAttachmentRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleServiceAttachmentsClient_List() { @@ -180,12 +186,15 @@ func ExampleServiceAttachmentsClient_Patch() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#PatchServiceAttachmentRequest. } - resp, err := c.Patch(ctx, req) + op, err := c.Patch(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleServiceAttachmentsClient_SetIamPolicy() { diff --git a/compute/apiv1/snapshots_client.go b/compute/apiv1/snapshots_client.go index f71b3a7c0b5..b4aa951902b 100644 --- a/compute/apiv1/snapshots_client.go +++ b/compute/apiv1/snapshots_client.go @@ -142,6 +142,9 @@ type snapshotsRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *GlobalOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -162,6 +165,16 @@ func NewSnapshotsRESTClient(ctx context.Context, opts ...option.ClientOption) (* } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewGlobalOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &SnapshotsClient{internalClient: c, CallOptions: &SnapshotsCallOptions{}}, nil } @@ -188,6 +201,9 @@ func (c *snapshotsRESTClient) setGoogleClientInfo(keyval ...string) { func (c *snapshotsRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -246,7 +262,13 @@ func (c *snapshotsRESTClient) Delete(ctx context.Context, req *computepb.DeleteS if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -534,7 +556,13 @@ func (c *snapshotsRESTClient) SetLabels(ctx context.Context, req *computepb.SetL if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } diff --git a/compute/apiv1/snapshots_client_example_test.go b/compute/apiv1/snapshots_client_example_test.go index 2668d3dd17a..36647081345 100644 --- a/compute/apiv1/snapshots_client_example_test.go +++ b/compute/apiv1/snapshots_client_example_test.go @@ -48,12 +48,15 @@ func ExampleSnapshotsClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteSnapshotRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleSnapshotsClient_Get() { @@ -154,12 +157,15 @@ func ExampleSnapshotsClient_SetLabels() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#SetLabelsSnapshotRequest. } - resp, err := c.SetLabels(ctx, req) + op, err := c.SetLabels(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleSnapshotsClient_TestIamPermissions() { diff --git a/compute/apiv1/ssl_certificates_client.go b/compute/apiv1/ssl_certificates_client.go index 36e8ac017a2..6ba4485d920 100644 --- a/compute/apiv1/ssl_certificates_client.go +++ b/compute/apiv1/ssl_certificates_client.go @@ -129,6 +129,9 @@ type sslCertificatesRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *GlobalOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -149,6 +152,16 @@ func NewSslCertificatesRESTClient(ctx context.Context, opts ...option.ClientOpti } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewGlobalOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &SslCertificatesClient{internalClient: c, CallOptions: &SslCertificatesCallOptions{}}, nil } @@ -175,6 +188,9 @@ func (c *sslCertificatesRESTClient) setGoogleClientInfo(keyval ...string) { func (c *sslCertificatesRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -333,7 +349,13 @@ func (c *sslCertificatesRESTClient) Delete(ctx context.Context, req *computepb.D if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -436,7 +458,13 @@ func (c *sslCertificatesRESTClient) Insert(ctx context.Context, req *computepb.I if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } diff --git a/compute/apiv1/ssl_certificates_client_example_test.go b/compute/apiv1/ssl_certificates_client_example_test.go index 272fc57d874..2c63170bc48 100644 --- a/compute/apiv1/ssl_certificates_client_example_test.go +++ b/compute/apiv1/ssl_certificates_client_example_test.go @@ -74,12 +74,15 @@ func ExampleSslCertificatesClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteSslCertificateRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleSslCertificatesClient_Get() { @@ -114,12 +117,15 @@ func ExampleSslCertificatesClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertSslCertificateRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleSslCertificatesClient_List() { diff --git a/compute/apiv1/ssl_policies_client.go b/compute/apiv1/ssl_policies_client.go index 290aac8766f..b67de3fb3b6 100644 --- a/compute/apiv1/ssl_policies_client.go +++ b/compute/apiv1/ssl_policies_client.go @@ -135,6 +135,9 @@ type sslPoliciesRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *GlobalOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -155,6 +158,16 @@ func NewSslPoliciesRESTClient(ctx context.Context, opts ...option.ClientOption) } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewGlobalOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &SslPoliciesClient{internalClient: c, CallOptions: &SslPoliciesCallOptions{}}, nil } @@ -181,6 +194,9 @@ func (c *sslPoliciesRESTClient) setGoogleClientInfo(keyval ...string) { func (c *sslPoliciesRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -239,7 +255,13 @@ func (c *sslPoliciesRESTClient) Delete(ctx context.Context, req *computepb.Delet if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -342,7 +364,13 @@ func (c *sslPoliciesRESTClient) Insert(ctx context.Context, req *computepb.Inser if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -554,7 +582,13 @@ func (c *sslPoliciesRESTClient) Patch(ctx context.Context, req *computepb.PatchS if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } diff --git a/compute/apiv1/ssl_policies_client_example_test.go b/compute/apiv1/ssl_policies_client_example_test.go index fc3f1009aed..f6f8d187e84 100644 --- a/compute/apiv1/ssl_policies_client_example_test.go +++ b/compute/apiv1/ssl_policies_client_example_test.go @@ -48,12 +48,15 @@ func ExampleSslPoliciesClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteSslPolicyRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleSslPoliciesClient_Get() { @@ -88,12 +91,15 @@ func ExampleSslPoliciesClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertSslPolicyRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleSslPoliciesClient_List() { @@ -154,10 +160,13 @@ func ExampleSslPoliciesClient_Patch() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#PatchSslPolicyRequest. } - resp, err := c.Patch(ctx, req) + op, err := c.Patch(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } diff --git a/compute/apiv1/subnetworks_client.go b/compute/apiv1/subnetworks_client.go index 7db896ecb33..79945e0f3b2 100644 --- a/compute/apiv1/subnetworks_client.go +++ b/compute/apiv1/subnetworks_client.go @@ -178,6 +178,9 @@ type subnetworksRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *RegionOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -198,6 +201,16 @@ func NewSubnetworksRESTClient(ctx context.Context, opts ...option.ClientOption) } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewRegionOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &SubnetworksClient{internalClient: c, CallOptions: &SubnetworksCallOptions{}}, nil } @@ -224,6 +237,9 @@ func (c *subnetworksRESTClient) setGoogleClientInfo(keyval ...string) { func (c *subnetworksRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -382,7 +398,14 @@ func (c *subnetworksRESTClient) Delete(ctx context.Context, req *computepb.Delet if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -441,7 +464,14 @@ func (c *subnetworksRESTClient) ExpandIpCidrRange(ctx context.Context, req *comp if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -595,7 +625,14 @@ func (c *subnetworksRESTClient) Insert(ctx context.Context, req *computepb.Inser if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -837,7 +874,14 @@ func (c *subnetworksRESTClient) Patch(ctx context.Context, req *computepb.PatchS if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -947,7 +991,14 @@ func (c *subnetworksRESTClient) SetPrivateIpGoogleAccess(ctx context.Context, re if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } diff --git a/compute/apiv1/subnetworks_client_example_test.go b/compute/apiv1/subnetworks_client_example_test.go index 42e0487a318..dddcd2a0804 100644 --- a/compute/apiv1/subnetworks_client_example_test.go +++ b/compute/apiv1/subnetworks_client_example_test.go @@ -74,12 +74,15 @@ func ExampleSubnetworksClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteSubnetworkRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleSubnetworksClient_ExpandIpCidrRange() { @@ -94,12 +97,15 @@ func ExampleSubnetworksClient_ExpandIpCidrRange() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#ExpandIpCidrRangeSubnetworkRequest. } - resp, err := c.ExpandIpCidrRange(ctx, req) + op, err := c.ExpandIpCidrRange(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleSubnetworksClient_Get() { @@ -154,12 +160,15 @@ func ExampleSubnetworksClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertSubnetworkRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleSubnetworksClient_List() { @@ -226,12 +235,15 @@ func ExampleSubnetworksClient_Patch() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#PatchSubnetworkRequest. } - resp, err := c.Patch(ctx, req) + op, err := c.Patch(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleSubnetworksClient_SetIamPolicy() { @@ -266,12 +278,15 @@ func ExampleSubnetworksClient_SetPrivateIpGoogleAccess() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#SetPrivateIpGoogleAccessSubnetworkRequest. } - resp, err := c.SetPrivateIpGoogleAccess(ctx, req) + op, err := c.SetPrivateIpGoogleAccess(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleSubnetworksClient_TestIamPermissions() { diff --git a/compute/apiv1/target_grpc_proxies_client.go b/compute/apiv1/target_grpc_proxies_client.go index 2cd1aaf6884..018cb6ad392 100644 --- a/compute/apiv1/target_grpc_proxies_client.go +++ b/compute/apiv1/target_grpc_proxies_client.go @@ -128,6 +128,9 @@ type targetGrpcProxiesRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *GlobalOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -148,6 +151,16 @@ func NewTargetGrpcProxiesRESTClient(ctx context.Context, opts ...option.ClientOp } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewGlobalOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &TargetGrpcProxiesClient{internalClient: c, CallOptions: &TargetGrpcProxiesCallOptions{}}, nil } @@ -174,6 +187,9 @@ func (c *targetGrpcProxiesRESTClient) setGoogleClientInfo(keyval ...string) { func (c *targetGrpcProxiesRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -232,7 +248,13 @@ func (c *targetGrpcProxiesRESTClient) Delete(ctx context.Context, req *computepb if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -335,7 +357,13 @@ func (c *targetGrpcProxiesRESTClient) Insert(ctx context.Context, req *computepb if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -484,7 +512,13 @@ func (c *targetGrpcProxiesRESTClient) Patch(ctx context.Context, req *computepb. if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } diff --git a/compute/apiv1/target_grpc_proxies_client_example_test.go b/compute/apiv1/target_grpc_proxies_client_example_test.go index 6144b136705..814d6517118 100644 --- a/compute/apiv1/target_grpc_proxies_client_example_test.go +++ b/compute/apiv1/target_grpc_proxies_client_example_test.go @@ -48,12 +48,15 @@ func ExampleTargetGrpcProxiesClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteTargetGrpcProxyRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleTargetGrpcProxiesClient_Get() { @@ -88,12 +91,15 @@ func ExampleTargetGrpcProxiesClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertTargetGrpcProxyRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleTargetGrpcProxiesClient_List() { @@ -134,10 +140,13 @@ func ExampleTargetGrpcProxiesClient_Patch() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#PatchTargetGrpcProxyRequest. } - resp, err := c.Patch(ctx, req) + op, err := c.Patch(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } diff --git a/compute/apiv1/target_http_proxies_client.go b/compute/apiv1/target_http_proxies_client.go index 9cfc2c2365b..8061c5eddca 100644 --- a/compute/apiv1/target_http_proxies_client.go +++ b/compute/apiv1/target_http_proxies_client.go @@ -143,6 +143,9 @@ type targetHttpProxiesRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *GlobalOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -163,6 +166,16 @@ func NewTargetHttpProxiesRESTClient(ctx context.Context, opts ...option.ClientOp } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewGlobalOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &TargetHttpProxiesClient{internalClient: c, CallOptions: &TargetHttpProxiesCallOptions{}}, nil } @@ -189,6 +202,9 @@ func (c *targetHttpProxiesRESTClient) setGoogleClientInfo(keyval ...string) { func (c *targetHttpProxiesRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -347,7 +363,13 @@ func (c *targetHttpProxiesRESTClient) Delete(ctx context.Context, req *computepb if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -450,7 +472,13 @@ func (c *targetHttpProxiesRESTClient) Insert(ctx context.Context, req *computepb if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -599,7 +627,13 @@ func (c *targetHttpProxiesRESTClient) Patch(ctx context.Context, req *computepb. if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -658,7 +692,13 @@ func (c *targetHttpProxiesRESTClient) SetUrlMap(ctx context.Context, req *comput if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } diff --git a/compute/apiv1/target_http_proxies_client_example_test.go b/compute/apiv1/target_http_proxies_client_example_test.go index 94bf7bab505..c2cd5aa5232 100644 --- a/compute/apiv1/target_http_proxies_client_example_test.go +++ b/compute/apiv1/target_http_proxies_client_example_test.go @@ -74,12 +74,15 @@ func ExampleTargetHttpProxiesClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteTargetHttpProxyRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleTargetHttpProxiesClient_Get() { @@ -114,12 +117,15 @@ func ExampleTargetHttpProxiesClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertTargetHttpProxyRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleTargetHttpProxiesClient_List() { @@ -160,12 +166,15 @@ func ExampleTargetHttpProxiesClient_Patch() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#PatchTargetHttpProxyRequest. } - resp, err := c.Patch(ctx, req) + op, err := c.Patch(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleTargetHttpProxiesClient_SetUrlMap() { @@ -180,10 +189,13 @@ func ExampleTargetHttpProxiesClient_SetUrlMap() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#SetUrlMapTargetHttpProxyRequest. } - resp, err := c.SetUrlMap(ctx, req) + op, err := c.SetUrlMap(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } diff --git a/compute/apiv1/target_https_proxies_client.go b/compute/apiv1/target_https_proxies_client.go index 1717aee9990..01e0488f5c7 100644 --- a/compute/apiv1/target_https_proxies_client.go +++ b/compute/apiv1/target_https_proxies_client.go @@ -164,6 +164,9 @@ type targetHttpsProxiesRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *GlobalOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -184,6 +187,16 @@ func NewTargetHttpsProxiesRESTClient(ctx context.Context, opts ...option.ClientO } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewGlobalOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &TargetHttpsProxiesClient{internalClient: c, CallOptions: &TargetHttpsProxiesCallOptions{}}, nil } @@ -210,6 +223,9 @@ func (c *targetHttpsProxiesRESTClient) setGoogleClientInfo(keyval ...string) { func (c *targetHttpsProxiesRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -368,7 +384,13 @@ func (c *targetHttpsProxiesRESTClient) Delete(ctx context.Context, req *computep if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -471,7 +493,13 @@ func (c *targetHttpsProxiesRESTClient) Insert(ctx context.Context, req *computep if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -620,7 +648,13 @@ func (c *targetHttpsProxiesRESTClient) Patch(ctx context.Context, req *computepb if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -679,7 +713,13 @@ func (c *targetHttpsProxiesRESTClient) SetQuicOverride(ctx context.Context, req if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -738,7 +778,13 @@ func (c *targetHttpsProxiesRESTClient) SetSslCertificates(ctx context.Context, r if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -797,7 +843,13 @@ func (c *targetHttpsProxiesRESTClient) SetSslPolicy(ctx context.Context, req *co if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -856,7 +908,13 @@ func (c *targetHttpsProxiesRESTClient) SetUrlMap(ctx context.Context, req *compu if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } diff --git a/compute/apiv1/target_https_proxies_client_example_test.go b/compute/apiv1/target_https_proxies_client_example_test.go index 0a9301cb34a..1a8b012453e 100644 --- a/compute/apiv1/target_https_proxies_client_example_test.go +++ b/compute/apiv1/target_https_proxies_client_example_test.go @@ -74,12 +74,15 @@ func ExampleTargetHttpsProxiesClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteTargetHttpsProxyRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleTargetHttpsProxiesClient_Get() { @@ -114,12 +117,15 @@ func ExampleTargetHttpsProxiesClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertTargetHttpsProxyRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleTargetHttpsProxiesClient_List() { @@ -160,12 +166,15 @@ func ExampleTargetHttpsProxiesClient_Patch() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#PatchTargetHttpsProxyRequest. } - resp, err := c.Patch(ctx, req) + op, err := c.Patch(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleTargetHttpsProxiesClient_SetQuicOverride() { @@ -180,12 +189,15 @@ func ExampleTargetHttpsProxiesClient_SetQuicOverride() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#SetQuicOverrideTargetHttpsProxyRequest. } - resp, err := c.SetQuicOverride(ctx, req) + op, err := c.SetQuicOverride(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleTargetHttpsProxiesClient_SetSslCertificates() { @@ -200,12 +212,15 @@ func ExampleTargetHttpsProxiesClient_SetSslCertificates() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#SetSslCertificatesTargetHttpsProxyRequest. } - resp, err := c.SetSslCertificates(ctx, req) + op, err := c.SetSslCertificates(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleTargetHttpsProxiesClient_SetSslPolicy() { @@ -220,12 +235,15 @@ func ExampleTargetHttpsProxiesClient_SetSslPolicy() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#SetSslPolicyTargetHttpsProxyRequest. } - resp, err := c.SetSslPolicy(ctx, req) + op, err := c.SetSslPolicy(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleTargetHttpsProxiesClient_SetUrlMap() { @@ -240,10 +258,13 @@ func ExampleTargetHttpsProxiesClient_SetUrlMap() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#SetUrlMapTargetHttpsProxyRequest. } - resp, err := c.SetUrlMap(ctx, req) + op, err := c.SetUrlMap(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } diff --git a/compute/apiv1/target_instances_client.go b/compute/apiv1/target_instances_client.go index ad4d22b94a0..ab61f3e5b15 100644 --- a/compute/apiv1/target_instances_client.go +++ b/compute/apiv1/target_instances_client.go @@ -129,6 +129,9 @@ type targetInstancesRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *ZoneOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -149,6 +152,16 @@ func NewTargetInstancesRESTClient(ctx context.Context, opts ...option.ClientOpti } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewZoneOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &TargetInstancesClient{internalClient: c, CallOptions: &TargetInstancesCallOptions{}}, nil } @@ -175,6 +188,9 @@ func (c *targetInstancesRESTClient) setGoogleClientInfo(keyval ...string) { func (c *targetInstancesRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -333,7 +349,14 @@ func (c *targetInstancesRESTClient) Delete(ctx context.Context, req *computepb.D if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } @@ -436,7 +459,14 @@ func (c *targetInstancesRESTClient) Insert(ctx context.Context, req *computepb.I if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &zoneOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + zone: req.GetZone(), + }, + } return op, nil } diff --git a/compute/apiv1/target_instances_client_example_test.go b/compute/apiv1/target_instances_client_example_test.go index a7ace4839b8..3d132954f60 100644 --- a/compute/apiv1/target_instances_client_example_test.go +++ b/compute/apiv1/target_instances_client_example_test.go @@ -74,12 +74,15 @@ func ExampleTargetInstancesClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteTargetInstanceRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleTargetInstancesClient_Get() { @@ -114,12 +117,15 @@ func ExampleTargetInstancesClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertTargetInstanceRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleTargetInstancesClient_List() { diff --git a/compute/apiv1/target_pools_client.go b/compute/apiv1/target_pools_client.go index d221d1efea9..d38b334f510 100644 --- a/compute/apiv1/target_pools_client.go +++ b/compute/apiv1/target_pools_client.go @@ -171,6 +171,9 @@ type targetPoolsRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *RegionOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -191,6 +194,16 @@ func NewTargetPoolsRESTClient(ctx context.Context, opts ...option.ClientOption) } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewRegionOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &TargetPoolsClient{internalClient: c, CallOptions: &TargetPoolsCallOptions{}}, nil } @@ -217,6 +230,9 @@ func (c *targetPoolsRESTClient) setGoogleClientInfo(keyval ...string) { func (c *targetPoolsRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -282,7 +298,14 @@ func (c *targetPoolsRESTClient) AddHealthCheck(ctx context.Context, req *compute if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -341,7 +364,14 @@ func (c *targetPoolsRESTClient) AddInstance(ctx context.Context, req *computepb. if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -493,7 +523,14 @@ func (c *targetPoolsRESTClient) Delete(ctx context.Context, req *computepb.Delet if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -647,7 +684,14 @@ func (c *targetPoolsRESTClient) Insert(ctx context.Context, req *computepb.Inser if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -796,7 +840,14 @@ func (c *targetPoolsRESTClient) RemoveHealthCheck(ctx context.Context, req *comp if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -855,7 +906,14 @@ func (c *targetPoolsRESTClient) RemoveInstance(ctx context.Context, req *compute if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -917,7 +975,14 @@ func (c *targetPoolsRESTClient) SetBackup(ctx context.Context, req *computepb.Se if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } diff --git a/compute/apiv1/target_pools_client_example_test.go b/compute/apiv1/target_pools_client_example_test.go index 3faeedf4dcb..9c86cbbc52d 100644 --- a/compute/apiv1/target_pools_client_example_test.go +++ b/compute/apiv1/target_pools_client_example_test.go @@ -48,12 +48,15 @@ func ExampleTargetPoolsClient_AddHealthCheck() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#AddHealthCheckTargetPoolRequest. } - resp, err := c.AddHealthCheck(ctx, req) + op, err := c.AddHealthCheck(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleTargetPoolsClient_AddInstance() { @@ -68,12 +71,15 @@ func ExampleTargetPoolsClient_AddInstance() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#AddInstanceTargetPoolRequest. } - resp, err := c.AddInstance(ctx, req) + op, err := c.AddInstance(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleTargetPoolsClient_AggregatedList() { @@ -114,12 +120,15 @@ func ExampleTargetPoolsClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteTargetPoolRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleTargetPoolsClient_Get() { @@ -174,12 +183,15 @@ func ExampleTargetPoolsClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertTargetPoolRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleTargetPoolsClient_List() { @@ -220,12 +232,15 @@ func ExampleTargetPoolsClient_RemoveHealthCheck() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#RemoveHealthCheckTargetPoolRequest. } - resp, err := c.RemoveHealthCheck(ctx, req) + op, err := c.RemoveHealthCheck(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleTargetPoolsClient_RemoveInstance() { @@ -240,12 +255,15 @@ func ExampleTargetPoolsClient_RemoveInstance() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#RemoveInstanceTargetPoolRequest. } - resp, err := c.RemoveInstance(ctx, req) + op, err := c.RemoveInstance(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleTargetPoolsClient_SetBackup() { @@ -260,10 +278,13 @@ func ExampleTargetPoolsClient_SetBackup() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#SetBackupTargetPoolRequest. } - resp, err := c.SetBackup(ctx, req) + op, err := c.SetBackup(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } diff --git a/compute/apiv1/target_ssl_proxies_client.go b/compute/apiv1/target_ssl_proxies_client.go index 974c8abd529..f98f2129b61 100644 --- a/compute/apiv1/target_ssl_proxies_client.go +++ b/compute/apiv1/target_ssl_proxies_client.go @@ -149,6 +149,9 @@ type targetSslProxiesRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *GlobalOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -169,6 +172,16 @@ func NewTargetSslProxiesRESTClient(ctx context.Context, opts ...option.ClientOpt } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewGlobalOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &TargetSslProxiesClient{internalClient: c, CallOptions: &TargetSslProxiesCallOptions{}}, nil } @@ -195,6 +208,9 @@ func (c *targetSslProxiesRESTClient) setGoogleClientInfo(keyval ...string) { func (c *targetSslProxiesRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -253,7 +269,13 @@ func (c *targetSslProxiesRESTClient) Delete(ctx context.Context, req *computepb. if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -356,7 +378,13 @@ func (c *targetSslProxiesRESTClient) Insert(ctx context.Context, req *computepb. if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -505,7 +533,13 @@ func (c *targetSslProxiesRESTClient) SetBackendService(ctx context.Context, req if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -564,7 +598,13 @@ func (c *targetSslProxiesRESTClient) SetProxyHeader(ctx context.Context, req *co if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -623,7 +663,13 @@ func (c *targetSslProxiesRESTClient) SetSslCertificates(ctx context.Context, req if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -682,7 +728,13 @@ func (c *targetSslProxiesRESTClient) SetSslPolicy(ctx context.Context, req *comp if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } diff --git a/compute/apiv1/target_ssl_proxies_client_example_test.go b/compute/apiv1/target_ssl_proxies_client_example_test.go index 3ca34bede0e..44d9a31658c 100644 --- a/compute/apiv1/target_ssl_proxies_client_example_test.go +++ b/compute/apiv1/target_ssl_proxies_client_example_test.go @@ -48,12 +48,15 @@ func ExampleTargetSslProxiesClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteTargetSslProxyRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleTargetSslProxiesClient_Get() { @@ -88,12 +91,15 @@ func ExampleTargetSslProxiesClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertTargetSslProxyRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleTargetSslProxiesClient_List() { @@ -134,12 +140,15 @@ func ExampleTargetSslProxiesClient_SetBackendService() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#SetBackendServiceTargetSslProxyRequest. } - resp, err := c.SetBackendService(ctx, req) + op, err := c.SetBackendService(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleTargetSslProxiesClient_SetProxyHeader() { @@ -154,12 +163,15 @@ func ExampleTargetSslProxiesClient_SetProxyHeader() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#SetProxyHeaderTargetSslProxyRequest. } - resp, err := c.SetProxyHeader(ctx, req) + op, err := c.SetProxyHeader(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleTargetSslProxiesClient_SetSslCertificates() { @@ -174,12 +186,15 @@ func ExampleTargetSslProxiesClient_SetSslCertificates() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#SetSslCertificatesTargetSslProxyRequest. } - resp, err := c.SetSslCertificates(ctx, req) + op, err := c.SetSslCertificates(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleTargetSslProxiesClient_SetSslPolicy() { @@ -194,10 +209,13 @@ func ExampleTargetSslProxiesClient_SetSslPolicy() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#SetSslPolicyTargetSslProxyRequest. } - resp, err := c.SetSslPolicy(ctx, req) + op, err := c.SetSslPolicy(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } diff --git a/compute/apiv1/target_tcp_proxies_client.go b/compute/apiv1/target_tcp_proxies_client.go index 1ee25c017e0..9e1c62ba316 100644 --- a/compute/apiv1/target_tcp_proxies_client.go +++ b/compute/apiv1/target_tcp_proxies_client.go @@ -135,6 +135,9 @@ type targetTcpProxiesRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *GlobalOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -155,6 +158,16 @@ func NewTargetTcpProxiesRESTClient(ctx context.Context, opts ...option.ClientOpt } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewGlobalOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &TargetTcpProxiesClient{internalClient: c, CallOptions: &TargetTcpProxiesCallOptions{}}, nil } @@ -181,6 +194,9 @@ func (c *targetTcpProxiesRESTClient) setGoogleClientInfo(keyval ...string) { func (c *targetTcpProxiesRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -239,7 +255,13 @@ func (c *targetTcpProxiesRESTClient) Delete(ctx context.Context, req *computepb. if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -342,7 +364,13 @@ func (c *targetTcpProxiesRESTClient) Insert(ctx context.Context, req *computepb. if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -491,7 +519,13 @@ func (c *targetTcpProxiesRESTClient) SetBackendService(ctx context.Context, req if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -550,7 +584,13 @@ func (c *targetTcpProxiesRESTClient) SetProxyHeader(ctx context.Context, req *co if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } diff --git a/compute/apiv1/target_tcp_proxies_client_example_test.go b/compute/apiv1/target_tcp_proxies_client_example_test.go index 523500af9b6..1e9c7826dd2 100644 --- a/compute/apiv1/target_tcp_proxies_client_example_test.go +++ b/compute/apiv1/target_tcp_proxies_client_example_test.go @@ -48,12 +48,15 @@ func ExampleTargetTcpProxiesClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteTargetTcpProxyRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleTargetTcpProxiesClient_Get() { @@ -88,12 +91,15 @@ func ExampleTargetTcpProxiesClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertTargetTcpProxyRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleTargetTcpProxiesClient_List() { @@ -134,12 +140,15 @@ func ExampleTargetTcpProxiesClient_SetBackendService() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#SetBackendServiceTargetTcpProxyRequest. } - resp, err := c.SetBackendService(ctx, req) + op, err := c.SetBackendService(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleTargetTcpProxiesClient_SetProxyHeader() { @@ -154,10 +163,13 @@ func ExampleTargetTcpProxiesClient_SetProxyHeader() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#SetProxyHeaderTargetTcpProxyRequest. } - resp, err := c.SetProxyHeader(ctx, req) + op, err := c.SetProxyHeader(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } diff --git a/compute/apiv1/target_vpn_gateways_client.go b/compute/apiv1/target_vpn_gateways_client.go index b57d16ec288..fa96afa522c 100644 --- a/compute/apiv1/target_vpn_gateways_client.go +++ b/compute/apiv1/target_vpn_gateways_client.go @@ -129,6 +129,9 @@ type targetVpnGatewaysRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *RegionOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -149,6 +152,16 @@ func NewTargetVpnGatewaysRESTClient(ctx context.Context, opts ...option.ClientOp } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewRegionOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &TargetVpnGatewaysClient{internalClient: c, CallOptions: &TargetVpnGatewaysCallOptions{}}, nil } @@ -175,6 +188,9 @@ func (c *targetVpnGatewaysRESTClient) setGoogleClientInfo(keyval ...string) { func (c *targetVpnGatewaysRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -333,7 +349,14 @@ func (c *targetVpnGatewaysRESTClient) Delete(ctx context.Context, req *computepb if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -436,7 +459,14 @@ func (c *targetVpnGatewaysRESTClient) Insert(ctx context.Context, req *computepb if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } diff --git a/compute/apiv1/target_vpn_gateways_client_example_test.go b/compute/apiv1/target_vpn_gateways_client_example_test.go index fb3b85a9541..f57670225f5 100644 --- a/compute/apiv1/target_vpn_gateways_client_example_test.go +++ b/compute/apiv1/target_vpn_gateways_client_example_test.go @@ -74,12 +74,15 @@ func ExampleTargetVpnGatewaysClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteTargetVpnGatewayRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleTargetVpnGatewaysClient_Get() { @@ -114,12 +117,15 @@ func ExampleTargetVpnGatewaysClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertTargetVpnGatewayRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleTargetVpnGatewaysClient_List() { diff --git a/compute/apiv1/url_maps_client.go b/compute/apiv1/url_maps_client.go index 996c45bd4e6..c21487d705c 100644 --- a/compute/apiv1/url_maps_client.go +++ b/compute/apiv1/url_maps_client.go @@ -157,6 +157,9 @@ type urlMapsRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *GlobalOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -177,6 +180,16 @@ func NewUrlMapsRESTClient(ctx context.Context, opts ...option.ClientOption) (*Ur } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewGlobalOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &UrlMapsClient{internalClient: c, CallOptions: &UrlMapsCallOptions{}}, nil } @@ -203,6 +216,9 @@ func (c *urlMapsRESTClient) setGoogleClientInfo(keyval ...string) { func (c *urlMapsRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -361,7 +377,13 @@ func (c *urlMapsRESTClient) Delete(ctx context.Context, req *computepb.DeleteUrl if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -464,7 +486,13 @@ func (c *urlMapsRESTClient) Insert(ctx context.Context, req *computepb.InsertUrl if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -523,7 +551,13 @@ func (c *urlMapsRESTClient) InvalidateCache(ctx context.Context, req *computepb. if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -672,7 +706,13 @@ func (c *urlMapsRESTClient) Patch(ctx context.Context, req *computepb.PatchUrlMa if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } @@ -731,7 +771,13 @@ func (c *urlMapsRESTClient) Update(ctx context.Context, req *computepb.UpdateUrl if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + &globalOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + }, + } return op, nil } diff --git a/compute/apiv1/url_maps_client_example_test.go b/compute/apiv1/url_maps_client_example_test.go index ed771674758..1c2293224ee 100644 --- a/compute/apiv1/url_maps_client_example_test.go +++ b/compute/apiv1/url_maps_client_example_test.go @@ -74,12 +74,15 @@ func ExampleUrlMapsClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteUrlMapRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleUrlMapsClient_Get() { @@ -114,12 +117,15 @@ func ExampleUrlMapsClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertUrlMapRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleUrlMapsClient_InvalidateCache() { @@ -134,12 +140,15 @@ func ExampleUrlMapsClient_InvalidateCache() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InvalidateCacheUrlMapRequest. } - resp, err := c.InvalidateCache(ctx, req) + op, err := c.InvalidateCache(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleUrlMapsClient_List() { @@ -180,12 +189,15 @@ func ExampleUrlMapsClient_Patch() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#PatchUrlMapRequest. } - resp, err := c.Patch(ctx, req) + op, err := c.Patch(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleUrlMapsClient_Update() { @@ -200,12 +212,15 @@ func ExampleUrlMapsClient_Update() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#UpdateUrlMapRequest. } - resp, err := c.Update(ctx, req) + op, err := c.Update(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleUrlMapsClient_Validate() { diff --git a/compute/apiv1/vpn_gateways_client.go b/compute/apiv1/vpn_gateways_client.go index 084879e2219..ffe9eccf7aa 100644 --- a/compute/apiv1/vpn_gateways_client.go +++ b/compute/apiv1/vpn_gateways_client.go @@ -150,6 +150,9 @@ type vpnGatewaysRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *RegionOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -170,6 +173,16 @@ func NewVpnGatewaysRESTClient(ctx context.Context, opts ...option.ClientOption) } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewRegionOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &VpnGatewaysClient{internalClient: c, CallOptions: &VpnGatewaysCallOptions{}}, nil } @@ -196,6 +209,9 @@ func (c *vpnGatewaysRESTClient) setGoogleClientInfo(keyval ...string) { func (c *vpnGatewaysRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -354,7 +370,14 @@ func (c *vpnGatewaysRESTClient) Delete(ctx context.Context, req *computepb.Delet if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -501,7 +524,14 @@ func (c *vpnGatewaysRESTClient) Insert(ctx context.Context, req *computepb.Inser if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -650,7 +680,14 @@ func (c *vpnGatewaysRESTClient) SetLabels(ctx context.Context, req *computepb.Se if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } diff --git a/compute/apiv1/vpn_gateways_client_example_test.go b/compute/apiv1/vpn_gateways_client_example_test.go index ff9d15f911e..1e11fd72fa0 100644 --- a/compute/apiv1/vpn_gateways_client_example_test.go +++ b/compute/apiv1/vpn_gateways_client_example_test.go @@ -74,12 +74,15 @@ func ExampleVpnGatewaysClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteVpnGatewayRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleVpnGatewaysClient_Get() { @@ -134,12 +137,15 @@ func ExampleVpnGatewaysClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertVpnGatewayRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleVpnGatewaysClient_List() { @@ -180,12 +186,15 @@ func ExampleVpnGatewaysClient_SetLabels() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#SetLabelsVpnGatewayRequest. } - resp, err := c.SetLabels(ctx, req) + op, err := c.SetLabels(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleVpnGatewaysClient_TestIamPermissions() { diff --git a/compute/apiv1/vpn_tunnels_client.go b/compute/apiv1/vpn_tunnels_client.go index 9dd82b0b90f..95f2f9e7989 100644 --- a/compute/apiv1/vpn_tunnels_client.go +++ b/compute/apiv1/vpn_tunnels_client.go @@ -129,6 +129,9 @@ type vpnTunnelsRESTClient struct { // The http client. httpClient *http.Client + // operationClient is used to call the operation-specific management service. + operationClient *RegionOperationsClient + // The x-goog-* metadata to be sent with each request. xGoogMetadata metadata.MD } @@ -149,6 +152,16 @@ func NewVpnTunnelsRESTClient(ctx context.Context, opts ...option.ClientOption) ( } c.setGoogleClientInfo() + o := []option.ClientOption{ + option.WithHTTPClient(httpClient), + option.WithEndpoint(endpoint), + } + opC, err := NewRegionOperationsRESTClient(ctx, o...) + if err != nil { + return nil, err + } + c.operationClient = opC + return &VpnTunnelsClient{internalClient: c, CallOptions: &VpnTunnelsCallOptions{}}, nil } @@ -175,6 +188,9 @@ func (c *vpnTunnelsRESTClient) setGoogleClientInfo(keyval ...string) { func (c *vpnTunnelsRESTClient) Close() error { // Replace httpClient with nil to force cleanup. c.httpClient = nil + if err := c.operationClient.Close(); err != nil { + return err + } return nil } @@ -333,7 +349,14 @@ func (c *vpnTunnelsRESTClient) Delete(ctx context.Context, req *computepb.Delete if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } @@ -436,7 +459,14 @@ func (c *vpnTunnelsRESTClient) Insert(ctx context.Context, req *computepb.Insert if e != nil { return nil, e } - op := &Operation{proto: resp} + op := &Operation{ + ®ionOperationsHandle{ + c: c.operationClient, + proto: resp, + project: req.GetProject(), + region: req.GetRegion(), + }, + } return op, nil } diff --git a/compute/apiv1/vpn_tunnels_client_example_test.go b/compute/apiv1/vpn_tunnels_client_example_test.go index eed82e97ec2..b17e460a760 100644 --- a/compute/apiv1/vpn_tunnels_client_example_test.go +++ b/compute/apiv1/vpn_tunnels_client_example_test.go @@ -74,12 +74,15 @@ func ExampleVpnTunnelsClient_Delete() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#DeleteVpnTunnelRequest. } - resp, err := c.Delete(ctx, req) + op, err := c.Delete(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleVpnTunnelsClient_Get() { @@ -114,12 +117,15 @@ func ExampleVpnTunnelsClient_Insert() { // TODO: Fill request struct fields. // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/compute/v1#InsertVpnTunnelRequest. } - resp, err := c.Insert(ctx, req) + op, err := c.Insert(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) if err != nil { // TODO: Handle error. } - // TODO: Use resp. - _ = resp } func ExampleVpnTunnelsClient_List() {