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,39 @@
# -*- coding: utf-8 -*- #
# Copyright 2024 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 creating or manipulating interconnect groups."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.UniverseCompatible
@base.ReleaseTracks(
base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA, base.ReleaseTrack.GA
)
class InterconnectGroups(base.Group):
"""Create or manipulate interconnect groups."""
pass
InterconnectGroups.detailed_help = {
'DESCRIPTION': """
Create or manipulate interconnect groups.
""",
}

View File

@@ -0,0 +1,91 @@
# -*- coding: utf-8 -*- #
# Copyright 2024 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 adding member interconnects to an interconnect group."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.compute import base_classes
from googlecloudsdk.api_lib.compute.interconnects.groups import client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.compute.interconnects.groups import flags
from googlecloudsdk.core import properties
DETAILED_HELP = {
'DESCRIPTION': """\
*{command}* is used to add member interconnects to an interconnect
group.
For an example, refer to the *EXAMPLES* section below.
""",
'EXAMPLES': """\
To add interconnects interconnect1 and interconnect2 to interconnect
group example-interconnect-group, run:
$ {command} example-interconnect-group
--interconnects=interconnect1,interconnect2
""",
}
@base.UniverseCompatible
@base.ReleaseTracks(
base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA, base.ReleaseTrack.GA
)
class AddMembers(base.UpdateCommand):
"""Add member interconnects to a Compute Engine interconnect group.
*{command}* adds member interconnects to a Compute Engine interconnect group.
"""
INTERCONNECT_GROUP_ARG = None
@classmethod
def Args(cls, parser):
cls.INTERCONNECT_GROUP_ARG = flags.InterconnectGroupArgument(plural=False)
cls.INTERCONNECT_GROUP_ARG.AddArgument(parser, operation_type='update')
flags.GetMemberInterconnects(parser)
def Collection(self):
return 'compute.interconnectGroups'
def Run(self, args):
holder = base_classes.ComputeApiHolder(self.ReleaseTrack())
ref = self.INTERCONNECT_GROUP_ARG.ResolveAsResource(args, holder.resources)
project = properties.VALUES.core.project.GetOrFail()
interconnect_group = client.InterconnectGroup(
ref, project, compute_client=holder.client, resources=holder.resources
)
interconnects = set()
interconnect_group_interconnects = (
interconnect_group.Describe().interconnects
)
if interconnect_group_interconnects is not None:
interconnects = set(
property.key
for property in interconnect_group_interconnects.additionalProperties
)
interconnects |= set(args.interconnects)
return interconnect_group.Patch(
interconnects=sorted(list(interconnects)),
)
AddMembers.detailed_help = DETAILED_HELP

View File

@@ -0,0 +1,97 @@
# -*- coding: utf-8 -*- #
# Copyright 2024 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 creating interconnect groups."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.compute import base_classes
from googlecloudsdk.api_lib.compute.interconnects.groups import client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.compute.interconnects.groups import flags
from googlecloudsdk.core import properties
DETAILED_HELP = {
'DESCRIPTION': """\
*{command}* is used to create interconnect groups. An interconnect group
connects a set of redundant interconnects between Google and the
customer.
For an example, refer to the *EXAMPLES* section below.
""",
'EXAMPLES': """\
To create an interconnect group capable of PRODUCTION_CRITICAL, run:
$ {command} example-interconnect-group
--intended-topology-capability=PRODUCTION_CRITICAL
--description="Example interconnect group"
It is easy to add members to an existing interconnect group after
creation using the *add-members* command.
To create an interconnect group capable of PRODUCTION_NON_CRITICAL, with
two members at creation time, run:
$ {command} example-interconnect-group
--intended-topology-capability=PRODUCTION_NON_CRITICAL
--interconnects=interconnect-1,interconnect-2
""",
}
@base.UniverseCompatible
@base.ReleaseTracks(
base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA, base.ReleaseTrack.GA
)
class Create(base.CreateCommand):
"""Create a Compute Engine interconnect group.
*{command}* is used to create interconnect groups. An interconnect group
connects a set of redundant interconnects between Google and the customer.
"""
INTERCONNECT_GROUP_ARG = None
@classmethod
def Args(cls, parser):
cls.INTERCONNECT_GROUP_ARG = flags.InterconnectGroupArgument(plural=False)
cls.INTERCONNECT_GROUP_ARG.AddArgument(parser, operation_type='create')
flags.AddDescription(parser)
flags.AddIntendedTopologyCapabilityForCreate(parser)
flags.GetMemberInterconnectsForCreate(parser)
def Collection(self):
return 'compute.interconnectGroups'
def Run(self, args):
holder = base_classes.ComputeApiHolder(self.ReleaseTrack())
ref = self.INTERCONNECT_GROUP_ARG.ResolveAsResource(args, holder.resources)
project = properties.VALUES.core.project.GetOrFail()
interconnect_group = client.InterconnectGroup(
ref, project, compute_client=holder.client, resources=holder.resources
)
topology_capability = flags.GetTopologyCapability(
holder.client.messages, args.intended_topology_capability
)
return interconnect_group.Create(
description=args.description,
topology_capability=topology_capability,
interconnects=args.interconnects,
)
Create.detailed_help = DETAILED_HELP

View File

@@ -0,0 +1,159 @@
# -*- 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 creating new member interconnects in an interconnect group."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.compute import base_classes
from googlecloudsdk.api_lib.compute.interconnects.groups import client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.compute.interconnects import flags as interconnect_flags
from googlecloudsdk.command_lib.compute.interconnects.groups import flags
from googlecloudsdk.core import properties
DETAILED_HELP = {
'DESCRIPTION': """\
*{command}* is used to create new member interconnects in an
interconnect group.
For an example, refer to the *EXAMPLES* section below.
""",
'EXAMPLES': """\
To create interconnects interconnect1 and interconnect2 in interconnect
group example-interconnect-group, run:
$ {command} example-interconnect-group --interconnect-type=DEDICATED
--link-type=LINK_TYPE_ETHERNET_10G_LR --requested-link-count=1
--facility=iad-1 --interconnect="name=interconnect1"
--interconnect="name=interconnect2"
""",
}
# Interconnect Flags
_FACILITY = 'facility'
_DESCRIPTION = 'description'
_NAME = 'name'
_LINK_TYPE = 'link-type'
_REQUESTED_LINK_COUNT = 'requested-link-count'
_INTERCONNECT_TYPE = 'interconnect-type'
_ADMIN_ENABLED = 'admin-enabled'
_NO_ADMIN_ENABLED = 'no-admin-enabled'
_NOC_CONTACT_EMAIL = 'noc-contact-email'
_CUSTOMER_NAME = 'customer-name'
_REMOTE_LOCATION = 'remote-location'
_REQUESTED_FEATURES = 'requested-features'
@base.UniverseCompatible
@base.ReleaseTracks(
base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA, base.ReleaseTrack.GA
)
class CreateMembers(base.UpdateCommand):
"""Create new member interconnects in a Compute Engine interconnect group.
*{command}* creates new member interconnects in a Compute Engine interconnect
group.
"""
INTERCONNECT_GROUP_ARG = None
REMOTE_LOCATION_ARG = None
@classmethod
def Args(cls, parser):
cls.INTERCONNECT_GROUP_ARG = flags.InterconnectGroupArgument(plural=False)
cls.INTERCONNECT_GROUP_ARG.AddArgument(
parser, operation_type='create members'
)
flags.AddMemberInterconnectsForCreateMembers(parser)
flags.AddFacility(parser)
flags.AddRemoteLocation(parser)
flags.AddIntentMismatchBehavior(parser)
interconnect_flags.AddCreateArgsForInterconnectGroupsCreateMembers(
parser, required=False
)
def Collection(self):
return 'compute.interconnectGroups'
def Run(self, args):
holder = base_classes.ComputeApiHolder(self.ReleaseTrack())
ref = self.INTERCONNECT_GROUP_ARG.ResolveAsResource(args, holder.resources)
project = properties.VALUES.core.project.GetOrFail()
interconnect_group = client.InterconnectGroup(
ref, project, compute_client=holder.client, resources=holder.resources
)
messages = holder.client.messages
template_interconnect = (
interconnect_group.MakeInterconnectGroupsCreateMembersInterconnectInput(
facility=args.facility,
description=args.description,
name=None,
link_type=flags.GetLinkType(messages, args.link_type),
requested_link_count=args.requested_link_count,
interconnect_type=flags.GetInterconnectType(
messages, args.interconnect_type
),
admin_enabled=args.admin_enabled,
noc_contact_email=args.noc_contact_email,
customer_name=args.customer_name,
remote_location=args.remote_location,
requested_features=flags.GetRequestedFeatures(
messages, args.requested_features
),
)
)
member_interconnects = []
for ic_args in args.interconnect:
if _ADMIN_ENABLED in ic_args:
admin_enabled = True
elif _NO_ADMIN_ENABLED in ic_args:
admin_enabled = False
else:
admin_enabled = None
member_interconnects.append(
interconnect_group.MakeInterconnectGroupsCreateMembersInterconnectInput(
facility=ic_args.get(_FACILITY),
description=ic_args.get(_DESCRIPTION),
name=ic_args.get(_NAME),
link_type=flags.GetLinkType(messages, ic_args.get(_LINK_TYPE)),
requested_link_count=ic_args.get(_REQUESTED_LINK_COUNT),
interconnect_type=flags.GetInterconnectType(
messages, ic_args.get(_INTERCONNECT_TYPE)
),
admin_enabled=admin_enabled,
noc_contact_email=ic_args.get(_NOC_CONTACT_EMAIL),
customer_name=ic_args.get(_CUSTOMER_NAME),
remote_location=ic_args.get(_REMOTE_LOCATION),
requested_features=flags.GetRequestedFeatures(
messages, ic_args.get(_REQUESTED_FEATURES)
),
)
)
return interconnect_group.CreateMembers(
intent_mismatch_behavior=flags.GetIntentMismatchBehavior(
messages, args.intent_mismatch_behavior
),
template_interconnect=template_interconnect,
member_interconnects=member_interconnects,
)
CreateMembers.detailed_help = DETAILED_HELP

View File

@@ -0,0 +1,85 @@
# -*- coding: utf-8 -*- #
# Copyright 2024 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 deleting interconnect groups."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.compute import base_classes
from googlecloudsdk.api_lib.compute import utils
from googlecloudsdk.api_lib.compute.interconnects.groups import client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.compute.interconnects.groups import flags
from googlecloudsdk.core import properties
DETAILED_HELP = {
'DESCRIPTION': """\
*{command}* is used to delete interconnect groups.
For an example, refer to the *EXAMPLES* section below.
""",
'EXAMPLES': """\
To delete an interconnect group, run:
$ {command} example-interconnect-group"
Although not shown in this example, you can delete multiple interconnect
groups in a single command.
""",
}
@base.UniverseCompatible
@base.ReleaseTracks(
base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA, base.ReleaseTrack.GA
)
class Delete(base.DeleteCommand):
"""Delete Compute Engine interconnect groups.
*{command}* deletes Compute Engine interconnect groups. Interconnect groups
can be deleted even if they are referenced by interconnects. Each
interconnect in the group will be updated to remove its reference to this
group.
"""
INTERCONNECT_GROUP_ARG = None
@classmethod
def Args(cls, parser):
cls.INTERCONNECT_GROUP_ARG = flags.InterconnectGroupArgument(plural=True)
cls.INTERCONNECT_GROUP_ARG.AddArgument(parser, operation_type='delete')
def Collection(self):
return 'compute.interconnectGroups'
def Run(self, args):
holder = base_classes.ComputeApiHolder(self.ReleaseTrack())
refs = self.INTERCONNECT_GROUP_ARG.ResolveAsResource(args, holder.resources)
project = properties.VALUES.core.project.GetOrFail()
utils.PromptForDeletion(refs)
requests = []
for ref in refs:
interconnect_group = client.InterconnectGroup(
ref, project, compute_client=holder.client
)
requests.extend(interconnect_group.Delete(only_generate_request=True))
return holder.client.MakeRequests(requests)
Delete.detailed_help = DETAILED_HELP

View File

@@ -0,0 +1,70 @@
# -*- coding: utf-8 -*- #
# Copyright 2024 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 describing interconnect groups."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.compute import base_classes
from googlecloudsdk.api_lib.compute.interconnects.groups import client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.compute.interconnects.groups import flags
from googlecloudsdk.core import properties
DETAILED_HELP = {
'DESCRIPTION': """\
*{command}* is used to describe an interconnect group.
For an example, refer to the *EXAMPLES* section below.
""",
'EXAMPLES': """\
To describe interconnect group example-interconnect-group, run:
$ {command} example-interconnect-group
""",
}
@base.UniverseCompatible
@base.ReleaseTracks(
base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA, base.ReleaseTrack.GA
)
class Describe(base.DescribeCommand):
"""Describe a Compute Engine interconnect group.
*{command}* displays all data associated with Compute Engine
interconnect group in a project.
"""
INTERCONNECT_GROUP_ARG = None
@classmethod
def Args(cls, parser):
cls.INTERCONNECT_GROUP_ARG = flags.InterconnectGroupArgument()
cls.INTERCONNECT_GROUP_ARG.AddArgument(parser, operation_type='describe')
def Run(self, args):
holder = base_classes.ComputeApiHolder(self.ReleaseTrack())
ref = self.INTERCONNECT_GROUP_ARG.ResolveAsResource(args, holder.resources)
project = properties.VALUES.core.project.GetOrFail()
interconnect_group = client.InterconnectGroup(
ref, project, compute_client=holder.client
)
return interconnect_group.Describe()
Describe.detailed_help = DETAILED_HELP

View File

@@ -0,0 +1,74 @@
# -*- 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 getting interconnect group operational status."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.compute import base_classes
from googlecloudsdk.api_lib.compute.interconnects.groups import client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.compute.interconnects.groups import flags
from googlecloudsdk.core import properties
DETAILED_HELP = {
'DESCRIPTION': """\
*{command}* is used to get the operational status of an interconnect
group.
For an example, refer to the *EXAMPLES* section below.
""",
'EXAMPLES': """\
To get the operational status of interconnect group
example-interconnect-group, run:
$ {command} example-interconnect-group
""",
}
@base.UniverseCompatible
@base.ReleaseTracks(
base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA, base.ReleaseTrack.GA
)
class GetOperationalStatus(base.DescribeCommand):
"""Get the operational status of a Compute Engine interconnect group.
*{command}* gets the operational status of a Compute Engine
interconnect group in a project.
"""
INTERCONNECT_GROUP_ARG = None
@classmethod
def Args(cls, parser):
cls.INTERCONNECT_GROUP_ARG = flags.InterconnectGroupArgument()
cls.INTERCONNECT_GROUP_ARG.AddArgument(
parser, operation_type='get operational status'
)
def Run(self, args):
holder = base_classes.ComputeApiHolder(self.ReleaseTrack())
ref = self.INTERCONNECT_GROUP_ARG.ResolveAsResource(args, holder.resources)
project = properties.VALUES.core.project.GetOrFail()
interconnect_group = client.InterconnectGroup(
ref, project, compute_client=holder.client
)
return interconnect_group.GetOperationalStatus()
GetOperationalStatus.detailed_help = DETAILED_HELP

View File

@@ -0,0 +1,89 @@
# -*- coding: utf-8 -*- #
# Copyright 2024 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 interconnect groups."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from apitools.base.py import list_pager
from googlecloudsdk.api_lib.compute import base_classes
from googlecloudsdk.api_lib.compute import filter_rewrite
from googlecloudsdk.calliope import base
from googlecloudsdk.core import properties
from googlecloudsdk.core.resource import resource_projection_spec
DETAILED_HELP = {
'DESCRIPTION': """\
*{command}* is used to list interconnect groups.
For an example, refer to the *EXAMPLES* section below.
""",
'EXAMPLES': """\
To list interconnect groups, run:
$ {command}
""",
}
@base.UniverseCompatible
@base.ReleaseTracks(
base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA, base.ReleaseTrack.GA
)
class List(base.ListCommand):
"""List interconnect groups."""
@classmethod
def Args(cls, parser):
parser.display_info.AddFormat("""
table(
name,
interconnects.flatten(show='keys', separator='\n'),
intent.topologyCapability:label=INTENDED_CAPABILITY,
configured.topologyCapability.supportedSla:label=CONFIGURED_CAPABILITY
)
""")
def Run(self, args):
holder = base_classes.ComputeApiHolder(self.ReleaseTrack())
client = holder.client.apitools_client
messages = client.MESSAGES_MODULE
project = properties.VALUES.core.project.GetOrFail()
display_info = args.GetDisplayInfo()
defaults = resource_projection_spec.ProjectionSpec(
symbols=display_info.transforms, aliases=display_info.aliases
)
args.filter, filter_expr = filter_rewrite.Rewriter().Rewrite(
args.filter, defaults=defaults
)
request = messages.ComputeInterconnectGroupsListRequest(
project=project, filter=filter_expr
)
return list_pager.YieldFromList(
client.interconnectGroups,
request,
field='items',
limit=args.limit,
batch_size=None,
)
List.detailed_help = DETAILED_HELP

View File

@@ -0,0 +1,93 @@
# -*- coding: utf-8 -*- #
# Copyright 2024 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 removing member interconnects from an interconnect group."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.compute import base_classes
from googlecloudsdk.api_lib.compute.interconnects.groups import client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.compute.interconnects.groups import flags
from googlecloudsdk.core import properties
DETAILED_HELP = {
'DESCRIPTION': """\
*{command}* is used to remove member interconnects from an interconnect
group.
For an example, refer to the *EXAMPLES* section below.
""",
'EXAMPLES': """\
To remove interconnects interconnect1 and interconnect2 from
interconnect group example-interconnect-group, run:
$ {command} example-interconnect-group
--interconnects=interconnect1,interconnect2
""",
}
@base.UniverseCompatible
@base.ReleaseTracks(
base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA, base.ReleaseTrack.GA
)
class RemoveMembers(base.UpdateCommand):
"""Remove member interconnects from a Compute Engine interconnect group.
*{command}* removes member interconnects from a Compute Engine interconnect
group.
"""
INTERCONNECT_GROUP_ARG = None
@classmethod
def Args(cls, parser):
cls.INTERCONNECT_GROUP_ARG = flags.InterconnectGroupArgument(plural=False)
cls.INTERCONNECT_GROUP_ARG.AddArgument(parser, operation_type='update')
flags.GetMemberInterconnects(parser)
def Collection(self):
return 'compute.interconnectGroups'
def Run(self, args):
holder = base_classes.ComputeApiHolder(self.ReleaseTrack())
ref = self.INTERCONNECT_GROUP_ARG.ResolveAsResource(args, holder.resources)
project = properties.VALUES.core.project.GetOrFail()
interconnect_group = client.InterconnectGroup(
ref, project, compute_client=holder.client, resources=holder.resources
)
interconnects = set()
interconnect_group_interconnects = (
interconnect_group.Describe().interconnects
)
if interconnect_group_interconnects is not None:
interconnects = set(
property.key
for property in interconnect_group_interconnects.additionalProperties
)
interconnects -= set(args.interconnects)
return interconnect_group.Patch(
interconnects=sorted(list(interconnects)),
update_mask='interconnects',
)
RemoveMembers.detailed_help = DETAILED_HELP

View File

@@ -0,0 +1,114 @@
# -*- coding: utf-8 -*- #
# Copyright 2024 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 updating interconnect groups."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.compute import base_classes
from googlecloudsdk.api_lib.compute.interconnects.groups import client
from googlecloudsdk.calliope import base
from googlecloudsdk.calliope import exceptions
from googlecloudsdk.command_lib.compute.interconnects.groups import flags
from googlecloudsdk.core import properties
DETAILED_HELP = {
'DESCRIPTION': """\
*{command}* is used to update interconnect groups.
For an example, refer to the *EXAMPLES* section below.
""",
'EXAMPLES': """\
To update an interconnect group example-interconnect-group's intended
topology capability to PRODUCTION_CRITICAL, run:
$ {command} example-interconnect-group
--intended-topology-capability=PRODUCTION_CRITICAL
To update an interconnect group example-interconnect-group's description
to "example interconnect group description", run:
$ {command} example-interconnect-group
--description="example interconnect group description"
To update an interconnect group example-interconnect-group's member
interconnects to interconnect-1 and interconnect-2, run:
$ {command} example-interconnect-group
--interconnects=interconnect-1,interconnect-2
--update-mask=interconnects
Although you can add or remove member interconnects using this command,
it is recommended to add or remove member interconnects using the
*add-members* and *remove-members* commands.
""",
}
@base.UniverseCompatible
@base.ReleaseTracks(
base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA, base.ReleaseTrack.GA
)
class Update(base.UpdateCommand):
"""Update a Compute Engine interconnect group.
*{command}* is used to update interconnect groups. An interconnect group
represents a set of redundant interconnects between Google and the customer.
"""
INTERCONNECT_GROUP_ARG = None
@classmethod
def Args(cls, parser):
cls.INTERCONNECT_GROUP_ARG = flags.InterconnectGroupArgument(plural=False)
cls.INTERCONNECT_GROUP_ARG.AddArgument(parser, operation_type='update')
flags.AddDescription(parser)
flags.AddIntendedTopologyCapabilityForUpdate(parser)
flags.GetMemberInterconnectsForUpdate(parser)
flags.AddUpdateMask(parser)
def Collection(self):
return 'compute.interconnectGroups'
def Run(self, args):
if (
args.description is None
and args.intended_topology_capability is None
and not args.interconnects
):
raise exceptions.MinimumArgumentException(
['--description', '--intended-topology-capability', '--interconnects']
)
holder = base_classes.ComputeApiHolder(self.ReleaseTrack())
ref = self.INTERCONNECT_GROUP_ARG.ResolveAsResource(args, holder.resources)
project = properties.VALUES.core.project.GetOrFail()
interconnect_group = client.InterconnectGroup(
ref, project, compute_client=holder.client, resources=holder.resources
)
topology_capability = None
if args.intended_topology_capability is not None:
topology_capability = flags.GetTopologyCapability(
holder.client.messages, args.intended_topology_capability
)
return interconnect_group.Patch(
description=args.description,
topology_capability=topology_capability,
interconnects=args.interconnects,
update_mask=args.update_mask,
)
Update.detailed_help = DETAILED_HELP