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 Taxonomy 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 DataTaxonomies(base.Group):
"""Manage Dataplex Data Taxonomies."""
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-taxonomies 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 Taxonomy."""
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 Taxonomy `test-taxonomy` in location
`us-central`, run:
$ {command} test-taxonomy --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.AddDataTaxonomyResourceArg(parser,
'to add IAM policy binding to.')
iam_util.AddArgsForAddIamPolicyBinding(parser)
@gcloud_exception.CatchHTTPErrorRaiseHTTPException(
'Status code: {status_code}. {status_message}.')
def Run(self, args):
taxonomy_ref = args.CONCEPTS.data_taxonomy.Parse()
result = data_taxonomy.DataTaxonomyAddIamPolicyBinding(
taxonomy_ref, args.member, args.role)
return result

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 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 Attributes(base.Group):
"""Manage Dataplex Data Attributes."""
category = base.DATA_ANALYTICS_CATEGORY

View File

@@ -0,0 +1,60 @@
# -*- 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-taxonomies attributes 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."""
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 `test-attribute` in location
`us-central`, in Data Taxonomy 'test-taxonomy', run:
$ {command} test-attribute --project=test-project --location=us-central1 --data_taxonomy=test-datataxonomy --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.AddAttributeResourceArg(parser,
'to add IAM policy binding to.')
iam_util.AddArgsForAddIamPolicyBinding(parser)
@gcloud_exception.CatchHTTPErrorRaiseHTTPException(
'Status code: {status_code}. {status_message}.')
def Run(self, args):
data_attribute_ref = args.CONCEPTS.data_attribute.Parse()
result = data_taxonomy.DataAttributeAddIamPolicyBinding(
data_attribute_ref, args.member, args.role)
return result

View File

@@ -0,0 +1,151 @@
# -*- 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-taxonomies atttributes 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."""
detailed_help = {
'EXAMPLES':
"""\
To create Data Attribute `test-attribute` for Data Taxonomy `test-datataxonomy` in project `test-dataplex`
at location `us-central1` with description as `test description` , display name as `displayName`,
resource-readers as user:test@google.com, resource-writers as user:test@google.com, resource-owner as user:test@google.com,
data-readers as user:test@google.com and parent as `test-attribute-parent`, run:
$ {command} test-attribute-6 --location=us-central1 --project=test-dataplex'
--data_taxonomy=test-datataxonomy --description='test description'
--display-name='displayName' --resource-readers='user:test@google.com'
--resource-writers='user:test@google.com' --resource-owners='user:test@google.com'
--data-readers='user:test@google.com'
--parent='test-attribute-parent'
""",
}
@staticmethod
def Args(parser):
resource_args.AddAttributeResourceArg(parser, 'to create.')
parser.add_argument(
'--description',
required=False,
help='Description of the Data Attribute.')
parser.add_argument(
'--display-name',
required=False,
help='Display Name of the Data Attribute.')
parser.add_argument(
'--parent',
required=False,
help='Parent Data Attribute for the created Data Attribute. It can be attribute name or fully qualified attribute name.')
resource_acces_sepc = parser.add_group(
required=False,
help='Spec related to Dataplex Resource.Specified when applied to a resource (eg: Google Cloud Storage bucket, BigQuery, dataset, BigQuery table).'
)
resource_acces_sepc.add_argument(
'--resource-readers',
metavar='RESOURCE_READERS',
default=[],
required=False,
type=arg_parsers.ArgList(),
help='The set of principals to be granted reader role on the resource. Expected principal formats are user:$userEmail, group:$groupEmail'
)
resource_acces_sepc.add_argument(
'--resource-writers',
metavar='RESOURCE_WRITERS',
default=[],
required=False,
type=arg_parsers.ArgList(),
help='The set of principals to be granted writer role on the resource. Expected principal formats are user:$userEmail, group:$groupEmail'
)
resource_acces_sepc.add_argument(
'--resource-owners',
metavar='RESOURCE_OWNERS',
default=[],
required=False,
type=arg_parsers.ArgList(),
help='The set of principals to be granted owner role on the resource. Expected principal formats are user:$userEmail, group:$groupEmail'
)
dataacces_sepc = parser.add_group(
required=False,
help='Specified when applied to data stored on the resource (eg: rows,columns in BigQuery Tables).'
)
dataacces_sepc.add_argument(
'--data-readers',
metavar='DATA_READERS',
default=[],
required=False,
type=arg_parsers.ArgList(),
help='The set of principals to be granted reader role on the resource. Expected principal formats are user:$userEmail, group:$groupEmail'
)
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):
data_attribute_ref = args.CONCEPTS.data_attribute.Parse()
dataplex_client = dataplex_util.GetClientInstance()
create_req_op = dataplex_client.projects_locations_dataTaxonomies_attributes.Create(
dataplex_util.GetMessageModule(
).DataplexProjectsLocationsDataTaxonomiesAttributesCreateRequest(
dataAttributeId=data_attribute_ref.Name(),
parent=data_attribute_ref.Parent().RelativeName(),
validateOnly=args.validate_only,
googleCloudDataplexV1DataAttribute=data_taxonomy
.GenerateDataAttributeForCreateRequest(data_attribute_ref, 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 created [{0}]'
.format(data_attribute_ref))
return response
log.status.Print(
'Creating Data Attribute [{0}] with operation [{1}].'.format(
data_attribute_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.
description: |
Delete a Dataplex Data Attribute.
examples: |
To delete Data Attribute `test-attribute` for Data Taxonomy `test-datataxonomy` in project `test-dataplex` at location `us-central1`, run:
$ {command} test-attribute --location=us-central1 --project=test-dataplex --data_taxonomy=test-datataxonomy
request:
ALPHA:
api_version: v1
collection: dataplex.projects.locations.dataTaxonomies.attributes
arguments:
resource:
help_text: |
Arguments and flags that define the Dataplex Data Attribute you want to delete.
spec: !REF googlecloudsdk.command_lib.dataplex.resources:data_attribute
params:
- arg_name: etag
api_field: etag
help_text: |
etag value for particular Data Attribute resource.
async:
collection: dataplex.projects.locations.operations

View File

@@ -0,0 +1,21 @@
- release_tracks: [ALPHA]
help_text:
brief: |
Describe a Dataplex Data Attribute.
description: |
Describe a Dataplex Data Attribute.
examples: |
To Describe Data Attribute `test-attribute` for Data Taxonomy `test-datataxonomy` in project `test-dataplex` at location `us-central1`, run:
$ {command} test-attribute --location=us-central1 --project=test-dataplex --data_taxonomy=test-datataxonomy
request:
ALPHA:
api_version: v1
collection: dataplex.projects.locations.dataTaxonomies.attributes
method: get
arguments:
resource:
help_text: |
DataAttribute to describe
spec: !REF googlecloudsdk.command_lib.dataplex.resources:data_attribute

View File

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

View File

@@ -0,0 +1,21 @@
- release_tracks: [ALPHA]
help_text:
brief: List Data Attributes within provided Data Taxonomy.
description: List Data Attributes within provided Data Taxonomy.
examples: |
To List Data Attribute `test-attribute` for Data Taxonomy `test-datataxonomy` in project `test-dataplex` at location `us-central1`, run:
$ {command} test-attribute --location=us-central1 --project=test-dataplex --data_taxonomy=test-datataxonomy
request:
collection: dataplex.projects.locations.dataTaxonomies.attributes
ALPHA:
api_version: v1
response:
id_field: name
arguments:
resource:
help_text: Data Taxonomy in which to list Data Attributes.
spec: !REF googlecloudsdk.command_lib.dataplex.resources:data_taxonomy

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-taxonomies attributes 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."""
detailed_help = {
'EXAMPLES':
"""\
To remove an IAM policy binding for the role `roles/dataplex.viewer`
for the user `testuser@gmail.com` from Data Attribute `test-attribute` in location
`us-central`, in Data Taxonomy 'test-taxonomy', run:
$ {command} test-attribute --project=test-project --location=us-central1 --data_taxonomy=test-datataxonomy --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.AddAttributeResourceArg(
parser, 'to remove IAM policy binding from ')
iam_util.AddArgsForRemoveIamPolicyBinding(parser)
@gcloud_exception.CatchHTTPErrorRaiseHTTPException(
'Status code: {status_code}. {status_message}.')
def Run(self, args):
data_attribute_ref = args.CONCEPTS.data_attribute.Parse()
result = data_taxonomy.DataAttributeRemoveIamPolicyBinding(
data_attribute_ref, args.member, args.role)
return result

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-taxonomies attributes 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 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 `test-attribute` in location
`us-central`, in Data Taxonomy 'test-taxonomy', run:
$ {command} test-attribute --project=test-project --location=us-central1 --data_taxonomy=test-datataxonomy policy.json
where policy.json is the relative path to the json file.
""",
}
@staticmethod
def Args(parser):
resource_args.AddAttributeResourceArg(parser, 'to set IAM policy to.')
iam_util.AddArgForPolicyFile(parser)
@gcloud_exception.CatchHTTPErrorRaiseHTTPException(
'Status code: {status_code}. {status_message}.')
def Run(self, args):
data_attribute_ref = args.CONCEPTS.data_attribute.Parse()
result = data_taxonomy.DataAttributeSetIamPolicyFromFile(
data_attribute_ref, args.policy_file)
return result

View File

@@ -0,0 +1,162 @@
# -*- 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-taxonomies atttributes 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."""
detailed_help = {
'EXAMPLES':
"""\
To update Data Attribute `test-attribute` for Data Taxonomy `test-datataxonomy` in project `test-dataplex`
at location `us-central1` with description as `test description` , display name as `displayName`,
resource-readers as user:test@google.com, resource-writers as user:test@google.com, resource-owner as user:test@google.com run:
data-readers as user:test@google.com and parent as `test-attribute-parent`, run:
$ {command} test-attribute --location=us-central1 --project=test-dataplex'
--data_taxonomy=test-datataxonomy --description='test description'
--display-name='displayName' --resource-readers='user:test@google.com'
--resource-writers='user:test@google.com' --resource-owners='user:test@google.com'
--data-readers='user:test@google.com'
--parent='test-attribute-parent'
""",
}
@staticmethod
def Args(parser):
resource_args.AddAttributeResourceArg(parser, 'to update.')
parser.add_argument(
'--description',
required=False,
help='Description of the Data Attribute.')
parser.add_argument(
'--display-name',
required=False,
help='Display Name of the Data Attribute.')
parser.add_argument(
'--etag',
required=False,
help='etag value of the Data Attribute resource.')
parser.add_argument(
'--parent',
required=False,
help='Parent Data Attribute for the defined Data Attribute. It can be attribute name or fully qualified attribute name.')
resource_acces_sepc = parser.add_group(
required=False,
help='Spec related to Dataplex Resource.Specified when applied to a resource (eg: Google Cloud Storage bucket, BigQuery, dataset, BigQuery table).'
)
resource_acces_sepc.add_argument(
'--resource-readers',
metavar='RESOURCE_READERS',
default=[],
required=False,
type=arg_parsers.ArgList(),
help='The set of principals to be granted reader role on the resource. Expected principal formats are user:$userEmail, group:$groupEmail'
)
resource_acces_sepc.add_argument(
'--resource-writers',
metavar='RESOURCE_WRITERS',
default=[],
required=False,
type=arg_parsers.ArgList(),
help='The set of principals to be granted writer role on the resource. Expected principal formats are user:$userEmail, group:$groupEmail'
)
resource_acces_sepc.add_argument(
'--resource-owners',
metavar='RESOURCE_OWNERS',
default=[],
required=False,
type=arg_parsers.ArgList(),
help='The set of principals to be granted owner role on the resource. Expected principal formats are user:$userEmail, group:$groupEmail'
)
dataacces_sepc = parser.add_group(
required=False,
help='Specified when applied to data stored on the resource (eg: rows,columns in BigQuery Tables).'
)
dataacces_sepc.add_argument(
'--data-readers',
metavar='DATA_READERS',
default=[],
required=False,
type=arg_parsers.ArgList(),
help='The set of principals to be granted reader role on the resource. Expected principal formats are user:$userEmail, group:$groupEmail'
)
async_group = parser.add_group(
mutex=True,
required=False,
help='At most one of --async | --validate-only can be specified.')
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.GenerateAttributeUpdateMask(args)
if len(update_mask) < 1:
raise exceptions.HttpException(
'Update commands must specify at least one additional parameter to change.'
)
data_attribute_ref = args.CONCEPTS.data_attribute.Parse()
dataplex_client = dataplex_util.GetClientInstance()
update_req_op = dataplex_client.projects_locations_dataTaxonomies_attributes.Patch(
dataplex_util.GetMessageModule(
).DataplexProjectsLocationsDataTaxonomiesAttributesPatchRequest(
name=data_attribute_ref.RelativeName(),
updateMask=u','.join(update_mask),
validateOnly=args.validate_only,
googleCloudDataplexV1DataAttribute=data_taxonomy
.GenerateDataAttributeForUpdateRequest(data_attribute_ref, 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(data_attribute_ref,
details='Operation was successful.')
return response
log.status.Print(
'Updating Data Attribute [{0}] with operation [{1}].'.format(
data_attribute_ref, update_req_op.name))
return update_req_op

View File

@@ -0,0 +1,104 @@
# -*- 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-taxonomies 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 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 Taxonomy.
A Data Taxonomy represents a logical group of related Data Attributes.
"""
detailed_help = {
'EXAMPLES':
"""\
To create Data Taxonomy `test-taxonomy` in project `test-dataplex` at location `us-central1`,
with description `test description` and displayName `displayName` , run:
$ {command} test-taxonomy --location=us-central1 --project=test-dataplex --description='test description' --display-name='displayName'
""",
}
@staticmethod
def Args(parser):
resource_args.AddDataTaxonomyResourceArg(parser,
'to create.')
parser.add_argument(
'--description',
required=False,
help='Description of the Data Taxonomy.')
parser.add_argument(
'--display-name',
required=False,
help='Display Name of the Data Taxonomy.')
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):
taxonomy_ref = args.CONCEPTS.data_taxonomy.Parse()
dataplex_client = dataplex_util.GetClientInstance()
create_req_op = dataplex_client.projects_locations_dataTaxonomies.Create(
dataplex_util.GetMessageModule(
).DataplexProjectsLocationsDataTaxonomiesCreateRequest(
dataTaxonomyId=taxonomy_ref.Name(),
parent=taxonomy_ref.Parent().RelativeName(),
validateOnly=args.validate_only,
googleCloudDataplexV1DataTaxonomy=data_taxonomy
.GenerateDataTaxonomyForCreateRequest(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 Taxonomy created in project [{0}] with location [{1}]'
.format(taxonomy_ref.projectsId,
taxonomy_ref.locationsId))
return response
log.status.Print(
'Creating Data Taxonomy [{0}] with operation [{1}].'.format(
taxonomy_ref, create_req_op.name))
return create_req_op

View File

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

View File

@@ -0,0 +1,21 @@
- release_tracks: [ALPHA]
help_text:
brief: |
Describe a Data Taxonomy.
description: |
Describe a Data Taxonomy.
Displays all details of a Data Taxonomy given a valid Data Taxonomy ID.
examples: |
To describe a Dataplex Data Taxonomy `test-taxonomy` within location `us-central1` and in project `test-project`
$ {command} test-taxonomy --location=us-central1 --project=test-project
request:
ALPHA:
api_version: v1
collection: dataplex.projects.locations.dataTaxonomies
method: get
arguments:
resource:
help_text: |
Data Taxonomies you want to describe.
spec: !REF googlecloudsdk.command_lib.dataplex.resources:data_taxonomy

View File

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

View File

@@ -0,0 +1,22 @@
- release_tracks: [ALPHA]
help_text:
brief: List Data Taxonomies.
description: List Data Taxonomies.
examples: |
To List Data Taxonomies in project `test-dataplex` at location `us-central1`
$ {command} --location=us-central1 --project=test-dataplex
request:
collection: dataplex.projects.locations.dataTaxonomies
ALPHA:
api_version: v1
response:
id_field: name
arguments:
resource:
help_text: Location in which to list Data Taxonomies.
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-taxonomies 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)
class RemoveIamPolicyBinding(base.Command):
"""Removes IAM policy binding from a Dataplex Data Taxonomy."""
detailed_help = {
'EXAMPLES':
"""\
To remove an IAM policy binding for the role `roles/dataplex.viewer`
for the user `testuser@gmail.com` from an taxonomy `test-taxonomy` within projet
`test-project` in location `us-central1`, run:
$ {command} test-taxonomy --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.AddDataTaxonomyResourceArg(
parser, 'to remove IAM policy binding from ')
iam_util.AddArgsForRemoveIamPolicyBinding(parser)
@gcloud_exception.CatchHTTPErrorRaiseHTTPException(
'Status code: {status_code}. {status_message}.')
def Run(self, args):
taxonomy_ref = args.CONCEPTS.data_taxonomy.Parse()
result = data_taxonomy.DataTaxonomyRemoveIamPolicyBinding(
taxonomy_ref, args.member, args.role)
return result

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-taxonomies 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)
class SetIamPolicy(base.Command):
"""Set an IAM policy binding for a Dataplex Data Taxonomy 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 Taxonomy `test-taxonomy` within
project `test-project` in location `us-central1`:
$ {command} test-taxonomy --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.AddDataTaxonomyResourceArg(parser, 'to set IAM policy to.')
iam_util.AddArgForPolicyFile(parser)
@gcloud_exception.CatchHTTPErrorRaiseHTTPException(
'Status code: {status_code}. {status_message}.')
def Run(self, args):
taxonomy_ref = args.CONCEPTS.data_taxonomy.Parse()
result = data_taxonomy.DataTaxonomySetIamPolicyFromFile(
taxonomy_ref, args.policy_file)
return result

View File

@@ -0,0 +1,108 @@
# -*- 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-taxonomies 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 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 Taxonomy."""
detailed_help = {
'EXAMPLES':
"""\
To update Data Taxonomy `test-taxonomy` in project `test-dataplex` at location `us-central1`,
with description `updated description` and displayName `displayName`
$ {command} test-taxonomy --location=us-central1 --project=test-dataplex --description='updated description'
""",
}
@staticmethod
def Args(parser):
resource_args.AddDataTaxonomyResourceArg(parser,
'to update.')
parser.add_argument(
'--description',
required=False,
help='Description of the Data Taxonomy.')
parser.add_argument(
'--display-name',
required=False,
help='Display Name of the Data Taxonomy.')
parser.add_argument(
'--etag',
required=False,
help='etag value for particular Data Taxonomy.')
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.GenerateUpdateMask(args)
if len(update_mask) < 1:
raise exceptions.HttpException(
'Update commands must specify at least one additional parameter to change.'
)
taxonomy_ref = args.CONCEPTS.data_taxonomy.Parse()
dataplex_client = dataplex_util.GetClientInstance()
update_req_op = dataplex_client.projects_locations_dataTaxonomies.Patch(
dataplex_util.GetMessageModule(
).DataplexProjectsLocationsDataTaxonomiesPatchRequest(
name=taxonomy_ref.RelativeName(),
validateOnly=args.validate_only,
updateMask=u','.join(update_mask),
googleCloudDataplexV1DataTaxonomy=data_taxonomy
.GenerateDataTaxonomyForUpdateRequest(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(taxonomy_ref, details='Operation was successful.')
return response
log.status.Print(
'Updating Data Taxonomy [{0}] with operation [{1}].'.format(
taxonomy_ref, update_req_op.name))
return update_req_op