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

205 行
4.2 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. "cloud.google.com/go/pubsub/apiv1"
  18. "golang.org/x/net/context"
  19. "google.golang.org/api/iterator"
  20. pubsubpb "google.golang.org/genproto/googleapis/pubsub/v1"
  21. )
  22. func ExampleNewPublisherClient() {
  23. ctx := context.Background()
  24. c, err := pubsub.NewPublisherClient(ctx)
  25. if err != nil {
  26. // TODO: Handle error.
  27. }
  28. // TODO: Use client.
  29. _ = c
  30. }
  31. func ExamplePublisherClient_SubscriptionIAM() {
  32. ctx := context.Background()
  33. c, err := pubsub.NewPublisherClient(ctx)
  34. if err != nil {
  35. // TODO: Handle error.
  36. }
  37. subscription := &pubsubpb.Subscription{}
  38. h := c.SubscriptionIAM(subscription)
  39. policy, err := h.Policy(ctx)
  40. if err != nil {
  41. // TODO: Handle error.
  42. }
  43. //TODO: Use the IAM policy
  44. _ = policy
  45. }
  46. func ExamplePublisherClient_TopicIAM() {
  47. ctx := context.Background()
  48. c, err := pubsub.NewPublisherClient(ctx)
  49. if err != nil {
  50. // TODO: Handle error.
  51. }
  52. topic := &pubsubpb.Topic{}
  53. h := c.TopicIAM(topic)
  54. policy, err := h.Policy(ctx)
  55. if err != nil {
  56. // TODO: Handle error.
  57. }
  58. //TODO: Use the IAM policy
  59. _ = policy
  60. }
  61. func ExamplePublisherClient_CreateTopic() {
  62. ctx := context.Background()
  63. c, err := pubsub.NewPublisherClient(ctx)
  64. if err != nil {
  65. // TODO: Handle error.
  66. }
  67. req := &pubsubpb.Topic{
  68. // TODO: Fill request struct fields.
  69. }
  70. resp, err := c.CreateTopic(ctx, req)
  71. if err != nil {
  72. // TODO: Handle error.
  73. }
  74. // TODO: Use resp.
  75. _ = resp
  76. }
  77. func ExamplePublisherClient_UpdateTopic() {
  78. ctx := context.Background()
  79. c, err := pubsub.NewPublisherClient(ctx)
  80. if err != nil {
  81. // TODO: Handle error.
  82. }
  83. req := &pubsubpb.UpdateTopicRequest{
  84. // TODO: Fill request struct fields.
  85. }
  86. resp, err := c.UpdateTopic(ctx, req)
  87. if err != nil {
  88. // TODO: Handle error.
  89. }
  90. // TODO: Use resp.
  91. _ = resp
  92. }
  93. func ExamplePublisherClient_Publish() {
  94. ctx := context.Background()
  95. c, err := pubsub.NewPublisherClient(ctx)
  96. if err != nil {
  97. // TODO: Handle error.
  98. }
  99. req := &pubsubpb.PublishRequest{
  100. // TODO: Fill request struct fields.
  101. }
  102. resp, err := c.Publish(ctx, req)
  103. if err != nil {
  104. // TODO: Handle error.
  105. }
  106. // TODO: Use resp.
  107. _ = resp
  108. }
  109. func ExamplePublisherClient_GetTopic() {
  110. ctx := context.Background()
  111. c, err := pubsub.NewPublisherClient(ctx)
  112. if err != nil {
  113. // TODO: Handle error.
  114. }
  115. req := &pubsubpb.GetTopicRequest{
  116. // TODO: Fill request struct fields.
  117. }
  118. resp, err := c.GetTopic(ctx, req)
  119. if err != nil {
  120. // TODO: Handle error.
  121. }
  122. // TODO: Use resp.
  123. _ = resp
  124. }
  125. func ExamplePublisherClient_ListTopics() {
  126. ctx := context.Background()
  127. c, err := pubsub.NewPublisherClient(ctx)
  128. if err != nil {
  129. // TODO: Handle error.
  130. }
  131. req := &pubsubpb.ListTopicsRequest{
  132. // TODO: Fill request struct fields.
  133. }
  134. it := c.ListTopics(ctx, req)
  135. for {
  136. resp, err := it.Next()
  137. if err == iterator.Done {
  138. break
  139. }
  140. if err != nil {
  141. // TODO: Handle error.
  142. }
  143. // TODO: Use resp.
  144. _ = resp
  145. }
  146. }
  147. func ExamplePublisherClient_ListTopicSubscriptions() {
  148. ctx := context.Background()
  149. c, err := pubsub.NewPublisherClient(ctx)
  150. if err != nil {
  151. // TODO: Handle error.
  152. }
  153. req := &pubsubpb.ListTopicSubscriptionsRequest{
  154. // TODO: Fill request struct fields.
  155. }
  156. it := c.ListTopicSubscriptions(ctx, req)
  157. for {
  158. resp, err := it.Next()
  159. if err == iterator.Done {
  160. break
  161. }
  162. if err != nil {
  163. // TODO: Handle error.
  164. }
  165. // TODO: Use resp.
  166. _ = resp
  167. }
  168. }
  169. func ExamplePublisherClient_DeleteTopic() {
  170. ctx := context.Background()
  171. c, err := pubsub.NewPublisherClient(ctx)
  172. if err != nil {
  173. // TODO: Handle error.
  174. }
  175. req := &pubsubpb.DeleteTopicRequest{
  176. // TODO: Fill request struct fields.
  177. }
  178. err = c.DeleteTopic(ctx, req)
  179. if err != nil {
  180. // TODO: Handle error.
  181. }
  182. }