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,30 @@
# -*- 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.
"""The streams command group for Datastream."""
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.ReleaseTrack.BETA)
class Streams(base.Group):
"""Manage Datastream stream resources.
Commands for managing Datastream stream resources.
"""

View File

@@ -0,0 +1,142 @@
# -*- 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 connection profiles for a datastream."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.datastream import streams
from googlecloudsdk.api_lib.datastream import util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.datastream import flags
from googlecloudsdk.command_lib.datastream import resource_args
from googlecloudsdk.command_lib.datastream.streams import flags as streams_flags
DESCRIPTION = """\
Create a Datastream stream. If successful, the response body contains a newly created instance of Operation.
To get the operation result, call: describe OPERATION
"""
EXAMPLES = """\
To create a stream with an Oracle source and a Google Cloud Storage destination:
$ {command} STREAM --location=us-central1 --display-name=my-stream --source=source --oracle-source-config=source_config.json --destination=destination --gcs-destination-config=destination_config.json --backfill-none
To create a stream with a MySQL source and a Cloud Storage destination and that excludes some objects from being backfilled:
$ {command} STREAM --location=us-central1 --display-name=my-stream --source=source --mysql-source-config=source_config.json --destination=destination --gcs-destination-config=destination_config.json --backfill-all --mysql-excluded-objects=excluded_objects.json
To create a stream with an Oracle source and a BigQuery destination:
$ {command} STREAM --location=us-central1 --display-name=my-stream --source=source --oracle-source-config=source_config.json --destination=destination --bigquery-destination-config=destination_config.json --backfill-none
To create a stream with a PostgreSQL source and a BigQuery destination:
$ {command} STREAM --location=us-central1 --display-name=my-stream --source=source --postgresql-source-config=source_config.json --destination=destination --bigquery-destination-config=destination_config.json --backfill-none
To create a stream with a MongoDB source and a Cloud Storage destination and that excludes some objects from being backfilled:
$ {command} STREAM --location=us-central1 --display-name=my-stream --source=source --mongodb-source-config=source_config.json --destination=destination --gcs-destination-config=destination_config.json --backfill-all --mongodb-excluded-objects=excluded_objects.json
"""
EXAMPLES_BETA = """\
To create a stream with an Oracle source and a Google Cloud Storage destination:
$ {command} STREAM --location=us-central1 --display-name=my-stream --source-name=source --oracle-source-config=source_config.json --destination-name=destination --gcs-destination-config=destination_config.json --backfill-none
To create a stream with a MySQL source and a Cloud Storage destination and that excludes some objects from being backfilled:
$ {command} STREAM --location=us-central1 --display-name=my-stream --source-name=source --mysql-source-config=source_config.json --destination-name=destination --gcs-destination-config=destination_config.json --backfill-all --mysql-excluded-objects=excluded_objects.json
"""
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Create(base.Command):
"""Create a Datastream stream."""
detailed_help = {'DESCRIPTION': DESCRIPTION, 'EXAMPLES': EXAMPLES}
@staticmethod
def CommonArgs(parser, release_track):
"""Common arguments for all release tracks.
Args:
parser: An argparse parser that you can use to add arguments that go on
the command line after this command. Positional arguments are allowed.
release_track: Some arguments are added based on the command release
track.
"""
resource_args.AddStreamResourceArg(parser, 'create', release_track)
streams_flags.AddDisplayNameFlag(parser)
streams_flags.AddBackfillStrategyGroup(parser)
streams_flags.AddValidationGroup(parser, 'Create')
streams_flags.AddRuleSetsFlag(parser)
flags.AddLabelsCreateFlags(parser)
@staticmethod
def Args(parser):
"""Args is called by calliope to gather arguments for this command."""
Create.CommonArgs(parser, base.ReleaseTrack.GA)
def Run(self, args):
"""Create a Datastream stream.
Args:
args: argparse.Namespace, The arguments that this command was invoked
with.
Returns:
A dict object representing the operations resource describing the create
operation if the create was successful.
"""
stream_ref = args.CONCEPTS.stream.Parse()
parent_ref = stream_ref.Parent().RelativeName()
stream_client = streams.StreamsClient()
result_operation = stream_client.Create(parent_ref, stream_ref.streamsId,
self.ReleaseTrack(), args)
client = util.GetClientInstance()
messages = util.GetMessagesModule()
resource_parser = util.GetResourceParser()
operation_ref = resource_parser.Create(
'datastream.projects.locations.operations',
operationsId=result_operation.name,
projectsId=stream_ref.projectsId,
locationsId=stream_ref.locationsId)
return client.projects_locations_operations.Get(
messages.DatastreamProjectsLocationsOperationsGetRequest(
name=operation_ref.operationsId))
@base.Deprecate(
is_removed=False,
warning=('Datastream beta version is deprecated. Please use`gcloud '
'datastream streams create` command instead.'))
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class CreateBeta(Create):
"""Creates a Datastream stream."""
detailed_help = {'DESCRIPTION': DESCRIPTION, 'EXAMPLES': EXAMPLES_BETA}
@staticmethod
def Args(parser):
"""Args is called by calliope to gather arguments for this command."""
Create.CommonArgs(parser, base.ReleaseTrack.BETA)

View File

@@ -0,0 +1,26 @@
- release_tracks: [BETA, GA]
BETA:
deprecate:
is_removed: false
warning: |
This command has been deprecated.
Use `gcloud datastream streams delete` instead.
help_text:
brief: |
Delete a Datastream stream.
description: |
Deletes a stream.
examples: |
To delete a stream:
$ {command} STREAM --location=us-central1
request:
collection: datastream.projects.locations.streams
api_version: v1
arguments:
resource:
help_text: |
Stream resource - Stream to delete.
spec: !REF googlecloudsdk.command_lib.datastream.resources:stream

View File

@@ -0,0 +1,23 @@
- release_tracks: [BETA, GA]
BETA:
deprecate:
is_removed: false
warning: |
This command has been deprecated.
Use `gcloud datastream streams describe` instead.
help_text:
brief: Show details about a Datastream stream resource.
description: Show details about a Datastream stream resource.
examples: |
To show details about a stream, run:
$ {command} my-stream --location=us-central1
request:
collection: datastream.projects.locations.streams
api_version: v1
arguments:
resource:
help_text: The stream you want to get the details of.
spec: !REF googlecloudsdk.command_lib.datastream.resources:stream

View File

@@ -0,0 +1,37 @@
- release_tracks: [BETA, GA]
BETA:
deprecate:
is_removed: false
warning: |
This command has been deprecated.
Use `gcloud datastream streams list` instead.
help_text:
brief: List Datastream stream resources.
description: List Datastream stream resources.
examples: |
To list all streams in a project and location 'us-central1', run:
$ {command} --location=us-central1
request:
collection: datastream.projects.locations.streams
api_version: v1
response:
id_field: name
arguments:
resource:
help_text: The location you want to list the streams for.
spec: !REF googlecloudsdk.command_lib.datastream.resources:location
output:
format: |
table(
displayName:label=NAME,
state:label=STATE,
sourceConfig.sourceConnectionProfile:label=SOURCE,
destinationConfig.destinationConnectionProfile:label=DESTINATION,
createTime,
updateTime
)

View File

@@ -0,0 +1,139 @@
# -*- 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 update a Datastream Stream."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.datastream import streams
from googlecloudsdk.api_lib.datastream import util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.datastream import flags
from googlecloudsdk.command_lib.datastream import resource_args
from googlecloudsdk.command_lib.datastream.streams import flags as streams_flags
DESCRIPTION = """\
Update a Datastream stream. If successful, the response body contains a newly created instance of Operation.
To get the operation result, call: describe OPERATION
"""
EXAMPLES = """\
To update a stream with a new source and new display name:
$ {command} STREAM --location=us-central1 --display-name=my-stream --source=source --update-mask=display_name,source
To update a stream's state to RUNNING:
$ {command} STREAM --location=us-central1 --state=RUNNING --update-mask=state
To update a stream's oracle source config:
$ {command} STREAM --location=us-central1 --oracle-source-config=good_oracle_cp.json --update-mask=oracle_source_config.include_objects
"""
EXAMPLES_BETA = """\
To update a stream with a new source and new display name:
$ {command} STREAM --location=us-central1 --display-name=my-stream --source-name=source --update-mask=display_name,source_name
To update a stream's state to RUNNING:
$ {command} STREAM --location=us-central1 --state=RUNNING --update-mask=state
To update a stream's oracle source config:
$ {command} STREAM --location=us-central1 --oracle-source-config=good_oracle_cp.json --update-mask=oracle_source_config.allowlist
"""
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Update(base.Command):
"""Updates a Datastream stream."""
detailed_help = {'DESCRIPTION': DESCRIPTION, 'EXAMPLES': EXAMPLES}
@staticmethod
def CommonArgs(parser, release_track):
"""Common arguments for all release tracks.
Args:
parser: An argparse parser that you can use to add arguments that go on
the command line after this command. Positional arguments are allowed.
release_track: Some arguments are added based on the command release
track.
"""
resource_args.AddStreamResourceArg(
parser, 'update', release_track, required=False)
streams_flags.AddUpdateMaskFlag(parser)
streams_flags.AddDisplayNameFlag(parser, required=False)
streams_flags.AddBackfillStrategyGroup(parser, required=False)
streams_flags.AddValidationGroup(parser, 'Update')
streams_flags.AddStateFlag(parser)
streams_flags.AddRuleSetsFlag(parser)
flags.AddLabelsUpdateFlags(parser)
@staticmethod
def Args(parser):
"""Args is called by calliope to gather arguments for this command."""
Update.CommonArgs(parser, base.ReleaseTrack.GA)
def Run(self, args):
"""Create a Datastream stream.
Args:
args: argparse.Namespace, The arguments that this command was invoked
with.
Returns:
A dict object representing the operations resource describing the create
operation if the create was successful.
"""
stream_ref = args.CONCEPTS.stream.Parse()
stream_client = streams.StreamsClient()
result_operation = stream_client.Update(stream_ref.RelativeName(),
self.ReleaseTrack(), args)
client = util.GetClientInstance()
messages = util.GetMessagesModule()
resource_parser = util.GetResourceParser()
operation_ref = resource_parser.Create(
'datastream.projects.locations.operations',
operationsId=result_operation.name,
projectsId=stream_ref.projectsId,
locationsId=stream_ref.locationsId)
return client.projects_locations_operations.Get(
messages.DatastreamProjectsLocationsOperationsGetRequest(
name=operation_ref.operationsId))
@base.Deprecate(
is_removed=False,
warning=('Datastream beta version is deprecated. Please use`gcloud '
'datastream streams update` command instead.')
)
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class UpdateBeta(Update):
"""Updates a Datastream stream."""
detailed_help = {'DESCRIPTION': DESCRIPTION, 'EXAMPLES': EXAMPLES_BETA}
@staticmethod
def Args(parser):
"""Args is called by calliope to gather arguments for this command."""
Update.CommonArgs(parser, base.ReleaseTrack.BETA)