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,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.
"""Command group for Cloud Security Command Center (SCC) posture deployments."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.GA)
class PostureDeployments(base.Group):
"""Manage Cloud Security Command Center (SCC) posture deployments."""
category = base.SECURITY_CATEGORY

View File

@@ -0,0 +1,63 @@
- release_tracks: [ALPHA, GA]
command_type: GENERIC
help_text:
brief: Create a Cloud Security Command Center (SCC) posture deployment.
description: |
Create a Cloud Security Command Center (SCC) posture deployment. First argument is the parent of the posture deployment to
be created. Second argument is the name of the posture deployment to be created. It is followed by details of the posture to be deployed and the target_resource to be deployed on.
LRO operation ID is returned as the response of the command.
examples: |
Create a posture deployment named `posture-deployment-foo-1` within parent `organizations/123/locations/global` on resource `folders/456` (i.e. a posture-deployment in organization `123`, location `global`, with id `posture-deployment-foo-1`, which deploys posture `organizations/123/locations/foo-posture` with revision-id `foo-posture-revision-id` on `folders/456`):
$ {command} organizations/123/locations/global/postureDeployments/posture-deployment-foo-1 --posture-name=organizations/123/locations/global/foo-posture --posture-revision-id=foo-posture-revision-id --target-resource=projects/456
request:
collection: securityposture.organizations.locations.postureDeployments
api_version: v1alpha
method: create
GA:
api_version: v1
arguments:
resource:
spec: !REF googlecloudsdk.command_lib.scc.resources:posture_deployment
help_text: |
The name of the posture deployment to be created. For example organizations/<organizationID>/locations/<location>/postureDeployments/<postureDeploymentID>.
params:
- arg_name: posture-name
api_field: postureDeployment.postureId
required: true
help_text: |
Posture that needs to be deployed. Format:
organizations/<organizationID>/locations/<location>/postures/<postureID>
- arg_name: posture-revision-id
api_field: postureDeployment.postureRevisionId
required: true
help_text: |
Posture revision that needs to be deployed.
- arg_name: target-resource
api_field: postureDeployment.targetResource
required: true
help_text: |
Name of the workload on which posture deployment is to be created. It could be an organization, folder or a project.
Possible formats: |
organizations/<organizationID> |
folders/<folderID> |
projects/<projectID>
The above mentioned IDs need to have numeric format.
- arg_name: description
api_field: postureDeployment.description
help_text: |
User-provided description of the posture deployment.
async:
collection: securityposture.organizations.locations.operations
extract_resource_result: false
output:
format: yaml

View File

@@ -0,0 +1,47 @@
- release_tracks: [ALPHA, GA]
command_type: GENERIC
help_text:
brief: Delete a Cloud Security Command Center (SCC) posture deployment.
description: |
Delete a Cloud Security Command Center (SCC) posture deployment.
examples: |
Delete the posture deployment named `organizations/123/locations/global/postureDeployments/posture-deployment-foo` (i.e. a posture deployment in organization `123`, location `global`, with id `posture-deployment-foo`):
$ {command} organizations/123/locations/global/postureDeployments/posture-deployment-foo
Delete the posture deployment named `organizations/123/locations/global/postureDeployments/posture-deployment-foo` (i.e. a posture deployment in organization `123`, location `global`, with id `posture-deployment-foo`)
for the ETAG ABcdO1Rf5clu7Yhlkwgelo7Vl4tiqd7Sy5iP5SdkSVU
$ {command} organizations/123/locations/global/postureDeployments/posture-deployment-foo --etag=ABcdO1Rf5clu7Yhlkwgelo7Vl4tiqd7Sy5iI5SdkSVU
request:
collection: securityposture.organizations.locations.postureDeployments
api_version: v1alpha
method: delete
GA:
api_version: v1
arguments:
resource:
spec: !REF googlecloudsdk.command_lib.scc.resources:posture_deployment
help_text: |
The posture deployment to delete. For example organizations/<organizationID>/locations/<location>/postureDeployments/<postureDeploymentID>.
params:
- arg_name: etag
api_field: etag
required: false
help_text: |
Etag is an optional flag. If the provided Etag doesn't match the server generated Etag, the delete operation won't proceed.
input:
confirmation_prompt: |
You are about to delete posture deployment [{__name__}]. All the deployed policies of this posture will get removed.
async:
collection: securityposture.organizations.locations.operations
extract_resource_result: false
output:
format: yaml

View File

@@ -0,0 +1,29 @@
- release_tracks: [ALPHA, GA]
help_text:
brief: Describe a Cloud Security Command Center (SCC) posture deployment.
description: |
Describe a Cloud Security Command Center (SCC) posture deployment.
examples: |
To describe posture deployment `organizations/123/locations/global/postureDeployments/posture-deployment-foo-1`
(i.e. a posture deployment
in organization `123`, location `global`, with ID `posture-deployment-foo-1`), run:
$ {command} organizations/123/locations/global/postureDeployments/posture-deployment-foo-1
or, run:
$ {command} posture-deployment-foo-1 --organization=123 --location=global
request:
collection: securityposture.organizations.locations.postureDeployments
api_version: v1alpha
method: get
GA:
api_version: v1
arguments:
resource:
spec: !REF googlecloudsdk.command_lib.scc.resources:posture_deployment
help_text: |
The posture deployment to describe. For example organizations/<organizationID>/locations/<location>/postureDeployments/<postureDeploymentID>.

View File

@@ -0,0 +1,177 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Command for listing an organization posture deployments."""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from apitools.base.py import list_pager
from googlecloudsdk.api_lib.scc.postures import util as securityposture_client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.scc import errors
from googlecloudsdk.command_lib.scc import util as scc_util
from googlecloudsdk.command_lib.scc.posture_deployments import flags
@base.ReleaseTracks(base.ReleaseTrack.GA)
@base.DefaultUniverseOnly
class List(base.ListCommand):
"""List the details of the Cloud Security Command Center (SCC) posture deployments."""
detailed_help = {
"DESCRIPTION": """
List the details of the Cloud Security Command Center (SCC) posture
deployments for the specified organization.""",
"EXAMPLES": """
To list Cloud Security Command Center posture deployments for organization `123` in the `global` location, run:
$ {command} organizations/123/locations/global
$ {command} --organization=123 --location=global
""",
"API REFERENCE": (
"""
This command uses the securityposture/v1 API. The full documentation for
this API can be found at: https://cloud.google.com/security-command-center"""
),
}
@staticmethod
def Args(parser):
# Remove URI flag.
base.URI_FLAG.RemoveFromParser(parser)
# Add shared flags and parent positional argument.
flags.AddParentOrFlagsGroup(parser)
def Run(self, args):
version = scc_util.GetVersionFromArguments(
args, version_specific_existing_resource=True
)
messages = securityposture_client.GetMessagesModule(base.ReleaseTrack.GA)
client = securityposture_client.GetClientInstance(base.ReleaseTrack.GA)
location = scc_util.ValidateAndGetLocation(args, version)
if (args.IsKnownAndSpecified("PARENT")) and (
args.IsSpecified("organization") and args.IsSpecified("location")
):
raise errors.InvalidSCCInputError(
"Cannot provide both a positional `PARENT` and argument "
"(`--organization`, `--location`) flags."
)
if (args.IsKnownAndSpecified("PARENT")):
parent = args.PARENT
elif (args.IsSpecified("organization") and args.IsSpecified("location")):
parent = f"{scc_util.GetParentFromPositionalArguments(args)}/locations/{location}"
else:
raise errors.InvalidSCCInputError(
"Must provide either positional `PARENT` or both `--organization` "
"and `--location` flags."
)
# Build request.
request = messages.SecuritypostureOrganizationsLocationsPostureDeploymentsListRequest(
parent=parent,
filter=getattr(args, "filter", None),
pageSize=getattr(args, "page_size", None),
)
return list_pager.YieldFromList(
client.organizations_locations_postureDeployments,
request,
batch_size_attribute="pageSize",
batch_size=args.page_size,
field="postureDeployments",
)
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
@base.DefaultUniverseOnly
class ListAlpha(base.ListCommand):
"""List the details of the Cloud Security Command Center (SCC) posture deployments."""
detailed_help = {
"DESCRIPTION": """
List the details of the Cloud Security Command Center (SCC) posture
deployments for the specified organization.""",
"EXAMPLES": """
To list Cloud Security Command Center posture deployments for organization `123` in the `global` location, run:
$ {command} organizations/123/locations/global
$ {command} --organization=123 --location=global
""",
"API REFERENCE": """
This command uses the securityposture/v1alpha API. The full documentation for this API can be found at:
https://cloud.google.com/security-command-center""",
}
@staticmethod
def Args(parser):
# Remove URI flag.
base.URI_FLAG.RemoveFromParser(parser)
# Add shared flags and parent positional argument.
flags.AddParentOrFlagsGroup(parser)
def Run(self, args):
version = scc_util.GetVersionFromArguments(
args, version_specific_existing_resource=True
)
messages = securityposture_client.GetMessagesModule(base.ReleaseTrack.ALPHA)
client = securityposture_client.GetClientInstance(base.ReleaseTrack.ALPHA)
location = scc_util.ValidateAndGetLocation(args, version)
if (args.IsKnownAndSpecified("PARENT")) and (
args.IsSpecified("organization") and args.IsSpecified("location")
):
raise errors.InvalidSCCInputError(
"Cannot provide both a positional `PARENT` and argument "
"(`--organization`, `--location`) flags."
)
if (args.IsKnownAndSpecified("PARENT")):
parent = args.PARENT
elif (args.IsSpecified("organization") and args.IsSpecified("location")):
parent = f"{scc_util.GetParentFromPositionalArguments(args)}/locations/{location}"
else:
raise errors.InvalidSCCInputError(
"Must provide either positional `PARENT` or both `--organization` "
"and `--location` flags."
)
# Build request.
request = messages.SecuritypostureOrganizationsLocationsPostureDeploymentsListRequest(
parent=parent,
filter=getattr(args, "filter", None),
pageSize=getattr(args, "page_size", None),
)
return list_pager.YieldFromList(
client.organizations_locations_postureDeployments,
request,
batch_size_attribute="pageSize",
batch_size=args.page_size,
field="postureDeployments",
)

View File

@@ -0,0 +1,72 @@
- release_tracks: [ALPHA, GA]
command_type: GENERIC
help_text:
brief: Update the given Cloud Security Command Center (SCC) posture deployment.
description: |
Update a Cloud Security Command Center (SCC) posture deployment.
Fields specified in update-mask flag are updated. Updatable fields are description and posture_name with posture_revision-id.
The target_resource for a posture deployment cannot be updated. The posture deployment to be updated should be in ACTIVE State.
An empty or "*" update-mask implies that posture-id and posture-revision-id are to be updated.
If posture details of posture deployment need to be updated, then the desired posture needs to be in ACTIVE state.
LRO operation ID is returned as the response of the command.
examples: |
Update the description of the posture deployment named `foo-posture-deployment` in the organization `organizations/123/locations/global`:
$ {command} organizations/123/locations/global/postureDeployments/foo-posture-deployment --update-mask=description --description="updated-description"
Update posture deployment named `foo-posture-deployment` with the posture named `foo-posture` and revision_id `abcdefgh` in the organization `organizations/123/locations/global`:
$ {command} organizations/123/locations/global/postureDeployments/foo-posture-deployment --update-mask=posture_id,posture_revision-id --posture-id=foo-posture --posture-revision-id=abcdefgh
Update posture deployment named `foo-posture-deployment` with the posture named `foo-posture` and revision_id `abcdefgh` in the organization `organizations/123/locations/global`:
$ {command} organizations/123/locations/global/postureDeployments/foo-posture-deployment --posture-id=foo-posture --posture-revision-id=abcdefgh
request:
collection: securityposture.organizations.locations.postureDeployments
api_version: v1alpha
method: patch
GA:
api_version: v1
arguments:
resource:
spec: !REF googlecloudsdk.command_lib.scc.resources:posture_deployment
help_text: |
The posture deployment to update. For example organizations/<organizationID>/locations/<location>/postureDeployments/<postureDeploymentID>.
params:
- group:
params:
- arg_name: posture-id
api_field: postureDeployment.postureId
required: true
help_text: |
Relative name of the posture to be updated, like `organizations/<organizationID>/locations/<location>/postures/<postureID>`.
- arg_name: posture-revision-id
api_field: postureDeployment.postureRevisionId
required: true
help_text: |
Revision ID of the posture to be updated.
- arg_name: description
api_field: postureDeployment.description
help_text: |
Updated description of posture deployment.
- arg_name: update-mask
api_field: updateMask
help_text: |
Comma-separated string containing list of fields to be updated.
- arg_name: etag
api_field: postureDeployment.etag
required: false
help_text: |
Etag is an optional flag. If the provided Etag doesn't match the server generated Etag, the update operation won't proceed.
async:
collection: securityposture.organizations.locations.operations
extract_resource_result: false
output:
format: yaml