Esempio n. 1
0
    def Args(parser):
        """Args is called by calliope to gather arguments for this command.

    Please add arguments in alphabetical order except for no- or a clear-
    pair for that argument which can follow the argument itself.
    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.Instance(
            positional=False,
            text='The ID of the instance the operations are executing on.'
        ).AddToParser(parser)
        flags.Database(
            positional=False,
            required=False,
            text='For database operations, the name of the database '
            'the operations are executing on.').AddToParser(parser)
        parser.display_info.AddFormat("""
          table(
            name.basename():label=OPERATION_ID,
            metadata.statements.join(sep="\n"),
            done,
            metadata.'@type'.split('.').slice(-1:).join()
          )
        """)
        parser.display_info.AddCacheUpdater(None)
Esempio n. 2
0
    def Args(parser):
        """Args is called by calliope to gather arguments for this command.

    Please add arguments in alphabetical order except for no- or a clear-
    pair for that argument which can follow the argument itself.
    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.Instance(positional=False).AddToParser(parser)
        flags.Database().AddToParser(parser)
        parser.add_argument(
            '--sql',
            required=True,
            help='The SQL query to issue to the database. Cloud Spanner SQL is '
            'described at https://cloud.google.com/spanner/docs/query-syntax')

        query_mode_choices = {
            'NORMAL':
            'Returns only the query result, without any information about '
            'the query plan.',
            'PLAN':
            'Returns only the query plan, without any result rows or '
            'execution statistics information.',
            'PROFILE':
            'Returns both the query plan and the execution statistics along '
            'with the result rows.'
        }

        parser.add_argument('--query-mode',
                            default='NORMAL',
                            type=str.upper,
                            choices=query_mode_choices,
                            help='Mode in which the query must be processed.')
    def Args(parser):
        """Args is called by calliope to gather arguments for this command.

    Please add arguments in alphabetical order except for no- or a clear-
    pair for that argument which can follow the argument itself.
    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.Instance(positional=False).AddToParser(parser)
        flags.Database().AddToParser(parser)
    def Args(parser):
        """Args is called by calliope to gather arguments for this command.

    Please add arguments in alphabetical order except for no- or a clear-
    pair for that argument which can follow the argument itself.
    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.Instance(positional=False).AddToParser(parser)
        flags.Database().AddToParser(parser)

        known_roles = databases.KNOWN_ROLES
        iam_util.AddArgsForRemoveIamPolicyBinding(parser, known_roles)
Esempio n. 5
0
    def Args(parser):
        """Args is called by calliope to gather arguments for this command.

    Please add arguments in alphabetical order except for no- or a clear-
    pair for that argument which can follow the argument itself.
    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.Instance(positional=False).AddToParser(parser)
        flags.Database().AddToParser(parser)
        parser.add_argument(
            '--sql',
            required=True,
            help='The SQL query to issue to the database. Cloud Spanner SQL is '
            'described at https://cloud.google.com/spanner/docs/query-syntax')
Esempio n. 6
0
  def Args(parser):
    """Args is called by calliope to gather arguments for this command.

    Please add arguments in alphabetical order except for no- or a clear-
    pair for that argument which can follow the argument itself.
    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.Instance(positional=False,
                   text='The ID of the instance the operation is executing on.'
                  ).AddToParser(parser)
    flags.Database(positional=False, required=False,
                   text='For a database operation, the name of the database '
                   'the operation is executing on.').AddToParser(parser)
    flags.OperationId().AddToParser(parser)
Esempio n. 7
0
  def Args(parser):
    """Args is called by calliope to gather arguments for this command.

    Please add arguments in alphabetical order except for no- or a clear-
    pair for that argument which can follow the argument itself.
    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.Instance(positional=False).AddToParser(parser)
    flags.Database().AddToParser(parser)
    flags.Ddl(required=True, help_text='Semi-colon separated DDL '
              '(data definition language) statements to '
              'run inside the database. If a statement fails, all subsequent '
              'statements in the batch are automatically cancelled.'
             ).AddToParser(parser)
    base.ASYNC_FLAG.AddToParser(parser)
Esempio n. 8
0
  def Args(parser):
    """Args is called by calliope to gather arguments for this command.

    Please add arguments in alphabetical order except for no- or a clear-
    pair for that argument which can follow the argument itself.
    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.Instance(positional=False).AddToParser(parser)
    flags.Database().AddToParser(parser)
    flags.Ddl(help_text='Semi-colon separated DDL (data definition language) '
              'statements to run inside the '
              'newly created database. If there is an error in any statement, '
              'the database is not created. Full DDL specification is at '
              'https://cloud.google.com/spanner/docs/data-definition-language'
             ).AddToParser(parser)
    base.ASYNC_FLAG.AddToParser(parser)
Esempio n. 9
0
    def Args(parser):
        """Args is called by calliope to gather arguments for this command.

    Please add arguments in alphabetical order except for no- or a clear-
    pair for that argument which can follow the argument itself.
    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.Instance(positional=False).AddToParser(parser)
        flags.Database(positional=False).AddToParser(parser)

        parser.add_argument(
            '--server-filter',
            required=False,
            help=
            'An expression for filtering the results of the request on the server. '
            'Filter rules are case insensitive. The fields eligible for filtering '
            'are: * labels.key where key is the name of a label.')
Esempio n. 10
0
  def Args(parser):
    """Args is called by calliope to gather arguments for this command.

    Please add arguments in alphabetical order except for no- or a clear-
    pair for that argument which can follow the argument itself.
    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.Instance(
        positional=False,
        text='The ID of the instance the operations are executing on.'
    ).AddToParser(parser)
    flags.Database(
        positional=False,
        required=False,
        text='For database operations, the name of the database '
        'the operations are executing on.').AddToParser(parser)
    flags.Backup(
        positional=False,
        required=False,
        text='For backup operations, the name of the backup '
        'the operations are executing on.').AddToParser(parser)

    type_choices = {
        'INSTANCE':
            'Returns instance operations for the given instance. '
            'Note, type=INSTANCE does not work with --database or --backup.',
        'DATABASE':
            'If only the instance is specified (--instance), returns all '
            'database operations associated with the databases in the '
            'instance. When a database is specified (--database), the command '
            'would return database operations for the given database.',
        'BACKUP':
            'If only the instance is specified (--instance), returns all '
            'backup operations associated with backups in the instance. When '
            'a backup is specified (--backup), only the backup operations for '
            'the given backup are returned.',
        'DATABASE_RESTORE':
            'Database restore operations are returned for all databases in '
            'the given instance (--instance only) or only those associated '
            'with the given database (--database)',
        'DATABASE_CREATE':
            'Database create operations are returned for all databases in '
            'the given instance (--instance only) or only those associated '
            'with the given database (--database)',
        'DATABASE_UPDATE_DDL':
            'Database update DDL operations are returned for all databases in '
            'the given instance (--instance only) or only those associated '
            'with the given database (--database)'
    }

    parser.add_argument(
        '--type',
        default='',
        type=lambda x: x.upper(),
        choices=type_choices,
        help='(optional) List only the operations of the given type.')

    parser.display_info.AddFormat("""
          table(
            name.basename():label=OPERATION_ID,
            metadata.statements.join(sep="\n"),
            done():label=DONE,
            metadata.'@type'.split('.').slice(-1:).join()
          )
        """)
    parser.display_info.AddCacheUpdater(None)
    parser.display_info.AddTransforms({'done': _TransformOperationDone})
    parser.display_info.AddTransforms({'database': _TransformDatabaseId})