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

View File

@@ -0,0 +1,153 @@
# -*- coding: utf-8 -*- #
# Copyright 2023 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Create- and update-deployment command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.infra_manager import configmanager_util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.infra_manager import deploy_util
from googlecloudsdk.command_lib.infra_manager import flags
from googlecloudsdk.command_lib.infra_manager import resource_args
from googlecloudsdk.command_lib.util.concepts import concept_parsers
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Create(base.CreateCommand):
"""Create or update a deployment.
This command updates a deployment when it already exists, otherwise the
deployment will be created.
"""
# pylint: disable=line-too-long
detailed_help = {'EXAMPLES': """
Create a deployment named `my-deployment` from a storage `my-bucket`:
$ {command} projects/p1/locations/us-central1/deployments/my-deployment --gcs-source="gs://my-bucket" --input-values="project=p1,region=us-central1"
Create a deployment named `my-deployment` from git repo "https://github.com/examples/repository.git", "staging/compute" folder, "mainline" branch:
$ {command} projects/p1/locations/us-central1/deployments/my-deployment --git-source-repo="https://github.com/examples/repository.git"
--git-source-directory="staging/compute" --git-source-ref="mainline"
Update a deployment's labels:
$ {command} projects/p1/locations/us-central1/deployments/my-deployment --git-source-repo="https://github.com/examples/repository.git"
--git-source-directory="staging/compute" --git-source-ref="mainline" --labels="env=prod,team=finance"
"""}
# pylint: enable=line-too-long
@staticmethod
def Args(parser):
labels_help_text = """\
Labels to apply to the deployment. Existing values are overwritten. To retain
the existing labels on a deployment, do not specify this flag.
Examples:
Update labels for an existing deployment:
$ {command} projects/p1/locations/us-central1/deployments/my-deployment --gcs-source="gs://my-bucket" --labels="env=prod,team=finance"
Clear labels for an existing deployment:
$ {command} projects/p1/locations/us-central1/deployments/my-deployment --gcs-source="gs://my-bucket" --labels=""
Add a label to an existing deployment:
First, fetch the current labels using the `describe` command, then follow the
preceding example for updating labels.
"""
annotations_help_text = """\
Annotations to apply to the deployment. Existing values are overwritten. To retain
the existing annotations on a deployment, do not specify this flag.
Examples:
Update annotations for an existing deployment:
$ {command} projects/p1/locations/us-central1/deployments/my-deployment --gcs-source="gs://my-bucket" --annotations="env=prod,team=finance"
Clear annotations for an existing deployment:
$ {command} projects/p1/locations/us-central1/deployments/my-deployment --gcs-source="gs://my-bucket" --annotations=""
Add an annotation to an existing deployment:
First, fetch the current annotations using the `describe` command, then follow the
preceding example for updating annotations.
"""
flags.AddLabelsFlag(parser, labels_help_text)
flags.AddAnnotationsFlag(parser, annotations_help_text)
flags.AddAsyncFlag(parser)
flags.AddTerraformBlueprintFlag(parser)
flags.AddServiceAccountFlag(parser)
flags.AddWorkerPoolFlag(parser)
flags.AddImportExistingResourcesFlag(parser)
flags.AddArtifactsGCSBucketFlag(parser)
flags.AddTFVersionConstraintFlag(parser)
flags.AddQuotaValidationFlag(parser)
flags.AddProviderSourceFlag(parser)
concept_parsers.ConceptParser(
[
resource_args.GetDeploymentResourceArgSpec(
'the deployment to create or update.'
)
]
).AddToParser(parser)
def Run(self, args):
"""This is what gets called when the user runs this command.
Args:
args: an argparse namespace. All the arguments that were provided to this
command invocation.
Returns:
The resulting Deployment resource or, in the case that args.async_ is
True, a long-running operation.
"""
messages = configmanager_util.GetMessagesModule()
deployment_ref = args.CONCEPTS.deployment.Parse()
deployment_full_name = deployment_ref.RelativeName()
return deploy_util.Apply(
messages,
args.async_,
deployment_full_name,
args.service_account,
args.tf_version_constraint,
args.local_source,
args.stage_bucket,
args.ignore_file,
args.import_existing_resources,
args.artifacts_gcs_bucket,
args.worker_pool,
args.gcs_source,
args.git_source_repo,
args.git_source_directory,
args.git_source_ref,
args.input_values,
args.inputs_file,
args.labels,
args.quota_validation,
args.annotations,
args.provider_source,
)

View File

@@ -0,0 +1,28 @@
- release_tracks: [GA]
help_text:
brief: Delete deployments
description: Delete a deployment
examples: |-
To delete the deployment `example-deployment` at location `us-central1`, run:
$ {command} projects/example-project/locations/us-central1/deployments/example-deployment
arguments:
resource:
spec: !REF googlecloudsdk.command_lib.infra_manager.resources:deployment
help_text: deployments TBD
params:
- arg_name: delete-policy
api_field: deletePolicy
help_text: |-
Policy on how resources actuated by the deployment should be deleted. The accepted values are DELETE, ABANDON.
DELETE = Delete resources actuated by the deployment.
ABANDON = Abandon resources and only delete deployment metadata.
request:
collection: config.projects.locations.deployments
modify_request_hooks:
- googlecloudsdk.command_lib.infra_manager.deploy_util:UpdateDeploymentDeleteRequestWithForce
response:
modify_response_hooks:
- googlecloudsdk.command_lib.infra_manager.deploy_util:DeleteCleanupStagedObjects
async:
collection: config.projects.locations.operations

View File

@@ -0,0 +1,14 @@
- release_tracks: [GA]
help_text:
brief: Describe deployments
description: Describe a deployment
examples: |-
To describe a deployment `example-deployment` in project `p1` at location `us-central1`, run:
$ {command} projects/p1/locations/us-central1/deployments/example-deployment
arguments:
resource:
spec: !REF googlecloudsdk.command_lib.infra_manager.resources:deployment
help_text: The deployment to describe
request:
collection: config.projects.locations.deployments

View File

@@ -0,0 +1,67 @@
# -*- coding: utf-8 -*- #
# Copyright 2023 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Export lock info command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.infra_manager import deploy_util
from googlecloudsdk.command_lib.infra_manager import resource_args
from googlecloudsdk.command_lib.util.concepts import concept_parsers
@base.ReleaseTracks(base.ReleaseTrack.GA)
class ExportLock(base.Command):
"""Exports lock info of a deployment.
This command exports lock info of a deployment.
"""
detailed_help = {'EXAMPLES': """
Export lock info for deployment `projects/p1/locations/us-central1/deployments/my-deployment`:
$ {command} projects/p1/locations/us-central1/deployments/my-deployment
"""}
@staticmethod
def Args(parser):
concept_parsers.ConceptParser(
[
resource_args.GetDeploymentResourceArgSpec(
'the deployment to be used as parent.'
)
]
).AddToParser(parser)
def Run(self, args):
"""This is what gets called when the user runs this command.
Args:
args: an argparse namespace. All the arguments that were provided to this
command invocation.
Returns:
A lock info response.
"""
deployment_ref = args.CONCEPTS.deployment.Parse()
deployment_full_name = deployment_ref.RelativeName()
return deploy_util.ExportLock(
deployment_full_name,
)

View File

@@ -0,0 +1,81 @@
# -*- coding: utf-8 -*- #
# Copyright 2023 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Export deployment state file command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.infra_manager import configmanager_util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.infra_manager import deploy_util
from googlecloudsdk.command_lib.infra_manager import flags
from googlecloudsdk.command_lib.infra_manager import resource_args
from googlecloudsdk.command_lib.util.concepts import concept_parsers
@base.ReleaseTracks(base.ReleaseTrack.GA)
class ExportStatefile(base.Command):
"""Export a terraform state file.
This command generates a signed url to download a terraform state file.
"""
detailed_help = {'EXAMPLES': """
Export state file for `my-deployment`:
$ {command} projects/p1/locations/us-central1/deployments/my-deployment
"""}
@staticmethod
def Args(parser):
file_help_text = """\
File name for statefile. It is optional and it specifies the filename or
complete path for the downloaded statefile. If only a file path is
provided, the statefile will be downloaded as "statefile" within that
directory. If a filename is included, the statefile will be downloaded
with that name."""
flags.AddFileFlag(parser, file_help_text)
flags.AddDraftFlag(parser)
concept_parsers.ConceptParser(
[
resource_args.GetDeploymentResourceArgSpec(
'the deployment to be used as parent.'
)
]
).AddToParser(parser)
def Run(self, args):
"""This is what gets called when the user runs this command.
Args:
args: an argparse namespace. All the arguments that were provided to this
command invocation.
Returns:
A statefile containing signed url that can be used to upload state file.
"""
messages = configmanager_util.GetMessagesModule()
deployment_ref = args.CONCEPTS.deployment.Parse()
deployment_full_name = deployment_ref.RelativeName()
return deploy_util.ExportDeploymentStateFile(
messages,
deployment_full_name,
args.draft,
args.file,
)

View File

@@ -0,0 +1,79 @@
# -*- coding: utf-8 -*- #
# Copyright 2023 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Import state file command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.infra_manager import configmanager_util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.infra_manager import deploy_util
from googlecloudsdk.command_lib.infra_manager import flags
from googlecloudsdk.command_lib.infra_manager import resource_args
from googlecloudsdk.command_lib.util.concepts import concept_parsers
@base.ReleaseTracks(base.ReleaseTrack.GA)
class ImportStatefile(base.Command):
"""Import a terraform state file.
This command generates a signed url to upload a terraform state file.
"""
detailed_help = {'EXAMPLES': """
Import state file for `my-deployment` with lock-id `1658343229583347`:
$ {command} projects/p1/locations/us-central1/deployments/my-deployment --lock-id=1658343229583347
"""}
@staticmethod
def Args(parser):
file_help_text = """\
File path for importing statefile into a deployment. It specifies the
local file path of an existing Terraform statefile to directly upload
for a deployment."""
flags.AddFileFlag(parser, file_help_text)
flags.AddLockFlag(parser)
concept_parsers.ConceptParser(
[
resource_args.GetDeploymentResourceArgSpec(
'the deployment to be used as parent.'
)
]
).AddToParser(parser)
def Run(self, args):
"""This is what gets called when the user runs this command.
Args:
args: an argparse namespace. All the arguments that were provided to this
command invocation.
Returns:
A statefile containing signed url that can be used to upload state file.
"""
messages = configmanager_util.GetMessagesModule()
deployment_ref = args.CONCEPTS.deployment.Parse()
deployment_full_name = deployment_ref.RelativeName()
return deploy_util.ImportStateFile(
messages,
deployment_full_name,
args.lock_id,
args.file,
)

View File

@@ -0,0 +1,26 @@
- release_tracks: [GA]
help_text:
brief: List deployments
description: List deployments
examples: |-
To list all deployments at location `us-central1`, run:
$ {command} --location=us-central1
arguments:
resource:
spec: !REF googlecloudsdk.command_lib.infra_manager.resources:location
help_text: Location to list deployments
request:
collection: config.projects.locations.deployments
response:
id_field: name
output:
format: |
table(
name.basename(),
state,
tfVersion,
latestRevision.basename(),
createTime:sort=1,
updateTime
)

View File

@@ -0,0 +1,73 @@
# -*- coding: utf-8 -*- #
# Copyright 2023 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Create- and update-deployment command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.infra_manager import configmanager_util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.infra_manager import deploy_util
from googlecloudsdk.command_lib.infra_manager import flags
from googlecloudsdk.command_lib.infra_manager import resource_args
from googlecloudsdk.command_lib.util.concepts import concept_parsers
@base.ReleaseTracks(base.ReleaseTrack.GA)
class LockDeployment(base.Command):
"""Locks the deployment.
This command locks the deployment and generates a lockId.
"""
detailed_help = {'EXAMPLES': """
Lock deployment `my-deployment` under project `p1` and location `us-central1`:
$ {command} projects/p1/locations/us-central1/deployments/my-deployment
"""}
@staticmethod
def Args(parser):
flags.AddAsyncFlag(parser)
concept_parsers.ConceptParser(
[
resource_args.GetDeploymentResourceArgSpec(
'the deployment to be used as parent.'
)
]
).AddToParser(parser)
def Run(self, args):
"""This is what gets called when the user runs this command.
Args:
args: an argparse namespace. All the arguments that were provided to this
command invocation.
Returns:
The statefile containing signed url that can be used to upload state file.
"""
messages = configmanager_util.GetMessagesModule()
deployment_ref = args.CONCEPTS.deployment.Parse()
deployment_full_name = deployment_ref.RelativeName()
return deploy_util.LockDeployment(
messages,
args.async_,
deployment_full_name,
)

View File

@@ -0,0 +1,75 @@
# -*- coding: utf-8 -*- #
# Copyright 2023 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Create- and update-deployment command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.infra_manager import configmanager_util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.infra_manager import deploy_util
from googlecloudsdk.command_lib.infra_manager import flags
from googlecloudsdk.command_lib.infra_manager import resource_args
from googlecloudsdk.command_lib.util.concepts import concept_parsers
@base.ReleaseTracks(base.ReleaseTrack.GA)
class UnlockDeployment(base.Command):
"""Unlocks the deployment.
This command releases the lock on deployment.
"""
detailed_help = {'EXAMPLES': """
Unlock deployment `my-deployment` under project `p1` and location `us-central1` with lock-id `1234`:
$ {command} projects/p1/locations/us-central1/deployments/my-deployment --lock-id=1234
"""}
@staticmethod
def Args(parser):
flags.AddAsyncFlag(parser)
flags.AddLockFlag(parser)
concept_parsers.ConceptParser(
[
resource_args.GetDeploymentResourceArgSpec(
'the deployment to be used as parent.'
)
]
).AddToParser(parser)
def Run(self, args):
"""This is what gets called when the user runs this command.
Args:
args: an argparse namespace. All the arguments that were provided to this
command invocation.
Returns:
The statefile containing signed url that can be used to upload state file.
"""
messages = configmanager_util.GetMessagesModule()
deployment_ref = args.CONCEPTS.deployment.Parse()
deployment_full_name = deployment_ref.RelativeName()
return deploy_util.UnlockDeployment(
messages,
args.async_,
deployment_full_name,
args.lock_id,
)