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,27 @@
# -*- 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 Dataproc Metastore federation."""
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.BETA,
base.ReleaseTrack.GA)
class Federations(base.Group):
"""Manage Dataproc Metastore federations."""

View File

@@ -0,0 +1,32 @@
release_tracks: [ALPHA, BETA, GA]
help_text:
brief: Add an IAM policy binding to a federation.
description: |
Add an IAM policy binding to a federation.
examples: |
To add an IAM policy binding for the role of `roles/metastore.admin` for the user
`test-user@gmail.com`, run:
$ {command} my-federation --member='user:test-user@gmail.com' --role='roles/metastore.admin'
See https://cloud.google.com/dataproc-metastore/docs/iam-and-access-control for details of
policy role and member types.
request:
collection: metastore.projects.locations.federations
ALPHA:
api_version: v1alpha
BETA:
api_version: v1beta
GA:
api_version: v1
iam:
enable_condition: false
policy_version: 0
arguments:
resource:
help_text: Federation for which to add the IAM policy to.
spec: !REF googlecloudsdk.command_lib.metastore.resources:federation

View File

@@ -0,0 +1,74 @@
- release_tracks: [ALPHA, BETA, GA]
help_text:
brief: |
Create a Dataproc Metastore federation.
description: |
Create a new Dataproc Metastore federation with the given name and configurations.
If run asynchronously with `--async`, exits after printing
one operation name that can be used to poll the status of the
creation via:
{top_command} metastore operations describe
examples: |
To create a Dataproc Metastore federation with the name `my-metastore-federation` in location
`us-central` with two backends `dpms1` and `dpms2`, run:
$ {command} my-metastore-federation --location=us-central1 --backends=1=dpms:dpms1,2=dpms:projects/my-project/locations/us-central1/services/dpms2
request:
ALPHA:
api_version: v1alpha
BETA:
api_version: v1beta
GA:
api_version: v1
modify_request_hooks:
- googlecloudsdk.command_lib.metastore.federations.util:GenerateCreateBackends
collection: metastore.projects.locations.federations
arguments:
resource:
help_text: |
Arguments and flags that specify the Dataproc Metastore federation
you want to create.
spec: !REF googlecloudsdk.command_lib.metastore.resources:federation
params:
- arg_name: hive-metastore-version
api_field: federation.version
choices:
- arg_value: 3.1.2
enum_value: 3.1.2
- arg_value: 2.3.6
enum_value: 2.3.6
help_text: |
Hive metastore schema version of the Metastore federation.
- arg_name: backends
api_field: federation.backendMetastores
required: true
metavar: RANK=BACKEND
processor: googlecloudsdk.command_lib.metastore.validators:ValidateBackendsAndReturnMetastoreDict
help_text: |
Backends from which the federation service serves metadata at query time. The backends are specified as a comma-separated
list of `RANK=BACKEND` pairs.
For example: `1=dpms:dpms1,2=dpms:projects/my-project/locations/us-central1/services/dpms2`.
`RANK` represents the rank of the backend metastore and is used to resolve database name collisions.
`BACKEND` is specified as `METASTORE_TYPE:METASTORE_NAME` where `METASTORE_TYPE` is the type of backend metastore and
`METASTORE_NAME` is the relative resource name of the metastore. If only the name of the metastore is specified (e.g. `dpms1`),
project and location will be inferred from the project and location used to create the federation.
- arg_name: tags
api_field: federation.tags.additionalProperties
metavar: KEY=VALUE
help_text: |
List of tag KEY=VALUE pairs to add.
type:
arg_dict:
flatten: true
spec:
- api_field: key
- api_field: value
labels:
api_field: federation.labels
async:
collection: metastore.projects.locations.operations

View File

@@ -0,0 +1,111 @@
# -*- 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 to delete one or more Dataproc Metastore federations."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from apitools.base.py import exceptions as apitools_exceptions
from googlecloudsdk.api_lib.metastore import federations_util as federations_api_util
from googlecloudsdk.api_lib.metastore import util as api_util
from googlecloudsdk.api_lib.util import exceptions
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.metastore import delete_util
from googlecloudsdk.command_lib.metastore import resource_args
from googlecloudsdk.command_lib.metastore import util as command_util
from googlecloudsdk.core import log
from googlecloudsdk.core.console import console_io
DETAILED_HELP = {
'EXAMPLES':
"""\
To delete a Dataproc Metastore federation with the name
`my-metastore-federation` in location `us-central1`, run:
$ {command} my-metastore-federation --location=us-central1
To delete multiple Dataproc Metastore federations with the name
`federation-1` and `federation-2` in the same location
`us-central1`, run:
$ {command} federation-1 federation-2 --location=us-central1
"""
}
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA,
base.ReleaseTrack.GA)
class Delete(base.DeleteCommand):
"""Delete one or more Dataproc Metastore federations.
If run asynchronously with `--async`, exits after printing
one or more operation names that can be used to poll the status of the
deletion(s) via:
{top_command} metastore operations describe
"""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
resource_args.AddFederationResourceArg(
parser, 'to delete', plural=True, required=True, positional=True)
base.ASYNC_FLAG.AddToParser(parser)
def Run(self, args):
env_refs = args.CONCEPTS.federations.Parse()
console_io.PromptContinue(
message=command_util.ConstructList(
'Deleting the following federations:', [
'[{}] in [{}]'.format(env_ref.federationsId,
env_ref.locationsId)
for env_ref in env_refs
]),
cancel_on_no=True,
cancel_string='Deletion aborted by user.',
throw_if_unattended=True)
waiter = delete_util.FederationDeletionWaiter(
release_track=self.ReleaseTrack())
encountered_errors = False
for env_ref in env_refs:
operation = None
failed = None
try:
operation = federations_api_util.Delete(
env_ref.RelativeName(), release_track=self.ReleaseTrack())
except apitools_exceptions.HttpError as e:
exc = exceptions.HttpException(e)
failed = exc.payload.status_message
encountered_errors = True
else:
waiter.AddPendingDelete(
federation_name=env_ref.RelativeName(), operation=operation)
finally:
log.DeletedResource(
env_ref.RelativeName(),
kind='federation',
is_async=True,
details=None if encountered_errors else
'with operation [{0}]'.format(operation.name),
failed=failed)
if not args.async_:
encountered_errors = waiter.Wait() or encountered_errors
if encountered_errors:
raise api_util.FederationDeleteError(
'Some requested deletions did not succeed.')

View File

@@ -0,0 +1,29 @@
- release_tracks: [ALPHA, BETA, GA]
help_text:
brief: |
Describe a Dataproc Metastore federation.
description: |
Describe a Dataproc Metastore federation.
Displays all details of a Dataproc Metastore federation given a valid federation ID.
examples: |
To describe a Dataproc Metastore federation with the ID
`my-metastore-federation` in `us-central1`, run:
$ {command} my-metastore-federation --location=us-central1
request:
ALPHA:
api_version: v1alpha
BETA:
api_version: v1beta
GA:
api_version: v1
collection: metastore.projects.locations.federations
arguments:
resource:
spec: !REF googlecloudsdk.command_lib.metastore.resources:federation
help_text: |
Arguments and flags that specify the Metastore federation you want
to describe.

View File

@@ -0,0 +1,34 @@
release_tracks: [ALPHA, BETA, GA]
help_text:
brief: Get the IAM policy for the federation.
description: |
`{command}` displays the IAM policy associated with the federation.
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. The "etag" field should be removed to be
used as set-iam-policy input; see `{parent_command} set-iam-policy`
for additional details.
examples: |
To print the IAM policy for a given federation, run:
$ {command} my-federation
request:
collection: metastore.projects.locations.federations
ALPHA:
api_version: v1alpha
BETA:
api_version: v1beta
GA:
api_version: v1
iam:
enable_condition: false
policy_version: 0
get_iam_policy_version_path: options_requestedPolicyVersion
arguments:
resource:
help_text: Federation for which to display the IAM policy.
spec: !REF googlecloudsdk.command_lib.metastore.resources:federation

View File

@@ -0,0 +1,42 @@
- release_tracks: [ALPHA, BETA, GA]
help_text:
brief: |
List Dataproc Metastore federations.
description: |
Lists all federations under the specified project and location.
examples: |
To list all Dataproc Metastore federations in location
`us-central1`, run:
$ {command} --location=us-central1
To list all Dataproc Metastore federations in all locations,
run:
$ {command} --location=-
arguments:
resource:
help_text: The location of the federations to list.
spec: !REF googlecloudsdk.command_lib.metastore.resources:location
request:
ALPHA:
api_version: v1alpha
BETA:
api_version: v1beta
GA:
api_version: v1
collection: metastore.projects.locations.federations
response:
id_field: name
output:
format: |
table(
name.basename():label=NAME,
name.segment(3):label=LOCATION,
state:label=STATE,
endpointUri:label=URI,
version:label=METASTORE_VERSION
)

View File

@@ -0,0 +1,32 @@
release_tracks: [ALPHA, BETA, GA]
help_text:
brief: Remove an IAM policy binding from a federation.
description: |
Remove an IAM policy binding from a federation.
examples: |
To remove an IAM policy binding for the role of `roles/metastore.admin` for the user
`test-user@gmail.com`, run:
$ {command} my-federation --member='user:test-user@gmail.com' --role='roles/metastore.admin'
See https://cloud.google.com/iam/docs/managing-policies for details of
policy role and member types.
request:
collection: metastore.projects.locations.federations
ALPHA:
api_version: v1alpha
BETA:
api_version: v1beta
GA:
api_version: v1
iam:
enable_condition: false
policy_version: 0
arguments:
resource:
help_text: Federation for which to remove the IAM policy from.
spec: !REF googlecloudsdk.command_lib.metastore.resources:federation

View File

@@ -0,0 +1,33 @@
release_tracks: [ALPHA, BETA, GA]
help_text:
brief: Set the IAM policy for the federation.
description: |
Sets the IAM policy for the given federation 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.
examples: |
The following command will read an IAM policy defined in a JSON file
`policy.json` and set it for the federation `my-federation`:
$ {command} my-federation policy.json
request:
collection: metastore.projects.locations.federations
ALPHA:
api_version: v1alpha
BETA:
api_version: v1beta
GA:
api_version: v1
iam:
enable_condition: false
policy_version: 0
get_iam_policy_version_path: options.requestedPolicyVersion
arguments:
resource:
help_text: Federation for which to display the IAM policy.
spec: !REF googlecloudsdk.command_lib.metastore.resources:federation

View File

@@ -0,0 +1,72 @@
- release_tracks: [ALPHA, BETA, GA]
help_text:
brief: |
Update a Dataproc Metastore federation.
description: |
Update the metadata and/or configuration parameters of a Dataproc Metastore federation.
If run asynchronously with `--async`, exits after printing
one operation name that can be used to poll the status of the
update via:
{top_command} metastore operations describe
examples: |
To update a Dataproc Metastore federation with the name `my-metastore-federation` in location
`us-central` with two backends `dpms1` and `dpms2`, run:
$ {command} my-metastore-federation --location=us-central1 --update-backends=1=dpms:dpms1,2=dpms:projects/my-project/locations/us-central1/services/dpms2
request:
ALPHA:
api_version: v1alpha
BETA:
api_version: v1beta
GA:
api_version: v1
modify_request_hooks:
- googlecloudsdk.command_lib.metastore.validators:ValidateClearBackends
- googlecloudsdk.command_lib.metastore.federations.util:GenerateUpdateBackends
collection: metastore.projects.locations.federations
arguments:
resource:
help_text: |
Arguments and flags that specify the Dataproc Metastore federation
you want to update.
spec: !REF googlecloudsdk.command_lib.metastore.resources:federation
params:
- group:
help_text: |
Update the backend metastores by passing key-value pairs in through the flags.
required: true
params:
- arg_name: update-backends
metavar: RANK=BACKEND
api_field: federation.backendMetastores
processor: googlecloudsdk.command_lib.metastore.validators:ValidateBackendsAndReturnMetastoreDict
help_text: |
Comma-separated list of metastore backends specified as a list of `RANK=BACKEND` pairs. For example: `1=dpms:dpms1,2=dpms:projects/my-project/locations/us-central1/services/dpms2`.
`RANK` represents the rank of the backend metastore and is used to resolve database name collisions.
`BACKEND` is specified as `METASTORE_TYPE:METASTORE_NAME` where `METASTORE_TYPE` is the type of backend metastore and
`METASTORE_NAME` is the relative resource name of the metastore. If only the name of the metastore is specified (e.g. `dpms1`),
project and location will be inferred from the project and location used to create the federation.
- group:
mutex: true
params:
- arg_name: remove-backends
metavar: RANK
help_text: |
Comma-separated list of metastore backend keys to remove with the form `RANK1,RANK2`. The Key represents the rank of the backend metastore and is used to resolve database name collisions.
If a `RANK` does not exist then it is sliently ignored. If `--update-backends` is also specified, then `--remove-backends` is applied first.
- arg_name: clear-backends
action: store_true
help_text: |
Clear existing metastore backends. `--clear-backends` must be used with `--update-backends`.
labels:
api_field: federation.labels
async:
collection: metastore.projects.locations.operations
update:
read_modify_update: true
disable_auto_field_mask: true