| // Copyright 2023 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 database_test | |
| import ( | |
| "context" | |
| iampb "cloud.google.com/go/iam/apiv1/iampb" | |
| longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb" | |
| database "cloud.google.com/go/spanner/admin/database/apiv1" | |
| databasepb "cloud.google.com/go/spanner/admin/database/apiv1/databasepb" | |
| "google.golang.org/api/iterator" | |
| ) | |
| func ExampleNewDatabaseAdminClient() { | |
| ctx := context.Background() | |
| // This snippet has been automatically generated and should be regarded as a code template only. | |
| // It will require modifications to work: | |
| // - It may require correct/in-range values for request initialization. | |
| // - It may require specifying regional endpoints when creating the service client as shown in: | |
| // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options | |
| c, err := database.NewDatabaseAdminClient(ctx) | |
| if err != nil { | |
| // TODO: Handle error. | |
| } | |
| defer c.Close() | |
| // TODO: Use client. | |
| _ = c | |
| } | |
| func ExampleNewDatabaseAdminRESTClient() { | |
| ctx := context.Background() | |
| // This snippet has been automatically generated and should be regarded as a code template only. | |
| // It will require modifications to work: | |
| // - It may require correct/in-range values for request initialization. | |
| // - It may require specifying regional endpoints when creating the service client as shown in: | |
| // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options | |
| c, err := database.NewDatabaseAdminRESTClient(ctx) | |
| if err != nil { | |
| // TODO: Handle error. | |
| } | |
| defer c.Close() | |
| // TODO: Use client. | |
| _ = c | |
| } | |
| func ExampleDatabaseAdminClient_ListDatabases() { | |
| ctx := context.Background() | |
| // This snippet has been automatically generated and should be regarded as a code template only. | |
| // It will require modifications to work: | |
| // - It may require correct/in-range values for request initialization. | |
| // - It may require specifying regional endpoints when creating the service client as shown in: | |
| // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options | |
| c, err := database.NewDatabaseAdminClient(ctx) | |
| if err != nil { | |
| // TODO: Handle error. | |
| } | |
| defer c.Close() | |
| req := &databasepb.ListDatabasesRequest{ | |
| // TODO: Fill request struct fields. | |
| // See https://pkg.go.dev/cloud.google.com/go/spanner/admin/database/apiv1/databasepb#ListDatabasesRequest. | |
| } | |
| it := c.ListDatabases(ctx, req) | |
| for { | |
| resp, err := it.Next() | |
| if err == iterator.Done { | |
| break | |
| } | |
| if err != nil { | |
| // TODO: Handle error. | |
| } | |
| // TODO: Use resp. | |
| _ = resp | |
| } | |
| } | |
| func ExampleDatabaseAdminClient_CreateDatabase() { | |
| ctx := context.Background() | |
| // This snippet has been automatically generated and should be regarded as a code template only. | |
| // It will require modifications to work: | |
| // - It may require correct/in-range values for request initialization. | |
| // - It may require specifying regional endpoints when creating the service client as shown in: | |
| // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options | |
| c, err := database.NewDatabaseAdminClient(ctx) | |
| if err != nil { | |
| // TODO: Handle error. | |
| } | |
| defer c.Close() | |
| req := &databasepb.CreateDatabaseRequest{ | |
| // TODO: Fill request struct fields. | |
| // See https://pkg.go.dev/cloud.google.com/go/spanner/admin/database/apiv1/databasepb#CreateDatabaseRequest. | |
| } | |
| op, err := c.CreateDatabase(ctx, req) | |
| if err != nil { | |
| // TODO: Handle error. | |
| } | |
| resp, err := op.Wait(ctx) | |
| if err != nil { | |
| // TODO: Handle error. | |
| } | |
| // TODO: Use resp. | |
| _ = resp | |
| } | |
| func ExampleDatabaseAdminClient_GetDatabase() { | |
| ctx := context.Background() | |
| // This snippet has been automatically generated and should be regarded as a code template only. | |
| // It will require modifications to work: | |
| // - It may require correct/in-range values for request initialization. | |
| // - It may require specifying regional endpoints when creating the service client as shown in: | |
| // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options | |
| c, err := database.NewDatabaseAdminClient(ctx) | |
| if err != nil { | |
| // TODO: Handle error. | |
| } | |
| defer c.Close() | |
| req := &databasepb.GetDatabaseRequest{ | |
| // TODO: Fill request struct fields. | |
| // See https://pkg.go.dev/cloud.google.com/go/spanner/admin/database/apiv1/databasepb#GetDatabaseRequest. | |
| } | |
| resp, err := c.GetDatabase(ctx, req) | |
| if err != nil { | |
| // TODO: Handle error. | |
| } | |
| // TODO: Use resp. | |
| _ = resp | |
| } | |
| func ExampleDatabaseAdminClient_UpdateDatabase() { | |
| ctx := context.Background() | |
| // This snippet has been automatically generated and should be regarded as a code template only. | |
| // It will require modifications to work: | |
| // - It may require correct/in-range values for request initialization. | |
| // - It may require specifying regional endpoints when creating the service client as shown in: | |
| // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options | |
| c, err := database.NewDatabaseAdminClient(ctx) | |
| if err != nil { | |
| // TODO: Handle error. | |
| } | |
| defer c.Close() | |
| req := &databasepb.UpdateDatabaseRequest{ | |
| // TODO: Fill request struct fields. | |
| // See https://pkg.go.dev/cloud.google.com/go/spanner/admin/database/apiv1/databasepb#UpdateDatabaseRequest. | |
| } | |
| op, err := c.UpdateDatabase(ctx, req) | |
| if err != nil { | |
| // TODO: Handle error. | |
| } | |
| resp, err := op.Wait(ctx) | |
| if err != nil { | |
| // TODO: Handle error. | |
| } | |
| // TODO: Use resp. | |
| _ = resp | |
| } | |
| func ExampleDatabaseAdminClient_UpdateDatabaseDdl() { | |
| ctx := context.Background() | |
| // This snippet has been automatically generated and should be regarded as a code template only. | |
| // It will require modifications to work: | |
| // - It may require correct/in-range values for request initialization. | |
| // - It may require specifying regional endpoints when creating the service client as shown in: | |
| // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options | |
| c, err := database.NewDatabaseAdminClient(ctx) | |
| if err != nil { | |
| // TODO: Handle error. | |
| } | |
| defer c.Close() | |
| req := &databasepb.UpdateDatabaseDdlRequest{ | |
| // TODO: Fill request struct fields. | |
| // See https://pkg.go.dev/cloud.google.com/go/spanner/admin/database/apiv1/databasepb#UpdateDatabaseDdlRequest. | |
| } | |
| op, err := c.UpdateDatabaseDdl(ctx, req) | |
| if err != nil { | |
| // TODO: Handle error. | |
| } | |
| err = op.Wait(ctx) | |
| if err != nil { | |
| // TODO: Handle error. | |
| } | |
| } | |
| func ExampleDatabaseAdminClient_DropDatabase() { | |
| ctx := context.Background() | |
| // This snippet has been automatically generated and should be regarded as a code template only. | |
| // It will require modifications to work: | |
| // - It may require correct/in-range values for request initialization. | |
| // - It may require specifying regional endpoints when creating the service client as shown in: | |
| // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options | |
| c, err := database.NewDatabaseAdminClient(ctx) | |
| if err != nil { | |
| // TODO: Handle error. | |
| } | |
| defer c.Close() | |
| req := &databasepb.DropDatabaseRequest{ | |
| // TODO: Fill request struct fields. | |
| // See https://pkg.go.dev/cloud.google.com/go/spanner/admin/database/apiv1/databasepb#DropDatabaseRequest. | |
| } | |
| err = c.DropDatabase(ctx, req) | |
| if err != nil { | |
| // TODO: Handle error. | |
| } | |
| } | |
| func ExampleDatabaseAdminClient_GetDatabaseDdl() { | |
| ctx := context.Background() | |
| // This snippet has been automatically generated and should be regarded as a code template only. | |
| // It will require modifications to work: | |
| // - It may require correct/in-range values for request initialization. | |
| // - It may require specifying regional endpoints when creating the service client as shown in: | |
| // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options | |
| c, err := database.NewDatabaseAdminClient(ctx) | |
| if err != nil { | |
| // TODO: Handle error. | |
| } | |
| defer c.Close() | |
| req := &databasepb.GetDatabaseDdlRequest{ | |
| // TODO: Fill request struct fields. | |
| // See https://pkg.go.dev/cloud.google.com/go/spanner/admin/database/apiv1/databasepb#GetDatabaseDdlRequest. | |
| } | |
| resp, err := c.GetDatabaseDdl(ctx, req) | |
| if err != nil { | |
| // TODO: Handle error. | |
| } | |
| // TODO: Use resp. | |
| _ = resp | |
| } | |
| func ExampleDatabaseAdminClient_SetIamPolicy() { | |
| ctx := context.Background() | |
| // This snippet has been automatically generated and should be regarded as a code template only. | |
| // It will require modifications to work: | |
| // - It may require correct/in-range values for request initialization. | |
| // - It may require specifying regional endpoints when creating the service client as shown in: | |
| // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options | |
| c, err := database.NewDatabaseAdminClient(ctx) | |
| if err != nil { | |
| // TODO: Handle error. | |
| } | |
| defer c.Close() | |
| req := &iampb.SetIamPolicyRequest{ | |
| // TODO: Fill request struct fields. | |
| // See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#SetIamPolicyRequest. | |
| } | |
| resp, err := c.SetIamPolicy(ctx, req) | |
| if err != nil { | |
| // TODO: Handle error. | |
| } | |
| // TODO: Use resp. | |
| _ = resp | |
| } | |
| func ExampleDatabaseAdminClient_GetIamPolicy() { | |
| ctx := context.Background() | |
| // This snippet has been automatically generated and should be regarded as a code template only. | |
| // It will require modifications to work: | |
| // - It may require correct/in-range values for request initialization. | |
| // - It may require specifying regional endpoints when creating the service client as shown in: | |
| // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options | |
| c, err := database.NewDatabaseAdminClient(ctx) | |
| if err != nil { | |
| // TODO: Handle error. | |
| } | |
| defer c.Close() | |
| req := &iampb.GetIamPolicyRequest{ | |
| // TODO: Fill request struct fields. | |
| // See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#GetIamPolicyRequest. | |
| } | |
| resp, err := c.GetIamPolicy(ctx, req) | |
| if err != nil { | |
| // TODO: Handle error. | |
| } | |
| // TODO: Use resp. | |
| _ = resp | |
| } | |
| func ExampleDatabaseAdminClient_TestIamPermissions() { | |
| ctx := context.Background() | |
| // This snippet has been automatically generated and should be regarded as a code template only. | |
| // It will require modifications to work: | |
| // - It may require correct/in-range values for request initialization. | |
| // - It may require specifying regional endpoints when creating the service client as shown in: | |
| // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options | |
| c, err := database.NewDatabaseAdminClient(ctx) | |
| if err != nil { | |
| // TODO: Handle error. | |
| } | |
| defer c.Close() | |
| req := &iampb.TestIamPermissionsRequest{ | |
| // TODO: Fill request struct fields. | |
| // See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#TestIamPermissionsRequest. | |
| } | |
| resp, err := c.TestIamPermissions(ctx, req) | |
| if err != nil { | |
| // TODO: Handle error. | |
| } | |
| // TODO: Use resp. | |
| _ = resp | |
| } | |
| func ExampleDatabaseAdminClient_CreateBackup() { | |
| ctx := context.Background() | |
| // This snippet has been automatically generated and should be regarded as a code template only. | |
| // It will require modifications to work: | |
| // - It may require correct/in-range values for request initialization. | |
| // - It may require specifying regional endpoints when creating the service client as shown in: | |
| // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options | |
| c, err := database.NewDatabaseAdminClient(ctx) | |
| if err != nil { | |
| // TODO: Handle error. | |
| } | |
| defer c.Close() | |
| req := &databasepb.CreateBackupRequest{ | |
| // TODO: Fill request struct fields. | |
| // See https://pkg.go.dev/cloud.google.com/go/spanner/admin/database/apiv1/databasepb#CreateBackupRequest. | |
| } | |
| op, err := c.CreateBackup(ctx, req) | |
| if err != nil { | |
| // TODO: Handle error. | |
| } | |
| resp, err := op.Wait(ctx) | |
| if err != nil { | |
| // TODO: Handle error. | |
| } | |
| // TODO: Use resp. | |
| _ = resp | |
| } | |
| func ExampleDatabaseAdminClient_CopyBackup() { | |
| ctx := context.Background() | |
| // This snippet has been automatically generated and should be regarded as a code template only. | |
| // It will require modifications to work: | |
| // - It may require correct/in-range values for request initialization. | |
| // - It may require specifying regional endpoints when creating the service client as shown in: | |
| // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options | |
| c, err := database.NewDatabaseAdminClient(ctx) | |
| if err != nil { | |
| // TODO: Handle error. | |
| } | |
| defer c.Close() | |
| req := &databasepb.CopyBackupRequest{ | |
| // TODO: Fill request struct fields. | |
| // See https://pkg.go.dev/cloud.google.com/go/spanner/admin/database/apiv1/databasepb#CopyBackupRequest. | |
| } | |
| op, err := c.CopyBackup(ctx, req) | |
| if err != nil { | |
| // TODO: Handle error. | |
| } | |
| resp, err := op.Wait(ctx) | |
| if err != nil { | |
| // TODO: Handle error. | |
| } | |
| // TODO: Use resp. | |
| _ = resp | |
| } | |
| func ExampleDatabaseAdminClient_GetBackup() { | |
| ctx := context.Background() | |
| // This snippet has been automatically generated and should be regarded as a code template only. | |
| // It will require modifications to work: | |
| // - It may require correct/in-range values for request initialization. | |
| // - It may require specifying regional endpoints when creating the service client as shown in: | |
| // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options | |
| c, err := database.NewDatabaseAdminClient(ctx) | |
| if err != nil { | |
| // TODO: Handle error. | |
| } | |
| defer c.Close() | |
| req := &databasepb.GetBackupRequest{ | |
| // TODO: Fill request struct fields. | |
| // See https://pkg.go.dev/cloud.google.com/go/spanner/admin/database/apiv1/databasepb#GetBackupRequest. | |
| } | |
| resp, err := c.GetBackup(ctx, req) | |
| if err != nil { | |
| // TODO: Handle error. | |
| } | |
| // TODO: Use resp. | |
| _ = resp | |
| } | |
| func ExampleDatabaseAdminClient_UpdateBackup() { | |
| ctx := context.Background() | |
| // This snippet has been automatically generated and should be regarded as a code template only. | |
| // It will require modifications to work: | |
| // - It may require correct/in-range values for request initialization. | |
| // - It may require specifying regional endpoints when creating the service client as shown in: | |
| // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options | |
| c, err := database.NewDatabaseAdminClient(ctx) | |
| if err != nil { | |
| // TODO: Handle error. | |
| } | |
| defer c.Close() | |
| req := &databasepb.UpdateBackupRequest{ | |
| // TODO: Fill request struct fields. | |
| // See https://pkg.go.dev/cloud.google.com/go/spanner/admin/database/apiv1/databasepb#UpdateBackupRequest. | |
| } | |
| resp, err := c.UpdateBackup(ctx, req) | |
| if err != nil { | |
| // TODO: Handle error. | |
| } | |
| // TODO: Use resp. | |
| _ = resp | |
| } | |
| func ExampleDatabaseAdminClient_DeleteBackup() { | |
| ctx := context.Background() | |
| // This snippet has been automatically generated and should be regarded as a code template only. | |
| // It will require modifications to work: | |
| // - It may require correct/in-range values for request initialization. | |
| // - It may require specifying regional endpoints when creating the service client as shown in: | |
| // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options | |
| c, err := database.NewDatabaseAdminClient(ctx) | |
| if err != nil { | |
| // TODO: Handle error. | |
| } | |
| defer c.Close() | |
| req := &databasepb.DeleteBackupRequest{ | |
| // TODO: Fill request struct fields. | |
| // See https://pkg.go.dev/cloud.google.com/go/spanner/admin/database/apiv1/databasepb#DeleteBackupRequest. | |
| } | |
| err = c.DeleteBackup(ctx, req) | |
| if err != nil { | |
| // TODO: Handle error. | |
| } | |
| } | |
| func ExampleDatabaseAdminClient_ListBackups() { | |
| ctx := context.Background() | |
| // This snippet has been automatically generated and should be regarded as a code template only. | |
| // It will require modifications to work: | |
| // - It may require correct/in-range values for request initialization. | |
| // - It may require specifying regional endpoints when creating the service client as shown in: | |
| // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options | |
| c, err := database.NewDatabaseAdminClient(ctx) | |
| if err != nil { | |
| // TODO: Handle error. | |
| } | |
| defer c.Close() | |
| req := &databasepb.ListBackupsRequest{ | |
| // TODO: Fill request struct fields. | |
| // See https://pkg.go.dev/cloud.google.com/go/spanner/admin/database/apiv1/databasepb#ListBackupsRequest. | |
| } | |
| it := c.ListBackups(ctx, req) | |
| for { | |
| resp, err := it.Next() | |
| if err == iterator.Done { | |
| break | |
| } | |
| if err != nil { | |
| // TODO: Handle error. | |
| } | |
| // TODO: Use resp. | |
| _ = resp | |
| } | |
| } | |
| func ExampleDatabaseAdminClient_RestoreDatabase() { | |
| ctx := context.Background() | |
| // This snippet has been automatically generated and should be regarded as a code template only. | |
| // It will require modifications to work: | |
| // - It may require correct/in-range values for request initialization. | |
| // - It may require specifying regional endpoints when creating the service client as shown in: | |
| // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options | |
| c, err := database.NewDatabaseAdminClient(ctx) | |
| if err != nil { | |
| // TODO: Handle error. | |
| } | |
| defer c.Close() | |
| req := &databasepb.RestoreDatabaseRequest{ | |
| // TODO: Fill request struct fields. | |
| // See https://pkg.go.dev/cloud.google.com/go/spanner/admin/database/apiv1/databasepb#RestoreDatabaseRequest. | |
| } | |
| op, err := c.RestoreDatabase(ctx, req) | |
| if err != nil { | |
| // TODO: Handle error. | |
| } | |
| resp, err := op.Wait(ctx) | |
| if err != nil { | |
| // TODO: Handle error. | |
| } | |
| // TODO: Use resp. | |
| _ = resp | |
| } | |
| func ExampleDatabaseAdminClient_ListDatabaseOperations() { | |
| ctx := context.Background() | |
| // This snippet has been automatically generated and should be regarded as a code template only. | |
| // It will require modifications to work: | |
| // - It may require correct/in-range values for request initialization. | |
| // - It may require specifying regional endpoints when creating the service client as shown in: | |
| // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options | |
| c, err := database.NewDatabaseAdminClient(ctx) | |
| if err != nil { | |
| // TODO: Handle error. | |
| } | |
| defer c.Close() | |
| req := &databasepb.ListDatabaseOperationsRequest{ | |
| // TODO: Fill request struct fields. | |
| // See https://pkg.go.dev/cloud.google.com/go/spanner/admin/database/apiv1/databasepb#ListDatabaseOperationsRequest. | |
| } | |
| it := c.ListDatabaseOperations(ctx, req) | |
| for { | |
| resp, err := it.Next() | |
| if err == iterator.Done { | |
| break | |
| } | |
| if err != nil { | |
| // TODO: Handle error. | |
| } | |
| // TODO: Use resp. | |
| _ = resp | |
| } | |
| } | |
| func ExampleDatabaseAdminClient_ListBackupOperations() { | |
| ctx := context.Background() | |
| // This snippet has been automatically generated and should be regarded as a code template only. | |
| // It will require modifications to work: | |
| // - It may require correct/in-range values for request initialization. | |
| // - It may require specifying regional endpoints when creating the service client as shown in: | |
| // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options | |
| c, err := database.NewDatabaseAdminClient(ctx) | |
| if err != nil { | |
| // TODO: Handle error. | |
| } | |
| defer c.Close() | |
| req := &databasepb.ListBackupOperationsRequest{ | |
| // TODO: Fill request struct fields. | |
| // See https://pkg.go.dev/cloud.google.com/go/spanner/admin/database/apiv1/databasepb#ListBackupOperationsRequest. | |
| } | |
| it := c.ListBackupOperations(ctx, req) | |
| for { | |
| resp, err := it.Next() | |
| if err == iterator.Done { | |
| break | |
| } | |
| if err != nil { | |
| // TODO: Handle error. | |
| } | |
| // TODO: Use resp. | |
| _ = resp | |
| } | |
| } | |
| func ExampleDatabaseAdminClient_ListDatabaseRoles() { | |
| ctx := context.Background() | |
| // This snippet has been automatically generated and should be regarded as a code template only. | |
| // It will require modifications to work: | |
| // - It may require correct/in-range values for request initialization. | |
| // - It may require specifying regional endpoints when creating the service client as shown in: | |
| // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options | |
| c, err := database.NewDatabaseAdminClient(ctx) | |
| if err != nil { | |
| // TODO: Handle error. | |
| } | |
| defer c.Close() | |
| req := &databasepb.ListDatabaseRolesRequest{ | |
| // TODO: Fill request struct fields. | |
| // See https://pkg.go.dev/cloud.google.com/go/spanner/admin/database/apiv1/databasepb#ListDatabaseRolesRequest. | |
| } | |
| it := c.ListDatabaseRoles(ctx, req) | |
| for { | |
| resp, err := it.Next() | |
| if err == iterator.Done { | |
| break | |
| } | |
| if err != nil { | |
| // TODO: Handle error. | |
| } | |
| // TODO: Use resp. | |
| _ = resp | |
| } | |
| } | |
| func ExampleDatabaseAdminClient_CancelOperation() { | |
| ctx := context.Background() | |
| // This snippet has been automatically generated and should be regarded as a code template only. | |
| // It will require modifications to work: | |
| // - It may require correct/in-range values for request initialization. | |
| // - It may require specifying regional endpoints when creating the service client as shown in: | |
| // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options | |
| c, err := database.NewDatabaseAdminClient(ctx) | |
| if err != nil { | |
| // TODO: Handle error. | |
| } | |
| defer c.Close() | |
| req := &longrunningpb.CancelOperationRequest{ | |
| // TODO: Fill request struct fields. | |
| // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#CancelOperationRequest. | |
| } | |
| err = c.CancelOperation(ctx, req) | |
| if err != nil { | |
| // TODO: Handle error. | |
| } | |
| } | |
| func ExampleDatabaseAdminClient_DeleteOperation() { | |
| ctx := context.Background() | |
| // This snippet has been automatically generated and should be regarded as a code template only. | |
| // It will require modifications to work: | |
| // - It may require correct/in-range values for request initialization. | |
| // - It may require specifying regional endpoints when creating the service client as shown in: | |
| // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options | |
| c, err := database.NewDatabaseAdminClient(ctx) | |
| if err != nil { | |
| // TODO: Handle error. | |
| } | |
| defer c.Close() | |
| req := &longrunningpb.DeleteOperationRequest{ | |
| // TODO: Fill request struct fields. | |
| // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#DeleteOperationRequest. | |
| } | |
| err = c.DeleteOperation(ctx, req) | |
| if err != nil { | |
| // TODO: Handle error. | |
| } | |
| } | |
| func ExampleDatabaseAdminClient_GetOperation() { | |
| ctx := context.Background() | |
| // This snippet has been automatically generated and should be regarded as a code template only. | |
| // It will require modifications to work: | |
| // - It may require correct/in-range values for request initialization. | |
| // - It may require specifying regional endpoints when creating the service client as shown in: | |
| // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options | |
| c, err := database.NewDatabaseAdminClient(ctx) | |
| if err != nil { | |
| // TODO: Handle error. | |
| } | |
| defer c.Close() | |
| req := &longrunningpb.GetOperationRequest{ | |
| // TODO: Fill request struct fields. | |
| // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#GetOperationRequest. | |
| } | |
| resp, err := c.GetOperation(ctx, req) | |
| if err != nil { | |
| // TODO: Handle error. | |
| } | |
| // TODO: Use resp. | |
| _ = resp | |
| } | |
| func ExampleDatabaseAdminClient_ListOperations() { | |
| ctx := context.Background() | |
| // This snippet has been automatically generated and should be regarded as a code template only. | |
| // It will require modifications to work: | |
| // - It may require correct/in-range values for request initialization. | |
| // - It may require specifying regional endpoints when creating the service client as shown in: | |
| // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options | |
| c, err := database.NewDatabaseAdminClient(ctx) | |
| if err != nil { | |
| // TODO: Handle error. | |
| } | |
| defer c.Close() | |
| req := &longrunningpb.ListOperationsRequest{ | |
| // TODO: Fill request struct fields. | |
| // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest. | |
| } | |
| it := c.ListOperations(ctx, req) | |
| for { | |
| resp, err := it.Next() | |
| if err == iterator.Done { | |
| break | |
| } | |
| if err != nil { | |
| // TODO: Handle error. | |
| } | |
| // TODO: Use resp. | |
| _ = resp | |
| } | |
| } |