Debian Codegraph @

locationfinder/apiv1/cloud_location_finder_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 locationfinder_test
18
19 import (
20 "context"
21
22 locationfinder "cloud.google.com/go/locationfinder/apiv1"
23 locationfinderpb "cloud.google.com/go/locationfinder/apiv1/locationfinderpb"
24 "google.golang.org/api/iterator"
25 locationpb "google.golang.org/genproto/googleapis/cloud/location"
26 )
27
28 func ExampleNewCloudLocationFinderClient() {
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 := locationfinder.NewCloudLocationFinderClient(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 ExampleNewCloudLocationFinderRESTClient() {
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 := locationfinder.NewCloudLocationFinderRESTClient(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 ExampleCloudLocationFinderClient_GetCloudLocation() {
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 := locationfinder.NewCloudLocationFinderClient(ctx)
70 if err != nil {
71 // TODO: Handle error.
72 }
73 defer c.Close()
74
75 req := &locationfinderpb.GetCloudLocationRequest{
76 // TODO: Fill request struct fields.
77 // See https://pkg.go.dev/cloud.google.com/go/locationfinder/apiv1/locationfinderpb#GetCloudLocationRequest.
78 }
79 resp, err := c.GetCloudLocation(ctx, req)
80 if err != nil {
81 // TODO: Handle error.
82 }
83 // TODO: Use resp.
84 _ = resp
85 }
86
87 func ExampleCloudLocationFinderClient_ListCloudLocations() {
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 := locationfinder.NewCloudLocationFinderClient(ctx)
95 if err != nil {
96 // TODO: Handle error.
97 }
98 defer c.Close()
99
100 req := &locationfinderpb.ListCloudLocationsRequest{
101 // TODO: Fill request struct fields.
102 // See https://pkg.go.dev/cloud.google.com/go/locationfinder/apiv1/locationfinderpb#ListCloudLocationsRequest.
103 }
104 it := c.ListCloudLocations(ctx, req)
105 for {
106 resp, err := it.Next()
107 if err == iterator.Done {
108 break
109 }
110 if err != nil {
111 // TODO: Handle error.
112 }
113 // TODO: Use resp.
114 _ = resp
115
116 // If you need to access the underlying RPC response,
117 // you can do so by casting the `Response` as below.
118 // Otherwise, remove this line. Only populated after
119 // first call to Next(). Not safe for concurrent access.
120 _ = it.Response.(*locationfinderpb.ListCloudLocationsResponse)
121 }
122 }
123
124 func ExampleCloudLocationFinderClient_SearchCloudLocations() {
125 ctx := context.Background()
126 // This snippet has been automatically generated and should be regarded as a code template only.
127 // It will require modifications to work:
128 // - It may require correct/in-range values for request initialization.
129 // - It may require specifying regional endpoints when creating the service client as shown in:
130 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
131 c, err := locationfinder.NewCloudLocationFinderClient(ctx)
132 if err != nil {
133 // TODO: Handle error.
134 }
135 defer c.Close()
136
137 req := &locationfinderpb.SearchCloudLocationsRequest{
138 // TODO: Fill request struct fields.
139 // See https://pkg.go.dev/cloud.google.com/go/locationfinder/apiv1/locationfinderpb#SearchCloudLocationsRequest.
140 }
141 it := c.SearchCloudLocations(ctx, req)
142 for {
143 resp, err := it.Next()
144 if err == iterator.Done {
145 break
146 }
147 if err != nil {
148 // TODO: Handle error.
149 }
150 // TODO: Use resp.
151 _ = resp
152
153 // If you need to access the underlying RPC response,
154 // you can do so by casting the `Response` as below.
155 // Otherwise, remove this line. Only populated after
156 // first call to Next(). Not safe for concurrent access.
157 _ = it.Response.(*locationfinderpb.SearchCloudLocationsResponse)
158 }
159 }
160
161 func ExampleCloudLocationFinderClient_GetLocation() {
162 ctx := context.Background()
163 // This snippet has been automatically generated and should be regarded as a code template only.
164 // It will require modifications to work:
165 // - It may require correct/in-range values for request initialization.
166 // - It may require specifying regional endpoints when creating the service client as shown in:
167 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
168 c, err := locationfinder.NewCloudLocationFinderClient(ctx)
169 if err != nil {
170 // TODO: Handle error.
171 }
172 defer c.Close()
173
174 req := &locationpb.GetLocationRequest{
175 // TODO: Fill request struct fields.
176 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#GetLocationRequest.
177 }
178 resp, err := c.GetLocation(ctx, req)
179 if err != nil {
180 // TODO: Handle error.
181 }
182 // TODO: Use resp.
183 _ = resp
184 }
185
186 func ExampleCloudLocationFinderClient_ListLocations() {
187 ctx := context.Background()
188 // This snippet has been automatically generated and should be regarded as a code template only.
189 // It will require modifications to work:
190 // - It may require correct/in-range values for request initialization.
191 // - It may require specifying regional endpoints when creating the service client as shown in:
192 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
193 c, err := locationfinder.NewCloudLocationFinderClient(ctx)
194 if err != nil {
195 // TODO: Handle error.
196 }
197 defer c.Close()
198
199 req := &locationpb.ListLocationsRequest{
200 // TODO: Fill request struct fields.
201 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#ListLocationsRequest.
202 }
203 it := c.ListLocations(ctx, req)
204 for {
205 resp, err := it.Next()
206 if err == iterator.Done {
207 break
208 }
209 if err != nil {
210 // TODO: Handle error.
211 }
212 // TODO: Use resp.
213 _ = resp
214
215 // If you need to access the underlying RPC response,
216 // you can do so by casting the `Response` as below.
217 // Otherwise, remove this line. Only populated after
218 // first call to Next(). Not safe for concurrent access.
219 _ = it.Response.(*locationpb.ListLocationsResponse)
220 }
221 }