Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 

172 rindas
3.5 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 pubsub_test
  16. import (
  17. "context"
  18. pubsub "cloud.google.com/go/pubsub/apiv1"
  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_CreateTopic() {
  32. ctx := context.Background()
  33. c, err := pubsub.NewPublisherClient(ctx)
  34. if err != nil {
  35. // TODO: Handle error.
  36. }
  37. req := &pubsubpb.Topic{
  38. // TODO: Fill request struct fields.
  39. }
  40. resp, err := c.CreateTopic(ctx, req)
  41. if err != nil {
  42. // TODO: Handle error.
  43. }
  44. // TODO: Use resp.
  45. _ = resp
  46. }
  47. func ExamplePublisherClient_UpdateTopic() {
  48. ctx := context.Background()
  49. c, err := pubsub.NewPublisherClient(ctx)
  50. if err != nil {
  51. // TODO: Handle error.
  52. }
  53. req := &pubsubpb.UpdateTopicRequest{
  54. // TODO: Fill request struct fields.
  55. }
  56. resp, err := c.UpdateTopic(ctx, req)
  57. if err != nil {
  58. // TODO: Handle error.
  59. }
  60. // TODO: Use resp.
  61. _ = resp
  62. }
  63. func ExamplePublisherClient_Publish() {
  64. ctx := context.Background()
  65. c, err := pubsub.NewPublisherClient(ctx)
  66. if err != nil {
  67. // TODO: Handle error.
  68. }
  69. req := &pubsubpb.PublishRequest{
  70. // TODO: Fill request struct fields.
  71. }
  72. resp, err := c.Publish(ctx, req)
  73. if err != nil {
  74. // TODO: Handle error.
  75. }
  76. // TODO: Use resp.
  77. _ = resp
  78. }
  79. func ExamplePublisherClient_GetTopic() {
  80. ctx := context.Background()
  81. c, err := pubsub.NewPublisherClient(ctx)
  82. if err != nil {
  83. // TODO: Handle error.
  84. }
  85. req := &pubsubpb.GetTopicRequest{
  86. // TODO: Fill request struct fields.
  87. }
  88. resp, err := c.GetTopic(ctx, req)
  89. if err != nil {
  90. // TODO: Handle error.
  91. }
  92. // TODO: Use resp.
  93. _ = resp
  94. }
  95. func ExamplePublisherClient_ListTopics() {
  96. ctx := context.Background()
  97. c, err := pubsub.NewPublisherClient(ctx)
  98. if err != nil {
  99. // TODO: Handle error.
  100. }
  101. req := &pubsubpb.ListTopicsRequest{
  102. // TODO: Fill request struct fields.
  103. }
  104. it := c.ListTopics(ctx, req)
  105. for {
  106. resp, err := it.Next()
  107. if err == iterator.Done {
  108. break
  109. }
  110. if err != nil {
  111. // TODO: Handle error.
  112. }
  113. // TODO: Use resp.
  114. _ = resp
  115. }
  116. }
  117. func ExamplePublisherClient_ListTopicSubscriptions() {
  118. ctx := context.Background()
  119. c, err := pubsub.NewPublisherClient(ctx)
  120. if err != nil {
  121. // TODO: Handle error.
  122. }
  123. req := &pubsubpb.ListTopicSubscriptionsRequest{
  124. // TODO: Fill request struct fields.
  125. }
  126. it := c.ListTopicSubscriptions(ctx, req)
  127. for {
  128. resp, err := it.Next()
  129. if err == iterator.Done {
  130. break
  131. }
  132. if err != nil {
  133. // TODO: Handle error.
  134. }
  135. // TODO: Use resp.
  136. _ = resp
  137. }
  138. }
  139. func ExamplePublisherClient_DeleteTopic() {
  140. ctx := context.Background()
  141. c, err := pubsub.NewPublisherClient(ctx)
  142. if err != nil {
  143. // TODO: Handle error.
  144. }
  145. req := &pubsubpb.DeleteTopicRequest{
  146. // TODO: Fill request struct fields.
  147. }
  148. err = c.DeleteTopic(ctx, req)
  149. if err != nil {
  150. // TODO: Handle error.
  151. }
  152. }