Package cloud.google.com/go/iam/admin/apiv1 (v0.10.0)

Package admin is an auto-generated package for the Identity and Access Management (IAM) API.

Manages identity and access control for Google Cloud Platform resources, including the creation of service accounts, which you can use to authenticate to Google and make API calls.

 NOTE 
 : 
  
 This 
  
 package 
  
 is 
  
 in 
  
 beta 
 . 
  
 It 
  
 is 
  
 not 
  
 stable 
 , 
  
 and 
  
 may 
  
 be 
  
 subject 
  
 to 
  
 changes 
 . 

Example usage

To get started with this package, create a client.

 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
 // This snippet has been automatically generated and should be regarded as a code template only. 
 // It will require modifications to work: 
 // - It may require correct/in-range values for request initialization. 
 // - It may require specifying regional endpoints when creating the service client as shown in: 
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
 c 
 , 
  
 err 
  
 := 
  
 admin 
 . 
 NewIamClient 
 ( 
 ctx 
 ) 
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
 } 
 defer 
  
 c 
 . 
 Close 
 () 

The client will use your default application credentials. Clients should be reused instead of created as needed. The methods of Client are safe for concurrent use by multiple goroutines. The returned client must be Closed when it is done being used.

Using the Client

The following is an example of making an API call with the newly created client.

 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
 // This snippet has been automatically generated and should be regarded as a code template only. 
 // It will require modifications to work: 
 // - It may require correct/in-range values for request initialization. 
 // - It may require specifying regional endpoints when creating the service client as shown in: 
 //   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options 
 c 
 , 
  
 err 
  
 := 
  
 admin 
 . 
 NewIamClient 
 ( 
 ctx 
 ) 
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
 } 
 defer 
  
 c 
 . 
 Close 
 () 
 req 
  
 := 
  
& adminpb 
 . 
 ListServiceAccountsRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 // See https://pkg.go.dev/google.golang.org/genproto/googleapis/iam/admin/v1#ListServiceAccountsRequest. 
 } 
 it 
  
 := 
  
 c 
 . 
 ListServiceAccounts 
 ( 
 ctx 
 , 
  
 req 
 ) 
 for 
  
 { 
  
 resp 
 , 
  
 err 
  
 := 
  
 it 
 . 
 Next 
 () 
  
 if 
  
 err 
  
 == 
  
 iterator 
 . 
 Done 
  
 { 
  
 break 
  
 } 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 

Use of Context

The ctx passed to NewIamClient is used for authentication requests and for creating the underlying connection, but is not used for subsequent calls. Individual methods on the client use the ctx given to them.

To close the open connection, use the Close() method.

For information about setting deadlines, reusing contexts, and more please visit https://pkg.go.dev/cloud.google.com/go .

Functions

func DefaultAuthScopes

  func 
  
 DefaultAuthScopes 
 () 
  
 [] 
  string 
 
 

DefaultAuthScopes reports the default set of authentication scopes to use with this package.

func IamKeyPath

  func 
  
 IamKeyPath 
 ( 
 project 
 , 
  
 serviceAccount 
 , 
  
 key 
  
  string 
 
 ) 
  
  string 
 
 

IamKeyPath returns the path for the key resource.

func IamProjectPath

  func 
  
 IamProjectPath 
 ( 
 project 
  
  string 
 
 ) 
  
  string 
 
 

IamProjectPath returns the path for the project resource.

func IamServiceAccountPath

  func 
  
 IamServiceAccountPath 
 ( 
 project 
 , 
  
 serviceAccount 
  
  string 
 
 ) 
  
  string 
 
 

IamServiceAccountPath returns the path for the service account resource.

IamCallOptions

  type 
  
 IamCallOptions 
  
 struct 
  
 { 
  
 ListServiceAccounts 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 GetServiceAccount 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 CreateServiceAccount 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 UpdateServiceAccount 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 DeleteServiceAccount 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 ListServiceAccountKeys 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 GetServiceAccountKey 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 CreateServiceAccountKey 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 DeleteServiceAccountKey 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 SignBlob 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 GetIamPolicy 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 SetIamPolicy 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 TestIamPermissions 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 QueryGrantableRoles 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 SignJwt 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 ListRoles 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 GetRole 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 CreateRole 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 UpdateRole 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 DeleteRole 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 UndeleteRole 
  
 [] 
  gax 
 
 . 
  CallOption 
 
  
 QueryTestablePermissions 
  
 [] 
  gax 
 
 . 
  CallOption 
 
 } 
 

IamCallOptions contains the retry settings for each method of IamClient.

IamClient

  type 
  
 IamClient 
  
 struct 
  
 { 
  
 // The call options for this service. 
  
 CallOptions 
  
 * 
  IamCallOptions 
 
  
 // contains filtered or unexported fields 
 } 
 

IamClient is a client for interacting with Google Identity and Access Management (IAM) API.

Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.

func NewIamClient

  func 
  
 NewIamClient 
 ( 
 ctx 
  
  context 
 
 . 
  Context 
 
 , 
  
 opts 
  
 ... 
  option 
 
 . 
  ClientOption 
 
 ) 
  
 ( 
 * 
  IamClient 
 
 , 
  
  error 
 
 ) 
 

NewIamClient creates a new iam client.

Creates and manages service account objects.

Service account is an account that belongs to your project instead of to an individual end user. It is used to authenticate calls to a Google API.

To create a service account, specify the project_id and account_id for the account. The account_id is unique within the project, and used to generate the service account email address and a stable unique_id.

All other methods can identify accounts using the format projects/{PROJECT_ID}/serviceAccounts/{SERVICE_ACCOUNT_EMAIL}. Using - as a wildcard for the project will infer the project from the account. The account value can be the email address or the unique_id of the service account.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 admin 
  
 "cloud.google.com/go/iam/admin/apiv1" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 c 
 , 
  
 err 
  
 := 
  
 admin 
 . 
  NewIamClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use client. 
  
 _ 
  
 = 
  
 c 
 } 
 

func (*IamClient) Close

  func 
  
 ( 
 c 
  
 * 
  IamClient 
 
 ) 
  
 Close 
 () 
  
  error 
 
 

Close closes the connection to the API service. The user should invoke this when the client is no longer required.

func (*IamClient) Connection

  func 
  
 ( 
 c 
  
 * 
  IamClient 
 
 ) 
  
 Connection 
 () 
  
 * 
  grpc 
 
 . 
  ClientConn 
 
 

Connection returns the client's connection to the API service.

func (*IamClient) CreateRole

CreateRole creates a new Role.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 admin 
  
 "cloud.google.com/go/iam/admin/apiv1" 
  
 adminpb 
  
 "google.golang.org/genproto/googleapis/iam/admin/v1" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 c 
 , 
  
 err 
  
 := 
  
 admin 
 . 
  NewIamClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 req 
  
 := 
  
& adminpb 
 . 
  CreateRoleRequest 
 
 { 
  
 // TODO: Fill request struct fields. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 CreateRole 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

func (*IamClient) CreateServiceAccount

CreateServiceAccount creates a [ServiceAccount][google.iam.admin.v1.ServiceAccount] and returns it.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 admin 
  
 "cloud.google.com/go/iam/admin/apiv1" 
  
 adminpb 
  
 "google.golang.org/genproto/googleapis/iam/admin/v1" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 c 
 , 
  
 err 
  
 := 
  
 admin 
 . 
  NewIamClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 req 
  
 := 
  
& adminpb 
 . 
  CreateServiceAccountRequest 
 
 { 
  
 // TODO: Fill request struct fields. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 CreateServiceAccount 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

func (*IamClient) CreateServiceAccountKey

CreateServiceAccountKey creates a [ServiceAccountKey][google.iam.admin.v1.ServiceAccountKey] and returns it.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 admin 
  
 "cloud.google.com/go/iam/admin/apiv1" 
  
 adminpb 
  
 "google.golang.org/genproto/googleapis/iam/admin/v1" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 c 
 , 
  
 err 
  
 := 
  
 admin 
 . 
  NewIamClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 req 
  
 := 
  
& adminpb 
 . 
  CreateServiceAccountKeyRequest 
 
 { 
  
 // TODO: Fill request struct fields. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 CreateServiceAccountKey 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

func (*IamClient) DeleteRole

DeleteRole soft deletes a role. The role is suspended and cannot be used to create new IAM Policy Bindings. The Role will not be included in ListRoles() unless show_deleted is set in the ListRolesRequest. The Role contains the deleted boolean set. Existing Bindings remains, but are inactive. The Role can be undeleted within 7 days. After 7 days the Role is deleted and all Bindings associated with the role are removed.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 admin 
  
 "cloud.google.com/go/iam/admin/apiv1" 
  
 adminpb 
  
 "google.golang.org/genproto/googleapis/iam/admin/v1" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 c 
 , 
  
 err 
  
 := 
  
 admin 
 . 
  NewIamClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 req 
  
 := 
  
& adminpb 
 . 
  DeleteRoleRequest 
 
 { 
  
 // TODO: Fill request struct fields. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 DeleteRole 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

func (*IamClient) DeleteServiceAccount

DeleteServiceAccount deletes a [ServiceAccount][google.iam.admin.v1.ServiceAccount].

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 admin 
  
 "cloud.google.com/go/iam/admin/apiv1" 
  
 adminpb 
  
 "google.golang.org/genproto/googleapis/iam/admin/v1" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 c 
 , 
  
 err 
  
 := 
  
 admin 
 . 
  NewIamClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 req 
  
 := 
  
& adminpb 
 . 
  DeleteServiceAccountRequest 
 
 { 
  
 // TODO: Fill request struct fields. 
  
 } 
  
 err 
  
 = 
  
 c 
 . 
 DeleteServiceAccount 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
 } 
 

func (*IamClient) DeleteServiceAccountKey

  func 
  
 ( 
 c 
  
 * 
  IamClient 
 
 ) 
  
 DeleteServiceAccountKey 
 ( 
 ctx 
  
  context 
 
 . 
  Context 
 
 , 
  
 req 
  
 * 
  adminpb 
 
 . 
  DeleteServiceAccountKeyRequest 
 
 , 
  
 opts 
  
 ... 
  gax 
 
 . 
  CallOption 
 
 ) 
  
  error 
 
 

DeleteServiceAccountKey deletes a [ServiceAccountKey][google.iam.admin.v1.ServiceAccountKey].

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 admin 
  
 "cloud.google.com/go/iam/admin/apiv1" 
  
 adminpb 
  
 "google.golang.org/genproto/googleapis/iam/admin/v1" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 c 
 , 
  
 err 
  
 := 
  
 admin 
 . 
  NewIamClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 req 
  
 := 
  
& adminpb 
 . 
  DeleteServiceAccountKeyRequest 
 
 { 
  
 // TODO: Fill request struct fields. 
  
 } 
  
 err 
  
 = 
  
 c 
 . 
 DeleteServiceAccountKey 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
 } 
 

func (*IamClient) GetIamPolicy

GetIamPolicy returns the IAM access control policy for a ServiceAccount.

func (*IamClient) GetRole

GetRole gets a Role definition.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 admin 
  
 "cloud.google.com/go/iam/admin/apiv1" 
  
 adminpb 
  
 "google.golang.org/genproto/googleapis/iam/admin/v1" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 c 
 , 
  
 err 
  
 := 
  
 admin 
 . 
  NewIamClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 req 
  
 := 
  
& adminpb 
 . 
  GetRoleRequest 
 
 { 
  
 // TODO: Fill request struct fields. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 GetRole 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

func (*IamClient) GetServiceAccount

GetServiceAccount gets a [ServiceAccount][google.iam.admin.v1.ServiceAccount].

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 admin 
  
 "cloud.google.com/go/iam/admin/apiv1" 
  
 adminpb 
  
 "google.golang.org/genproto/googleapis/iam/admin/v1" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 c 
 , 
  
 err 
  
 := 
  
 admin 
 . 
  NewIamClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 req 
  
 := 
  
& adminpb 
 . 
  GetServiceAccountRequest 
 
 { 
  
 // TODO: Fill request struct fields. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 GetServiceAccount 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

func (*IamClient) GetServiceAccountKey

GetServiceAccountKey gets the [ServiceAccountKey][google.iam.admin.v1.ServiceAccountKey] by key id.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 admin 
  
 "cloud.google.com/go/iam/admin/apiv1" 
  
 adminpb 
  
 "google.golang.org/genproto/googleapis/iam/admin/v1" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 c 
 , 
  
 err 
  
 := 
  
 admin 
 . 
  NewIamClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 req 
  
 := 
  
& adminpb 
 . 
  GetServiceAccountKeyRequest 
 
 { 
  
 // TODO: Fill request struct fields. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 GetServiceAccountKey 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

func (*IamClient) ListRoles

ListRoles lists the Roles defined on a resource.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 admin 
  
 "cloud.google.com/go/iam/admin/apiv1" 
  
 adminpb 
  
 "google.golang.org/genproto/googleapis/iam/admin/v1" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 c 
 , 
  
 err 
  
 := 
  
 admin 
 . 
  NewIamClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 req 
  
 := 
  
& adminpb 
 . 
  ListRolesRequest 
 
 { 
  
 // TODO: Fill request struct fields. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 ListRoles 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

func (*IamClient) ListServiceAccountKeys

ListServiceAccountKeys lists [ServiceAccountKeys][google.iam.admin.v1.ServiceAccountKey].

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 admin 
  
 "cloud.google.com/go/iam/admin/apiv1" 
  
 adminpb 
  
 "google.golang.org/genproto/googleapis/iam/admin/v1" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 c 
 , 
  
 err 
  
 := 
  
 admin 
 . 
  NewIamClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 req 
  
 := 
  
& adminpb 
 . 
  ListServiceAccountKeysRequest 
 
 { 
  
 // TODO: Fill request struct fields. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 ListServiceAccountKeys 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

func (*IamClient) ListServiceAccounts

ListServiceAccounts lists [ServiceAccounts][google.iam.admin.v1.ServiceAccount] for a project.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 admin 
  
 "cloud.google.com/go/iam/admin/apiv1" 
  
 "google.golang.org/api/iterator" 
  
 adminpb 
  
 "google.golang.org/genproto/googleapis/iam/admin/v1" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 c 
 , 
  
 err 
  
 := 
  
 admin 
 . 
  NewIamClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 req 
  
 := 
  
& adminpb 
 . 
  ListServiceAccountsRequest 
 
 { 
  
 // TODO: Fill request struct fields. 
  
 } 
  
 it 
  
 := 
  
 c 
 . 
 ListServiceAccounts 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 for 
  
 { 
  
 resp 
 , 
  
 err 
  
 := 
  
 it 
 . 
 Next 
 () 
  
 if 
  
 err 
  
 == 
  
 iterator 
 . 
 Done 
  
 { 
  
 break 
  
 } 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
  
 } 
 } 
 

func (*IamClient) QueryGrantableRoles

QueryGrantableRoles queries roles that can be granted on a particular resource. A role is grantable if it can be used as the role in a binding for a policy for that resource.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 admin 
  
 "cloud.google.com/go/iam/admin/apiv1" 
  
 adminpb 
  
 "google.golang.org/genproto/googleapis/iam/admin/v1" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 c 
 , 
  
 err 
  
 := 
  
 admin 
 . 
  NewIamClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 req 
  
 := 
  
& adminpb 
 . 
  QueryGrantableRolesRequest 
 
 { 
  
 // TODO: Fill request struct fields. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 QueryGrantableRoles 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

func (*IamClient) QueryTestablePermissions

QueryTestablePermissions lists the permissions testable on a resource. A permission is testable if it can be tested for an identity on a resource.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 admin 
  
 "cloud.google.com/go/iam/admin/apiv1" 
  
 adminpb 
  
 "google.golang.org/genproto/googleapis/iam/admin/v1" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 c 
 , 
  
 err 
  
 := 
  
 admin 
 . 
  NewIamClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 req 
  
 := 
  
& adminpb 
 . 
  QueryTestablePermissionsRequest 
 
 { 
  
 // TODO: Fill request struct fields. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 QueryTestablePermissions 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

func (*IamClient) SetIamPolicy

  func 
  
 ( 
 c 
  
 * 
  IamClient 
 
 ) 
  
 SetIamPolicy 
 ( 
 ctx 
  
  context 
 
 . 
  Context 
 
 , 
  
 req 
  
 * 
  SetIamPolicyRequest 
 
 ) 
  
 ( 
 * 
  iam 
 
 . 
  Policy 
 
 , 
  
  error 
 
 ) 
 

SetIamPolicy sets the IAM access control policy for a ServiceAccount.

func (*IamClient) SignBlob

SignBlob signs a blob using a service account's system-managed private key.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 admin 
  
 "cloud.google.com/go/iam/admin/apiv1" 
  
 adminpb 
  
 "google.golang.org/genproto/googleapis/iam/admin/v1" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 c 
 , 
  
 err 
  
 := 
  
 admin 
 . 
  NewIamClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 req 
  
 := 
  
& adminpb 
 . 
  SignBlobRequest 
 
 { 
  
 // TODO: Fill request struct fields. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 SignBlob 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

func (*IamClient) SignJwt

SignJwt signs a JWT using a service account's system-managed private key.

If no expiry time (exp) is provided in the SignJwtRequest, IAM sets an an expiry time of one hour by default. If you request an expiry time of more than one hour, the request will fail.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 admin 
  
 "cloud.google.com/go/iam/admin/apiv1" 
  
 adminpb 
  
 "google.golang.org/genproto/googleapis/iam/admin/v1" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 c 
 , 
  
 err 
  
 := 
  
 admin 
 . 
  NewIamClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 req 
  
 := 
  
& adminpb 
 . 
  SignJwtRequest 
 
 { 
  
 // TODO: Fill request struct fields. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 SignJwt 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

func (*IamClient) TestIamPermissions

TestIamPermissions tests the specified permissions against the IAM access control policy for a [ServiceAccount][google.iam.admin.v1.ServiceAccount].

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 admin 
  
 "cloud.google.com/go/iam/admin/apiv1" 
  
 iampb 
  
 "google.golang.org/genproto/googleapis/iam/v1" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 c 
 , 
  
 err 
  
 := 
  
 admin 
 . 
  NewIamClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 req 
  
 := 
  
& iampb 
 . 
 TestIamPermissionsRequest 
 { 
  
 // TODO: Fill request struct fields. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 TestIamPermissions 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

func (*IamClient) UndeleteRole

UndeleteRole undelete a Role, bringing it back in its previous state.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 admin 
  
 "cloud.google.com/go/iam/admin/apiv1" 
  
 adminpb 
  
 "google.golang.org/genproto/googleapis/iam/admin/v1" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 c 
 , 
  
 err 
  
 := 
  
 admin 
 . 
  NewIamClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 req 
  
 := 
  
& adminpb 
 . 
  UndeleteRoleRequest 
 
 { 
  
 // TODO: Fill request struct fields. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 UndeleteRole 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

func (*IamClient) UpdateRole

UpdateRole updates a Role definition.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 admin 
  
 "cloud.google.com/go/iam/admin/apiv1" 
  
 adminpb 
  
 "google.golang.org/genproto/googleapis/iam/admin/v1" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 c 
 , 
  
 err 
  
 := 
  
 admin 
 . 
  NewIamClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 req 
  
 := 
  
& adminpb 
 . 
  UpdateRoleRequest 
 
 { 
  
 // TODO: Fill request struct fields. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 UpdateRole 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

func (*IamClient) UpdateServiceAccount

UpdateServiceAccount updates a [ServiceAccount][google.iam.admin.v1.ServiceAccount].

Currently, only the following fields are updatable: display_name . The etag is mandatory.

Example

  package 
  
 main 
 import 
  
 ( 
  
 "context" 
  
 admin 
  
 "cloud.google.com/go/iam/admin/apiv1" 
  
 adminpb 
  
 "google.golang.org/genproto/googleapis/iam/admin/v1" 
 ) 
 func 
  
 main 
 () 
  
 { 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 c 
 , 
  
 err 
  
 := 
  
 admin 
 . 
  NewIamClient 
 
 ( 
 ctx 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 req 
  
 := 
  
& adminpb 
 . 
  ServiceAccount 
 
 { 
  
 // TODO: Fill request struct fields. 
  
 } 
  
 resp 
 , 
  
 err 
  
 := 
  
 c 
 . 
 UpdateServiceAccount 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 // TODO: Handle error. 
  
 } 
  
 // TODO: Use resp. 
  
 _ 
  
 = 
  
 resp 
 } 
 

ServiceAccountIterator

  type 
  
 ServiceAccountIterator 
  
 struct 
  
 { 
  
 // InternalFetch is for use by the Google Cloud Libraries only. 
  
 // It is not part of the stable interface of this package. 
  
 // 
  
 // InternalFetch returns results from a single call to the underlying RPC. 
  
 // The number of results is no greater than pageSize. 
  
 // If there are no more results, nextPageToken is empty and err is nil. 
  
 InternalFetch 
  
 func 
 ( 
 pageSize 
  
  int 
 
 , 
  
 pageToken 
  
  string 
 
 ) 
  
 ( 
 results 
  
 [] 
 * 
  adminpb 
 
 . 
  ServiceAccount 
 
 , 
  
 nextPageToken 
  
  string 
 
 , 
  
 err 
  
  error 
 
 ) 
  
 // contains filtered or unexported fields 
 } 
 

ServiceAccountIterator manages a stream of *adminpb.ServiceAccount.

func (*ServiceAccountIterator) Next

Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.

func (*ServiceAccountIterator) PageInfo

PageInfo supports pagination. See the google.golang.org/api/iterator package for details.

SetIamPolicyRequest

  type 
  
 SetIamPolicyRequest 
  
 struct 
  
 { 
  
 Resource 
  
  string 
 
  
 Policy 
  
 * 
  iam 
 
 . 
  Policy 
 
 } 
 

SetIamPolicyRequest is the request type for the SetIamPolicy method.

Create a Mobile Website
View Site in Mobile | Classic
Share by: