Пример #1
0
def AddBaseImportFlags(parser,
                       filetype,
                       gz_supported=True,
                       user_supported=True):
    """Adds the base flags for importing data.

  Args:
    parser: An argparse parser that you can use to add arguments that go on the
      command line after this command. Positional arguments are allowed.
    filetype: String, description of the file type being imported.
    gz_supported: Boolean, if True then .gz compressed files are supported.
    user_supported: Boolean, if True then a Postgres user can be specified.
  """
    base.ASYNC_FLAG.AddToParser(parser)
    flags.AddInstanceArgument(parser)
    uri_help_text = (
        'Path to the {filetype} file in Google Cloud Storage from '
        'which the import is made. The URI is in the form '
        '`gs://bucketName/fileName`.')
    if gz_supported:
        uri_help_text = uri_help_text + (
            ' Compressed gzip files (.gz) are also '
            'supported.')
    flags.AddUriArgument(parser, uri_help_text.format(filetype=filetype))

    if user_supported:
        flags.AddUser(parser, 'PostgreSQL user for this import operation.')
Пример #2
0
def AddBaseExportFlags(
    parser,
    gz_supported=True,
    database_required=False,
    database_help_text=flags.DEFAULT_DATABASE_LIST_EXPORT_HELP_TEXT):
  """Adds the base export flags to the parser.

  Args:
    parser: The current argparse parser to add these flags to.
    gz_supported: Boolean, specifies whether gz compression is supported.
    database_required: Boolean, specifies whether the database flag is required.
    database_help_text: String, specifies the help text for the database flag.
  """
  base.ASYNC_FLAG.AddToParser(parser)
  flags.AddInstanceArgument(parser)

  uri_help_text = ('The path to the file in Google Cloud Storage where the '
                   'export will be stored. The URI is in the form '
                   'gs://bucketName/fileName. If the file already exists, the '
                   'operation fails.')
  if gz_supported:
    uri_help_text = uri_help_text + (' If the filename ends with .gz, the '
                                     'contents are compressed.')
  flags.AddUriArgument(parser, uri_help_text)
  flags.AddDatabaseList(parser, database_help_text, database_required)
Пример #3
0
def AddBaseImportFlags(parser):
    base.ASYNC_FLAG.AddToParser(parser)
    flags.AddInstanceArgument(parser)
    flags.AddUriArgument(
        parser,
        'Path to the MySQL dump file in Google Cloud Storage from which'
        ' the import is made. The URI is in the form gs://bucketName/fileName.'
        ' Compressed gzip files (.gz) are also supported.')
Пример #4
0
def AddBaseExportFlags(parser):
    base.ASYNC_FLAG.AddToParser(parser)
    flags.AddInstanceArgument(parser)
    flags.AddUriArgument(
        parser,
        'The path to the file in Google Cloud Storage where the export '
        'will be stored. The URI is in the form gs://bucketName/fileName. '
        'If the file already exists, the operation fails. If the filename '
        'ends with .gz, the contents are compressed.')
    flags.AddDatabaseList(parser, flags.DEFAULT_DATABASE_LIST_EXPORT_HELP_TEXT)
Пример #5
0
def AddBaseImportFlags(parser, filetype):
    base.ASYNC_FLAG.AddToParser(parser)
    flags.AddInstanceArgument(parser)
    flags.AddUriArgument(
        parser,
        'Path to the {filetype} file in Google Cloud Storage from which'
        ' the import is made. The URI is in the form gs://bucketName/fileName.'
        ' Compressed gzip files (.gz) are also supported.'.format(
            filetype=filetype))
    flags.AddUser(parser, 'PostgreSQL user for this import operation.')
    def Args(parser):
        """Args is called by calliope to gather arguments for this command.

    Args:
      parser: An argparse parser that you can use to add arguments that go on
        the command line after this command. Positional arguments are allowed.
    """
        flags.AddInstanceArgument(parser)
        flags.AddRescheduleType(parser)
        flags.AddScheduleTime(parser)
Пример #7
0
def AddBaseExportFlags(parser):
    base.ASYNC_FLAG.AddToParser(parser)
    flags.AddInstanceArgument(parser)
    flags.AddUriArgument(
        parser,
        'The path to the file in Google Cloud Storage where the export '
        'will be stored. The URI is in the form gs://bucketName/fileName. '
        'If the file already exists, the operation fails. If the filename '
        'ends with .gz, the contents are compressed.')
    flags.AddDatabaseList(
        parser, 'Database (for example, guestbook) from which the export is '
        'made. If unspecified, all databases are exported.')