// Copyright 2025 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 cloudbuild_test import ( "context" cloudbuild "cloud.google.com/go/cloudbuild/apiv1/v2" cloudbuildpb "cloud.google.com/go/cloudbuild/apiv1/v2/cloudbuildpb" "google.golang.org/api/iterator" ) func ExampleNewClient() { 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 := cloudbuild.NewClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() // TODO: Use client. _ = c } func ExampleNewRESTClient() { 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 := cloudbuild.NewRESTClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() // TODO: Use client. _ = c } func ExampleClient_ApproveBuild() { 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 := cloudbuild.NewClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &cloudbuildpb.ApproveBuildRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/cloudbuild/apiv1/v2/cloudbuildpb#ApproveBuildRequest. } op, err := c.ApproveBuild(ctx, req) if err != nil { // TODO: Handle error. } resp, err := op.Wait(ctx) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } func ExampleClient_CancelBuild() { 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 := cloudbuild.NewClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &cloudbuildpb.CancelBuildRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/cloudbuild/apiv1/v2/cloudbuildpb#CancelBuildRequest. } resp, err := c.CancelBuild(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } func ExampleClient_CreateBuild() { 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 := cloudbuild.NewClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &cloudbuildpb.CreateBuildRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/cloudbuild/apiv1/v2/cloudbuildpb#CreateBuildRequest. } op, err := c.CreateBuild(ctx, req) if err != nil { // TODO: Handle error. } resp, err := op.Wait(ctx) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } func ExampleClient_CreateBuildTrigger() { 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 := cloudbuild.NewClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &cloudbuildpb.CreateBuildTriggerRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/cloudbuild/apiv1/v2/cloudbuildpb#CreateBuildTriggerRequest. } resp, err := c.CreateBuildTrigger(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } func ExampleClient_CreateWorkerPool() { 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 := cloudbuild.NewClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &cloudbuildpb.CreateWorkerPoolRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/cloudbuild/apiv1/v2/cloudbuildpb#CreateWorkerPoolRequest. } op, err := c.CreateWorkerPool(ctx, req) if err != nil { // TODO: Handle error. } resp, err := op.Wait(ctx) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } func ExampleClient_DeleteBuildTrigger() { 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 := cloudbuild.NewClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &cloudbuildpb.DeleteBuildTriggerRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/cloudbuild/apiv1/v2/cloudbuildpb#DeleteBuildTriggerRequest. } err = c.DeleteBuildTrigger(ctx, req) if err != nil { // TODO: Handle error. } } func ExampleClient_DeleteWorkerPool() { 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 := cloudbuild.NewClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &cloudbuildpb.DeleteWorkerPoolRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/cloudbuild/apiv1/v2/cloudbuildpb#DeleteWorkerPoolRequest. } op, err := c.DeleteWorkerPool(ctx, req) if err != nil { // TODO: Handle error. } err = op.Wait(ctx) if err != nil { // TODO: Handle error. } } func ExampleClient_GetBuild() { 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 := cloudbuild.NewClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &cloudbuildpb.GetBuildRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/cloudbuild/apiv1/v2/cloudbuildpb#GetBuildRequest. } resp, err := c.GetBuild(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } func ExampleClient_GetBuildTrigger() { 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 := cloudbuild.NewClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &cloudbuildpb.GetBuildTriggerRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/cloudbuild/apiv1/v2/cloudbuildpb#GetBuildTriggerRequest. } resp, err := c.GetBuildTrigger(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } func ExampleClient_GetWorkerPool() { 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 := cloudbuild.NewClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &cloudbuildpb.GetWorkerPoolRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/cloudbuild/apiv1/v2/cloudbuildpb#GetWorkerPoolRequest. } resp, err := c.GetWorkerPool(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } func ExampleClient_ListBuildTriggers() { 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 := cloudbuild.NewClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &cloudbuildpb.ListBuildTriggersRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/cloudbuild/apiv1/v2/cloudbuildpb#ListBuildTriggersRequest. } it := c.ListBuildTriggers(ctx, req) for { resp, err := it.Next() if err == iterator.Done { break } if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp // If you need to access the underlying RPC response, // you can do so by casting the `Response` as below. // Otherwise, remove this line. Only populated after // first call to Next(). Not safe for concurrent access. _ = it.Response.(*cloudbuildpb.ListBuildTriggersResponse) } } func ExampleClient_ListBuilds() { 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 := cloudbuild.NewClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &cloudbuildpb.ListBuildsRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/cloudbuild/apiv1/v2/cloudbuildpb#ListBuildsRequest. } it := c.ListBuilds(ctx, req) for { resp, err := it.Next() if err == iterator.Done { break } if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp // If you need to access the underlying RPC response, // you can do so by casting the `Response` as below. // Otherwise, remove this line. Only populated after // first call to Next(). Not safe for concurrent access. _ = it.Response.(*cloudbuildpb.ListBuildsResponse) } } func ExampleClient_ListWorkerPools() { 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 := cloudbuild.NewClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &cloudbuildpb.ListWorkerPoolsRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/cloudbuild/apiv1/v2/cloudbuildpb#ListWorkerPoolsRequest. } it := c.ListWorkerPools(ctx, req) for { resp, err := it.Next() if err == iterator.Done { break } if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp // If you need to access the underlying RPC response, // you can do so by casting the `Response` as below. // Otherwise, remove this line. Only populated after // first call to Next(). Not safe for concurrent access. _ = it.Response.(*cloudbuildpb.ListWorkerPoolsResponse) } } func ExampleClient_ReceiveTriggerWebhook() { 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 := cloudbuild.NewClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &cloudbuildpb.ReceiveTriggerWebhookRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/cloudbuild/apiv1/v2/cloudbuildpb#ReceiveTriggerWebhookRequest. } resp, err := c.ReceiveTriggerWebhook(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } func ExampleClient_RetryBuild() { 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 := cloudbuild.NewClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &cloudbuildpb.RetryBuildRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/cloudbuild/apiv1/v2/cloudbuildpb#RetryBuildRequest. } op, err := c.RetryBuild(ctx, req) if err != nil { // TODO: Handle error. } resp, err := op.Wait(ctx) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } func ExampleClient_RunBuildTrigger() { 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 := cloudbuild.NewClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &cloudbuildpb.RunBuildTriggerRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/cloudbuild/apiv1/v2/cloudbuildpb#RunBuildTriggerRequest. } op, err := c.RunBuildTrigger(ctx, req) if err != nil { // TODO: Handle error. } resp, err := op.Wait(ctx) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } func ExampleClient_UpdateBuildTrigger() { 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 := cloudbuild.NewClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &cloudbuildpb.UpdateBuildTriggerRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/cloudbuild/apiv1/v2/cloudbuildpb#UpdateBuildTriggerRequest. } resp, err := c.UpdateBuildTrigger(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp } func ExampleClient_UpdateWorkerPool() { 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 := cloudbuild.NewClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &cloudbuildpb.UpdateWorkerPoolRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/cloudbuild/apiv1/v2/cloudbuildpb#UpdateWorkerPoolRequest. } op, err := c.UpdateWorkerPool(ctx, req) if err != nil { // TODO: Handle error. } resp, err := op.Wait(ctx) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp }