You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

403 lines
7.7 KiB

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