def AddBaseArgs(parser, is_alpha=False):
  """Declare flag and positional arguments for this command parser."""
  # TODO(b/35705305): move common flags to command_lib.sql.flags
  base.ASYNC_FLAG.AddToParser(parser)
  parser.display_info.AddFormat(flags.GetInstanceListFormat())
  flags.AddActivationPolicy(parser)
  flags.AddActiveDirectoryDomain(parser)
  flags.AddAssignIp(parser)
  flags.AddAuthorizedNetworks(parser)
  flags.AddAvailabilityType(parser)
  parser.add_argument(
      '--backup',
      required=False,
      action='store_true',
      default=True,
      help='Enables daily backup.')
  flags.AddBackupStartTime(parser)
  flags.AddBackupLocation(parser, allow_empty=False)
  flags.AddCPU(parser)
  flags.AddInstanceCollation(parser)
  flags.AddDatabaseFlags(parser)
  flags.AddEnableBinLog(parser, show_negated_in_help=False)
  flags.AddRetainedBackupsCount(parser)
  flags.AddRetainedTransactionLogDays(parser)

  parser.add_argument(
      '--failover-replica-name',
      required=False,
      help='Also create a failover replica with the specified name.')
  parser.add_argument(
      'instance',
      type=command_validate.InstanceNameRegexpValidator(),
      help='Cloud SQL instance ID.')
  flags.AddMaintenanceReleaseChannel(parser)
  flags.AddMaintenanceWindowDay(parser)
  flags.AddMaintenanceWindowHour(parser)
  flags.AddDenyMaintenancePeriodStartDate(parser)
  flags.AddDenyMaintenancePeriodEndDate(parser)
  flags.AddDenyMaintenancePeriodTime(parser)
  flags.AddInsightsConfigQueryInsightsEnabled(parser, show_negated_in_help=True)
  flags.AddInsightsConfigQueryStringLength(parser)
  flags.AddInsightsConfigRecordApplicationTags(
      parser, show_negated_in_help=True)
  flags.AddInsightsConfigRecordClientAddress(parser, show_negated_in_help=True)
  flags.AddInsightsConfigQueryPlansPerMinute(parser)
  parser.add_argument(
      '--master-instance-name',
      required=False,
      help=('Name of the instance which will act as master in the '
            'replication setup. The newly created instance will be a read '
            'replica of the specified master instance.'))
  flags.AddMemory(parser)
  flags.AddPasswordPolicyMinLength(parser)
  flags.AddPasswordPolicyComplexity(parser)
  flags.AddPasswordPolicyReuseInterval(parser)
  flags.AddPasswordPolicyDisallowUsernameSubstring(parser)
  flags.AddPasswordPolicyPasswordChangeInterval(parser)
  flags.AddPasswordPolicyEnablePasswordPolicy(parser)
  parser.add_argument(
      '--replica-type',
      choices=['READ', 'FAILOVER'],
      help='The type of replica to create.')
  flags.AddReplication(parser)
  parser.add_argument(
      '--require-ssl',
      required=False,
      action='store_true',
      default=None,
      help='Specified if users connecting over IP must use SSL.')
  flags.AddRootPassword(parser)
  flags.AddStorageAutoIncrease(parser)
  flags.AddStorageSize(parser)
  parser.add_argument(
      '--storage-type',
      required=False,
      choices=['SSD', 'HDD'],
      default=None,
      help='The storage type for the instance. The default is SSD.')
  flags.AddTier(parser, is_alpha=is_alpha)
  kms_flag_overrides = {
      'kms-key': '--disk-encryption-key',
      'kms-keyring': '--disk-encryption-key-keyring',
      'kms-location': '--disk-encryption-key-location',
      'kms-project': '--disk-encryption-key-project'
  }
  kms_resource_args.AddKmsKeyResourceArg(
      parser,
      'instance',
      flag_overrides=kms_flag_overrides)
  flags.AddEnablePointInTimeRecovery(parser)
  flags.AddNetwork(parser)
Example #2
0
def AddBaseArgs(parser):
    """Declare flag and positional arguments for this command parser."""
    # TODO(b/35705305): move common flags to command_lib.sql.flags
    base.ASYNC_FLAG.AddToParser(parser)
    parser.display_info.AddFormat(flags.GetInstanceListFormat())
    flags.AddActivationPolicy(parser)
    flags.AddAssignIp(parser)
    flags.AddAuthorizedGAEApps(parser)
    flags.AddAuthorizedNetworks(parser)
    flags.AddAvailabilityType(parser)
    parser.add_argument('--backup',
                        required=False,
                        action='store_true',
                        default=True,
                        help='Enables daily backup.')
    flags.AddBackupStartTime(parser)
    flags.AddCPU(parser)
    flags.AddDatabaseFlags(parser)
    flags.AddEnableBinLog(parser, show_negated_in_help=False)
    parser.add_argument(
        '--failover-replica-name',
        required=False,
        help='Also create a failover replica with the specified name.')
    parser.add_argument(
        '--follow-gae-app',
        required=False,
        help=('First Generation instances only. The App Engine app this '
              'instance should follow. It must be in the same region as '
              'the instance.'))
    parser.add_argument('instance',
                        type=command_validate.InstanceNameRegexpValidator(),
                        help='Cloud SQL instance ID.')
    flags.AddMaintenanceReleaseChannel(parser)
    flags.AddMaintenanceWindowDay(parser)
    flags.AddMaintenanceWindowHour(parser)
    parser.add_argument(
        '--main-instance-name',
        required=False,
        help=('Name of the instance which will act as main in the '
              'replication setup. The newly created instance will be a read '
              'replica of the specified main instance.'))
    flags.AddMemory(parser)
    parser.add_argument(
        '--pricing-plan',
        '-p',
        required=False,
        choices=['PER_USE', 'PACKAGE'],
        default='PER_USE',
        help=('First Generation instances only. The pricing plan for this '
              'instance.'))
    # TODO(b/31989340): add remote completion
    # TODO(b/73362371): Make specifying a location required.
    location_group = parser.add_mutually_exclusive_group()
    location_group.add_argument(
        '--region',
        required=False,
        default='us-central',
        help=('Regional location (e.g. asia-east1, us-east1). See the full '
              'list of regions at '
              'https://cloud.google.com/sql/docs/instance-locations.'))
    flags.AddZone(
        location_group,
        help_text=('Preferred Compute Engine zone (e.g. us-central1-a, '
                   'us-central1-b, etc.).'))
    parser.add_argument('--replica-type',
                        choices=['READ', 'FAILOVER'],
                        help='The type of replica to create.')
    flags.AddReplication(parser)
    parser.add_argument(
        '--require-ssl',
        required=False,
        action='store_true',
        default=None,
        help='Specified if users connecting over IP must use SSL.')
    flags.AddRootPassword(parser)
    flags.AddStorageAutoIncrease(parser)
    flags.AddStorageSize(parser)
    parser.add_argument(
        '--storage-type',
        required=False,
        choices=['SSD', 'HDD'],
        default=None,
        help='The storage type for the instance. The default is SSD.')
    flags.AddTier(parser)
Example #3
0
def AddBaseArgs(parser):
    """Declare flag and positional arguments for this command parser."""
    # TODO(b/35705305): move common flags to command_lib.sql.flags
    base.ASYNC_FLAG.AddToParser(parser)
    parser.display_info.AddFormat(flags.GetInstanceListFormat())
    flags.AddActivationPolicy(parser)
    flags.AddAssignIp(parser)
    flags.AddAuthorizedNetworks(parser)
    flags.AddAvailabilityType(parser)
    parser.add_argument('--backup',
                        required=False,
                        action='store_true',
                        default=True,
                        help='Enables daily backup.')
    flags.AddBackupStartTime(parser)
    flags.AddBackupLocation(parser, allow_empty=False)
    flags.AddCPU(parser)
    flags.AddInstanceCollation(parser)
    flags.AddDatabaseFlags(parser)
    flags.AddEnableBinLog(parser, show_negated_in_help=False)
    parser.add_argument(
        '--failover-replica-name',
        required=False,
        help='Also create a failover replica with the specified name.')
    parser.add_argument('instance',
                        type=command_validate.InstanceNameRegexpValidator(),
                        help='Cloud SQL instance ID.')
    flags.AddMaintenanceReleaseChannel(parser)
    flags.AddMaintenanceWindowDay(parser)
    flags.AddMaintenanceWindowHour(parser)
    flags.AddDenyMaintenancePeriodStartDate(parser)
    flags.AddDenyMaintenancePeriodEndDate(parser)
    flags.AddDenyMaintenancePeriodTime(parser)
    parser.add_argument(
        '--master-instance-name',
        required=False,
        help=('Name of the instance which will act as master in the '
              'replication setup. The newly created instance will be a read '
              'replica of the specified master instance.'))
    flags.AddMemory(parser)
    # TODO(b/31989340): add remote completion
    # TODO(b/73362371): Make specifying a location required.
    location_group = parser.add_mutually_exclusive_group()
    location_group.add_argument(
        '--region',
        required=False,
        default='us-central',
        help=('Regional location (e.g. asia-east1, us-east1). See the full '
              'list of regions at '
              'https://cloud.google.com/sql/docs/instance-locations.'))
    flags.AddZone(
        location_group,
        help_text=('Preferred Compute Engine zone (e.g. us-central1-a, '
                   'us-central1-b, etc.).'))
    parser.add_argument('--replica-type',
                        choices=['READ', 'FAILOVER'],
                        help='The type of replica to create.')
    flags.AddReplication(parser)
    parser.add_argument(
        '--require-ssl',
        required=False,
        action='store_true',
        default=None,
        help='Specified if users connecting over IP must use SSL.')
    flags.AddRootPassword(parser)
    flags.AddStorageAutoIncrease(parser)
    flags.AddStorageSize(parser)
    parser.add_argument(
        '--storage-type',
        required=False,
        choices=['SSD', 'HDD'],
        default=None,
        help='The storage type for the instance. The default is SSD.')
    flags.AddTier(parser)
    kms_flag_overrides = {
        'kms-key': '--disk-encryption-key',
        'kms-keyring': '--disk-encryption-key-keyring',
        'kms-location': '--disk-encryption-key-location',
        'kms-project': '--disk-encryption-key-project'
    }
    kms_resource_args.AddKmsKeyResourceArg(parser,
                                           'instance',
                                           flag_overrides=kms_flag_overrides)
    flags.AddEnablePointInTimeRecovery(parser)