Debian Codegraph @

orchestration/airflow/service/apiv1/image_versions_client_example_test.go

raw
1 // Copyright 2025 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 // Code generated by protoc-gen-go_gapic. DO NOT EDIT.
16
17 package service_test
18
19 import (
20 "context"
21
22 longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
23 service "cloud.google.com/go/orchestration/airflow/service/apiv1"
24 servicepb "cloud.google.com/go/orchestration/airflow/service/apiv1/servicepb"
25 "google.golang.org/api/iterator"
26 )
27
28 func ExampleNewImageVersionsClient() {
29 ctx := context.Background()
30 // This snippet has been automatically generated and should be regarded as a code template only.
31 // It will require modifications to work:
32 // - It may require correct/in-range values for request initialization.
33 // - It may require specifying regional endpoints when creating the service client as shown in:
34 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
35 c, err := service.NewImageVersionsClient(ctx)
36 if err != nil {
37 // TODO: Handle error.
38 }
39 defer c.Close()
40
41 // TODO: Use client.
42 _ = c
43 }
44
45 func ExampleNewImageVersionsRESTClient() {
46 ctx := context.Background()
47 // This snippet has been automatically generated and should be regarded as a code template only.
48 // It will require modifications to work:
49 // - It may require correct/in-range values for request initialization.
50 // - It may require specifying regional endpoints when creating the service client as shown in:
51 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
52 c, err := service.NewImageVersionsRESTClient(ctx)
53 if err != nil {
54 // TODO: Handle error.
55 }
56 defer c.Close()
57
58 // TODO: Use client.
59 _ = c
60 }
61
62 func ExampleImageVersionsClient_ListImageVersions() {
63 ctx := context.Background()
64 // This snippet has been automatically generated and should be regarded as a code template only.
65 // It will require modifications to work:
66 // - It may require correct/in-range values for request initialization.
67 // - It may require specifying regional endpoints when creating the service client as shown in:
68 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
69 c, err := service.NewImageVersionsClient(ctx)
70 if err != nil {
71 // TODO: Handle error.
72 }
73 defer c.Close()
74
75 req := &servicepb.ListImageVersionsRequest{
76 // TODO: Fill request struct fields.
77 // See https://pkg.go.dev/cloud.google.com/go/orchestration/airflow/service/apiv1/servicepb#ListImageVersionsRequest.
78 }
79 it := c.ListImageVersions(ctx, req)
80 for {
81 resp, err := it.Next()
82 if err == iterator.Done {
83 break
84 }
85 if err != nil {
86 // TODO: Handle error.
87 }
88 // TODO: Use resp.
89 _ = resp
90
91 // If you need to access the underlying RPC response,
92 // you can do so by casting the `Response` as below.
93 // Otherwise, remove this line. Only populated after
94 // first call to Next(). Not safe for concurrent access.
95 _ = it.Response.(*servicepb.ListImageVersionsResponse)
96 }
97 }
98
99 func ExampleImageVersionsClient_DeleteOperation() {
100 ctx := context.Background()
101 // This snippet has been automatically generated and should be regarded as a code template only.
102 // It will require modifications to work:
103 // - It may require correct/in-range values for request initialization.
104 // - It may require specifying regional endpoints when creating the service client as shown in:
105 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
106 c, err := service.NewImageVersionsClient(ctx)
107 if err != nil {
108 // TODO: Handle error.
109 }
110 defer c.Close()
111
112 req := &longrunningpb.DeleteOperationRequest{
113 // TODO: Fill request struct fields.
114 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#DeleteOperationRequest.
115 }
116 err = c.DeleteOperation(ctx, req)
117 if err != nil {
118 // TODO: Handle error.
119 }
120 }
121
122 func ExampleImageVersionsClient_GetOperation() {
123 ctx := context.Background()
124 // This snippet has been automatically generated and should be regarded as a code template only.
125 // It will require modifications to work:
126 // - It may require correct/in-range values for request initialization.
127 // - It may require specifying regional endpoints when creating the service client as shown in:
128 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
129 c, err := service.NewImageVersionsClient(ctx)
130 if err != nil {
131 // TODO: Handle error.
132 }
133 defer c.Close()
134
135 req := &longrunningpb.GetOperationRequest{
136 // TODO: Fill request struct fields.
137 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#GetOperationRequest.
138 }
139 resp, err := c.GetOperation(ctx, req)
140 if err != nil {
141 // TODO: Handle error.
142 }
143 // TODO: Use resp.
144 _ = resp
145 }
146
147 func ExampleImageVersionsClient_ListOperations() {
148 ctx := context.Background()
149 // This snippet has been automatically generated and should be regarded as a code template only.
150 // It will require modifications to work:
151 // - It may require correct/in-range values for request initialization.
152 // - It may require specifying regional endpoints when creating the service client as shown in:
153 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
154 c, err := service.NewImageVersionsClient(ctx)
155 if err != nil {
156 // TODO: Handle error.
157 }
158 defer c.Close()
159
160 req := &longrunningpb.ListOperationsRequest{
161 // TODO: Fill request struct fields.
162 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest.
163 }
164 it := c.ListOperations(ctx, req)
165 for {
166 resp, err := it.Next()
167 if err == iterator.Done {
168 break
169 }
170 if err != nil {
171 // TODO: Handle error.
172 }
173 // TODO: Use resp.
174 _ = resp
175
176 // If you need to access the underlying RPC response,
177 // you can do so by casting the `Response` as below.
178 // Otherwise, remove this line. Only populated after
179 // first call to Next(). Not safe for concurrent access.
180 _ = it.Response.(*longrunningpb.ListOperationsResponse)
181 }
182 }