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,30 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""The command group for the VMware Engine datastore CLI."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.Hidden
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Datastores(base.Group):
"""Manage VMware Engine datastores in Google Cloud VMware Engine."""
category = base.COMPUTE_CATEGORY

View File

@@ -0,0 +1,140 @@
# -*- 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.
"""'vmware datastores create' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware import datastores
from googlecloudsdk.calliope import arg_parsers
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
from googlecloudsdk.core import log
DatastoresClient = datastores.DatastoresClient
DETAILED_HELP = {
'DESCRIPTION': """
Create a datastore. Datastore creation is considered finished when the datastore is in ACTIVE state. Check the progress of a datastore using `{parent_command} list`.
""",
'EXAMPLES': """
To create a datastore named `my-datastore` in `us-west2-a` connected to filestore instance `projects/my-project/locations/us-west2-a/instances/my-filestore-instance`, run:
$ {command} my-datastore --location=us-west2-a --project=my-project --filestore=projects/my-project/locations/us-west2-a/instances/my-filestore-instance
Or:
$ {command} my-datastore --filestore=projects/my-project/locations/us-west2-a/instances/my-filestore-instance
Or:
$ {command} my-datastore --netapp=projects/my-project/locations/us-west2-a/volumes/my-netapp-volume
Or:
$ {command} my-datastore --third-party-nfs-network=my-network --third-party-nfs-file-share=my-fileshare --third-party-nfs-servers=10.0.0.1,10.0.0.2 --location=us-west2-a --project=my-project
In the second example, the project and location are taken from gcloud properties core/project and compute/zone.
""",
}
@base.Hidden
@base.ReleaseTracks(base.ReleaseTrack.GA)
@base.DefaultUniverseOnly
class Create(base.CreateCommand):
"""Create a datastore."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddDatastoreArgToParser(parser, positional=True)
base.ASYNC_FLAG.AddToParser(parser)
base.ASYNC_FLAG.SetDefault(parser, True)
parser.display_info.AddFormat('yaml')
parser.add_argument(
'--description',
help="""\
Text describing the datastore.
""",
)
datastore_type_group = parser.add_group(
mutex=True,
required=True,
)
datastore_type_group.add_argument(
'--netapp',
help="""\
Google NetApp volume to be used as datastore.
""",
)
datastore_type_group.add_argument(
'--filestore',
help="""\
Google Filestore instance to be used as datastore.
""",
)
third_party_nfs_group = datastore_type_group.add_group()
third_party_nfs_group.add_argument(
'--third-party-nfs-network',
required=True,
help="""\
Network name of NFS's VPC.
""",
)
third_party_nfs_group.add_argument(
'--third-party-nfs-file-share',
required=True,
help="""\
Mount folder name of NFS.
""",
)
third_party_nfs_group.add_argument(
'--third-party-nfs-servers',
required=True,
help="""\
Comma-separated list of server IP addresses of the NFS file service.
""",
type=arg_parsers.ArgList(min_length=1),
metavar='SERVER',
)
def Run(self, args):
datastore = args.CONCEPTS.datastore.Parse()
client = DatastoresClient()
is_async = args.async_
operation = client.Create(
datastore,
description=args.description,
netapp_volume=args.netapp,
filestore_instance=args.filestore,
third_party_nfs_network=args.third_party_nfs_network,
third_party_nfs_file_share=args.third_party_nfs_file_share,
third_party_nfs_servers=args.third_party_nfs_servers,
)
if is_async:
log.CreatedResource(operation.name, kind='datastore', is_async=True)
return
resource = client.WaitForOperation(
operation_ref=client.GetOperationRef(operation),
message='waiting for datastore [{}] to be created'.format(
datastore.RelativeName()
),
)
log.CreatedResource(datastore.RelativeName(), kind='datastore')
return resource

View File

@@ -0,0 +1,80 @@
# -*- 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.
"""'vmware datastores delete' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware.datastores import DatastoresClient
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
from googlecloudsdk.core import log
DETAILED_HELP = {
'DESCRIPTION': """
Delete a datastore.
""",
'EXAMPLES': """
To delete a datastore named `my-datastore` in location `us-west2-a`, run:
$ {command} my-datastore --location=us-west2-a --project=my-project
Or:
$ {command} my-datastore
In the second example, the project and location are taken from gcloud properties core/project and compute/zone.
""",
}
@base.Hidden
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Delete(base.DeleteCommand):
"""Delete a datastore."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddDatastoreArgToParser(parser, positional=True)
base.ASYNC_FLAG.AddToParser(parser)
base.ASYNC_FLAG.SetDefault(parser, True)
parser.add_argument(
'--etag',
help="""\
Etag of the datastore.
""",
)
def Run(self, args):
datastore = args.CONCEPTS.datastore.Parse()
client = DatastoresClient()
is_async = args.async_
operation = client.Delete(datastore, etag=args.etag)
if is_async:
log.DeletedResource(operation.name, kind='datastore', is_async=True)
return operation
return client.WaitForOperation(
operation_ref=client.GetOperationRef(operation),
message='waiting for datastore [{}] to be deleted'.format(
datastore.RelativeName()
),
has_result=False,
)

View File

@@ -0,0 +1,60 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""'vmware datastores describe' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware import datastores
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
DatastoresClient = datastores.DatastoresClient
DETAILED_HELP = {
'DESCRIPTION': """
Describe a datastore.
""",
'EXAMPLES': """
To describe a datastore named `my-datastore` in location `us-west2-a`, run:
$ {command} my-datastore --location=us-west2-a --project=my-project
Or:
$ {command} my-datastore
In the second example, the project and location are taken from gcloud properties core/project and compute/zone.
""",
}
@base.Hidden
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Describe(base.DescribeCommand):
"""Describe a datastore."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddDatastoreArgToParser(parser, positional=True)
def Run(self, args):
datastore = args.CONCEPTS.datastore.Parse()
client = DatastoresClient()
return client.Get(datastore)

View File

@@ -0,0 +1,119 @@
# -*- 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.
"""'vmware datastores list' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from typing import Any, Dict
from googlecloudsdk.api_lib.vmware import datastores
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
DatastoresClient = datastores.DatastoresClient
def _GetServiceType(r: Dict[str, Any]) -> str:
"""Gets the service type from a datastore resource.
Args:
r: The datastore resource.
Returns:
A string representing the service type, or an empty string if not found.
"""
if r.get('nfsDatastore'):
if r['nfsDatastore'].get('googleFileService'):
if r['nfsDatastore']['googleFileService'].get('netappVolume'):
return 'NETAPP'
if r['nfsDatastore']['googleFileService'].get('filestoreInstance'):
return 'FILESTORE'
if r['nfsDatastore'].get('thirdPartyFileService'):
return 'THIRD_PARTY'
return ''
def _GetVolume(r: Dict[str, Any]) -> str:
"""Gets the volume information from a datastore resource.
Args:
r: The datastore resource.
Returns:
A string representing the volume, or an empty string if not found.
"""
if r.get('nfsDatastore'):
nfs = r['nfsDatastore']
if nfs.get('googleFileService'):
gfs = nfs['googleFileService']
if gfs.get('netappVolume'):
return gfs['netappVolume'].split('/')[-1]
if gfs.get('filestoreInstance'):
return gfs['filestoreInstance'].split('/')[-1]
if nfs.get('thirdPartyFileService'):
tfs = nfs['thirdPartyFileService']
file_share = tfs.get('fileShare', '')
servers = tfs.get('servers', [])
if servers:
return ','.join(servers) + ':' + file_share
return file_share
return ''
TRANSFORMS = {'service_type': _GetServiceType, 'volume': _GetVolume}
DETAILED_HELP = {
'DESCRIPTION': """
List datastores.
""",
'EXAMPLES': """
To list datastores in location `us-west2-a`, run:
$ {command} --location=us-west2-a --project=my-project
Or:
$ {command}
In the second example, the project and location are taken from gcloud properties core/project and compute/zone.
""",
}
@base.Hidden
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class List(base.ListCommand):
"""List datastores."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddLocationArgToParser(parser)
parser.display_info.AddTransforms(TRANSFORMS)
parser.display_info.AddFormat('table(name.segment(-1):label=NAME,'
'name.segment(-5):label=PROJECT,'
'name.segment(-3):label=LOCATION,'
'createTime,state,'
'service_type():label=SERVICE_TYPE,'
'volume():label=VOLUME)')
def Run(self, args):
location = args.CONCEPTS.location.Parse()
client = DatastoresClient()
return client.List(location)

View File

@@ -0,0 +1,83 @@
# -*- 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.
"""'vmware datastores update' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.vmware import datastores
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.vmware import flags
from googlecloudsdk.core import log
DatastoresClient = datastores.DatastoresClient
DETAILED_HELP = {
'DESCRIPTION': """
Update a datastore.
""",
'EXAMPLES': """
To update a datastore named `my-datastore` in location `us-west2-a` with a new description, run:
$ {command} my-datastore --location=us-west2-a --project=my-project --description="new description"
Or:
$ {command} my-datastore --description="new description"
In the second example, the project and location are taken from gcloud properties core/project and compute/zone.
""",
}
@base.Hidden
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Update(base.UpdateCommand):
"""Update a datastore."""
detailed_help = DETAILED_HELP
@staticmethod
def Args(parser):
"""Register flags for this command."""
flags.AddDatastoreArgToParser(parser, positional=True)
base.ASYNC_FLAG.AddToParser(parser)
base.ASYNC_FLAG.SetDefault(parser, True)
parser.display_info.AddFormat('yaml')
parser.add_argument(
'--description',
help="""\
New description for the datastore.
""",
)
def Run(self, args):
datastore = args.CONCEPTS.datastore.Parse()
client = DatastoresClient()
is_async = args.async_
operation = client.Update(datastore, description=args.description)
if is_async:
log.UpdatedResource(operation.name, kind='datastore', is_async=True)
return
resource = client.WaitForOperation(
operation_ref=client.GetOperationRef(operation),
message='waiting for datastore [{}] to be updated'.format(
datastore.RelativeName()
),
)
log.UpdatedResource(datastore.RelativeName(), kind='datastore')
return resource