feat: Add new gcloud commands, API clients, and third-party libraries across various services.

This commit is contained in:
2026-01-01 20:26:35 +01:00
parent 5e23cbece0
commit a19e592eb7
25221 changed files with 8324611 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
# -*- coding: utf-8 -*- #
# Copyright 2021 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""The channel connections command group for Eventarc."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.GA)
@base.DefaultUniverseOnly
class ChannelConnections(base.Group):
"""Manage Eventarc channel connections."""
category = base.SERVERLESS_CATEGORY

View File

@@ -0,0 +1,89 @@
# -*- coding: utf-8 -*- #
# Copyright 2021 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Command to create a channel connection."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.eventarc import channel_connections
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.eventarc import flags
from googlecloudsdk.core import log
_DETAILED_HELP = {
'DESCRIPTION':
'{description}',
'EXAMPLES':
"""\
To create a new channel connection ``my-channel-connection'' for channel ``my-channel'' with activation token ``channel-activation-token'', run:
$ {command} my-channel-connection --channel=my-channel --activation-token=channel-activation-token
""",
}
ACTIVATION_TOKEN_FLAG = base.Argument(
'--activation-token',
dest='activation_token',
help="""Activation token for the specified channel.""",
required=True)
CHANNEL_FLAG = base.Argument(
'--channel',
dest='channel',
help="""Subscriber channel for which to create the channel connection. This argument should be the full channel name, including project, location and the channel id. """,
required=True)
@base.ReleaseTracks(base.ReleaseTrack.GA)
@base.DefaultUniverseOnly
class Create(base.CreateCommand):
"""Create an Eventarc channel connection."""
detailed_help = _DETAILED_HELP
@classmethod
def Args(cls, parser):
flags.AddChannelConnectionResourceArg(parser,
'Channel connection to create.')
CHANNEL_FLAG.AddToParser(parser)
ACTIVATION_TOKEN_FLAG.AddToParser(parser)
flags.AddLabelsArg(
parser, help_text='Labels to apply to the channel connection.'
)
base.ASYNC_FLAG.AddToParser(parser)
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,
labels=args.labels,
),
)
if args.async_:
return operation
return client.WaitFor(operation, 'Creating', channel_connection_ref)

View File

@@ -0,0 +1,66 @@
# -*- coding: utf-8 -*- #
# Copyright 2021 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Command to delete the specified channel connection."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.eventarc import channel_connections
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.eventarc import flags
from googlecloudsdk.core.console import console_io
_DETAILED_HELP = {
'DESCRIPTION':
'{description}',
'EXAMPLES':
"""\
To delete the channel connection ``my-channel-connection'' in location ``us-central1'', run:
$ {command} my-channel-connection --location=us-central1
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Delete(base.DeleteCommand):
"""Delete an Eventarc channel connection."""
detailed_help = _DETAILED_HELP
@classmethod
def Args(cls, parser):
flags.AddChannelConnectionResourceArg(parser,
'Channel connection to delete.')
base.ASYNC_FLAG.AddToParser(parser)
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)

View File

@@ -0,0 +1,52 @@
# -*- coding: utf-8 -*- #
# Copyright 2021 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Command to describe the specified channel."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.eventarc import channel_connections
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.eventarc import flags
_DETAILED_HELP = {
'DESCRIPTION':
'{description}',
'EXAMPLES':
"""\
To describe the channel connection ``my-channel-connection'' in location ``us-central1'', run:
$ {command} my-channel-connection --location=us-central1
""",
}
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Describe(base.DescribeCommand):
"""Describe an Eventarc channel connection."""
detailed_help = _DETAILED_HELP
@classmethod
def Args(cls, parser):
flags.AddChannelConnectionResourceArg(parser,
'Channel connection to describe.')
def Run(self, args):
client = channel_connections.ChannelConnectionClientV1()
channel_ref = args.CONCEPTS.channel_connection.Parse()
return client.Get(channel_ref)

View File

@@ -0,0 +1,76 @@
# -*- coding: utf-8 -*- #
# Copyright 2021 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Command to list all channel connections in a project and location."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.eventarc import channel_connections
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.eventarc import flags
_DETAILED_HELP = {
"DESCRIPTION":
"{description}",
"EXAMPLES":
"""\
To list all channel connections in location ``us-central1'', run:
$ {command} --location=us-central1
To list all channel connections in all locations, run:
$ {command} --location=-
or
$ {command}
""",
}
_FORMAT = """\
table(
name.scope("channelConnections"):label=NAME,
channel:label=CHANNEL
)
"""
@base.ReleaseTracks(base.ReleaseTrack.GA)
@base.DefaultUniverseOnly
class List(base.ListCommand):
"""List Eventarc channel connections."""
detailed_help = _DETAILED_HELP
@staticmethod
def Args(parser):
flags.AddLocationResourceArg(
parser,
"Location for which to list channel connections. This should be one of"
" the supported regions.",
required=False,
allow_aggregation=True,
)
flags.AddProjectResourceArg(parser)
parser.display_info.AddFormat(_FORMAT)
parser.display_info.AddUriFunc(channel_connections.GetChannelConnectionsURI)
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)

View File

@@ -0,0 +1,72 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Command to publish channels."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.eventarc import channel_connections
from googlecloudsdk.api_lib.eventarc import common_publishing
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.eventarc import flags
from googlecloudsdk.core import log
_DETAILED_HELP = {
'DESCRIPTION':
'{description}',
'EXAMPLES':
""" \
To publish an event to your channel connection `my-channel-connection`
with event id `1234`
with event type `event-provider.event.v1.eventType`
with event source `//event-provider/projects/project-id/resource-id`
with event data `{ "key": "value" }`
and event attributes of `attribute1=value`, run:
$ {command} my-channel-connection --event-id=1234 --event-type=event-provider.event.v1.eventType --event-source="//event-provider/event/source" --event-data='{"key": "value"}' --event-attributes=attribute1=value
""",
}
@base.Hidden
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Publish(base.Command):
"""Publish to an Eventarc channel connection."""
detailed_help = _DETAILED_HELP
@classmethod
def Args(cls, parser):
flags.AddChannelConnectionResourceArg(parser,
'Channel connection to publish to.')
flags.AddEventPublishingArgs(parser)
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')