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,28 @@
# -*- coding: utf-8 -*- #
# Copyright 2020 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.
"""Manage Pub/Sub Lite subscriptions."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA,
base.ReleaseTrack.GA)
class LiteSubscriptions(base.Group):
"""Manage Pub/Sub Lite subscriptions."""

View File

@@ -0,0 +1,35 @@
release_tracks: [ALPHA, BETA, GA]
help_text:
brief: Acknowledge messages on a Pub/Sub Lite subscription.
description: |
Acknowledge all messages on a Pub/Sub Lite subscription up to the provided offset. The message
corresponding to the provided offset will be included in the list of messages that are
acknowledged.
examples: |
To acknowledge messages on a Pub/Sub Lite subscription, run:
$ {command} mysubscription \
--location=us-central1-a \
--partition=0 \
--offset=10
request:
collection: pubsublite.cursor.projects.locations.subscriptions
method: commitCursor
modify_request_hooks:
- googlecloudsdk.command_lib.pubsub.lite_util:UpdateCommitCursorRequest
arguments:
resource:
help_text: Subscription on which to acknowledge messages.
spec: !REF googlecloudsdk.command_lib.pubsub.resources:lite_cursor_subscription
command_level_fallthroughs:
location:
- arg_name: 'zone'
params:
- _REF_: googlecloudsdk.command_lib.pubsub.flags:zone
- _REF_: googlecloudsdk.command_lib.pubsub.flags:partition
required: true
- _REF_: googlecloudsdk.command_lib.pubsub.flags:offset
required: true

View File

@@ -0,0 +1,63 @@
release_tracks: [ALPHA, BETA, GA]
help_text:
brief: Create a Pub/Sub Lite subscription.
description: Create a Pub/Sub Lite subscription.
examples: |
To create a Pub/Sub Lite subscription, run:
$ {command} mysubscription \
--location=us-central1-a \
--topic=mytopic
To create a Pub/Sub Lite subscription at the offset of the oldest retained message, run:
$ {command} mysubscription \
--location=us-central1-a \
--topic=mytopic \
--starting-offset=beginning
To create a Pub/Sub Lite subscription that exports messages from a Pub/Sub Lite topic to a
Pub/Sub topic, run:
$ {command} mysubscription \
--location=us-central1-a \
--topic=mytopic
--export-pubsub-topic=pubsubtopic
request:
collection: pubsublite.admin.projects.locations.subscriptions
method: create
issue_request_hook: googlecloudsdk.command_lib.pubsub.lite_util:ExecuteCreateSubscriptionRequest
arguments:
resource:
help_text: Identifies the Cloud zone this command will be executed on.
spec: !REF googlecloudsdk.command_lib.pubsub.resources:location
is_parent_resource: true
is_positional: false
command_level_fallthroughs:
location:
- arg_name: 'zone'
params:
- _REF_: googlecloudsdk.command_lib.pubsub.flags:zone
- _REF_: googlecloudsdk.command_lib.pubsub.flags:subscription-name
required: true
- _REF_: googlecloudsdk.command_lib.pubsub.flags:subscription-topic-name
required: true
- _REF_: googlecloudsdk.command_lib.pubsub.flags:delivery-requirement
default: deliver-immediately
- group:
mutex: true
params:
- _REF_: googlecloudsdk.command_lib.pubsub.flags:starting-offset
default: end
- _REF_: googlecloudsdk.command_lib.pubsub.flags:publish-time
- _REF_: googlecloudsdk.command_lib.pubsub.flags:event-time
- group:
params:
- _REF_: googlecloudsdk.command_lib.pubsub.flags:export-desired-state
default: active
- _REF_: googlecloudsdk.command_lib.pubsub.flags:export-pubsub-topic
required: true
- _REF_: googlecloudsdk.command_lib.pubsub.flags:export-dead-letter-topic

View File

@@ -0,0 +1,26 @@
release_tracks: [ALPHA, BETA, GA]
help_text:
brief: Delete a Pub/Sub Lite subscription.
description: Delete a Pub/Sub Lite subscription.
examples: |
To delete a Pub/Sub Lite subscription, run:
$ {command} mysubscription \
--location=us-central1-a
request:
collection: pubsublite.admin.projects.locations.subscriptions
method: delete
modify_request_hooks:
- googlecloudsdk.command_lib.pubsub.lite_util:UpdateAdminRequest
arguments:
resource:
help_text: Subscription to delete.
spec: !REF googlecloudsdk.command_lib.pubsub.resources:lite_subscription
command_level_fallthroughs:
location:
- arg_name: 'zone'
params:
- _REF_: googlecloudsdk.command_lib.pubsub.flags:zone

View File

@@ -0,0 +1,26 @@
release_tracks: [ALPHA, BETA, GA]
help_text:
brief: Describe a Pub/Sub Lite subscription.
description: Describe a Pub/Sub Lite subscription.
examples: |
To describe a Pub/Sub Lite subscription, run:
$ {command} mysubscription \
--location=us-central1-a
request:
collection: pubsublite.admin.projects.locations.subscriptions
method: get
modify_request_hooks:
- googlecloudsdk.command_lib.pubsub.lite_util:UpdateAdminRequest
arguments:
resource:
help_text: Subscription to describe.
spec: !REF googlecloudsdk.command_lib.pubsub.resources:lite_subscription
command_level_fallthroughs:
location:
- arg_name: 'zone'
params:
- _REF_: googlecloudsdk.command_lib.pubsub.flags:zone

View File

@@ -0,0 +1,26 @@
release_tracks: [ALPHA, BETA, GA]
help_text:
brief: List Pub/Sub Lite subscriptions.
description: List Pub/Sub Lite subscriptions.
examples: |
To list Pub/Sub Lite subscriptions, run:
$ {command} --location=us-central1-a \
--limit=5
request:
collection: pubsublite.admin.projects.locations.subscriptions
method: list
modify_request_hooks:
- googlecloudsdk.command_lib.pubsub.lite_util:UpdateAdminRequest
arguments:
resource:
help_text: ID of the location or fully qualified identifier for the location.
spec: !REF googlecloudsdk.command_lib.pubsub.resources:location
command_level_fallthroughs:
location:
- arg_name: 'zone'
params:
- _REF_: googlecloudsdk.command_lib.pubsub.flags:zone

View File

@@ -0,0 +1,51 @@
release_tracks: [ALPHA, BETA, GA]
help_text:
brief: Seek a Pub/Sub Lite subscription.
description: |
Initiate an out-of-band seek operation for a Pub/Sub Lite subscription to a specified target,
which may be timestamps or named locations within the message backlog.
The seek operation will complete once subscriber clients react to the seek for all partitions of
the topic. Note that the seek operation will not complete until subscribers are online. It may
take some time (usually within 30 seconds) for the seek to propagate if subscribers are online.
Use the --async flag if it's not necessary to wait for completion.
examples: |
To seek a Pub/Sub Lite subscription to the beginning of the message backlog, run:
$ {command} mysubscription \
--location=us-central1-a \
--starting-offset=beginning
To seek a Pub/Sub Lite subscription to a publish time without waiting for the operation to
complete, run:
$ {command} mysubscription \
--location=us-central1-a \
--publish-time="2021-01-01T12:00:00Z"
--async
request:
collection: pubsublite.admin.projects.locations.subscriptions
method: seek
modify_request_hooks:
- googlecloudsdk.command_lib.pubsub.lite_util:UpdateAdminRequest
- googlecloudsdk.command_lib.pubsub.lite_util:SetSeekTarget
async:
collection: pubsublite.admin.projects.locations.operations
# The response does not contain a resource. Print operation metadata instead.
extract_resource_result: false
arguments:
resource:
help_text: Subscription to seek.
spec: !REF googlecloudsdk.command_lib.pubsub.resources:lite_subscription
params:
- group:
mutex: true
required: true
params:
- _REF_: googlecloudsdk.command_lib.pubsub.flags:starting-offset
- _REF_: googlecloudsdk.command_lib.pubsub.flags:publish-time
- _REF_: googlecloudsdk.command_lib.pubsub.flags:event-time

View File

@@ -0,0 +1,117 @@
# -*- 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.
"""Pub/Sub Lite lite-subscriptions subscribe command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import arg_parsers
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.pubsub import lite_util
from googlecloudsdk.command_lib.util.args import resource_args
from googlecloudsdk.core import log
from googlecloudsdk.core.resource import resource_printer
MESSAGE_FORMAT = """\
default(
data,
message_id,
ordering_key,
attributes
)
"""
@base.ReleaseTracks(base.ReleaseTrack.GA, base.ReleaseTrack.BETA,
base.ReleaseTrack.ALPHA)
class Subscribe(base.Command):
"""Stream messages from a Pub/Sub Lite subscription."""
detailed_help = {
'DESCRIPTION':
"""\
Streams messages from a Pub/Sub Lite subscription. This command
requires Python 3.6 or greater, and requires the grpcio Python package
to be installed.
For MacOS, Linux, and Cloud Shell users, to install the gRPC client
libraries, run:
$ sudo pip3 install grpcio
$ export CLOUDSDK_PYTHON_SITEPACKAGES=1
""",
'EXAMPLES':
"""\
To subscribe to a Pub/Sub Lite subscription and automatically
acknowledge messages, run:
$ {command} mysubscription --location=us-central1-a --auto-ack
To subscribe to specific partitions in a subscription, run:
$ {command} mysubscription --location=us-central1-a --partitions=0,1,2
"""
}
@staticmethod
def Args(parser):
resource_args.AddResourceArgToParser(
parser,
resource_path='pubsub.lite_subscription',
required=True,
help_text='The Pub/Sub Lite subscription to receive messages from.')
parser.add_argument(
'--num-messages',
type=arg_parsers.BoundedInt(1, 1000),
default=1,
help="""The number of messages to stream before exiting. This value must
be less than or equal to 1000.""")
parser.add_argument(
'--auto-ack',
action='store_true',
default=False,
help='Automatically ACK every message received on this subscription.')
parser.add_argument(
'--partitions',
metavar='INT',
type=arg_parsers.ArgList(element_type=int),
help="""The partitions this subscriber should connect to to receive
messages. If empty, partitions will be automatically assigned.""")
def Run(self, args):
lite_util.RequirePython36('gcloud pubsub lite-subscriptions subscribe')
try:
# pylint: disable=g-import-not-at-top
from googlecloudsdk.api_lib.pubsub import lite_subscriptions
# pylint: enable=g-import-not-at-top
except ImportError:
raise lite_util.NoGrpcInstalled()
log.out.Print(
'Initializing the Subscriber stream... This may take up to 30 seconds.')
printer = resource_printer.Printer(args.format or MESSAGE_FORMAT)
with lite_subscriptions.SubscriberClient(
args.CONCEPTS.subscription.Parse(), args.partitions or [],
args.num_messages, args.auto_ack) as subscriber_client:
received = 0
while received < args.num_messages:
message = subscriber_client.Pull()
if message:
splits = message.message_id.split(',')
message.message_id = 'Partition: {}, Offset: {}'.format(
splits[0], splits[1])
printer.Print([message])
received += 1

View File

@@ -0,0 +1,35 @@
release_tracks: [ALPHA, BETA, GA]
help_text:
brief: Update a Pub/Sub Lite subscription.
description: Update a Pub/Sub Lite subscription.
examples: |
To update a Pub/Sub Lite subscription, run:
$ {command} mysubscription \
--location=us-central1-a \
--delivery-requirement=DELIVER_IMMEDIATELY
request:
collection: pubsublite.admin.projects.locations.subscriptions
method: patch
modify_request_hooks:
- googlecloudsdk.command_lib.pubsub.lite_util:UpdateAdminRequest
- googlecloudsdk.command_lib.pubsub.lite_util:AddExportResources
arguments:
resource:
help_text: Subscription to update.
spec: !REF googlecloudsdk.command_lib.pubsub.resources:lite_subscription
command_level_fallthroughs:
location:
- arg_name: 'zone'
params:
- _REF_: googlecloudsdk.command_lib.pubsub.flags:zone
- group:
required: true
params:
- _REF_: googlecloudsdk.command_lib.pubsub.flags:delivery-requirement
- _REF_: googlecloudsdk.command_lib.pubsub.flags:export-desired-state
- _REF_: googlecloudsdk.command_lib.pubsub.flags:export-pubsub-topic
- _REF_: googlecloudsdk.command_lib.pubsub.flags:export-dead-letter-topic