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,37 @@
# -*- coding: utf-8 -*- #
# Copyright 2023 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 Cloud NetApp Volume Replications."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Replications(base.Group):
"""Create and manage Cloud NetApp Volume Replications."""
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class ReplicationsBeta(Replications):
"""Create and manage Cloud NetApp Volume Replications."""
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class ReplicationsAlpha(ReplicationsBeta):
"""Create and manage Cloud NetApp Volume Replications."""

View File

@@ -0,0 +1,128 @@
# -*- coding: utf-8 -*- #
# Copyright 2023 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 a Cloud NetApp Volume Replication."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp import util as netapp_api_util
from googlecloudsdk.api_lib.netapp.volumes.replications import client as replications_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp import flags
from googlecloudsdk.command_lib.netapp.volumes.replications import flags as replications_flags
from googlecloudsdk.command_lib.util.args import labels_util
from googlecloudsdk.command_lib.util.concepts import concept_parsers
from googlecloudsdk.core import log
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Create(base.CreateCommand):
"""Create a Cloud NetApp Volume Replication."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION': """\
Create a Cloud NetApp Volume Replication.
""",
'EXAMPLES': """\
The following command creates a Replication named NAME using the required arguments:
$ {command} NAME --location=us-central1 --volume=vol1 --replication-schedule=EVERY_10_MINUTES --destination-volume-parameters=storage_pool=sp1,volume_id=vol2,share_name=share2
""",
}
@staticmethod
def Args(parser):
return Create._ReplicationArgs(parser, Create._RELEASE_TRACK)
@staticmethod
def _ReplicationArgs(parser, release_track):
"""Add args for creating a Replication."""
concept_parsers.ConceptParser(
[flags.GetReplicationPresentationSpec('The Replication to create.')]
).AddToParser(parser)
messages = netapp_api_util.GetMessagesModule(
release_track=release_track
)
replications_flags.AddReplicationVolumeArg(parser)
replications_flags.AddReplicationReplicationScheduleArg(parser)
replications_flags.AddReplicationDestinationVolumeParametersArg(
parser, messages
)
replications_flags.AddReplicationClusterLocationArg(parser)
flags.AddResourceAsyncFlag(parser)
flags.AddResourceDescriptionArg(parser, 'Replication')
labels_util.AddCreateLabelsFlags(parser)
def Run(self, args):
"""Create a Cloud NetApp Volume Replication in the current project."""
replication_ref = args.CONCEPTS.replication.Parse()
volume_ref = args.CONCEPTS.volume.Parse().RelativeName()
client = replications_client.ReplicationsClient(self._RELEASE_TRACK)
labels = labels_util.ParseCreateArgs(
args, client.messages.Replication.LabelsValue
)
replication_schedule_enum = (
replications_flags.GetReplicationReplicationScheduleEnumFromArg(
args.replication_schedule, client.messages
)
)
replication = client.ParseReplicationConfig(
name=replication_ref.RelativeName(),
description=args.description,
labels=labels,
replication_schedule=replication_schedule_enum,
destination_volume_parameters=args.destination_volume_parameters,
cluster_location=args.cluster_location,
)
result = client.CreateReplication(
replication_ref, volume_ref, args.async_, replication
)
if args.async_:
command = 'gcloud {} netapp volumes replications list'.format(
self.ReleaseTrack().prefix
)
log.status.Print(
'Check the status of the new replication by listing all'
' replications:\n $ {} '.format(command)
)
return result
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class CreateBeta(Create):
"""Create a Cloud NetApp Volume Replication."""
_RELEASE_TRACK = base.ReleaseTrack.BETA
@staticmethod
def Args(parser):
return CreateBeta._ReplicationArgs(parser, CreateBeta._RELEASE_TRACK)
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class CreateAlpha(CreateBeta):
"""Create a Cloud NetApp Volume Replication."""
_RELEASE_TRACK = base.ReleaseTrack.ALPHA
@staticmethod
def Args(parser):
return CreateAlpha._ReplicationArgs(parser, CreateAlpha._RELEASE_TRACK)

View File

@@ -0,0 +1,99 @@
# -*- coding: utf-8 -*- #
# Copyright 2023 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 a Cloud NetApp Volume Replication."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.volumes.replications import client as replications_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp import flags
from googlecloudsdk.command_lib.netapp.volumes.replications import flags as replications_flags
from googlecloudsdk.command_lib.util.concepts import concept_parsers
from googlecloudsdk.core import log
from googlecloudsdk.core.console import console_io
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Delete(base.DeleteCommand):
"""Delete a Cloud NetApp Volume Replication."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION': """\
Delete a Cloud NetApp Volume Replication.
""",
'EXAMPLES': """\
The following command deletes a Replication named NAME using the required arguments:
$ {command} NAME --location=us-central1 --volume=vol1
To delete a Replication named NAME asynchronously, run the following command:
$ {command} NAME --location=us-central1 --volume=vol1 --async
""",
}
@staticmethod
def Args(parser):
"""Add args for deleting a Replication."""
concept_parsers.ConceptParser([
flags.GetReplicationPresentationSpec('The Replication to delete.')
]).AddToParser(parser)
replications_flags.AddReplicationVolumeArg(parser)
flags.AddResourceAsyncFlag(parser)
def Run(self, args):
"""Delete a Cloud NetApp Volume Replication in the current project."""
replication_ref = args.CONCEPTS.replication.Parse()
if not args.quiet:
delete_warning = (
'You are about to delete a Replication {}.\nAre you sure?'.format(
replication_ref.RelativeName()
)
)
if not console_io.PromptContinue(message=delete_warning):
return None
client = replications_client.ReplicationsClient(self._RELEASE_TRACK)
result = client.DeleteReplication(replication_ref, args.async_)
if args.async_:
command = 'gcloud {} netapp volumes replications list'.format(
self.ReleaseTrack().prefix
)
log.status.Print(
'Check the status of the deletion by listing all replications:\n '
'$ {} '.format(command)
)
return result
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class DeleteBeta(Delete):
"""Delete a Cloud NetApp Volume Replication."""
_RELEASE_TRACK = base.ReleaseTrack.BETA
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class DeleteAlpha(DeleteBeta):
"""Delete a Cloud NetApp Storage Pool."""
_RELEASE_TRACK = base.ReleaseTrack.ALPHA

View File

@@ -0,0 +1,101 @@
# -*- coding: utf-8 -*- #
# Copyright 2023 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 a Cloud NetApp Volume Replication."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.volumes.replications import client as replications_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp import flags
from googlecloudsdk.command_lib.netapp.volumes.replications import flags as replications_flags
from googlecloudsdk.command_lib.util.concepts import concept_parsers
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Describe(base.DescribeCommand):
"""Describe a Cloud NetApp Volume Replication."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION': """\
Describe a Cloud NetApp Volume Replication.
""",
'EXAMPLES': """\
The following command describes a Replication named NAME in the given location and volume:
$ {command} NAME --location=us-central1 --volume=vol1
""",
}
@staticmethod
def Args(parser):
concept_parsers.ConceptParser(
[flags.GetReplicationPresentationSpec('The Replication to describe.')]
).AddToParser(parser)
replications_flags.AddReplicationVolumeArg(parser)
def Run(self, args):
"""Get a Cloud NetApp Volume Replication in the current project."""
replication_ref = args.CONCEPTS.replication.Parse()
client = replications_client.ReplicationsClient(
release_track=self._RELEASE_TRACK
)
return client.GetReplication(replication_ref)
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class DescribeBeta(Describe):
"""Describe a Cloud NetApp Volume Replication."""
_RELEASE_TRACK = base.ReleaseTrack.BETA
detailed_help = {
'DESCRIPTION': """\
Describe a Cloud NetApp Volume Replication
""",
'EXAMPLES': """\
The following command describes a Replication named NAME in the given location and volume
$ {command} NAME --location=us-central1 --volume=vol1
""",
}
@staticmethod
def Args(parser):
concept_parsers.ConceptParser(
[flags.GetReplicationPresentationSpec('The Replication to describe.')]
).AddToParser(parser)
replications_flags.AddReplicationVolumeArg(parser)
def Run(self, args):
"""Get a Cloud NetApp Volume Replication in the current project."""
replication_ref = args.CONCEPTS.replication.Parse()
client = replications_client.ReplicationsClient(
release_track=self._RELEASE_TRACK
)
return client.GetReplication(replication_ref)
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class DescribeAlpha(DescribeBeta):
"""Describe a Cloud NetApp Volume Replication."""
_RELEASE_TRACK = base.ReleaseTrack.ALPHA

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.
"""Establish peering for Hybrid replication."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.volumes.replications import client as replications_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp import flags
from googlecloudsdk.command_lib.netapp.volumes.replications import flags as replications_flags
from googlecloudsdk.command_lib.util.concepts import concept_parsers
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class EstablishPeering(base.Command):
"""Establish peering for Hybrid replication."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION': """\
Establish peering for Hybrid replication.
""",
'EXAMPLES': """\
The following command establishes peering for Hybrid replication named NAME using the arguments specified:
$ {command} NAME --volume=volume1 --peer-cluster-name=peer-cluster-name1 --peer-svm-name=peer-svm-name1 --peer-volume-name=peer-volume-name1 --peer-ip-addresses=1.1.1.1,2.2.2.2
""",
}
@staticmethod
def Args(parser):
"""Add args for establishing peering for Hybrid replication."""
concept_parsers.ConceptParser([
flags.GetReplicationPresentationSpec(
'The Hybrid replication to establish peering for.'
)
]).AddToParser(parser)
flags.AddResourcePeerClusterNameArg(parser)
flags.AddResourcePeerSvmNameArg(parser)
flags.AddResourcePeerVolumeNameArg(parser)
flags.AddResourcePeerIpAddressesArg(parser)
replications_flags.AddReplicationVolumeArg(parser)
flags.AddResourceAsyncFlag(parser)
def Run(self, args):
"""Run the establish peering command."""
replication_ref = args.CONCEPTS.replication.Parse()
client = replications_client.ReplicationsClient(
release_track=self._RELEASE_TRACK
)
establish_peering_request_config = (
client.ParseEstablishPeeringRequestConfig(
args.peer_cluster_name,
args.peer_svm_name,
args.peer_volume_name,
args.peer_ip_addresses,
)
)
replication = client.EstablishPeering(
replication_ref,
establish_peering_request_config,
args.async_,
)
return replication
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class EstablishPeeringBeta(EstablishPeering):
"""Establish peering for Hybrid replication."""
_RELEASE_TRACK = base.ReleaseTrack.BETA
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class EstablishPeeringAlpha(EstablishPeeringBeta):
"""Establish peering for Hybrid replication."""
_RELEASE_TRACK = base.ReleaseTrack.ALPHA

View File

@@ -0,0 +1,88 @@
# -*- coding: utf-8 -*- #
# Copyright 2023 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.
"""List Cloud NetApp Volume Replications."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.volumes.replications import client as replications_client
from googlecloudsdk.calliope import base
from googlecloudsdk.calliope import exceptions
from googlecloudsdk.command_lib.netapp import flags
from googlecloudsdk.command_lib.netapp.volumes.replications import flags as replications_flags
from googlecloudsdk.command_lib.util.concepts import concept_parsers
from googlecloudsdk.core import properties
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class List(base.ListCommand):
"""List Cloud NetApp Volume Replications."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION': """\
Lists Cloud NetApp Volume Replications.
""",
'EXAMPLES': """\
The following command lists all Replications in the given location and volume:
$ {command} --location=us-central1 --volume=vol1
""",
}
@staticmethod
def Args(parser):
concept_parsers.ConceptParser(
[
flags.GetResourceListingLocationPresentationSpec(
'The location in which to list Volume Replications.'
)
]
).AddToParser(parser)
replications_flags.AddReplicationVolumeArg(parser)
def Run(self, args):
"""Run the list command."""
# Ensure that project is set before parsing location resource.
properties.VALUES.core.project.GetOrFail()
if args.CONCEPTS.volume.Parse() is None:
raise exceptions.RequiredArgumentException(
'--volume', 'Requires a volume to list replications of'
)
volume_ref = args.CONCEPTS.volume.Parse().RelativeName()
client = replications_client.ReplicationsClient(
release_track=self._RELEASE_TRACK
)
return list(client.ListReplications(volume_ref, limit=args.limit))
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class ListBeta(List):
"""List Cloud NetApp Volume Replications."""
_RELEASE_TRACK = base.ReleaseTrack.BETA
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class ListAlpha(ListBeta):
"""List Cloud NetApp Volume Replications."""
_RELEASE_TRACK = base.ReleaseTrack.ALPHA

View File

@@ -0,0 +1,89 @@
# -*- coding: utf-8 -*- #
# Copyright 2023 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.
"""Resume a Cloud NetApp Volume Replication."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.volumes.replications import client as replications_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp import flags
from googlecloudsdk.command_lib.netapp.volumes.replications import flags as replications_flags
from googlecloudsdk.command_lib.util.concepts import concept_parsers
from googlecloudsdk.core import log
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Resume(base.Command):
"""Resume a Cloud NetApp Volume Replication."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION': """\
Resume a Cloud NetApp Volume Replication.
""",
'EXAMPLES': """\
The following command resumes a Replication named NAME using the required arguments:
$ {command} NAME --location=us-central1 --volume=vol1
To resume a Replication named NAME asynchronously, run the following command:
$ {command} NAME --location=us-central1 --volume=vol1 --async
""",
}
@staticmethod
def Args(parser):
concept_parsers.ConceptParser(
[flags.GetReplicationPresentationSpec('The Replication to create.')]
).AddToParser(parser)
replications_flags.AddReplicationVolumeArg(parser)
flags.AddResourceAsyncFlag(parser)
def Run(self, args):
"""Resume a Cloud NetApp Volume Replication in the current project."""
replication_ref = args.CONCEPTS.replication.Parse()
client = replications_client.ReplicationsClient(self._RELEASE_TRACK)
result = client.ResumeReplication(
replication_ref, args.async_)
if args.async_:
command = 'gcloud {} netapp volumes replications list'.format(
self.ReleaseTrack().prefix
)
log.status.Print(
'Check the status of the resumed replication by listing all'
' replications:\n $ {} '.format(command)
)
return result
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class ResumeBeta(Resume):
"""Resume a Cloud NetApp Volume Replication."""
_RELEASE_TRACK = base.ReleaseTrack.BETA
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class ResumeAlpha(ResumeBeta):
"""Resume a Cloud NetApp Volume Replication."""
_RELEASE_TRACK = base.ReleaseTrack.ALPHA

View File

@@ -0,0 +1,93 @@
# -*- coding: utf-8 -*- #
# Copyright 2023 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.
"""Reverse a Cloud NetApp Volume Replication's direction."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.volumes.replications import client as replications_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp import flags
from googlecloudsdk.command_lib.netapp.volumes.replications import flags as replications_flags
from googlecloudsdk.command_lib.util.concepts import concept_parsers
from googlecloudsdk.core import log
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Reverse(base.Command):
"""Reverse a Cloud NetApp Volume Replication's direction."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION': """\
Reverse a Cloud NetApp Volume Replication.
""",
'EXAMPLES': """\
The following command reverses a Replication named NAME using the required arguments:
$ {command} NAME --location=us-central1 --volume=vol1
To reverse a Replication named NAME asynchronously, run the following command:
$ {command} NAME --location=us-central1 --volume=vol1 --async
""",
}
@staticmethod
def Args(parser):
concept_parsers.ConceptParser(
[
flags.GetReplicationPresentationSpec(
'The Replication to reverse direction.'
)
]
).AddToParser(parser)
replications_flags.AddReplicationVolumeArg(parser, reverse_op=True)
flags.AddResourceAsyncFlag(parser)
def Run(self, args):
"""Reverse a Cloud NetApp Volume Replication's direction in the current project."""
replication_ref = args.CONCEPTS.replication.Parse()
client = replications_client.ReplicationsClient(self._RELEASE_TRACK)
result = client.ReverseReplication(
replication_ref, args.async_)
if args.async_:
command = 'gcloud {} netapp volumes replications list'.format(
self.ReleaseTrack().prefix
)
log.status.Print(
'Check the status of the reversed replication by listing all'
' replications:\n $ {} '.format(command)
)
return result
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class ReverseBeta(Reverse):
"""Reverse a Cloud NetApp Volume Replication's direction."""
_RELEASE_TRACK = base.ReleaseTrack.BETA
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class ReverseAlpha(ReverseBeta):
"""Reverse a Cloud NetApp Volume Replication's direction."""
_RELEASE_TRACK = base.ReleaseTrack.ALPHA

View File

@@ -0,0 +1,90 @@
# -*- coding: utf-8 -*- #
# Copyright 2023 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.
"""Stop a Cloud NetApp Volume Replication."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.volumes.replications import client as replications_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp import flags
from googlecloudsdk.command_lib.netapp.volumes.replications import flags as replications_flags
from googlecloudsdk.command_lib.util.concepts import concept_parsers
from googlecloudsdk.core import log
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Stop(base.Command):
"""Stop a Cloud NetApp Volume Replication."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION': """\
Stop a Cloud NetApp Volume Replication.
""",
'EXAMPLES': """\
The following command stops a Replication named NAME using the required arguments:
$ {command} NAME --location=us-central1 --volume=vol1
To stop a Replication named NAME asynchronously, run the following command:
$ {command} NAME --location=us-central1 --volume=vol1 --async
""",
}
@staticmethod
def Args(parser):
concept_parsers.ConceptParser(
[flags.GetReplicationPresentationSpec('The Replication to create.')]
).AddToParser(parser)
replications_flags.AddReplicationVolumeArg(parser)
flags.AddResourceAsyncFlag(parser)
replications_flags.AddReplicationForceArg(parser)
def Run(self, args):
"""Stop a Cloud NetApp Volume Replication in the current project."""
replication_ref = args.CONCEPTS.replication.Parse()
client = replications_client.ReplicationsClient(self._RELEASE_TRACK)
result = client.StopReplication(
replication_ref, args.async_, args.force)
if args.async_:
command = 'gcloud {} netapp volumes replications list'.format(
self.ReleaseTrack().prefix
)
log.status.Print(
'Check the status of the stopped replication by listing all'
' replications:\n $ {} '.format(command)
)
return result
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class StopBeta(Stop):
"""Stop a Cloud NetApp Volume Replication."""
_RELEASE_TRACK = base.ReleaseTrack.BETA
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class StopAlpha(StopBeta):
"""Stop a Cloud NetApp Volume Replication."""
_RELEASE_TRACK = base.ReleaseTrack.ALPHA

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.
"""Sync a Cloud NetApp Volume Replication."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.volumes.replications import client as replications_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp import flags
from googlecloudsdk.command_lib.netapp.volumes.replications import flags as replications_flags
from googlecloudsdk.command_lib.util.concepts import concept_parsers
from googlecloudsdk.core import log
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Sync(base.Command):
"""Sync a Cloud NetApp Volume Replication."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION': """\
Sync a Cloud NetApp Volume Replication.
""",
'EXAMPLES': """\
The following command syncs a Replication named NAME using the required arguments:
$ {command} NAME --location=us-central1 --volume=vol1
To sync a Replication named NAME asynchronously, run the following command:
$ {command} NAME --location=us-central1 --volume=vol1 --async
""",
}
@staticmethod
def Args(parser):
"""Add args for syncing a Replication."""
concept_parsers.ConceptParser(
[flags.GetReplicationPresentationSpec('The Replication to sync.')]
).AddToParser(parser)
replications_flags.AddReplicationVolumeArg(parser)
flags.AddResourceAsyncFlag(parser)
def Run(self, args):
"""Sync a Cloud NetApp Volume Replication in the current project."""
replication_ref = args.CONCEPTS.replication.Parse()
client = replications_client.ReplicationsClient(self._RELEASE_TRACK)
result = client.SyncReplication(replication_ref, args.async_)
if args.async_:
command = 'gcloud {} netapp volumes replications list'.format(
self.ReleaseTrack().prefix
)
log.status.Print(
'Check the status of the sync replication by listing all'
' replications:\n $ {} '.format(command)
)
return result
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class SyncBeta(Sync):
"""Sync a Cloud NetApp Volume Replication."""
_RELEASE_TRACK = base.ReleaseTrack.BETA
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class SyncAlpha(SyncBeta):
"""Sync a Cloud NetApp Volume Replication."""
_RELEASE_TRACK = base.ReleaseTrack.ALPHA

View File

@@ -0,0 +1,135 @@
# -*- coding: utf-8 -*- #
# Copyright 2023 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.
"""Update a Cloud NetApp Volume Replication."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.netapp.volumes.replications import client as replications_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.netapp import flags
from googlecloudsdk.command_lib.netapp.volumes.replications import flags as replications_flags
from googlecloudsdk.command_lib.util.args import labels_util
from googlecloudsdk.command_lib.util.concepts import concept_parsers
from googlecloudsdk.core import log
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Update(base.UpdateCommand):
"""Update a Cloud NetApp Volume Replication."""
_RELEASE_TRACK = base.ReleaseTrack.GA
detailed_help = {
'DESCRIPTION': """\
Update a Cloud NetApp Volume Replication and its specified parameters.
""",
'EXAMPLES': """\
The following command updates a Replication named NAME and its specified parameters:
$ {command} NAME --location=us-central1 --volume=vol1 --replication-schedule=EVERY_5_MINUTES --description="new description" --cluster-location= us-central1
""",
}
@staticmethod
def Args(parser):
"""Add args for updating a Replication."""
concept_parsers.ConceptParser(
[flags.GetReplicationPresentationSpec('The Replication to update.')]
).AddToParser(parser)
replications_flags.AddReplicationVolumeArg(parser)
replications_flags.AddReplicationReplicationScheduleArg(
parser, required=False
)
replications_flags.AddReplicationClusterLocationArg(parser)
flags.AddResourceAsyncFlag(parser)
flags.AddResourceDescriptionArg(parser, 'Replication')
labels_util.AddUpdateLabelsFlags(parser)
def Run(self, args):
"""Update a Cloud NetApp Volume Replication in the current project."""
replication_ref = args.CONCEPTS.replication.Parse()
client = replications_client.ReplicationsClient(self._RELEASE_TRACK)
labels_diff = labels_util.Diff.FromUpdateArgs(args)
original_replication = client.GetReplication(replication_ref)
# Update labels
if labels_diff.MayHaveUpdates():
labels = labels_diff.Apply(
client.messages.Replication.LabelsValue, original_replication.labels
).GetOrNone()
else:
labels = None
replication_schedule_enum = (
replications_flags.GetReplicationReplicationScheduleEnumFromArg(
args.replication_schedule, client.messages
)
)
replication = client.ParseUpdatedReplicationConfig(
original_replication, description=args.description, labels=labels,
replication_schedule=replication_schedule_enum,
cluster_location=args.cluster_location,
)
updated_fields = []
# Add possible updated replication fields.
# TODO(b/243601146) add config mapping and separate config file for update
if args.IsSpecified('description'):
updated_fields.append('description')
if (
args.IsSpecified('update_labels')
or args.IsSpecified('remove_labels')
or args.IsSpecified('clear_labels')
):
updated_fields.append('labels')
if args.IsSpecified('replication_schedule'):
updated_fields.append('replication_schedule')
if args.IsSpecified('cluster_location'):
updated_fields.append('cluster_location')
update_mask = ','.join(updated_fields)
result = client.UpdateReplication(
replication_ref, replication, update_mask, args.async_
)
if args.async_:
command = 'gcloud {} netapp volumes replications list'.format(
self.ReleaseTrack().prefix
)
log.status.Print(
'Check the status of the updated replication by listing all'
' replications:\n $ {} '.format(command)
)
return result
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class UpdateBeta(Update):
"""Update a Cloud NetApp Volume Replication."""
_RELEASE_TRACK = base.ReleaseTrack.BETA
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class UpdateAlpha(UpdateBeta):
"""Update a Cloud NetApp Volume Replication."""
_RELEASE_TRACK = base.ReleaseTrack.ALPHA