Ejemplo n.º 1
0
  def Run(self, args):
    client = iam.Client()
    policy_ref = util.GetPolicyRef()

    policy, _ = iam_util.ParseYamlOrJsonPolicyFile(args.policy_file,
                                                   client.messages.IamPolicy)

    result = client.Set(policy_ref, policy)
    iam_util.LogSetIamPolicy(policy_ref.Name(), 'policy')
    return result
Ejemplo n.º 2
0
    def Run(self, args):
        api_version = apis.GetApiVersion(self.ReleaseTrack())
        client = iam.Client(api_version)
        policy_ref = util.GetPolicyRef()

        policy, _ = iam_util.ParseYamlOrJsonPolicyFile(
            args.policy_file, client.messages.IamPolicy)

        result = client.Set(policy_ref, policy)
        iam_util.LogSetIamPolicy(policy_ref.Name(), 'policy')
        return result
Ejemplo n.º 3
0
 def Run(self, args):
   api_version = apis.GetApiVersion(self.ReleaseTrack())
   ref = util.GetPolicyRef()
   if ref.Name() == OLD_SYSTEM_POLICY_PROJECT_NAME:
     raise Error(
         'The Binary Authorization system policy is no longer accessible via '
         'the binauthz-global-policy project. Use the following command to '
         'display the system policy:\n'
         '    $ gcloud alpha container binauthz policy export-system-policy\n'
         'For details, see https://cloud.google.com/binary-authorization/docs/'
         'key-concepts#google-maintained_system_images.')
   return policies.Client(api_version).Get(ref)
Ejemplo n.º 4
0
  def Run(self, args):
    api_version = apis.GetApiVersion(self.ReleaseTrack())
    messages = apis.GetMessagesModule(api_version)

    # Load the policy file into a Python object.
    policy_obj = parsing.LoadResourceFile(args.policy_file)
    if not policy_obj:
      # NOTE: This is necessary because apitools falls over when you provide it
      # with None and that's what the yaml returns when passed an empty string.
      policy_obj = {}

      # Make sure the user meant to do this.
      log.warning('Empty Policy provided!')
      console_io.PromptContinue(
          prompt_string='Do you want to import an empty policy?',
          cancel_on_no=True)

    # Decode the dict into a Policy message, allowing DecodeErrors to bubble up
    # to the user if they are raised.
    policy = encoding.DictToMessageWithErrorCheck(policy_obj, messages.Policy)

    return policies.Client(api_version).Set(util.GetPolicyRef(), policy)
 def Run(self, args):
     api_version = apis.GetApiVersion(self.ReleaseTrack())
     return iam.Client(api_version).RemoveBinding(util.GetPolicyRef(),
                                                  args.member, args.role)
Ejemplo n.º 6
0
 def Run(self, args):
     return iam.Client().AddBinding(util.GetPolicyRef(), args.member,
                                    args.role)
Ejemplo n.º 7
0
 def Run(self, args):
     api_version = apis.GetApiVersion(self.ReleaseTrack())
     return iam.Client(api_version).Get(util.GetPolicyRef())
Ejemplo n.º 8
0
 def Run(self, args):
   return iam.Client().Get(util.GetPolicyRef())