Debian Codegraph @

apihub/apiv1/provisioning_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 apihub_test
18
19 import (
20 "context"
21
22 apihub "cloud.google.com/go/apihub/apiv1"
23 apihubpb "cloud.google.com/go/apihub/apiv1/apihubpb"
24 longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
25 "google.golang.org/api/iterator"
26 locationpb "google.golang.org/genproto/googleapis/cloud/location"
27 )
28
29 func ExampleNewProvisioningRESTClient() {
30 ctx := context.Background()
31 // This snippet has been automatically generated and should be regarded as a code template only.
32 // It will require modifications to work:
33 // - It may require correct/in-range values for request initialization.
34 // - It may require specifying regional endpoints when creating the service client as shown in:
35 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
36 c, err := apihub.NewProvisioningRESTClient(ctx)
37 if err != nil {
38 // TODO: Handle error.
39 }
40 defer c.Close()
41
42 // TODO: Use client.
43 _ = c
44 }
45
46 func ExampleProvisioningClient_CreateApiHubInstance() {
47 ctx := context.Background()
48 // This snippet has been automatically generated and should be regarded as a code template only.
49 // It will require modifications to work:
50 // - It may require correct/in-range values for request initialization.
51 // - It may require specifying regional endpoints when creating the service client as shown in:
52 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
53 c, err := apihub.NewProvisioningRESTClient(ctx)
54 if err != nil {
55 // TODO: Handle error.
56 }
57 defer c.Close()
58
59 req := &apihubpb.CreateApiHubInstanceRequest{
60 // TODO: Fill request struct fields.
61 // See https://pkg.go.dev/cloud.google.com/go/apihub/apiv1/apihubpb#CreateApiHubInstanceRequest.
62 }
63 op, err := c.CreateApiHubInstance(ctx, req)
64 if err != nil {
65 // TODO: Handle error.
66 }
67
68 resp, err := op.Wait(ctx)
69 if err != nil {
70 // TODO: Handle error.
71 }
72 // TODO: Use resp.
73 _ = resp
74 }
75
76 func ExampleProvisioningClient_DeleteApiHubInstance() {
77 ctx := context.Background()
78 // This snippet has been automatically generated and should be regarded as a code template only.
79 // It will require modifications to work:
80 // - It may require correct/in-range values for request initialization.
81 // - It may require specifying regional endpoints when creating the service client as shown in:
82 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
83 c, err := apihub.NewProvisioningRESTClient(ctx)
84 if err != nil {
85 // TODO: Handle error.
86 }
87 defer c.Close()
88
89 req := &apihubpb.DeleteApiHubInstanceRequest{
90 // TODO: Fill request struct fields.
91 // See https://pkg.go.dev/cloud.google.com/go/apihub/apiv1/apihubpb#DeleteApiHubInstanceRequest.
92 }
93 op, err := c.DeleteApiHubInstance(ctx, req)
94 if err != nil {
95 // TODO: Handle error.
96 }
97
98 err = op.Wait(ctx)
99 if err != nil {
100 // TODO: Handle error.
101 }
102 }
103
104 func ExampleProvisioningClient_GetApiHubInstance() {
105 ctx := context.Background()
106 // This snippet has been automatically generated and should be regarded as a code template only.
107 // It will require modifications to work:
108 // - It may require correct/in-range values for request initialization.
109 // - It may require specifying regional endpoints when creating the service client as shown in:
110 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
111 c, err := apihub.NewProvisioningRESTClient(ctx)
112 if err != nil {
113 // TODO: Handle error.
114 }
115 defer c.Close()
116
117 req := &apihubpb.GetApiHubInstanceRequest{
118 // TODO: Fill request struct fields.
119 // See https://pkg.go.dev/cloud.google.com/go/apihub/apiv1/apihubpb#GetApiHubInstanceRequest.
120 }
121 resp, err := c.GetApiHubInstance(ctx, req)
122 if err != nil {
123 // TODO: Handle error.
124 }
125 // TODO: Use resp.
126 _ = resp
127 }
128
129 func ExampleProvisioningClient_LookupApiHubInstance() {
130 ctx := context.Background()
131 // This snippet has been automatically generated and should be regarded as a code template only.
132 // It will require modifications to work:
133 // - It may require correct/in-range values for request initialization.
134 // - It may require specifying regional endpoints when creating the service client as shown in:
135 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
136 c, err := apihub.NewProvisioningRESTClient(ctx)
137 if err != nil {
138 // TODO: Handle error.
139 }
140 defer c.Close()
141
142 req := &apihubpb.LookupApiHubInstanceRequest{
143 // TODO: Fill request struct fields.
144 // See https://pkg.go.dev/cloud.google.com/go/apihub/apiv1/apihubpb#LookupApiHubInstanceRequest.
145 }
146 resp, err := c.LookupApiHubInstance(ctx, req)
147 if err != nil {
148 // TODO: Handle error.
149 }
150 // TODO: Use resp.
151 _ = resp
152 }
153
154 func ExampleProvisioningClient_GetLocation() {
155 ctx := context.Background()
156 // This snippet has been automatically generated and should be regarded as a code template only.
157 // It will require modifications to work:
158 // - It may require correct/in-range values for request initialization.
159 // - It may require specifying regional endpoints when creating the service client as shown in:
160 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
161 c, err := apihub.NewProvisioningRESTClient(ctx)
162 if err != nil {
163 // TODO: Handle error.
164 }
165 defer c.Close()
166
167 req := &locationpb.GetLocationRequest{
168 // TODO: Fill request struct fields.
169 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#GetLocationRequest.
170 }
171 resp, err := c.GetLocation(ctx, req)
172 if err != nil {
173 // TODO: Handle error.
174 }
175 // TODO: Use resp.
176 _ = resp
177 }
178
179 func ExampleProvisioningClient_ListLocations() {
180 ctx := context.Background()
181 // This snippet has been automatically generated and should be regarded as a code template only.
182 // It will require modifications to work:
183 // - It may require correct/in-range values for request initialization.
184 // - It may require specifying regional endpoints when creating the service client as shown in:
185 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
186 c, err := apihub.NewProvisioningRESTClient(ctx)
187 if err != nil {
188 // TODO: Handle error.
189 }
190 defer c.Close()
191
192 req := &locationpb.ListLocationsRequest{
193 // TODO: Fill request struct fields.
194 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#ListLocationsRequest.
195 }
196 it := c.ListLocations(ctx, req)
197 for {
198 resp, err := it.Next()
199 if err == iterator.Done {
200 break
201 }
202 if err != nil {
203 // TODO: Handle error.
204 }
205 // TODO: Use resp.
206 _ = resp
207
208 // If you need to access the underlying RPC response,
209 // you can do so by casting the `Response` as below.
210 // Otherwise, remove this line. Only populated after
211 // first call to Next(). Not safe for concurrent access.
212 _ = it.Response.(*locationpb.ListLocationsResponse)
213 }
214 }
215
216 func ExampleProvisioningClient_CancelOperation() {
217 ctx := context.Background()
218 // This snippet has been automatically generated and should be regarded as a code template only.
219 // It will require modifications to work:
220 // - It may require correct/in-range values for request initialization.
221 // - It may require specifying regional endpoints when creating the service client as shown in:
222 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
223 c, err := apihub.NewProvisioningRESTClient(ctx)
224 if err != nil {
225 // TODO: Handle error.
226 }
227 defer c.Close()
228
229 req := &longrunningpb.CancelOperationRequest{
230 // TODO: Fill request struct fields.
231 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#CancelOperationRequest.
232 }
233 err = c.CancelOperation(ctx, req)
234 if err != nil {
235 // TODO: Handle error.
236 }
237 }
238
239 func ExampleProvisioningClient_DeleteOperation() {
240 ctx := context.Background()
241 // This snippet has been automatically generated and should be regarded as a code template only.
242 // It will require modifications to work:
243 // - It may require correct/in-range values for request initialization.
244 // - It may require specifying regional endpoints when creating the service client as shown in:
245 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
246 c, err := apihub.NewProvisioningRESTClient(ctx)
247 if err != nil {
248 // TODO: Handle error.
249 }
250 defer c.Close()
251
252 req := &longrunningpb.DeleteOperationRequest{
253 // TODO: Fill request struct fields.
254 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#DeleteOperationRequest.
255 }
256 err = c.DeleteOperation(ctx, req)
257 if err != nil {
258 // TODO: Handle error.
259 }
260 }
261
262 func ExampleProvisioningClient_GetOperation() {
263 ctx := context.Background()
264 // This snippet has been automatically generated and should be regarded as a code template only.
265 // It will require modifications to work:
266 // - It may require correct/in-range values for request initialization.
267 // - It may require specifying regional endpoints when creating the service client as shown in:
268 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
269 c, err := apihub.NewProvisioningRESTClient(ctx)
270 if err != nil {
271 // TODO: Handle error.
272 }
273 defer c.Close()
274
275 req := &longrunningpb.GetOperationRequest{
276 // TODO: Fill request struct fields.
277 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#GetOperationRequest.
278 }
279 resp, err := c.GetOperation(ctx, req)
280 if err != nil {
281 // TODO: Handle error.
282 }
283 // TODO: Use resp.
284 _ = resp
285 }
286
287 func ExampleProvisioningClient_ListOperations() {
288 ctx := context.Background()
289 // This snippet has been automatically generated and should be regarded as a code template only.
290 // It will require modifications to work:
291 // - It may require correct/in-range values for request initialization.
292 // - It may require specifying regional endpoints when creating the service client as shown in:
293 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
294 c, err := apihub.NewProvisioningRESTClient(ctx)
295 if err != nil {
296 // TODO: Handle error.
297 }
298 defer c.Close()
299
300 req := &longrunningpb.ListOperationsRequest{
301 // TODO: Fill request struct fields.
302 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest.
303 }
304 it := c.ListOperations(ctx, req)
305 for {
306 resp, err := it.Next()
307 if err == iterator.Done {
308 break
309 }
310 if err != nil {
311 // TODO: Handle error.
312 }
313 // TODO: Use resp.
314 _ = resp
315
316 // If you need to access the underlying RPC response,
317 // you can do so by casting the `Response` as below.
318 // Otherwise, remove this line. Only populated after
319 // first call to Next(). Not safe for concurrent access.
320 _ = it.Response.(*longrunningpb.ListOperationsResponse)
321 }
322 }