Exemple #1
0
    def Filter(self, context, args):
        client = autoscaler_v1beta2.AutoscalerV1beta2(get_credentials=False,
                                                      http=self.Http())
        context['autoscaler_messages_module'] = messages_v2

        context['autoscaler-client'] = client
        resources.SetParamDefault(api='compute',
                                  collection=None,
                                  param='project',
                                  resolver=resolvers.FromProperty(
                                      properties.VALUES.core.project))
        resources.SetParamDefault(api='autoscaler',
                                  collection=None,
                                  param='project',
                                  resolver=resolvers.FromProperty(
                                      properties.VALUES.core.project))
        resources.SetParamDefault(api='autoscaler',
                                  collection=None,
                                  param='zone',
                                  resolver=resolvers.FromProperty(
                                      properties.VALUES.compute.zone))
        resources.SetParamDefault(api='replicapool',
                                  collection=None,
                                  param='project',
                                  resolver=resolvers.FromProperty(
                                      properties.VALUES.core.project))
        resources.SetParamDefault(api='replicapool',
                                  collection=None,
                                  param='zone',
                                  resolver=resolvers.FromProperty(
                                      properties.VALUES.compute.zone))

        context['autoscaler_resources'] = resources
        return context
    def Filter(self, context, args):
        client = core_apis.GetClientInstance('autoscaler', 'v1beta2')
        context['autoscaler-client'] = client

        messages_v2 = core_apis.GetMessagesModule('autoscaler', 'v1beta2')
        context['autoscaler_messages_module'] = messages_v2

        resources.SetParamDefault(api='compute',
                                  collection=None,
                                  param='project',
                                  resolver=resolvers.FromProperty(
                                      properties.VALUES.core.project))
        resources.SetParamDefault(api='autoscaler',
                                  collection=None,
                                  param='project',
                                  resolver=resolvers.FromProperty(
                                      properties.VALUES.core.project))
        resources.SetParamDefault(api='autoscaler',
                                  collection=None,
                                  param='zone',
                                  resolver=resolvers.FromProperty(
                                      properties.VALUES.compute.zone))
        resources.SetParamDefault(api='replicapool',
                                  collection=None,
                                  param='project',
                                  resolver=resolvers.FromProperty(
                                      properties.VALUES.core.project))
        resources.SetParamDefault(api='replicapool',
                                  collection=None,
                                  param='zone',
                                  resolver=resolvers.FromProperty(
                                      properties.VALUES.compute.zone))

        context['autoscaler_resources'] = resources
        return context
Exemple #3
0
  def Filter(self, context, args):
    """Context() is a filter function that can update the context.

    Args:
      context: The current context.
      args: The argparse namespace that was specified on the CLI or API.

    Returns:
      The updated context.
    """
    properties.VALUES.compute.zone.Get(required=True)
    context['updater_api'] = core_apis.GetClientInstance(
        'replicapoolupdater', 'v1beta1')
    context['updater_messages'] = core_apis.GetMessagesModule(
        'replicapoolupdater', 'v1beta1')
    resources.SetParamDefault(
        api='compute', collection=None, param='project',
        resolver=resolvers.FromProperty(properties.VALUES.core.project))
    resources.SetParamDefault(
        api='compute', collection=None, param='zone',
        resolver=resolvers.FromProperty(properties.VALUES.compute.zone))
    resources.SetParamDefault(
        api='replicapoolupdater', collection=None, param='project',
        resolver=resolvers.FromProperty(properties.VALUES.core.project))
    resources.SetParamDefault(
        api='replicapoolupdater', collection=None, param='zone',
        resolver=resolvers.FromProperty(properties.VALUES.compute.zone))
    context['updater_resources'] = resources
    return context
Exemple #4
0
    def Filter(self, context, args):
        """Modify the context that will be given to this group's commands when run.

    Args:
      context: {str:object}, The current context, which is a set of key-value
          pairs that can be used for common initialization among commands.
      args: argparse.Namespace: The same Namespace given to the corresponding
          .Run() invocation.

    Returns:
      The refined command context.
    """
        http = self.Http()
        testing_url = properties.VALUES.api_endpoint_overrides.testing.Get()
        toolresults_url = properties.VALUES.api_endpoint_overrides.toolresults.Get(
        )
        log.info('Test Service endpoint: [{0}]'.format(testing_url))
        log.info('Tool Results endpoint: [{0}]'.format(toolresults_url))

        # Create the Testing service client
        resources.SetParamDefault(api='test',
                                  collection=None,
                                  param='project',
                                  resolver=resolvers.FromProperty(
                                      properties.VALUES.core.project))
        # TODO(user) Support multiple versions when they exist
        testing_client_v1 = testing_v1.TestingV1(get_credentials=False,
                                                 url=testing_url,
                                                 http=http)
        testing_registry = resources.REGISTRY.CloneAndSwitchAPIs(
            testing_client_v1)
        context['testing_client'] = testing_client_v1
        context['testing_messages'] = testing_v1
        context['testing_registry'] = testing_registry

        # Create the Tool Results service client.
        resources.SetParamDefault(api='toolresults',
                                  collection=None,
                                  param='project',
                                  resolver=resolvers.FromProperty(
                                      properties.VALUES.core.project))
        toolresults_client_v1 = toolresults_v1beta3.ToolresultsV1beta3(
            get_credentials=False, url=toolresults_url, http=http)
        tr_registry = resources.REGISTRY.CloneAndSwitchAPIs(
            toolresults_client_v1)
        context['toolresults_client'] = toolresults_client_v1
        context['toolresults_messages'] = toolresults_v1beta3
        context['toolresults_registry'] = tr_registry

        # Get the android catalog and store in the context
        context['android_catalog'] = util.GetAndroidCatalog(context)

        # TODO(user): remove this message for general release.
        log.status.Print(
            '\nHave questions, feedback, or issues? Please let us know by using '
            'this Google Group:\n  https://groups.google.com/forum/#!forum'
            '/google-cloud-test-lab-external\n')

        return context
Exemple #5
0
  def Filter(self, context, args):
    """Setup the API client within the context for this group's commands.

    Args:
      context: {str:object}, A set of key-value pairs that can be used for
          common initialization among commands.
      args: argparse.Namespace: The same namespace given to the corresponding
          .Run() invocation.

    Returns:
      The updated context.
    """

    project = properties.VALUES.core.project
    resolver = resolvers.FromProperty(project)
    resources.SetParamDefault('genomics', None, 'project', resolver)

    genomics_client = genomics_v1_client.GenomicsV1(
        url=properties.VALUES.api_endpoint_overrides.genomics.Get(),
        get_credentials=False,
        http=self.Http())

    context[lib.GENOMICS_APITOOLS_CLIENT_KEY] = genomics_client
    context[lib.GENOMICS_MESSAGES_MODULE_KEY] = genomics_v1_messages
    context[lib.GENOMICS_RESOURCES_KEY] = resources

    return context
  def Filter(self, context, args):
    """Modify the context that will be given to this group's commands when run.

    Args:
      context: The current context.
      args: The argparse namespace given to the corresponding .Run() invocation.

    Returns:
      The updated context.
    """
    # All logging collections use projectId, so we can set a default value.
    resources.SetParamDefault(
        api='logging', collection=None, param='projectsId',
        resolver=resolvers.FromProperty(properties.VALUES.core.project))

    context['logging_client_v1beta3'] = apis.GetClientInstance(
        'logging', 'v1beta3')
    context['logging_messages_v1beta3'] = apis.GetMessagesModule(
        'logging', 'v1beta3')

    context['logging_client_v2beta1'] = apis.GetClientInstance(
        'logging', 'v2beta1')
    context['logging_messages_v2beta1'] = apis.GetMessagesModule(
        'logging', 'v2beta1')

    context['logging_resources'] = resources
    return context
def _DoFilter(context, api_version, http):
    """Set up and return the context to be used by all SQL release tracks."""
    cloud_resources.SetParamDefault(api='sql',
                                    collection=None,
                                    param='project',
                                    resolver=resolvers.FromProperty(
                                        properties.VALUES.core.project))

    url = '/'.join([properties.VALUES.core.api_host.Get(), 'sql'])

    context['sql_client-v1beta3'] = sql_v1beta3.SqladminV1beta3(
        get_credentials=False, url='/'.join([url, 'v1beta3']), http=http)
    context['sql_messages-v1beta3'] = sql_v1beta3
    context['registry-v1beta3'] = cloud_resources.REGISTRY.CloneAndSwitchAPIs(
        context['sql_client-v1beta3'])

    context['sql_client-v1beta4'] = sql_v1beta4.SqladminV1beta4(
        get_credentials=False, url='/'.join([url, 'v1beta4']), http=http)
    context['sql_messages-v1beta4'] = sql_v1beta4
    context['registry-v1beta4'] = cloud_resources.REGISTRY.CloneAndSwitchAPIs(
        context['sql_client-v1beta4'])

    context['sql_client'] = context['sql_client-' + api_version]
    context['sql_messages'] = context['sql_messages-' + api_version]
    context['registry'] = context['registry-' + api_version]

    return context
Exemple #8
0
    def Filter(self, context, args):
        http = cli.Http()
        core_values = properties.VALUES.core
        compute_values = properties.VALUES.compute
        context['http'] = http
        context['project'] = core_values.project.Get(required=True)

        for api, param, prop in (('compute', 'project', core_values.project),
                                 ('resourceviews', 'projectName',
                                  core_values.project), ('compute', 'zone',
                                                         compute_values.zone),
                                 ('resourceviews', 'zone',
                                  compute_values.zone),
                                 ('compute', 'region', compute_values.region),
                                 ('resourceviews', 'region',
                                  compute_values.region)):
            resources.SetParamDefault(api=api,
                                      collection=None,
                                      param=param,
                                      resolver=resolvers.FromProperty(prop))

        api_host = properties.VALUES.core.api_host.Get()
        v1_version_component = 'compute/v1/'

        compute_url = urlparse.urljoin(api_host, v1_version_component)
        context['batch-url'] = urlparse.urljoin(api_host, 'batch')

        v1_compute = compute_v1_client.ComputeV1(url=compute_url,
                                                 get_credentials=False,
                                                 http=http)
        context['compute'] = v1_compute
        context['resources'] = resources.REGISTRY.CloneAndSwitchAPIs(
            v1_compute)
Exemple #9
0
  def Filter(self, context, args):
    """Context() is a filter function that can update the context.

    Args:
      context: The current context.
      args: The argparse namespace that was specified on the CLI or API.

    Returns:
      The updated context.
    """

    cloud_resources.SetParamDefault(
        api='sql', collection=None, param='project',
        resolver=resolvers.FromProperty(properties.VALUES.core.project))
    credentials = cli.Credentials()

    context['sql_client-v1beta3'] = sql_v1beta3.SqladminV1beta3(
        credentials=credentials)
    context['sql_messages-v1beta3'] = sql_v1beta3
    context['registry-v1beta3'] = cloud_resources.REGISTRY

    context['sql_client-v1beta1'] = sql_v1beta1.SqladminV1beta1(
        credentials=credentials)
    context['sql_messages-v1beta1'] = sql_v1beta1
    context['registry-v1beta1'] = cloud_resources.REGISTRY.CloneAndSwitchAPIs(
        context['sql_client-v1beta1'])

    return context
    def Filter(self, context, args):
        """Context() is a filter function that can update the context.

    Args:
      context: The current context.
      args: The argparse namespace that was specified on the CLI or API.

    Returns:
      The updated context.
    Raises:
      ToolException: When no project is specified.
    """

        client = apis.GetClientInstance('serviceregistry', 'v1alpha')
        context[constants.CLIENT] = client
        context[constants.MESSAGES] = apis.GetMessagesModule(
            'serviceregistry', 'v1alpha')

        project = properties.VALUES.core.project
        resolver = resolvers.FromProperty(project)
        resources.SetParamDefault('serviceregistry', None, 'project', resolver)
        # guarantee we use the same API as our client
        context[constants.RESOURCES] = resources.REGISTRY.CloneAndSwitchAPIs(
            client)

        return context
Exemple #11
0
    def Filter(self, context, args):
        """Modify the context that will be given to this group's commands when run.

    Args:
      context: The current context.
      args: The argparse namespace given to the corresponding .Run() invocation.

    Returns:
      The updated context.
    """
        url = properties.VALUES.api_endpoint_overrides.logging.Get()

        # All logging collections use projectId, so we can set a default value.
        resources.SetParamDefault(api='logging',
                                  collection=None,
                                  param='projectsId',
                                  resolver=resolvers.FromProperty(
                                      properties.VALUES.core.project))

        client_v1beta3 = v1beta3.LoggingV1beta3(url=url,
                                                http=self.Http(),
                                                get_credentials=False)

        context['logging_client'] = client_v1beta3
        context['logging_messages'] = v1beta3
        context['logging_resources'] = resources
        return context
  def Filter(self, context, args):
    """Initialize context for bigquery commands.

    Args:
      context: The current context.
      args: The argparse namespace that was specified on the CLI or API.

    Returns:
      The updated context.
    """
    resources.SetParamDefault(
        api='bigquery', collection=None, param='projectId',
        resolver=resolvers.FromProperty(properties.VALUES.core.project))

    # TODO(user): remove command dependence on these.
    context[BIGQUERY_MESSAGES_MODULE_KEY] = apis.GetMessagesModule(
        'bigquery', 'v2')
    context[APITOOLS_CLIENT_KEY] = apis.GetClientInstance(
        'bigquery', 'v2', http=self.Http())
    context[BIGQUERY_REGISTRY_KEY] = resources.REGISTRY

    # Inject bigquery backend params.
    bigquery.Bigquery.SetResourceParser(resources.REGISTRY)
    bigquery.Bigquery.SetApiEndpoint(
        self.Http(), properties.VALUES.api_endpoint_overrides.bigquery.Get())
Exemple #13
0
def _DoFilter(context, http, api_version_default, api_version_arg):
    """Set up and return the context to be used by all SQL release tracks."""

    api_version = api_version_default
    if properties.VALUES.api_client_overrides.sql.Get():
        api_version = properties.VALUES.api_client_overrides.sql.Get()
    if api_version_arg:
        api_version = api_version_arg

    cloud_resources.SetParamDefault(api='sql',
                                    collection=None,
                                    param='project',
                                    resolver=resolvers.FromProperty(
                                        properties.VALUES.core.project))

    url = properties.VALUES.api_endpoint_overrides.sql.Get()

    context['sql_client-v1beta3'] = sql_v1beta3.SqladminV1beta3(
        get_credentials=False, url=url, http=http)
    context['sql_messages-v1beta3'] = sql_v1beta3
    context['registry-v1beta3'] = cloud_resources.REGISTRY.CloneAndSwitchAPIs(
        context['sql_client-v1beta3'])

    context['sql_client-v1beta4'] = sql_v1beta4.SqladminV1beta4(
        get_credentials=False, url=url, http=http)
    context['sql_messages-v1beta4'] = sql_v1beta4
    context['registry-v1beta4'] = cloud_resources.REGISTRY.CloneAndSwitchAPIs(
        context['sql_client-v1beta4'])

    context['sql_client'] = context['sql_client-' + api_version]
    context['sql_messages'] = context['sql_messages-' + api_version]
    context['registry'] = context['registry-' + api_version]

    return context
Exemple #14
0
  def Filter(self, context, args):
    """Setup the API client within the context for this group's commands.

    Args:
      context: {str:object}, A set of key-value pairs that can be used for
          common initialization among commands.
      args: argparse.Namespace: The same namespace given to the corresponding
          .Run() invocation.
    """
    cloud_resources.SetParamDefault(
        api='dataflow', collection=None, param='projectId',
        resolver=resolvers.FromProperty(properties.VALUES.core.project))

    context[DATAFLOW_MESSAGES_MODULE_KEY] = dataflow_v1b3_messages

    context[DATAFLOW_APITOOLS_CLIENT_KEY] = (
        dataflow_v1b3_client.DataflowV1b3(
            url=properties.VALUES.api_endpoint_overrides.dataflow.Get(),
            get_credentials=False,
            http=self.Http()))
    context[DATAFLOW_REGISTRY_KEY] = cloud_resources.REGISTRY

    if args.endpoint:
      log.warn('The --endpoint flag is deprecated and will be removed.  '
               'Set the api_endpoint_overrides/dataflow property instead.  '
               'e.g. gcloud config set api_endpoint_overrides/dataflow '
               'https://www.googleapis.com/dataflow/v1b3')
Exemple #15
0
  def Filter(self, context, args):
    log.warn('This preview command will be removed soon.')
    log.warn('These managed infrastructure preview commands have been migrated '
             'to "gcloud compute instance-groups managed" command group.')
    log.warn('See https://cloud.google.com/sdk/gcloud/reference/ for more '
             'details.')

    client = autoscaler_v1beta2.AutoscalerV1beta2(
        get_credentials=False, http=self.Http())
    context['autoscaler_messages_module'] = messages_v2


    context['autoscaler-client'] = client
    resources.SetParamDefault(
        api='compute',
        collection=None,
        param='project',
        resolver=resolvers.FromProperty(properties.VALUES.core.project))
    resources.SetParamDefault(
        api='autoscaler',
        collection=None,
        param='project',
        resolver=resolvers.FromProperty(properties.VALUES.core.project))
    resources.SetParamDefault(
        api='autoscaler',
        collection=None,
        param='zone',
        resolver=resolvers.FromProperty(properties.VALUES.compute.zone))
    resources.SetParamDefault(
        api='replicapool',
        collection=None,
        param='project',
        resolver=resolvers.FromProperty(properties.VALUES.core.project))
    resources.SetParamDefault(
        api='replicapool',
        collection=None,
        param='zone',
        resolver=resolvers.FromProperty(properties.VALUES.compute.zone))

    context['autoscaler_resources'] = resources
    return context
def _DoFilter(context, api_version_default):
  """Set up and return the context to be used by all SQL release tracks."""
  cloud_resources.SetParamDefault(
      api='sql', collection=None, param='project',
      resolver=resolvers.FromProperty(properties.VALUES.core.project))

  context['sql_client'] = apis.GetClientInstance('sql', api_version_default)
  context['sql_messages'] = apis.GetMessagesModule('sql', api_version_default)
  context['registry'] = cloud_resources.REGISTRY.CloneAndSwitchAPIs(
      context['sql_client'])

  return context
Exemple #17
0
    def Filter(self, context, args):
        """Context() is a filter function that can update the context.

    Args:
      context: The current context.
      args: The argparse namespace that was specified on the CLI or API.

    Returns:
      The updated context.
    """
        if args.zone is None:
            raise exceptions.ToolException('argument --zone is required')

        context['updater_api'] = updater_v1beta1.ReplicapoolupdaterV1beta1(
            get_credentials=False, http=cli.Http())
        context['updater_messages'] = replicapoolupdater_v1beta1_messages
        resources.SetParamDefault(api='compute',
                                  collection='instanceTemplates',
                                  param='project',
                                  resolver=resolvers.FromProperty(
                                      properties.VALUES.core.project))
        resources.SetParamDefault(api='replicapool',
                                  collection=None,
                                  param='project',
                                  resolver=resolvers.FromProperty(
                                      properties.VALUES.core.project))
        resources.SetParamDefault(api='replicapool',
                                  collection=None,
                                  param='zone',
                                  resolver=resolvers.FromProperty(
                                      properties.VALUES.compute.zone))
        resources.SetParamDefault(api='resourceviews',
                                  collection=None,
                                  param='projectName',
                                  resolver=resolvers.FromProperty(
                                      properties.VALUES.core.project))
        resources.SetParamDefault(api='resourceviews',
                                  collection=None,
                                  param='zone',
                                  resolver=resolvers.FromProperty(
                                      properties.VALUES.compute.zone))
        resources.SetParamDefault(api='replicapoolupdater',
                                  collection=None,
                                  param='project',
                                  resolver=resolvers.FromProperty(
                                      properties.VALUES.core.project))
        resources.SetParamDefault(api='replicapoolupdater',
                                  collection=None,
                                  param='zone',
                                  resolver=resolvers.FromProperty(
                                      properties.VALUES.compute.zone))
        context['updater_resources'] = resources
        return context
Exemple #18
0
    def Filter(self, context, args):
        context['http'] = self.Http()
        context['dataproc_messages'] = apis.GetMessagesModule('dataproc', 'v1')
        context['resources'] = resources

        # TODO(user): Move outside of context in a place that will be easier to
        # convert into a property when there are multiple regions.
        context['dataproc_region'] = self.REGION

        context['dataproc_client'] = apis.GetClientInstance('dataproc', 'v1')

        resources.SetParamDefault(api='dataproc',
                                  collection=None,
                                  param='projectId',
                                  resolver=resolvers.FromProperty(
                                      properties.VALUES.core.project))

        resources.SetParamDefault(api='dataproc',
                                  collection=None,
                                  param='region',
                                  resolver=lambda: context['dataproc_region'])

        return context
Exemple #19
0
    def Filter(self, context, args):
        """Context() is a filter function that can update the context.

    Args:
      context: The current context.
      args: The argparse namespace that was specified on the CLI or API.

    Returns:
      The updated context.
    """
        properties.VALUES.compute.zone.Get(required=True)
        context['updater_api'] = updater_v1beta1.ReplicapoolupdaterV1beta1(
            get_credentials=False, http=cli.Http())
        context['updater_messages'] = replicapoolupdater_v1beta1_messages
        resources.SetParamDefault(api='compute',
                                  collection=None,
                                  param='project',
                                  resolver=resolvers.FromProperty(
                                      properties.VALUES.core.project))
        resources.SetParamDefault(api='compute',
                                  collection=None,
                                  param='zone',
                                  resolver=resolvers.FromProperty(
                                      properties.VALUES.compute.zone))
        resources.SetParamDefault(api='replicapoolupdater',
                                  collection=None,
                                  param='project',
                                  resolver=resolvers.FromProperty(
                                      properties.VALUES.core.project))
        resources.SetParamDefault(api='replicapoolupdater',
                                  collection=None,
                                  param='zone',
                                  resolver=resolvers.FromProperty(
                                      properties.VALUES.compute.zone))
        context['updater_resources'] = resources
        return context
Exemple #20
0
  def Filter(self, context, args):
    """Initialize context for Cloud Debugger commands.

    Args:
      context: The current context.
      args: The argparse namespace that was specified on the CLI or API.

    Returns:
      The updated context.
    """
    resources.SetParamDefault(
        api='debug', collection=None, param='projectId',
        resolver=resolvers.FromProperty(properties.VALUES.core.project))

    debug.DebugObject.InitializeApiClients()
    def Filter(self, context, args):
        project = properties.VALUES.core.project
        resolver = resolvers.FromProperty(project)
        resources.SetParamDefault('dns', None, 'project', resolver)

        dns_client = dns_v1_client.DnsV1(
            url=properties.VALUES.api_endpoint_overrides.dns.Get(),
            get_credentials=False,
            http=self.Http())

        context['dns_client'] = dns_client
        context['dns_messages'] = dns_v1_messages
        context['dns_resources'] = resources

        return context
Exemple #22
0
    def Filter(self, context, args):
        project = properties.VALUES.core.project
        resolver = resolvers.FromProperty(project)
        resources.SetParamDefault('dns', None, 'project', resolver)

        context['dns_client'] = apis.GetClientInstance('dns', 'v1')
        context['dns_messages'] = apis.GetMessagesModule('dns', 'v1')
        context['dns_resources'] = resources

        if args.endpoint:
            log.warn('The --endpoint flag is deprecated and will be removed.  '
                     'Set the api_endpoint_overrides/dns property instead.  '
                     'e.g. gcloud config set api_endpoint_overrides/dns '
                     'https://www.googleapis.com/dns/v1beta1')

        return context
Exemple #23
0
def SetResourceParamDefaults():
  """Sets resource parsing default parameters to point to properties."""
  core_values = properties.VALUES.core
  compute_values = properties.VALUES.compute
  for api, param, prop in (
      ('compute', 'project', core_values.project),
      ('clouduseraccounts', 'project', core_values.project),
      ('resourceviews', 'projectName', core_values.project),
      ('compute', 'zone', compute_values.zone),
      ('resourceviews', 'zone', compute_values.zone),
      ('compute', 'region', compute_values.region),
      ('resourceviews', 'region', compute_values.region)):
    resources.SetParamDefault(
        api=api,
        collection=None,
        param=param,
        resolver=resolvers.FromProperty(prop))
    def Filter(self, context, args):
        """Initialize context for source commands.

    Args:
      context: The current context.
      args: The argparse namespace that was specified on the CLI or API.

    Returns:
      The updated context.
    """
        resources.SetParamDefault(api='source',
                                  collection=None,
                                  param='projectId',
                                  resolver=resolvers.FromProperty(
                                      properties.VALUES.core.project))

        source.Source.SetResourceParser(resources.REGISTRY)
        source.Source.SetApiEndpoint()
Exemple #25
0
    def Filter(self, context, args):
        context['http'] = self.Http()
        context['dataproc_endpoint'] = (
            properties.VALUES.api_endpoint_overrides.dataproc.Get())
        context['dataproc_messages'] = dataproc_v1beta1_messages
        context['resources'] = resources

        context['dataproc_client'] = dataproc_v1beta1_client.DataprocV1beta1(
            get_credentials=False,
            http=context['http'],
            url=context['dataproc_endpoint'])

        resources.SetParamDefault(api='dataproc',
                                  collection=None,
                                  param='projectId',
                                  resolver=resolvers.FromProperty(
                                      properties.VALUES.core.project))

        return context
Exemple #26
0
    def Filter(self, context, args):
        project = properties.VALUES.core.project
        resolver = resolvers.FromProperty(project)
        resources.SetParamDefault('dns', None, 'project', resolver)

        dns_client = dns_v1_client.DnsV1(
            url=properties.VALUES.api_endpoint_overrides.dns.Get(),
            get_credentials=False,
            http=self.Http())

        context['dns_client'] = dns_client
        context['dns_messages'] = dns_v1_messages
        context['dns_resources'] = resources

        if args.endpoint:
            log.warn('The --endpoint flag is deprecated and will be removed.  '
                     'Set the api_endpoint_overrides/dns property instead.  '
                     'e.g. gcloud config set api_endpoint_overrides/dns '
                     'https://www.googleapis.com/dns/v1beta1')

        return context
Exemple #27
0
    def Filter(self, context, args):
        """Context() is a filter function that can update the context.

    Args:
      context: The current context.
      args: The argparse namespace that was specified on the CLI or API.

    Returns:
      The updated context.
    """

        cloud_resources.SetParamDefault(api='sql',
                                        collection=None,
                                        param='project',
                                        resolver=resolvers.FromProperty(
                                            properties.VALUES.core.project))

        url = '/'.join([properties.VALUES.core.api_host.Get(), 'sql'])
        http = self.Http()

        context['sql_client-v1beta3'] = sql_v1beta3.SqladminV1beta3(
            get_credentials=False, url='/'.join([url, 'v1beta3']), http=http)
        context['sql_messages-v1beta3'] = sql_v1beta3
        context[
            'registry-v1beta3'] = cloud_resources.REGISTRY.CloneAndSwitchAPIs(
                context['sql_client-v1beta3'])

        context['sql_client-v1beta1'] = sql_v1beta1.SqladminV1beta1(
            get_credentials=False, url='/'.join([url, 'v1beta1']), http=http)
        context['sql_messages-v1beta1'] = sql_v1beta1
        context[
            'registry-v1beta1'] = cloud_resources.REGISTRY.CloneAndSwitchAPIs(
                context['sql_client-v1beta1'])

        context['sql_client'] = context['sql_client-' + args.api_version]
        context['sql_messages'] = context['sql_messages-' + args.api_version]
        context['registry'] = context['registry-' + args.api_version]

        return context
Exemple #28
0
    def Filter(self, context, args):
        http = cli.Http()
        core_values = properties.VALUES.core
        compute_values = properties.VALUES.compute
        context['http'] = http
        context['project'] = core_values.project.Get(required=True)

        for api, param, prop in (('compute', 'project', core_values.project),
                                 ('resourceviews', 'projectName',
                                  core_values.project), ('compute', 'zone',
                                                         compute_values.zone),
                                 ('resourceviews', 'zone',
                                  compute_values.zone),
                                 ('compute', 'region', compute_values.region),
                                 ('resourceviews', 'region',
                                  compute_values.region)):
            resources.SetParamDefault(api=api,
                                      collection=None,
                                      param=param,
                                      resolver=resolvers.FromProperty(prop))

        utils.UpdateContextEndpointEntries(context, )
    def Filter(self, context, args):
        """Setup the API client within the context for this group's commands.

    Args:
      context: {str:object}, A set of key-value pairs that can be used for
          common initialization among commands.
      args: argparse.Namespace: The same namespace given to the corresponding
          .Run() invocation.
    """
        cloud_resources.SetParamDefault(api='dataflow',
                                        collection=None,
                                        param='projectId',
                                        resolver=resolvers.FromProperty(
                                            properties.VALUES.core.project))

        context[DATAFLOW_MESSAGES_MODULE_KEY] = dataflow_v1beta3_messages

        context[DATAFLOW_APITOOLS_CLIENT_KEY] = (
            dataflow_v1beta3_client.DataflowV1beta3(
                url=properties.VALUES.api_endpoint_overrides.dataflow.Get(),
                get_credentials=False,
                http=self.Http()))
        context[DATAFLOW_REGISTRY_KEY] = cloud_resources.REGISTRY
Exemple #30
0
    def Filter(self, context, args):
        """Context() is a filter function that can update the context.

    Args:
      context: The current context.
      args: The argparse namespace that was specified on the CLI or API.

    Returns:
      The updated context.
    Raises:
      ToolException: When no project is specified.
    """

        context['serviceregistry_client'] = apis.GetClientInstance(
            'serviceregistry', 'beta')
        context['serviceregistry_messages'] = apis.GetMessagesModule(
            'serviceregistry', 'beta')

        project = properties.VALUES.core.project
        resolver = resolvers.FromProperty(project)
        resources.SetParamDefault('serviceregistry', None, 'project', resolver)
        context['serviceregistry_resources'] = resources

        return context