示例#1
0
def GetBucketArgsForUpdate():
    """Returns bucket-related args for crawler update."""
    bucket_group = base.ArgumentGroup(
        help='Update buckets to crawl. These arguments can be provided only if '
        'the crawler will be bucket-scoped after updating.')
    bucket_group.AddArgument(
        base.Argument('--add-buckets',
                      type=arg_parsers.ArgList(),
                      metavar='BUCKET',
                      help='List of buckets to add to the crawl scope.'))

    remove_bucket_group = base.ArgumentGroup(mutex=True)
    remove_bucket_group.AddArgument(
        base.Argument('--remove-buckets',
                      type=arg_parsers.ArgList(),
                      metavar='BUCKET',
                      help='List of buckets to remove from the crawl scope.'))
    remove_bucket_group.AddArgument(
        base.Argument(
            '--clear-buckets',
            action='store_true',
            help='If specified, clear the existing list of buckets in the crawl '
            'scope.'))

    bucket_group.AddArgument(remove_bucket_group)
    return bucket_group
示例#2
0
def AddCreateFlags(parser,
                   support_location_hint=False,
                   support_fleet=False,
                   support_share_setting=False):
    """Adds all flags needed for the create command."""
    GetDescriptionFlag().AddToParser(parser)

    group = base.ArgumentGroup(
        'Manage the specific SKU reservation properties to create',
        required=True)

    group.AddArgument(GetRequireSpecificAllocation())
    group.AddArgument(GetVmCountFlag())
    group.AddArgument(GetMinCpuPlatform())
    group.AddArgument(GetMachineType())
    group.AddArgument(GetLocalSsdFlag())
    group.AddArgument(GetAcceleratorFlag())
    if support_location_hint:
        group.AddArgument(GetLocationHint())
    if support_fleet:
        group.AddArgument(instance_flags.AddMaintenanceFreezeDuration())
        group.AddArgument(instance_flags.AddMaintenanceInterval())
    group.AddToParser(parser)

    if support_share_setting:
        share_group = base.ArgumentGroup(
            'Manage the properties of a shared reservation to create',
            required=False)
        share_group.AddArgument(GetSharedSettingFlag())
        share_group.AddArgument(GetShareWithFlag())
        share_group.AddToParser(parser)
示例#3
0
def AddTerraformGenerateImportArgs(parser):
    """Arguments for resource-config terraform generate-import command."""
    input_path_help = (
        'Path to a Terrafrom formatted (.tf) resource file or directory of files '
        'exported via. `gcloud alpha resource-config bulk-export` or '
        'resource surface specific `config export` command.')
    input_path = calliope_base.Argument('INPUT_PATH',
                                        type=files.ExpandHomeAndVars,
                                        help=input_path_help)

    output_args = calliope_base.ArgumentGroup(
        category='OUTPUT DESTINATION',
        mutex=True,
        help='Specify the destination of the generated script.')

    file_spec_group = calliope_base.ArgumentGroup(
        help=
        'Specify the exact filenames for the output import script and module files.'
    )

    file_spec_group.AddArgument(
        calliope_base.Argument(
            '--output-script-file',
            required=False,
            type=files.ExpandHomeAndVars,
            help=(
                'Specify the full path path for generated import script. If '
                'not set, a default filename of the form '
                '`terraform_import_YYYYMMDD-HH-MM-SS.sh|cmd` will be generated.'
            )))
    file_spec_group.AddArgument(
        calliope_base.Argument(
            '--output-module-file',
            required=False,
            type=files.ExpandHomeAndVars,
            help=
            ('Specify the full path path for generated terraform module file. If '
             'not set, a default filename of '
             '`gcloud-export-modules.tf` will be generated.')))
    output_args.AddArgument(file_spec_group)
    output_args.AddArgument(
        calliope_base.Argument(
            '--output-dir',
            required=False,
            type=files.ExpandHomeAndVars,
            help=
            ('Specify the output directory only for the generated import script.'
             ' If specified directory does not exists it will be created. '
             'Generated script will have a default name of the form '
             '`terraform_import_YYYYMMDD-HH-MM-SS.sh|cmd`')))
    input_path.AddToParser(parser)
    output_args.AddToParser(parser)
示例#4
0
def AddBasicAndCustomSpecArgs(parser, api_version):
    """Add args for basic and custom specs (grouped together)."""
    basic_level_help_text = (
        'Path to a file containing a list of basic access level conditions.\n\n'
        'An access level condition file is a YAML-formatted list of conditions,'
        'which are YAML objects representing a Condition as described in the API '
        'reference. For example:\n\n'
        '    ```\n'
        '     - ipSubnetworks:\n'
        '       - 162.222.181.197/24\n'
        '       - 2001:db8::/48\n'
        '     - members:\n'
        '       - user:[email protected]\n'
        '    ```')
    custom_level_help_text = (
        'Path to a file representing an expression for an access level.\n\n'
        'The expression is in the Common Expression Langague (CEL) format.'
        'For example:\n\n'
        '    ```\n'
        '     expression: "origin.region_code in [\'US\', \'CA\']"\n'
        '    ```')

    basic_level_spec_arg = base.Argument(
        '--basic-level-spec',
        help=basic_level_help_text,
        type=ParseBasicLevelConditions(api_version))
    basic_level_combine_arg = GetCombineFunctionEnumMapper(
        api_version=api_version).choice_arg

    basic_level_spec_group = base.ArgumentGroup(
        help='Basic level specification.')
    basic_level_spec_group.AddArgument(basic_level_spec_arg)
    basic_level_spec_group.AddArgument(basic_level_combine_arg)

    custom_level_spec_arg = base.Argument('--custom-level-spec',
                                          help=custom_level_help_text,
                                          type=ParseCustomLevel(api_version))

    # Custom level spec group only consists of a single argument.
    # This is done so help text between basic/custom specs is consistent.
    custom_level_spec_group = base.ArgumentGroup(
        help='Custom level specification.')
    custom_level_spec_group.AddArgument(custom_level_spec_arg)

    level_spec_group = base.ArgumentGroup(help='Level specification.',
                                          mutex=True)

    level_spec_group.AddArgument(basic_level_spec_group)
    level_spec_group.AddArgument(custom_level_spec_group)

    level_spec_group.AddToParser(parser)
    def _MaybeAddArgToGroup(self, attributes, arg, groups):
        """Conditionally adds the argument to a group if it should be in one.

    Args:
      attributes: yaml_command_schema.Argument, The attributes to use to
        generate the arg.
      arg: calliope.base.Argument: The generated arg.
      groups: {id: calliope.base.ArgumentGroup}, The collection of groups that
        have been generated.

    Returns:
      The argument if not in a group, an ArgumentGroup if a new group was
      created for this argument, or None if it was added to a group that already
      exists.
    """
        if not attributes.group:
            # This is just a normal argument, return it so it can be added to the
            # parser.
            return arg

        group = groups.get(attributes.group.group_id, None)
        if group:
            # The group this belongs to has already been created and stored. Just add
            # this arg to the group, no need to add the group again, so return None.
            group.AddArgument(arg)
            return None

        # Arg is in a group but it hasn't been created yet. Make the group, store it
        # and return it for addition to the parser.
        group = base.ArgumentGroup(attributes.group.group_id,
                                   required=attributes.group.required)
        groups[attributes.group.group_id] = group
        group.AddArgument(arg)
        return group
示例#6
0
def GetZoneArg(help_text=(
    'Name of the managed-zone whose record-sets you want to manage.'),
               hide_short_zone_flag=False):
  if hide_short_zone_flag:
    zone_group = base.ArgumentGroup(required=True)
    zone_group.AddArgument(
        base.Argument(
            '--zone',
            completer=ManagedZoneCompleter,
            help=help_text))
    zone_group.AddArgument(
        base.Argument(
            '-z',
            dest='zone',
            completer=ManagedZoneCompleter,
            help=help_text,
            hidden=True))
    return zone_group
  else:
    return base.Argument(
        '--zone',
        '-z',
        completer=ManagedZoneCompleter,
        help=help_text,
        required=True)
示例#7
0
def AddUserCodeArgs(parser):
    """Add args that configure user prediction code."""
    user_code_group = base.ArgumentGroup(help="""\
          Configure user code in prediction.

          AI Platform allows a model to have user-provided prediction
          code; these options configure that code.
          """)
    user_code_group.AddArgument(
        base.Argument('--prediction-class',
                      help="""\
          Fully-qualified name of the custom prediction class in the package
          provided for custom prediction.

          For example, `--prediction-class=my_package.SequenceModel`.
          """))
    user_code_group.AddArgument(
        base.Argument('--package-uris',
                      type=arg_parsers.ArgList(),
                      metavar='PACKAGE_URI',
                      help="""\
          Comma-separated list of Cloud Storage URIs ('gs://...') for
          user-supplied Python packages to use.
          """))
    user_code_group.AddToParser(parser)
示例#8
0
def AddInlineReusableConfigFlags(parser, is_ca):
    """Adds flags for providing inline reusable config values.

  Args:
    parser: The parser to add the flags to.
    is_ca: Whether the current operation is on a CA. This influences the help
           text, and whether the --max-chain-length flag is added.
  """
    resource_name = 'CA' if is_ca else 'certificate'
    group = base.ArgumentGroup()
    group.AddArgument(
        base.Argument(
            '--key-usages',
            help='The list of key usages for this {}.'.format(resource_name),
            type=arg_parsers.ArgList(element_type=_StripVal,
                                     choices=_VALID_KEY_USAGES)))
    group.AddArgument(
        base.Argument(
            '--extended-key-usages',
            help='The list of extended key usages for this {}'.format(
                resource_name),
            type=arg_parsers.ArgList(element_type=_StripVal,
                                     choices=_VALID_EXTENDED_KEY_USAGES)))
    if is_ca:
        group.AddArgument(
            base.Argument(
                '--max-chain-length',
                help='Maximum depth of subordinate CAs allowed under this CA.')
        )
    group.AddToParser(parser)
  def _GenerateArguments(self, prefix, message):
    """Gets the arguments to add to the parser that appear in the method body.

    Args:
      prefix: str, A string to prepend to the name of the flag. This is used
        for flags representing fields of a submessage.
      message: The apitools message to generate the flags for.

    Returns:
      {str, calliope.base.Argument}, A map of field name to argument.
    """
    args = []
    field_helps = arg_utils.FieldHelpDocs(message)
    for field in message.all_fields():
      field_help = field_helps.get(field.name, None)
      name = self._GetArgName(field.name, field_help)
      if not name:
        continue
      name = prefix + name
      if field.variant == messages.Variant.MESSAGE:
        sub_args = self._GenerateArguments(name + '.', field.type)
        if sub_args:
          help_text = (name + ': ' + field_help) if field_help else ''
          group = base.ArgumentGroup(help=help_text)
          args.append(group)
          for arg in sub_args:
            group.AddArgument(arg)
      else:
        attributes = yaml_command_schema.Argument(name, name, field_help)
        arg = arg_utils.GenerateFlag(field, attributes, fix_bools=False,
                                     category='MESSAGE')
        if not arg.kwargs.get('help'):
          arg.kwargs['help'] = 'API doc needs help for field [{}].'.format(name)
        args.append(arg)
    return args
示例#10
0
  def _MessageFieldFlags(self, prefix, message):
    """Get the arguments to add to the parser that appear in the method body.

    Args:
      prefix: str, A string to prepend to the name of the flag. This is used
        for flags representing fields of a submessage.
      message: The apitools message to generate the flags for.

    Returns:
      {str, calliope.base.Argument}, A map of field name to argument.
    """
    args = {}
    field_helps = self._FieldHelpDocs(message)
    for field in message.all_fields():
      name = ArgumentGenerator.FlagNameForField(self.method, prefix, field)
      if field.variant == messages.Variant.MESSAGE:
        field_help = field_helps.get(field.name, None)
        group = base.ArgumentGroup(
            name, description=(name + ': ' + field_help) if field_help else '')
        for arg in self._MessageFieldFlags(name + '.', field.type).values():
          group.AddArgument(arg)
        args[name] = group
      else:
        args[name] = self._FlagForMessageField(name, field, field_helps)
    return {k: v for k, v in args.iteritems() if v is not None}
def AddCreateFlags(
    parser,
    support_location_hint=False,
    support_share_setting=False,
    support_fleet=False,
):
    """Adds all flags needed for the create command."""
    GetNamePrefixFlag().AddToParser(parser)
    GetTotalCountFlag().AddToParser(parser)
    reservation_flags.GetDescriptionFlag().AddToParser(parser)

    group = base.ArgumentGroup(
        'Manage the specific SKU reservation properties.', required=True)
    group.AddArgument(reservation_flags.GetMachineType())
    group.AddArgument(reservation_flags.GetMinCpuPlatform())
    group.AddArgument(reservation_flags.GetLocalSsdFlag())
    group.AddArgument(reservation_flags.GetAcceleratorFlag())
    if support_location_hint:
        group.AddArgument(reservation_flags.GetLocationHint())
    if support_fleet:
        group.AddArgument(instance_flags.AddMaintenanceFreezeDuration())
        group.AddArgument(instance_flags.AddMaintenanceInterval())
    group.AddToParser(parser)

    time_window_group = parser.add_group(
        help=
        'Manage the time specific properties for requesting future capacity',
        required=True)
    time_window_group.add_argument('--start-time',
                                   required=True,
                                   help=GetStartTimeHelpText())
    end_time_window_group = time_window_group.add_mutually_exclusive_group(
        required=True)
    end_time_window_group.add_argument('--end-time', help=GetEndTimeHelpText())
    end_time_window_group.add_argument('--duration',
                                       type=int,
                                       help=GetDurationHelpText())

    if support_share_setting:
        share_group = base.ArgumentGroup(
            'Manage the properties of a shared reservation.', required=False)
        share_group.AddArgument(GetSharedSettingFlag())
        share_group.AddArgument(GetShareWithFlag())
        share_group.AddToParser(parser)
示例#12
0
def AddCreateCustomJobFlags(parser):
    """Adds flags related to create a custom job."""
    AddRegionResourceArg(parser, 'to create a custom job')
    CUSTOM_JOB_DISPLAY_NAME.AddToParser(parser)
    PYTHON_PACKGE_URIS.AddToParser(parser)
    worker_pool_spec_group = base.ArgumentGroup(
        help='Worker pool specification.', required=True)
    worker_pool_spec_group.AddArgument(CUSTOM_JOB_CONFIG)
    worker_pool_spec_group.AddArgument(WORKER_POOL_SPEC)
    worker_pool_spec_group.AddToParser(parser)
示例#13
0
def _AddPatchRolloutArguments(parser):
  """Adds top-level patch rollout arguments."""
  rollout_group = base.ArgumentGroup(
      mutex=False, help='Rollout configurations for this patch job:')
  rollout_group.AddArgument(
      base.ChoiceArgument(
          '--rollout-mode',
          help_str='Mode of the rollout.',
          choices={
              'zone-by-zone':
                  """\
              Patches are applied one zone at a time. The patch job begins in
              the region with the lowest number of targeted VMs. Within the
              region, patching begins in the zone with the lowest number of
              targeted VMs. If multiple regions (or zones within a region) have
              the same number of targeted VMs, a tie-breaker is achieved by
              sorting the regions or zones in alphabetical order.""",
              'concurrent-zones':
                  'Patches are applied to VMs in all zones at the same time.',
          },
      ))
  disruption_budget_group = base.ArgumentGroup(
      mutex=True,
      help="""\
      Disruption budget for this rollout. A running VM with an active agent is
      considered disrupted if its patching operation fails anytime between the
      time the agent is notified until the patch process completes.""")
  disruption_budget_group.AddArgument(
      base.Argument(
          '--rollout-disruption-budget',
          help='Number of VMs per zone to disrupt at any given moment.',
      ))
  disruption_budget_group.AddArgument(
      base.Argument(
          '--rollout-disruption-budget-percent',
          help="""\
          Percentage of VMs per zone to disrupt at any given moment. The number
          of VMs calculated from multiplying the percentage by the total number
          of VMs in a zone is rounded up.""",
      ))
  rollout_group.AddArgument(disruption_budget_group)
  rollout_group.AddToParser(parser)
示例#14
0
def AddFieldUpdateArgs():
  """Python hook to add the argument group for field updates.

  Returns:
    List consisting of the field update arg group.
  """
  group = base.ArgumentGroup(mutex=True, required=True)
  group.AddArgument(GetIndexArg())
  group.AddArgument(GetDisableIndexesArg())
  group.AddArgument(GetClearExemptionArg())
  return [group]
示例#15
0
    def _GenerateMessageFieldsFlags(self,
                                    prefix,
                                    message,
                                    groups=None,
                                    is_root=True):
        """Gets the arguments to add to the parser that appear in the method body.

    Args:
      prefix: str, A string to prepend to the name of the flag. This is used
        for flags representing fields of a submessage.
      message: The apitools message to generate the flags for.
      groups: {id: calliope.base.ArgumentGroup}, The collection of groups that
        have been generated. Newly generated arguments will be put in one of
        these groups if their attributes say they should be. This collection
        is modified and should not be passed in at the root invocation.
      is_root: bool, True if this is the request message itself (not a
        sub-field).

    Returns:
      {str, calliope.base.Argument}, A map of field name to argument.
    """
        args = {}
        if groups is None:
            groups = {}
        field_helps = _FieldHelpDocs(message)
        for field in message.all_fields():
            attributes = self._FlagAttributesForField(prefix, field, is_root)
            if not attributes:
                continue
            name = attributes.arg_name
            if (field.variant == messages.Variant.MESSAGE
                    and (self.arg_info is None
                         or prefix + field.name not in self.arg_info)):
                sub_args = self._GenerateMessageFieldsFlags(name + '.',
                                                            field.type,
                                                            groups,
                                                            is_root=False)
                if self.arg_info is not None:
                    args.update(sub_args)
                elif sub_args:
                    field_help = field_helps.get(field.name, None)
                    group = base.ArgumentGroup(
                        name,
                        description=(name + ': ' +
                                     field_help) if field_help else '')
                    for arg in sub_args.values():
                        group.AddArgument(arg)
                    args[name] = group
            else:
                args[name] = self._MaybeAddArgToGroup(
                    attributes,
                    self._GenerateMessageFieldFlag(attributes, prefix, field),
                    groups)
        return {k: v for k, v in args.iteritems() if v is not None}
示例#16
0
def AddRegistrationSettingsFlagsToParser(parser):
  """Get flags for registration commands.

  Args:
    parser: argparse parser to which to add these flags.

  """
  dns_group = base.ArgumentGroup(
      mutex=True,
      help=('Set the addresses of authoritative name servers for the given '
            'domain.'))
  dns_group.AddArgument(
      base.Argument(
          '--name-servers',
          help='List of DNS name servers for the domain.',
          metavar='NAME_SERVER',
          type=arg_parsers.ArgList(str, min_length=2)))

  dns_group.AddArgument(
      base.Argument(
          '--cloud-dns-zone',
          help=('The name of the Cloud DNS managed-zone to set as the name '
                'server for the domain.\n'
                'If it\'s in the same project, you can use short name. If not, '
                'use the full resource name, e.g.: --cloud-dns-zone='
                'projects/example-project/managedZones/example-zone')))
  dns_group.AddToParser(parser)

  base.Argument(
      '--registrant-contact-from-file',
      help="""\
      A YAML file containing the required WHOIS data. If specified, this file
      must contain values for all required fields: email, phoneNumber and
      postalAddress in google.type.PostalAddress format.

      For more guidance on how to specify postalAddress, please see:
      https://support.google.com/business/answer/6397478

      Example file contents:

      ```
      email: '*****@*****.**'
      phoneNumber: '+11234567890'
      postalAddress:
        regionCode: 'US'
        postalCode: '94043'
        administrativeArea: 'CA'
        locality: 'Mountain View'
        addressLines: ['1600 Amphitheatre Pkwy']
        recipients: ['Jane Doe']
      ```
      """).AddToParser(parser)

  WHOIS_PRIVACY_ENUM_MAPPER.choice_arg.AddToParser(parser)
示例#17
0
def AuthFlags():
    """Hook to add additional authentication flags.

  Returns:
    Auth flag group
  """
    auth_group = base.ArgumentGroup(mutex=False)
    auth_group.AddArgument(_TypeFlag())
    auth_group.AddArgument(_UserFlag())
    auth_group.AddArgument(_PasswordFlag())
    auth_group.AddArgument(_UrlFlag())
    return [auth_group]
示例#18
0
def AddAttachedCertificatesFlagsToParser(parser):
  """Adds flags describing certificate update without resource args."""
  is_clear_certificates = base.Argument(
      '--clear-certificates',
      help='Removes all certificates from the entry',
      action='store_true')

  group = base.ArgumentGroup(
      help='Arguments to update list of certificates attached to map entry.',
      required=False,
      mutex=True,
      category=base.COMMONLY_USED_FLAGS)
  group.AddArgument(is_clear_certificates)
  return group.AddToParser(parser)
示例#19
0
def AddInlineX509ParametersFlags(parser,
                                 is_ca_command,
                                 default_max_chain_length=None):
    """Adds flags for providing inline x509 parameters.

  Args:
    parser: The parser to add the flags to.
    is_ca_command: Whether the current command is on a CA. This influences the
      help text, and whether the --is-ca-cert flag is added.
    default_max_chain_length: optional, The default value for maxPathLength to
      use if an explicit value is not specified. If this is omitted or set to
      None, no default max path length will be added.
  """
    resource_name = 'CA' if is_ca_command else 'certificate'
    group = base.ArgumentGroup()
    group.AddArgument(
        base.Argument(
            '--key-usages',
            metavar='KEY_USAGES',
            help=
            'The list of key usages for this {}. This can only be provided if `--use-preset-profile` is not provided.'
            .format(resource_name),
            type=arg_parsers.ArgList(element_type=_StripVal,
                                     choices=_VALID_KEY_USAGES)))
    group.AddArgument(
        base.Argument(
            '--extended-key-usages',
            metavar='EXTENDED_KEY_USAGES',
            help=
            'The list of extended key usages for this {}. This can only be provided if `--use-preset-profile` is not provided.'
            .format(resource_name),
            type=arg_parsers.ArgList(element_type=_StripVal,
                                     choices=_VALID_EXTENDED_KEY_USAGES)))
    group.AddArgument(
        base.Argument(
            '--max-chain-length',
            help=
            'Maximum depth of subordinate CAs allowed under this CA for a CA certificate. This can only be provided if `--use-preset-profile` is not provided.',
            default=default_max_chain_length))

    if not is_ca_command:
        group.AddArgument(
            base.Argument(
                '--is-ca-cert',
                help=
                'Whether this certificate is for a CertificateAuthority or not. Indicates the Certificate Authority field in the x509 basic constraints extension.',
                required=False,
                default=False,
                action='store_true'))
    group.AddToParser(parser)
示例#20
0
def AddCrawlerScopeAndSchedulingFlags(for_update=False):
    """Python hook to add the arguments for scope and scheduling options.

  Args:
    for_update: If flags are for update instead of create.

  Returns:
    List consisting of the scope and scheduling arg groups.
  """
    scope_group = base.ArgumentGroup(
        help='Arguments to configure the crawler scope:',
        required=not for_update)
    scope_group.AddArgument(GetCrawlScopeArg(for_update))
    scope_group.AddArgument(GetBucketArgForCreate(
    ) if not for_update else GetBucketArgsForUpdate())

    scheduling_group = base.ArgumentGroup(
        help='Arguments to configure the crawler run scheduling:',
        required=not for_update)
    scheduling_group.AddArgument(GetRunOptionArg(for_update))
    scheduling_group.AddArgument(GetRunScheduleArg(for_update))

    return [scope_group, scheduling_group]
示例#21
0
def AddUpdateFlags(parser):
    """Adds all flags needed for the update command."""
    GetVmCountFlag().AddToParser(parser)
    GetDestinationFlag().AddToParser(parser)

    group = base.ArgumentGroup(
        'Manage the specific SKU allocation properties to update')

    group.AddArgument(GetMinCpuPlatform())
    group.AddArgument(GetMachineType())
    group.AddArgument(GetLocalSsdFlag())
    group.AddArgument(GetAcceleratorFlag())

    group.AddToParser(parser)
示例#22
0
  def Generate(self, message):
    """Generates and returns the base argument group.

    Args:
      message: The API message, None for non-resource args.

    Returns:
      The base argument group.
    """
    group = base.ArgumentGroup(
        mutex=self.mutex, required=self.required, help=self.help_text)
    for arg in self.arguments:
      group.AddArgument(arg.Generate(message))
    return group
示例#23
0
def GetResourceRecordSetsRrdatasArgGroup(use_deprecated_names=False):
    """Returns arg group for rrdatas flags.

  Args:
    use_deprecated_names: If true, uses snake_case names for flags
        --routing-policy-type and --routing-policy-data, --routing_policy_type
        and --routing_policy_data.

  This group is defined with required=True and mutex=True, meaning that exactly
  one of these two arg configurations must be specified:
    --rrdatas
    --routing-policy-type AND --routing-policy-data
  """
    # Declare optional routing policy group. If group specified, must contain
    # both routing-policy-type and routing-policy-data args.
    policy_group = base.ArgumentGroup(
        required=False,
        help=
        'Routing policy arguments. If you specify one of --routing-policy-data or --routing-policy-type, you must specify both.'
    )
    policy_group.AddArgument(
        GetResourceRecordSetsRoutingPolicyTypeArg(
            required=True, deprecated_name=use_deprecated_names))
    policy_group.AddArgument(
        GetResourceRecordSetsRoutingPolicyDataArg(
            required=True, deprecated_name=use_deprecated_names))

    rrdatas_group = base.ArgumentGroup(
        required=True,
        mutex=True,
        help=
        'Resource record sets arguments. Can specify either --rrdatas or both --routing-policy-data and --routing-policy-type.'
    )
    rrdatas_group.AddArgument(GetResourceRecordSetsRrdatasArg(required=False))
    rrdatas_group.AddArgument(policy_group)

    return rrdatas_group
示例#24
0
def _GetEventNotificationConfigFlags(include_deprecated=True):
    """Returns a list of flags for specfiying Event Notification Configs."""
    event_config_group = base.ArgumentGroup(mutex=True)
    if include_deprecated:
        # TODO(b/64597199): Remove this flag when usage is low.
        event_config_group.AddArgument(
            base.Argument(
                '--pubsub-topic',
                required=False,
                action=actions.DeprecationAction(
                    '--pubsub-topic',
                    removed=True,
                    error='Flag {flag_name} is removed. Use '
                    '--event-notification-config instead.'),
                hidden=True,
                help='A Google Cloud Pub/Sub topic name for event notifications'
            ))
        event_config_group.AddArgument(
            base.Argument(
                '--event-pubsub-topic',
                required=False,
                action=actions.DeprecationAction(
                    '--event-pubsub-topic',
                    warn='Flag {flag_name} is deprecated. Use '
                    '--event-notification-config instead.'),
                help='A Google Cloud Pub/Sub topic name for event notifications'
            ))

    event_notification_spec = {'topic': str, 'subfolder': str}
    event_config_group.AddArgument(
        base.Argument('--event-notification-config',
                      dest='event_notification_configs',
                      action='append',
                      required=False,
                      type=arg_parsers.ArgDict(spec=event_notification_spec,
                                               required_keys=['topic']),
                      help="""\
The configuration for notification of telemetry events received
from the device. This flag can be specified multiple times to add multiple
configs to the device registry. Configs are added to the registry in the order
the flags are specified. Only one config with an empty subfolder field is
allowed and must be specified last.

*topic*::::A Google Cloud Pub/Sub topic name for event notifications

*subfolder*::::If the subfolder name matches this string exactly, this
configuration will be used to publish telemetry events. If empty all strings
are matched."""))
    return [event_config_group]
示例#25
0
def AddCreateFlags(parser):
  """Adds all flags needed for the create command."""
  GetDescriptionFlag().AddToParser(parser)

  group = base.ArgumentGroup(
      'Manage the specific SKU reservation properties to create', required=True)

  group.AddArgument(GetRequireSpecificAllocation())
  group.AddArgument(GetVmCountFlag())
  group.AddArgument(GetMinCpuPlatform())
  group.AddArgument(GetMachineType())
  group.AddArgument(GetLocalSsdFlag())
  group.AddArgument(GetAcceleratorFlag())

  group.AddToParser(parser)
示例#26
0
def _AddAcceleratorFlags(parser):
  """Add arguments for accelerator config."""
  accelerator_config_group = base.ArgumentGroup(
      help='Accelerator Configuration.')

  accelerator_config_group.AddArgument(base.Argument(
      '--accelerator-count',
      required=True,
      default=1,
      type=arg_parsers.BoundedInt(lower_bound=1),
      help=('The number of accelerators to attach to the machines.'
            ' Must be >= 1.')))
  accelerator_config_group.AddArgument(
      jobs_util.AcceleratorFlagMap().choice_arg)
  accelerator_config_group.AddToParser(parser)
示例#27
0
def AddInlineReusableConfigFlags(parser, is_ca):
    """Adds flags for providing inline reusable config values.

  Args:
    parser: The parser to add the flags to.
    is_ca: Whether the current operation is on a CA. This influences the help
      text, and whether the --max-chain-length flag is added.
  """
    resource_name = 'CA' if is_ca else 'certificate'
    group = base.ArgumentGroup()
    group.AddArgument(
        base.Argument(
            '--key-usages',
            metavar='KEY_USAGES',
            help=
            'The list of key usages for this {}. This can only be provided if `--reusable-config` is not provided.'
            .format(resource_name),
            type=arg_parsers.ArgList(element_type=_StripVal,
                                     choices=_VALID_KEY_USAGES)))
    group.AddArgument(
        base.Argument(
            '--extended-key-usages',
            metavar='EXTENDED_KEY_USAGES',
            help=
            'The list of extended key usages for this {}. This can only be provided if `--reusable-config` is not provided.'
            .format(resource_name),
            type=arg_parsers.ArgList(element_type=_StripVal,
                                     choices=_VALID_EXTENDED_KEY_USAGES)))
    group.AddArgument(
        base.Argument(
            '--max-chain-length',
            help=
            'Maximum depth of subordinate CAs allowed under this CA for a CA certificate. This can only be provided if `--reusable-config` is not provided.',
            default=0))

    if not is_ca:
        group.AddArgument(
            base.Argument(
                '--is-ca-cert',
                help=
                'Whether this certificate is for a CertificateAuthority or not. Indicates the Certificate Authority field in the x509 basic constraints extension.',
                required=False,
                default=False,
                action='store_true'))

    group.AddToParser(parser)
def GetStreamingUpdateArgs(required=False):
    """Defines the Streaming Update Args for the Pipeline."""
    streaming_update_args = base.ArgumentGroup(required=required)
    streaming_update_args.AddArgument(
        base.Argument('--update',
                      required=required,
                      action=arg_parsers.StoreTrueFalseAction,
                      help="""Set this to true for streaming update jobs."""))
    streaming_update_args.AddArgument(
        base.Argument(
            '--transform-name-mappings',
            required=required,
            default=None,
            metavar='TRANSFORM_NAME_MAPPINGS',
            type=arg_parsers.ArgDict(),
            action=arg_parsers.UpdateAction,
            help="""Transform name mappings for the streaming update job."""))
    return streaming_update_args
示例#29
0
def GetDnsPeeringArgs():
    """Return arg group for DNS Peering flags."""
    peering_group = base.ArgumentGroup(required=False)
    target_network_help_text = (
        'Network ID of the Google Compute Engine private network to forward'
        ' queries to.')
    target_project_help_text = (
        'Project ID of the Google Compute Engine private network to forward'
        ' queries to.')
    peering_group.AddArgument(
        base.Argument('--target-network',
                      required=True,
                      help=target_network_help_text))
    peering_group.AddArgument(
        base.Argument('--target-project',
                      required=True,
                      help=target_project_help_text))
    return peering_group
示例#30
0
def AddMapEntryMatcherFlagsToParser(parser):
  """Adds flags defining certificate map entry matcher."""
  is_primary_flag = base.Argument(
      '--set-primary',
      help='The certificate will be used as the default cert if no other certificate in the map matches on SNI.',
      action='store_true')
  hostname_flag = base.Argument(
      '--hostname',
      help='A domain name (FQDN), which controls when list of certificates specified in the resource will be taken under consideration for certificate selection.'
  )
  group = base.ArgumentGroup(
      help='Arguments to configure matcher for the certificate map entry.',
      required=True,
      mutex=True,
      category=base.COMMONLY_USED_FLAGS)
  group.AddArgument(is_primary_flag)
  group.AddArgument(hostname_flag)
  group.AddToParser(parser)