package iam import ( "context" "google.golang.org/api/cloudresourcemanager/v1" ) // CreatePolicy returns a new cloudresourcemanager policy. func CreatePolicy(bindings []*cloudresourcemanager.Binding) *cloudresourcemanager.Policy { return &cloudresourcemanager.Policy{ Bindings: bindings, } } // CreatePolicyBinding returns a new cloudresourcemanager binding with the specified role and members. func CreatePolicyBinding(role string, members []string) *cloudresourcemanager.Binding { return &cloudresourcemanager.Binding{ Role: role, Members: members, } } // GetPolicy returns the policy for a specified resource. func (crmService *CloudResourceManagerService) GetPolicy(ctx context.Context, projectID string) (*cloudresourcemanager.Policy, error) { request := new(cloudresourcemanager.GetIamPolicyRequest) return crmService.Projects.GetIamPolicy(projectID, request).Context(ctx).Do() } // SetPolicy sets the policy for the specified resources. func (crmService *CloudResourceManagerService) SetPolicy(ctx context.Context, projectID string, policy *cloudresourcemanager.Policy) (*cloudresourcemanager.Policy, error) { request := new(cloudresourcemanager.SetIamPolicyRequest) request.Policy = policy return crmService.Projects.SetIamPolicy(projectID, request).Context(ctx).Do() }