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.
 
 
 

273 lines
5.6 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 admin_test
  16. import (
  17. "context"
  18. admin "cloud.google.com/go/iam/admin/apiv1"
  19. "google.golang.org/api/iterator"
  20. adminpb "google.golang.org/genproto/googleapis/iam/admin/v1"
  21. iampb "google.golang.org/genproto/googleapis/iam/v1"
  22. )
  23. func ExampleNewIamClient() {
  24. ctx := context.Background()
  25. c, err := admin.NewIamClient(ctx)
  26. if err != nil {
  27. // TODO: Handle error.
  28. }
  29. // TODO: Use client.
  30. _ = c
  31. }
  32. func ExampleIamClient_ListServiceAccounts() {
  33. ctx := context.Background()
  34. c, err := admin.NewIamClient(ctx)
  35. if err != nil {
  36. // TODO: Handle error.
  37. }
  38. req := &adminpb.ListServiceAccountsRequest{
  39. // TODO: Fill request struct fields.
  40. }
  41. it := c.ListServiceAccounts(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 ExampleIamClient_GetServiceAccount() {
  55. ctx := context.Background()
  56. c, err := admin.NewIamClient(ctx)
  57. if err != nil {
  58. // TODO: Handle error.
  59. }
  60. req := &adminpb.GetServiceAccountRequest{
  61. // TODO: Fill request struct fields.
  62. }
  63. resp, err := c.GetServiceAccount(ctx, req)
  64. if err != nil {
  65. // TODO: Handle error.
  66. }
  67. // TODO: Use resp.
  68. _ = resp
  69. }
  70. func ExampleIamClient_CreateServiceAccount() {
  71. ctx := context.Background()
  72. c, err := admin.NewIamClient(ctx)
  73. if err != nil {
  74. // TODO: Handle error.
  75. }
  76. req := &adminpb.CreateServiceAccountRequest{
  77. // TODO: Fill request struct fields.
  78. }
  79. resp, err := c.CreateServiceAccount(ctx, req)
  80. if err != nil {
  81. // TODO: Handle error.
  82. }
  83. // TODO: Use resp.
  84. _ = resp
  85. }
  86. func ExampleIamClient_UpdateServiceAccount() {
  87. ctx := context.Background()
  88. c, err := admin.NewIamClient(ctx)
  89. if err != nil {
  90. // TODO: Handle error.
  91. }
  92. req := &adminpb.ServiceAccount{
  93. // TODO: Fill request struct fields.
  94. }
  95. resp, err := c.UpdateServiceAccount(ctx, req)
  96. if err != nil {
  97. // TODO: Handle error.
  98. }
  99. // TODO: Use resp.
  100. _ = resp
  101. }
  102. func ExampleIamClient_DeleteServiceAccount() {
  103. ctx := context.Background()
  104. c, err := admin.NewIamClient(ctx)
  105. if err != nil {
  106. // TODO: Handle error.
  107. }
  108. req := &adminpb.DeleteServiceAccountRequest{
  109. // TODO: Fill request struct fields.
  110. }
  111. err = c.DeleteServiceAccount(ctx, req)
  112. if err != nil {
  113. // TODO: Handle error.
  114. }
  115. }
  116. func ExampleIamClient_ListServiceAccountKeys() {
  117. ctx := context.Background()
  118. c, err := admin.NewIamClient(ctx)
  119. if err != nil {
  120. // TODO: Handle error.
  121. }
  122. req := &adminpb.ListServiceAccountKeysRequest{
  123. // TODO: Fill request struct fields.
  124. }
  125. resp, err := c.ListServiceAccountKeys(ctx, req)
  126. if err != nil {
  127. // TODO: Handle error.
  128. }
  129. // TODO: Use resp.
  130. _ = resp
  131. }
  132. func ExampleIamClient_GetServiceAccountKey() {
  133. ctx := context.Background()
  134. c, err := admin.NewIamClient(ctx)
  135. if err != nil {
  136. // TODO: Handle error.
  137. }
  138. req := &adminpb.GetServiceAccountKeyRequest{
  139. // TODO: Fill request struct fields.
  140. }
  141. resp, err := c.GetServiceAccountKey(ctx, req)
  142. if err != nil {
  143. // TODO: Handle error.
  144. }
  145. // TODO: Use resp.
  146. _ = resp
  147. }
  148. func ExampleIamClient_CreateServiceAccountKey() {
  149. ctx := context.Background()
  150. c, err := admin.NewIamClient(ctx)
  151. if err != nil {
  152. // TODO: Handle error.
  153. }
  154. req := &adminpb.CreateServiceAccountKeyRequest{
  155. // TODO: Fill request struct fields.
  156. }
  157. resp, err := c.CreateServiceAccountKey(ctx, req)
  158. if err != nil {
  159. // TODO: Handle error.
  160. }
  161. // TODO: Use resp.
  162. _ = resp
  163. }
  164. func ExampleIamClient_DeleteServiceAccountKey() {
  165. ctx := context.Background()
  166. c, err := admin.NewIamClient(ctx)
  167. if err != nil {
  168. // TODO: Handle error.
  169. }
  170. req := &adminpb.DeleteServiceAccountKeyRequest{
  171. // TODO: Fill request struct fields.
  172. }
  173. err = c.DeleteServiceAccountKey(ctx, req)
  174. if err != nil {
  175. // TODO: Handle error.
  176. }
  177. }
  178. func ExampleIamClient_SignBlob() {
  179. ctx := context.Background()
  180. c, err := admin.NewIamClient(ctx)
  181. if err != nil {
  182. // TODO: Handle error.
  183. }
  184. req := &adminpb.SignBlobRequest{
  185. // TODO: Fill request struct fields.
  186. }
  187. resp, err := c.SignBlob(ctx, req)
  188. if err != nil {
  189. // TODO: Handle error.
  190. }
  191. // TODO: Use resp.
  192. _ = resp
  193. }
  194. func ExampleIamClient_TestIamPermissions() {
  195. ctx := context.Background()
  196. c, err := admin.NewIamClient(ctx)
  197. if err != nil {
  198. // TODO: Handle error.
  199. }
  200. req := &iampb.TestIamPermissionsRequest{
  201. // TODO: Fill request struct fields.
  202. }
  203. resp, err := c.TestIamPermissions(ctx, req)
  204. if err != nil {
  205. // TODO: Handle error.
  206. }
  207. // TODO: Use resp.
  208. _ = resp
  209. }
  210. func ExampleIamClient_QueryGrantableRoles() {
  211. ctx := context.Background()
  212. c, err := admin.NewIamClient(ctx)
  213. if err != nil {
  214. // TODO: Handle error.
  215. }
  216. req := &adminpb.QueryGrantableRolesRequest{
  217. // TODO: Fill request struct fields.
  218. }
  219. resp, err := c.QueryGrantableRoles(ctx, req)
  220. if err != nil {
  221. // TODO: Handle error.
  222. }
  223. // TODO: Use resp.
  224. _ = resp
  225. }
  226. func ExampleIamClient_SignJwt() {
  227. ctx := context.Background()
  228. c, err := admin.NewIamClient(ctx)
  229. if err != nil {
  230. // TODO: Handle error.
  231. }
  232. req := &adminpb.SignJwtRequest{
  233. // TODO: Fill request struct fields.
  234. }
  235. resp, err := c.SignJwt(ctx, req)
  236. if err != nil {
  237. // TODO: Handle error.
  238. }
  239. // TODO: Use resp.
  240. _ = resp
  241. }