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,52 @@
# -*- coding: utf-8 -*- #
# Copyright 2017 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 super-group for the Filestore CLI."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
DETAILED_HELP = {
'DESCRIPTION':
"""\
The gcloud filestore command group lets you create, configure and
manipulate Filestore instances.
With Filestore, you can take advantage of Google Cloud Platform's scale,
performance, and value to create and run managed file systems on Google
infrastructure.
More information on Filestore can be found here:
https://cloud.google.com/filestore/ and detailed documentation can be
found here: https://cloud.google.com/filestore/docs/
""",
}
@base.UniverseCompatible
@base.ReleaseTracks(
base.ReleaseTrack.ALPHA,
base.ReleaseTrack.BETA,
base.ReleaseTrack.GA,
)
class Filestore(base.Group):
"""Create and manipulate Filestore resources."""
detailed_help = DETAILED_HELP
category = base.STORAGE_CATEGORY
def Filter(self, context, args):
del context, args

View File

@@ -0,0 +1,51 @@
# -*- coding: utf-8 -*- #
# Copyright 2020 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 Filestore backups."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA,
base.ReleaseTrack.GA)
class Backups(base.Group):
"""Create and manage Filestore backups.
## EXAMPLES
To create a backup with the name 'my-backup', run:
$ {command} create my-backup --region=Region
To delete a backup with the name 'my-backup', run:
$ {command} delete my-backup --region=Region
To display the details for an backup with the name 'my-backup', run:
$ {command} describe my-backup --region=Region
To list all the backups, run:
$ {command} list [--region=Region]
To set the label 'env' to 'prod' for an backup with the name
'my-backup', run:
$ {command} my-backup --update-labels=env=prod
"""

View File

@@ -0,0 +1,109 @@
- release_tracks: [GA, BETA, ALPHA]
help_text:
brief: Create a Filestore backup.
description: |
Create a Filestore backup of an instance file share.
This command can fail for the following reasons:
* A backup with the same name already exists.
* The active account does not have permission to create backups.
examples: |
To create a backup with the name 'my-backup' and description 'My backup description' in a
particular region like 'us-central1' from an instance called 'my-instance' in 'us-central1-c'
and the source file share called 'my-fs', run:
$ {command} my-backup --instance=my-instance --file-share=my-fs --instance-zone=us-central1-c --region=us-central1 --description="My backup description"
arguments:
params:
- arg_name: backup
is_positional: true
required: true
help_text: |
Arguments and flags that specify the Filestore backup you want to
create.
- arg_name: instance
required: true
help_text: |
Share name of the Filestore instance you want to backup.
- arg_name: region
required: true
help_text: |
Region (e.g. us-central1) for the backup.
- group:
mutex: true
required: true
params:
- arg_name: instance-zone
help_text: |
Zone of the Filestore instance.
- arg_name: instance-location
release_tracks: [BETA, GA]
help_text: |
Region of the Filestore instance.
- api_field: backup.description
arg_name: description
required: false
help_text: |
Description for the backup. Limit: 2048 characters.
- api_field: backup.kmsKeyName
arg_name: kms-key
required: false
release_tracks: [BETA]
help_text: |
CMEK for backup in the form of `projects/{project}/locations/{location}/keyRings/{key-ring}/cryptoKeys/{crypto-key}`
- api_field: backup.kmsKey
arg_name: kms-key
required: false
release_tracks: [GA]
help_text: |
CMEK for backup in the form of `projects/{project}/locations/{location}/keyRings/{key-ring}/cryptoKeys/{crypto-key}`
- api_field: backup.sourceFileShare
arg_name: file-share
required: true
help_text: |
File share name on the Filestore instance to backup.
- api_field: backup.labels.additionalProperties
arg_name: labels
metavar: KEY=VALUE
required: false
help_text: |
List of label KEY=VALUE pairs to add.
type:
arg_dict:
flatten: true
spec:
- api_field: key
- api_field: value
- api_field: backup.tags.additionalProperties
arg_name: tags
release_tracks: [BETA, GA]
required: false
metavar: KEY=VALUE
help_text: |
List of tag KEY=VALUE pairs to add.
type:
arg_dict:
flatten: true
spec:
- api_field: key
- api_field: value
async:
collection: file.projects.locations.operations
request:
ALPHA:
api_version: v1p1alpha1
BETA:
api_version: v1beta1
GA:
api_version: v1
display_resource_type: backup
collection: file.projects.locations.backups
# Disable validating that a backups resource arg is specified (as we are using the
# file.projects.locations.backups collection). This collection is populated manually.
disable_resource_check: true
modify_request_hooks:
- googlecloudsdk.command_lib.filestore.backups.util:FormatBackupCreateRequest
- googlecloudsdk.command_lib.filestore.backups.util:AddInstanceNameToRequest

View File

@@ -0,0 +1,52 @@
- release_tracks: [GA, BETA, ALPHA]
help_text:
brief: |
Delete a Filestore backup.
description: |
Delete a Filestore backup.
This command can fail for the following reasons:
* The backup specified does not exist.
* The active account does not have permission to delete the given
backup.
examples: |
The following command deletes a backup with the name 'my-backup' in the region
us-central1:
$ {command} my-backup --region=us-central1
arguments:
params:
- arg_name: backup
required: true
is_positional: true
help_text: |
Arguments and flags that specify the Filestore backup you want to
delete.
- arg_name: region
required: true
help_text: |
Compute region (e.g. us-central1) for the backup.
async:
collection: file.projects.locations.operations
request_issued_message: |-
Delete request issued
input:
confirmation_prompt: |
You are about to delete a backup
request:
ALPHA:
api_version: v1p1alpha1
BETA:
api_version: v1beta1
GA:
api_version: v1
display_resource_type: backup
collection: file.projects.locations.backups
disable_resource_check: true
modify_request_hooks:
- googlecloudsdk.command_lib.filestore.backups.util:FormatBackupAccessRequest

View File

@@ -0,0 +1,41 @@
- release_tracks: [GA, BETA, ALPHA]
help_text:
brief: |
Describe a Filestore backup.
description: |
Displays all data associated with a Filestore backup given a valid backup name.
This command can fail for the following reasons:
* The backup specified does not exist.
* The active account does not have permission to access the given
backup.
examples: |
To display all data associated with a backup of the name 'my-backup' in the
region us-central1:
$ {command} my-backup --region=us-central1
arguments:
params:
- arg_name: backup
required: true
is_positional: true
help_text: |
Arguments and flags that specify the Filestore backup you want to
create.
- arg_name: region
required: true
help_text: |
Region (e.g. us-central1) for the backup.
request:
ALPHA:
api_version: v1p1alpha1
BETA:
api_version: v1beta1
GA:
api_version: v1
collection: file.projects.locations.backups
disable_resource_check: true
modify_request_hooks:
- googlecloudsdk.command_lib.filestore.backups.util:FormatBackupAccessRequest

View File

@@ -0,0 +1,47 @@
- release_tracks: [GA, BETA, ALPHA]
help_text:
brief: |
List Filestore backups.
description: |
List all Filestore backups in a project for either a specified region or for all region.
To specify the maximum number of backups to list, use the --limit flag.
examples: |
To list up to five backups, run:
$ {command} --limit=5
arguments:
params:
- arg_name: region
help_text: |
The region of the Backups to display. If unspecified, all backups will be listed.
resource:
help_text: |
Project name.
spec: !REF googlecloudsdk.command_lib.filestore.resources:project
override_resource_collection: true
request:
ALPHA:
api_version: v1p1alpha1
BETA:
api_version: v1beta1
GA:
api_version: v1
collection: file.projects.locations.backups
modify_request_hooks:
- googlecloudsdk.command_lib.filestore.util:AddDefaultLocationToListRequest
response:
id_field: name
output:
format: |
table(
name.basename():label=NAME:sort=1,
name.segment(3):label=LOCATION,
sourceInstance.split('/').slice(3:).join('/'):label=SRC_INSTANCE,
sourceFileShare:label=SRC_FILE_SHARE,
state
)

View File

@@ -0,0 +1,56 @@
- release_tracks: [GA, BETA, ALPHA]
help_text:
brief: |
Update a Filestore backup.
description: |
Update the metadata of a Filestore backup.
This command can fail for the following reasons:
* The backup specified does not exist.
* The active account does not have permission to update the given
backup.
examples: |
The following command updates the Filestore Backup named 'my-backup' in region
us-central1 to change the description to 'A new description.'
$ {command} my-backup --region=us-central1 --description="A new description."
arguments:
params:
- arg_name: backup
is_positional: true
required: true
help_text: |
Arguments and flags that specify the Filestore backup you want to
update.
- arg_name: region
required: true
help_text: |
Compute region (e.g. us-central1) for the backup.
- arg_name: description
api_field: backup.description
help_text: |
Description of the backup.
additional_arguments_hook: googlecloudsdk.command_lib.filestore.update_util:UpdateLabelsFlags
response:
modify_response_hooks:
- googlecloudsdk.command_lib.filestore.backups.update_util:FormatBackupUpdateResponse
async:
collection: file.projects.locations.operations
request:
ALPHA:
api_version: v1p1alpha1
BETA:
api_version: v1beta1
GA:
api_version: v1
display_resource_type: backup
collection: file.projects.locations.backups
modify_request_hooks:
- googlecloudsdk.command_lib.filestore.backups.util:FormatBackupAccessRequest
- googlecloudsdk.command_lib.filestore.backups.update_util:GetExistingBackup
- googlecloudsdk.command_lib.filestore.backups.update_util:AddDescription
- googlecloudsdk.command_lib.filestore.backups.update_util:UpdateLabels

View File

@@ -0,0 +1,25 @@
# -*- coding: utf-8 -*- #
# Copyright 2017 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 sub-group for the Filestore Instances."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
class Instances(base.Group):
"""Create and manage Filestore instances."""

View File

@@ -0,0 +1,353 @@
# -*- coding: utf-8 -*- #
# Copyright 2017 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.
"""Creates a Filestore instance."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.filestore import filestore_client
from googlecloudsdk.calliope import base
from googlecloudsdk.calliope import exceptions
from googlecloudsdk.command_lib.filestore.instances import flags as instances_flags
from googlecloudsdk.command_lib.util.args import labels_util
from googlecloudsdk.core import log
from googlecloudsdk.core import properties
import six
def _CommonArgs(parser, api_version=filestore_client.V1_API_VERSION):
instances_flags.AddInstanceCreateArgs(parser, api_version)
@base.UniverseCompatible
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Create(base.CreateCommand):
"""Create a Filestore instance."""
_API_VERSION = filestore_client.V1_API_VERSION
detailed_help = {
'DESCRIPTION': 'Create a Filestore instance.',
'EXAMPLES': """\
To create a Basic HDD instance named `my-instance` in zone `us-central1-c` with a 1TB volume named `my_vol` on the default network, run:
$ {command} my-instance --zone=us-central1-c --tier=BASIC_HDD --file-share=name=my_vol,capacity=1TB --network=name=default
To create an Enterprise instance named `my-ent-instance` in region `us-central1` with a 2TB volume named `my_vol` on network `my-network`, run:
$ {command} my-ent-instance --zone=us-central1 --tier=ENTERPRISE --file-share=name=my_vol,capacity=2TB --network=name=my-network
To create an instance with specific NFS export options, you can use a JSON configuration file with `--flags-file`. For example, create a file named `config.json` with the following content:
{
"--file-share":
{
"capacity": "1024",
"name": "my_vol",
"nfs-export-options": [
{
"access-mode": "READ_WRITE",
"ip-ranges": [
"10.0.0.0/8"
],
"squash-mode": "NO_ROOT_SQUASH"
},
{
"access-mode": "READ_ONLY",
"ip-ranges": [
"192.168.0.0/24"
],
"squash-mode": "ROOT_SQUASH",
"anon_uid": 1003,
"anon_gid": 1003
}
]
}
}
To create a Basic SSD instance named `my-nfs-instance` using the above configuration file, run:
$ {command} my-nfs-instance --zone=us-central1-c --tier=BASIC_SSD --network=name=default --flags-file=config.json
""",
}
@staticmethod
def Args(parser):
_CommonArgs(parser, Create._API_VERSION)
def Run(self, args):
"""Create a Filestore instance in the current project."""
instance_ref = args.CONCEPTS.instance.Parse()
client = filestore_client.FilestoreClient(self._API_VERSION)
tier = instances_flags.GetTierArg(client.messages).GetEnumForChoice(
args.tier
)
protocol = None
if args.protocol is not None:
protocol = instances_flags.GetProtocolArg(
client.messages
).GetEnumForChoice(args.protocol)
ldap = args.ldap or None
labels = labels_util.ParseCreateArgs(args,
client.messages.Instance.LabelsValue)
tags = instances_flags.GetTagsFromArgs(args,
client.messages.Instance.TagsValue)
try:
nfs_export_options = client.MakeNFSExportOptionsMsg(
messages=client.messages,
nfs_export_options=args.file_share.get('nfs-export-options', []))
except KeyError as err:
raise exceptions.InvalidArgumentException('--file-share',
six.text_type(err))
instance = client.ParseFilestoreConfig(
tier=tier,
protocol=protocol,
description=args.description,
file_share=args.file_share,
network=args.network,
performance=args.performance,
labels=labels,
tags=tags,
zone=instance_ref.locationsId,
nfs_export_options=nfs_export_options,
kms_key_name=instances_flags.GetAndValidateKmsKeyName(args),
ldap=ldap,
source_instance=args.source_instance,
deletion_protection_enabled=args.deletion_protection,
deletion_protection_reason=args.deletion_protection_reason)
result = client.CreateInstance(instance_ref, args.async_, instance)
if args.async_:
command = properties.VALUES.metrics.command_name.Get().split('.')
if command:
command[-1] = 'list'
log.status.Print(
'Check the status of the new instance by listing all instances:\n '
'$ {} '.format(' '.join(command)))
return result
@base.UniverseCompatible
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class CreateBeta(Create):
"""Create a Filestore instance."""
_API_VERSION = filestore_client.BETA_API_VERSION
detailed_help = {
'DESCRIPTION': 'Create a Filestore instance.',
'EXAMPLES': """\
To create a Basic HDD instance named `my-instance` in zone `us-central1-c` with a 1TB volume named `my_vol` on the default network, run:
$ {command} my-instance --zone=us-central1-c --tier=BASIC_HDD --file-share=name=my_vol,capacity=1TB --network=name=default
To create an Enterprise instance named `my-ent-instance` in region `us-central1` with a 2TB volume named `my_vol` on network `my-network`, run:
$ {command} my-ent-instance --zone=us-central1 --tier=ENTERPRISE --file-share=name=my_vol,capacity=2TB --network=name=my-network
To create an instance with specific NFS export options, you can use a JSON configuration file with `--flags-file`. For example, create a file named `config.json` with the following content:
{
"--file-share":
{
"capacity": "1024",
"name": "my_vol",
"nfs-export-options": [
{
"access-mode": "READ_WRITE",
"ip-ranges": [
"10.0.0.0/8"
],
"squash-mode": "NO_ROOT_SQUASH"
},
{
"access-mode": "READ_ONLY",
"ip-ranges": [
"192.168.0.0/24"
],
"squash-mode": "ROOT_SQUASH",
"anon_uid": 1003,
"anon_gid": 1003
}
]
}
}
To create a Basic SSD instance named `my-nfs-instance` using the above configuration file, run:
$ {command} my-nfs-instance --zone=us-central1-c --tier=BASIC_SSD --network=name=default --flags-file=config.json
""",
}
@staticmethod
def Args(parser):
_CommonArgs(parser, CreateBeta._API_VERSION)
def Run(self, args):
"""Creates a Filestore instance in the current project.
Note: This is a copied code from Run() of base.ReleaseTrack.GA.
Args:
args: A list of fields.
Returns:
A filestore instance.
"""
instance_ref = args.CONCEPTS.instance.Parse()
client = filestore_client.FilestoreClient(self._API_VERSION)
tier = instances_flags.GetTierArg(client.messages).GetEnumForChoice(
args.tier
)
protocol = None
if args.protocol is not None:
protocol = instances_flags.GetProtocolArg(
client.messages
).GetEnumForChoice(args.protocol)
backend_type = None
if args.backend_type is not None:
backend_type = instances_flags.GetBackendTypeArg(
client.messages
).GetEnumForChoice(args.backend_type)
managed_ad = args.managed_ad or None
ldap = args.ldap or None
source_instance = args.source_instance or None
labels = labels_util.ParseCreateArgs(
args, client.messages.Instance.LabelsValue)
tags = instances_flags.GetTagsFromArgs(args,
client.messages.Instance.TagsValue)
try:
nfs_export_options = client.MakeNFSExportOptionsMsgBeta(
messages=client.messages,
nfs_export_options=args.file_share.get('nfs-export-options', []))
except KeyError as err:
raise exceptions.InvalidArgumentException('--file-share',
six.text_type(err))
instance = client.ParseFilestoreConfig(
tier=tier,
protocol=protocol,
description=args.description,
file_share=args.file_share,
network=args.network,
performance=args.performance,
labels=labels,
tags=tags,
zone=instance_ref.locationsId,
nfs_export_options=nfs_export_options,
kms_key_name=instances_flags.GetAndValidateKmsKeyName(args),
managed_ad=managed_ad,
ldap=ldap,
source_instance=source_instance,
deletion_protection_enabled=args.deletion_protection,
deletion_protection_reason=args.deletion_protection_reason,
backend_type=backend_type,
)
result = client.CreateInstance(instance_ref, args.async_, instance)
if args.async_:
command = properties.VALUES.metrics.command_name.Get().split('.')
if command:
command[-1] = 'list'
log.status.Print(
'Check the status of the new instance by listing all instances:\n '
'$ {} '.format(' '.join(command)))
return result
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class CreateAlpha(Create):
"""Create a Filestore instance."""
_API_VERSION = filestore_client.ALPHA_API_VERSION
detailed_help = {
'DESCRIPTION':
'Create a Filestore instance.',
'EXAMPLES':
"""\
The following command creates a Filestore instance named NAME with a single volume.
$ {command} NAME \
--description=DESCRIPTION --tier=TIER \
--file-share=name=VOLUME_NAME,capacity=CAPACITY \
--network=name=NETWORK_NAME,reserved-ip-range=RESERVED_IP_RANGE,connect-mode=CONNECT_MODE \
--zone=ZONE \
--flags-file=FLAGS_FILE
Example json configuration file:
{
"--file-share":
{
"capacity": "61440",
"name": "my_vol",
"nfs-export-options": [
{
"access-mode": "READ_WRITE",
"ip-ranges": [
"10.0.0.0/8",
],
"squash-mode": "NO_ROOT_SQUASH",
},
{
"access-mode": "READ_ONLY",
"ip-ranges": [
"192.168.0.0/24"
],
"squash-mode": "ROOT_SQUASH"
"anon_uid": 1003,
"anon_gid": 1003
}
],
}
}
"""
}
@staticmethod
def Args(parser):
_CommonArgs(parser, CreateAlpha._API_VERSION)
def Run(self, args):
"""Create a Filestore instance in the current project."""
instance_ref = args.CONCEPTS.instance.Parse()
client = filestore_client.FilestoreClient(self._API_VERSION)
tier = instances_flags.GetTierArg(client.messages).GetEnumForChoice(
args.tier
)
labels = labels_util.ParseCreateArgs(args,
client.messages.Instance.LabelsValue)
try:
nfs_export_options = client.MakeNFSExportOptionsMsg(
messages=client.messages,
nfs_export_options=args.file_share.get('nfs-export-options', []))
except KeyError as err:
raise exceptions.InvalidArgumentException('--file-share',
six.text_type(err))
instance = client.ParseFilestoreConfig(
tier=tier,
description=args.description,
file_share=args.file_share,
network=args.network,
labels=labels,
zone=instance_ref.locationsId,
nfs_export_options=nfs_export_options)
result = client.CreateInstance(instance_ref, args.async_, instance)
if args.async_:
command = properties.VALUES.metrics.command_name.Get().split('.')
if command:
command[-1] = 'list'
log.status.Print(
'Check the status of the new instance by listing all instances:\n '
'$ {} '.format(' '.join(command)))
return result

View File

@@ -0,0 +1,145 @@
# -*- coding: utf-8 -*- #
# Copyright 2017 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.
"""Deletes a Filestore instance."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.filestore import filestore_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.filestore import flags
from googlecloudsdk.command_lib.filestore.instances import flags as instances_flags
from googlecloudsdk.command_lib.util.concepts import concept_parsers
from googlecloudsdk.core import log
from googlecloudsdk.core import properties
from googlecloudsdk.core.console import console_io
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Delete(base.DeleteCommand):
"""Delete a Filestore instance."""
_API_VERSION = filestore_client.V1_API_VERSION
@staticmethod
def Args(parser):
concept_parsers.ConceptParser([flags.GetInstancePresentationSpec(
'The instance to delete.')]).AddToParser(parser)
instances_flags.AddLocationArg(parser)
instances_flags.AddRegionArg(parser)
instances_flags.AddAsyncFlag(parser)
instances_flags.AddForceArg(parser)
def Run(self, args):
"""Deletes a Filestore instance."""
instance_ref = args.CONCEPTS.instance.Parse()
delete_warning = ('You are about to delete Filestore instance {}.\n'
'Are you sure?'.format(instance_ref.RelativeName()))
if not console_io.PromptContinue(message=delete_warning):
return None
client = filestore_client.FilestoreClient(version=self._API_VERSION)
result = client.DeleteInstance(instance_ref, args.async_, args.force)
if args.async_:
command = properties.VALUES.metrics.command_name.Get().split('.')
if command:
command[-1] = 'list'
log.status.Print(
'Check the status of the deletion by listing all instances:\n '
'$ {} '.format(' '.join(command)))
return result
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class DeleteBeta(Delete):
"""Delete a Filestore instance."""
_API_VERSION = filestore_client.BETA_API_VERSION
def Run(self, args):
"""Deletes a Filestore instance."""
instance_ref = args.CONCEPTS.instance.Parse()
delete_warning = ('You are about to delete Filestore instance {}.\n'
'Are you sure?'.format(instance_ref.RelativeName()))
if not console_io.PromptContinue(message=delete_warning):
return None
client = filestore_client.FilestoreClient(version=self._API_VERSION)
result = client.DeleteInstance(instance_ref, args.async_, args.force)
if args.async_:
command = properties.VALUES.metrics.command_name.Get().split('.')
if command:
command[-1] = 'list'
log.status.Print(
'Check the status of the deletion by listing all instances:\n '
'$ {} '.format(' '.join(command)))
return result
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class DeleteAlpha(base.DeleteCommand):
"""Delete a Filestore instance."""
_API_VERSION = filestore_client.ALPHA_API_VERSION
@staticmethod
def Args(parser):
concept_parsers.ConceptParser([
flags.GetInstancePresentationSpec('The instance to delete.')
]).AddToParser(parser)
instances_flags.AddLocationArg(parser)
instances_flags.AddRegionArg(parser)
instances_flags.AddAsyncFlag(parser)
def Run(self, args):
"""Delete a Filestore instance."""
instance_ref = args.CONCEPTS.instance.Parse()
delete_warning = ('You are about to delete Filestore instance {}.\n'
'Are you sure?'.format(instance_ref.RelativeName()))
if not console_io.PromptContinue(message=delete_warning):
return None
client = filestore_client.FilestoreClient(version=self._API_VERSION)
result = client.DeleteInstanceAlpha(instance_ref, args.async_)
if args.async_:
command = properties.VALUES.metrics.command_name.Get().split('.')
if command:
command[-1] = 'list'
log.status.Print(
'Check the status of the deletion by listing all instances:\n '
'$ {} '.format(' '.join(command)))
return result
help_ = {
'DESCRIPTION':
'Delete a Filestore instance.',
'EXAMPLES':
"""\
To delete a Filestore instance named NAME in us-central1-c:
$ {command} NAME --zone=us-central1-c
"""
}
Delete.detailed_help = help_
DeleteAlpha.detailed_help = help_

View File

@@ -0,0 +1,72 @@
# -*- coding: utf-8 -*- #
# Copyright 2017 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 show metadata for a Filestore instance."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.filestore import filestore_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.filestore import flags
from googlecloudsdk.command_lib.filestore.instances import flags as instances_flags
from googlecloudsdk.command_lib.util.concepts import concept_parsers
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Describe(base.DescribeCommand):
"""Show metadata for a Filestore instance."""
_API_VERSION = filestore_client.V1_API_VERSION
@staticmethod
def Args(parser):
concept_parsers.ConceptParser([flags.GetInstancePresentationSpec(
'The instance to describe.')]).AddToParser(parser)
instances_flags.AddLocationArg(parser)
instances_flags.AddRegionArg(parser)
def Run(self, args):
"""Run the describe command."""
instance_ref = args.CONCEPTS.instance.Parse()
client = filestore_client.FilestoreClient(version=self._API_VERSION)
return client.GetInstance(instance_ref)
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class DescribeBeta(Describe):
"""Show metadata for a Filestore instance."""
_API_VERSION = filestore_client.BETA_API_VERSION
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class DescribeAlpha(Describe):
"""Show metadata for a Filestore instance."""
_API_VERSION = filestore_client.ALPHA_API_VERSION
Describe.detailed_help = {
'DESCRIPTION':
'Show metadata for a Filestore instance.',
'EXAMPLES':
"""\
The following command shows the metadata for the Filestore instance named NAME
in us-central1-c.
$ {command} NAME --location=us-central1-c
"""
}

View File

@@ -0,0 +1,154 @@
# -*- coding: utf-8 -*- #
# Copyright 2017 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 Filestore instances."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.filestore import filestore_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.filestore import flags
from googlecloudsdk.command_lib.filestore.instances import flags as instances_flags
from googlecloudsdk.command_lib.util.concepts import concept_parsers
from googlecloudsdk.core import properties
from googlecloudsdk.core import resources
@base.UniverseCompatible
@base.ReleaseTracks(base.ReleaseTrack.GA)
class List(base.ListCommand):
"""List Filestore instances."""
_API_VERSION = filestore_client.V1_API_VERSION
@staticmethod
def Args(parser):
concept_parsers.ConceptParser([flags.GetListingLocationPresentationSpec(
'The location in which to list instances.')]).AddToParser(parser)
instances_flags.AddLocationArg(parser)
instances_flags.AddRegionArg(parser)
parser.display_info.AddFormat(
instances_flags.INSTANCES_LIST_FORMAT_V1_ALPAH
)
def UriFunc(resource):
registry = filestore_client.GetFilestoreRegistry()
ref = registry.Parse(
resource.name, collection=filestore_client.INSTANCES_COLLECTION)
return ref.SelfLink()
parser.display_info.AddUriFunc(UriFunc)
def Run(self, args):
"""Run the list command."""
# Ensure that project is set before parsing location resource.
properties.VALUES.core.project.GetOrFail()
location_ref = args.CONCEPTS.zone.Parse().RelativeName()
if args.zone is None and args.location is not None:
location_list = location_ref.split('/')
location_list[-1] = args.location
location_ref = '/'.join(location_list)
client = filestore_client.FilestoreClient(version=self._API_VERSION)
return list(client.ListInstances(location_ref, limit=args.limit))
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class ListBeta(List):
"""List Filestore instances."""
_API_VERSION = filestore_client.BETA_API_VERSION
@staticmethod
def Args(parser):
concept_parsers.ConceptParser([
flags.GetListingLocationPresentationSpec(
'The location in which to list instances.')
]).AddToParser(parser)
instances_flags.AddLocationArg(parser)
instances_flags.AddRegionArg(parser)
parser.display_info.AddFormat(
instances_flags.INSTANCES_LIST_FORMAT_BETA
)
def UriFunc(resource):
registry = filestore_client.GetFilestoreRegistry(
filestore_client.BETA_API_VERSION)
ref = registry.Parse(
resource.name, collection=filestore_client.INSTANCES_COLLECTION)
return ref.SelfLink()
parser.display_info.AddUriFunc(UriFunc)
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class ListAlpha(List):
"""List Filestore instances."""
_API_VERSION = filestore_client.ALPHA_API_VERSION
@staticmethod
def Args(parser):
concept_parsers.ConceptParser([flags.GetListingLocationPresentationSpec(
'The location in which to list instances.')]).AddToParser(parser)
instances_flags.AddLocationArg(parser)
instances_flags.AddRegionArg(parser)
parser.display_info.AddFormat(
instances_flags.INSTANCES_LIST_FORMAT_V1_ALPAH
)
def UriFunc(resource):
registry = resources.REGISTRY.Clone()
registry.RegisterApiByName(
filestore_client.API_NAME,
api_version=filestore_client.ALPHA_API_VERSION)
ref = registry.Parse(
resource.name, collection=filestore_client.INSTANCES_COLLECTION)
return ref.SelfLink()
parser.display_info.AddUriFunc(UriFunc)
def Run(self, args):
"""Run the list command."""
# Ensure that project is set before parsing location resource.
properties.VALUES.core.project.GetOrFail()
location_ref = args.CONCEPTS.zone.Parse().RelativeName()
# Fetch the location value from fallback options when args.zone is absent.
# The fallback options will check args.region first, then args.location if
# args.region also absent.
if args.zone is None:
location_list = location_ref.split('/')
if args.region is not None:
location_list[-1] = args.region
elif args.location is not None:
location_list[-1] = args.location
location_ref = '/'.join(location_list)
client = filestore_client.FilestoreClient(version=self._API_VERSION)
return list(client.ListInstances(location_ref, limit=args.limit))
List.detailed_help = {
'DESCRIPTION':
'',
'EXAMPLES':
"""\
The following command lists a maximum of five Filestore instances sorted
alphabetically by name in descending order:
$ {command} --limit=5 --sort-by=~name
"""
}

View File

@@ -0,0 +1,44 @@
- release_tracks: [BETA, GA]
help_text:
brief: Pause a Filestore replica instance.
description: |
Pause a Filestore replica instance. This command can be called only on a standby instance.
After calling the command, the NFS file system of the standby instance becomes writeable. Any
data changed on the standby instance while it is paused will be lost when the replica is
resumed or promoted.
examples: |
To pause a replica instance with the name ``my-replica-instance'' located in ``us-central1-c'',
run:
$ {command} my-replica-instance --zone=us-central1
arguments:
resource:
spec: !REF googlecloudsdk.command_lib.filestore.resources:instance
help_text: |
Arguments and flags that specify the Filestore instance to pause.
command_level_fallthroughs:
zone:
- arg_name: location
release_tracks: [BETA, GA]
params:
- arg_name: location
release_tracks: [BETA, GA]
help_text: |
Location of the Filestore instance to pause.
request:
BETA:
api_version: v1beta1
GA:
api_version: v1
collection: file.projects.locations.instances
method: pauseReplica
async:
collection: file.projects.locations.operations
input:
confirmation_prompt: |
Warning: You are about to pause a standby replica instance, this action makes the standby
instance's NFS filesystem writeable.

View File

@@ -0,0 +1,64 @@
- release_tracks: [BETA, GA]
help_text:
brief: Promote a Filestore standby replication instance.
description: |
Promote a Filestore standby replication instance to a regular instance. This command can be
called directly on the standby instance or on the active instance with the standby peer
instance parameter.
When used on the standby instance promotes the standby instance to a regular instance even if
the active instance is unavailable.
When used on the active instance detaches the standby instance from the active instance even
if the standby instance is unavailable.
This command can fail for the following reasons:
* The target instance does not exist.
* The instance is not a standby replication member.
* The instance is an active instance and the peer instance parameter is missing or invalid.
examples: |
To promote a standby instance with the name ``my-replica-instance'' located in
``us-central1'', run:
$ {command} my-replica-instance --zone=us-central1
To promote a standby instance with the name ``my-replica-instance'' located in
``us-central1'', attached to the active peer instance ``my-active-instance'' located in
``us-west1'', run:
$ {command} my-active-instance --zone=us-west1 \
--peer-instance=projects/my-project/locations/us-central1/instances/my-replica-instance
arguments:
resource:
spec: !REF googlecloudsdk.command_lib.filestore.resources:instance
help_text: |
Arguments and flags that specify the Filestore instance to promote.
command_level_fallthroughs:
zone:
- arg_name: location
release_tracks: [BETA, GA]
params:
- arg_name: location
release_tracks: [BETA, GA]
help_text: |
Location of the Filestore instance to promote.
- arg_name: peer-instance
release_tracks: [BETA, GA]
api_field: promoteReplicaRequest.peerInstance
help_text: |
The name of the standby peer instance to promote.
request:
BETA:
api_version: v1beta1
GA:
api_version: v1
collection: file.projects.locations.instances
method: promoteReplica
async:
collection: file.projects.locations.operations
input:
confirmation_prompt: |
Warning: You are about to promote a replication standby instance, this action will
permanently remove replication settings and convert the standby into a regular instance.

View File

@@ -0,0 +1,140 @@
- release_tracks: [GA, BETA, ALPHA]
help_text:
ALPHA:
brief: |
Restore a Filestore instance from a snapshot or backup.
description: |
Restore an existing Filestore instance from an existing snapshot
or backup.
examples: |
The following command restores an instance named 'my-instance' with a
fileshare named 'vol1' in the zone europe-west3-a from a backup named
'my-backup' in the region europe-west3.
$ {command} my-instance \
--zone=europe-west3-a \
--file-share=vol1 \
--source-backup=my-backup \
--source-backup-region=europe-west3
BETA:
brief: |
Restore a Filestore instance from a backup.
description: |
Restore an existing Filestore instance from an existing backup.
examples: |
The following command restores an instance named 'my-instance' with a
fileshare named 'vol1' in the zone europe-west3-a from a backup named
'my-backup' in the region europe-west3.
$ {command} my-instance \
--zone=europe-west3-a \
--file-share=vol1 \
--source-backup=my-backup \
--source-backup-region=europe-west3
GA:
brief: |
Restore a Filestore instance from a backup.
description: |
Restore an existing Filestore instance from an existing backup.
examples: |
The following command restores an instance named 'my-instance' with a
fileshare named 'vol1' in the zone europe-west3-a from a backup named
'my-backup' in the region europe-west3.
$ {command} my-instance \
--zone=europe-west3-a \
--file-share=vol1 \
--source-backup=my-backup \
--source-backup-region=europe-west3
arguments:
resource:
spec: !REF googlecloudsdk.command_lib.filestore.resources:instance
help_text: |
Arguments and flags that specify the Filestore instance to restore.
command_level_fallthroughs:
zone:
- arg_name: location
release_tracks: [BETA]
params:
- arg_name: file-share
required: true
api_field: restoreInstanceRequest.fileShare
ALPHA:
help_text:
File share to restore from the snapshot or backup.
BETA:
help_text:
File share to restore from the backup.
GA:
help_text:
File share to restore from the backup.
- arg_name: source-backup
release_tracks: [GA, BETA]
required: true
help_text: |
Name of the Filestore backup to restore from.
- arg_name: source-backup-region
release_tracks: [GA, BETA]
required: true
help_text: |
Region of the Filestore backup to restore from.
- arg_name: location
release_tracks: [BETA]
help_text: |
Location of the Filestore instance to restore this backup to.
- group:
release_tracks: [ALPHA]
required: true
ALPHA:
mutex: true
params:
- group:
help_text: |
The name and region of the Filestore snapshot to restore from.
params:
- arg_name: source-snapshot
required: true
help_text: |
Name of the Filestore snapshot to restore from.
- arg_name: source-snapshot-region
required: false
help_text: |
Region of the Filestore snapshot to restore from. If unspecified, it
is assumed that the Filestore snapshot is local.
- group:
help_text: |
The name and region of the Filestore backup to restore from.
params:
- arg_name: source-backup
required: true
help_text: |
Name of the Filestore backup to restore from.
- arg_name: source-backup-region
required: true
help_text: |
Region of the Filestore backup to restore from.
request:
ALPHA:
api_version: v1p1alpha1
modify_request_hooks:
- googlecloudsdk.command_lib.filestore.backups.util:AddBackupNameToRequest
- googlecloudsdk.command_lib.filestore.snapshots.util:AddSnapshotNameToRequest
BETA:
api_version: v1beta1
modify_request_hooks:
- googlecloudsdk.command_lib.filestore.backups.util:AddBackupNameToRequest
GA:
api_version: v1
modify_request_hooks:
- googlecloudsdk.command_lib.filestore.backups.util:AddBackupNameToRequest
collection: file.projects.locations.instances
method: restore
async:
collection: file.projects.locations.operations
input:
confirmation_prompt: |
You are about to override existing data in [{__name__}].

View File

@@ -0,0 +1,45 @@
- release_tracks: [BETA, GA]
help_text:
brief: Resume a Filestore replica instance.
description: |
Resume a Filestore replica instance. This command can be called only on a paused standby
instance.
Any data written to the standby instance while being paused will be lost when the replica is
resumed. The NFS file system of the standby instance becomes inaccessible and replication is
resumed.
examples: |
To resume a replica instance with the name ``my-replica-instance'' located in ``us-central1-c''
, run:
$ {command} my-replica-instance --zone=us-central1-c
arguments:
resource:
spec: !REF googlecloudsdk.command_lib.filestore.resources:instance
help_text: |
Arguments and flags that specify the Filestore instance to resume.
command_level_fallthroughs:
zone:
- arg_name: location
release_tracks: [BETA, GA]
params:
- arg_name: location
release_tracks: [BETA, GA]
help_text: |
Location of the Filestore instance to resume.
request:
BETA:
api_version: v1beta1
GA:
api_version: v1
collection: file.projects.locations.instances
method: resumeReplica
async:
collection: file.projects.locations.operations
input:
confirmation_prompt: |
Warning: You are about to resume a standby replica instance, any data written to the
standby instance while paused will be lost.

View File

@@ -0,0 +1,42 @@
- release_tracks: [BETA, GA]
help_text:
brief: Revert a Filestore instance.
description: |
Revert a Filestore instance to the target snapshot.
This command can fail for the following reasons:
* The target snapshot does not exist.
* The active account does not have permission to revert the instance.
* The service tier of the instance does not support the operation.
examples: |
To revert an instance with the name ``my-instance'' that's located in
``us-central1'' to the target snapshot named ``my-snapshot'' , run:
$ {command} my-instance --target-snapshot=my-snapshot --location=us-central1
arguments:
resource:
spec: !REF googlecloudsdk.command_lib.filestore.resources:instance_with_generic_location
help_text: |
Arguments and flags that specify the Filestore instance to revert.
params:
- arg_name: target-snapshot
required: true
api_field: revertInstanceRequest.targetSnapshotId
help_text: |
Name of the Filestore snapshot to revert to.
request:
BETA:
api_version: v1beta1
GA:
api_version: v1
collection: file.projects.locations.instances
method: revert
async:
collection: file.projects.locations.operations
input:
confirmation_prompt: |
You are about to override existing data in [{__name__}].

View File

@@ -0,0 +1,26 @@
# -*- coding: utf-8 -*- #
# Copyright 2021 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 sub-group for the Filestore snapshots."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.BETA, base.ReleaseTrack.GA)
class Snapshots(base.Group):
"""Create and manage Filestore snapshots."""

View File

@@ -0,0 +1,71 @@
- release_tracks: [BETA, GA]
help_text:
brief: Create a Filestore snapshot.
description: |
Create a Filestore snapshot of an instance.
This command can fail for the following reasons:
* A snapshot with the same name already exists.
* The active account does not have permission to create snapshots.
* Maximum number of snapshots for the instance has been reached.
* The service tier of the instance does not support snapshots.
examples: |
To create a snapshot with the name ``my-snapshot'' for an instance named
``my-instance'' that's located in ``us-central1'', run:
$ {command} my-snapshot --instance=my-instance --instance-region=us-central1
arguments:
params:
- arg_name: snapshot
is_positional: true
required: true
help_text: |
Name of the Filestore snapshot to be created.
- arg_name: instance
required: true
help_text: |
Name of the Filestore instance that you want to create a snapshot of.
- group:
mutex: true
required: true
params:
- arg_name: instance-region
help_text: |
Region of the Filestore instance.
- arg_name: instance-location
help_text: |
Location of the Filestore instance.
- api_field: snapshot.description
arg_name: description
required: false
help_text: |
Description of the snapshot. Limit: 2048 characters.
- api_field: snapshot.labels.additionalProperties
arg_name: labels
metavar: KEY=VALUE
required: false
help_text: |
List of label KEY=VALUE pairs to add.
type:
arg_dict:
flatten: true
spec:
- api_field: key
- api_field: value
async:
collection: file.projects.locations.operations
request:
BETA:
api_version: v1beta1
GA:
api_version: v1
display_resource_type: snapshot
collection: file.projects.locations.instances.snapshots
# Disable validating that a snapshot resource arg is specified (as we are using the
# file.projects.locations.instances.snapshots collection). This collection is populated manually.
disable_resource_check: true
modify_request_hooks:
- googlecloudsdk.command_lib.filestore.instances.snapshots.util:FormatSnapshotCreateRequest

View File

@@ -0,0 +1,61 @@
- release_tracks: [BETA, GA]
help_text:
brief: |
Delete a Filestore snapshot.
description: |
Delete a Filestore snapshot.
This command can fail for the following reasons:
* The snapshot or instance specified does not exist.
* The active account does not have permission to delete the given
snapshot.
examples: |
To delete a snapshot named ``my-snapshot'' for the instance ``my-instance''
from ``us-central1'', run:
$ {command} my-snapshot --instance=my-instance --instance-region=us-central1
arguments:
params:
- arg_name: snapshot
required: true
is_positional: true
help_text: |
Name of the Filestore snapshot to be deleted.
- arg_name: instance
required: true
help_text: |
Name of the Filestore instance the snapshot belongs to.
- group:
mutex: true
required: true
params:
- arg_name: instance-region
help_text: |
Region of the Filestore instance.
- arg_name: instance-location
help_text: |
Location of the Filestore instance.
async:
collection: file.projects.locations.operations
request_issued_message: |-
Delete request issued
input:
confirmation_prompt: |
You are about to delete Filestore snapshot. Are you sure?
request:
BETA:
api_version: v1beta1
GA:
api_version: v1
display_resource_type: snapshot
collection: file.projects.locations.instances.snapshots
# Disable validating that a snapshot resource arg is specified (as we are using the
# file.projects.locations.instances.snapshots collection). This collection is populated manually.
disable_resource_check: true
modify_request_hooks:
- googlecloudsdk.command_lib.filestore.instances.snapshots.util:FormatSnapshotAccessRequest

View File

@@ -0,0 +1,50 @@
- release_tracks: [BETA, GA]
help_text:
brief: Display information about a Filestore snapshot.
description: |
Displays information about a Filestore snapshot given a valid snapshot
name, as well as instance name and instance region.
This command can fail for the following reasons:
* The snapshot or instance specified does not exist.
* The active account does not have permission to access the given
snapshot.
examples: |
To display all information associated with a snapshot of the name
``my-snapshot'' for the instance ``my-instance'' from ``us-central1'', run:
$ {command} my-snapshot --instance=my-instance --instance-region=us-central1
arguments:
params:
- arg_name: snapshot
required: true
is_positional: true
help_text: |
Name of the Filestore snapshot to display information about.
- arg_name: instance
required: true
help_text: |
Name of the Filestore instance the snapshot belongs to.
- group:
mutex: true
required: true
params:
- arg_name: instance-region
help_text: |
Region of the Filestore instance.
- arg_name: instance-location
help_text: |
Location of the Filestore instance.
request:
BETA:
api_version: v1beta1
GA:
api_version: v1
collection: file.projects.locations.instances.snapshots
# Disable validating that a snapshot resource arg is specified (as we are using the
# file.projects.locations.instances.snapshots collection). This collection is populated manually.
disable_resource_check: true
modify_request_hooks:
- googlecloudsdk.command_lib.filestore.instances.snapshots.util:FormatSnapshotAccessRequest

View File

@@ -0,0 +1,58 @@
- release_tracks: [BETA, GA]
help_text:
brief: |
List Filestore snapshots.
description: |
List all Filestore snapshots for the specified instance.
To limit the number of snapshots to list, use the `--limit` flag.
This command can fail for the following reasons:
* Specified instance does not exist.
* The active account does not have permission to list snapshots for the
given instance.
* The service tier of the instance does not support snapshots.
examples: |
To list up to five snapshots for the instance ``my-instance'' from
``us-central1'', run:
$ {command} --instance=my-instance --instance-region=us-central1 --limit=5
arguments:
params:
- arg_name: instance
required: true
help_text: |
Name of the Filestore instance the snapshot belongs to.
- group:
mutex: true
required: true
params:
- arg_name: instance-region
help_text: |
Region of the Filestore instance.
- arg_name: instance-location
help_text: |
Location of the Filestore instance.
request:
BETA:
api_version: v1beta1
GA:
api_version: v1
collection: file.projects.locations.instances.snapshots
# Disable validating that a snapshot resource arg is specified (as we are using the
# file.projects.locations.instances.snapshots collection). This collection is populated manually.
disable_resource_check: true
modify_request_hooks:
- googlecloudsdk.command_lib.filestore.instances.snapshots.util:FormatSnapshotsListRequest
response:
id_field: name
output:
format: |
table(
name.basename():label=NAME:sort=1,
state
)

View File

@@ -0,0 +1,63 @@
- release_tracks: [BETA, GA]
help_text:
brief: |
Update the description or labels of a Filestore snapshot.
description: |
Update the metadata of a Filestore snapshot.
This command can fail for the following reasons:
* The snapshot or instance specified does not exist.
* The active account does not have permission to update the given
snapshot.
examples: |
To update the description of a snapshot named ``my-snapshot'' for the
instance ``my-instance'' from ``us-central1'', run:
$ {command} my-snapshot --instance=my-instance --instance-region=us-central1 --description="A new description."
arguments:
params:
- arg_name: snapshot
is_positional: true
required: true
help_text: |
Name of the Filestore snapshot to be updated.
- arg_name: instance
required: true
help_text: |
Name of the Filestore instance the snapshot belongs to.
- group:
mutex: true
required: true
params:
- arg_name: instance-region
help_text: |
Region of the Filestore instance.
- arg_name: instance-location
help_text: |
Location of the Filestore instance.
- arg_name: description
api_field: snapshot.description
help_text: |
Description of the snapshot.
additional_arguments_hook: googlecloudsdk.command_lib.filestore.update_util:UpdateLabelsFlags
response:
modify_response_hooks:
- googlecloudsdk.command_lib.filestore.instances.snapshots.util:FormatSnapshotUpdateResponse
async:
collection: file.projects.locations.operations
request:
BETA:
api_version: v1beta1
GA:
api_version: v1
display_resource_type: snapshot
collection: file.projects.locations.instances.snapshots
modify_request_hooks:
- googlecloudsdk.command_lib.filestore.instances.snapshots.util:FormatSnapshotAccessRequest
- googlecloudsdk.command_lib.filestore.instances.snapshots.util:GetExistingSnapshot
- googlecloudsdk.command_lib.filestore.instances.snapshots.util:AddDescription
- googlecloudsdk.command_lib.filestore.instances.snapshots.util:UpdateLabels

View File

@@ -0,0 +1,475 @@
# -*- coding: utf-8 -*- #
# Copyright 2018 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 Filestore instance."""
import textwrap
from googlecloudsdk.api_lib.filestore import filestore_client
from googlecloudsdk.calliope import base
from googlecloudsdk.calliope import exceptions
from googlecloudsdk.command_lib.filestore.instances import dp_util
from googlecloudsdk.command_lib.filestore.instances import flags as instances_flags
from googlecloudsdk.command_lib.util.args import labels_util
from googlecloudsdk.core import log
def _CommonArgs(parser, api_version=filestore_client.V1_API_VERSION):
instances_flags.AddInstanceUpdateArgs(parser, api_version)
@base.UniverseCompatible
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Update(base.CreateCommand):
"""Update a Filestore instance."""
_API_VERSION = filestore_client.V1_API_VERSION
detailed_help = {
'DESCRIPTION':
'Update a Filestore instance.',
'EXAMPLES':
textwrap.dedent("""\
The following command updates the Filestore instance NAME to change the
description to "A new description."
$ {command} NAME --description="A new description."
The following command updates a Filestore instance named NAME to add the label
"key1=value1" and remove any metadata with the label "key2".
$ {command} NAME --update-labels=key1=value1 --remove-labels=key2
$ {command} NAME --zone=ZONE --flags-file=FILE_PATH
Example json configuration file:
{
"--file-share":
{
"capacity": "102400",
"name": "my_vol",
"nfs-export-options": [
{
"access-mode": "READ_WRITE",
"ip-ranges": [
"10.0.0.0/29",
"10.2.0.0/29"
],
"squash-mode": "ROOT_SQUASH",
"anon_uid": 1003,
"anon_gid": 1003
}
]
}
}
The following command updates a Filestore instance named NAME to change the
capacity to CAPACITY.
$ {command} NAME --project=PROJECT_ID --zone=ZONE\
--file-share=name=VOLUME_NAME,capacity=CAPACITY
The following command updates a Filestore instance named NAME to configure the
max-iops-per-tb to MAX-IOPS-PER-TB.
$ {command} NAME --project=PROJECT_ID --zone=ZONE\
--performance=max-iops-per-tb=MAX-IOPS-PER-TB
"""),
}
@staticmethod
def Args(parser):
_CommonArgs(parser, Update._API_VERSION)
def Run(self, args):
"""Runs command line arguments.
Args:
args: Command line arguments.
Returns:
The client instance.
Raises:
InvalidArgumentException: For invalid JSON formatted --file-args.
"""
instance_ref = args.CONCEPTS.instance.Parse()
client = filestore_client.FilestoreClient(self._API_VERSION)
labels_diff = labels_util.Diff.FromUpdateArgs(args)
dp_util.ValidateDeletionProtectionUpdateArgs(args)
orig_instance = client.GetInstance(instance_ref)
try:
if args.file_share:
client.MakeNFSExportOptionsMsg(
messages=client.messages,
nfs_export_options=args.file_share.get('nfs-export-options', []),
)
except KeyError as err:
raise exceptions.InvalidArgumentException(
'--file-share', str(err)
)
if labels_diff.MayHaveUpdates():
labels = labels_diff.Apply(
client.messages.Instance.LabelsValue, orig_instance.labels
).GetOrNone()
else:
labels = None
try:
instance = client.ParseUpdatedInstanceConfig(
orig_instance,
description=args.description,
labels=labels,
file_share=args.file_share,
performance=args.performance,
ldap=args.ldap,
disconnect_ldap=args.disconnect_ldap,
clear_nfs_export_options=args.clear_nfs_export_options,
deletion_protection_enabled=args.deletion_protection,
deletion_protection_reason=args.deletion_protection_reason,
)
except filestore_client.InvalidDisconnectLdapError as e:
raise exceptions.InvalidArgumentException(
'--disconnect-ldap', str(e)
)
except filestore_client.InvalidDisconnectManagedADError as e:
raise exceptions.InvalidArgumentException(
'--disconnect-managed-ad', str(e)
)
except filestore_client.Error as e:
raise exceptions.InvalidArgumentException(
'--file-share', str(e)
)
updated_fields = []
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('file_share'):
updated_fields.append('fileShares')
if args.IsSpecified('performance'):
updated_fields.append('performanceConfig')
updated_fields += dp_util.GetDeletionProtectionUpdateMask(args)
if args.IsSpecified('ldap') or args.IsSpecified('disconnect_ldap'):
updated_fields.append('directoryServices')
update_mask = ','.join(updated_fields)
result = client.UpdateInstance(
instance_ref, instance, update_mask, args.async_
)
if args.async_:
log.status.Print(
'To check the status of the operation, run `gcloud filestore '
'operations describe {}`'.format(result.name)
)
return result
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class UpdateAlpha(Update):
"""Update a Filestore instance."""
_API_VERSION = filestore_client.ALPHA_API_VERSION
detailed_help = {
'DESCRIPTION':
'Update a Filestore instance.',
'EXAMPLES':
textwrap.dedent("""\
The following command updates the Filestore instance NAME to change the
description to "A new description."
$ {command} NAME --description="A new description."
The following command updates a Filestore instance named NAME to add the label
"key1=value1" and remove any metadata with the label "key2".
$ {command} NAME --update-labels=key1=value1 --remove-labels=key2
$ {command} NAME --zone=ZONE --flags-file=FILE_PATH
Example json configuration file:
{
"--file-share":
{
"capacity": "102400",
"name": "my_vol",
"nfs-export-options": [
{
"access-mode": "READ_WRITE",
"ip-ranges": [
"10.0.0.0/29",
"10.2.0.0/29"
],
"squash-mode": "ROOT_SQUASH",
"anon_uid": 1003,
"anon_gid": 1003
}
]
}
}
The following command updates a Filestore instance named NAME to change the
capacity to CAPACITY.
$ {command} NAME --project=PROJECT_ID --zone=ZONE\
--file-share=name=VOLUME_NAME,capacity=CAPACITY
"""),
}
@staticmethod
def Args(parser):
_CommonArgs(parser, UpdateAlpha._API_VERSION)
def Run(self, args):
"""Runs command line arguments.
Args:
args: Command line arguments.
Returns:
The client instance.
Raises:
InvalidArgumentException: For invalid JSON formatted --file-args.
"""
instance_ref = args.CONCEPTS.instance.Parse()
client = filestore_client.FilestoreClient(self._API_VERSION)
labels_diff = labels_util.Diff.FromUpdateArgs(args)
orig_instance = client.GetInstance(instance_ref)
try:
if args.file_share:
client.MakeNFSExportOptionsMsg(
messages=client.messages,
nfs_export_options=args.file_share.get('nfs-export-options', []),
)
except KeyError as err:
raise exceptions.InvalidArgumentException(
'--file-share', str(err)
)
if labels_diff.MayHaveUpdates():
labels = labels_diff.Apply(
client.messages.Instance.LabelsValue, orig_instance.labels
).GetOrNone()
else:
labels = None
try:
instance = client.ParseUpdatedInstanceConfig(
orig_instance,
description=args.description,
labels=labels,
file_share=args.file_share,
clear_nfs_export_options=args.clear_nfs_export_options,
)
except filestore_client.Error as e:
raise exceptions.InvalidArgumentException(
'--file-share', str(e)
)
updated_fields = []
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('file_share'):
updated_fields.append('fileShares')
update_mask = ','.join(updated_fields)
result = client.UpdateInstance(
instance_ref, instance, update_mask, args.async_
)
if args.async_:
log.status.Print(
'To check the status of the operation, run `gcloud alpha filestore '
'operations describe {}`'.format(result.name)
)
return result
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class UpdateBeta(Update):
"""Update a Filestore instance."""
_API_VERSION = filestore_client.BETA_API_VERSION
detailed_help = {
'DESCRIPTION':
'Update a Filestore instance.',
'EXAMPLES':
textwrap.dedent("""\
The following command updates the Filestore instance NAME to change the
description to "A new description."
$ {command} NAME --description="A new description."
The following command updates a Filestore instance named NAME to add the label
"key1=value1" and remove any metadata with the label "key2".
$ {command} NAME --update-labels=key1=value1 --remove-labels=key2
$ {command} NAME --zone=ZONE --flags-file=FILE_PATH
Example json configuration file:
{
"--file-share":
{
"capacity": "102400",
"name": "my_vol",
"nfs-export-options": [
{
"access-mode": "READ_WRITE",
"ip-ranges": [
"10.0.0.0/29",
"10.2.0.0/29"
],
"squash-mode": "ROOT_SQUASH",
"anon_uid": 1003,
"anon_gid": 1003
}
]
}
}
The following command updates a Filestore instance named NAME to change the
capacity to CAPACITY.
$ {command} NAME --project=PROJECT_ID --zone=ZONE\
--file-share=name=VOLUME_NAME,capacity=CAPACITY
The following command updates a Filestore instance named NAME to configure the
max-iops-per-tb to MAX-IOPS-PER-TB.
$ {command} NAME --project=PROJECT_ID --zone=ZONE\
--performance=max-iops-per-tb=MAX-IOPS-PER-TB
"""),
}
@staticmethod
def Args(parser):
_CommonArgs(parser, UpdateBeta._API_VERSION)
def Run(self, args):
"""Runs a command line string arguments.
Args:
args: cmd line string arguments.
Returns:
client: A FilestoreClient instance.
Raises:
InvalidArgumentException: for invalid JSON formatted --file-args.
KeyError: for key errors in JSON values.
"""
instance_ref = args.CONCEPTS.instance.Parse()
client = filestore_client.FilestoreClient(self._API_VERSION)
labels_diff = labels_util.Diff.FromUpdateArgs(args)
dp_util.ValidateDeletionProtectionUpdateArgs(args)
orig_instance = client.GetInstance(instance_ref)
try:
if args.file_share:
client.MakeNFSExportOptionsMsgBeta(
messages=client.messages,
nfs_export_options=args.file_share.get('nfs-export-options', []),
)
except KeyError as e:
raise exceptions.InvalidArgumentException(
'--file-share', str(e)
)
if labels_diff.MayHaveUpdates():
labels = labels_diff.Apply(
client.messages.Instance.LabelsValue, orig_instance.labels
).GetOrNone()
else:
labels = None
try:
instance = client.ParseUpdatedInstanceConfig(
orig_instance,
description=args.description,
labels=labels,
file_share=args.file_share,
performance=args.performance,
managed_ad=args.managed_ad,
disconnect_managed_ad=args.disconnect_managed_ad,
ldap=args.ldap,
disconnect_ldap=args.disconnect_ldap,
clear_nfs_export_options=args.clear_nfs_export_options,
deletion_protection_enabled=args.deletion_protection,
deletion_protection_reason=args.deletion_protection_reason,
)
except filestore_client.InvalidDisconnectLdapError as e:
raise exceptions.InvalidArgumentException(
'--disconnect-ldap', str(e)
)
except filestore_client.InvalidDisconnectManagedADError as e:
raise exceptions.InvalidArgumentException(
'--disconnect-managed-ad', str(e)
)
except filestore_client.Error as e:
raise exceptions.InvalidArgumentException(
'--file-share', str(e)
)
updated_fields = []
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('file_share'):
updated_fields.append('fileShares')
if args.IsSpecified('performance'):
updated_fields.append('performanceConfig')
if args.IsSpecified('managed_ad') or args.IsSpecified(
'disconnect_managed_ad'
) or args.IsSpecified('ldap') or args.IsSpecified('disconnect_ldap'):
updated_fields.append('directoryServices')
updated_fields += dp_util.GetDeletionProtectionUpdateMask(args)
update_mask = ','.join(updated_fields)
result = client.UpdateInstance(
instance_ref, instance, update_mask, args.async_
)
if args.async_:
log.status.Print(
'To check the status of the operation, run `gcloud beta filestore '
'operations describe {}`'.format(result.name)
)
return result

View File

@@ -0,0 +1,25 @@
# -*- coding: utf-8 -*- #
# Copyright 2017 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 sub-group for the Filestore locations."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
class Locations(base.Group):
"""List locations where Filestore is available."""

View File

@@ -0,0 +1,68 @@
# -*- coding: utf-8 -*- #
# Copyright 2017 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 locations."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.filestore import filestore_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.filestore import flags
from googlecloudsdk.command_lib.util.concepts import concept_parsers
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Describe(base.DescribeCommand):
"""Describe a Filestore location."""
_API_VERSION = filestore_client.V1_API_VERSION
@staticmethod
def Args(parser):
concept_parsers.ConceptParser([flags.GetLocationPresentationSpec(
'The location to describe.')]).AddToParser(parser)
def Run(self, args):
"""Run the describe command."""
location_ref = args.CONCEPTS.zone.Parse().RelativeName()
client = filestore_client.FilestoreClient(version=self._API_VERSION)
return client.GetLocation(location_ref)
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class DescribeBeta(Describe):
"""Describe a Filestore location."""
_API_VERSION = filestore_client.BETA_API_VERSION
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class DescribeAlpha(Describe):
"""Describe a Filestore location."""
_API_VERSION = filestore_client.ALPHA_API_VERSION
Describe.detailed_help = {
'DESCRIPTION':
'Describe a Filestore location.',
'EXAMPLES':
"""\
The following command shows the details for the Filestore location named NAME.
$ {command} NAME
"""
}

View File

@@ -0,0 +1,104 @@
# -*- coding: utf-8 -*- #
# Copyright 2017 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 Filestore locations."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.filestore import filestore_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.filestore.locations import flags
from googlecloudsdk.core import properties
from googlecloudsdk.core import resources
@base.ReleaseTracks(base.ReleaseTrack.GA)
class List(base.ListCommand):
"""List all Filestore locations."""
_API_VERSION = filestore_client.V1_API_VERSION
@staticmethod
def Args(parser):
parser.display_info.AddFormat(flags.LOCATIONS_LIST_FORMAT)
def UriFunc(resource):
registry = filestore_client.GetFilestoreRegistry()
ref = registry.Parse(
resource.name, collection=filestore_client.LOCATIONS_COLLECTION)
return ref.SelfLink()
parser.display_info.AddUriFunc(UriFunc)
def Run(self, args):
project_ref = resources.REGISTRY.Parse(
properties.VALUES.core.project.GetOrFail(),
collection='file.projects')
client = filestore_client.FilestoreClient(version=self._API_VERSION)
return list(client.ListLocations(project_ref, limit=args.limit))
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class ListBeta(List):
"""List all Filestore locations."""
_API_VERSION = filestore_client.BETA_API_VERSION
@staticmethod
def Args(parser):
parser.display_info.AddFormat(flags.LOCATIONS_LIST_FORMAT)
def UriFunc(resource):
registry = filestore_client.GetFilestoreRegistry(
filestore_client.BETA_API_VERSION)
ref = registry.Parse(
resource.name, collection=filestore_client.LOCATIONS_COLLECTION)
return ref.SelfLink()
parser.display_info.AddUriFunc(UriFunc)
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class ListAlpha(List):
"""List all Filestore locations."""
_API_VERSION = filestore_client.ALPHA_API_VERSION
@staticmethod
def Args(parser):
parser.display_info.AddFormat(flags.LOCATIONS_LIST_FORMAT)
def UriFunc(resource):
registry = filestore_client.GetFilestoreRegistry(
filestore_client.ALPHA_API_VERSION)
ref = registry.Parse(
resource.name, collection=filestore_client.LOCATIONS_COLLECTION)
return ref.SelfLink()
parser.display_info.AddUriFunc(UriFunc)
List.detailed_help = {
'DESCRIPTION':
'List all Filestore locations.',
'EXAMPLES':
"""\
The following command lists a maximum of five Filestore locations sorted
alphabetically by name in descending order:
$ {command} --limit=5 --sort-by=~name
"""
}

View File

@@ -0,0 +1,25 @@
# -*- coding: utf-8 -*- #
# Copyright 2017 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 sub-group for the Filestore operations."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
class Operations(base.Group):
"""Read and manipulate Filestore operations."""

View File

@@ -0,0 +1,82 @@
# -*- coding: utf-8 -*- #
# Copyright 2020 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 cancelling operations."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.filestore import filestore_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.filestore import flags
from googlecloudsdk.command_lib.filestore.instances import flags as instances_flags
from googlecloudsdk.command_lib.util.concepts import concept_parsers
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Cancel(base.Command):
"""Cancel a Filestore operation."""
_API_VERSION = filestore_client.V1_API_VERSION
@staticmethod
def Args(parser):
concept_parsers.ConceptParser([
flags.GetOperationPresentationSpec('The operation to cancel.')
]).AddToParser(parser)
instances_flags.AddLocationArg(parser)
parser.display_info.AddFormat('default')
def Run(self, args):
"""Run the cancel command."""
operation_ref = args.CONCEPTS.operation.Parse()
client = filestore_client.FilestoreClient(version=self._API_VERSION)
return client.CancelOperation(operation_ref)
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class CancelBeta(Cancel):
"""Cancel a Filestore operation."""
_API_VERSION = filestore_client.BETA_API_VERSION
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class CancelAlpha(Cancel):
"""Cancel a Filestore operation."""
_API_VERSION = filestore_client.ALPHA_API_VERSION
Cancel.detailed_help = {
'DESCRIPTION':
"""\
Cancels a Filestore operation. The server makes a best effort to cancel
the operation, but success is not guaranteed. Clients can use the
`filestore operations describe` command to check whether the
cancellation succeeded or not.
""",
'EXAMPLES':
"""\
To cancel a Filestore operation named ``NAME" in the ``us-central1-c" zone, run:
$ {command} NAME --zone=us-central1-c
To cancel a Filestore operation named ``NAME" in the ``us-central1" region, run:
$ {command} NAME --location=us-central1
"""
}

View File

@@ -0,0 +1,70 @@
# -*- coding: utf-8 -*- #
# Copyright 2017 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 operations."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.filestore import filestore_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.filestore import flags
from googlecloudsdk.command_lib.filestore.instances import flags as instances_flags
from googlecloudsdk.command_lib.util.concepts import concept_parsers
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Describe(base.DescribeCommand):
"""Describe a Filestore operation."""
_API_VERSION = filestore_client.V1_API_VERSION
@staticmethod
def Args(parser):
concept_parsers.ConceptParser([flags.GetOperationPresentationSpec(
'The operation to describe.')]).AddToParser(parser)
instances_flags.AddLocationArg(parser)
parser.display_info.AddFormat('default')
def Run(self, args):
"""Run the describe command."""
operation_ref = args.CONCEPTS.operation.Parse()
client = filestore_client.FilestoreClient(version=self._API_VERSION)
return client.GetOperation(operation_ref)
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class DescribeBeta(Describe):
"""Describe a Filestore operation."""
_API_VERSION = filestore_client.BETA_API_VERSION
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class DescribeAlpha(Describe):
"""Describe a Filestore operation."""
_API_VERSION = filestore_client.ALPHA_API_VERSION
Describe.detailed_help = {
'DESCRIPTION': 'Describe a Filestore operation.',
'EXAMPLES': """\
The following command shows the details for the Filestore operation named NAME
in us-central1-c.
$ {command} NAME --location=us-central1-c
"""
}

View File

@@ -0,0 +1,127 @@
# -*- coding: utf-8 -*- #
# Copyright 2017 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 Filestore operations."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.filestore import filestore_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.filestore import flags
from googlecloudsdk.command_lib.filestore.instances import flags as instances_flags
from googlecloudsdk.command_lib.filestore.operations import flags as operations_flags
from googlecloudsdk.command_lib.util.concepts import concept_parsers
from googlecloudsdk.core import properties
@base.ReleaseTracks(base.ReleaseTrack.GA)
class List(base.ListCommand):
"""List all Filestore operations."""
_API_VERSION = filestore_client.V1_API_VERSION
@staticmethod
def Args(parser):
concept_parsers.ConceptParser(
[flags.GetListingLocationPresentationSpec(
'The location in which to list operations.')]
).AddToParser(parser)
instances_flags.AddLocationArg(parser)
parser.display_info.AddFormat(operations_flags.OPERATIONS_LIST_FORMAT)
def UriFunc(resource):
registry = filestore_client.GetFilestoreRegistry()
ref = registry.Parse(
resource.name,
collection=filestore_client.OPERATIONS_COLLECTION)
return ref.SelfLink()
parser.display_info.AddUriFunc(UriFunc)
def Run(self, args):
# Ensure that project is set before parsing location resource.
properties.VALUES.core.project.GetOrFail()
location_ref = args.CONCEPTS.zone.Parse().RelativeName()
if args.zone is None and args.location is not None:
location_list = location_ref.split('/')
location_list[-1] = args.location
location_ref = '/'.join(location_list)
client = filestore_client.FilestoreClient(version=self._API_VERSION)
return list(client.ListOperations(location_ref, limit=args.limit))
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class ListBeta(List):
"""List all Filestore operations."""
_API_VERSION = filestore_client.BETA_API_VERSION
@staticmethod
def Args(parser):
concept_parsers.ConceptParser(
[flags.GetListingLocationPresentationSpec(
'The location in which to list operations.')]
).AddToParser(parser)
instances_flags.AddLocationArg(parser)
parser.display_info.AddFormat(operations_flags.OPERATIONS_LIST_FORMAT)
def UriFunc(resource):
registry = filestore_client.GetFilestoreRegistry(
filestore_client.BETA_API_VERSION)
ref = registry.Parse(
resource.name,
collection=filestore_client.OPERATIONS_COLLECTION)
return ref.SelfLink()
parser.display_info.AddUriFunc(UriFunc)
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class ListAlpha(List):
"""List all Filestore operations."""
_API_VERSION = filestore_client.ALPHA_API_VERSION
@staticmethod
def Args(parser):
concept_parsers.ConceptParser(
[flags.GetListingLocationPresentationSpec(
'The location in which to list operations.')]
).AddToParser(parser)
instances_flags.AddLocationArg(parser)
parser.display_info.AddFormat(operations_flags.OPERATIONS_LIST_FORMAT)
def UriFunc(resource):
registry = filestore_client.GetFilestoreRegistry(
filestore_client.ALPHA_API_VERSION)
ref = registry.Parse(
resource.name,
collection=filestore_client.OPERATIONS_COLLECTION)
return ref.SelfLink()
parser.display_info.AddUriFunc(UriFunc)
List.detailed_help = {
'DESCRIPTION': 'List all Filestore operations.',
'EXAMPLES': """\
The following command lists a maximum of five Filestore operations sorted
alphabetically by name in descending order:
$ {command} --limit=5 --sort-by=~name
"""
}

View File

@@ -0,0 +1,25 @@
# -*- coding: utf-8 -*- #
# Copyright 2019 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 Filestore regions."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
class Regions(base.Group):
"""List regions where Filestore is available."""

View File

@@ -0,0 +1,114 @@
# -*- 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 Filestore regions."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.filestore import filestore_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.filestore import locations_util
from googlecloudsdk.command_lib.filestore.locations import flags
from googlecloudsdk.core import properties
from googlecloudsdk.core import resources
@base.UniverseCompatible
@base.ReleaseTracks(base.ReleaseTrack.GA)
class List(base.ListCommand):
"""List all Filestore regions."""
_API_VERSION = filestore_client.V1_API_VERSION
@staticmethod
def Args(parser):
parser.display_info.AddFormat(flags.LOCATIONS_LIST_FORMAT)
def UriFunc(resource):
registry = filestore_client.GetFilestoreRegistry()
ref = registry.Parse(
resource.name, collection=filestore_client.LOCATIONS_COLLECTION
)
return ref.SelfLink()
parser.display_info.AddUriFunc(UriFunc)
def Run(self, args):
project_ref = resources.REGISTRY.Parse(
properties.VALUES.core.project.GetOrFail(), collection='file.projects'
)
client = filestore_client.FilestoreClient(version=self._API_VERSION)
all_locations = list(client.ListLocations(project_ref, limit=None))
return list(
locations_util.ExtractRegionsFromLocationsListResponse(
all_locations, limit=args.limit
)
)
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class ListBeta(List):
"""List all Filestore regions."""
_API_VERSION = filestore_client.BETA_API_VERSION
@staticmethod
def Args(parser):
parser.display_info.AddFormat(flags.LOCATIONS_LIST_FORMAT)
def UriFunc(resource):
registry = filestore_client.GetFilestoreRegistry(
filestore_client.BETA_API_VERSION
)
ref = registry.Parse(
resource.name, collection=filestore_client.LOCATIONS_COLLECTION
)
return ref.SelfLink()
parser.display_info.AddUriFunc(UriFunc)
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class ListAlpha(List):
"""List all Filestore regions."""
_API_VERSION = filestore_client.ALPHA_API_VERSION
@staticmethod
def Args(parser):
parser.display_info.AddFormat(flags.LOCATIONS_LIST_FORMAT)
def UriFunc(resource):
registry = filestore_client.GetFilestoreRegistry(
filestore_client.ALPHA_API_VERSION
)
ref = registry.Parse(
resource.name, collection=filestore_client.LOCATIONS_COLLECTION
)
return ref.SelfLink()
parser.display_info.AddUriFunc(UriFunc)
List.detailed_help = {
'DESCRIPTION': 'List all Filestore regions.',
'EXAMPLES': """\
The following command lists a maximum of five Filestore regions sorted
alphabetically by name in descending order:
$ {command} --limit=5 --sort-by=~name
""",
}

View File

@@ -0,0 +1,50 @@
# -*- coding: utf-8 -*- #
# Copyright 2018 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 Filestore snapshots."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class Snapshots(base.Group):
"""Create and manage Filestore snapshots.
## EXAMPLES
To create a snapshot with the name 'my-snapshot', run:
$ {command} create my-snapshot
To delete a snapshot with the name 'my-snapshot', run:
$ {command} delete my-snapshot
To display the details for an snapshot with the name 'my-snapshot', run:
$ {command} describe my-snapshot
To list all the snapshots, run:
$ {command} list
To set the label 'env' to 'prod' for an snapshot with the name
'my-snapshot', run:
$ {command} my-snapshot --update-labels=env=prod
"""

View File

@@ -0,0 +1,74 @@
- help_text:
brief: |
Create a Filestore snapshot.
description: |
Take a Filestore snapshot of an instance file share.
This command can fail for the following reasons:
* An instance with the same name already exists.
* The active account does not have permission to create snapshots.
examples: |
To create a snapshot with the name 'my-snapshot' from an instance called 'my-instance' in
'us-central1-c' and the source file share called 'my-fs', run:
$ {command} my-snapshot --instance=my-instance --file-share=my-fs
--instance-zone=us-central1-c
To create a snapshot with the name 'my-snapshot' in a particular region like 'us-central1'
from an instance called 'my-instance' in 'us-central1-c' and the source file share called
'my-fs', run:
$ {command} my-snapshot --instance=my-instance --file-share=my-fs
--instance-zone=us-central1-c --region=us-central1
arguments:
params:
- arg_name: snapshot
is_positional: true
required: true
help_text: |
Arguments and flags that specify the Filestore snapshot you want to
create.
- arg_name: instance
required: true
help_text: |
Share name of the Filestore instance you want to snapshot.
- arg_name: instance-zone
required: true
help_text: |
Zone of the Filestore instance.
- arg_name: region
help_text: |
Region (e.g. us-central1) for the regional snapshot.
- api_field: snapshot.sourceFileShare
arg_name: file-share
required: true
help_text: |
File share name on the Filestore instance to snapshot.
- api_field: snapshot.labels.additionalProperties
arg_name: labels
metavar: KEY=VALUE
required: false
help_text: |
List of label KEY=VALUE pairs to add.
type:
arg_dict:
flatten: true
spec:
- api_field: key
- api_field: value
async:
collection: file.projects.locations.operations
request:
api_version: v1p1alpha1
display_resource_type: snapshot
collection: file.projects.locations.snapshots
# Disable validating that a snapshots resource arg is specified (as we are using the
# file.projects.locations.snapshots collection). This collection is populated manually.
disable_resource_check: true
modify_request_hooks:
- googlecloudsdk.command_lib.filestore.snapshots.util:FormatSnapshotCreateRequest
- googlecloudsdk.command_lib.filestore.snapshots.util:AddInstanceNameToRequest

View File

@@ -0,0 +1,51 @@
- help_text:
brief: |
Delete a Filestore snapshot.
description: |
Delete a Filestore snapshot.
This command can fail for the following reasons:
* The snapshot specified does not exist.
* The active account does not have permission to delete the given
snapshot.
examples: |
The following command deletes a snapshot with the name 'my-snapshot' in the region
us-central1:
$ {command} my-snapshot --region=us-central1
arguments:
params:
- arg_name: snapshot
is_positional: true
help_text: |
Arguments and flags that specify the Filestore snapshot you want to
delete.
- group:
mutex: true
required: true
params:
- arg_name: zone
help_text: |
Compute zone (e.g. us-central1-c) for the snapshot.
- arg_name: region
help_text: |
Compute region (e.g. us-central1) for the snapshot.
async:
collection: file.projects.locations.operations
request_issued_message: |-
Delete request issued
input:
confirmation_prompt: |
You are about to delete a snapshot
request:
api_version: v1p1alpha1
display_resource_type: snapshot
collection: file.projects.locations.snapshots
disable_resource_check: true
modify_request_hooks:
- googlecloudsdk.command_lib.filestore.snapshots.util:FormatSnapshotAccessRequest

View File

@@ -0,0 +1,40 @@
- help_text:
brief: |
Describe a Filestore snapshot.
description: |
Displays all data associated with a Filestore snapshot given a valid snapshot name.
This command can fail for the following reasons:
* The snapshot specified does not exist.
* The active account does not have permission to access the given
snapshot.
examples: |
To display all data associated with a snapshot of the name 'my-snapshot' in the
region us-central1:
$ {command} my-snapshot --region=us-central1
arguments:
params:
- arg_name: snapshot
is_positional: true
help_text: |
Arguments and flags that specify the Filestore snapshot you want to
create.
- group:
mutex: true
required: true
params:
- arg_name: zone
help_text: |
Zone (e.g. us-central1-c) for the snapshot.
- arg_name: region
help_text: |
Region (e.g. us-central1) for the snapshot.
request:
api_version: v1p1alpha1
collection: file.projects.locations.snapshots
disable_resource_check: true
modify_request_hooks:
- googlecloudsdk.command_lib.filestore.snapshots.util:FormatSnapshotAccessRequest

View File

@@ -0,0 +1,49 @@
- help_text:
brief: |
List Filestore snapshots.
description: |
List all Filestore snapshots under the specified project and region.
To specify the maximum number of snapshots to list, use the --limit flag.
examples: |
To list up to five snapshots, run:
$ {command} --limit=5
arguments:
resource:
help_text: |
Project name.
spec: !REF googlecloudsdk.command_lib.filestore.resources:project
override_resource_collection: true
params:
- group:
mutex: true
params:
- arg_name: zone
help_text: |
The zone of the Local Snapshots to display. If unspecified, all snapshots will be
listed.
- arg_name: region
help_text: |
The region of the Snapshots to display. If unspecified, all snapshots will be listed.
request:
api_version: v1p1alpha1
collection: file.projects.locations.snapshots
modify_request_hooks:
- googlecloudsdk.command_lib.filestore.util:AddDefaultLocationToListRequest
response:
id_field: name
output:
format: |
table(
name.basename():label=NAME:sort=1,
name.segment(3):label=LOCATION,
sourceInstance.split('/').slice(3:).join('/'):label=SRC_INSTANCE,
sourceFileShare:label=SRC_FILE_SHARE,
state
)

View File

@@ -0,0 +1,55 @@
- help_text:
brief: |
Update a Filestore snapshot.
description: |
Update the metadata of a Filestore snapshot.
This command can fail for the following reasons:
* The snapshot specified does not exist.
* The active account does not have permission to update the given
snapshot.
examples: |
The following command updates the Filestore Snapshot named 'my-snapshot' in region
us-central1 to change the description to 'A new description.'
$ {command} my-snapshot --region=us-central1 --description="A new description."
arguments:
params:
- arg_name: snapshot
is_positional: true
help_text: |
Arguments and flags that specify the Filestore snapshot you want to
update.
- group:
mutex: true
required: true
params:
- arg_name: zone
help_text: |
Compute zone (e.g. us-central1-c) for the snapshot.
- arg_name: region
help_text: |
Compute region (e.g. us-central1) for the snapshot.
- arg_name: description
api_field: snapshot.description
help_text: |
Description of the snapshot.
additional_arguments_hook: googlecloudsdk.command_lib.filestore.update_util:UpdateLabelsFlags
response:
modify_response_hooks:
- googlecloudsdk.command_lib.filestore.snapshots.update_util:FormatSnapshotUpdateResponse
async:
collection: file.projects.locations.operations
request:
api_version: v1p1alpha1
display_resource_type: snapshot
collection: file.projects.locations.snapshots
modify_request_hooks:
- googlecloudsdk.command_lib.filestore.snapshots.util:FormatSnapshotAccessRequest
- googlecloudsdk.command_lib.filestore.snapshots.update_util:GetExistingSnapshot
- googlecloudsdk.command_lib.filestore.snapshots.update_util:AddDescription
- googlecloudsdk.command_lib.filestore.snapshots.update_util:UpdateLabels

View File

@@ -0,0 +1,25 @@
# -*- coding: utf-8 -*- #
# Copyright 2019 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 Filestore zones."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
class Zones(base.Group):
"""List zones where Filestore is available."""

View File

@@ -0,0 +1,114 @@
# -*- 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 Filestore zones."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.filestore import filestore_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.filestore import locations_util
from googlecloudsdk.command_lib.filestore.locations import flags
from googlecloudsdk.core import properties
from googlecloudsdk.core import resources
@base.UniverseCompatible
@base.ReleaseTracks(base.ReleaseTrack.GA)
class List(base.ListCommand):
"""List all Filestore zones."""
_API_VERSION = filestore_client.V1_API_VERSION
@staticmethod
def Args(parser):
parser.display_info.AddFormat(flags.LOCATIONS_LIST_FORMAT)
def UriFunc(resource):
registry = filestore_client.GetFilestoreRegistry()
ref = registry.Parse(
resource.name, collection=filestore_client.LOCATIONS_COLLECTION
)
return ref.SelfLink()
parser.display_info.AddUriFunc(UriFunc)
def Run(self, args):
project_ref = resources.REGISTRY.Parse(
properties.VALUES.core.project.GetOrFail(), collection='file.projects'
)
client = filestore_client.FilestoreClient(version=self._API_VERSION)
all_locations = list(client.ListLocations(project_ref, limit=None))
return list(
locations_util.ExtractZonesFromLocationsListResponse(
all_locations, limit=args.limit
)
)
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class ListBeta(List):
"""List all Filestore zones."""
_API_VERSION = filestore_client.BETA_API_VERSION
@staticmethod
def Args(parser):
parser.display_info.AddFormat(flags.LOCATIONS_LIST_FORMAT)
def UriFunc(resource):
registry = filestore_client.GetFilestoreRegistry(
filestore_client.BETA_API_VERSION
)
ref = registry.Parse(
resource.name, collection=filestore_client.LOCATIONS_COLLECTION
)
return ref.SelfLink()
parser.display_info.AddUriFunc(UriFunc)
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class ListAlpha(List):
"""List all Filestore zones."""
_API_VERSION = filestore_client.ALPHA_API_VERSION
@staticmethod
def Args(parser):
parser.display_info.AddFormat(flags.LOCATIONS_LIST_FORMAT)
def UriFunc(resource):
registry = filestore_client.GetFilestoreRegistry(
filestore_client.ALPHA_API_VERSION
)
ref = registry.Parse(
resource.name, collection=filestore_client.LOCATIONS_COLLECTION
)
return ref.SelfLink()
parser.display_info.AddUriFunc(UriFunc)
List.detailed_help = {
'DESCRIPTION': 'List all Filestore zones.',
'EXAMPLES': """\
The following command lists a maximum of five Filestore zones sorted
alphabetically by name in descending order:
$ {command} --limit=5 --sort-by=~name
""",
}