Exemplo n.º 1
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
Exemplo n.º 2
0
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
Exemplo n.º 3
0
def RegisterReleasedAPIs():
  """Register all official versions of released Cloud APIs.

  """
  # pylint:disable=g-import-not-at-top
  from googlecloudapis.bigquery import v2 as bigquery_v2
  from googlecloudapis.compute import v1 as compute_v1
  from googlecloudapis.dataflow import v1beta3 as dataflow_v1beta3
  from googlecloudapis.developerprojects import v2beta1 as projects_v2beta1
  from googlecloudapis.dns import v1beta1 as dns_v1beta1
  from googlecloudapis.manager import v1beta2 as manager_v1beta2
  from googlecloudapis.replicapool import v1beta1 as replicapool_v1beta1
  from googlecloudapis.resourceviews import v1beta1 as resourceviews_v1beta1
  from googlecloudapis.sqladmin import v1beta3 as sqladmin_v1beta3
  resources.RegisterAPI(bigquery_v2.BigqueryV2(get_credentials=False))
  resources.RegisterAPI(compute_v1.ComputeV1(get_credentials=False))
  resources.RegisterAPI(dataflow_v1beta3.DataflowV1beta3(get_credentials=False))
  resources.RegisterAPI(
      projects_v2beta1.DeveloperprojectsV2beta1(get_credentials=False))
  resources.RegisterAPI(dns_v1beta1.DnsV1beta1(get_credentials=False))
  resources.RegisterAPI(manager_v1beta2.ManagerV1beta2(get_credentials=False))
  resources.RegisterAPI(
      replicapool_v1beta1.ReplicapoolV1beta1(get_credentials=False))
  resources.RegisterAPI(
      resourceviews_v1beta1.ResourceviewsV1beta1(get_credentials=False))
  resources.RegisterAPI(sqladmin_v1beta3.SqladminV1beta3(get_credentials=False))
  from googlecloudapis.autoscaler import v1beta2 as autoscaler_v1beta2
  resources.RegisterAPI(
      autoscaler_v1beta2.AutoscalerV1beta2(get_credentials=False))
  from googlecloudapis.replicapool import v1beta2 as replicapool_v1beta2
  resources.RegisterAPI(
      replicapool_v1beta2.ReplicapoolV1beta2(get_credentials=False))
  from googlecloudapis.replicapoolupdater import v1beta1 as updater_v1beta1
  resources.RegisterAPI(
      updater_v1beta1.ReplicapoolupdaterV1beta1(get_credentials=False))
Exemplo n.º 4
0
def RegisterAPIs():
    """Register all official versions of released Cloud APIs.

  """
    # pylint:disable=g-import-not-at-top
    from googlecloudapis.bigquery import v2 as bigquery_v2
    from googlecloudapis.cloudresourcemanager import v1beta1 as projects_v1beta1
    from googlecloudapis.compute import alpha as compute_alpha
    from googlecloudapis.compute import beta as compute_beta
    from googlecloudapis.compute import v1 as compute_v1
    from googlecloudapis.dataflow import v1beta3 as dataflow_v1beta3
    from googlecloudapis.dns import v1 as dns_v1
    from googlecloudapis.genomics import v1beta2 as genomics_v1beta2
    from googlecloudapis.manager import v1beta2 as manager_v1beta2
    from googlecloudapis.replicapool import v1beta1 as replicapool_v1beta1
    from googlecloudapis.resourceviews import v1beta1 as resourceviews_v1beta1
    from googlecloudapis.sqladmin import v1beta3 as sqladmin_v1beta3
    resources.RegisterAPI(bigquery_v2.BigqueryV2(get_credentials=False))
    resources.RegisterAPI(compute_alpha.ComputeAlpha(get_credentials=False),
                          urls_only=True)
    resources.RegisterAPI(compute_beta.ComputeBeta(get_credentials=False),
                          urls_only=True)
    resources.RegisterAPI(compute_v1.ComputeV1(get_credentials=False))
    resources.RegisterAPI(
        dataflow_v1beta3.DataflowV1beta3(get_credentials=False))
    resources.RegisterAPI(
        projects_v1beta1.CloudresourcemanagerV1beta1(get_credentials=False))
    resources.RegisterAPI(dns_v1.DnsV1(get_credentials=False))
    resources.RegisterAPI(
        genomics_v1beta2.GenomicsV1beta2(get_credentials=False))
    resources.RegisterAPI(
        manager_v1beta2.ManagerV1beta2(get_credentials=False))
    resources.RegisterAPI(
        replicapool_v1beta1.ReplicapoolV1beta1(get_credentials=False))
    resources.RegisterAPI(
        resourceviews_v1beta1.ResourceviewsV1beta1(get_credentials=False))
    resources.RegisterAPI(
        sqladmin_v1beta3.SqladminV1beta3(get_credentials=False))
    from googlecloudapis.autoscaler import v1beta2 as autoscaler_v1beta2
    resources.RegisterAPI(
        autoscaler_v1beta2.AutoscalerV1beta2(get_credentials=False))
    from googlecloudapis.replicapool import v1beta2 as replicapool_v1beta2
    resources.RegisterAPI(
        replicapool_v1beta2.ReplicapoolV1beta2(get_credentials=False))
    from googlecloudapis.replicapoolupdater import v1beta1 as updater_v1beta1
    resources.RegisterAPI(
        updater_v1beta1.ReplicapoolupdaterV1beta1(get_credentials=False))
    from googlecloudapis.storage import v1 as storage_v1
    resources.RegisterAPI(storage_v1.StorageV1(get_credentials=False))

    pass
Exemplo n.º 5
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