1// Copyright 2019 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 gapic-generator. DO NOT EDIT.
16
17package pubsub_test
18
19import (
20	"context"
21	"io"
22
23	pubsub "cloud.google.com/go/pubsub/apiv1"
24	"google.golang.org/api/iterator"
25	pubsubpb "google.golang.org/genproto/googleapis/pubsub/v1"
26)
27
28func ExampleNewSubscriberClient() {
29	ctx := context.Background()
30	c, err := pubsub.NewSubscriberClient(ctx)
31	if err != nil {
32		// TODO: Handle error.
33	}
34	// TODO: Use client.
35	_ = c
36}
37
38func ExampleSubscriberClient_CreateSubscription() {
39	ctx := context.Background()
40	c, err := pubsub.NewSubscriberClient(ctx)
41	if err != nil {
42		// TODO: Handle error.
43	}
44
45	req := &pubsubpb.Subscription{
46		// TODO: Fill request struct fields.
47	}
48	resp, err := c.CreateSubscription(ctx, req)
49	if err != nil {
50		// TODO: Handle error.
51	}
52	// TODO: Use resp.
53	_ = resp
54}
55
56func ExampleSubscriberClient_GetSubscription() {
57	ctx := context.Background()
58	c, err := pubsub.NewSubscriberClient(ctx)
59	if err != nil {
60		// TODO: Handle error.
61	}
62
63	req := &pubsubpb.GetSubscriptionRequest{
64		// TODO: Fill request struct fields.
65	}
66	resp, err := c.GetSubscription(ctx, req)
67	if err != nil {
68		// TODO: Handle error.
69	}
70	// TODO: Use resp.
71	_ = resp
72}
73
74func ExampleSubscriberClient_UpdateSubscription() {
75	ctx := context.Background()
76	c, err := pubsub.NewSubscriberClient(ctx)
77	if err != nil {
78		// TODO: Handle error.
79	}
80
81	req := &pubsubpb.UpdateSubscriptionRequest{
82		// TODO: Fill request struct fields.
83	}
84	resp, err := c.UpdateSubscription(ctx, req)
85	if err != nil {
86		// TODO: Handle error.
87	}
88	// TODO: Use resp.
89	_ = resp
90}
91
92func ExampleSubscriberClient_ListSubscriptions() {
93	ctx := context.Background()
94	c, err := pubsub.NewSubscriberClient(ctx)
95	if err != nil {
96		// TODO: Handle error.
97	}
98
99	req := &pubsubpb.ListSubscriptionsRequest{
100		// TODO: Fill request struct fields.
101	}
102	it := c.ListSubscriptions(ctx, req)
103	for {
104		resp, err := it.Next()
105		if err == iterator.Done {
106			break
107		}
108		if err != nil {
109			// TODO: Handle error.
110		}
111		// TODO: Use resp.
112		_ = resp
113	}
114}
115
116func ExampleSubscriberClient_DeleteSubscription() {
117	ctx := context.Background()
118	c, err := pubsub.NewSubscriberClient(ctx)
119	if err != nil {
120		// TODO: Handle error.
121	}
122
123	req := &pubsubpb.DeleteSubscriptionRequest{
124		// TODO: Fill request struct fields.
125	}
126	err = c.DeleteSubscription(ctx, req)
127	if err != nil {
128		// TODO: Handle error.
129	}
130}
131
132func ExampleSubscriberClient_ModifyAckDeadline() {
133	ctx := context.Background()
134	c, err := pubsub.NewSubscriberClient(ctx)
135	if err != nil {
136		// TODO: Handle error.
137	}
138
139	req := &pubsubpb.ModifyAckDeadlineRequest{
140		// TODO: Fill request struct fields.
141	}
142	err = c.ModifyAckDeadline(ctx, req)
143	if err != nil {
144		// TODO: Handle error.
145	}
146}
147
148func ExampleSubscriberClient_Acknowledge() {
149	ctx := context.Background()
150	c, err := pubsub.NewSubscriberClient(ctx)
151	if err != nil {
152		// TODO: Handle error.
153	}
154
155	req := &pubsubpb.AcknowledgeRequest{
156		// TODO: Fill request struct fields.
157	}
158	err = c.Acknowledge(ctx, req)
159	if err != nil {
160		// TODO: Handle error.
161	}
162}
163
164func ExampleSubscriberClient_Pull() {
165	ctx := context.Background()
166	c, err := pubsub.NewSubscriberClient(ctx)
167	if err != nil {
168		// TODO: Handle error.
169	}
170
171	req := &pubsubpb.PullRequest{
172		// TODO: Fill request struct fields.
173	}
174	resp, err := c.Pull(ctx, req)
175	if err != nil {
176		// TODO: Handle error.
177	}
178	// TODO: Use resp.
179	_ = resp
180}
181
182func ExampleSubscriberClient_StreamingPull() {
183	ctx := context.Background()
184	c, err := pubsub.NewSubscriberClient(ctx)
185	if err != nil {
186		// TODO: Handle error.
187	}
188	stream, err := c.StreamingPull(ctx)
189	if err != nil {
190		// TODO: Handle error.
191	}
192	go func() {
193		reqs := []*pubsubpb.StreamingPullRequest{
194			// TODO: Create requests.
195		}
196		for _, req := range reqs {
197			if err := stream.Send(req); err != nil {
198				// TODO: Handle error.
199			}
200		}
201		stream.CloseSend()
202	}()
203	for {
204		resp, err := stream.Recv()
205		if err == io.EOF {
206			break
207		}
208		if err != nil {
209			// TODO: handle error.
210		}
211		// TODO: Use resp.
212		_ = resp
213	}
214}
215
216func ExampleSubscriberClient_ModifyPushConfig() {
217	ctx := context.Background()
218	c, err := pubsub.NewSubscriberClient(ctx)
219	if err != nil {
220		// TODO: Handle error.
221	}
222
223	req := &pubsubpb.ModifyPushConfigRequest{
224		// TODO: Fill request struct fields.
225	}
226	err = c.ModifyPushConfig(ctx, req)
227	if err != nil {
228		// TODO: Handle error.
229	}
230}
231
232func ExampleSubscriberClient_ListSnapshots() {
233	ctx := context.Background()
234	c, err := pubsub.NewSubscriberClient(ctx)
235	if err != nil {
236		// TODO: Handle error.
237	}
238
239	req := &pubsubpb.ListSnapshotsRequest{
240		// TODO: Fill request struct fields.
241	}
242	it := c.ListSnapshots(ctx, req)
243	for {
244		resp, err := it.Next()
245		if err == iterator.Done {
246			break
247		}
248		if err != nil {
249			// TODO: Handle error.
250		}
251		// TODO: Use resp.
252		_ = resp
253	}
254}
255
256func ExampleSubscriberClient_CreateSnapshot() {
257	ctx := context.Background()
258	c, err := pubsub.NewSubscriberClient(ctx)
259	if err != nil {
260		// TODO: Handle error.
261	}
262
263	req := &pubsubpb.CreateSnapshotRequest{
264		// TODO: Fill request struct fields.
265	}
266	resp, err := c.CreateSnapshot(ctx, req)
267	if err != nil {
268		// TODO: Handle error.
269	}
270	// TODO: Use resp.
271	_ = resp
272}
273
274func ExampleSubscriberClient_UpdateSnapshot() {
275	ctx := context.Background()
276	c, err := pubsub.NewSubscriberClient(ctx)
277	if err != nil {
278		// TODO: Handle error.
279	}
280
281	req := &pubsubpb.UpdateSnapshotRequest{
282		// TODO: Fill request struct fields.
283	}
284	resp, err := c.UpdateSnapshot(ctx, req)
285	if err != nil {
286		// TODO: Handle error.
287	}
288	// TODO: Use resp.
289	_ = resp
290}
291
292func ExampleSubscriberClient_DeleteSnapshot() {
293	ctx := context.Background()
294	c, err := pubsub.NewSubscriberClient(ctx)
295	if err != nil {
296		// TODO: Handle error.
297	}
298
299	req := &pubsubpb.DeleteSnapshotRequest{
300		// TODO: Fill request struct fields.
301	}
302	err = c.DeleteSnapshot(ctx, req)
303	if err != nil {
304		// TODO: Handle error.
305	}
306}
307
308func ExampleSubscriberClient_Seek() {
309	ctx := context.Background()
310	c, err := pubsub.NewSubscriberClient(ctx)
311	if err != nil {
312		// TODO: Handle error.
313	}
314
315	req := &pubsubpb.SeekRequest{
316		// TODO: Fill request struct fields.
317	}
318	resp, err := c.Seek(ctx, req)
319	if err != nil {
320		// TODO: Handle error.
321	}
322	// TODO: Use resp.
323	_ = resp
324}
325