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.
 
 
 

212 line
4.3 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 redis_test
  16. import (
  17. "context"
  18. redis "cloud.google.com/go/redis/apiv1"
  19. "google.golang.org/api/iterator"
  20. redispb "google.golang.org/genproto/googleapis/cloud/redis/v1"
  21. )
  22. func ExampleNewCloudRedisClient() {
  23. ctx := context.Background()
  24. c, err := redis.NewCloudRedisClient(ctx)
  25. if err != nil {
  26. // TODO: Handle error.
  27. }
  28. // TODO: Use client.
  29. _ = c
  30. }
  31. func ExampleCloudRedisClient_ListInstances() {
  32. ctx := context.Background()
  33. c, err := redis.NewCloudRedisClient(ctx)
  34. if err != nil {
  35. // TODO: Handle error.
  36. }
  37. req := &redispb.ListInstancesRequest{
  38. // TODO: Fill request struct fields.
  39. }
  40. it := c.ListInstances(ctx, req)
  41. for {
  42. resp, err := it.Next()
  43. if err == iterator.Done {
  44. break
  45. }
  46. if err != nil {
  47. // TODO: Handle error.
  48. }
  49. // TODO: Use resp.
  50. _ = resp
  51. }
  52. }
  53. func ExampleCloudRedisClient_GetInstance() {
  54. ctx := context.Background()
  55. c, err := redis.NewCloudRedisClient(ctx)
  56. if err != nil {
  57. // TODO: Handle error.
  58. }
  59. req := &redispb.GetInstanceRequest{
  60. // TODO: Fill request struct fields.
  61. }
  62. resp, err := c.GetInstance(ctx, req)
  63. if err != nil {
  64. // TODO: Handle error.
  65. }
  66. // TODO: Use resp.
  67. _ = resp
  68. }
  69. func ExampleCloudRedisClient_CreateInstance() {
  70. ctx := context.Background()
  71. c, err := redis.NewCloudRedisClient(ctx)
  72. if err != nil {
  73. // TODO: Handle error.
  74. }
  75. req := &redispb.CreateInstanceRequest{
  76. // TODO: Fill request struct fields.
  77. }
  78. op, err := c.CreateInstance(ctx, req)
  79. if err != nil {
  80. // TODO: Handle error.
  81. }
  82. resp, err := op.Wait(ctx)
  83. if err != nil {
  84. // TODO: Handle error.
  85. }
  86. // TODO: Use resp.
  87. _ = resp
  88. }
  89. func ExampleCloudRedisClient_UpdateInstance() {
  90. ctx := context.Background()
  91. c, err := redis.NewCloudRedisClient(ctx)
  92. if err != nil {
  93. // TODO: Handle error.
  94. }
  95. req := &redispb.UpdateInstanceRequest{
  96. // TODO: Fill request struct fields.
  97. }
  98. op, err := c.UpdateInstance(ctx, req)
  99. if err != nil {
  100. // TODO: Handle error.
  101. }
  102. resp, err := op.Wait(ctx)
  103. if err != nil {
  104. // TODO: Handle error.
  105. }
  106. // TODO: Use resp.
  107. _ = resp
  108. }
  109. func ExampleCloudRedisClient_DeleteInstance() {
  110. ctx := context.Background()
  111. c, err := redis.NewCloudRedisClient(ctx)
  112. if err != nil {
  113. // TODO: Handle error.
  114. }
  115. req := &redispb.DeleteInstanceRequest{
  116. // TODO: Fill request struct fields.
  117. }
  118. op, err := c.DeleteInstance(ctx, req)
  119. if err != nil {
  120. // TODO: Handle error.
  121. }
  122. err = op.Wait(ctx)
  123. // TODO: Handle error.
  124. }
  125. func ExampleCloudRedisClient_ImportInstance() {
  126. ctx := context.Background()
  127. c, err := redis.NewCloudRedisClient(ctx)
  128. if err != nil {
  129. // TODO: Handle error.
  130. }
  131. req := &redispb.ImportInstanceRequest{
  132. // TODO: Fill request struct fields.
  133. }
  134. op, err := c.ImportInstance(ctx, req)
  135. if err != nil {
  136. // TODO: Handle error.
  137. }
  138. resp, err := op.Wait(ctx)
  139. if err != nil {
  140. // TODO: Handle error.
  141. }
  142. // TODO: Use resp.
  143. _ = resp
  144. }
  145. func ExampleCloudRedisClient_ExportInstance() {
  146. ctx := context.Background()
  147. c, err := redis.NewCloudRedisClient(ctx)
  148. if err != nil {
  149. // TODO: Handle error.
  150. }
  151. req := &redispb.ExportInstanceRequest{
  152. // TODO: Fill request struct fields.
  153. }
  154. op, err := c.ExportInstance(ctx, req)
  155. if err != nil {
  156. // TODO: Handle error.
  157. }
  158. resp, err := op.Wait(ctx)
  159. if err != nil {
  160. // TODO: Handle error.
  161. }
  162. // TODO: Use resp.
  163. _ = resp
  164. }
  165. func ExampleCloudRedisClient_FailoverInstance() {
  166. ctx := context.Background()
  167. c, err := redis.NewCloudRedisClient(ctx)
  168. if err != nil {
  169. // TODO: Handle error.
  170. }
  171. req := &redispb.FailoverInstanceRequest{
  172. // TODO: Fill request struct fields.
  173. }
  174. op, err := c.FailoverInstance(ctx, req)
  175. if err != nil {
  176. // TODO: Handle error.
  177. }
  178. resp, err := op.Wait(ctx)
  179. if err != nil {
  180. // TODO: Handle error.
  181. }
  182. // TODO: Use resp.
  183. _ = resp
  184. }