Home | History | Annotate | Download | only in servicemanagement_v1
      1 #!/usr/bin/env python
      2 """CLI for servicemanagement, version v1."""
      3 # NOTE: This file is autogenerated and should not be edited by hand.
      4 
      5 import code
      6 import os
      7 import platform
      8 import sys
      9 
     10 from apitools.base.protorpclite import message_types
     11 from apitools.base.protorpclite import messages
     12 
     13 from google.apputils import appcommands
     14 import gflags as flags
     15 
     16 import apitools.base.py as apitools_base
     17 from apitools.base.py import cli as apitools_base_cli
     18 import servicemanagement_v1_client as client_lib
     19 import servicemanagement_v1_messages as messages
     20 
     21 
     22 def _DeclareServicemanagementFlags():
     23   """Declare global flags in an idempotent way."""
     24   if 'api_endpoint' in flags.FLAGS:
     25     return
     26   flags.DEFINE_string(
     27       'api_endpoint',
     28       u'https://servicemanagement.googleapis.com/',
     29       'URL of the API endpoint to use.',
     30       short_name='servicemanagement_url')
     31   flags.DEFINE_string(
     32       'history_file',
     33       u'~/.servicemanagement.v1.history',
     34       'File with interactive shell history.')
     35   flags.DEFINE_multistring(
     36       'add_header', [],
     37       'Additional http headers (as key=value strings). '
     38       'Can be specified multiple times.')
     39   flags.DEFINE_string(
     40       'service_account_json_keyfile', '',
     41       'Filename for a JSON service account key downloaded'
     42       ' from the Developer Console.')
     43   flags.DEFINE_enum(
     44       'f__xgafv',
     45       u'_1',
     46       [u'_1', u'_2'],
     47       u'V1 error format.')
     48   flags.DEFINE_string(
     49       'access_token',
     50       None,
     51       u'OAuth access token.')
     52   flags.DEFINE_enum(
     53       'alt',
     54       u'json',
     55       [u'json', u'media', u'proto'],
     56       u'Data format for response.')
     57   flags.DEFINE_string(
     58       'bearer_token',
     59       None,
     60       u'OAuth bearer token.')
     61   flags.DEFINE_string(
     62       'callback',
     63       None,
     64       u'JSONP')
     65   flags.DEFINE_string(
     66       'fields',
     67       None,
     68       u'Selector specifying which fields to include in a partial response.')
     69   flags.DEFINE_string(
     70       'key',
     71       None,
     72       u'API key. Your API key identifies your project and provides you with '
     73       u'API access, quota, and reports. Required unless you provide an OAuth '
     74       u'2.0 token.')
     75   flags.DEFINE_string(
     76       'oauth_token',
     77       None,
     78       u'OAuth 2.0 token for the current user.')
     79   flags.DEFINE_boolean(
     80       'pp',
     81       'True',
     82       u'Pretty-print response.')
     83   flags.DEFINE_boolean(
     84       'prettyPrint',
     85       'True',
     86       u'Returns response with indentations and line breaks.')
     87   flags.DEFINE_string(
     88       'quotaUser',
     89       None,
     90       u'Available to use for quota purposes for server-side applications. Can'
     91       u' be any arbitrary string assigned to a user, but should not exceed 40'
     92       u' characters.')
     93   flags.DEFINE_string(
     94       'trace',
     95       None,
     96       'A tracing token of the form "token:<tokenid>" to include in api '
     97       'requests.')
     98   flags.DEFINE_string(
     99       'uploadType',
    100       None,
    101       u'Legacy upload protocol for media (e.g. "media", "multipart").')
    102   flags.DEFINE_string(
    103       'upload_protocol',
    104       None,
    105       u'Upload protocol for media (e.g. "raw", "multipart").')
    106 
    107 
    108 FLAGS = flags.FLAGS
    109 apitools_base_cli.DeclareBaseFlags()
    110 _DeclareServicemanagementFlags()
    111 
    112 
    113 def GetGlobalParamsFromFlags():
    114   """Return a StandardQueryParameters based on flags."""
    115   result = messages.StandardQueryParameters()
    116   if FLAGS['f__xgafv'].present:
    117     result.f__xgafv = messages.StandardQueryParameters.FXgafvValueValuesEnum(FLAGS.f__xgafv)
    118   if FLAGS['access_token'].present:
    119     result.access_token = FLAGS.access_token.decode('utf8')
    120   if FLAGS['alt'].present:
    121     result.alt = messages.StandardQueryParameters.AltValueValuesEnum(FLAGS.alt)
    122   if FLAGS['bearer_token'].present:
    123     result.bearer_token = FLAGS.bearer_token.decode('utf8')
    124   if FLAGS['callback'].present:
    125     result.callback = FLAGS.callback.decode('utf8')
    126   if FLAGS['fields'].present:
    127     result.fields = FLAGS.fields.decode('utf8')
    128   if FLAGS['key'].present:
    129     result.key = FLAGS.key.decode('utf8')
    130   if FLAGS['oauth_token'].present:
    131     result.oauth_token = FLAGS.oauth_token.decode('utf8')
    132   if FLAGS['pp'].present:
    133     result.pp = FLAGS.pp
    134   if FLAGS['prettyPrint'].present:
    135     result.prettyPrint = FLAGS.prettyPrint
    136   if FLAGS['quotaUser'].present:
    137     result.quotaUser = FLAGS.quotaUser.decode('utf8')
    138   if FLAGS['trace'].present:
    139     result.trace = FLAGS.trace.decode('utf8')
    140   if FLAGS['uploadType'].present:
    141     result.uploadType = FLAGS.uploadType.decode('utf8')
    142   if FLAGS['upload_protocol'].present:
    143     result.upload_protocol = FLAGS.upload_protocol.decode('utf8')
    144   return result
    145 
    146 
    147 def GetClientFromFlags():
    148   """Return a client object, configured from flags."""
    149   log_request = FLAGS.log_request or FLAGS.log_request_response
    150   log_response = FLAGS.log_response or FLAGS.log_request_response
    151   api_endpoint = apitools_base.NormalizeApiEndpoint(FLAGS.api_endpoint)
    152   additional_http_headers = dict(x.split('=', 1) for x in FLAGS.add_header)
    153   credentials_args = {
    154       'service_account_json_keyfile': os.path.expanduser(FLAGS.service_account_json_keyfile)
    155   }
    156   try:
    157     client = client_lib.ServicemanagementV1(
    158         api_endpoint, log_request=log_request,
    159         log_response=log_response,
    160         credentials_args=credentials_args,
    161         additional_http_headers=additional_http_headers)
    162   except apitools_base.CredentialsError as e:
    163     print 'Error creating credentials: %s' % e
    164     sys.exit(1)
    165   return client
    166 
    167 
    168 class PyShell(appcommands.Cmd):
    169 
    170   def Run(self, _):
    171     """Run an interactive python shell with the client."""
    172     client = GetClientFromFlags()
    173     params = GetGlobalParamsFromFlags()
    174     for field in params.all_fields():
    175       value = params.get_assigned_value(field.name)
    176       if value != field.default:
    177         client.AddGlobalParam(field.name, value)
    178     banner = """
    179            == servicemanagement interactive console ==
    180                  client: a servicemanagement client
    181           apitools_base: base apitools module
    182          messages: the generated messages module
    183     """
    184     local_vars = {
    185         'apitools_base': apitools_base,
    186         'client': client,
    187         'client_lib': client_lib,
    188         'messages': messages,
    189     }
    190     if platform.system() == 'Linux':
    191       console = apitools_base_cli.ConsoleWithReadline(
    192           local_vars, histfile=FLAGS.history_file)
    193     else:
    194       console = code.InteractiveConsole(local_vars)
    195     try:
    196       console.interact(banner)
    197     except SystemExit as e:
    198       return e.code
    199 
    200 
    201 class OperationsGet(apitools_base_cli.NewCmd):
    202   """Command wrapping operations.Get."""
    203 
    204   usage = """operations_get <operationsId>"""
    205 
    206   def __init__(self, name, fv):
    207     super(OperationsGet, self).__init__(name, fv)
    208 
    209   def RunWithArgs(self, operationsId):
    210     """Gets the latest state of a long-running operation.  Clients can use
    211     this method to poll the operation result at intervals as recommended by
    212     the API service.
    213 
    214     Args:
    215       operationsId: Part of `name`. The name of the operation resource.
    216     """
    217     client = GetClientFromFlags()
    218     global_params = GetGlobalParamsFromFlags()
    219     request = messages.ServicemanagementOperationsGetRequest(
    220         operationsId=operationsId.decode('utf8'),
    221         )
    222     result = client.operations.Get(
    223         request, global_params=global_params)
    224     print apitools_base_cli.FormatOutput(result)
    225 
    226 
    227 class ServicesConvertConfig(apitools_base_cli.NewCmd):
    228   """Command wrapping services.ConvertConfig."""
    229 
    230   usage = """services_convertConfig"""
    231 
    232   def __init__(self, name, fv):
    233     super(ServicesConvertConfig, self).__init__(name, fv)
    234     flags.DEFINE_string(
    235         'configSpec',
    236         None,
    237         u'Input configuration For this version of API, the supported type is '
    238         u'OpenApiSpec',
    239         flag_values=fv)
    240     flags.DEFINE_string(
    241         'openApiSpec',
    242         None,
    243         u'The OpenAPI specification for an API.',
    244         flag_values=fv)
    245     flags.DEFINE_string(
    246         'serviceName',
    247         None,
    248         u'The service name to use for constructing the normalized service '
    249         u'configuration equivalent of the provided configuration '
    250         u'specification.',
    251         flag_values=fv)
    252     flags.DEFINE_string(
    253         'swaggerSpec',
    254         None,
    255         u'The swagger specification for an API.',
    256         flag_values=fv)
    257 
    258   def RunWithArgs(self):
    259     """DEPRECATED. `SubmitConfigSource` with `validate_only=true` will provide
    260     config conversion moving forward.  Converts an API specification (e.g.
    261     Swagger spec) to an equivalent `google.api.Service`.
    262 
    263     Flags:
    264       configSpec: Input configuration For this version of API, the supported
    265         type is OpenApiSpec
    266       openApiSpec: The OpenAPI specification for an API.
    267       serviceName: The service name to use for constructing the normalized
    268         service configuration equivalent of the provided configuration
    269         specification.
    270       swaggerSpec: The swagger specification for an API.
    271     """
    272     client = GetClientFromFlags()
    273     global_params = GetGlobalParamsFromFlags()
    274     request = messages.ConvertConfigRequest(
    275         )
    276     if FLAGS['configSpec'].present:
    277       request.configSpec = apitools_base.JsonToMessage(messages.ConvertConfigRequest.ConfigSpecValue, FLAGS.configSpec)
    278     if FLAGS['openApiSpec'].present:
    279       request.openApiSpec = apitools_base.JsonToMessage(messages.OpenApiSpec, FLAGS.openApiSpec)
    280     if FLAGS['serviceName'].present:
    281       request.serviceName = FLAGS.serviceName.decode('utf8')
    282     if FLAGS['swaggerSpec'].present:
    283       request.swaggerSpec = apitools_base.JsonToMessage(messages.SwaggerSpec, FLAGS.swaggerSpec)
    284     result = client.services.ConvertConfig(
    285         request, global_params=global_params)
    286     print apitools_base_cli.FormatOutput(result)
    287 
    288 
    289 class ServicesCreate(apitools_base_cli.NewCmd):
    290   """Command wrapping services.Create."""
    291 
    292   usage = """services_create"""
    293 
    294   def __init__(self, name, fv):
    295     super(ServicesCreate, self).__init__(name, fv)
    296     flags.DEFINE_string(
    297         'configSource',
    298         None,
    299         u'User-supplied source configuration for the service. This is '
    300         u'distinct from the generated configuration provided in '
    301         u'`google.api.Service`. This is NOT populated on GetService calls at '
    302         u'the moment. NOTE: Any upsert operation that contains both a '
    303         u'service_config and a config_source is considered invalid and will '
    304         u'result in an error being returned.',
    305         flag_values=fv)
    306     flags.DEFINE_string(
    307         'generation',
    308         None,
    309         u'A server-assigned monotonically increasing number that changes '
    310         u'whenever a mutation is made to the `ManagedService` or any of its '
    311         u'components via the `ServiceManager` API.',
    312         flag_values=fv)
    313     flags.DEFINE_string(
    314         'operations',
    315         None,
    316         u'Read-only view of pending operations affecting this resource, if '
    317         u'requested.',
    318         flag_values=fv)
    319     flags.DEFINE_string(
    320         'producerProjectId',
    321         None,
    322         u'ID of the project that produces and owns this service.',
    323         flag_values=fv)
    324     flags.DEFINE_string(
    325         'projectSettings',
    326         None,
    327         u'Read-only view of settings for a particular consumer project, if '
    328         u'requested.',
    329         flag_values=fv)
    330     flags.DEFINE_string(
    331         'serviceConfig',
    332         None,
    333         u"The service's generated configuration.",
    334         flag_values=fv)
    335     flags.DEFINE_string(
    336         'serviceName',
    337         None,
    338         u'The name of the service.  See the `ServiceManager` overview for '
    339         u'naming requirements.  This name must match '
    340         u'`google.api.Service.name` in the `service_config` field.',
    341         flag_values=fv)
    342 
    343   def RunWithArgs(self):
    344     """Creates a new managed service.  Operation<response: ManagedService>
    345 
    346     Flags:
    347       configSource: User-supplied source configuration for the service. This
    348         is distinct from the generated configuration provided in
    349         `google.api.Service`. This is NOT populated on GetService calls at the
    350         moment. NOTE: Any upsert operation that contains both a service_config
    351         and a config_source is considered invalid and will result in an error
    352         being returned.
    353       generation: A server-assigned monotonically increasing number that
    354         changes whenever a mutation is made to the `ManagedService` or any of
    355         its components via the `ServiceManager` API.
    356       operations: Read-only view of pending operations affecting this
    357         resource, if requested.
    358       producerProjectId: ID of the project that produces and owns this
    359         service.
    360       projectSettings: Read-only view of settings for a particular consumer
    361         project, if requested.
    362       serviceConfig: The service's generated configuration.
    363       serviceName: The name of the service.  See the `ServiceManager` overview
    364         for naming requirements.  This name must match
    365         `google.api.Service.name` in the `service_config` field.
    366     """
    367     client = GetClientFromFlags()
    368     global_params = GetGlobalParamsFromFlags()
    369     request = messages.ManagedService(
    370         )
    371     if FLAGS['configSource'].present:
    372       request.configSource = apitools_base.JsonToMessage(messages.ConfigSource, FLAGS.configSource)
    373     if FLAGS['generation'].present:
    374       request.generation = int(FLAGS.generation)
    375     if FLAGS['operations'].present:
    376       request.operations = [apitools_base.JsonToMessage(messages.Operation, x) for x in FLAGS.operations]
    377     if FLAGS['producerProjectId'].present:
    378       request.producerProjectId = FLAGS.producerProjectId.decode('utf8')
    379     if FLAGS['projectSettings'].present:
    380       request.projectSettings = apitools_base.JsonToMessage(messages.ProjectSettings, FLAGS.projectSettings)
    381     if FLAGS['serviceConfig'].present:
    382       request.serviceConfig = apitools_base.JsonToMessage(messages.Service, FLAGS.serviceConfig)
    383     if FLAGS['serviceName'].present:
    384       request.serviceName = FLAGS.serviceName.decode('utf8')
    385     result = client.services.Create(
    386         request, global_params=global_params)
    387     print apitools_base_cli.FormatOutput(result)
    388 
    389 
    390 class ServicesDelete(apitools_base_cli.NewCmd):
    391   """Command wrapping services.Delete."""
    392 
    393   usage = """services_delete <serviceName>"""
    394 
    395   def __init__(self, name, fv):
    396     super(ServicesDelete, self).__init__(name, fv)
    397 
    398   def RunWithArgs(self, serviceName):
    399     """Deletes a managed service.  Operation<response: google.protobuf.Empty>
    400 
    401     Args:
    402       serviceName: The name of the service.  See the `ServiceManager` overview
    403         for naming requirements.  For example: `example.googleapis.com`.
    404     """
    405     client = GetClientFromFlags()
    406     global_params = GetGlobalParamsFromFlags()
    407     request = messages.ServicemanagementServicesDeleteRequest(
    408         serviceName=serviceName.decode('utf8'),
    409         )
    410     result = client.services.Delete(
    411         request, global_params=global_params)
    412     print apitools_base_cli.FormatOutput(result)
    413 
    414 
    415 class ServicesDisable(apitools_base_cli.NewCmd):
    416   """Command wrapping services.Disable."""
    417 
    418   usage = """services_disable <serviceName>"""
    419 
    420   def __init__(self, name, fv):
    421     super(ServicesDisable, self).__init__(name, fv)
    422     flags.DEFINE_string(
    423         'disableServiceRequest',
    424         None,
    425         u'A DisableServiceRequest resource to be passed as the request body.',
    426         flag_values=fv)
    427 
    428   def RunWithArgs(self, serviceName):
    429     """Disable a managed service for a project. Google Service Management will
    430     only disable the managed service even if there are other services depend
    431     on the managed service.  Operation<response: DisableServiceResponse>
    432 
    433     Args:
    434       serviceName: Name of the service to disable. Specifying an unknown
    435         service name will cause the request to fail.
    436 
    437     Flags:
    438       disableServiceRequest: A DisableServiceRequest resource to be passed as
    439         the request body.
    440     """
    441     client = GetClientFromFlags()
    442     global_params = GetGlobalParamsFromFlags()
    443     request = messages.ServicemanagementServicesDisableRequest(
    444         serviceName=serviceName.decode('utf8'),
    445         )
    446     if FLAGS['disableServiceRequest'].present:
    447       request.disableServiceRequest = apitools_base.JsonToMessage(messages.DisableServiceRequest, FLAGS.disableServiceRequest)
    448     result = client.services.Disable(
    449         request, global_params=global_params)
    450     print apitools_base_cli.FormatOutput(result)
    451 
    452 
    453 class ServicesEnable(apitools_base_cli.NewCmd):
    454   """Command wrapping services.Enable."""
    455 
    456   usage = """services_enable <serviceName>"""
    457 
    458   def __init__(self, name, fv):
    459     super(ServicesEnable, self).__init__(name, fv)
    460     flags.DEFINE_string(
    461         'enableServiceRequest',
    462         None,
    463         u'A EnableServiceRequest resource to be passed as the request body.',
    464         flag_values=fv)
    465 
    466   def RunWithArgs(self, serviceName):
    467     """Enable a managed service for a project with default setting. If the
    468     managed service has dependencies, they will be enabled as well.
    469     Operation<response: EnableServiceResponse>
    470 
    471     Args:
    472       serviceName: Name of the service to enable. Specifying an unknown
    473         service name will cause the request to fail.
    474 
    475     Flags:
    476       enableServiceRequest: A EnableServiceRequest resource to be passed as
    477         the request body.
    478     """
    479     client = GetClientFromFlags()
    480     global_params = GetGlobalParamsFromFlags()
    481     request = messages.ServicemanagementServicesEnableRequest(
    482         serviceName=serviceName.decode('utf8'),
    483         )
    484     if FLAGS['enableServiceRequest'].present:
    485       request.enableServiceRequest = apitools_base.JsonToMessage(messages.EnableServiceRequest, FLAGS.enableServiceRequest)
    486     result = client.services.Enable(
    487         request, global_params=global_params)
    488     print apitools_base_cli.FormatOutput(result)
    489 
    490 
    491 class ServicesGet(apitools_base_cli.NewCmd):
    492   """Command wrapping services.Get."""
    493 
    494   usage = """services_get <serviceName>"""
    495 
    496   def __init__(self, name, fv):
    497     super(ServicesGet, self).__init__(name, fv)
    498     flags.DEFINE_string(
    499         'consumerProjectId',
    500         None,
    501         u'If project_settings is expanded, return settings for the specified '
    502         u'consumer project.',
    503         flag_values=fv)
    504     flags.DEFINE_string(
    505         'expand',
    506         None,
    507         u'Fields to expand in any results.  By default, the following fields '
    508         u'are not present in the result: - `operations` - `project_settings` '
    509         u'- `project_settings.operations` - `quota_usage` (It requires '
    510         u'`project_settings`) - `historical_quota_usage` (It requires '
    511         u'`project_settings`)',
    512         flag_values=fv)
    513     flags.DEFINE_enum(
    514         'view',
    515         u'PROJECT_SETTINGS_VIEW_UNSPECIFIED',
    516         [u'PROJECT_SETTINGS_VIEW_UNSPECIFIED', u'CONSUMER_VIEW', u'PRODUCER_VIEW', u'ALL'],
    517         u'If project_settings is expanded, request only fields for the '
    518         u'specified view.',
    519         flag_values=fv)
    520 
    521   def RunWithArgs(self, serviceName):
    522     """Gets a managed service. If the `consumer_project_id` is specified, the
    523     project's settings for the specified service are also returned.
    524 
    525     Args:
    526       serviceName: The name of the service.  See the `ServiceManager` overview
    527         for naming requirements.  For example: `example.googleapis.com`.
    528 
    529     Flags:
    530       consumerProjectId: If project_settings is expanded, return settings for
    531         the specified consumer project.
    532       expand: Fields to expand in any results.  By default, the following
    533         fields are not present in the result: - `operations` -
    534         `project_settings` - `project_settings.operations` - `quota_usage` (It
    535         requires `project_settings`) - `historical_quota_usage` (It requires
    536         `project_settings`)
    537       view: If project_settings is expanded, request only fields for the
    538         specified view.
    539     """
    540     client = GetClientFromFlags()
    541     global_params = GetGlobalParamsFromFlags()
    542     request = messages.ServicemanagementServicesGetRequest(
    543         serviceName=serviceName.decode('utf8'),
    544         )
    545     if FLAGS['consumerProjectId'].present:
    546       request.consumerProjectId = FLAGS.consumerProjectId.decode('utf8')
    547     if FLAGS['expand'].present:
    548       request.expand = FLAGS.expand.decode('utf8')
    549     if FLAGS['view'].present:
    550       request.view = messages.ServicemanagementServicesGetRequest.ViewValueValuesEnum(FLAGS.view)
    551     result = client.services.Get(
    552         request, global_params=global_params)
    553     print apitools_base_cli.FormatOutput(result)
    554 
    555 
    556 class ServicesGetAccessPolicy(apitools_base_cli.NewCmd):
    557   """Command wrapping services.GetAccessPolicy."""
    558 
    559   usage = """services_getAccessPolicy <serviceName>"""
    560 
    561   def __init__(self, name, fv):
    562     super(ServicesGetAccessPolicy, self).__init__(name, fv)
    563 
    564   def RunWithArgs(self, serviceName):
    565     """Producer method to retrieve current policy.
    566 
    567     Args:
    568       serviceName: The name of the service.  For example:
    569         `example.googleapis.com`.
    570     """
    571     client = GetClientFromFlags()
    572     global_params = GetGlobalParamsFromFlags()
    573     request = messages.ServicemanagementServicesGetAccessPolicyRequest(
    574         serviceName=serviceName.decode('utf8'),
    575         )
    576     result = client.services.GetAccessPolicy(
    577         request, global_params=global_params)
    578     print apitools_base_cli.FormatOutput(result)
    579 
    580 
    581 class ServicesGetConfig(apitools_base_cli.NewCmd):
    582   """Command wrapping services.GetConfig."""
    583 
    584   usage = """services_getConfig <serviceName>"""
    585 
    586   def __init__(self, name, fv):
    587     super(ServicesGetConfig, self).__init__(name, fv)
    588     flags.DEFINE_string(
    589         'configId',
    590         None,
    591         u'The id of the service config resource. Optional. If it is not '
    592         u'specified, the latest version of config will be returned.',
    593         flag_values=fv)
    594 
    595   def RunWithArgs(self, serviceName):
    596     """Gets a service config (version) for a managed service. If `config_id`
    597     is not specified, the latest service config will be returned.
    598 
    599     Args:
    600       serviceName: The name of the service.  See the `ServiceManager` overview
    601         for naming requirements.  For example: `example.googleapis.com`.
    602 
    603     Flags:
    604       configId: The id of the service config resource. Optional. If it is not
    605         specified, the latest version of config will be returned.
    606     """
    607     client = GetClientFromFlags()
    608     global_params = GetGlobalParamsFromFlags()
    609     request = messages.ServicemanagementServicesGetConfigRequest(
    610         serviceName=serviceName.decode('utf8'),
    611         )
    612     if FLAGS['configId'].present:
    613       request.configId = FLAGS.configId.decode('utf8')
    614     result = client.services.GetConfig(
    615         request, global_params=global_params)
    616     print apitools_base_cli.FormatOutput(result)
    617 
    618 
    619 class ServicesList(apitools_base_cli.NewCmd):
    620   """Command wrapping services.List."""
    621 
    622   usage = """services_list"""
    623 
    624   def __init__(self, name, fv):
    625     super(ServicesList, self).__init__(name, fv)
    626     flags.DEFINE_string(
    627         'category',
    628         None,
    629         u'Include services only in the specified category. Supported '
    630         u'categories are servicemanagement.googleapis.com/categories/google-'
    631         u'services or servicemanagement.googleapis.com/categories/play-games.',
    632         flag_values=fv)
    633     flags.DEFINE_string(
    634         'consumerProjectId',
    635         None,
    636         u'Include services consumed by the specified project.  If '
    637         u'project_settings is expanded, then this field controls which '
    638         u'project project_settings is populated for.',
    639         flag_values=fv)
    640     flags.DEFINE_string(
    641         'expand',
    642         None,
    643         u'Fields to expand in any results.  By default, the following fields '
    644         u'are not fully included in list results: - `operations` - '
    645         u'`project_settings` - `project_settings.operations` - `quota_usage` '
    646         u'(It requires `project_settings`)',
    647         flag_values=fv)
    648     flags.DEFINE_integer(
    649         'pageSize',
    650         None,
    651         u'Requested size of the next page of data.',
    652         flag_values=fv)
    653     flags.DEFINE_string(
    654         'pageToken',
    655         None,
    656         u'Token identifying which result to start with; returned by a '
    657         u'previous list call.',
    658         flag_values=fv)
    659     flags.DEFINE_string(
    660         'producerProjectId',
    661         None,
    662         u'Include services produced by the specified project.',
    663         flag_values=fv)
    664 
    665   def RunWithArgs(self):
    666     """Lists all managed services. If the `consumer_project_id` is specified,
    667     the project's settings for the specified service are also returned.
    668 
    669     Flags:
    670       category: Include services only in the specified category. Supported
    671         categories are servicemanagement.googleapis.com/categories/google-
    672         services or servicemanagement.googleapis.com/categories/play-games.
    673       consumerProjectId: Include services consumed by the specified project.
    674         If project_settings is expanded, then this field controls which
    675         project project_settings is populated for.
    676       expand: Fields to expand in any results.  By default, the following
    677         fields are not fully included in list results: - `operations` -
    678         `project_settings` - `project_settings.operations` - `quota_usage` (It
    679         requires `project_settings`)
    680       pageSize: Requested size of the next page of data.
    681       pageToken: Token identifying which result to start with; returned by a
    682         previous list call.
    683       producerProjectId: Include services produced by the specified project.
    684     """
    685     client = GetClientFromFlags()
    686     global_params = GetGlobalParamsFromFlags()
    687     request = messages.ServicemanagementServicesListRequest(
    688         )
    689     if FLAGS['category'].present:
    690       request.category = FLAGS.category.decode('utf8')
    691     if FLAGS['consumerProjectId'].present:
    692       request.consumerProjectId = FLAGS.consumerProjectId.decode('utf8')
    693     if FLAGS['expand'].present:
    694       request.expand = FLAGS.expand.decode('utf8')
    695     if FLAGS['pageSize'].present:
    696       request.pageSize = FLAGS.pageSize
    697     if FLAGS['pageToken'].present:
    698       request.pageToken = FLAGS.pageToken.decode('utf8')
    699     if FLAGS['producerProjectId'].present:
    700       request.producerProjectId = FLAGS.producerProjectId.decode('utf8')
    701     result = client.services.List(
    702         request, global_params=global_params)
    703     print apitools_base_cli.FormatOutput(result)
    704 
    705 
    706 class ServicesPatch(apitools_base_cli.NewCmd):
    707   """Command wrapping services.Patch."""
    708 
    709   usage = """services_patch <serviceName>"""
    710 
    711   def __init__(self, name, fv):
    712     super(ServicesPatch, self).__init__(name, fv)
    713     flags.DEFINE_string(
    714         'managedService',
    715         None,
    716         u'A ManagedService resource to be passed as the request body.',
    717         flag_values=fv)
    718     flags.DEFINE_string(
    719         'updateMask',
    720         None,
    721         u'A mask specifying which fields to update.',
    722         flag_values=fv)
    723 
    724   def RunWithArgs(self, serviceName):
    725     """Updates the specified subset of the configuration. If the specified
    726     service does not exists the patch operation fails.  Operation<response:
    727     ManagedService>
    728 
    729     Args:
    730       serviceName: The name of the service.  See the `ServiceManager` overview
    731         for naming requirements.  For example: `example.googleapis.com`.
    732 
    733     Flags:
    734       managedService: A ManagedService resource to be passed as the request
    735         body.
    736       updateMask: A mask specifying which fields to update.
    737     """
    738     client = GetClientFromFlags()
    739     global_params = GetGlobalParamsFromFlags()
    740     request = messages.ServicemanagementServicesPatchRequest(
    741         serviceName=serviceName.decode('utf8'),
    742         )
    743     if FLAGS['managedService'].present:
    744       request.managedService = apitools_base.JsonToMessage(messages.ManagedService, FLAGS.managedService)
    745     if FLAGS['updateMask'].present:
    746       request.updateMask = FLAGS.updateMask.decode('utf8')
    747     result = client.services.Patch(
    748         request, global_params=global_params)
    749     print apitools_base_cli.FormatOutput(result)
    750 
    751 
    752 class ServicesPatchConfig(apitools_base_cli.NewCmd):
    753   """Command wrapping services.PatchConfig."""
    754 
    755   usage = """services_patchConfig <serviceName>"""
    756 
    757   def __init__(self, name, fv):
    758     super(ServicesPatchConfig, self).__init__(name, fv)
    759     flags.DEFINE_string(
    760         'service',
    761         None,
    762         u'A Service resource to be passed as the request body.',
    763         flag_values=fv)
    764     flags.DEFINE_string(
    765         'updateMask',
    766         None,
    767         u'A mask specifying which fields to update.',
    768         flag_values=fv)
    769 
    770   def RunWithArgs(self, serviceName):
    771     """Updates the specified subset of the service resource. Equivalent to
    772     calling `PatchService` with only the `service_config` field updated.
    773     Operation<response: google.api.Service>
    774 
    775     Args:
    776       serviceName: The name of the service.  See the `ServiceManager` overview
    777         for naming requirements.  For example: `example.googleapis.com`.
    778 
    779     Flags:
    780       service: A Service resource to be passed as the request body.
    781       updateMask: A mask specifying which fields to update.
    782     """
    783     client = GetClientFromFlags()
    784     global_params = GetGlobalParamsFromFlags()
    785     request = messages.ServicemanagementServicesPatchConfigRequest(
    786         serviceName=serviceName.decode('utf8'),
    787         )
    788     if FLAGS['service'].present:
    789       request.service = apitools_base.JsonToMessage(messages.Service, FLAGS.service)
    790     if FLAGS['updateMask'].present:
    791       request.updateMask = FLAGS.updateMask.decode('utf8')
    792     result = client.services.PatchConfig(
    793         request, global_params=global_params)
    794     print apitools_base_cli.FormatOutput(result)
    795 
    796 
    797 class ServicesUpdate(apitools_base_cli.NewCmd):
    798   """Command wrapping services.Update."""
    799 
    800   usage = """services_update <serviceName>"""
    801 
    802   def __init__(self, name, fv):
    803     super(ServicesUpdate, self).__init__(name, fv)
    804     flags.DEFINE_string(
    805         'managedService',
    806         None,
    807         u'A ManagedService resource to be passed as the request body.',
    808         flag_values=fv)
    809     flags.DEFINE_string(
    810         'updateMask',
    811         None,
    812         u'A mask specifying which fields to update. Update mask has been '
    813         u'deprecated on UpdateService service method. Please use PatchService'
    814         u' method instead to do partial updates.',
    815         flag_values=fv)
    816 
    817   def RunWithArgs(self, serviceName):
    818     """Updates the configuration of a service.  If the specified service does
    819     not already exist, then it is created.  Operation<response:
    820     ManagedService>
    821 
    822     Args:
    823       serviceName: The name of the service.  See the `ServiceManager` overview
    824         for naming requirements.  For example: `example.googleapis.com`.
    825 
    826     Flags:
    827       managedService: A ManagedService resource to be passed as the request
    828         body.
    829       updateMask: A mask specifying which fields to update. Update mask has
    830         been deprecated on UpdateService service method. Please use
    831         PatchService method instead to do partial updates.
    832     """
    833     client = GetClientFromFlags()
    834     global_params = GetGlobalParamsFromFlags()
    835     request = messages.ServicemanagementServicesUpdateRequest(
    836         serviceName=serviceName.decode('utf8'),
    837         )
    838     if FLAGS['managedService'].present:
    839       request.managedService = apitools_base.JsonToMessage(messages.ManagedService, FLAGS.managedService)
    840     if FLAGS['updateMask'].present:
    841       request.updateMask = FLAGS.updateMask.decode('utf8')
    842     result = client.services.Update(
    843         request, global_params=global_params)
    844     print apitools_base_cli.FormatOutput(result)
    845 
    846 
    847 class ServicesUpdateAccessPolicy(apitools_base_cli.NewCmd):
    848   """Command wrapping services.UpdateAccessPolicy."""
    849 
    850   usage = """services_updateAccessPolicy <serviceName>"""
    851 
    852   def __init__(self, name, fv):
    853     super(ServicesUpdateAccessPolicy, self).__init__(name, fv)
    854     flags.DEFINE_string(
    855         'accessList',
    856         None,
    857         u'ACL for access to the unrestricted surface of the service.',
    858         flag_values=fv)
    859     flags.DEFINE_string(
    860         'visibilityLabelAccessLists',
    861         None,
    862         u'ACLs for access to restricted parts of the service.  The map key is'
    863         u' the visibility label that is being controlled.  Note that access '
    864         u'to any label also implies access to the unrestricted surface.',
    865         flag_values=fv)
    866 
    867   def RunWithArgs(self, serviceName):
    868     """Producer method to update the current policy.  This method will return
    869     an error if the policy is too large (more than 50 entries across all
    870     lists).
    871 
    872     Args:
    873       serviceName: The service protected by this policy.
    874 
    875     Flags:
    876       accessList: ACL for access to the unrestricted surface of the service.
    877       visibilityLabelAccessLists: ACLs for access to restricted parts of the
    878         service.  The map key is the visibility label that is being
    879         controlled.  Note that access to any label also implies access to the
    880         unrestricted surface.
    881     """
    882     client = GetClientFromFlags()
    883     global_params = GetGlobalParamsFromFlags()
    884     request = messages.ServiceAccessPolicy(
    885         serviceName=serviceName.decode('utf8'),
    886         )
    887     if FLAGS['accessList'].present:
    888       request.accessList = apitools_base.JsonToMessage(messages.ServiceAccessList, FLAGS.accessList)
    889     if FLAGS['visibilityLabelAccessLists'].present:
    890       request.visibilityLabelAccessLists = apitools_base.JsonToMessage(messages.ServiceAccessPolicy.VisibilityLabelAccessListsValue, FLAGS.visibilityLabelAccessLists)
    891     result = client.services.UpdateAccessPolicy(
    892         request, global_params=global_params)
    893     print apitools_base_cli.FormatOutput(result)
    894 
    895 
    896 class ServicesUpdateConfig(apitools_base_cli.NewCmd):
    897   """Command wrapping services.UpdateConfig."""
    898 
    899   usage = """services_updateConfig <serviceName>"""
    900 
    901   def __init__(self, name, fv):
    902     super(ServicesUpdateConfig, self).__init__(name, fv)
    903     flags.DEFINE_string(
    904         'service',
    905         None,
    906         u'A Service resource to be passed as the request body.',
    907         flag_values=fv)
    908     flags.DEFINE_string(
    909         'updateMask',
    910         None,
    911         u'A mask specifying which fields to update. Update mask has been '
    912         u'deprecated on UpdateServiceConfig service method. Please use '
    913         u'PatchServiceConfig method instead to do partial updates.',
    914         flag_values=fv)
    915 
    916   def RunWithArgs(self, serviceName):
    917     """Updates the specified subset of the service resource. Equivalent to
    918     calling `UpdateService` with only the `service_config` field updated.
    919     Operation<response: google.api.Service>
    920 
    921     Args:
    922       serviceName: The name of the service.  See the `ServiceManager` overview
    923         for naming requirements.  For example: `example.googleapis.com`.
    924 
    925     Flags:
    926       service: A Service resource to be passed as the request body.
    927       updateMask: A mask specifying which fields to update. Update mask has
    928         been deprecated on UpdateServiceConfig service method. Please use
    929         PatchServiceConfig method instead to do partial updates.
    930     """
    931     client = GetClientFromFlags()
    932     global_params = GetGlobalParamsFromFlags()
    933     request = messages.ServicemanagementServicesUpdateConfigRequest(
    934         serviceName=serviceName.decode('utf8'),
    935         )
    936     if FLAGS['service'].present:
    937       request.service = apitools_base.JsonToMessage(messages.Service, FLAGS.service)
    938     if FLAGS['updateMask'].present:
    939       request.updateMask = FLAGS.updateMask.decode('utf8')
    940     result = client.services.UpdateConfig(
    941         request, global_params=global_params)
    942     print apitools_base_cli.FormatOutput(result)
    943 
    944 
    945 class ServicesAccessPolicyQuery(apitools_base_cli.NewCmd):
    946   """Command wrapping services_accessPolicy.Query."""
    947 
    948   usage = """services_accessPolicy_query <serviceName>"""
    949 
    950   def __init__(self, name, fv):
    951     super(ServicesAccessPolicyQuery, self).__init__(name, fv)
    952     flags.DEFINE_string(
    953         'userEmail',
    954         None,
    955         u'The user to query access for.',
    956         flag_values=fv)
    957 
    958   def RunWithArgs(self, serviceName):
    959     """Method to query the accessibility of a service and any associated
    960     visibility labels for a specified user.  Members of the producer project
    961     may call this method and specify any user.  Any user may call this method,
    962     but must specify their own email address. In this case the method will
    963     return NOT_FOUND if the user has no access to the service.
    964 
    965     Args:
    966       serviceName: The service to query access for.
    967 
    968     Flags:
    969       userEmail: The user to query access for.
    970     """
    971     client = GetClientFromFlags()
    972     global_params = GetGlobalParamsFromFlags()
    973     request = messages.ServicemanagementServicesAccessPolicyQueryRequest(
    974         serviceName=serviceName.decode('utf8'),
    975         )
    976     if FLAGS['userEmail'].present:
    977       request.userEmail = FLAGS.userEmail.decode('utf8')
    978     result = client.services_accessPolicy.Query(
    979         request, global_params=global_params)
    980     print apitools_base_cli.FormatOutput(result)
    981 
    982 
    983 class ServicesConfigsCreate(apitools_base_cli.NewCmd):
    984   """Command wrapping services_configs.Create."""
    985 
    986   usage = """services_configs_create <serviceName>"""
    987 
    988   def __init__(self, name, fv):
    989     super(ServicesConfigsCreate, self).__init__(name, fv)
    990     flags.DEFINE_string(
    991         'service',
    992         None,
    993         u'A Service resource to be passed as the request body.',
    994         flag_values=fv)
    995 
    996   def RunWithArgs(self, serviceName):
    997     """Creates a new service config (version) for a managed service. This
    998     method only stores the service config, but does not apply the service
    999     config to any backend services.
   1000 
   1001     Args:
   1002       serviceName: The name of the service.  See the `ServiceManager` overview
   1003         for naming requirements.  For example: `example.googleapis.com`.
   1004 
   1005     Flags:
   1006       service: A Service resource to be passed as the request body.
   1007     """
   1008     client = GetClientFromFlags()
   1009     global_params = GetGlobalParamsFromFlags()
   1010     request = messages.ServicemanagementServicesConfigsCreateRequest(
   1011         serviceName=serviceName.decode('utf8'),
   1012         )
   1013     if FLAGS['service'].present:
   1014       request.service = apitools_base.JsonToMessage(messages.Service, FLAGS.service)
   1015     result = client.services_configs.Create(
   1016         request, global_params=global_params)
   1017     print apitools_base_cli.FormatOutput(result)
   1018 
   1019 
   1020 class ServicesConfigsGet(apitools_base_cli.NewCmd):
   1021   """Command wrapping services_configs.Get."""
   1022 
   1023   usage = """services_configs_get <serviceName> <configId>"""
   1024 
   1025   def __init__(self, name, fv):
   1026     super(ServicesConfigsGet, self).__init__(name, fv)
   1027 
   1028   def RunWithArgs(self, serviceName, configId):
   1029     """Gets a service config (version) for a managed service. If `config_id`
   1030     is not specified, the latest service config will be returned.
   1031 
   1032     Args:
   1033       serviceName: The name of the service.  See the `ServiceManager` overview
   1034         for naming requirements.  For example: `example.googleapis.com`.
   1035       configId: The id of the service config resource. Optional. If it is not
   1036         specified, the latest version of config will be returned.
   1037     """
   1038     client = GetClientFromFlags()
   1039     global_params = GetGlobalParamsFromFlags()
   1040     request = messages.ServicemanagementServicesConfigsGetRequest(
   1041         serviceName=serviceName.decode('utf8'),
   1042         configId=configId.decode('utf8'),
   1043         )
   1044     result = client.services_configs.Get(
   1045         request, global_params=global_params)
   1046     print apitools_base_cli.FormatOutput(result)
   1047 
   1048 
   1049 class ServicesConfigsList(apitools_base_cli.NewCmd):
   1050   """Command wrapping services_configs.List."""
   1051 
   1052   usage = """services_configs_list <serviceName>"""
   1053 
   1054   def __init__(self, name, fv):
   1055     super(ServicesConfigsList, self).__init__(name, fv)
   1056     flags.DEFINE_integer(
   1057         'pageSize',
   1058         None,
   1059         u'The max number of items to include in the response list.',
   1060         flag_values=fv)
   1061     flags.DEFINE_string(
   1062         'pageToken',
   1063         None,
   1064         u'The token of the page to retrieve.',
   1065         flag_values=fv)
   1066 
   1067   def RunWithArgs(self, serviceName):
   1068     """Lists the history of the service config for a managed service, from the
   1069     newest to the oldest.
   1070 
   1071     Args:
   1072       serviceName: The name of the service.  See the `ServiceManager` overview
   1073         for naming requirements.  For example: `example.googleapis.com`.
   1074 
   1075     Flags:
   1076       pageSize: The max number of items to include in the response list.
   1077       pageToken: The token of the page to retrieve.
   1078     """
   1079     client = GetClientFromFlags()
   1080     global_params = GetGlobalParamsFromFlags()
   1081     request = messages.ServicemanagementServicesConfigsListRequest(
   1082         serviceName=serviceName.decode('utf8'),
   1083         )
   1084     if FLAGS['pageSize'].present:
   1085       request.pageSize = FLAGS.pageSize
   1086     if FLAGS['pageToken'].present:
   1087       request.pageToken = FLAGS.pageToken.decode('utf8')
   1088     result = client.services_configs.List(
   1089         request, global_params=global_params)
   1090     print apitools_base_cli.FormatOutput(result)
   1091 
   1092 
   1093 class ServicesConfigsSubmit(apitools_base_cli.NewCmd):
   1094   """Command wrapping services_configs.Submit."""
   1095 
   1096   usage = """services_configs_submit <serviceName>"""
   1097 
   1098   def __init__(self, name, fv):
   1099     super(ServicesConfigsSubmit, self).__init__(name, fv)
   1100     flags.DEFINE_string(
   1101         'submitConfigSourceRequest',
   1102         None,
   1103         u'A SubmitConfigSourceRequest resource to be passed as the request '
   1104         u'body.',
   1105         flag_values=fv)
   1106 
   1107   def RunWithArgs(self, serviceName):
   1108     """Creates a new service config (version) for a managed service based on
   1109     user-supplied configuration sources files (for example: OpenAPI
   1110     Specification). This method stores the source configurations as well as
   1111     the generated service config. It does NOT apply the service config to any
   1112     backend services.  Operation<response: SubmitConfigSourceResponse>
   1113 
   1114     Args:
   1115       serviceName: The name of the service.  See the `ServiceManager` overview
   1116         for naming requirements.  For example: `example.googleapis.com`.
   1117 
   1118     Flags:
   1119       submitConfigSourceRequest: A SubmitConfigSourceRequest resource to be
   1120         passed as the request body.
   1121     """
   1122     client = GetClientFromFlags()
   1123     global_params = GetGlobalParamsFromFlags()
   1124     request = messages.ServicemanagementServicesConfigsSubmitRequest(
   1125         serviceName=serviceName.decode('utf8'),
   1126         )
   1127     if FLAGS['submitConfigSourceRequest'].present:
   1128       request.submitConfigSourceRequest = apitools_base.JsonToMessage(messages.SubmitConfigSourceRequest, FLAGS.submitConfigSourceRequest)
   1129     result = client.services_configs.Submit(
   1130         request, global_params=global_params)
   1131     print apitools_base_cli.FormatOutput(result)
   1132 
   1133 
   1134 class ServicesCustomerSettingsGet(apitools_base_cli.NewCmd):
   1135   """Command wrapping services_customerSettings.Get."""
   1136 
   1137   usage = """services_customerSettings_get <serviceName> <customerId>"""
   1138 
   1139   def __init__(self, name, fv):
   1140     super(ServicesCustomerSettingsGet, self).__init__(name, fv)
   1141     flags.DEFINE_string(
   1142         'expand',
   1143         None,
   1144         u'Fields to expand in any results.',
   1145         flag_values=fv)
   1146     flags.DEFINE_enum(
   1147         'view',
   1148         u'PROJECT_SETTINGS_VIEW_UNSPECIFIED',
   1149         [u'PROJECT_SETTINGS_VIEW_UNSPECIFIED', u'CONSUMER_VIEW', u'PRODUCER_VIEW', u'ALL'],
   1150         u'Request only fields for the specified view.',
   1151         flag_values=fv)
   1152 
   1153   def RunWithArgs(self, serviceName, customerId):
   1154     """Retrieves the settings that control the specified customer's usage of
   1155     the service.
   1156 
   1157     Args:
   1158       serviceName: The name of the service.  See the `ServiceManager` overview
   1159         for naming requirements.  For example: `example.googleapis.com`. This
   1160         field is required.
   1161       customerId: ID for the customer. See the comment for
   1162         `CustomerSettings.customer_id` field of message for its format. This
   1163         field is required.
   1164 
   1165     Flags:
   1166       expand: Fields to expand in any results.
   1167       view: Request only fields for the specified view.
   1168     """
   1169     client = GetClientFromFlags()
   1170     global_params = GetGlobalParamsFromFlags()
   1171     request = messages.ServicemanagementServicesCustomerSettingsGetRequest(
   1172         serviceName=serviceName.decode('utf8'),
   1173         customerId=customerId.decode('utf8'),
   1174         )
   1175     if FLAGS['expand'].present:
   1176       request.expand = FLAGS.expand.decode('utf8')
   1177     if FLAGS['view'].present:
   1178       request.view = messages.ServicemanagementServicesCustomerSettingsGetRequest.ViewValueValuesEnum(FLAGS.view)
   1179     result = client.services_customerSettings.Get(
   1180         request, global_params=global_params)
   1181     print apitools_base_cli.FormatOutput(result)
   1182 
   1183 
   1184 class ServicesCustomerSettingsPatch(apitools_base_cli.NewCmd):
   1185   """Command wrapping services_customerSettings.Patch."""
   1186 
   1187   usage = """services_customerSettings_patch <serviceName> <customerId>"""
   1188 
   1189   def __init__(self, name, fv):
   1190     super(ServicesCustomerSettingsPatch, self).__init__(name, fv)
   1191     flags.DEFINE_string(
   1192         'customerSettings',
   1193         None,
   1194         u'A CustomerSettings resource to be passed as the request body.',
   1195         flag_values=fv)
   1196     flags.DEFINE_string(
   1197         'updateMask',
   1198         None,
   1199         u'The field mask specifying which fields are to be updated.',
   1200         flag_values=fv)
   1201 
   1202   def RunWithArgs(self, serviceName, customerId):
   1203     """Updates specified subset of the settings that control the specified
   1204     customer's usage of the service.  Attempts to update a field not
   1205     controlled by the caller will result in an access denied error.
   1206     Operation<response: CustomerSettings>
   1207 
   1208     Args:
   1209       serviceName: The name of the service.  See the `ServiceManager` overview
   1210         for naming requirements.  For example: `example.googleapis.com`. This
   1211         field is required.
   1212       customerId: ID for the customer. See the comment for
   1213         `CustomerSettings.customer_id` field of message for its format. This
   1214         field is required.
   1215 
   1216     Flags:
   1217       customerSettings: A CustomerSettings resource to be passed as the
   1218         request body.
   1219       updateMask: The field mask specifying which fields are to be updated.
   1220     """
   1221     client = GetClientFromFlags()
   1222     global_params = GetGlobalParamsFromFlags()
   1223     request = messages.ServicemanagementServicesCustomerSettingsPatchRequest(
   1224         serviceName=serviceName.decode('utf8'),
   1225         customerId=customerId.decode('utf8'),
   1226         )
   1227     if FLAGS['customerSettings'].present:
   1228       request.customerSettings = apitools_base.JsonToMessage(messages.CustomerSettings, FLAGS.customerSettings)
   1229     if FLAGS['updateMask'].present:
   1230       request.updateMask = FLAGS.updateMask.decode('utf8')
   1231     result = client.services_customerSettings.Patch(
   1232         request, global_params=global_params)
   1233     print apitools_base_cli.FormatOutput(result)
   1234 
   1235 
   1236 class ServicesProjectSettingsGet(apitools_base_cli.NewCmd):
   1237   """Command wrapping services_projectSettings.Get."""
   1238 
   1239   usage = """services_projectSettings_get <serviceName> <consumerProjectId>"""
   1240 
   1241   def __init__(self, name, fv):
   1242     super(ServicesProjectSettingsGet, self).__init__(name, fv)
   1243     flags.DEFINE_string(
   1244         'expand',
   1245         None,
   1246         u'Fields to expand in any results.  By default, the following fields '
   1247         u'are not present in the result: - `operations` - `quota_usage`',
   1248         flag_values=fv)
   1249     flags.DEFINE_enum(
   1250         'view',
   1251         u'PROJECT_SETTINGS_VIEW_UNSPECIFIED',
   1252         [u'PROJECT_SETTINGS_VIEW_UNSPECIFIED', u'CONSUMER_VIEW', u'PRODUCER_VIEW', u'ALL'],
   1253         u'Request only the fields for the specified view.',
   1254         flag_values=fv)
   1255 
   1256   def RunWithArgs(self, serviceName, consumerProjectId):
   1257     """Retrieves the settings that control the specified consumer project's
   1258     usage of the service.
   1259 
   1260     Args:
   1261       serviceName: The name of the service.  See the `ServiceManager` overview
   1262         for naming requirements.  For example: `example.googleapis.com`.
   1263       consumerProjectId: The project ID of the consumer.
   1264 
   1265     Flags:
   1266       expand: Fields to expand in any results.  By default, the following
   1267         fields are not present in the result: - `operations` - `quota_usage`
   1268       view: Request only the fields for the specified view.
   1269     """
   1270     client = GetClientFromFlags()
   1271     global_params = GetGlobalParamsFromFlags()
   1272     request = messages.ServicemanagementServicesProjectSettingsGetRequest(
   1273         serviceName=serviceName.decode('utf8'),
   1274         consumerProjectId=consumerProjectId.decode('utf8'),
   1275         )
   1276     if FLAGS['expand'].present:
   1277       request.expand = FLAGS.expand.decode('utf8')
   1278     if FLAGS['view'].present:
   1279       request.view = messages.ServicemanagementServicesProjectSettingsGetRequest.ViewValueValuesEnum(FLAGS.view)
   1280     result = client.services_projectSettings.Get(
   1281         request, global_params=global_params)
   1282     print apitools_base_cli.FormatOutput(result)
   1283 
   1284 
   1285 class ServicesProjectSettingsPatch(apitools_base_cli.NewCmd):
   1286   """Command wrapping services_projectSettings.Patch."""
   1287 
   1288   usage = """services_projectSettings_patch <serviceName> <consumerProjectId>"""
   1289 
   1290   def __init__(self, name, fv):
   1291     super(ServicesProjectSettingsPatch, self).__init__(name, fv)
   1292     flags.DEFINE_string(
   1293         'projectSettings',
   1294         None,
   1295         u'A ProjectSettings resource to be passed as the request body.',
   1296         flag_values=fv)
   1297     flags.DEFINE_string(
   1298         'updateMask',
   1299         None,
   1300         u'The field mask specifying which fields are to be updated.',
   1301         flag_values=fv)
   1302 
   1303   def RunWithArgs(self, serviceName, consumerProjectId):
   1304     """Updates specified subset of the settings that control the specified
   1305     consumer project's usage of the service.  Attempts to update a field not
   1306     controlled by the caller will result in an access denied error.
   1307     Operation<response: ProjectSettings>
   1308 
   1309     Args:
   1310       serviceName: The name of the service.  See the `ServiceManager` overview
   1311         for naming requirements.  For example: `example.googleapis.com`.
   1312       consumerProjectId: The project ID of the consumer.
   1313 
   1314     Flags:
   1315       projectSettings: A ProjectSettings resource to be passed as the request
   1316         body.
   1317       updateMask: The field mask specifying which fields are to be updated.
   1318     """
   1319     client = GetClientFromFlags()
   1320     global_params = GetGlobalParamsFromFlags()
   1321     request = messages.ServicemanagementServicesProjectSettingsPatchRequest(
   1322         serviceName=serviceName.decode('utf8'),
   1323         consumerProjectId=consumerProjectId.decode('utf8'),
   1324         )
   1325     if FLAGS['projectSettings'].present:
   1326       request.projectSettings = apitools_base.JsonToMessage(messages.ProjectSettings, FLAGS.projectSettings)
   1327     if FLAGS['updateMask'].present:
   1328       request.updateMask = FLAGS.updateMask.decode('utf8')
   1329     result = client.services_projectSettings.Patch(
   1330         request, global_params=global_params)
   1331     print apitools_base_cli.FormatOutput(result)
   1332 
   1333 
   1334 class ServicesProjectSettingsUpdate(apitools_base_cli.NewCmd):
   1335   """Command wrapping services_projectSettings.Update."""
   1336 
   1337   usage = """services_projectSettings_update <serviceName> <consumerProjectId>"""
   1338 
   1339   def __init__(self, name, fv):
   1340     super(ServicesProjectSettingsUpdate, self).__init__(name, fv)
   1341     flags.DEFINE_string(
   1342         'operations',
   1343         None,
   1344         u'Read-only view of pending operations affecting this resource, if '
   1345         u'requested.',
   1346         flag_values=fv)
   1347     flags.DEFINE_string(
   1348         'properties',
   1349         None,
   1350         u'Service-defined per-consumer properties.  A key-value mapping a '
   1351         u'string key to a google.protobuf.ListValue proto. Values in the list'
   1352         u" are typed as defined in the Service configuration's "
   1353         u'consumer.properties field.',
   1354         flag_values=fv)
   1355     flags.DEFINE_string(
   1356         'quotaSettings',
   1357         None,
   1358         u'Settings that control how much or how fast the service can be used '
   1359         u'by the consumer project.',
   1360         flag_values=fv)
   1361     flags.DEFINE_string(
   1362         'usageSettings',
   1363         None,
   1364         u'Settings that control whether this service is usable by the '
   1365         u'consumer project.',
   1366         flag_values=fv)
   1367     flags.DEFINE_string(
   1368         'visibilitySettings',
   1369         None,
   1370         u'Settings that control which features of the service are visible to '
   1371         u'the consumer project.',
   1372         flag_values=fv)
   1373 
   1374   def RunWithArgs(self, serviceName, consumerProjectId):
   1375     """NOTE: Currently unsupported.  Use PatchProjectSettings instead.
   1376     Updates the settings that control the specified consumer project's usage
   1377     of the service.  Attempts to update a field not controlled by the caller
   1378     will result in an access denied error.  Operation<response:
   1379     ProjectSettings>
   1380 
   1381     Args:
   1382       serviceName: The name of the service.  See the `ServiceManager` overview
   1383         for naming requirements.
   1384       consumerProjectId: ID for the project consuming this service.
   1385 
   1386     Flags:
   1387       operations: Read-only view of pending operations affecting this
   1388         resource, if requested.
   1389       properties: Service-defined per-consumer properties.  A key-value
   1390         mapping a string key to a google.protobuf.ListValue proto. Values in
   1391         the list are typed as defined in the Service configuration's
   1392         consumer.properties field.
   1393       quotaSettings: Settings that control how much or how fast the service
   1394         can be used by the consumer project.
   1395       usageSettings: Settings that control whether this service is usable by
   1396         the consumer project.
   1397       visibilitySettings: Settings that control which features of the service
   1398         are visible to the consumer project.
   1399     """
   1400     client = GetClientFromFlags()
   1401     global_params = GetGlobalParamsFromFlags()
   1402     request = messages.ProjectSettings(
   1403         serviceName=serviceName.decode('utf8'),
   1404         consumerProjectId=consumerProjectId.decode('utf8'),
   1405         )
   1406     if FLAGS['operations'].present:
   1407       request.operations = [apitools_base.JsonToMessage(messages.Operation, x) for x in FLAGS.operations]
   1408     if FLAGS['properties'].present:
   1409       request.properties = apitools_base.JsonToMessage(messages.ProjectSettings.PropertiesValue, FLAGS.properties)
   1410     if FLAGS['quotaSettings'].present:
   1411       request.quotaSettings = apitools_base.JsonToMessage(messages.QuotaSettings, FLAGS.quotaSettings)
   1412     if FLAGS['usageSettings'].present:
   1413       request.usageSettings = apitools_base.JsonToMessage(messages.UsageSettings, FLAGS.usageSettings)
   1414     if FLAGS['visibilitySettings'].present:
   1415       request.visibilitySettings = apitools_base.JsonToMessage(messages.VisibilitySettings, FLAGS.visibilitySettings)
   1416     result = client.services_projectSettings.Update(
   1417         request, global_params=global_params)
   1418     print apitools_base_cli.FormatOutput(result)
   1419 
   1420 
   1421 class ConvertConfig(apitools_base_cli.NewCmd):
   1422   """Command wrapping v1.ConvertConfig."""
   1423 
   1424   usage = """convertConfig"""
   1425 
   1426   def __init__(self, name, fv):
   1427     super(ConvertConfig, self).__init__(name, fv)
   1428     flags.DEFINE_string(
   1429         'configSpec',
   1430         None,
   1431         u'Input configuration For this version of API, the supported type is '
   1432         u'OpenApiSpec',
   1433         flag_values=fv)
   1434     flags.DEFINE_string(
   1435         'openApiSpec',
   1436         None,
   1437         u'The OpenAPI specification for an API.',
   1438         flag_values=fv)
   1439     flags.DEFINE_string(
   1440         'serviceName',
   1441         None,
   1442         u'The service name to use for constructing the normalized service '
   1443         u'configuration equivalent of the provided configuration '
   1444         u'specification.',
   1445         flag_values=fv)
   1446     flags.DEFINE_string(
   1447         'swaggerSpec',
   1448         None,
   1449         u'The swagger specification for an API.',
   1450         flag_values=fv)
   1451 
   1452   def RunWithArgs(self):
   1453     """DEPRECATED. `SubmitConfigSource` with `validate_only=true` will provide
   1454     config conversion moving forward.  Converts an API specification (e.g.
   1455     Swagger spec) to an equivalent `google.api.Service`.
   1456 
   1457     Flags:
   1458       configSpec: Input configuration For this version of API, the supported
   1459         type is OpenApiSpec
   1460       openApiSpec: The OpenAPI specification for an API.
   1461       serviceName: The service name to use for constructing the normalized
   1462         service configuration equivalent of the provided configuration
   1463         specification.
   1464       swaggerSpec: The swagger specification for an API.
   1465     """
   1466     client = GetClientFromFlags()
   1467     global_params = GetGlobalParamsFromFlags()
   1468     request = messages.ConvertConfigRequest(
   1469         )
   1470     if FLAGS['configSpec'].present:
   1471       request.configSpec = apitools_base.JsonToMessage(messages.ConvertConfigRequest.ConfigSpecValue, FLAGS.configSpec)
   1472     if FLAGS['openApiSpec'].present:
   1473       request.openApiSpec = apitools_base.JsonToMessage(messages.OpenApiSpec, FLAGS.openApiSpec)
   1474     if FLAGS['serviceName'].present:
   1475       request.serviceName = FLAGS.serviceName.decode('utf8')
   1476     if FLAGS['swaggerSpec'].present:
   1477       request.swaggerSpec = apitools_base.JsonToMessage(messages.SwaggerSpec, FLAGS.swaggerSpec)
   1478     result = client.v1.ConvertConfig(
   1479         request, global_params=global_params)
   1480     print apitools_base_cli.FormatOutput(result)
   1481 
   1482 
   1483 def main(_):
   1484   appcommands.AddCmd('pyshell', PyShell)
   1485   appcommands.AddCmd('operations_get', OperationsGet)
   1486   appcommands.AddCmd('services_convertConfig', ServicesConvertConfig)
   1487   appcommands.AddCmd('services_create', ServicesCreate)
   1488   appcommands.AddCmd('services_delete', ServicesDelete)
   1489   appcommands.AddCmd('services_disable', ServicesDisable)
   1490   appcommands.AddCmd('services_enable', ServicesEnable)
   1491   appcommands.AddCmd('services_get', ServicesGet)
   1492   appcommands.AddCmd('services_getAccessPolicy', ServicesGetAccessPolicy)
   1493   appcommands.AddCmd('services_getConfig', ServicesGetConfig)
   1494   appcommands.AddCmd('services_list', ServicesList)
   1495   appcommands.AddCmd('services_patch', ServicesPatch)
   1496   appcommands.AddCmd('services_patchConfig', ServicesPatchConfig)
   1497   appcommands.AddCmd('services_update', ServicesUpdate)
   1498   appcommands.AddCmd('services_updateAccessPolicy', ServicesUpdateAccessPolicy)
   1499   appcommands.AddCmd('services_updateConfig', ServicesUpdateConfig)
   1500   appcommands.AddCmd('services_accessPolicy_query', ServicesAccessPolicyQuery)
   1501   appcommands.AddCmd('services_configs_create', ServicesConfigsCreate)
   1502   appcommands.AddCmd('services_configs_get', ServicesConfigsGet)
   1503   appcommands.AddCmd('services_configs_list', ServicesConfigsList)
   1504   appcommands.AddCmd('services_configs_submit', ServicesConfigsSubmit)
   1505   appcommands.AddCmd('services_customerSettings_get', ServicesCustomerSettingsGet)
   1506   appcommands.AddCmd('services_customerSettings_patch', ServicesCustomerSettingsPatch)
   1507   appcommands.AddCmd('services_projectSettings_get', ServicesProjectSettingsGet)
   1508   appcommands.AddCmd('services_projectSettings_patch', ServicesProjectSettingsPatch)
   1509   appcommands.AddCmd('services_projectSettings_update', ServicesProjectSettingsUpdate)
   1510   appcommands.AddCmd('convertConfig', ConvertConfig)
   1511 
   1512   apitools_base_cli.SetupLogger()
   1513   if hasattr(appcommands, 'SetDefaultCommand'):
   1514     appcommands.SetDefaultCommand('pyshell')
   1515 
   1516 
   1517 run_main = apitools_base_cli.run_main
   1518 
   1519 if __name__ == '__main__':
   1520   appcommands.Run()
   1521