選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 

359 行
7.3 KiB

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