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,33 @@
# -*- 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.
"""Commands for reading and manipulating instant snapshot groups."""
from googlecloudsdk.calliope import base
DETAILED_HELP = { # Dict[str, str]
'brief': 'Create, list and delete Compute Engine instant snapshot groups',
}
@base.UniverseCompatible
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class InstantSnapshotGroups(base.Group):
"""Create, list and delete Compute Engine instant snapshot groups."""
InstantSnapshotGroups.category = base.INSTANCES_CATEGORY
InstantSnapshotGroups.detailed_help = DETAILED_HELP

View File

@@ -0,0 +1,99 @@
# -*- 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.
"""Create instant snapshot group command."""
from googlecloudsdk.api_lib.compute import base_classes
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.compute.instant_snapshot_groups import flags as isg_flags
DETAILED_HELP = { # Dict[str, str]
'brief': 'Create an instant snapshot group.',
'DESCRIPTION': """\
*{command}* creates an instant snapshot group of the consistency group. An Instant Snapshot Group is a Point In Time view of the constituent disks of a Consistency Group, they are stored in-place as Instant Snapshots on the corresponding disks.
""",
'EXAMPLES': """\
To create an instant snapshot group 'my-instant-snapshot-group' in zone 'us-east1-a' from a consistency group 'my-consistency-group' in region 'us-east1', run:
$ {command} my-instant-snapshot-group --zone us-east1-a --source-consistency-group=regions/us-east1/resourcePolicies/policy1
""",
}
def _SourceArgs(parser):
isg_flags.AddSourceConsistencyGroupArg(parser)
def _CommonArgs(parser):
"""A helper function to build args based on different API version."""
Create.ISG_ARG = isg_flags.MakeInstantSnapshotGroupArg()
Create.ISG_ARG.AddArgument(parser, operation_type='create')
_SourceArgs(parser)
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
@base.DefaultUniverseOnly
class Create(base.Command):
"""Create a Compute Engine instant snapshot group."""
@classmethod
def Args(cls, parser):
_CommonArgs(parser)
@classmethod
def _GetApiHolder(cls, no_http=False):
return base_classes.ComputeApiHolder(cls.ReleaseTrack())
def _Run(self, args):
compute_holder = self._GetApiHolder()
client = compute_holder.client
messages = client.messages
isg_ref = Create.ISG_ARG.ResolveAsResource(args, compute_holder.resources)
requests = []
source_cg_url = getattr(args, 'source_consistency_group', None)
if isg_ref.Collection() == 'compute.instantSnapshotGroups':
instant_snapshot_group = messages.InstantSnapshotGroup(
name=isg_ref.Name(), sourceConsistencyGroup=source_cg_url
)
request = messages.ComputeInstantSnapshotGroupsInsertRequest(
instantSnapshotGroup=instant_snapshot_group,
project=isg_ref.project,
zone=isg_ref.zone,
)
request = (
client.apitools_client.instantSnapshotGroups,
'Insert',
request,
)
elif isg_ref.Collection() == 'compute.regionInstantSnapshotGroups':
instant_snapshot_group = messages.InstantSnapshotGroup(
name=isg_ref.Name(), sourceConsistencyGroup=source_cg_url,
)
request = messages.ComputeRegionInstantSnapshotGroupsInsertRequest(
instantSnapshotGroup=instant_snapshot_group,
project=isg_ref.project,
region=isg_ref.region,
)
request = (
client.apitools_client.regionInstantSnapshotGroups,
'Insert',
request,
)
requests.append(request)
return client.MakeRequests(requests)
def Run(self, args):
return self._Run(args)

View File

@@ -0,0 +1,105 @@
# -*- 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.
"""Delete instant snapshot group command."""
from googlecloudsdk.api_lib.compute import base_classes
from googlecloudsdk.api_lib.compute import utils
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.compute import flags as compute_flags
from googlecloudsdk.command_lib.compute.instant_snapshot_groups import flags as isg_flags
DETAILED_HELP = { # Dict[str, str]
'brief': 'Delete an instant snapshot group.',
}
def _CommonArgs(parser):
"""A helper function to build args based on different API version."""
Delete.ISG_ARG = isg_flags.MakeInstantSnapshotGroupArg(plural=True)
Delete.ISG_ARG.AddArgument(parser, operation_type='delete')
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
@base.DefaultUniverseOnly
class Delete(base.DeleteCommand):
"""Delete a Compute Engine instant snapshot group."""
def _GetCommonScopeNameForRefs(self, refs):
"""Gets common scope for references."""
has_zone = any(hasattr(ref, 'zone') for ref in refs)
has_region = any(hasattr(ref, 'region') for ref in refs)
if has_zone and not has_region:
return 'zone'
elif has_region and not has_zone:
return 'region'
else:
return None
def _CreateDeleteRequests(self, client, isg_refs):
"""Returns a list of delete messages for instant snapshot groups."""
messages = client.MESSAGES_MODULE
requests = []
for isg_ref in isg_refs:
if isg_ref.Collection() == 'compute.instantSnapshotGroups':
service = client.instantSnapshotGroups
request = messages.ComputeInstantSnapshotGroupsDeleteRequest(
instantSnapshotGroup=isg_ref.Name(),
project=isg_ref.project,
zone=isg_ref.zone)
elif isg_ref.Collection() == 'compute.regionInstantSnapshotGroups':
service = client.regionInstantSnapshotGroups
request = messages.ComputeRegionInstantSnapshotGroupsDeleteRequest(
instantSnapshotGroup=isg_ref.Name(),
project=isg_ref.project,
region=isg_ref.region)
else:
raise ValueError('Unknown reference type {0}'.format(
isg_ref.Collection()))
requests.append((service, 'Delete', request))
return requests
@classmethod
def Args(cls, parser):
_CommonArgs(parser)
@classmethod
def _GetApiHolder(cls, no_http=False):
return base_classes.ComputeApiHolder(cls.ReleaseTrack())
def _Run(self, args):
holder = base_classes.ComputeApiHolder(self.ReleaseTrack())
client = holder.client
isg_ref = Delete.ISG_ARG.ResolveAsResource(
args,
holder.resources,
scope_lister=compute_flags.GetDefaultScopeLister(client),
)
scope_name = self._GetCommonScopeNameForRefs(isg_ref)
utils.PromptForDeletion(isg_ref, scope_name=scope_name, prompt_title=None)
requests = list(
self._CreateDeleteRequests(client.apitools_client, isg_ref))
return client.MakeRequests(requests)
def Run(self, args):
return self._Run(args)

View File

@@ -0,0 +1,68 @@
# -*- 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.
"""Describe instant snapshot group command."""
from googlecloudsdk.api_lib.compute import base_classes
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.compute.instant_snapshot_groups import flags as isg_flags
DETAILED_HELP = { # Dict[str, str]
'brief': 'Describe a Compute Engine instant snapshot group',
'DESCRIPTION': """\
*{command}* displays all data associated with a Compute
Engine instant snapshot group in a project.
""",
'EXAMPLES': """\
To describe the instant snapshot group 'instant-snapshot-group-1' in zone 'us-east1-a', run:
$ {command} instant-snapshot-group-1 --zone=us-east1-a
""",
}
def _CommonArgs(parser):
"""A helper function to build args based on different API version."""
Describe.ISG_ARG = isg_flags.MakeInstantSnapshotGroupArg()
Describe.ISG_ARG.AddArgument(parser, operation_type='describe')
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
@base.DefaultUniverseOnly
class Describe(base.DescribeCommand):
"""Describe a Compute Engine instant snapshot group."""
@classmethod
def Args(cls, parser):
_CommonArgs(parser)
def _Run(self, args):
holder = base_classes.ComputeApiHolder(self.ReleaseTrack())
client = holder.client
messages = client.messages
isg_ref = Describe.ISG_ARG.ResolveAsResource(args, holder.resources)
if isg_ref.Collection() == 'compute.instantSnapshotGroups':
service = client.apitools_client.instantSnapshotGroups
request_type = messages.ComputeInstantSnapshotGroupsGetRequest
else:
service = client.apitools_client.regionInstantSnapshotGroups
request_type = messages.ComputeRegionInstantSnapshotGroupsGetRequest
return client.MakeRequests([(service, 'Get',
request_type(**isg_ref.AsDict()))])
def Run(self, args):
return self._Run(args)

View File

@@ -0,0 +1,68 @@
# -*- 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 for listing Compute Engine instant snapshot groups."""
from googlecloudsdk.api_lib.compute import base_classes
from googlecloudsdk.api_lib.compute import lister
from googlecloudsdk.api_lib.compute import utils
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.compute import completers
from googlecloudsdk.command_lib.compute.instant_snapshot_groups import flags as isg_flags
def _CommonArgs(parser):
parser.display_info.AddFormat(isg_flags.MULTISCOPE_LIST_FORMAT)
parser.display_info.AddUriFunc(utils.MakeGetUriFunc())
lister.AddMultiScopeListerFlagsIsg(parser, zonal=True, regional=True)
parser.display_info.AddCacheUpdater(completers.InstantSnapshotGroupsCompleter)
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
@base.DefaultUniverseOnly
class List(base.ListCommand):
"""List Compute Engine instant snapshot groups.
This command lists all Compute Engine instant snapshot groups in a project in
the provided zone/region.
"""
@classmethod
def Args(cls, parser):
_CommonArgs(parser)
def _Run(self, args):
holder = base_classes.ComputeApiHolder(self.ReleaseTrack())
client = holder.client
request_data = lister.ParseMultiScopeFlags(args, holder.resources)
list_implementation = lister.MultiScopeLister(
client,
zonal_service=client.apitools_client.instantSnapshotGroups,
regional_service=client.apitools_client.regionInstantSnapshotGroups,
aggregation_service=client.apitools_client.instantSnapshotGroups)
return lister.Invoke(request_data, list_implementation)
def Run(self, args):
return self._Run(args)
List.detailed_help = base_classes.GetMultiScopeListerHelp(
'instant snapshot groups',
scopes=[
base_classes.ScopeType.zonal_scope,
base_classes.ScopeType.regional_scope,
],
)