Debian Codegraph @

apihub/apiv1/host_project_registration_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 ExampleNewHostProjectRegistrationRESTClient() {
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.NewHostProjectRegistrationRESTClient(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 ExampleHostProjectRegistrationClient_CreateHostProjectRegistration() {
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.NewHostProjectRegistrationRESTClient(ctx)
54 if err != nil {
55 // TODO: Handle error.
56 }
57 defer c.Close()
58
59 req := &apihubpb.CreateHostProjectRegistrationRequest{
60 // TODO: Fill request struct fields.
61 // See https://pkg.go.dev/cloud.google.com/go/apihub/apiv1/apihubpb#CreateHostProjectRegistrationRequest.
62 }
63 resp, err := c.CreateHostProjectRegistration(ctx, req)
64 if err != nil {
65 // TODO: Handle error.
66 }
67 // TODO: Use resp.
68 _ = resp
69 }
70
71 func ExampleHostProjectRegistrationClient_GetHostProjectRegistration() {
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.NewHostProjectRegistrationRESTClient(ctx)
79 if err != nil {
80 // TODO: Handle error.
81 }
82 defer c.Close()
83
84 req := &apihubpb.GetHostProjectRegistrationRequest{
85 // TODO: Fill request struct fields.
86 // See https://pkg.go.dev/cloud.google.com/go/apihub/apiv1/apihubpb#GetHostProjectRegistrationRequest.
87 }
88 resp, err := c.GetHostProjectRegistration(ctx, req)
89 if err != nil {
90 // TODO: Handle error.
91 }
92 // TODO: Use resp.
93 _ = resp
94 }
95
96 func ExampleHostProjectRegistrationClient_ListHostProjectRegistrations() {
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.NewHostProjectRegistrationRESTClient(ctx)
104 if err != nil {
105 // TODO: Handle error.
106 }
107 defer c.Close()
108
109 req := &apihubpb.ListHostProjectRegistrationsRequest{
110 // TODO: Fill request struct fields.
111 // See https://pkg.go.dev/cloud.google.com/go/apihub/apiv1/apihubpb#ListHostProjectRegistrationsRequest.
112 }
113 it := c.ListHostProjectRegistrations(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.ListHostProjectRegistrationsResponse)
130 }
131 }
132
133 func ExampleHostProjectRegistrationClient_GetLocation() {
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.NewHostProjectRegistrationRESTClient(ctx)
141 if err != nil {
142 // TODO: Handle error.
143 }
144 defer c.Close()
145
146 req := &locationpb.GetLocationRequest{
147 // TODO: Fill request struct fields.
148 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#GetLocationRequest.
149 }
150 resp, err := c.GetLocation(ctx, req)
151 if err != nil {
152 // TODO: Handle error.
153 }
154 // TODO: Use resp.
155 _ = resp
156 }
157
158 func ExampleHostProjectRegistrationClient_ListLocations() {
159 ctx := context.Background()
160 // This snippet has been automatically generated and should be regarded as a code template only.
161 // It will require modifications to work:
162 // - It may require correct/in-range values for request initialization.
163 // - It may require specifying regional endpoints when creating the service client as shown in:
164 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
165 c, err := apihub.NewHostProjectRegistrationRESTClient(ctx)
166 if err != nil {
167 // TODO: Handle error.
168 }
169 defer c.Close()
170
171 req := &locationpb.ListLocationsRequest{
172 // TODO: Fill request struct fields.
173 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/cloud/location#ListLocationsRequest.
174 }
175 it := c.ListLocations(ctx, req)
176 for {
177 resp, err := it.Next()
178 if err == iterator.Done {
179 break
180 }
181 if err != nil {
182 // TODO: Handle error.
183 }
184 // TODO: Use resp.
185 _ = resp
186
187 // If you need to access the underlying RPC response,
188 // you can do so by casting the `Response` as below.
189 // Otherwise, remove this line. Only populated after
190 // first call to Next(). Not safe for concurrent access.
191 _ = it.Response.(*locationpb.ListLocationsResponse)
192 }
193 }
194
195 func ExampleHostProjectRegistrationClient_CancelOperation() {
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.NewHostProjectRegistrationRESTClient(ctx)
203 if err != nil {
204 // TODO: Handle error.
205 }
206 defer c.Close()
207
208 req := &longrunningpb.CancelOperationRequest{
209 // TODO: Fill request struct fields.
210 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#CancelOperationRequest.
211 }
212 err = c.CancelOperation(ctx, req)
213 if err != nil {
214 // TODO: Handle error.
215 }
216 }
217
218 func ExampleHostProjectRegistrationClient_DeleteOperation() {
219 ctx := context.Background()
220 // This snippet has been automatically generated and should be regarded as a code template only.
221 // It will require modifications to work:
222 // - It may require correct/in-range values for request initialization.
223 // - It may require specifying regional endpoints when creating the service client as shown in:
224 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
225 c, err := apihub.NewHostProjectRegistrationRESTClient(ctx)
226 if err != nil {
227 // TODO: Handle error.
228 }
229 defer c.Close()
230
231 req := &longrunningpb.DeleteOperationRequest{
232 // TODO: Fill request struct fields.
233 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#DeleteOperationRequest.
234 }
235 err = c.DeleteOperation(ctx, req)
236 if err != nil {
237 // TODO: Handle error.
238 }
239 }
240
241 func ExampleHostProjectRegistrationClient_GetOperation() {
242 ctx := context.Background()
243 // This snippet has been automatically generated and should be regarded as a code template only.
244 // It will require modifications to work:
245 // - It may require correct/in-range values for request initialization.
246 // - It may require specifying regional endpoints when creating the service client as shown in:
247 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
248 c, err := apihub.NewHostProjectRegistrationRESTClient(ctx)
249 if err != nil {
250 // TODO: Handle error.
251 }
252 defer c.Close()
253
254 req := &longrunningpb.GetOperationRequest{
255 // TODO: Fill request struct fields.
256 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#GetOperationRequest.
257 }
258 resp, err := c.GetOperation(ctx, req)
259 if err != nil {
260 // TODO: Handle error.
261 }
262 // TODO: Use resp.
263 _ = resp
264 }
265
266 func ExampleHostProjectRegistrationClient_ListOperations() {
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.NewHostProjectRegistrationRESTClient(ctx)
274 if err != nil {
275 // TODO: Handle error.
276 }
277 defer c.Close()
278
279 req := &longrunningpb.ListOperationsRequest{
280 // TODO: Fill request struct fields.
281 // See https://pkg.go.dev/cloud.google.com/go/longrunning/autogen/longrunningpb#ListOperationsRequest.
282 }
283 it := c.ListOperations(ctx, req)
284 for {
285 resp, err := it.Next()
286 if err == iterator.Done {
287 break
288 }
289 if err != nil {
290 // TODO: Handle error.
291 }
292 // TODO: Use resp.
293 _ = resp
294
295 // If you need to access the underlying RPC response,
296 // you can do so by casting the `Response` as below.
297 // Otherwise, remove this line. Only populated after
298 // first call to Next(). Not safe for concurrent access.
299 _ = it.Response.(*longrunningpb.ListOperationsResponse)
300 }
301 }