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