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 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 Infra Manager 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)
@base.DefaultUniverseOnly
class InfraManager(base.Group):
"""Manage Infra Manager resources."""
category = base.MANAGEMENT_TOOLS_CATEGORY

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.
"""Manage auto migration config resources."""
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 AutoMigrationConfig(base.Group):
"""Manage auto migration config resources."""

View File

@@ -0,0 +1,23 @@
- release_tracks: [GA]
hidden: true
help_text:
brief: |
Describe an AutoMigrationConfig.
description: |
Describe an AutoMigrationConfig.
examples: |
To describe an AutoMigrationConfig for location `us-central1`:
$ {command} --location=us-central1
arguments:
resource:
spec: !REF googlecloudsdk.command_lib.infra_manager.resources:location
is_positional: false
help_text: |
The location to read the AutoMigrationConfig from.
request:
api_version: v1
disable_resource_check: true
collection: config.projects.locations
method: getAutoMigrationConfig
modify_request_hooks:
- googlecloudsdk.api_lib.infra_manager.configmanager_util:SetGetAutoMigrationInRequest

View File

@@ -0,0 +1,26 @@
- release_tracks: [GA]
hidden: true
help_text:
brief: |
Disable AutoMigrationConfig.
description: |
Disable AutoMigrationConfig.
examples: |
To disable AutoMigrationConfig for location `us-central1`:
$ {command} --location=us-central1
arguments:
resource:
spec: !REF googlecloudsdk.command_lib.infra_manager.resources:location
is_positional: false
help_text: |
The location to disable AutoMigrationConfig for.
request:
api_version: v1
disable_resource_check: true
collection: config.projects.locations
method: updateAutoMigrationConfig
modify_request_hooks:
- googlecloudsdk.api_lib.infra_manager.configmanager_util:SetDisableAutoMigrationInRequest
async:
collection: config.projects.locations.operations
extract_resource_result: false

View File

@@ -0,0 +1,26 @@
- release_tracks: [GA]
hidden: true
help_text:
brief: |
Enable AutoMigrationConfig.
description: |
Enable AutoMigrationConfig.
examples: |
To enable AutoMigrationConfig for location `us-central1`:
$ {command} --location=us-central1
arguments:
resource:
spec: !REF googlecloudsdk.command_lib.infra_manager.resources:location
is_positional: false
help_text: |
The location to enable AutoMigrationConfig for.
request:
api_version: v1
disable_resource_check: true
collection: config.projects.locations
method: updateAutoMigrationConfig
modify_request_hooks:
- googlecloudsdk.api_lib.infra_manager.configmanager_util:SetEnableAutoMigrationInRequest
async:
collection: config.projects.locations.operations
extract_resource_result: false

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,
)

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 Preview 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 Previews(base.Group):
"""Manage Preview resources."""

View File

@@ -0,0 +1,129 @@
# -*- 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-preview 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 a preview.
This command creates a preview.
"""
# pylint: disable=line-too-long
detailed_help = {'EXAMPLES': """
Create a preview named `my-preview` from a storage `my-bucket`:
$ {command} projects/p1/locations/us-central1/previews/my-preview --gcs-source="gs://my-bucket" --input-values="project=p1,region=us-central1"
Create a preview named `my-preview` from git repo "https://github.com/examples/repository.git", "staging/compute" folder, "mainline" branch:
$ {command} projects/p1/locations/us-central1/previews/my-preview --git-source-repo="https://github.com/examples/repository.git"
--git-source-directory="staging/compute" --git-source-ref="mainline"
"""}
# pylint: enable=line-too-long
@staticmethod
def Args(parser):
labels_help_text = 'Preview labels cannot be updated after creation.'
annotations_help_text = (
'Preview annotations cannot be updated after creation.'
)
flags.AddLabelsFlag(parser, labels_help_text)
flags.AddAnnotationsFlag(parser, annotations_help_text)
flags.AddAsyncFlag(parser)
flags.AddDeploymentFlag(parser)
flags.AddPreviewModeFlag(parser)
flags.AddTerraformBlueprintFlag(parser)
flags.AddServiceAccountFlag(parser)
flags.AddWorkerPoolFlag(parser)
flags.AddArtifactsGCSBucketFlag(parser)
flags.AddProviderSourceFlag(parser)
flags.AddTFVersionConstraintFlag(parser)
concept_parsers.ConceptParser(
[
resource_args.GetLocationResourceArgSpec(
'the location to be used as parent.'
),
resource_args.GetPreviewResourceArgSpec(
"""the preview to be used as parent. It is optional and will be
generated if not specified with a fully specified name.""",
False,
{'location': ''},
),
],
command_level_fallthroughs={
'PREVIEW.location': ['--location.location']
},
).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 Preview resource or, in the case that args.async_ is
True, a long-running operation.
"""
messages = configmanager_util.GetMessagesModule()
preview_ref = args.CONCEPTS.preview.Parse()
if preview_ref is not None:
preview_full_name = preview_ref.RelativeName()
location_full_name = preview_ref.Parent().RelativeName()
else:
preview_full_name = None
location_ref = args.CONCEPTS.location.Parse()
location_full_name = location_ref.RelativeName()
return deploy_util.Create(
messages,
args.async_,
preview_full_name,
location_full_name,
args.deployment,
args.preview_mode,
args.service_account,
args.local_source,
args.stage_bucket,
args.ignore_file,
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.annotations,
args.provider_source,
args.tf_version_constraint,
)

View File

@@ -0,0 +1,19 @@
- release_tracks: [GA]
help_text:
brief: Delete previews
description: Delete a preview
examples: |-
To delete the preview `example-preview` at location `us-central1`, run:
$ {command} projects/example-project/locations/us-central1/previews/example-preview
arguments:
resource:
spec: !REF googlecloudsdk.command_lib.infra_manager.resources:preview
help_text: previews TBD
request:
collection: config.projects.locations.previews
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 previews
description: Describe a preview
examples: |-
To describe a preview `example-preview` in project `p1` at location `us-central1`, run:
$ {command} projects/p1/locations/us-central1/previews/example-preview
arguments:
resource:
spec: !REF googlecloudsdk.command_lib.infra_manager.resources:preview
help_text: The preview to describe
request:
collection: config.projects.locations.previews

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.
"""Export preview results."""
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 Export(base.Command):
"""Export preview results.
This command generates a signed url to download a preview results.
"""
detailed_help = {'EXAMPLES': """
Export preview results for `my-preview`:
$ {command} projects/p1/locations/us-central1/previews/my-preview
"""}
@staticmethod
def Args(parser):
flag_help_text = """\
File name for preview export artifacts. It is optional and it specifies
the filename or complete path for the downloaded preview export
artifacts. If only a file path is provided, the artifacts will be
downloaded as "preview" within that directory. If a filename is
included, the artifacts will be downloaded with that name."""
flags.AddFileFlag(parser, flag_help_text)
concept_parsers.ConceptParser(
[
resource_args.GetPreviewResourceArgSpec(
'the preview 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:
Preview results containing signed urls that can be used to download the
binary and json plans.
"""
messages = configmanager_util.GetMessagesModule()
preview_ref = args.CONCEPTS.preview.Parse()
preview_full_name = preview_ref.RelativeName()
return deploy_util.ExportPreviewResult(
messages,
preview_full_name,
args.file,
)

View File

@@ -0,0 +1,24 @@
- release_tracks: [GA]
help_text:
brief: List previews
description: List previews
examples: |-
To list all previews 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 previews
request:
collection: config.projects.locations.previews
response:
id_field: name
output:
format: |
table(
name.basename(),
state,
tfVersion,
createTime:sort=1
)

View File

@@ -0,0 +1,27 @@
# -*- 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.
"""Manage resource change resources."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class ResourceChanges(base.Group):
"""Manage resource change resources."""

View File

@@ -0,0 +1,14 @@
- release_tracks: [GA]
help_text:
brief: Describe resource changes
description: Describe a resource change
examples: |-
To describe a resource change `rc` under preview `pr1` at location `us-central1`, run:
$ {command} projects/p1/locations/us-central1/previews/pr1/resourceChanges/rc
arguments:
resource:
spec: !REF googlecloudsdk.command_lib.infra_manager.resources:resource_change
help_text: The resource change to describe
request:
collection: config.projects.locations.previews.resourceChanges

View File

@@ -0,0 +1,23 @@
- release_tracks: [GA]
help_text:
brief: List resource changes
description: List resource changes for a preview
examples: |-
To list all resource changes for preview projects/p1/locations/us-central1/previews/pr1, run:
$ {command} --preview=projects/p1/locations/us-central1/previews/pr1
arguments:
resource:
spec: !REF googlecloudsdk.command_lib.infra_manager.resources:preview
help_text: The preview for which we want to list all resource changes.
request:
collection: config.projects.locations.previews.resourceChanges
response:
id_field: name
output:
format: |
table(
name.basename(),
intent,
terraformInfo.address:label=TF_ADDRESS
)

View File

@@ -0,0 +1,27 @@
# -*- 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.
"""Manage resource drift resources."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class ResourceDrifts(base.Group):
"""Manage resource drift resources."""

View File

@@ -0,0 +1,14 @@
- release_tracks: [GA]
help_text:
brief: Describe resource drifts
description: Describe a resource drift
examples: |-
To describe a resource drift `rd` under preview `pr1` at location `us-central1`, run:
$ {command} projects/p1/locations/us-central1/previews/pr1/resourceDrifts/rd
arguments:
resource:
spec: !REF googlecloudsdk.command_lib.infra_manager.resources:resource_drift
help_text: The resource drift to describe
request:
collection: config.projects.locations.previews.resourceDrifts

View File

@@ -0,0 +1,22 @@
- release_tracks: [GA]
help_text:
brief: List resource drifts
description: List resource drifts for a preview
examples: |-
To list all resource drifts for preview projects/p1/locations/us-central1/previews/pr1, run:
$ {command} --preview=projects/p1/locations/us-central1/previews/pr1
arguments:
resource:
spec: !REF googlecloudsdk.command_lib.infra_manager.resources:preview
help_text: The preview for which we want to list all resource drifts.
request:
collection: config.projects.locations.previews.resourceDrifts
response:
id_field: name
output:
format: |
table(
name.basename(),
terraformInfo.address:label=TF_ADDRESS
)

View File

@@ -0,0 +1,28 @@
# -*- 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.
#
# NOTE: This file is autogenerated and should not be edited by hand.
"""List or describe resources under a Revision."""
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 Resources(base.Group):
"""List or describe resources under a Revision."""

View File

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

View File

@@ -0,0 +1,22 @@
- release_tracks: [GA]
help_text:
brief: List resources
description: List resources for a deployment revision
examples: |-
To list all resources for a deployment revision, projects/p1/locations/l1/deployments/d1/revisions/r-0, run:
$ {command} --revision=projects/p1/locations/l1/deployments/d1/revisions/r-0
arguments:
resource:
spec: !REF googlecloudsdk.command_lib.infra_manager.resources:revision
help_text: The deployment revision for which we want to list all resources.
request:
collection: config.projects.locations.deployments.revisions.resources
response:
id_field: name
output:
format: |
table(
name.basename(),
state
)

View File

@@ -0,0 +1,28 @@
# -*- 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.
#
# NOTE: This file is autogenerated and should not be edited by hand.
"""Manage Revision 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 Revisions(base.Group):
"""Manage Revision resources."""

View File

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

View File

@@ -0,0 +1,69 @@
# -*- 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 revision 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 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 revision `projects/p1/locations/l1/deployments/d1/revisions/r-0`:
$ {command} projects/p1/locations/l1/deployments/d1/revisions/r-0
"""}
@staticmethod
def Args(parser):
concept_parsers.ConceptParser(
[
resource_args.GetRevisionResourceArgSpec(
'the revision 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()
revision_ref = args.CONCEPTS.revision.Parse()
revision_full_name = revision_ref.RelativeName()
return deploy_util.ExportRevisionStateFile(
messages,
revision_full_name,
)

View File

@@ -0,0 +1,25 @@
- release_tracks: [GA]
help_text:
brief: List revisions
description: List revisions for a deployment
examples: |-
To list all revisions for deployment projects/p1/locations/l1/deployments/d1, run:
$ {command} --deployment=projects/p1/locations/l1/deployments/d1
arguments:
resource:
spec: !REF googlecloudsdk.command_lib.infra_manager.resources:deployment
help_text: The deployment for which we want to list all revisions.
request:
collection: config.projects.locations.deployments.revisions
response:
id_field: name
output:
format: |
table(
name.basename(),
state,
tfVersion,
createTime:sort=1,
updateTime
)

View File

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

View File

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

View File

@@ -0,0 +1,25 @@
- release_tracks: [GA]
help_text:
brief: List Terraform versions
description: List Terraform versions
examples: |-
To list all Terraform versions 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 Terraform versions
request:
collection: config.projects.locations.terraformVersions
response:
id_field: name
output:
format: |
table(
name.basename(),
state:sort=1,
supportTime,
deprecateTime,
obsoleteTime
)