Debian Codegraph @

shopping/merchant/accounts/apiv1/account_services_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 accounts_test
18
19 import (
20 "context"
21
22 accounts "cloud.google.com/go/shopping/merchant/accounts/apiv1"
23 accountspb "cloud.google.com/go/shopping/merchant/accounts/apiv1/accountspb"
24 "google.golang.org/api/iterator"
25 )
26
27 func ExampleNewAccountServicesClient() {
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 := accounts.NewAccountServicesClient(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 ExampleNewAccountServicesRESTClient() {
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 := accounts.NewAccountServicesRESTClient(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 ExampleAccountServicesClient_ApproveAccountService() {
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 := accounts.NewAccountServicesClient(ctx)
69 if err != nil {
70 // TODO: Handle error.
71 }
72 defer c.Close()
73
74 req := &accountspb.ApproveAccountServiceRequest{
75 // TODO: Fill request struct fields.
76 // See https://pkg.go.dev/cloud.google.com/go/shopping/merchant/accounts/apiv1/accountspb#ApproveAccountServiceRequest.
77 }
78 resp, err := c.ApproveAccountService(ctx, req)
79 if err != nil {
80 // TODO: Handle error.
81 }
82 // TODO: Use resp.
83 _ = resp
84 }
85
86 func ExampleAccountServicesClient_GetAccountService() {
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 := accounts.NewAccountServicesClient(ctx)
94 if err != nil {
95 // TODO: Handle error.
96 }
97 defer c.Close()
98
99 req := &accountspb.GetAccountServiceRequest{
100 // TODO: Fill request struct fields.
101 // See https://pkg.go.dev/cloud.google.com/go/shopping/merchant/accounts/apiv1/accountspb#GetAccountServiceRequest.
102 }
103 resp, err := c.GetAccountService(ctx, req)
104 if err != nil {
105 // TODO: Handle error.
106 }
107 // TODO: Use resp.
108 _ = resp
109 }
110
111 func ExampleAccountServicesClient_ListAccountServices() {
112 ctx := context.Background()
113 // This snippet has been automatically generated and should be regarded as a code template only.
114 // It will require modifications to work:
115 // - It may require correct/in-range values for request initialization.
116 // - It may require specifying regional endpoints when creating the service client as shown in:
117 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
118 c, err := accounts.NewAccountServicesClient(ctx)
119 if err != nil {
120 // TODO: Handle error.
121 }
122 defer c.Close()
123
124 req := &accountspb.ListAccountServicesRequest{
125 // TODO: Fill request struct fields.
126 // See https://pkg.go.dev/cloud.google.com/go/shopping/merchant/accounts/apiv1/accountspb#ListAccountServicesRequest.
127 }
128 it := c.ListAccountServices(ctx, req)
129 for {
130 resp, err := it.Next()
131 if err == iterator.Done {
132 break
133 }
134 if err != nil {
135 // TODO: Handle error.
136 }
137 // TODO: Use resp.
138 _ = resp
139
140 // If you need to access the underlying RPC response,
141 // you can do so by casting the `Response` as below.
142 // Otherwise, remove this line. Only populated after
143 // first call to Next(). Not safe for concurrent access.
144 _ = it.Response.(*accountspb.ListAccountServicesResponse)
145 }
146 }
147
148 func ExampleAccountServicesClient_ProposeAccountService() {
149 ctx := context.Background()
150 // This snippet has been automatically generated and should be regarded as a code template only.
151 // It will require modifications to work:
152 // - It may require correct/in-range values for request initialization.
153 // - It may require specifying regional endpoints when creating the service client as shown in:
154 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
155 c, err := accounts.NewAccountServicesClient(ctx)
156 if err != nil {
157 // TODO: Handle error.
158 }
159 defer c.Close()
160
161 req := &accountspb.ProposeAccountServiceRequest{
162 // TODO: Fill request struct fields.
163 // See https://pkg.go.dev/cloud.google.com/go/shopping/merchant/accounts/apiv1/accountspb#ProposeAccountServiceRequest.
164 }
165 resp, err := c.ProposeAccountService(ctx, req)
166 if err != nil {
167 // TODO: Handle error.
168 }
169 // TODO: Use resp.
170 _ = resp
171 }
172
173 func ExampleAccountServicesClient_RejectAccountService() {
174 ctx := context.Background()
175 // This snippet has been automatically generated and should be regarded as a code template only.
176 // It will require modifications to work:
177 // - It may require correct/in-range values for request initialization.
178 // - It may require specifying regional endpoints when creating the service client as shown in:
179 // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
180 c, err := accounts.NewAccountServicesClient(ctx)
181 if err != nil {
182 // TODO: Handle error.
183 }
184 defer c.Close()
185
186 req := &accountspb.RejectAccountServiceRequest{
187 // TODO: Fill request struct fields.
188 // See https://pkg.go.dev/cloud.google.com/go/shopping/merchant/accounts/apiv1/accountspb#RejectAccountServiceRequest.
189 }
190 err = c.RejectAccountService(ctx, req)
191 if err != nil {
192 // TODO: Handle error.
193 }
194 }