Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 

54 рядки
1.7 KiB

  1. // Copyright 2016 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. // http://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. // This is handwritten code. These methods are implemented by hand so they can use
  15. // the iam.Policy type.
  16. package admin
  17. import (
  18. "context"
  19. "cloud.google.com/go/iam"
  20. iampb "google.golang.org/genproto/googleapis/iam/v1"
  21. )
  22. // GetIamPolicy returns the IAM access control policy for a ServiceAccount.
  23. func (c *IamClient) GetIamPolicy(ctx context.Context, req *iampb.GetIamPolicyRequest) (*iam.Policy, error) {
  24. policy, err := c.getIamPolicy(ctx, req)
  25. if err != nil {
  26. return nil, err
  27. }
  28. return &iam.Policy{InternalProto: policy}, nil
  29. }
  30. // SetIamPolicyRequest is the request type for the SetIamPolicy method.
  31. type SetIamPolicyRequest struct {
  32. Resource string
  33. Policy *iam.Policy
  34. }
  35. // SetIamPolicy sets the IAM access control policy for a ServiceAccount.
  36. func (c *IamClient) SetIamPolicy(ctx context.Context, req *SetIamPolicyRequest) (*iam.Policy, error) {
  37. preq := &iampb.SetIamPolicyRequest{
  38. Resource: req.Resource,
  39. Policy: req.Policy.InternalProto,
  40. }
  41. policy, err := c.setIamPolicy(ctx, preq)
  42. if err != nil {
  43. return nil, err
  44. }
  45. return &iam.Policy{InternalProto: policy}, nil
  46. }