예제 #1
0
파일: apis.py 프로젝트: bopopescu/GoogleAPI
    def Create(self, api_ref, managed_service, labels=None, display_name=None):
        """Creates a new Api object.

    Args:
      api_ref: Resource, a resource reference for the api
      managed_service: String, reference name for OP service
      labels: Optional cloud labels
      display_name: Optional display name

    Returns:
      Long running operation response object.
    """
        labels = common_flags.ProcessLabelsFlag(
            labels, self.messages.ApigatewayApi.LabelsValue)

        api_controller = self.messages.ApigatewayApiApiController(
            managedService=managed_service)
        api = self.messages.ApigatewayApi(name=api_ref.RelativeName(),
                                          apiController=api_controller,
                                          labels=labels,
                                          displayName=display_name)

        req = self.create_request(apiId=api_ref.Name(),
                                  apigatewayApi=api,
                                  parent=api_ref.Parent().RelativeName())

        return self.service.Create(req)
예제 #2
0
    def Create(self, gateway_ref, api_config, display_name=None, labels=None):
        """Creates a new gateway object.

    Args:
      gateway_ref: Resource, a resource reference for the gateway
      api_config: Resource, a resource reference for the gateway
      display_name: Optional display name
      labels: Optional cloud labels

    Returns:
      Long running operation.
    """
        labels = common_flags.ProcessLabelsFlag(
            labels, self.messages.ApigatewayGateway.LabelsValue)

        gateway = self.messages.ApigatewayGateway(
            name=gateway_ref.RelativeName(),
            labels=labels,
            apiConfig=api_config.RelativeName(),
            displayName=display_name,
        )

        req = self.create_request(
            parent=gateway_ref.Parent().RelativeName(),
            gatewayId=gateway_ref.Name(),
            apigatewayGateway=gateway,
        )
        resp = self.service.Create(req)

        return resp
예제 #3
0
  def Create(self, api_config_ref, display_name=None, labels=None,
             backend_auth=None, managed_service_configs=None,
             grpc_service_defs=None, open_api_docs=None):
    """Creates an Api Config object.

    Args:
      api_config_ref: A parsed resource reference for the api
      display_name: Optional string display name
      labels: Optional cloud labels (as provided in the labels argument)
      backend_auth: Optional string to set the service account for backend auth
      managed_service_configs: Optional field to send in a list of managed
       service configurations. Should be in the form of the
       ApigatewayApiConfigFileMessage's generated from the discovery document
      grpc_service_defs: Optional field to send in a list of GRPC service
       definitions. Should be in the form of
       ApigatewayApiConfigGrpcServiceDefinition's generated from the discovery
       document
      open_api_docs: Optional field to send in a list of Open API documents.
       Should be in the form of ApigatewayApiConfigOpenApiDocument's generated
       from the discovery document


    Returns:
      Long running operation
    """
    labels = common_flags.ProcessLabelsFlag(
        labels,
        self.messages.ApigatewayApiConfig.LabelsValue)

    backend_config = self.messages.ApigatewayBackendConfig(
        googleServiceAccount=backend_auth)
    gateway_config = self.messages.ApigatewayGatewayConfig(
        backendConfig=backend_config)
    api_config = self.messages.ApigatewayApiConfig(
        name=api_config_ref.RelativeName(),
        displayName=display_name,
        labels=labels,
        gatewayConfig=gateway_config,
        managedServiceConfigs=managed_service_configs,
        grpcServices=grpc_service_defs,
        openapiDocuments=open_api_docs)

    req = self.create_request(
        apiConfigId=api_config_ref.Name(),
        apigatewayApiConfig=api_config,
        parent=api_config_ref.Parent().RelativeName())

    return self.service.Create(req)
    def Create(self,
               api_config_ref,
               rollout_id,
               display_name=None,
               labels=None,
               backend_auth=None):
        """Creates an Api Config object.

    Args:
      api_config_ref: Resource, a resource reference for the api
      rollout_id: Id of the service rollout
      display_name: Optional display name
      labels: Optional cloud labels
      backend_auth: Optional field to set the service account for backend auth

    Returns:
      Long running operation
    """
        labels = common_flags.ProcessLabelsFlag(
            labels, self.messages.ApigatewayApiConfig.LabelsValue)

        service_rollout = self.messages.ApigatewayApiConfigManagedServiceRollout(
            rolloutId=rollout_id)
        backend_config = self.messages.ApigatewayBackendConfig(
            googleServiceAccount=backend_auth)
        gateway_config = self.messages.ApigatewayGatewayConfig(
            backendConfig=backend_config)
        api_config = self.messages.ApigatewayApiConfig(
            name=api_config_ref.RelativeName(),
            serviceRollout=service_rollout,
            displayName=display_name,
            labels=labels,
            gatewayConfig=gateway_config)

        req = self.create_request(
            apiConfigId=api_config_ref.Name(),
            apigatewayApiConfig=api_config,
            parent=api_config_ref.Parent().RelativeName())

        return self.service.Create(req)