1// Copyright 2020 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
17package cloudtasks_test
18
19import (
20	"context"
21
22	cloudtasks "cloud.google.com/go/cloudtasks/apiv2beta2"
23	"google.golang.org/api/iterator"
24	taskspb "google.golang.org/genproto/googleapis/cloud/tasks/v2beta2"
25	iampb "google.golang.org/genproto/googleapis/iam/v1"
26)
27
28func ExampleNewClient() {
29	ctx := context.Background()
30	c, err := cloudtasks.NewClient(ctx)
31	if err != nil {
32		// TODO: Handle error.
33	}
34	// TODO: Use client.
35	_ = c
36}
37
38func ExampleClient_ListQueues() {
39	// import taskspb "google.golang.org/genproto/googleapis/cloud/tasks/v2beta2"
40	// import "google.golang.org/api/iterator"
41
42	ctx := context.Background()
43	c, err := cloudtasks.NewClient(ctx)
44	if err != nil {
45		// TODO: Handle error.
46	}
47
48	req := &taskspb.ListQueuesRequest{
49		// TODO: Fill request struct fields.
50	}
51	it := c.ListQueues(ctx, req)
52	for {
53		resp, err := it.Next()
54		if err == iterator.Done {
55			break
56		}
57		if err != nil {
58			// TODO: Handle error.
59		}
60		// TODO: Use resp.
61		_ = resp
62	}
63}
64
65func ExampleClient_GetQueue() {
66	// import taskspb "google.golang.org/genproto/googleapis/cloud/tasks/v2beta2"
67
68	ctx := context.Background()
69	c, err := cloudtasks.NewClient(ctx)
70	if err != nil {
71		// TODO: Handle error.
72	}
73
74	req := &taskspb.GetQueueRequest{
75		// TODO: Fill request struct fields.
76	}
77	resp, err := c.GetQueue(ctx, req)
78	if err != nil {
79		// TODO: Handle error.
80	}
81	// TODO: Use resp.
82	_ = resp
83}
84
85func ExampleClient_CreateQueue() {
86	// import taskspb "google.golang.org/genproto/googleapis/cloud/tasks/v2beta2"
87
88	ctx := context.Background()
89	c, err := cloudtasks.NewClient(ctx)
90	if err != nil {
91		// TODO: Handle error.
92	}
93
94	req := &taskspb.CreateQueueRequest{
95		// TODO: Fill request struct fields.
96	}
97	resp, err := c.CreateQueue(ctx, req)
98	if err != nil {
99		// TODO: Handle error.
100	}
101	// TODO: Use resp.
102	_ = resp
103}
104
105func ExampleClient_UpdateQueue() {
106	// import taskspb "google.golang.org/genproto/googleapis/cloud/tasks/v2beta2"
107
108	ctx := context.Background()
109	c, err := cloudtasks.NewClient(ctx)
110	if err != nil {
111		// TODO: Handle error.
112	}
113
114	req := &taskspb.UpdateQueueRequest{
115		// TODO: Fill request struct fields.
116	}
117	resp, err := c.UpdateQueue(ctx, req)
118	if err != nil {
119		// TODO: Handle error.
120	}
121	// TODO: Use resp.
122	_ = resp
123}
124
125func ExampleClient_DeleteQueue() {
126	ctx := context.Background()
127	c, err := cloudtasks.NewClient(ctx)
128	if err != nil {
129		// TODO: Handle error.
130	}
131
132	req := &taskspb.DeleteQueueRequest{
133		// TODO: Fill request struct fields.
134	}
135	err = c.DeleteQueue(ctx, req)
136	if err != nil {
137		// TODO: Handle error.
138	}
139}
140
141func ExampleClient_PurgeQueue() {
142	// import taskspb "google.golang.org/genproto/googleapis/cloud/tasks/v2beta2"
143
144	ctx := context.Background()
145	c, err := cloudtasks.NewClient(ctx)
146	if err != nil {
147		// TODO: Handle error.
148	}
149
150	req := &taskspb.PurgeQueueRequest{
151		// TODO: Fill request struct fields.
152	}
153	resp, err := c.PurgeQueue(ctx, req)
154	if err != nil {
155		// TODO: Handle error.
156	}
157	// TODO: Use resp.
158	_ = resp
159}
160
161func ExampleClient_PauseQueue() {
162	// import taskspb "google.golang.org/genproto/googleapis/cloud/tasks/v2beta2"
163
164	ctx := context.Background()
165	c, err := cloudtasks.NewClient(ctx)
166	if err != nil {
167		// TODO: Handle error.
168	}
169
170	req := &taskspb.PauseQueueRequest{
171		// TODO: Fill request struct fields.
172	}
173	resp, err := c.PauseQueue(ctx, req)
174	if err != nil {
175		// TODO: Handle error.
176	}
177	// TODO: Use resp.
178	_ = resp
179}
180
181func ExampleClient_ResumeQueue() {
182	// import taskspb "google.golang.org/genproto/googleapis/cloud/tasks/v2beta2"
183
184	ctx := context.Background()
185	c, err := cloudtasks.NewClient(ctx)
186	if err != nil {
187		// TODO: Handle error.
188	}
189
190	req := &taskspb.ResumeQueueRequest{
191		// TODO: Fill request struct fields.
192	}
193	resp, err := c.ResumeQueue(ctx, req)
194	if err != nil {
195		// TODO: Handle error.
196	}
197	// TODO: Use resp.
198	_ = resp
199}
200
201func ExampleClient_GetIamPolicy() {
202	// import iampb "google.golang.org/genproto/googleapis/iam/v1"
203
204	ctx := context.Background()
205	c, err := cloudtasks.NewClient(ctx)
206	if err != nil {
207		// TODO: Handle error.
208	}
209
210	req := &iampb.GetIamPolicyRequest{
211		// TODO: Fill request struct fields.
212	}
213	resp, err := c.GetIamPolicy(ctx, req)
214	if err != nil {
215		// TODO: Handle error.
216	}
217	// TODO: Use resp.
218	_ = resp
219}
220
221func ExampleClient_SetIamPolicy() {
222	// import iampb "google.golang.org/genproto/googleapis/iam/v1"
223
224	ctx := context.Background()
225	c, err := cloudtasks.NewClient(ctx)
226	if err != nil {
227		// TODO: Handle error.
228	}
229
230	req := &iampb.SetIamPolicyRequest{
231		// TODO: Fill request struct fields.
232	}
233	resp, err := c.SetIamPolicy(ctx, req)
234	if err != nil {
235		// TODO: Handle error.
236	}
237	// TODO: Use resp.
238	_ = resp
239}
240
241func ExampleClient_TestIamPermissions() {
242	// import iampb "google.golang.org/genproto/googleapis/iam/v1"
243
244	ctx := context.Background()
245	c, err := cloudtasks.NewClient(ctx)
246	if err != nil {
247		// TODO: Handle error.
248	}
249
250	req := &iampb.TestIamPermissionsRequest{
251		// TODO: Fill request struct fields.
252	}
253	resp, err := c.TestIamPermissions(ctx, req)
254	if err != nil {
255		// TODO: Handle error.
256	}
257	// TODO: Use resp.
258	_ = resp
259}
260
261func ExampleClient_ListTasks() {
262	// import taskspb "google.golang.org/genproto/googleapis/cloud/tasks/v2beta2"
263	// import "google.golang.org/api/iterator"
264
265	ctx := context.Background()
266	c, err := cloudtasks.NewClient(ctx)
267	if err != nil {
268		// TODO: Handle error.
269	}
270
271	req := &taskspb.ListTasksRequest{
272		// TODO: Fill request struct fields.
273	}
274	it := c.ListTasks(ctx, req)
275	for {
276		resp, err := it.Next()
277		if err == iterator.Done {
278			break
279		}
280		if err != nil {
281			// TODO: Handle error.
282		}
283		// TODO: Use resp.
284		_ = resp
285	}
286}
287
288func ExampleClient_GetTask() {
289	// import taskspb "google.golang.org/genproto/googleapis/cloud/tasks/v2beta2"
290
291	ctx := context.Background()
292	c, err := cloudtasks.NewClient(ctx)
293	if err != nil {
294		// TODO: Handle error.
295	}
296
297	req := &taskspb.GetTaskRequest{
298		// TODO: Fill request struct fields.
299	}
300	resp, err := c.GetTask(ctx, req)
301	if err != nil {
302		// TODO: Handle error.
303	}
304	// TODO: Use resp.
305	_ = resp
306}
307
308func ExampleClient_CreateTask() {
309	// import taskspb "google.golang.org/genproto/googleapis/cloud/tasks/v2beta2"
310
311	ctx := context.Background()
312	c, err := cloudtasks.NewClient(ctx)
313	if err != nil {
314		// TODO: Handle error.
315	}
316
317	req := &taskspb.CreateTaskRequest{
318		// TODO: Fill request struct fields.
319	}
320	resp, err := c.CreateTask(ctx, req)
321	if err != nil {
322		// TODO: Handle error.
323	}
324	// TODO: Use resp.
325	_ = resp
326}
327
328func ExampleClient_DeleteTask() {
329	ctx := context.Background()
330	c, err := cloudtasks.NewClient(ctx)
331	if err != nil {
332		// TODO: Handle error.
333	}
334
335	req := &taskspb.DeleteTaskRequest{
336		// TODO: Fill request struct fields.
337	}
338	err = c.DeleteTask(ctx, req)
339	if err != nil {
340		// TODO: Handle error.
341	}
342}
343
344func ExampleClient_LeaseTasks() {
345	// import taskspb "google.golang.org/genproto/googleapis/cloud/tasks/v2beta2"
346
347	ctx := context.Background()
348	c, err := cloudtasks.NewClient(ctx)
349	if err != nil {
350		// TODO: Handle error.
351	}
352
353	req := &taskspb.LeaseTasksRequest{
354		// TODO: Fill request struct fields.
355	}
356	resp, err := c.LeaseTasks(ctx, req)
357	if err != nil {
358		// TODO: Handle error.
359	}
360	// TODO: Use resp.
361	_ = resp
362}
363
364func ExampleClient_AcknowledgeTask() {
365	ctx := context.Background()
366	c, err := cloudtasks.NewClient(ctx)
367	if err != nil {
368		// TODO: Handle error.
369	}
370
371	req := &taskspb.AcknowledgeTaskRequest{
372		// TODO: Fill request struct fields.
373	}
374	err = c.AcknowledgeTask(ctx, req)
375	if err != nil {
376		// TODO: Handle error.
377	}
378}
379
380func ExampleClient_RenewLease() {
381	// import taskspb "google.golang.org/genproto/googleapis/cloud/tasks/v2beta2"
382
383	ctx := context.Background()
384	c, err := cloudtasks.NewClient(ctx)
385	if err != nil {
386		// TODO: Handle error.
387	}
388
389	req := &taskspb.RenewLeaseRequest{
390		// TODO: Fill request struct fields.
391	}
392	resp, err := c.RenewLease(ctx, req)
393	if err != nil {
394		// TODO: Handle error.
395	}
396	// TODO: Use resp.
397	_ = resp
398}
399
400func ExampleClient_CancelLease() {
401	// import taskspb "google.golang.org/genproto/googleapis/cloud/tasks/v2beta2"
402
403	ctx := context.Background()
404	c, err := cloudtasks.NewClient(ctx)
405	if err != nil {
406		// TODO: Handle error.
407	}
408
409	req := &taskspb.CancelLeaseRequest{
410		// TODO: Fill request struct fields.
411	}
412	resp, err := c.CancelLease(ctx, req)
413	if err != nil {
414		// TODO: Handle error.
415	}
416	// TODO: Use resp.
417	_ = resp
418}
419
420func ExampleClient_RunTask() {
421	// import taskspb "google.golang.org/genproto/googleapis/cloud/tasks/v2beta2"
422
423	ctx := context.Background()
424	c, err := cloudtasks.NewClient(ctx)
425	if err != nil {
426		// TODO: Handle error.
427	}
428
429	req := &taskspb.RunTaskRequest{
430		// TODO: Fill request struct fields.
431	}
432	resp, err := c.RunTask(ctx, req)
433	if err != nil {
434		// TODO: Handle error.
435	}
436	// TODO: Use resp.
437	_ = resp
438}
439