Beispiel #1
0
    def Run(self, args):
        client = channel_connections.ChannelConnectionClientV1()
        channel_connection_ref = args.CONCEPTS.channel_connection.Parse()

        location_name = channel_connection_ref.Parent().Name()
        console_io.PromptContinue(
            message=('The following channel connection will be deleted.\n'
                     '[{name}] in location [{location}]'.format(
                         name=channel_connection_ref.Name(),
                         location=location_name)),
            throw_if_unattended=True,
            cancel_on_no=True)
        operation = client.Delete(channel_connection_ref)

        if args.async_:
            return operation
        return client.WaitFor(operation, 'Deleting', channel_connection_ref)
    def Run(self, args):
        """Run the create command."""
        client = channel_connections.ChannelConnectionClientV1()
        channel_connection_ref = args.CONCEPTS.channel_connection.Parse()

        project_name = channel_connection_ref.Parent().Parent().Name()
        location_name = channel_connection_ref.Parent().Name()
        log.debug('Creating channel {} for project {} in location {}'.format(
            channel_connection_ref.Name(), project_name, location_name))
        operation = client.Create(
            channel_connection_ref,
            client.BuildChannelConnection(
                channel_connection_ref,
                channel=args.channel,
                activation_token=args.activation_token))

        if args.async_:
            return operation
        return client.WaitFor(operation, 'Creating', channel_connection_ref)
Beispiel #3
0
    def Run(self, args):
        """Run the Publish command."""

        client = channel_connections.ChannelConnectionClientV1()
        channel_connection_ref = args.CONCEPTS.channel_connection.Parse()

        name = channel_connection_ref.Name()
        log.debug(
            'Publishing event with id: {} to channel connection: {}'.format(
                args.event_id, name))

        client.Publish(
            channel_connection_ref,
            common_publishing.CreateCloudEvent(args.event_id, args.event_type,
                                               args.event_source,
                                               args.event_data,
                                               args.event_attributes))

        return log.out.Print('Event published successfully')
Beispiel #4
0
    def Run(self, args):
        client = channel_connections.ChannelConnectionClientV1()
        channel_ref = args.CONCEPTS.channel_connection.Parse()

        return client.Get(channel_ref)
 def Run(self, args):
     client = channel_connections.ChannelConnectionClientV1()
     args.CONCEPTS.project.Parse()
     location_ref = args.CONCEPTS.location.Parse()
     return client.List(location_ref, args.limit, args.page_size)