Debian Codegraph @

streetview/publish/apiv1/street_view_publish_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 publish_test
18
19 import (
20 "context"
21
22 publish "cloud.google.com/go/streetview/publish/apiv1"
23 publishpb "cloud.google.com/go/streetview/publish/apiv1/publishpb"
24 "google.golang.org/api/iterator"
25 emptypb "google.golang.org/protobuf/types/known/emptypb"
26 )
27
28 func ExampleNewStreetViewPublishClient() {
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 := publish.NewStreetViewPublishClient(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 ExampleNewStreetViewPublishRESTClient() {
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 := publish.NewStreetViewPublishRESTClient(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 ExampleStreetViewPublishClient_BatchDeletePhotos() {
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 := publish.NewStreetViewPublishClient(ctx)
70 if err != nil {
71 // TODO: Handle error.
72 }
73 defer c.Close()
74
75 req := &publishpb.BatchDeletePhotosRequest{
76 // TODO: Fill request struct fields.
77 // See https://pkg.go.dev/cloud.google.com/go/streetview/publish/apiv1/publishpb#BatchDeletePhotosRequest.
78 }
79 resp, err := c.BatchDeletePhotos(ctx, req)
80 if err != nil {
81 // TODO: Handle error.
82 }
83 // TODO: Use resp.
84 _ = resp
85 }
86
87 func ExampleStreetViewPublishClient_BatchGetPhotos() {
88 ctx := context.Background()
89 // This snippet has been automatically generated and should be regarded as a code template only.
90 // It will require modifications to work:
91 // - It may require correct/in-range values for request initialization.
92 // - It may require specifying regional endpoints when creating the service client as shown in:
93 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
94 c, err := publish.NewStreetViewPublishClient(ctx)
95 if err != nil {
96 // TODO: Handle error.
97 }
98 defer c.Close()
99
100 req := &publishpb.BatchGetPhotosRequest{
101 // TODO: Fill request struct fields.
102 // See https://pkg.go.dev/cloud.google.com/go/streetview/publish/apiv1/publishpb#BatchGetPhotosRequest.
103 }
104 resp, err := c.BatchGetPhotos(ctx, req)
105 if err != nil {
106 // TODO: Handle error.
107 }
108 // TODO: Use resp.
109 _ = resp
110 }
111
112 func ExampleStreetViewPublishClient_BatchUpdatePhotos() {
113 ctx := context.Background()
114 // This snippet has been automatically generated and should be regarded as a code template only.
115 // It will require modifications to work:
116 // - It may require correct/in-range values for request initialization.
117 // - It may require specifying regional endpoints when creating the service client as shown in:
118 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
119 c, err := publish.NewStreetViewPublishClient(ctx)
120 if err != nil {
121 // TODO: Handle error.
122 }
123 defer c.Close()
124
125 req := &publishpb.BatchUpdatePhotosRequest{
126 // TODO: Fill request struct fields.
127 // See https://pkg.go.dev/cloud.google.com/go/streetview/publish/apiv1/publishpb#BatchUpdatePhotosRequest.
128 }
129 resp, err := c.BatchUpdatePhotos(ctx, req)
130 if err != nil {
131 // TODO: Handle error.
132 }
133 // TODO: Use resp.
134 _ = resp
135 }
136
137 func ExampleStreetViewPublishClient_CreatePhoto() {
138 ctx := context.Background()
139 // This snippet has been automatically generated and should be regarded as a code template only.
140 // It will require modifications to work:
141 // - It may require correct/in-range values for request initialization.
142 // - It may require specifying regional endpoints when creating the service client as shown in:
143 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
144 c, err := publish.NewStreetViewPublishClient(ctx)
145 if err != nil {
146 // TODO: Handle error.
147 }
148 defer c.Close()
149
150 req := &publishpb.CreatePhotoRequest{
151 // TODO: Fill request struct fields.
152 // See https://pkg.go.dev/cloud.google.com/go/streetview/publish/apiv1/publishpb#CreatePhotoRequest.
153 }
154 resp, err := c.CreatePhoto(ctx, req)
155 if err != nil {
156 // TODO: Handle error.
157 }
158 // TODO: Use resp.
159 _ = resp
160 }
161
162 func ExampleStreetViewPublishClient_CreatePhotoSequence() {
163 ctx := context.Background()
164 // This snippet has been automatically generated and should be regarded as a code template only.
165 // It will require modifications to work:
166 // - It may require correct/in-range values for request initialization.
167 // - It may require specifying regional endpoints when creating the service client as shown in:
168 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
169 c, err := publish.NewStreetViewPublishClient(ctx)
170 if err != nil {
171 // TODO: Handle error.
172 }
173 defer c.Close()
174
175 req := &publishpb.CreatePhotoSequenceRequest{
176 // TODO: Fill request struct fields.
177 // See https://pkg.go.dev/cloud.google.com/go/streetview/publish/apiv1/publishpb#CreatePhotoSequenceRequest.
178 }
179 op, err := c.CreatePhotoSequence(ctx, req)
180 if err != nil {
181 // TODO: Handle error.
182 }
183
184 resp, err := op.Wait(ctx)
185 if err != nil {
186 // TODO: Handle error.
187 }
188 // TODO: Use resp.
189 _ = resp
190 }
191
192 func ExampleStreetViewPublishClient_DeletePhoto() {
193 ctx := context.Background()
194 // This snippet has been automatically generated and should be regarded as a code template only.
195 // It will require modifications to work:
196 // - It may require correct/in-range values for request initialization.
197 // - It may require specifying regional endpoints when creating the service client as shown in:
198 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
199 c, err := publish.NewStreetViewPublishClient(ctx)
200 if err != nil {
201 // TODO: Handle error.
202 }
203 defer c.Close()
204
205 req := &publishpb.DeletePhotoRequest{
206 // TODO: Fill request struct fields.
207 // See https://pkg.go.dev/cloud.google.com/go/streetview/publish/apiv1/publishpb#DeletePhotoRequest.
208 }
209 err = c.DeletePhoto(ctx, req)
210 if err != nil {
211 // TODO: Handle error.
212 }
213 }
214
215 func ExampleStreetViewPublishClient_DeletePhotoSequence() {
216 ctx := context.Background()
217 // This snippet has been automatically generated and should be regarded as a code template only.
218 // It will require modifications to work:
219 // - It may require correct/in-range values for request initialization.
220 // - It may require specifying regional endpoints when creating the service client as shown in:
221 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
222 c, err := publish.NewStreetViewPublishClient(ctx)
223 if err != nil {
224 // TODO: Handle error.
225 }
226 defer c.Close()
227
228 req := &publishpb.DeletePhotoSequenceRequest{
229 // TODO: Fill request struct fields.
230 // See https://pkg.go.dev/cloud.google.com/go/streetview/publish/apiv1/publishpb#DeletePhotoSequenceRequest.
231 }
232 err = c.DeletePhotoSequence(ctx, req)
233 if err != nil {
234 // TODO: Handle error.
235 }
236 }
237
238 func ExampleStreetViewPublishClient_GetPhoto() {
239 ctx := context.Background()
240 // This snippet has been automatically generated and should be regarded as a code template only.
241 // It will require modifications to work:
242 // - It may require correct/in-range values for request initialization.
243 // - It may require specifying regional endpoints when creating the service client as shown in:
244 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
245 c, err := publish.NewStreetViewPublishClient(ctx)
246 if err != nil {
247 // TODO: Handle error.
248 }
249 defer c.Close()
250
251 req := &publishpb.GetPhotoRequest{
252 // TODO: Fill request struct fields.
253 // See https://pkg.go.dev/cloud.google.com/go/streetview/publish/apiv1/publishpb#GetPhotoRequest.
254 }
255 resp, err := c.GetPhoto(ctx, req)
256 if err != nil {
257 // TODO: Handle error.
258 }
259 // TODO: Use resp.
260 _ = resp
261 }
262
263 func ExampleStreetViewPublishClient_GetPhotoSequence() {
264 ctx := context.Background()
265 // This snippet has been automatically generated and should be regarded as a code template only.
266 // It will require modifications to work:
267 // - It may require correct/in-range values for request initialization.
268 // - It may require specifying regional endpoints when creating the service client as shown in:
269 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
270 c, err := publish.NewStreetViewPublishClient(ctx)
271 if err != nil {
272 // TODO: Handle error.
273 }
274 defer c.Close()
275
276 req := &publishpb.GetPhotoSequenceRequest{
277 // TODO: Fill request struct fields.
278 // See https://pkg.go.dev/cloud.google.com/go/streetview/publish/apiv1/publishpb#GetPhotoSequenceRequest.
279 }
280 op, err := c.GetPhotoSequence(ctx, req)
281 if err != nil {
282 // TODO: Handle error.
283 }
284
285 resp, err := op.Wait(ctx)
286 if err != nil {
287 // TODO: Handle error.
288 }
289 // TODO: Use resp.
290 _ = resp
291 }
292
293 func ExampleStreetViewPublishClient_ListPhotoSequences() {
294 ctx := context.Background()
295 // This snippet has been automatically generated and should be regarded as a code template only.
296 // It will require modifications to work:
297 // - It may require correct/in-range values for request initialization.
298 // - It may require specifying regional endpoints when creating the service client as shown in:
299 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
300 c, err := publish.NewStreetViewPublishClient(ctx)
301 if err != nil {
302 // TODO: Handle error.
303 }
304 defer c.Close()
305
306 req := &publishpb.ListPhotoSequencesRequest{
307 // TODO: Fill request struct fields.
308 // See https://pkg.go.dev/cloud.google.com/go/streetview/publish/apiv1/publishpb#ListPhotoSequencesRequest.
309 }
310 it := c.ListPhotoSequences(ctx, req)
311 for {
312 resp, err := it.Next()
313 if err == iterator.Done {
314 break
315 }
316 if err != nil {
317 // TODO: Handle error.
318 }
319 // TODO: Use resp.
320 _ = resp
321
322 // If you need to access the underlying RPC response,
323 // you can do so by casting the `Response` as below.
324 // Otherwise, remove this line. Only populated after
325 // first call to Next(). Not safe for concurrent access.
326 _ = it.Response.(*publishpb.ListPhotoSequencesResponse)
327 }
328 }
329
330 func ExampleStreetViewPublishClient_ListPhotos() {
331 ctx := context.Background()
332 // This snippet has been automatically generated and should be regarded as a code template only.
333 // It will require modifications to work:
334 // - It may require correct/in-range values for request initialization.
335 // - It may require specifying regional endpoints when creating the service client as shown in:
336 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
337 c, err := publish.NewStreetViewPublishClient(ctx)
338 if err != nil {
339 // TODO: Handle error.
340 }
341 defer c.Close()
342
343 req := &publishpb.ListPhotosRequest{
344 // TODO: Fill request struct fields.
345 // See https://pkg.go.dev/cloud.google.com/go/streetview/publish/apiv1/publishpb#ListPhotosRequest.
346 }
347 it := c.ListPhotos(ctx, req)
348 for {
349 resp, err := it.Next()
350 if err == iterator.Done {
351 break
352 }
353 if err != nil {
354 // TODO: Handle error.
355 }
356 // TODO: Use resp.
357 _ = resp
358
359 // If you need to access the underlying RPC response,
360 // you can do so by casting the `Response` as below.
361 // Otherwise, remove this line. Only populated after
362 // first call to Next(). Not safe for concurrent access.
363 _ = it.Response.(*publishpb.ListPhotosResponse)
364 }
365 }
366
367 func ExampleStreetViewPublishClient_StartPhotoSequenceUpload() {
368 ctx := context.Background()
369 // This snippet has been automatically generated and should be regarded as a code template only.
370 // It will require modifications to work:
371 // - It may require correct/in-range values for request initialization.
372 // - It may require specifying regional endpoints when creating the service client as shown in:
373 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
374 c, err := publish.NewStreetViewPublishClient(ctx)
375 if err != nil {
376 // TODO: Handle error.
377 }
378 defer c.Close()
379
380 req := &emptypb.Empty{
381 // TODO: Fill request struct fields.
382 // See https://pkg.go.dev/google.golang.org/protobuf/types/known/emptypb#Empty.
383 }
384 resp, err := c.StartPhotoSequenceUpload(ctx, req)
385 if err != nil {
386 // TODO: Handle error.
387 }
388 // TODO: Use resp.
389 _ = resp
390 }
391
392 func ExampleStreetViewPublishClient_StartUpload() {
393 ctx := context.Background()
394 // This snippet has been automatically generated and should be regarded as a code template only.
395 // It will require modifications to work:
396 // - It may require correct/in-range values for request initialization.
397 // - It may require specifying regional endpoints when creating the service client as shown in:
398 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
399 c, err := publish.NewStreetViewPublishClient(ctx)
400 if err != nil {
401 // TODO: Handle error.
402 }
403 defer c.Close()
404
405 req := &emptypb.Empty{
406 // TODO: Fill request struct fields.
407 // See https://pkg.go.dev/google.golang.org/protobuf/types/known/emptypb#Empty.
408 }
409 resp, err := c.StartUpload(ctx, req)
410 if err != nil {
411 // TODO: Handle error.
412 }
413 // TODO: Use resp.
414 _ = resp
415 }
416
417 func ExampleStreetViewPublishClient_UpdatePhoto() {
418 ctx := context.Background()
419 // This snippet has been automatically generated and should be regarded as a code template only.
420 // It will require modifications to work:
421 // - It may require correct/in-range values for request initialization.
422 // - It may require specifying regional endpoints when creating the service client as shown in:
423 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
424 c, err := publish.NewStreetViewPublishClient(ctx)
425 if err != nil {
426 // TODO: Handle error.
427 }
428 defer c.Close()
429
430 req := &publishpb.UpdatePhotoRequest{
431 // TODO: Fill request struct fields.
432 // See https://pkg.go.dev/cloud.google.com/go/streetview/publish/apiv1/publishpb#UpdatePhotoRequest.
433 }
434 resp, err := c.UpdatePhoto(ctx, req)
435 if err != nil {
436 // TODO: Handle error.
437 }
438 // TODO: Use resp.
439 _ = resp
440 }