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 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 group for Dataplex Data Attribute Binding services."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class DataAttributeBindings(base.Group):
"""Manage Dataplex Data Attribute Bindings."""
category = base.DATA_ANALYTICS_CATEGORY

View File

@@ -0,0 +1,61 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 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.
"""`gcloud dataplex data-attribute-bindings add-iam-policy-binding` command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.dataplex import data_taxonomy
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)
class AddIamPolicyBinding(base.Command):
"""Add IAM policy binding to a Dataplex Data Attribute Binding."""
detailed_help = {
'EXAMPLES':
"""\
To add an IAM policy binding for the role of `roles/dataplex.viewer`
for the user `test-user@gmail.com` to Data Attribute Binding `test-attribute-binding` in location
`us-central`, run:
$ {command} test-attribute-binding --project=test-project --location=us-central1 --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.AddDataAttributeBindingResourceArg(
parser, 'to add IAM policy binding to.')
iam_util.AddArgsForAddIamPolicyBinding(parser)
@gcloud_exception.CatchHTTPErrorRaiseHTTPException(
'Status code: {status_code}. {status_message}.')
def Run(self, args):
attribute_binding_ref = args.CONCEPTS.data_attribute_binding.Parse()
result = data_taxonomy.DataAttributeBindingAddIamPolicyBinding(
attribute_binding_ref, args.member, args.role)
return result

View File

@@ -0,0 +1,157 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 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.
"""`gcloud dataplex data-attribute-bindings create` command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.dataplex import data_taxonomy
from googlecloudsdk.api_lib.dataplex import util as dataplex_util
from googlecloudsdk.api_lib.util import exceptions as gcloud_exception
from googlecloudsdk.calliope import arg_parsers
from googlecloudsdk.calliope import base
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)
class Create(base.Command):
"""Create a Dataplex Data Attribute Binding."""
detailed_help = {
'EXAMPLES':
"""\
To create Data Attribute Binding `test-attribute-binding` in project
`test-dataplex` at location `us-central1` with resouce name 'testResource' and resource attributes
a1 and a2. Test column 'testColumn1' attached to attribute 'a1' and 'testColumn2' attached to attribute 'a2' , run:
$ {command} test-attribute-binding --project=test-dataplex --location=us-central1
--resource='projects/test-dataplex/locations/us-central1/lakes/my-lake/zones/test-zone/entities/testResource'
--resource-attributes='a1,a2'
--paths=name=testColumn1,attributes=a1
--paths=name=testColumn2,attributes=a2
"""
}
@staticmethod
def Args(parser):
resource_args.AddDataAttributeBindingResourceArg(parser,
'to create.')
parser.add_argument(
'--description',
required=False,
help='Description of the Data Attribute Binding.')
parser.add_argument(
'--display-name',
required=False,
help='Display Name of the Data Attribute Binding.')
parser.add_argument(
'--resource',
required=False,
help='The resource name of the resource'
' that is binded to Data Attribute.')
parser.add_argument(
'--resource-attributes',
metavar='ATTRIBUTES',
default=[],
required=False,
type=arg_parsers.ArgList(),
help='List of attributes to be associated with '
'the resource. It should be fully qualified attribute name'
)
group = parser.add_group(mutex=True, help='Creation options.')
group.add_argument(
'--paths',
metavar='PATH',
action='append',
required=False,
type=arg_parsers.ArgDict(
spec={
'name': str,
'attributes': arg_parsers.ArgList()
},
required_keys=['name', 'attributes'],
),
help='The list of paths for items within the associated resource '
'(eg. columns within a table) along with attribute bindings. '
'The args can be passed as key value pair. Supported Keys are '
'--path=name=value1,attributes=value2 '
',See https://cloud.google.com/sdk/gcloud/reference/topic/escaping for details on '
'using a delimiter other than a comma. '
'Attribute name should be fully qualified attribute name.')
group.add_argument(
'--path-file-name',
help=('The name of the JSON or YAML file to define Path '
'config from.'))
parser.add_argument(
'--path-file-format',
choices=['json', 'yaml'],
help=(
'The format of the file to create the path. '
'Specify either yaml or json. Defaults to json if not specified. '
'Will be ignored if --file-name is not specified.'))
async_group = parser.add_group(
mutex=True,
required=False)
async_group.add_argument(
'--validate-only',
action='store_true',
default=False,
help='Validate the create action, but don\'t actually perform it.')
base.ASYNC_FLAG.AddToParser(async_group)
labels_util.AddCreateLabelsFlags(parser)
@gcloud_exception.CatchHTTPErrorRaiseHTTPException(
'Status code: {status_code}. {status_message}.')
def Run(self, args):
attribute_binding_ref = args.CONCEPTS.data_attribute_binding.Parse()
dataplex_client = dataplex_util.GetClientInstance()
create_req_op = dataplex_client.projects_locations_dataAttributeBindings.Create(
dataplex_util.GetMessageModule(
).DataplexProjectsLocationsDataAttributeBindingsCreateRequest(
dataAttributeBindingId=attribute_binding_ref.Name(),
parent=attribute_binding_ref.Parent().RelativeName(),
validateOnly=args.validate_only,
googleCloudDataplexV1DataAttributeBinding=data_taxonomy
.GenerateDataAttributeBindingForCreateRequest(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_:
response = data_taxonomy.WaitForOperation(create_req_op)
log.CreatedResource(
response.name,
details='Data Attribute Binding created in project [{0}] with location [{1}]'
.format(attribute_binding_ref.projectsId,
attribute_binding_ref.locationsId))
return response
log.status.Print(
'Creating Data Attribute Binding [{0}] with operation [{1}].'.format(
attribute_binding_ref, create_req_op.name))
return create_req_op

View File

@@ -0,0 +1,28 @@
- release_tracks: [ALPHA]
help_text:
brief: |
Delete a Dataplex Data Attribute Binding.
description: |
Delete a Dataplex Data Attribute Binding.
examples: |
To Delete Data Attribute Binding `test-attribute-binding` in project `test-dataplex` at location `us-central1`, run:
${command} test-attribute-binding --project=test-dataplex --location=us-central1
request:
ALPHA:
api_version: v1
collection: dataplex.projects.locations.dataAttributeBindings
arguments:
resource:
help_text: |
Arguments and flags that define the Dataplex Attribute Binding you want to delete.
spec: !REF googlecloudsdk.command_lib.dataplex.resources:data_attribute_binding
params:
- arg_name: etag
api_field: etag
required: true
help_text: |
etag value for particular Data Attribute Binding.
async:
collection: dataplex.projects.locations.operations

View File

@@ -0,0 +1,21 @@
- release_tracks: [ALPHA]
help_text:
brief: |
Describe a Data Attribute Binding resource.
description: |
Describe a Data Attribute Binding resource.
Displays all details of a Data Attribute Binding resource given a valid DataAttributeBindingID.
examples: |
To Describe Data Attribute Binding `test-attribute-binding` in project `test-dataplex` at location `us-central1`, run:
${command} test-attribute-binding --project=test-dataplex --location=us-central1
request:
ALPHA:
api_version: v1
collection: dataplex.projects.locations.dataAttributeBindings
method: get
arguments:
resource:
help_text: |
Data Attribute Binding you want to describe.
spec: !REF googlecloudsdk.command_lib.dataplex.resources:data_attribute_binding

View File

@@ -0,0 +1,22 @@
- release_tracks: [ALPHA]
help_text:
brief: |
Retrieve a Dataplex Data Attribute Binding IAM policy.
description: |
Displays the IAM policy associated with a Dataplex Data Attribute Binding 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 get the IAM policy of a Dataplex Data Attribute Binding `test-attribute-binding` in project `test-project` under location `us-central1`
$ {command} test-attribute-binding --project=test-project --location=us-central1
request:
collection: dataplex.projects.locations.dataAttributeBindings
arguments:
resource:
help_text: |
Arguments and flags that define the Dataplex Data Attribute Binding IAM policy you want to retrieve.
spec: !REF googlecloudsdk.command_lib.dataplex.resources:data_attribute_binding

View File

@@ -0,0 +1,21 @@
- release_tracks: [ALPHA]
help_text:
brief: List Data Attribute Bindings.
description: List Data Attribute Bindings.
examples: |
To List all the Data Attribute Bindings in project `test-dataplex` at location `us-central1`, run:
${command} --project=test-dataplex --location=us-central1
request:
collection: dataplex.projects.locations.dataAttributeBindings
GA:
api_version: v1
response:
id_field: name
arguments:
resource:
help_text: Location in which to list Data Attribute Bindings.
spec: !REF googlecloudsdk.command_lib.dataplex.resources:location

View File

@@ -0,0 +1,62 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 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.
"""`gcloud dataplex data-attribute-bindings remove-iam-policy-binding` command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.dataplex import data_taxonomy
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):
"""Removes IAM policy binding from a Dataplex Data Attribute Binding."""
detailed_help = {
'EXAMPLES':
"""\
To remove an IAM policy binding for the role `roles/dataplex.viewer`
for the user `testuser@gmail.com` from an Data Attribute Binding `test-attribute-binding` within projet
`test-project` in location `us-central1`, run:
$ {command} test-attribute-binding --project=test-project --location=us-central1 --role=roles/dataplex.viewer --member=user:testuser@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.AddDataAttributeBindingResourceArg(
parser, 'to remove IAM policy binding from ')
iam_util.AddArgsForRemoveIamPolicyBinding(parser)
@gcloud_exception.CatchHTTPErrorRaiseHTTPException(
'Status code: {status_code}. {status_message}.')
def Run(self, args):
attribute_binding_ref = args.CONCEPTS.data_attribute_binding.Parse()
result = data_taxonomy.DataAttributeBindingRemoveIamPolicyBinding(
attribute_binding_ref, args.member, args.role)
return result

View File

@@ -0,0 +1,62 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 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.
"""`gcloud dataplex data-attribute-bindings set-iam-policy-binding` command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.dataplex import data_taxonomy
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 an IAM policy binding for a Dataplex Data Attribute Binding 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.json` and set it for the Dataplex Data Attribute Binding `test-attribute-binding` within
project `test-project` in location `us-central1`:
$ {command} test-attribute-binding --project=test-project --location=us-central1 policy.json
where policy.json is the relative path to the json file.
""",
}
@staticmethod
def Args(parser):
resource_args.AddDataAttributeBindingResourceArg(parser,
'to set IAM policy to.')
iam_util.AddArgForPolicyFile(parser)
@gcloud_exception.CatchHTTPErrorRaiseHTTPException(
'Status code: {status_code}. {status_message}.')
def Run(self, args):
attribute_binding_ref = args.CONCEPTS.data_attribute_binding.Parse()
result = data_taxonomy.DataAttributeBindingSetIamPolicyFromFile(
attribute_binding_ref, args.policy_file)
return result

View File

@@ -0,0 +1,157 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 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.
"""`gcloud dataplex data-attribute-bindings update` command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.dataplex import data_taxonomy
from googlecloudsdk.api_lib.dataplex import util as dataplex_util
from googlecloudsdk.api_lib.util import exceptions as gcloud_exception
from googlecloudsdk.calliope import arg_parsers
from googlecloudsdk.calliope import base
from googlecloudsdk.calliope import exceptions
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)
class Update(base.Command):
"""Update a Dataplex Data Attribute Binding."""
detailed_help = {
'EXAMPLES':
"""\
To Update Data Attribute Binding `test-attribute-binding` in project
`test-dataplex` at location `us-central1` with resource attributes
a1 and a2. Test column 'testColumn1' attached to attribute 'a1' and 'testColumn2' attached to attribute 'a2' , run:
$ {command} test-attribute-binding --project=test-dataplex --location=us-central1
--resource-attributes='a1,a2'
--paths=name=testColumn1,attributes=a1
--paths=name=testColumn2,attributes=a2
--etag=Etag_Received_From_Get
"""
}
@staticmethod
def Args(parser):
resource_args.AddDataAttributeBindingResourceArg(parser,
'to update.')
parser.add_argument(
'--description',
required=False,
help='Description of the Data Attribute Binding.')
parser.add_argument(
'--display-name',
required=False,
help='Display Name of the Data Attribute Binding.')
parser.add_argument(
'--etag',
required=True,
help='etag value of the Data Attribute Binding resource.')
parser.add_argument(
'--resource-attributes',
metavar='ATTRIBUTES',
default=[],
required=False,
type=arg_parsers.ArgList(),
help='List of Data Attributes to be associated with the resource')
group = parser.add_group(mutex=True, help='Creation options.')
group.add_argument(
'--paths',
metavar='PATH',
action='append',
required=False,
type=arg_parsers.ArgDict(
spec={
'name': str,
'attributes': arg_parsers.ArgList()
},
required_keys=['name', 'attributes'],
),
help='The list of paths for items within the associated resource '
'(eg. columns within a table) along with attribute bindings. '
'The args can be passed as key value pair. Supported Keys are '
'--path=name=value1,attributes=value2 '
',See https://cloud.google.com/sdk/gcloud/reference/topic/escaping for details on '
'using a delimiter other than a comma.')
group.add_argument(
'--path-file-name',
help=('The name of the JSON or YAML file to define Path '
'config from.'))
parser.add_argument(
'--path-file-format',
choices=['json', 'yaml'],
help=(
'The format of the file to create the path. '
'Specify either yaml or json. Defaults to yaml if not specified. '
'Will be ignored if --file-name is not specified.'))
async_group = parser.add_group(
mutex=True,
required=False)
async_group.add_argument(
'--validate-only',
action='store_true',
default=False,
help='Validate the update action, but don\'t actually perform it.')
base.ASYNC_FLAG.AddToParser(async_group)
labels_util.AddCreateLabelsFlags(parser)
@gcloud_exception.CatchHTTPErrorRaiseHTTPException(
'Status code: {status_code}. {status_message}.')
def Run(self, args):
update_mask = data_taxonomy.GenerateAttributeBindingUpdateMask(args)
if len(update_mask) < 1:
raise exceptions.HttpException(
'Update commands must specify at least one additional parameter to change.'
)
attribute_binding_ref = args.CONCEPTS.data_attribute_binding.Parse()
dataplex_client = dataplex_util.GetClientInstance()
update_req_op = dataplex_client.projects_locations_dataAttributeBindings.Patch(
dataplex_util.GetMessageModule(
).DataplexProjectsLocationsDataAttributeBindingsPatchRequest(
name=attribute_binding_ref.RelativeName(),
updateMask=u','.join(update_mask),
validateOnly=args.validate_only,
googleCloudDataplexV1DataAttributeBinding=data_taxonomy
.GenerateDataAttributeBindingForUpdateRequest(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_:
response = data_taxonomy.WaitForOperation(update_req_op)
log.UpdatedResource(attribute_binding_ref,
details='Operation was successful.')
return response
log.status.Print(
'Updating Data Attribute Binding [{0}] with operation [{1}].'.format(
attribute_binding_ref, update_req_op.name))
return update_req_op