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 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 group for Dataplex Zone Resource."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.GA)
class Zones(base.Group):
"""Manage Dataplex Zone resources."""
category = base.DATA_ANALYTICS_CATEGORY

View File

@@ -0,0 +1,28 @@
# -*- 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 group for Dataplex Zone Resource."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.GA)
class Actions(base.Group):
"""Manage Dataplex zone resource actions."""
category = base.DATA_ANALYTICS_CATEGORY

View File

@@ -0,0 +1,35 @@
- release_tracks: [ALPHA, GA]
help_text:
brief: |
List Dataplex zone actions.
description: |
List all Dataplex Actions under a specific zone.
examples: |
To list all actions of a Dataplex zone `test-zone` defined in project `test-project` in
location `us-central1` with lake `test-lake`, run:
$ {command} --project=test-project --location=us-central1 --lake=test-lake --zone=test-zone
command_type: LIST
request:
ALPHA:
api_version: v1
collection: dataplex.projects.locations.lakes.zones.actions
arguments:
resource:
help_text: |
Arguments and flags that define the Dataplex zone Actions you want to list.
override_resource_collection: true
spec: !REF googlecloudsdk.command_lib.dataplex.resources:zone
response:
id_field: name
output:
format: |
table(
name.basename():label=NAME,
data_locations:label=DATA_LOCATION,
category: label=CATEGORY,
issue:label=ISSUE
)

View File

@@ -0,0 +1,57 @@
# -*- coding: utf-8 -*- #
# Copyright 2021 Google Inc. 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 add-iam-policy-binding to a Dataplex zone resource."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.dataplex import zone
from googlecloudsdk.api_lib.util import exceptions as gcloud_exception
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.dataplex import resource_args
from googlecloudsdk.command_lib.iam import iam_util
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.GA)
class AddIamPolicyBinding(base.Command):
"""Add IAM policy binding to a Dataplex zone resource."""
detailed_help = {
'EXAMPLES':
"""\
To add an IAM policy binding for the role of `roles/dataplex.viewer`
for the user `test-user@gmail.com` to zone `test-zone` within lake
`test-lake` in location `us-central`, run:
$ {command} test-zone --location=us-central1 --lake=test-lake --role=roles/dataplex.viewer --member=user:foo@gmail.com
See https://cloud.google.com/dataplex/docs/iam-roles for details of
policy role and member types.
""",
}
@staticmethod
def Args(parser):
resource_args.AddZoneResourceArg(parser, 'to add IAM policy binding to.')
iam_util.AddArgsForAddIamPolicyBinding(parser)
@gcloud_exception.CatchHTTPErrorRaiseHTTPException(
'Status code: {status_code}. {status_message}.')
def Run(self, args):
zone_ref = args.CONCEPTS.zone.Parse()
result = zone.AddIamPolicyBinding(zone_ref, args.member, args.role)
return result

View File

@@ -0,0 +1,142 @@
# -*- coding: utf-8 -*- #
# Copyright 2021 Google Inc. 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 Dataplex zone resource."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.dataplex import util as dataplex_util
from googlecloudsdk.api_lib.dataplex import zone
from googlecloudsdk.api_lib.util import exceptions as gcloud_exception
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.dataplex import flags
from googlecloudsdk.command_lib.dataplex import resource_args
from googlecloudsdk.command_lib.util.apis import arg_utils
from googlecloudsdk.command_lib.util.args import labels_util
from googlecloudsdk.core import log
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.GA)
class Create(base.Command):
"""Create a zone.
A zone represents a logical group of related assets within a lake. A zone can
be used to map to organizational structure or represent stages of data
readiness from raw to curated. It provides managing behavior that is shared
or inherited by all contained assets.
The Zone ID is used to generate names such as database and dataset names
when publishing metadata to Hive Metastore and BigQuery.
* Must contain only lowercase letters, numbers, and hyphens.
* Must start with a letter.
* Must end with a number or a letter.
* Must be between 1-63 characters.
* Must be unique across all lakes from all locations in a project.
"""
detailed_help = {
'EXAMPLES':
"""\
To create a Dataplex zone with name `test-zone` within lake
`test-lake` in location `us-central1` with type `RAW`, and resource
location type `SINGLE_REGION`, run:
$ {command} test-zone --location=us-central --lake=test-lake --resource-location-type=SINGLE_REGION --type=RAW
To create a Dataplex zone with name `test-zone` within lake
`test-lake` in location `us-central1` with type `RAW`,resource
location type `SINGLE_REGION` with discovery-enabled and discovery
schedule `0 * * * *`, run:
$ {command} test-zone --location=us-central --lake=test-lake --resource-location-type=SINGLE_REGION --type=RAW --discovery-enabled --discovery-schedule="0 * * * *"
""",
}
@staticmethod
def Args(parser):
resource_args.AddZoneResourceArg(parser, 'to create.')
parser.add_argument(
'--validate-only',
action='store_true',
default=False,
help='Validate the create action, but don\'t actually perform it.')
parser.add_argument('--description', help='Description of the zone.')
parser.add_argument('--display-name', help='Display name of the zone.')
parser.add_argument(
'--type',
choices={
'RAW':
"""A zone that contains data that needs further processing
before it is considered generally ready for consumption and
analytics workloads.""",
'CURATED':
"""A zone that contains data that is considered to be ready for
broader consumption and analytics workloads. Curated
structured data stored in Cloud Storage must conform to
certain file formats (Parquet, Avro, and Orc) and organized
in a hive-compatible directory layout.""",
},
type=arg_utils.ChoiceToEnumName,
help='Type',
required=True)
flags.AddDiscoveryArgs(parser)
resource_spec = parser.add_group(
required=True,
help='Settings for resources attached as assets within a zone.')
resource_spec.add_argument(
'--resource-location-type',
choices={
'SINGLE_REGION':
'Resources that are associated with a single region.',
'MULTI_REGION':
'Resources that are associated with a multi-region location.'
},
type=arg_utils.ChoiceToEnumName,
help='Location type of the resources attached to a zone',
required=True)
base.ASYNC_FLAG.AddToParser(parser)
labels_util.AddCreateLabelsFlags(parser)
@gcloud_exception.CatchHTTPErrorRaiseHTTPException(
'Status code: {status_code}. {status_message}.')
def Run(self, args):
zone_ref = args.CONCEPTS.zone.Parse()
dataplex_client = dataplex_util.GetClientInstance()
create_req_op = dataplex_client.projects_locations_lakes_zones.Create(
dataplex_util.GetMessageModule(
).DataplexProjectsLocationsLakesZonesCreateRequest(
zoneId=zone_ref.Name(),
parent=zone_ref.Parent().RelativeName(),
validateOnly=args.validate_only,
googleCloudDataplexV1Zone=zone.GenerateZoneForCreateRequest(args)))
validate_only = getattr(args, 'validate_only', False)
if validate_only:
log.status.Print('Validation complete.')
return
async_ = getattr(args, 'async_', False)
if not async_:
zone.WaitForOperation(create_req_op)
log.CreatedResource(
zone_ref.Name(),
details='Zone created in [{0}]'
.format(zone_ref.Parent().RelativeName()))
return
log.status.Print('Creating [{0}] with operation [{1}].'.format(
zone_ref, create_req_op.name))

View File

@@ -0,0 +1,21 @@
- release_tracks: [ALPHA, GA]
help_text:
brief: |
Delete a Dataplex zone resource.
description: |
Delete a Dataplex zone resource.
examples: |
To delete a Dataplex zone `test-zone` within lake `test-lake` in location `us-central1`, run:
$ {command} test-lake --location=us-central1 --lake=test-lake
request:
ALPHA:
api_version: v1
collection: dataplex.projects.locations.lakes.zones
arguments:
resource:
help_text: |
Arguments and flags that define the Dataplex zone you want to delete.
spec: !REF googlecloudsdk.command_lib.dataplex.resources:zone
async:
collection: dataplex.projects.locations.operations

View File

@@ -0,0 +1,21 @@
- release_tracks: [ALPHA, GA]
help_text:
brief: |
Describe a Dataplex zone resource.
description: |
Displays all details of a Dataplex zone resource given a valid zone ID.
examples: |
To describe a Dataplex zone `test-zone` within lake `test-lake` in location `us-central1`,
run:
$ {command} test-zone --location=us-central1 --lake=test-lake
request:
ALPHA:
api_version: v1
collection: dataplex.projects.locations.lakes.zones
method: get
arguments:
resource:
help_text: |
Arguments and flags that define the Dataplex zones you want to retrieve.
spec: !REF googlecloudsdk.command_lib.dataplex.resources:zone

View File

@@ -0,0 +1,24 @@
- release_tracks: [ALPHA, GA]
help_text:
brief: |
Get the IAM policy for a Dataplex zone resource.
description: |
Displays the IAM policy associated with a Dataplex zone
resource. If formatted as JSON, the output can be edited and used as
a policy file for *set-iam-policy*. The output includes an "etag"
field identifying the version emitted and allowing detection of
concurrent policy updates.
examples: |
To print the IAM policy for Dataplex zone `test-zone` within lake `test-lake` in location
`us-central1`, run:
$ {command} test-zone --location=us-central1 --lake=test-lake
request:
ALPHA:
api_version: v1
collection: dataplex.projects.locations.lakes.zones
arguments:
resource:
help_text: |
Arguments and flags that define the Dataplex zone IAM policy you want to retrieve.
spec: !REF googlecloudsdk.command_lib.dataplex.resources:zone

View File

@@ -0,0 +1,35 @@
- release_tracks: [ALPHA, GA]
help_text:
brief: |
List Dataplex zone resources under a lake.
description: |
List Dataplex zone resource under a specific project. location, and lake.
examples: |
To list all Dataplex zone resources within lake `test-lake` in location `us-central`, run:
$ {command} --location=us-central1 --lake=test-lake
request:
ALPHA:
api_version: v1
collection: dataplex.projects.locations.lakes.zones
arguments:
resource:
help_text: |
Arguments and flags that define the Dataplex zone you want to list.
spec: !REF googlecloudsdk.command_lib.dataplex.resources:lake
response:
id_field: name
output:
format: |
table(
name.basename():label=NAME,
displayName:label=DISPLAY_NAME,
state:label=ZONE_STATUS,
type:label=ZONE_TYPE,
resourceSpec.locationType:label=RESOURCE_LOCATION_TYPE,
discoverySpec.enabled:label=DISCOVERY_ENABLED,
securityStatus.state:label=SECURITY_STATUS,
assetStatus.activeAssets:label=ACTIVE_ASSETS,
labels:label=LABELS
)

View File

@@ -0,0 +1,59 @@
# -*- coding: utf-8 -*- #
# Copyright 2021 Google Inc. 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 remove-iam-policy-binding from a Dataplex zone resource."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.dataplex import zone
from googlecloudsdk.api_lib.util import exceptions as gcloud_exception
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.dataplex import resource_args
from googlecloudsdk.command_lib.iam import iam_util
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.GA)
class RemoveIamPolicyBinding(base.Command):
"""Remove IAM policy binding from a Dataplex zone resource."""
detailed_help = {
'EXAMPLES':
"""\
To remove an IAM policy binding for the role `roles/dataplex.viewer`
for the user `test-user@gmail.com` from zone `test-zone` in lake
`test-lake` in location `us-central`, run:
$ {command} test-zone --location=us-central1 --lake=test-lake --role=roles/dataplex.viewer --member=user:foo@gmail.com
See https://cloud.google.com/dataplex/docs/iam-roles for details of
policy role and member types.
""",
}
@staticmethod
def Args(parser):
resource_args.AddZoneResourceArg(parser,
'to remove IAM policy binding from.')
iam_util.AddArgsForRemoveIamPolicyBinding(parser)
@gcloud_exception.CatchHTTPErrorRaiseHTTPException(
'Status code: {status_code}. {status_message}.')
def Run(self, args):
zone_ref = args.CONCEPTS.zone.Parse()
result = zone.RemoveIamPolicyBinding(zone_ref, args.member, args.role)
return result

View File

@@ -0,0 +1,59 @@
# -*- coding: utf-8 -*- #
# Copyright 2021 Google Inc. 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 set-iam-policy for a Dataplex zone resource."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.dataplex import zone
from googlecloudsdk.api_lib.util import exceptions as gcloud_exception
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.dataplex import resource_args
from googlecloudsdk.command_lib.iam import iam_util
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.GA)
class SetIamPolicy(base.Command):
"""Set the IAM policy to a Dataplex zone as defined in a JSON or YAML file.
See https://cloud.google.com/iam/docs/managing-policies for details of
the policy file format and contents.
"""
detailed_help = {
'EXAMPLES':
"""\
The following command will read an IAM policy defined in a JSON file
`policy.son` and set it for the Dataplex zone `test-zone` defined in
lake `test-lake` in location `us-central1`:
$ {command} test-zone --location=us-central1 --lake=test-lake policy.json
""",
}
@staticmethod
def Args(parser):
resource_args.AddZoneResourceArg(parser, 'to set IAM policy binding to.')
iam_util.AddArgForPolicyFile(parser)
@gcloud_exception.CatchHTTPErrorRaiseHTTPException(
'Status code: {status_code}. {status_message}.')
def Run(self, args):
zone_ref = args.CONCEPTS.zone.Parse()
result = zone.SetIamPolicyFromFile(zone_ref, args.policy_file)
return result

View File

@@ -0,0 +1,91 @@
# -*- coding: utf-8 -*- #
# Copyright 2021 Google Inc. 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 Dataplex zone resource."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.dataplex import util as dataplex_util
from googlecloudsdk.api_lib.dataplex import zone
from googlecloudsdk.api_lib.util import exceptions as gcloud_exception
from googlecloudsdk.calliope import base
from googlecloudsdk.calliope import exceptions
from googlecloudsdk.command_lib.dataplex import flags
from googlecloudsdk.command_lib.dataplex import resource_args
from googlecloudsdk.command_lib.util.args import labels_util
from googlecloudsdk.core import log
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.GA)
class Update(base.Command):
"""Update a Dataplex zone resource."""
detailed_help = {
'EXAMPLES':
"""\
To update a Dataplex zone `test-zone` in lake `test-lake` in location
`us-central1` to have the display name `first-dataplex-zone` and
discovery include patterns `abc`, `def`, run:
$ {command} test-zone --location=us-central1 --lake=test-lake --display-name="first-dataplex-zone" --discovery-include-patterns=abc,def
""",
}
@staticmethod
def Args(parser):
resource_args.AddZoneResourceArg(parser, 'to update.')
parser.add_argument(
'--validate-only',
action='store_true',
default=False,
help='Validate the create action, but don\'t actually perform it.')
parser.add_argument('--description', help='Description of the zone')
parser.add_argument('--display-name', help='Display Name')
flags.AddDiscoveryArgs(parser)
base.ASYNC_FLAG.AddToParser(parser)
labels_util.AddCreateLabelsFlags(parser)
@gcloud_exception.CatchHTTPErrorRaiseHTTPException(
'Status code: {status_code}. {status_message}.')
def Run(self, args):
update_mask = zone.GenerateUpdateMask(args)
if len(update_mask) < 1:
raise exceptions.HttpException(
'Update commands must specify at least one additional parameter to change.'
)
zone_ref = args.CONCEPTS.zone.Parse()
dataplex_client = dataplex_util.GetClientInstance()
update_req_op = dataplex_client.projects_locations_lakes_zones.Patch(
dataplex_util.GetMessageModule(
).DataplexProjectsLocationsLakesZonesPatchRequest(
name=zone_ref.RelativeName(),
validateOnly=args.validate_only,
updateMask=u','.join(update_mask),
googleCloudDataplexV1Zone=zone.GenerateZoneForUpdateRequest(args)))
validate_only = getattr(args, 'validate_only', False)
if validate_only:
log.status.Print('Validation complete.')
return
async_ = getattr(args, 'async_', False)
if not async_:
zone.WaitForOperation(update_req_op)
log.UpdatedResource(zone_ref, details='Operation was sucessful.')
return
log.status.Print('Updating [{0}] with operation [{1}].'.format(
zone_ref, update_req_op.name))