Beispiel #1
0
    def Run(self, args):
        """Runs 'endpoints update'.

    Args:
      args: argparse.Namespace, The arguments that this command was invoked
          with.

    Returns:
      If --async=true, returns Operation to poll.
      Else returns nothing.

    Raises:
      HttpException: An http error response was received while executing api
          request.
      ToolException: Endpoint update encountered an error.
    """
        client = self.context[constants.CLIENT]
        messages = self.context[constants.MESSAGES]
        resources = self.context[constants.RESOURCES]
        project = properties.VALUES.core.project.Get(required=True)
        writer = write_support.ServiceRegistryClient(client, resources)

        fingerprint = None
        endpoint = client.endpoints.Get(
            messages.ServiceregistryEndpointsGetRequest(
                project=project, endpoint=args.endpoint_name))
        fingerprint = endpoint.fingerprint

        message_str = 'Preparing to update [{0}].'.format(args.endpoint_name)
        if not console_io.PromptContinue(message=message_str):
            log.Print('Cancelling update operation.')
            return

        request = messages.ServiceregistryEndpointsUpdateRequest(
            project=project,
            endpoint=args.endpoint_name,
            endpointResource=messages.Endpoint(
                name=args.endpoint_name,
                description=args.description,
                addresses=args.target,
                dnsIntegration=messages.EndpointDnsIntegration(
                    networks=arg_support.ExpandNetworks(
                        args.networks, project),
                    enableExternal=args.enable_external,
                ),
                fingerprint=fingerprint))

        return writer.call_service_registry(
            client.endpoints.Update, request, args. async,
            'Updated [{0}] successfully.'.format(args.endpoint_name))
Beispiel #2
0
    def Run(self, args):
        """Runs 'endpoints create'.

    Args:
      args: argparse.Namespace, The arguments that this command was invoked
          with.

    Returns:
      If --async=true, returns Operation to poll.
      Else, returns nothing.

    Raises:
      HttpException: An http error response was received while executing api
          request.
      ToolException: Endpoint creation encountered an error.
    """
        client = self.context[constants.CLIENT]
        messages = self.context[constants.MESSAGES]
        resources = self.context[constants.RESOURCES]
        project = properties.VALUES.core.project.Get(required=True)
        writer = write_support.ServiceRegistryClient(client, resources)

        request = messages.ServiceregistryEndpointsInsertRequest(
            project=project,
            endpoint=messages.Endpoint(
                name=args.endpoint_name,
                description=args.description,
                addresses=args.target,
                dnsIntegration=messages.EndpointDnsIntegration(
                    networks=arg_support.ExpandNetworks(
                        args.networks, project),
                    enableExternal=args.enable_external,
                ),
            ))

        return writer.call_service_registry(
            client.endpoints.Insert, request, args. async,
            'Created [{0}] successfully.'.format(args.endpoint_name))