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,41 @@
# -*- 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.
"""Package for the machine image CLI commands."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.UniverseCompatible
@base.ReleaseTracks(
base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA, base.ReleaseTrack.GA)
class MachineImage(base.Group):
"""Read and manage Compute Engine machine image resources."""
category = base.COMPUTE_CATEGORY
MachineImage.detailed_help = {
'DESCRIPTION': """
Read and manage Compute Engine machine image resources..
For more information about machine images, see the
[machine images documentation](https://cloud.google.com/compute/docs/machine-images).
See also: [Machine images API](https://cloud.google.com/compute/docs/reference/rest/v1/machineImages).
""",
}

View File

@@ -0,0 +1,36 @@
release_tracks: [ALPHA, BETA, GA]
help_text:
brief: Add IAM policy binding to the IAM policy of a Compute Engine machine image.
description: |
Add an IAM policy binding to the IAM policy of a Compute Engine machine image. A policy binding
consists of a member and a role.
examples: |
To add an IAM policy binding for the role of 'roles/compute.admin' for the user
'test-user@gmail.com' to machine image 'my-image' run:
$ {command} my-image --member='user:test-user@gmail.com' --role='roles/compute.admin'
See https://cloud.google.com/iam/docs/managing-policies for details of
policy role and member types.
request:
collection: compute.machineImages
use_relative_name: false
api_version: v1
BETA:
api_version: beta
ALPHA:
api_version: alpha
arguments:
resource:
help_text: The machine image for which to add IAM policy binding to.
spec: !REF googlecloudsdk.command_lib.compute.resources:machine_image
iam:
enable_condition: false
set_iam_policy_request_path: globalSetPolicyRequest
policy_version: 3
get_iam_policy_version_path: optionsRequestedPolicyVersion

View File

@@ -0,0 +1,163 @@
# -*- 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 for creating machine images."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.compute import base_classes
from googlecloudsdk.api_lib.compute import csek_utils
from googlecloudsdk.api_lib.compute import kms_utils
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.compute import flags
from googlecloudsdk.command_lib.compute import scope
from googlecloudsdk.command_lib.compute.machine_images import flags as machine_image_flags
from googlecloudsdk.command_lib.kms import resource_args as kms_resource_args
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Create(base.CreateCommand):
"""Create a Compute Engine machine image."""
_ALLOW_RSA_ENCRYPTED_CSEK_KEYS = True
_SUPPORT_DISK_FILTERING = False
detailed_help = {
'brief':
'Create a Compute Engine machine image.',
'EXAMPLES':
"""
To create a machine image, run:
$ {command} my-machine-image --source-instance=example-source --source-instance-zone=us-central1-a
""",
}
@classmethod
def Args(cls, parser):
parser.display_info.AddFormat(machine_image_flags.DEFAULT_LIST_FORMAT)
Create.MACHINE_IMAGE_ARG = machine_image_flags.MakeMachineImageArg()
Create.MACHINE_IMAGE_ARG.AddArgument(parser, operation_type='create')
parser.add_argument(
'--description',
help='Specifies a text description of the machine image.')
csek_utils.AddCsekKeyArgs(parser, resource_type='machine image')
flags.AddStorageLocationFlag(parser, "machine image's")
flags.AddGuestFlushFlag(parser, 'machine image')
flags.AddSourceDiskCsekKeyArg(parser)
kms_resource_args.AddKmsKeyResourceArg(parser, 'machine image')
if cls._SUPPORT_DISK_FILTERING:
machine_image_flags.AddDiskFilterArgs(parser)
Create.SOURCE_INSTANCE = machine_image_flags.MakeSourceInstanceArg()
Create.SOURCE_INSTANCE.AddArgument(parser)
def Run(self, args):
"""Returns a list of requests necessary for adding machine images."""
holder = base_classes.ComputeApiHolder(self.ReleaseTrack())
client = holder.client
machine_image_ref = Create.MACHINE_IMAGE_ARG.ResolveAsResource(
args,
holder.resources,
default_scope=scope.ScopeEnum.GLOBAL,
scope_lister=flags.GetDefaultScopeLister(client))
source_instance = Create.SOURCE_INSTANCE.ResolveAsResource(
args, holder.resources)
machine_image = client.messages.MachineImage(
name=machine_image_ref.Name(),
description=args.description,
sourceInstance=source_instance.SelfLink())
csek_keys = csek_utils.CsekKeyStore.FromArgs(
args, self._ALLOW_RSA_ENCRYPTED_CSEK_KEYS)
if csek_keys:
machine_image.machineImageEncryptionKey = csek_utils.MaybeToMessage(
csek_keys.LookupKey(
machine_image_ref, raise_if_missing=args.require_csek_key_create),
client.apitools_client)
machine_image.machineImageEncryptionKey = kms_utils.MaybeGetKmsKey(
args, client.messages, machine_image.machineImageEncryptionKey)
if args.IsSpecified('storage_location'):
machine_image.storageLocations = [args.storage_location]
if args.IsSpecified('guest_flush'):
machine_image.guestFlush = args.guest_flush
if self._SUPPORT_DISK_FILTERING:
if args.IsSpecified('include_disks'):
machine_image.params = client.messages.MachineImageParams(
includedDisks=args.include_disks
)
if args.IsSpecified('exclude_disks'):
machine_image.params = client.messages.MachineImageParams(
excludedDisks=args.exclude_disks
)
source_csek_keys = getattr(args, 'source_disk_csek_key', [])
disk_keys = {}
if source_csek_keys:
for key in source_csek_keys:
disk_url = key.get('disk')
disk_ref = holder.resources.Parse(
disk_url,
collection='compute.disks',
params={
'project': source_instance.project,
'zone': source_instance.project
})
key_store = csek_utils.CsekKeyStore.FromFile(
key.get('csek-key-file'), self._ALLOW_RSA_ENCRYPTED_CSEK_KEYS)
disk_key = csek_utils.MaybeToMessage(
key_store.LookupKey(disk_ref), client.apitools_client)
disk_keys[disk_url] = disk_key
source_disk_messages = []
if disk_keys:
for disk, key in disk_keys.items():
source_disk_message = client.messages.SourceDiskEncryptionKey(
sourceDisk=disk, diskEncryptionKey=key)
source_disk_messages.append(source_disk_message)
if source_disk_messages:
machine_image.sourceDiskEncryptionKeys = source_disk_messages
request = client.messages.ComputeMachineImagesInsertRequest(
machineImage=machine_image, project=machine_image_ref.project)
return client.MakeRequests([(client.apitools_client.machineImages, 'Insert',
request)])
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class CreateBeta(Create):
"""Create a Compute Engine machine image."""
_SUPPORT_DISK_FILTERING = False
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class CreateAlpha(CreateBeta):
"""Create a Compute Engine machine image."""
_SUPPORT_DISK_FILTERING = True

View File

@@ -0,0 +1,76 @@
# -*- 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 for deleting machine images."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.compute import base_classes
from googlecloudsdk.api_lib.compute import utils
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.compute import flags as compute_flags
from googlecloudsdk.command_lib.compute.machine_images import flags
def construct_requests(client, machine_image_refs):
requests = []
for machine_image_ref in machine_image_refs:
delete_request = (client.apitools_client.machineImages, 'Delete',
client.messages.ComputeMachineImagesDeleteRequest(
**machine_image_ref.AsDict()))
requests.append(delete_request)
return requests
class Delete(base.DeleteCommand):
"""Delete a Compute Engine machine image."""
detailed_help = {
'brief':
'Delete a Compute Engine machine image.',
'description':
"""
*{command}* deletes one or more Compute Engine
machine images. Machine images can be deleted only if they are not
being used to restore virtual machine instances.
""",
'EXAMPLES':
"""
To delete a machine image, run:
$ {command} my-machine-image
""",
}
@staticmethod
def Args(parser):
Delete.MACHINE_IMAGE_ARG = flags.MakeMachineImageArg(plural=True)
Delete.MACHINE_IMAGE_ARG.AddArgument(parser, operation_type='delete')
def Run(self, args):
holder = base_classes.ComputeApiHolder(self.ReleaseTrack())
client = holder.client
machine_image_refs = Delete.MACHINE_IMAGE_ARG.ResolveAsResource(
args,
holder.resources,
scope_lister=compute_flags.GetDefaultScopeLister(client))
utils.PromptForDeletion(machine_image_refs)
requests = construct_requests(client, machine_image_refs)
return client.MakeRequests(requests)

View File

@@ -0,0 +1,64 @@
# -*- 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 for describing machine images."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.compute import base_classes
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.compute import flags as compute_flags
from googlecloudsdk.command_lib.compute.machine_images import flags
class Describe(base.DescribeCommand):
"""Describe a Compute Engine machine image."""
detailed_help = {
'brief':
'Describe a Compute Engine machine image.',
'description': """
*{command}* deletes one or more Compute Engine
machine images. Machine images can be deleted only if they are not
being used to restore virtual machine instances.
""",
'EXAMPLES':
"""
To describe a machine image, run:
$ {command} my-machine-image
""",
}
@staticmethod
def Args(parser):
Describe.MACHINE_IMAGE_ARG = flags.MakeMachineImageArg()
Describe.MACHINE_IMAGE_ARG.AddArgument(parser, operation_type='describe')
def Run(self, args):
holder = base_classes.ComputeApiHolder(self.ReleaseTrack())
client = holder.client
machine_image_ref = Describe.MACHINE_IMAGE_ARG.ResolveAsResource(
args,
holder.resources,
scope_lister=compute_flags.GetDefaultScopeLister(client))
request = client.messages.ComputeMachineImagesGetRequest(
**machine_image_ref.AsDict())
return client.MakeRequests([(client.apitools_client.machineImages, 'Get',
request)])[0]

View File

@@ -0,0 +1,29 @@
release_tracks: [ALPHA, BETA, GA]
help_text:
brief: Get the IAM policy for a Compute Engine machine image.
description: |
*{command}* displays the IAM policy associated with a Compute Engine machine image in a
project. If formatted as JSON, the output can be edited and used as a policy file for {command}
set-iam-policy. The output includes an `etag` field that identifies the version emitted and
allows detection of concurrent policy updates; see $ {command} set-iam-policy for additional details.
examples: |
To print the IAM policy for a given machine image, run:
$ {command} my-machine-image
request:
collection: compute.machineImages
use_relative_name: false
api_version: v1
BETA:
api_version: beta
ALPHA:
api_version: alpha
modify_request_hooks:
- googlecloudsdk.command_lib.iam.hooks:UseMaxRequestedPolicyVersion:api_field=optionsRequestedPolicyVersion
arguments:
resource:
help_text: The machine image to display the IAM policy for.
spec: !REF googlecloudsdk.command_lib.compute.resources:machine_image

View File

@@ -0,0 +1,216 @@
# -*- 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 importing machine images in OVF format into GCE."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.compute import base_classes
from googlecloudsdk.api_lib.compute import daisy_utils
from googlecloudsdk.api_lib.compute import image_utils
from googlecloudsdk.calliope import base
from googlecloudsdk.calliope import exceptions
from googlecloudsdk.command_lib.compute import completers
from googlecloudsdk.command_lib.compute import flags
from googlecloudsdk.command_lib.compute.images import os_choices
from googlecloudsdk.command_lib.compute.instances import flags as instances_flags
from googlecloudsdk.command_lib.compute.machine_images import flags as machine_image_flags
from googlecloudsdk.command_lib.util.args import labels_util
from googlecloudsdk.core import log
from googlecloudsdk.core import resources
_OUTPUT_FILTER = ['[Daisy', '[import-', 'starting build', ' import', 'ERROR']
@base.ReleaseTracks(base.ReleaseTrack.GA)
@base.Deprecate(
is_removed=False,
warning=(
'This command is being deprecated. Instead, use the `gcloud migration'
' vms machine-image-imports` command. For more information, See "gcloud'
' alpha migration vms machine-image-imports --help".'
),
error=(
'This command has been deprecated. Instead, use the `gcloud migration'
' vms machine-image-imports` command. For more information, See "gcloud'
' alpha migration vms machine-image-imports --help".'
),
)
@base.DefaultUniverseOnly
class Import(base.CreateCommand):
"""Import a machine image into Compute Engine from OVF."""
@classmethod
def Args(cls, parser):
compute_holder = cls._GetComputeApiHolder(no_http=True)
messages = compute_holder.client.messages
parser.display_info.AddFormat(machine_image_flags.DEFAULT_LIST_FORMAT)
Import.MACHINE_IMAGE_ARG = machine_image_flags.MakeMachineImageArg()
Import.MACHINE_IMAGE_ARG.AddArgument(parser, operation_type='import')
parser.add_argument(
'--description',
help='Specifies a text description of the machine image.')
flags.AddStorageLocationFlag(parser, "machine image's")
flags.AddGuestFlushFlag(parser, 'machine image')
machine_image_flags.AddNoRestartOnFailureArgs(parser)
machine_image_flags.AddTagsArgs(parser)
machine_image_flags.AddCanIpForwardArgs(parser)
machine_image_flags.AddNetworkArgs(parser)
machine_image_flags.AddNetworkTierArgs(parser)
instances_flags.AddMachineTypeArgs(parser)
instances_flags.AddCustomMachineTypeArgs(parser)
labels_util.AddCreateLabelsFlags(parser)
daisy_utils.AddCommonDaisyArgs(parser, operation='an import')
daisy_utils.AddOVFSourceUriArg(parser)
image_utils.AddGuestOsFeaturesArgForImport(parser, messages)
parser.add_argument(
'--os',
required=False,
choices=sorted(os_choices.OS_CHOICES_INSTANCE_IMPORT_BETA),
help='Specifies the OS of the machine image being imported.')
daisy_utils.AddByolArg(parser)
flags.AddZoneFlag(
parser,
'machine image',
'import',
explanation='The zone in which to perform the import of the machine image. '
+ flags.ZONE_PROPERTY_EXPLANATION)
daisy_utils.AddGuestEnvironmentArg(parser, 'machine image')
parser.display_info.AddCacheUpdater(completers.InstancesCompleter)
daisy_utils.AddNoAddressArg(
parser,
'machine image import',
docs_url=(
'https://cloud.google.com/nat/docs/gce-example#create-nat '
'and https://cloud.google.com/vpc/docs/private-access-options#pga'))
daisy_utils.AddComputeServiceAccountArg(
parser, 'machine image import',
daisy_utils.IMPORT_ROLES_FOR_COMPUTE_SERVICE_ACCOUNT)
daisy_utils.AddCloudBuildServiceAccountArg(
parser,
'machine image import',
daisy_utils.IMPORT_ROLES_FOR_CLOUDBUILD_SERVICE_ACCOUNT,
)
instances_flags.AddServiceAccountAndScopeArgs(
parser,
False,
extra_scopes_help=(
'However, if neither `--scopes` nor `--no-scopes` are '
'specified and the project has no default service '
'account, then the machine image is imported with no '
'scopes. Note that the level of access that a service '
'account has is determined by a combination of access '
'scopes and IAM roles so you must configure both '
'access scopes and IAM roles for the service account '
'to work properly.'),
operation='Import',
resource='machine image')
parser.add_argument(
'--cmd-deprecated',
action='store_true',
required=True,
help="""
The command you're using is deprecated and will be removed by December 31,
2025. We recommend using `gcloud compute migration image-imports` instead.
See our official documentation for more information.
https://cloud.google.com/migrate/virtual-machines/docs/5.0/migrate/image_import.
""",
)
@classmethod
def _GetComputeApiHolder(cls, no_http=False):
return base_classes.ComputeApiHolder(cls.ReleaseTrack(), no_http)
def _ValidateArgs(self, args, compute_client):
instances_flags.ValidateNicFlags(args)
instances_flags.ValidateNetworkTierArgs(args)
daisy_utils.ValidateZone(args, compute_client)
instances_flags.ValidateServiceAccountAndScopeArgs(args)
try:
args.source_uri = daisy_utils.MakeGcsUri(args.source_uri)
except resources.UnknownCollectionException:
raise exceptions.InvalidArgumentException(
'source-uri',
'must be a path to an object or a directory in Cloud Storage')
def Run(self, args):
compute_holder = self._GetComputeApiHolder()
compute_client = compute_holder.client
self._ValidateArgs(args, compute_client)
log.warning('Importing OVF. This may take 40 minutes for smaller OVFs '
'and up to a couple of hours for larger OVFs.')
return daisy_utils.RunMachineImageOVFImportBuild(
args=args,
output_filter=_OUTPUT_FILTER,
release_track=(self.ReleaseTrack().id.lower()
if self.ReleaseTrack() else None),
messages=compute_client.messages)
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class ImportBeta(Import):
"""Import a machine image into Compute Engine from OVF for Beta."""
@classmethod
def Args(cls, parser):
super(ImportBeta, cls).Args(parser)
daisy_utils.AddExtraCommonDaisyArgs(parser)
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class ImportAlpha(Import):
"""Import a machine image into Compute Engine from OVF for Alpha."""
@classmethod
def Args(cls, parser):
super(ImportAlpha, cls).Args(parser)
daisy_utils.AddExtraCommonDaisyArgs(parser)
Import.detailed_help = {
'brief': (
'Create a Compute Engine machine image from virtual appliance '
'in OVA/OVF format.'),
'DESCRIPTION':
"""\
*{command}* creates Compute Engine machine image from virtual appliance
in OVA/OVF format.
Importing OVF involves:
* Unpacking OVF package (if in OVA format) to Cloud Storage.
* Import disks from OVF to Compute Engine.
* Translate the boot disk to make it bootable in Compute Engine.
* Create a machine image using OVF metadata and imported disks.
Virtual instances, images, machine images, and disks in Compute engine
and files stored on Cloud Storage incur charges. See [](https://cloud.google.com/compute/docs/images/importing-virtual-disks#resource_cleanup).
""",
'EXAMPLES':
"""\
To import an OVF package from Cloud Storage into a machine image named
`my-machine-image`, run:
$ {command} my-machine-image --source-uri=gs://my-bucket/my-dir
""",
}

View File

@@ -0,0 +1,48 @@
# -*- 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 for listing machine images."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.compute import base_classes
from googlecloudsdk.api_lib.compute import lister
from googlecloudsdk.api_lib.compute import utils
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.compute.machine_images import flags
class List(base.ListCommand):
"""List Compute Engine machine images."""
@staticmethod
def Args(parser):
parser.display_info.AddFormat(flags.DEFAULT_LIST_FORMAT)
parser.display_info.AddUriFunc(utils.MakeGetUriFunc())
def Run(self, args):
holder = base_classes.ComputeApiHolder(self.ReleaseTrack())
client = holder.client
request_data = lister.ParseNamesAndRegexpFlags(args, holder.resources)
list_implementation = lister.GlobalLister(
client, client.apitools_client.machineImages)
return lister.Invoke(request_data, list_implementation)
List.detailed_help = base_classes.GetGlobalListerHelp('machine images')

View File

@@ -0,0 +1,36 @@
release_tracks: [ALPHA, BETA, GA]
help_text:
brief: Remove IAM policy binding from the IAM policy of a Compute Engine machine image.
description: |
Remove an IAM policy binding from the IAM policy of a Compute Engine machine image.
A policy binding consists of a member and a role.
examples: |
To remove an IAM policy binding for the role of 'roles/compute.admin' for the user
'test-user@gmail.com' from image 'my-image'
$ {command} my-image --member='user:test-user@gmail.com' --role='roles/compute.admin'
See https://cloud.google.com/iam/docs/managing-policies for details of
policy role and member types.
request:
collection: compute.machineImages
use_relative_name: false
api_version: v1
BETA:
api_version: beta
ALPHA:
api_version: alpha
arguments:
resource:
help_text: The machine image from which to remove the IAM policy binding.
spec: !REF googlecloudsdk.command_lib.compute.resources:machine_image
iam:
enable_condition: false
set_iam_policy_request_path: globalSetPolicyRequest
policy_version: 3
get_iam_policy_version_path: optionsRequestedPolicyVersion

View File

@@ -0,0 +1,37 @@
release_tracks: [ALPHA, BETA, GA]
help_text:
brief: Set the IAM policy for a Compute Engine machine image.
description: |
Sets the IAM policy for the given machine image as defined in a JSON or YAML file.
examples: |
The following command reads an IAM policy defined in a `policy.json` file
and sets the policy for the machine image `my-image`:
$ {command} my-image policy.json
See https://cloud.google.com/iam/docs/managing-policies for details of the
policy file format and contents.
request:
collection: compute.machineImages
use_relative_name: false
modify_request_hooks:
- googlecloudsdk.command_lib.iam.hooks:UseMaxRequestedPolicyVersion:api_field=globalSetPolicyRequest.policy.version
api_version: v1
BETA:
api_version: beta
ALPHA:
api_version: alpha
arguments:
resource:
help_text: The machine image to set the IAM policy for.
spec: !REF googlecloudsdk.command_lib.compute.resources:machine_image
iam:
enable_condition: true
set_iam_policy_request_path: globalSetPolicyRequest
message_type_overrides:
policy: Policy
set_iam_policy_request: ComputeMachineImagesSetIamPolicyRequest