Debian Codegraph @

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