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 2025 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.
"""Manage BigLake Iceberg REST catalogs."""
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.DefaultUniverseOnly
class Catalogs(base.Group):
"""Manage BigLake Iceberg REST catalogs."""

View File

@@ -0,0 +1,84 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""The create command for BigLake Iceberg REST catalogs."""
import textwrap
from googlecloudsdk.api_lib.biglake import util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.biglake import flags
from googlecloudsdk.core import log
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
@base.DefaultUniverseOnly
class CreateCatalog(base.CreateCommand):
"""Create a BigLake Iceberg REST catalog."""
detailed_help = {
'EXAMPLES':
textwrap.dedent("""\
To add a catalog using a GCS bucket `my-catalog-bucket`, run:
$ {command} my-catalog-bucket --catalog-type=gcs-bucket
To create a catalog using a GCS bucket `my-catalog-bucket` with vended credentials, run:
$ {command} my-catalog-bucket --catalog-type=gcs-bucket --credential-mode=vended-credentials
"""),
}
@staticmethod
def Args(parser):
flags.AddCatalogResourceArg(parser, 'to create')
util.GetCredentialModeEnumMapper(
base.ReleaseTrack.ALPHA
).choice_arg.AddToParser(parser)
util.GetCatalogTypeEnumMapper(
base.ReleaseTrack.ALPHA
).choice_arg.AddToParser(parser)
def Run(self, args):
client = util.GetClientInstance(self.ReleaseTrack())
messages = client.MESSAGES_MODULE
catalog_name = util.GetCatalogName(args.catalog)
credential_mode = None
if args.IsSpecified('credential_mode'):
credential_mode = util.GetCredentialModeEnumMapper(
self.ReleaseTrack()
).GetEnumForChoice(args.credential_mode)
catalog = messages.IcebergCatalog(
name=catalog_name,
catalog_type=util.GetCatalogTypeEnumMapper(
self.ReleaseTrack()
).GetEnumForChoice(args.catalog_type),
credential_mode=credential_mode,
)
request = (
messages.BiglakeIcebergV1RestcatalogExtensionsProjectsCatalogsCreateRequest(
iceberg_catalog_id=args.catalog,
icebergCatalog=catalog,
parent=util.GetParentName(),
)
)
log.CreatedResource(catalog_name, 'catalog')
return client.iceberg_v1_restcatalog_extensions_projects_catalogs.Create(
request
)

View File

@@ -0,0 +1,48 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""The delete command for BigLake Iceberg REST catalogs."""
from googlecloudsdk.api_lib.biglake import util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.biglake import flags
from googlecloudsdk.core import log
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
@base.DefaultUniverseOnly
class DeleteCatalog(base.DeleteCommand):
"""Delete a BigLake Iceberg REST catalog."""
@staticmethod
def Args(parser):
flags.AddCatalogResourceArg(parser, 'to delete')
def Run(self, args):
client = util.GetClientInstance(self.ReleaseTrack())
messages = util.GetMessagesModule(self.ReleaseTrack())
catalog_name = util.GetCatalogName(args.catalog)
request = messages.BiglakeIcebergV1RestcatalogExtensionsProjectsCatalogsDeleteRequest(
name=catalog_name
)
response = (
client.iceberg_v1_restcatalog_extensions_projects_catalogs.Delete(
request
)
)
log.DeletedResource(catalog_name, 'catalog')
return response

View File

@@ -0,0 +1,43 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""The describe command for BigLake Iceberg REST catalogs."""
from googlecloudsdk.api_lib.biglake import util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.biglake import flags
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
@base.DefaultUniverseOnly
class DescribeCatalog(base.DescribeCommand):
"""Describe a BigLake Iceberg REST catalog."""
@staticmethod
def Args(parser):
flags.AddCatalogResourceArg(parser, 'to describe')
def Run(self, args):
client = util.GetClientInstance(self.ReleaseTrack())
messages = client.MESSAGES_MODULE
catalog_name = util.GetCatalogName(args.catalog)
request = messages.BiglakeIcebergV1RestcatalogExtensionsProjectsCatalogsGetRequest(
name=catalog_name
)
return client.iceberg_v1_restcatalog_extensions_projects_catalogs.Get(
request
)

View File

@@ -0,0 +1,95 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""The update command for BigLake Iceberg REST catalogs."""
from googlecloudsdk.calliope import arg_parsers
from googlecloudsdk.api_lib.biglake import util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.biglake import flags
from googlecloudsdk.core import log
from googlecloudsdk.core.util import times
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
@base.DefaultUniverseOnly
class Failover(base.Command):
"""Failover a BigLake Iceberg REST catalog."""
@staticmethod
def Args(parser):
flags.AddCatalogResourceArg(parser, 'to failover')
parser.add_argument(
'--primary-replica',
required=True,
help='The primary replica region to failover to.',
)
parser.add_argument(
'--validate-only',
required=False,
action='store_true',
help='If true, the failover will be validated but not executed.',
)
parser.add_argument(
'--conditional-failover-replication-time',
required=False,
type=arg_parsers.Datetime.ParseUtcTime,
help=(
'If not specified, wait for all data from the source region to'
' replicate to the new primary region before completing the'
' failover, with no data loss. If specified, the failover will be'
' executed immediately, accepting data loss of any data commited'
' after the specified timestamp. This timestamp must be in UTC'
' format, e.g. "2025-10-09T01:13:34.038262Z". See `$ gcloud topic'
' datetimes` for more information.'
),
)
def Run(self, args):
client = util.GetClientInstance(self.ReleaseTrack())
messages = client.MESSAGES_MODULE
catalog_name = util.GetCatalogName(args.catalog)
failover_request = messages.FailoverIcebergCatalogRequest(
primaryReplica=args.primary_replica,
)
if args.IsSpecified('validate_only'):
failover_request.validateOnly = args.validate_only
if args.IsSpecified('conditional_failover_replication_time'):
failover_request.conditionalFailoverReplicationTime = (
times.FormatDateTime(args.conditional_failover_replication_time)
)
request = messages.BiglakeIcebergV1RestcatalogExtensionsProjectsCatalogsFailoverRequest(
name=catalog_name,
failoverIcebergCatalogRequest=failover_request,
)
response = (
client.iceberg_v1_restcatalog_extensions_projects_catalogs.Failover(
request
)
)
if args.validate_only:
log.UpdatedResource(
catalog_name,
details=f'Failover to [{args.primary_replica}] validated.',
)
else:
log.UpdatedResource(
catalog_name,
details=f'Failover to [{args.primary_replica}] initiated.',
)
return response

View File

@@ -0,0 +1,58 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 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 get the IAM policy for a BigLake Iceberg REST catalog."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.biglake import util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.biglake import flags
from googlecloudsdk.core import properties
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
@base.DefaultUniverseOnly
class GetIamPolicy(base.ListCommand):
"""Get the IAM policy for a BigLake Iceberg REST catalog."""
detailed_help = {
'DESCRIPTION': 'Gets the IAM policy for a BigLake Iceberg REST catalog.',
'EXAMPLES': """\
To get the IAM policy for the catalog `my-catalog` run:
$ {command} my-catalog
""",
}
@staticmethod
def Args(parser):
flags.AddCatalogResourceArg(parser, 'to get the IAM policy for')
base.URI_FLAG.RemoveFromParser(parser)
def Run(self, args):
"""This is what gets called when the user runs this command."""
client = util.GetClientInstance(self.ReleaseTrack())
messages = util.GetMessagesModule(self.ReleaseTrack())
project = args.project or properties.VALUES.core.project.Get(required=True)
catalog_name = f'projects/{project}/catalogs/{args.catalog}'
return client.projects_catalogs.GetIamPolicy(
messages.BiglakeProjectsCatalogsGetIamPolicyRequest(
resource=catalog_name
)
)

View File

@@ -0,0 +1,55 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""The list command for BigLake Iceberg REST catalogs."""
from googlecloudsdk.api_lib.biglake import util
from googlecloudsdk.calliope import base
def _GetUriFunction(resource):
return util.GetCatalogRef(resource.name).SelfLink()
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
@base.DefaultUniverseOnly
class ListIcebergCatalogs(base.ListCommand):
"""List BigLake Iceberg REST catalogs."""
@staticmethod
def Args(parser):
parser.display_info.AddFormat("""
table(
name:sort=1,
name.basename():label=CATALOG-ID,
catalog-type,
storage-regions,
replicas
)
""")
parser.display_info.AddUriFunc(_GetUriFunction)
def Run(self, args):
client = util.GetClientInstance(self.ReleaseTrack())
messages = client.MESSAGES_MODULE
parent_name = util.GetParentName()
request = messages.BiglakeIcebergV1RestcatalogExtensionsProjectsCatalogsListRequest(
parent=parent_name
)
response = client.iceberg_v1_restcatalog_extensions_projects_catalogs.List(
request
)
return response.iceberg_catalogs

View File

@@ -0,0 +1,60 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 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 set the IAM policy for a BigLake Iceberg REST catalog."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.biglake import util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.biglake import flags
from googlecloudsdk.command_lib.iam import iam_util
from googlecloudsdk.core import properties
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
@base.DefaultUniverseOnly
class SetIamPolicy(base.Command):
"""Set the IAM policy for a BigLake Iceberg REST catalog."""
detailed_help = {
'DESCRIPTION': 'Sets the IAM policy for a BigLake Iceberg REST catalog.',
'EXAMPLES': """\
To set the IAM policy for the catalog `my-catalog` with the policy in `policy.json` run:
$ {command} my-catalog policy.json
""",
}
@staticmethod
def Args(parser):
flags.AddCatalogResourceArg(parser, 'to set the IAM policy for')
iam_util.AddArgForPolicyFile(parser)
def Run(self, args):
"""This is what gets called when the user runs this command."""
client = util.GetClientInstance(self.ReleaseTrack())
messages = util.GetMessagesModule(self.ReleaseTrack())
project = args.project or properties.VALUES.core.project.Get(required=True)
catalog_name = f'projects/{project}/catalogs/{args.catalog}'
policy = iam_util.ParsePolicyFile(args.policy_file, messages.Policy)
return client.projects_catalogs.SetIamPolicy(
messages.BiglakeProjectsCatalogsSetIamPolicyRequest(
resource=catalog_name,
setIamPolicyRequest=messages.SetIamPolicyRequest(policy=policy),
)
)

View File

@@ -0,0 +1,64 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""The update command for BigLake Iceberg REST catalogs."""
from googlecloudsdk.api_lib.biglake import util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.biglake import flags
from googlecloudsdk.core import log
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
@base.DefaultUniverseOnly
class UpdateCatalog(base.UpdateCommand):
"""Update a BigLake Iceberg REST catalog."""
@staticmethod
def Args(parser):
flags.AddCatalogResourceArg(parser, 'to update')
util.GetCredentialModeEnumMapper(
base.ReleaseTrack.ALPHA
).choice_arg.AddToParser(parser)
def Run(self, args):
client = util.GetClientInstance(self.ReleaseTrack())
messages = client.MESSAGES_MODULE
catalog_name = util.GetCatalogName(args.catalog)
update_mask = []
credential_mode = None
if args.IsSpecified('credential_mode'):
update_mask.append('credential_mode')
credential_mode = util.GetCredentialModeEnumMapper(
self.ReleaseTrack()
).GetEnumForChoice(args.credential_mode)
catalog_type_enum = messages.IcebergCatalog.CatalogTypeValueValuesEnum
catalog = messages.IcebergCatalog(
name=catalog_name,
catalog_type=catalog_type_enum.CATALOG_TYPE_GCS_BUCKET,
credential_mode=credential_mode,
)
request = messages.BiglakeIcebergV1RestcatalogExtensionsProjectsCatalogsPatchRequest(
name=catalog_name,
icebergCatalog=catalog,
updateMask=','.join(update_mask),
)
log.UpdatedResource(catalog_name, 'catalog')
return client.iceberg_v1_restcatalog_extensions_projects_catalogs.Patch(
request
)