def GetAlgorithmMapper(api_version=None): messages = apis.GetMessagesModule(api_version) algorithm_enum = messages.PkixPublicKey.SignatureAlgorithmValueValuesEnum return arg_utils.ChoiceEnumMapper( 'algorithm_enum', algorithm_enum, include_filter=lambda name: 'UNSPECIFIED' not in name)
def Run(self, args): """Runs the command. Args: args: argparse.Namespace with command-line arguments. Returns: The policy resource. """ policy_resource_name = args.CONCEPTS.policy_resource_name.Parse() # Load the policy file into a Python dict. policy_obj = parsing.LoadResourceFile( # Avoid 'u' prefix in Python 2 when this file path gets embedded in # error messages. six.ensure_str(args.policy_file)) # Decode the dict into a PlatformPolicy message, allowing DecodeErrors to # bubble up to the user if they are raised. policy = messages_util.DictToMessageWithErrorCheck( policy_obj, # The API is only available in v1. apis.GetMessagesModule('v1').PlatformPolicy) return platform_policy.Client('v1').Create(policy_resource_name, policy)
def Run(self, args): # The API is only available in v1. messages = apis.GetMessagesModule('v1') policy_ref = args.CONCEPTS.policy_resource_name.Parse().RelativeName() # Load the policy file into a Python dict. policy_obj = parsing.LoadResourceFile(args.policy_file) # Decode the dict into a PlatformPolicy message, allowing DecodeErrors to # bubble up to the user if they are raised. policy = messages_util.DictToMessageWithErrorCheck( policy_obj, messages.PlatformPolicy) return platform_policy.Client('v1').Update(policy_ref, policy)
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 __init__(self, api_version=None): self.client = apis.GetClientInstance(api_version) self.messages = apis.GetMessagesModule(api_version)
def __init__(self, client=None, messages=None): self.client = client or apis.GetClientInstance() self.messages = messages or apis.GetMessagesModule()