Пример #1
0
    def Run(self, args):
        messages = cloudkms_base.GetMessagesModule()

        policy = iam_util.ParseYamlorJsonPolicyFile(args.policy_file,
                                                    messages.Policy)

        crypto_key_ref = flags.ParseCryptoKeyName(args)
        result = iam.SetCryptoKeyIamPolicy(crypto_key_ref, policy)
        iam_util.LogSetIamPolicy(crypto_key_ref.Name(), 'CryptoKey')
        return result
Пример #2
0
    def Run(self, args):
        messages = cloudkms_base.GetMessagesModule()

        policy = iam_util.ParseYamlorJsonPolicyFile(args.policy_file,
                                                    messages.Policy)
        update_mask = iam_util.ConstructUpdateMaskFromPolicy(args.policy_file)

        keyring_ref = flags.ParseKeyRingName(args)
        result = iam.SetKeyRingIamPolicy(keyring_ref, policy, update_mask)
        iam_util.LogSetIamPolicy(keyring_ref.Name(), 'keyring')
        return result
    def Run(self, args):
        """Sets the IAM policy for the repository.

    Args:
      args: argparse.Namespace, the arguments this command is run with.

    Returns:
      (sourcerepo_v1_messsages.Policy) The IAM policy.

    Raises:
      ToolException: on project initialization errors.
    """
        res = sourcerepo.ParseRepo(args.name)
        source = sourcerepo.Source()
        policy = iam_util.ParseYamlorJsonPolicyFile(args.policy_file,
                                                    source.messages.Policy)
        result = source.SetIamPolicy(res, policy)
        iam_util.LogSetIamPolicy(res.Name(), 'repo')
        return result
Пример #4
0
    def Run(self, args):
        """Sets the IAM policy for the repository.

    Args:
      args: argparse.Namespace, the arguments this command is run with.

    Returns:
      (sourcerepo_v1_messsages.Policy) The IAM policy.

    Raises:
      sourcerepo.RepoResourceError: on resource initialization errors.
      iam_util.BadFileException: if the YAML or JSON file is malformed.
      iam_util.IamEtagReadError: if the etag is badly formatted.
      apitools.base.py.exceptions.HttpError: on request errors.
    """
        res = sourcerepo.ParseRepo(args.name)
        source = sourcerepo.Source()
        policy = iam_util.ParseYamlorJsonPolicyFile(args.policy_file,
                                                    source.messages.Policy)
        result = source.SetIamPolicy(res, policy)
        iam_util.LogSetIamPolicy(res.Name(), 'repo')
        return result
Пример #5
0
  def Run(self, args):
    """Sets the IAM policy for the repository.

    Args:
      args: argparse.Namespace, the arguments this command is run with.

    Returns:
      (sourcerepo_v1_messsages.Policy) The IAM policy.

    Raises:
      ToolException: on project initialization errors.
    """
    res = resources.REGISTRY.Parse(
        args.name,
        params={'projectsId': properties.VALUES.core.project.GetOrFail},
        collection='sourcerepo.projects.repos')
    policy = iam_util.ParseYamlorJsonPolicyFile(args.policy_file,
                                                sourcerepo.messages.Policy)
    source = sourcerepo.Source()
    result = source.SetIamPolicy(res, policy)
    iam_util.LogSetIamPolicy(res.Name(), 'repo')
    return result