예제 #1
0
    def DeleteBroker(self, namespace_name, broker_name):
        """Deletes the referenced broker."""

        # represents namespaces/<namespace_name>/brokers/<broker_name>
        broker_full_name = 'namespaces/{}/brokers/{}'.format(
            namespace_name, broker_name)

        messages = self._client.MESSAGES_MODULE
        request = self.messages.AnthoseventsNamespacesBrokersDeleteRequest(
            name=broker_full_name)
        try:
            self._client.namespaces_brokers.Delete(request)
        except api_exceptions.HttpNotFoundError:
            raise exceptions.BrokerNotFound(
                'Broker [{}] not found.'.format(broker_name))
예제 #2
0
    def Run(self, args):
        """Executes when the user runs the describe command."""
        conn_context = connection_context.EventsConnectionContext(args)

        namespace_ref = args.CONCEPTS.namespace.Parse()
        broker_name = args.BROKER
        broker_full_name = namespace_ref.RelativeName(
        ) + '/brokers/' + broker_name

        with eventflow_operations.Connect(conn_context) as client:
            broker_obj = client.GetBroker(broker_full_name)

        if not broker_obj:
            raise exceptions.BrokerNotFound(
                'Broker [{}] not found.'.format(broker_name))
        return broker_obj
예제 #3
0
  def Run(self, args):
    """Executes when the user runs the describe command."""
    if platforms.GetPlatform() == platforms.PLATFORM_MANAGED:
      raise exceptions.UnsupportedArgumentError(
          'This command is only available with Cloud Run for Anthos.')

    conn_context = connection_context.GetConnectionContext(
        args, serverless_flags.Product.EVENTS, self.ReleaseTrack())

    namespace_ref = args.CONCEPTS.namespace.Parse()
    broker_name = args.BROKER
    broker_full_name = namespace_ref.RelativeName() + '/brokers/' + broker_name

    with eventflow_operations.Connect(conn_context) as client:
      broker_obj = client.GetBroker(broker_full_name)

    if not broker_obj:
      raise exceptions.BrokerNotFound(
          'Broker [{}] not found.'.format(broker_name))
    return broker_obj