Debian Codegraph @

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