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.
 
 
 

209 lines
4.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 database_test
  16. import (
  17. "context"
  18. database "cloud.google.com/go/spanner/admin/database/apiv1"
  19. "google.golang.org/api/iterator"
  20. iampb "google.golang.org/genproto/googleapis/iam/v1"
  21. databasepb "google.golang.org/genproto/googleapis/spanner/admin/database/v1"
  22. )
  23. func ExampleNewDatabaseAdminClient() {
  24. ctx := context.Background()
  25. c, err := database.NewDatabaseAdminClient(ctx)
  26. if err != nil {
  27. // TODO: Handle error.
  28. }
  29. // TODO: Use client.
  30. _ = c
  31. }
  32. func ExampleDatabaseAdminClient_ListDatabases() {
  33. ctx := context.Background()
  34. c, err := database.NewDatabaseAdminClient(ctx)
  35. if err != nil {
  36. // TODO: Handle error.
  37. }
  38. req := &databasepb.ListDatabasesRequest{
  39. // TODO: Fill request struct fields.
  40. }
  41. it := c.ListDatabases(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 ExampleDatabaseAdminClient_CreateDatabase() {
  55. ctx := context.Background()
  56. c, err := database.NewDatabaseAdminClient(ctx)
  57. if err != nil {
  58. // TODO: Handle error.
  59. }
  60. req := &databasepb.CreateDatabaseRequest{
  61. // TODO: Fill request struct fields.
  62. }
  63. op, err := c.CreateDatabase(ctx, req)
  64. if err != nil {
  65. // TODO: Handle error.
  66. }
  67. resp, err := op.Wait(ctx)
  68. if err != nil {
  69. // TODO: Handle error.
  70. }
  71. // TODO: Use resp.
  72. _ = resp
  73. }
  74. func ExampleDatabaseAdminClient_GetDatabase() {
  75. ctx := context.Background()
  76. c, err := database.NewDatabaseAdminClient(ctx)
  77. if err != nil {
  78. // TODO: Handle error.
  79. }
  80. req := &databasepb.GetDatabaseRequest{
  81. // TODO: Fill request struct fields.
  82. }
  83. resp, err := c.GetDatabase(ctx, req)
  84. if err != nil {
  85. // TODO: Handle error.
  86. }
  87. // TODO: Use resp.
  88. _ = resp
  89. }
  90. func ExampleDatabaseAdminClient_UpdateDatabaseDdl() {
  91. ctx := context.Background()
  92. c, err := database.NewDatabaseAdminClient(ctx)
  93. if err != nil {
  94. // TODO: Handle error.
  95. }
  96. req := &databasepb.UpdateDatabaseDdlRequest{
  97. // TODO: Fill request struct fields.
  98. }
  99. op, err := c.UpdateDatabaseDdl(ctx, req)
  100. if err != nil {
  101. // TODO: Handle error.
  102. }
  103. err = op.Wait(ctx)
  104. // TODO: Handle error.
  105. }
  106. func ExampleDatabaseAdminClient_DropDatabase() {
  107. ctx := context.Background()
  108. c, err := database.NewDatabaseAdminClient(ctx)
  109. if err != nil {
  110. // TODO: Handle error.
  111. }
  112. req := &databasepb.DropDatabaseRequest{
  113. // TODO: Fill request struct fields.
  114. }
  115. err = c.DropDatabase(ctx, req)
  116. if err != nil {
  117. // TODO: Handle error.
  118. }
  119. }
  120. func ExampleDatabaseAdminClient_GetDatabaseDdl() {
  121. ctx := context.Background()
  122. c, err := database.NewDatabaseAdminClient(ctx)
  123. if err != nil {
  124. // TODO: Handle error.
  125. }
  126. req := &databasepb.GetDatabaseDdlRequest{
  127. // TODO: Fill request struct fields.
  128. }
  129. resp, err := c.GetDatabaseDdl(ctx, req)
  130. if err != nil {
  131. // TODO: Handle error.
  132. }
  133. // TODO: Use resp.
  134. _ = resp
  135. }
  136. func ExampleDatabaseAdminClient_SetIamPolicy() {
  137. ctx := context.Background()
  138. c, err := database.NewDatabaseAdminClient(ctx)
  139. if err != nil {
  140. // TODO: Handle error.
  141. }
  142. req := &iampb.SetIamPolicyRequest{
  143. // TODO: Fill request struct fields.
  144. }
  145. resp, err := c.SetIamPolicy(ctx, req)
  146. if err != nil {
  147. // TODO: Handle error.
  148. }
  149. // TODO: Use resp.
  150. _ = resp
  151. }
  152. func ExampleDatabaseAdminClient_GetIamPolicy() {
  153. ctx := context.Background()
  154. c, err := database.NewDatabaseAdminClient(ctx)
  155. if err != nil {
  156. // TODO: Handle error.
  157. }
  158. req := &iampb.GetIamPolicyRequest{
  159. // TODO: Fill request struct fields.
  160. }
  161. resp, err := c.GetIamPolicy(ctx, req)
  162. if err != nil {
  163. // TODO: Handle error.
  164. }
  165. // TODO: Use resp.
  166. _ = resp
  167. }
  168. func ExampleDatabaseAdminClient_TestIamPermissions() {
  169. ctx := context.Background()
  170. c, err := database.NewDatabaseAdminClient(ctx)
  171. if err != nil {
  172. // TODO: Handle error.
  173. }
  174. req := &iampb.TestIamPermissionsRequest{
  175. // TODO: Fill request struct fields.
  176. }
  177. resp, err := c.TestIamPermissions(ctx, req)
  178. if err != nil {
  179. // TODO: Handle error.
  180. }
  181. // TODO: Use resp.
  182. _ = resp
  183. }