Debian Codegraph @

lustre/apiv1/lustre_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 lustre_test
18
19 import (
20 "context"
21
22 longrunningpb "cloud.google.com/go/longrunning/autogen/longrunningpb"
23 lustre "cloud.google.com/go/lustre/apiv1"
24 lustrepb "cloud.google.com/go/lustre/apiv1/lustrepb"
25 "google.golang.org/api/iterator"
26 locationpb "google.golang.org/genproto/googleapis/cloud/location"
27 )
28
29 func ExampleNewClient() {
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 := lustre.NewClient(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 ExampleNewRESTClient() {
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 := lustre.NewRESTClient(ctx)
54 if err != nil {
55 // TODO: Handle error.
56 }
57 defer c.Close()
58
59 // TODO: Use client.
60 _ = c
61 }
62
63 func ExampleClient_CreateInstance() {
64 ctx := context.Background()
65 // This snippet has been automatically generated and should be regarded as a code template only.
66 // It will require modifications to work:
67 // - It may require correct/in-range values for request initialization.
68 // - It may require specifying regional endpoints when creating the service client as shown in:
69 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
70 c, err := lustre.NewClient(ctx)
71 if err != nil {
72 // TODO: Handle error.
73 }
74 defer c.Close()
75
76 req := &lustrepb.CreateInstanceRequest{
77 // TODO: Fill request struct fields.
78 // See https://pkg.go.dev/cloud.google.com/go/lustre/apiv1/lustrepb#CreateInstanceRequest.
79 }
80 op, err := c.CreateInstance(ctx, req)
81 if err != nil {
82 // TODO: Handle error.
83 }
84
85 resp, err := op.Wait(ctx)
86 if err != nil {
87 // TODO: Handle error.
88 }
89 // TODO: Use resp.
90 _ = resp
91 }
92
93 func ExampleClient_DeleteInstance() {
94 ctx := context.Background()
95 // This snippet has been automatically generated and should be regarded as a code template only.
96 // It will require modifications to work:
97 // - It may require correct/in-range values for request initialization.
98 // - It may require specifying regional endpoints when creating the service client as shown in:
99 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
100 c, err := lustre.NewClient(ctx)
101 if err != nil {
102 // TODO: Handle error.
103 }
104 defer c.Close()
105
106 req := &lustrepb.DeleteInstanceRequest{
107 // TODO: Fill request struct fields.
108 // See https://pkg.go.dev/cloud.google.com/go/lustre/apiv1/lustrepb#DeleteInstanceRequest.
109 }
110 op, err := c.DeleteInstance(ctx, req)
111 if err != nil {
112 // TODO: Handle error.
113 }
114
115 err = op.Wait(ctx)
116 if err != nil {
117 // TODO: Handle error.
118 }
119 }
120
121 func ExampleClient_ExportData() {
122 ctx := context.Background()
123 // This snippet has been automatically generated and should be regarded as a code template only.
124 // It will require modifications to work:
125 // - It may require correct/in-range values for request initialization.
126 // - It may require specifying regional endpoints when creating the service client as shown in:
127 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
128 c, err := lustre.NewClient(ctx)
129 if err != nil {
130 // TODO: Handle error.
131 }
132 defer c.Close()
133
134 req := &lustrepb.ExportDataRequest{
135 // TODO: Fill request struct fields.
136 // See https://pkg.go.dev/cloud.google.com/go/lustre/apiv1/lustrepb#ExportDataRequest.
137 }
138 op, err := c.ExportData(ctx, req)
139 if err != nil {
140 // TODO: Handle error.
141 }
142
143 resp, err := op.Wait(ctx)
144 if err != nil {
145 // TODO: Handle error.
146 }
147 // TODO: Use resp.
148 _ = resp
149 }
150
151 func ExampleClient_GetInstance() {
152 ctx := context.Background()
153 // This snippet has been automatically generated and should be regarded as a code template only.
154 // It will require modifications to work:
155 // - It may require correct/in-range values for request initialization.
156 // - It may require specifying regional endpoints when creating the service client as shown in:
157 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
158 c, err := lustre.NewClient(ctx)
159 if err != nil {
160 // TODO: Handle error.
161 }
162 defer c.Close()
163
164 req := &lustrepb.GetInstanceRequest{
165 // TODO: Fill request struct fields.
166 // See https://pkg.go.dev/cloud.google.com/go/lustre/apiv1/lustrepb#GetInstanceRequest.
167 }
168 resp, err := c.GetInstance(ctx, req)
169 if err != nil {
170 // TODO: Handle error.
171 }
172 // TODO: Use resp.
173 _ = resp
174 }
175
176 func ExampleClient_ImportData() {
177 ctx := context.Background()
178 // This snippet has been automatically generated and should be regarded as a code template only.
179 // It will require modifications to work:
180 // - It may require correct/in-range values for request initialization.
181 // - It may require specifying regional endpoints when creating the service client as shown in:
182 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
183 c, err := lustre.NewClient(ctx)
184 if err != nil {
185 // TODO: Handle error.
186 }
187 defer c.Close()
188
189 req := &lustrepb.ImportDataRequest{
190 // TODO: Fill request struct fields.
191 // See https://pkg.go.dev/cloud.google.com/go/lustre/apiv1/lustrepb#ImportDataRequest.
192 }
193 op, err := c.ImportData(ctx, req)
194 if err != nil {
195 // TODO: Handle error.
196 }
197
198 resp, err := op.Wait(ctx)
199 if err != nil {
200 // TODO: Handle error.
201 }
202 // TODO: Use resp.
203 _ = resp
204 }
205
206 func ExampleClient_ListInstances() {
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 := lustre.NewClient(ctx)
214 if err != nil {
215 // TODO: Handle error.
216 }
217 defer c.Close()
218
219 req := &lustrepb.ListInstancesRequest{
220 // TODO: Fill request struct fields.
221 // See https://pkg.go.dev/cloud.google.com/go/lustre/apiv1/lustrepb#ListInstancesRequest.
222 }
223 it := c.ListInstances(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.(*lustrepb.ListInstancesResponse)
240 }
241 }
242
243 func ExampleClient_UpdateInstance() {
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 := lustre.NewClient(ctx)
251 if err != nil {
252 // TODO: Handle error.
253 }
254 defer c.Close()
255
256 req := &lustrepb.UpdateInstanceRequest{
257 // TODO: Fill request struct fields.
258 // See https://pkg.go.dev/cloud.google.com/go/lustre/apiv1/lustrepb#UpdateInstanceRequest.
259 }
260 op, err := c.UpdateInstance(ctx, req)
261 if err != nil {
262 // TODO: Handle error.
263 }
264
265 resp, err := op.Wait(ctx)
266 if err != nil {
267 // TODO: Handle error.
268 }
269 // TODO: Use resp.
270 _ = resp
271 }
272
273 func ExampleClient_GetLocation() {
274 ctx := context.Background()
275 // This snippet has been automatically generated and should be regarded as a code template only.
276 // It will require modifications to work:
277 // - It may require correct/in-range values for request initialization.
278 // - It may require specifying regional endpoints when creating the service client as shown in:
279 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
280 c, err := lustre.NewClient(ctx)
281 if err != nil {
282 // TODO: Handle error.
283 }
284 defer c.Close()
285
286 req := &locationpb.GetLocationRequest{
287 // TODO: Fill request struct fields.
288 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#GetLocationRequest.
289 }
290 resp, err := c.GetLocation(ctx, req)
291 if err != nil {
292 // TODO: Handle error.
293 }
294 // TODO: Use resp.
295 _ = resp
296 }
297
298 func ExampleClient_ListLocations() {
299 ctx := context.Background()
300 // This snippet has been automatically generated and should be regarded as a code template only.
301 // It will require modifications to work:
302 // - It may require correct/in-range values for request initialization.
303 // - It may require specifying regional endpoints when creating the service client as shown in:
304 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
305 c, err := lustre.NewClient(ctx)
306 if err != nil {
307 // TODO: Handle error.
308 }
309 defer c.Close()
310
311 req := &locationpb.ListLocationsRequest{
312 // TODO: Fill request struct fields.
313 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#ListLocationsRequest.
314 }
315 it := c.ListLocations(ctx, req)
316 for {
317 resp, err := it.Next()
318 if err == iterator.Done {
319 break
320 }
321 if err != nil {
322 // TODO: Handle error.
323 }
324 // TODO: Use resp.
325 _ = resp
326
327 // If you need to access the underlying RPC response,
328 // you can do so by casting the `Response` as below.
329 // Otherwise, remove this line. Only populated after
330 // first call to Next(). Not safe for concurrent access.
331 _ = it.Response.(*locationpb.ListLocationsResponse)
332 }
333 }
334
335 func ExampleClient_CancelOperation() {
336 ctx := context.Background()
337 // This snippet has been automatically generated and should be regarded as a code template only.
338 // It will require modifications to work:
339 // - It may require correct/in-range values for request initialization.
340 // - It may require specifying regional endpoints when creating the service client as shown in:
341 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
342 c, err := lustre.NewClient(ctx)
343 if err != nil {
344 // TODO: Handle error.
345 }
346 defer c.Close()
347
348 req := &longrunningpb.CancelOperationRequest{
349 // TODO: Fill request struct fields.
350 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#CancelOperationRequest.
351 }
352 err = c.CancelOperation(ctx, req)
353 if err != nil {
354 // TODO: Handle error.
355 }
356 }
357
358 func ExampleClient_DeleteOperation() {
359 ctx := context.Background()
360 // This snippet has been automatically generated and should be regarded as a code template only.
361 // It will require modifications to work:
362 // - It may require correct/in-range values for request initialization.
363 // - It may require specifying regional endpoints when creating the service client as shown in:
364 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
365 c, err := lustre.NewClient(ctx)
366 if err != nil {
367 // TODO: Handle error.
368 }
369 defer c.Close()
370
371 req := &longrunningpb.DeleteOperationRequest{
372 // TODO: Fill request struct fields.
373 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#DeleteOperationRequest.
374 }
375 err = c.DeleteOperation(ctx, req)
376 if err != nil {
377 // TODO: Handle error.
378 }
379 }
380
381 func ExampleClient_GetOperation() {
382 ctx := context.Background()
383 // This snippet has been automatically generated and should be regarded as a code template only.
384 // It will require modifications to work:
385 // - It may require correct/in-range values for request initialization.
386 // - It may require specifying regional endpoints when creating the service client as shown in:
387 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
388 c, err := lustre.NewClient(ctx)
389 if err != nil {
390 // TODO: Handle error.
391 }
392 defer c.Close()
393
394 req := &longrunningpb.GetOperationRequest{
395 // TODO: Fill request struct fields.
396 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#GetOperationRequest.
397 }
398 resp, err := c.GetOperation(ctx, req)
399 if err != nil {
400 // TODO: Handle error.
401 }
402 // TODO: Use resp.
403 _ = resp
404 }
405
406 func ExampleClient_ListOperations() {
407 ctx := context.Background()
408 // This snippet has been automatically generated and should be regarded as a code template only.
409 // It will require modifications to work:
410 // - It may require correct/in-range values for request initialization.
411 // - It may require specifying regional endpoints when creating the service client as shown in:
412 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
413 c, err := lustre.NewClient(ctx)
414 if err != nil {
415 // TODO: Handle error.
416 }
417 defer c.Close()
418
419 req := &longrunningpb.ListOperationsRequest{
420 // TODO: Fill request struct fields.
421 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest.
422 }
423 it := c.ListOperations(ctx, req)
424 for {
425 resp, err := it.Next()
426 if err == iterator.Done {
427 break
428 }
429 if err != nil {
430 // TODO: Handle error.
431 }
432 // TODO: Use resp.
433 _ = resp
434
435 // If you need to access the underlying RPC response,
436 // you can do so by casting the `Response` as below.
437 // Otherwise, remove this line. Only populated after
438 // first call to Next(). Not safe for concurrent access.
439 _ = it.Response.(*longrunningpb.ListOperationsResponse)
440 }
441 }