Debian Codegraph @

shopping/css/apiv1/accounts_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 css_test
18
19 import (
20 "context"
21
22 css "cloud.google.com/go/shopping/css/apiv1"
23 csspb "cloud.google.com/go/shopping/css/apiv1/csspb"
24 "google.golang.org/api/iterator"
25 )
26
27 func ExampleNewAccountsClient() {
28 ctx := context.Background()
29 // This snippet has been automatically generated and should be regarded as a code template only.
30 // It will require modifications to work:
31 // - It may require correct/in-range values for request initialization.
32 // - It may require specifying regional endpoints when creating the service client as shown in:
33 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
34 c, err := css.NewAccountsClient(ctx)
35 if err != nil {
36 // TODO: Handle error.
37 }
38 defer c.Close()
39
40 // TODO: Use client.
41 _ = c
42 }
43
44 func ExampleNewAccountsRESTClient() {
45 ctx := context.Background()
46 // This snippet has been automatically generated and should be regarded as a code template only.
47 // It will require modifications to work:
48 // - It may require correct/in-range values for request initialization.
49 // - It may require specifying regional endpoints when creating the service client as shown in:
50 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
51 c, err := css.NewAccountsRESTClient(ctx)
52 if err != nil {
53 // TODO: Handle error.
54 }
55 defer c.Close()
56
57 // TODO: Use client.
58 _ = c
59 }
60
61 func ExampleAccountsClient_GetAccount() {
62 ctx := context.Background()
63 // This snippet has been automatically generated and should be regarded as a code template only.
64 // It will require modifications to work:
65 // - It may require correct/in-range values for request initialization.
66 // - It may require specifying regional endpoints when creating the service client as shown in:
67 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
68 c, err := css.NewAccountsClient(ctx)
69 if err != nil {
70 // TODO: Handle error.
71 }
72 defer c.Close()
73
74 req := &csspb.GetAccountRequest{
75 // TODO: Fill request struct fields.
76 // See https://pkg.go.dev/cloud.google.com/go/shopping/css/apiv1/csspb#GetAccountRequest.
77 }
78 resp, err := c.GetAccount(ctx, req)
79 if err != nil {
80 // TODO: Handle error.
81 }
82 // TODO: Use resp.
83 _ = resp
84 }
85
86 func ExampleAccountsClient_ListChildAccounts() {
87 ctx := context.Background()
88 // This snippet has been automatically generated and should be regarded as a code template only.
89 // It will require modifications to work:
90 // - It may require correct/in-range values for request initialization.
91 // - It may require specifying regional endpoints when creating the service client as shown in:
92 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
93 c, err := css.NewAccountsClient(ctx)
94 if err != nil {
95 // TODO: Handle error.
96 }
97 defer c.Close()
98
99 req := &csspb.ListChildAccountsRequest{
100 // TODO: Fill request struct fields.
101 // See https://pkg.go.dev/cloud.google.com/go/shopping/css/apiv1/csspb#ListChildAccountsRequest.
102 }
103 it := c.ListChildAccounts(ctx, req)
104 for {
105 resp, err := it.Next()
106 if err == iterator.Done {
107 break
108 }
109 if err != nil {
110 // TODO: Handle error.
111 }
112 // TODO: Use resp.
113 _ = resp
114
115 // If you need to access the underlying RPC response,
116 // you can do so by casting the `Response` as below.
117 // Otherwise, remove this line. Only populated after
118 // first call to Next(). Not safe for concurrent access.
119 _ = it.Response.(*csspb.ListChildAccountsResponse)
120 }
121 }
122
123 func ExampleAccountsClient_UpdateLabels() {
124 ctx := context.Background()
125 // This snippet has been automatically generated and should be regarded as a code template only.
126 // It will require modifications to work:
127 // - It may require correct/in-range values for request initialization.
128 // - It may require specifying regional endpoints when creating the service client as shown in:
129 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
130 c, err := css.NewAccountsClient(ctx)
131 if err != nil {
132 // TODO: Handle error.
133 }
134 defer c.Close()
135
136 req := &csspb.UpdateAccountLabelsRequest{
137 // TODO: Fill request struct fields.
138 // See https://pkg.go.dev/cloud.google.com/go/shopping/css/apiv1/csspb#UpdateAccountLabelsRequest.
139 }
140 resp, err := c.UpdateLabels(ctx, req)
141 if err != nil {
142 // TODO: Handle error.
143 }
144 // TODO: Use resp.
145 _ = resp
146 }