Debian Codegraph @

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