def AddBaseArgs(parser):
  """Parses provided arguments to add base arguments used for both Beta and GA.

  Args:
    parser: an argparse argument parser.
  """
  resource_args.AddDatabaseResourceArg(parser,
                                       'to execute the SQL query against')
  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=lambda x: x.upper(),
      choices=query_mode_choices,
      help='Mode in which the query must be processed.')

  parser.add_argument(
      '--enable-partitioned-dml',
      action='store_true',
      help='Execute DML statement using Partitioned DML')

  parser.add_argument(
      '--timeout',
      type=arg_parsers.Duration(),
      default='10m',
      help='Maximum time to wait for the SQL query to complete. See $ gcloud '
           'topic datetimes for information on duration formats.')
示例#2
0
 def Args(parser):
     """See base class."""
     resource_args.AddDatabaseResourceArg(parser, 'to create')
     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)
     flags.DdlFile(
         help_text=
         'Path of a file that contains 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.'
         ' If --ddl_file is set, --ddl is ignored.').AddToParser(parser)
     base.ASYNC_FLAG.AddToParser(parser)
     parser.display_info.AddCacheUpdater(flags.DatabaseCompleter)
 def Args(parser):
     """See base class."""
     resource_args.AddDatabaseResourceArg(
         parser, 'to remove IAM policy binding from')
     iam_util.AddArgsForRemoveIamPolicyBinding(parser)
示例#4
0
 def Args(parser):
     """See base class."""
     resource_args.AddDatabaseResourceArg(parser,
                                          'to get IAM policy binding for')
     base.URI_FLAG.RemoveFromParser(parser)
 def Args(parser):
     """See base class."""
     resource_args.AddDatabaseResourceArg(parser, 'to delete')
 def Args(parser):
     """See base class."""
     resource_args.AddDatabaseResourceArg(parser,
                                          'to add IAM policy binding to')
     iam_util.AddArgsForAddIamPolicyBinding(parser)
示例#7
0
 def Args(parser):
     """See base class."""
     resource_args.AddDatabaseResourceArg(parser,
                                          'of which the ddl to describe')
     parser.display_info.AddCacheUpdater(None)
示例#8
0
    def Args(parser):
        """See base class."""

        resource_args.AddDatabaseResourceArg(parser, 'to create')
        parser.display_info.AddCacheUpdater(flags.DatabaseCompleter)
 def Args(parser):
   """See base class."""
   resource_args.AddDatabaseResourceArg(parser,
                                        'to set IAM policy binding for')
   parser.add_argument(
       'policy_file', help='Name of JSON or YAML file with the IAM policy.')