...

Source file src/cloud.google.com/go/iam/admin/apiv1/iam_client_example_test.go

Documentation: cloud.google.com/go/iam/admin/apiv1

     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  
    15  // Code generated by gapic-generator. DO NOT EDIT.
    16  
    17  package admin_test
    18  
    19  import (
    20  	"context"
    21  
    22  	admin "cloud.google.com/go/iam/admin/apiv1"
    23  	"cloud.google.com/go/iam/admin/apiv1/adminpb"
    24  	"cloud.google.com/go/iam/apiv1/iampb"
    25  	"google.golang.org/api/iterator"
    26  )
    27  
    28  func ExampleNewIamClient() {
    29  	ctx := context.Background()
    30  	c, err := admin.NewIamClient(ctx)
    31  	if err != nil {
    32  		// TODO: Handle error.
    33  	}
    34  	// TODO: Use client.
    35  	_ = c
    36  }
    37  
    38  func ExampleIamClient_ListServiceAccounts() {
    39  	ctx := context.Background()
    40  	c, err := admin.NewIamClient(ctx)
    41  	if err != nil {
    42  		// TODO: Handle error.
    43  	}
    44  
    45  	req := &adminpb.ListServiceAccountsRequest{
    46  		// TODO: Fill request struct fields.
    47  	}
    48  	it := c.ListServiceAccounts(ctx, req)
    49  	for {
    50  		resp, err := it.Next()
    51  		if err == iterator.Done {
    52  			break
    53  		}
    54  		if err != nil {
    55  			// TODO: Handle error.
    56  		}
    57  		// TODO: Use resp.
    58  		_ = resp
    59  	}
    60  }
    61  
    62  func ExampleIamClient_GetServiceAccount() {
    63  	ctx := context.Background()
    64  	c, err := admin.NewIamClient(ctx)
    65  	if err != nil {
    66  		// TODO: Handle error.
    67  	}
    68  
    69  	req := &adminpb.GetServiceAccountRequest{
    70  		// TODO: Fill request struct fields.
    71  	}
    72  	resp, err := c.GetServiceAccount(ctx, req)
    73  	if err != nil {
    74  		// TODO: Handle error.
    75  	}
    76  	// TODO: Use resp.
    77  	_ = resp
    78  }
    79  
    80  func ExampleIamClient_CreateServiceAccount() {
    81  	ctx := context.Background()
    82  	c, err := admin.NewIamClient(ctx)
    83  	if err != nil {
    84  		// TODO: Handle error.
    85  	}
    86  
    87  	req := &adminpb.CreateServiceAccountRequest{
    88  		// TODO: Fill request struct fields.
    89  	}
    90  	resp, err := c.CreateServiceAccount(ctx, req)
    91  	if err != nil {
    92  		// TODO: Handle error.
    93  	}
    94  	// TODO: Use resp.
    95  	_ = resp
    96  }
    97  
    98  func ExampleIamClient_UpdateServiceAccount() {
    99  	ctx := context.Background()
   100  	c, err := admin.NewIamClient(ctx)
   101  	if err != nil {
   102  		// TODO: Handle error.
   103  	}
   104  
   105  	req := &adminpb.ServiceAccount{
   106  		// TODO: Fill request struct fields.
   107  	}
   108  	resp, err := c.UpdateServiceAccount(ctx, req)
   109  	if err != nil {
   110  		// TODO: Handle error.
   111  	}
   112  	// TODO: Use resp.
   113  	_ = resp
   114  }
   115  
   116  func ExampleIamClient_DeleteServiceAccount() {
   117  	ctx := context.Background()
   118  	c, err := admin.NewIamClient(ctx)
   119  	if err != nil {
   120  		// TODO: Handle error.
   121  	}
   122  
   123  	req := &adminpb.DeleteServiceAccountRequest{
   124  		// TODO: Fill request struct fields.
   125  	}
   126  	err = c.DeleteServiceAccount(ctx, req)
   127  	if err != nil {
   128  		// TODO: Handle error.
   129  	}
   130  }
   131  
   132  func ExampleIamClient_ListServiceAccountKeys() {
   133  	ctx := context.Background()
   134  	c, err := admin.NewIamClient(ctx)
   135  	if err != nil {
   136  		// TODO: Handle error.
   137  	}
   138  
   139  	req := &adminpb.ListServiceAccountKeysRequest{
   140  		// TODO: Fill request struct fields.
   141  	}
   142  	resp, err := c.ListServiceAccountKeys(ctx, req)
   143  	if err != nil {
   144  		// TODO: Handle error.
   145  	}
   146  	// TODO: Use resp.
   147  	_ = resp
   148  }
   149  
   150  func ExampleIamClient_GetServiceAccountKey() {
   151  	ctx := context.Background()
   152  	c, err := admin.NewIamClient(ctx)
   153  	if err != nil {
   154  		// TODO: Handle error.
   155  	}
   156  
   157  	req := &adminpb.GetServiceAccountKeyRequest{
   158  		// TODO: Fill request struct fields.
   159  	}
   160  	resp, err := c.GetServiceAccountKey(ctx, req)
   161  	if err != nil {
   162  		// TODO: Handle error.
   163  	}
   164  	// TODO: Use resp.
   165  	_ = resp
   166  }
   167  
   168  func ExampleIamClient_CreateServiceAccountKey() {
   169  	ctx := context.Background()
   170  	c, err := admin.NewIamClient(ctx)
   171  	if err != nil {
   172  		// TODO: Handle error.
   173  	}
   174  
   175  	req := &adminpb.CreateServiceAccountKeyRequest{
   176  		// TODO: Fill request struct fields.
   177  	}
   178  	resp, err := c.CreateServiceAccountKey(ctx, req)
   179  	if err != nil {
   180  		// TODO: Handle error.
   181  	}
   182  	// TODO: Use resp.
   183  	_ = resp
   184  }
   185  
   186  func ExampleIamClient_DeleteServiceAccountKey() {
   187  	ctx := context.Background()
   188  	c, err := admin.NewIamClient(ctx)
   189  	if err != nil {
   190  		// TODO: Handle error.
   191  	}
   192  
   193  	req := &adminpb.DeleteServiceAccountKeyRequest{
   194  		// TODO: Fill request struct fields.
   195  	}
   196  	err = c.DeleteServiceAccountKey(ctx, req)
   197  	if err != nil {
   198  		// TODO: Handle error.
   199  	}
   200  }
   201  
   202  func ExampleIamClient_SignBlob() {
   203  	ctx := context.Background()
   204  	c, err := admin.NewIamClient(ctx)
   205  	if err != nil {
   206  		// TODO: Handle error.
   207  	}
   208  
   209  	req := &adminpb.SignBlobRequest{
   210  		// TODO: Fill request struct fields.
   211  	}
   212  	resp, err := c.SignBlob(ctx, req)
   213  	if err != nil {
   214  		// TODO: Handle error.
   215  	}
   216  	// TODO: Use resp.
   217  	_ = resp
   218  }
   219  
   220  func ExampleIamClient_TestIamPermissions() {
   221  	ctx := context.Background()
   222  	c, err := admin.NewIamClient(ctx)
   223  	if err != nil {
   224  		// TODO: Handle error.
   225  	}
   226  
   227  	req := &iampb.TestIamPermissionsRequest{
   228  		// TODO: Fill request struct fields.
   229  	}
   230  	resp, err := c.TestIamPermissions(ctx, req)
   231  	if err != nil {
   232  		// TODO: Handle error.
   233  	}
   234  	// TODO: Use resp.
   235  	_ = resp
   236  }
   237  
   238  func ExampleIamClient_QueryGrantableRoles() {
   239  	ctx := context.Background()
   240  	c, err := admin.NewIamClient(ctx)
   241  	if err != nil {
   242  		// TODO: Handle error.
   243  	}
   244  
   245  	req := &adminpb.QueryGrantableRolesRequest{
   246  		// TODO: Fill request struct fields.
   247  	}
   248  	resp, err := c.QueryGrantableRoles(ctx, req)
   249  	if err != nil {
   250  		// TODO: Handle error.
   251  	}
   252  	// TODO: Use resp.
   253  	_ = resp
   254  }
   255  
   256  func ExampleIamClient_SignJwt() {
   257  	ctx := context.Background()
   258  	c, err := admin.NewIamClient(ctx)
   259  	if err != nil {
   260  		// TODO: Handle error.
   261  	}
   262  
   263  	req := &adminpb.SignJwtRequest{
   264  		// TODO: Fill request struct fields.
   265  	}
   266  	resp, err := c.SignJwt(ctx, req)
   267  	if err != nil {
   268  		// TODO: Handle error.
   269  	}
   270  	// TODO: Use resp.
   271  	_ = resp
   272  }
   273  
   274  func ExampleIamClient_ListRoles() {
   275  	ctx := context.Background()
   276  	c, err := admin.NewIamClient(ctx)
   277  	if err != nil {
   278  		// TODO: Handle error.
   279  	}
   280  
   281  	req := &adminpb.ListRolesRequest{
   282  		// TODO: Fill request struct fields.
   283  	}
   284  	resp, err := c.ListRoles(ctx, req)
   285  	if err != nil {
   286  		// TODO: Handle error.
   287  	}
   288  	// TODO: Use resp.
   289  	_ = resp
   290  }
   291  
   292  func ExampleIamClient_GetRole() {
   293  	ctx := context.Background()
   294  	c, err := admin.NewIamClient(ctx)
   295  	if err != nil {
   296  		// TODO: Handle error.
   297  	}
   298  
   299  	req := &adminpb.GetRoleRequest{
   300  		// TODO: Fill request struct fields.
   301  	}
   302  	resp, err := c.GetRole(ctx, req)
   303  	if err != nil {
   304  		// TODO: Handle error.
   305  	}
   306  	// TODO: Use resp.
   307  	_ = resp
   308  }
   309  
   310  func ExampleIamClient_CreateRole() {
   311  	ctx := context.Background()
   312  	c, err := admin.NewIamClient(ctx)
   313  	if err != nil {
   314  		// TODO: Handle error.
   315  	}
   316  
   317  	req := &adminpb.CreateRoleRequest{
   318  		// TODO: Fill request struct fields.
   319  	}
   320  	resp, err := c.CreateRole(ctx, req)
   321  	if err != nil {
   322  		// TODO: Handle error.
   323  	}
   324  	// TODO: Use resp.
   325  	_ = resp
   326  }
   327  
   328  func ExampleIamClient_UpdateRole() {
   329  	ctx := context.Background()
   330  	c, err := admin.NewIamClient(ctx)
   331  	if err != nil {
   332  		// TODO: Handle error.
   333  	}
   334  
   335  	req := &adminpb.UpdateRoleRequest{
   336  		// TODO: Fill request struct fields.
   337  	}
   338  	resp, err := c.UpdateRole(ctx, req)
   339  	if err != nil {
   340  		// TODO: Handle error.
   341  	}
   342  	// TODO: Use resp.
   343  	_ = resp
   344  }
   345  
   346  func ExampleIamClient_DeleteRole() {
   347  	ctx := context.Background()
   348  	c, err := admin.NewIamClient(ctx)
   349  	if err != nil {
   350  		// TODO: Handle error.
   351  	}
   352  
   353  	req := &adminpb.DeleteRoleRequest{
   354  		// TODO: Fill request struct fields.
   355  	}
   356  	resp, err := c.DeleteRole(ctx, req)
   357  	if err != nil {
   358  		// TODO: Handle error.
   359  	}
   360  	// TODO: Use resp.
   361  	_ = resp
   362  }
   363  
   364  func ExampleIamClient_UndeleteRole() {
   365  	ctx := context.Background()
   366  	c, err := admin.NewIamClient(ctx)
   367  	if err != nil {
   368  		// TODO: Handle error.
   369  	}
   370  
   371  	req := &adminpb.UndeleteRoleRequest{
   372  		// TODO: Fill request struct fields.
   373  	}
   374  	resp, err := c.UndeleteRole(ctx, req)
   375  	if err != nil {
   376  		// TODO: Handle error.
   377  	}
   378  	// TODO: Use resp.
   379  	_ = resp
   380  }
   381  
   382  func ExampleIamClient_QueryTestablePermissions() {
   383  	ctx := context.Background()
   384  	c, err := admin.NewIamClient(ctx)
   385  	if err != nil {
   386  		// TODO: Handle error.
   387  	}
   388  
   389  	req := &adminpb.QueryTestablePermissionsRequest{
   390  		// TODO: Fill request struct fields.
   391  	}
   392  	resp, err := c.QueryTestablePermissions(ctx, req)
   393  	if err != nil {
   394  		// TODO: Handle error.
   395  	}
   396  	// TODO: Use resp.
   397  	_ = resp
   398  }
   399  

View as plain text