Debian Codegraph @

apihub/apiv1/api_hub_dependencies_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 ExampleNewApiHubDependenciesRESTClient() {
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.NewApiHubDependenciesRESTClient(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 ExampleApiHubDependenciesClient_CreateDependency() {
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.NewApiHubDependenciesRESTClient(ctx)
54 if err != nil {
55 // TODO: Handle error.
56 }
57 defer c.Close()
58
59 req := &apihubpb.CreateDependencyRequest{
60 // TODO: Fill request struct fields.
61 // See https://pkg.go.dev/cloud.google.com/go/apihub/apiv1/apihubpb#CreateDependencyRequest.
62 }
63 resp, err := c.CreateDependency(ctx, req)
64 if err != nil {
65 // TODO: Handle error.
66 }
67 // TODO: Use resp.
68 _ = resp
69 }
70
71 func ExampleApiHubDependenciesClient_DeleteDependency() {
72 ctx := context.Background()
73 // This snippet has been automatically generated and should be regarded as a code template only.
74 // It will require modifications to work:
75 // - It may require correct/in-range values for request initialization.
76 // - It may require specifying regional endpoints when creating the service client as shown in:
77 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
78 c, err := apihub.NewApiHubDependenciesRESTClient(ctx)
79 if err != nil {
80 // TODO: Handle error.
81 }
82 defer c.Close()
83
84 req := &apihubpb.DeleteDependencyRequest{
85 // TODO: Fill request struct fields.
86 // See https://pkg.go.dev/cloud.google.com/go/apihub/apiv1/apihubpb#DeleteDependencyRequest.
87 }
88 err = c.DeleteDependency(ctx, req)
89 if err != nil {
90 // TODO: Handle error.
91 }
92 }
93
94 func ExampleApiHubDependenciesClient_GetDependency() {
95 ctx := context.Background()
96 // This snippet has been automatically generated and should be regarded as a code template only.
97 // It will require modifications to work:
98 // - It may require correct/in-range values for request initialization.
99 // - It may require specifying regional endpoints when creating the service client as shown in:
100 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
101 c, err := apihub.NewApiHubDependenciesRESTClient(ctx)
102 if err != nil {
103 // TODO: Handle error.
104 }
105 defer c.Close()
106
107 req := &apihubpb.GetDependencyRequest{
108 // TODO: Fill request struct fields.
109 // See https://pkg.go.dev/cloud.google.com/go/apihub/apiv1/apihubpb#GetDependencyRequest.
110 }
111 resp, err := c.GetDependency(ctx, req)
112 if err != nil {
113 // TODO: Handle error.
114 }
115 // TODO: Use resp.
116 _ = resp
117 }
118
119 func ExampleApiHubDependenciesClient_ListDependencies() {
120 ctx := context.Background()
121 // This snippet has been automatically generated and should be regarded as a code template only.
122 // It will require modifications to work:
123 // - It may require correct/in-range values for request initialization.
124 // - It may require specifying regional endpoints when creating the service client as shown in:
125 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
126 c, err := apihub.NewApiHubDependenciesRESTClient(ctx)
127 if err != nil {
128 // TODO: Handle error.
129 }
130 defer c.Close()
131
132 req := &apihubpb.ListDependenciesRequest{
133 // TODO: Fill request struct fields.
134 // See https://pkg.go.dev/cloud.google.com/go/apihub/apiv1/apihubpb#ListDependenciesRequest.
135 }
136 it := c.ListDependencies(ctx, req)
137 for {
138 resp, err := it.Next()
139 if err == iterator.Done {
140 break
141 }
142 if err != nil {
143 // TODO: Handle error.
144 }
145 // TODO: Use resp.
146 _ = resp
147
148 // If you need to access the underlying RPC response,
149 // you can do so by casting the `Response` as below.
150 // Otherwise, remove this line. Only populated after
151 // first call to Next(). Not safe for concurrent access.
152 _ = it.Response.(*apihubpb.ListDependenciesResponse)
153 }
154 }
155
156 func ExampleApiHubDependenciesClient_UpdateDependency() {
157 ctx := context.Background()
158 // This snippet has been automatically generated and should be regarded as a code template only.
159 // It will require modifications to work:
160 // - It may require correct/in-range values for request initialization.
161 // - It may require specifying regional endpoints when creating the service client as shown in:
162 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
163 c, err := apihub.NewApiHubDependenciesRESTClient(ctx)
164 if err != nil {
165 // TODO: Handle error.
166 }
167 defer c.Close()
168
169 req := &apihubpb.UpdateDependencyRequest{
170 // TODO: Fill request struct fields.
171 // See https://pkg.go.dev/cloud.google.com/go/apihub/apiv1/apihubpb#UpdateDependencyRequest.
172 }
173 resp, err := c.UpdateDependency(ctx, req)
174 if err != nil {
175 // TODO: Handle error.
176 }
177 // TODO: Use resp.
178 _ = resp
179 }
180
181 func ExampleApiHubDependenciesClient_GetLocation() {
182 ctx := context.Background()
183 // This snippet has been automatically generated and should be regarded as a code template only.
184 // It will require modifications to work:
185 // - It may require correct/in-range values for request initialization.
186 // - It may require specifying regional endpoints when creating the service client as shown in:
187 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
188 c, err := apihub.NewApiHubDependenciesRESTClient(ctx)
189 if err != nil {
190 // TODO: Handle error.
191 }
192 defer c.Close()
193
194 req := &locationpb.GetLocationRequest{
195 // TODO: Fill request struct fields.
196 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#GetLocationRequest.
197 }
198 resp, err := c.GetLocation(ctx, req)
199 if err != nil {
200 // TODO: Handle error.
201 }
202 // TODO: Use resp.
203 _ = resp
204 }
205
206 func ExampleApiHubDependenciesClient_ListLocations() {
207 ctx := context.Background()
208 // This snippet has been automatically generated and should be regarded as a code template only.
209 // It will require modifications to work:
210 // - It may require correct/in-range values for request initialization.
211 // - It may require specifying regional endpoints when creating the service client as shown in:
212 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
213 c, err := apihub.NewApiHubDependenciesRESTClient(ctx)
214 if err != nil {
215 // TODO: Handle error.
216 }
217 defer c.Close()
218
219 req := &locationpb.ListLocationsRequest{
220 // TODO: Fill request struct fields.
221 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#ListLocationsRequest.
222 }
223 it := c.ListLocations(ctx, req)
224 for {
225 resp, err := it.Next()
226 if err == iterator.Done {
227 break
228 }
229 if err != nil {
230 // TODO: Handle error.
231 }
232 // TODO: Use resp.
233 _ = resp
234
235 // If you need to access the underlying RPC response,
236 // you can do so by casting the `Response` as below.
237 // Otherwise, remove this line. Only populated after
238 // first call to Next(). Not safe for concurrent access.
239 _ = it.Response.(*locationpb.ListLocationsResponse)
240 }
241 }
242
243 func ExampleApiHubDependenciesClient_CancelOperation() {
244 ctx := context.Background()
245 // This snippet has been automatically generated and should be regarded as a code template only.
246 // It will require modifications to work:
247 // - It may require correct/in-range values for request initialization.
248 // - It may require specifying regional endpoints when creating the service client as shown in:
249 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
250 c, err := apihub.NewApiHubDependenciesRESTClient(ctx)
251 if err != nil {
252 // TODO: Handle error.
253 }
254 defer c.Close()
255
256 req := &longrunningpb.CancelOperationRequest{
257 // TODO: Fill request struct fields.
258 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#CancelOperationRequest.
259 }
260 err = c.CancelOperation(ctx, req)
261 if err != nil {
262 // TODO: Handle error.
263 }
264 }
265
266 func ExampleApiHubDependenciesClient_DeleteOperation() {
267 ctx := context.Background()
268 // This snippet has been automatically generated and should be regarded as a code template only.
269 // It will require modifications to work:
270 // - It may require correct/in-range values for request initialization.
271 // - It may require specifying regional endpoints when creating the service client as shown in:
272 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
273 c, err := apihub.NewApiHubDependenciesRESTClient(ctx)
274 if err != nil {
275 // TODO: Handle error.
276 }
277 defer c.Close()
278
279 req := &longrunningpb.DeleteOperationRequest{
280 // TODO: Fill request struct fields.
281 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#DeleteOperationRequest.
282 }
283 err = c.DeleteOperation(ctx, req)
284 if err != nil {
285 // TODO: Handle error.
286 }
287 }
288
289 func ExampleApiHubDependenciesClient_GetOperation() {
290 ctx := context.Background()
291 // This snippet has been automatically generated and should be regarded as a code template only.
292 // It will require modifications to work:
293 // - It may require correct/in-range values for request initialization.
294 // - It may require specifying regional endpoints when creating the service client as shown in:
295 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
296 c, err := apihub.NewApiHubDependenciesRESTClient(ctx)
297 if err != nil {
298 // TODO: Handle error.
299 }
300 defer c.Close()
301
302 req := &longrunningpb.GetOperationRequest{
303 // TODO: Fill request struct fields.
304 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#GetOperationRequest.
305 }
306 resp, err := c.GetOperation(ctx, req)
307 if err != nil {
308 // TODO: Handle error.
309 }
310 // TODO: Use resp.
311 _ = resp
312 }
313
314 func ExampleApiHubDependenciesClient_ListOperations() {
315 ctx := context.Background()
316 // This snippet has been automatically generated and should be regarded as a code template only.
317 // It will require modifications to work:
318 // - It may require correct/in-range values for request initialization.
319 // - It may require specifying regional endpoints when creating the service client as shown in:
320 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
321 c, err := apihub.NewApiHubDependenciesRESTClient(ctx)
322 if err != nil {
323 // TODO: Handle error.
324 }
325 defer c.Close()
326
327 req := &longrunningpb.ListOperationsRequest{
328 // TODO: Fill request struct fields.
329 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest.
330 }
331 it := c.ListOperations(ctx, req)
332 for {
333 resp, err := it.Next()
334 if err == iterator.Done {
335 break
336 }
337 if err != nil {
338 // TODO: Handle error.
339 }
340 // TODO: Use resp.
341 _ = resp
342
343 // If you need to access the underlying RPC response,
344 // you can do so by casting the `Response` as below.
345 // Otherwise, remove this line. Only populated after
346 // first call to Next(). Not safe for concurrent access.
347 _ = it.Response.(*longrunningpb.ListOperationsResponse)
348 }
349 }