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 Event Threat Detection custom modules."""
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.ReleaseTrack.ALPHA)
class EventThreatDetectionCustomModules(base.Group):
"""Manage custom modules."""
category = base.SECURITY_CATEGORY

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.
"""Command to create a ETD custom module."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.scc.manage.etd import clients
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.scc.manage import constants
from googlecloudsdk.command_lib.scc.manage import flags
from googlecloudsdk.command_lib.scc.manage import parsing
@base.ReleaseTracks(base.ReleaseTrack.GA, base.ReleaseTrack.ALPHA)
class Create(base.Command):
"""Create an Event Threat Detection custom module.
## EXAMPLES
To create an Event Threat Detection custom module for organization `123`, run:
$ {command} --organization=organizations/123
--display-name="test_display_name"
--module-type="CONFIGURABLE_BAD_IP"
--enablement-state="ENABLED"
--custom-config-file=config.json
"""
@staticmethod
def Args(parser):
flags.CreateParentFlag(required=True).AddToParser(parser)
flags.CreateValidateOnlyFlag(required=False).AddToParser(parser)
flags.CreateEtdCustomConfigFilePathFlag(required=True).AddToParser(parser)
flags.CreateEnablementStateFlag(
module_type=constants.CustomModuleType.ETD,
required=True,
).AddToParser(parser)
flags.CreateDisplayNameFlag(required=True).AddToParser(parser)
flags.CreateModuleTypeFlag(required=True).AddToParser(parser)
def Run(self, args):
parent = parsing.GetParentResourceNameFromArgs(args)
validate_only = args.validate_only
custom_config = parsing.GetConfigValueFromArgs(args.custom_config_file)
enablement_state = parsing.GetEnablementStateFromArgs(
args.enablement_state,
module_type=constants.CustomModuleType.ETD,
)
module_type = args.module_type
display_name = args.display_name
client = clients.ETDCustomModuleClient()
return client.Create(
parent=parent,
validate_only=validate_only,
custom_config=custom_config,
enablement_state=enablement_state,
module_type=module_type,
display_name=display_name,
)

View File

@@ -0,0 +1,91 @@
# -*- 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 to delete a ETD custom module."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.scc.manage.etd import clients
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.scc.manage import constants
from googlecloudsdk.command_lib.scc.manage import flags
from googlecloudsdk.command_lib.scc.manage import parsing
from googlecloudsdk.core.console import console_io
@base.ReleaseTracks(base.ReleaseTrack.GA, base.ReleaseTrack.ALPHA)
class Delete(base.DeleteCommand):
"""Delete an Event Threat Detection custom module.
Delete a Event Threat Detection custom module. User specifies the custom
module as well as the parent of the module to delete. A validation_only flag
is optional. When set to true only validations (including IAM checks) will
done for the request (module will not be deleted).
## EXAMPLES
To delete an Event Threat Detection custom module with ID
`123456` for organization `123`, run:
$ {command} 123456 --organization=123
To delete a Event Threat Detection custom module with ID
`123456` for folder `456`, run:
$ {command} 123456 --folder=456
To delete a Event Threat Detection custom module with ID
`123456` for project `789`, run:
$ {command} 123456 --project=789
You can also specify the parent more generally:
$ {command} 123456 --parent=organizations/123
Or just specify the fully qualified module name:
$ {command}
organizations/123/locations/global/eventThreatDetectionCustomModules/123456
"""
@staticmethod
def Args(parser):
flags.CreateModuleIdOrNameArg(
module_type=constants.CustomModuleType.ETD
).AddToParser(parser)
flags.CreateParentFlag(required=False).AddToParser(parser)
flags.CreateValidateOnlyFlag(required=False).AddToParser(parser)
def Run(self, args):
name = parsing.GetModuleNameFromArgs(
args, module_type=constants.CustomModuleType.ETD
)
validate_only = args.validate_only
if not validate_only:
console_io.PromptContinue(
message=(
'Are you sure you want to delete the Event Threat Detection'
' custom module {}?\n'.format(name)
),
cancel_on_no=True,
)
client = clients.ETDCustomModuleClient()
return client.Delete(name=name, validate_only=validate_only)

View File

@@ -0,0 +1,82 @@
# -*- 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 to get a ETD custom module."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.scc.manage.etd import clients
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.scc.manage import constants
from googlecloudsdk.command_lib.scc.manage import flags
from googlecloudsdk.command_lib.scc.manage import parsing
@base.ReleaseTracks(base.ReleaseTrack.GA, base.ReleaseTrack.ALPHA)
class Describe(base.DescribeCommand):
"""Get the details of a Event Threat Detection custom module.
Get the details of a Event Threat Detection custom module. It does not
resolve INHERITED enablement states
to ENABLED or DISABLED for modules created at ancestor levels. For example, if
the module is enabled
at the ancestor level, modules for all child resources will have the
enablement state set to
INHERITED. Use `gcloud scc manage custom-modules etd get-effective` to
retrieve a custom module with its effective enablement state.
## EXAMPLES
To get the details of a Event Threat Detection custom module with ID
`123456` for organization `123`, run:
$ {command} 123456 --organization=123
To get the details of a Event Threat Detection custom module with ID
`123456` for folder `456`, run:
$ {command} 123456 --folder=456
To get the details of a Event Threat Detection custom module with ID
`123456` for project `789`, run:
$ {command} 123456 --project=789
You can also specify the parent more generally:
$ {command} 123456 --parent=organizations/123
Or just specify the fully qualified module name:
$ {command}
organizations/123/locations/global/eventThreatDetectionCustomModules/123456
"""
@staticmethod
def Args(parser):
flags.CreateModuleIdOrNameArg(
module_type=constants.CustomModuleType.ETD
).AddToParser(parser)
flags.CreateParentFlag(required=False).AddToParser(parser)
def Run(self, args):
name = parsing.GetModuleNameFromArgs(
args, module_type=constants.CustomModuleType.ETD
)
client = clients.ETDCustomModuleClient()
return client.Get(name)

View File

@@ -0,0 +1,76 @@
# -*- 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 to get a ETD effective custom module."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.scc.manage.etd import clients
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.scc.manage import constants
from googlecloudsdk.command_lib.scc.manage import flags
from googlecloudsdk.command_lib.scc.manage import parsing
@base.ReleaseTracks(base.ReleaseTrack.GA, base.ReleaseTrack.ALPHA)
class DescribeEffective(base.DescribeCommand):
"""Get the effective details of a Event Threat Detection effective custom module.
Get the effective details of a Event Threat Detection effective custom module.
It retrieves a custom module with its effective enablement state.
## EXAMPLES
To get the effective details of a Event Threat Detection custom module with ID
`123456` for organization `123`, run:
$ {command} 123456 --organization=123
To get the effective details of a Event Threat Detection custom module with ID
`123456` for folder `456`, run:
$ {command} 123456 --folder=456
To get the effective details of a Event Threat Detection custom module with ID
`123456` for project `789`, run:
$ {command} 123456 --project=789
You can also specify the parent more generally:
$ {command} 123456 --parent=organizations/123
Or just specify the fully qualified module name:
$ {command}
organizations/123/locations/global/effectiveEventThreatDetectionCustomModules/123456
"""
@staticmethod
def Args(parser):
flags.CreateModuleIdOrNameArg(
module_type=constants.CustomModuleType.EFFECTIVE_ETD
).AddToParser(parser)
flags.CreateParentFlag(required=False).AddToParser(parser)
def Run(self, args):
name = parsing.GetModuleNameFromArgs(
args, module_type=constants.CustomModuleType.EFFECTIVE_ETD
)
client = clients.EffectiveETDCustomModuleClient()
return client.Get(name)

View File

@@ -0,0 +1,72 @@
# -*- 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 to list details of resident and inherited Event Threat Detection Custom Modules."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.scc.manage.etd import clients
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.scc.manage import flags
from googlecloudsdk.command_lib.scc.manage import parsing
@base.ReleaseTracks(base.ReleaseTrack.GA, base.ReleaseTrack.ALPHA)
class List(base.ListCommand):
"""List details of resident and inherited Event Threat Detection Custom Modules.
List the details of the resident and inherited Event Threat Detection
custom modules for the specified folder or project. For an organization, this
command lists only the custom modules that are created at the organization
level. Custom modules created in child folders or projects are not included in
the list. To list the resident custom modules and the modules that are created
in child folders or projects, use `gcloud scc manage custom-modules etd
list-descendant`.
## EXAMPLES
To list resident and inherited Event Threat Detection custom modules for
organization `123`, run:
$ {command} --organization=organizations/123
To list resident and inherited Event Threat Detection custom modules for
folder `456`, run:
$ {command} --folder=folders/456
To list resident and inherited Event Threat Detection custom modules for
project `789`, run:
$ {command} --project=projects/789
"""
@staticmethod
def Args(parser):
base.URI_FLAG.RemoveFromParser(parser)
flags.CreateParentFlag(required=True).AddToParser(parser)
def Run(self, args):
parent = parsing.GetParentResourceNameFromArgs(args)
page_size = args.page_size
client = clients.ETDCustomModuleClient()
return client.List(
page_size=page_size,
parent=parent,
limit=args.limit,
)

View File

@@ -0,0 +1,72 @@
# -*- 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 to list the details of an ETD custom module and its descendant."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.scc.manage.etd import clients
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.scc.manage import flags
from googlecloudsdk.command_lib.scc.manage import parsing
@base.ReleaseTracks(base.ReleaseTrack.GA, base.ReleaseTrack.ALPHA)
class ListDescendant(base.ListCommand):
"""List the details of the resident and descendant Event Threat Detection custom modules.
List the details of the resident and descendant Event Threat Detection
custom modules for a specified organization or folder. For a project, this
command lists only the custom modules that are created in the project.
Modules created in a parent organization or folder are excluded from the
list. To list the resident custom modules and the modules that are
inherited from a parent organization and folder, use gcloud scc manage
custom-modules etd list.
## EXAMPLES
To list resident and descendant Event Threat Detection custom modules for
organization `123`, run:
$ {command} --organization=organizations/123
To list resident and descendant Event Threat Detection custom modules for
folder `456`, run:
$ {command} --folder=folders/456
To list resident and descendant Event Threat Detection custom modules for
project `789`, run:
$ {command} --project=projects/789
"""
@staticmethod
def Args(parser):
base.URI_FLAG.RemoveFromParser(parser)
flags.CreateParentFlag(required=True).AddToParser(parser)
def Run(self, args):
parent = parsing.GetParentResourceNameFromArgs(args)
page_size = args.page_size
client = clients.ETDCustomModuleClient()
return client.ListDescendant(
page_size=page_size,
parent=parent,
limit=args.limit,
)

View File

@@ -0,0 +1,71 @@
# -*- 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 to list the details of an ETD effective custom module."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.scc.manage.etd import clients
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.scc.manage import flags
from googlecloudsdk.command_lib.scc.manage import parsing
@base.ReleaseTracks(base.ReleaseTrack.GA, base.ReleaseTrack.ALPHA)
class ListEffective(base.ListCommand):
"""List the details of an Event Threat Detection effective custom module.
List the details of resident and inherited Event Threat Detection custom
modules for the specified folder or project with their effective enablement
states. For an organization, this command lists only the custom modules
that are created at the organization level. Custom modules created in child
folders or projects are not included in the list.
## EXAMPLES
To list resident and inherited Event Threat Detection custom modules
with effective enablement states for organization 123, run:
$ {command} --organization=organizations/123
To list resident and inherited effective Event Threat Detection custom
modules with effective enablement states for folder 456, run:
$ {command} --folder=folders/456
To list resident and inherited effective Event Threat Detection custom
modules with effective enablement states for project 789, run:
$ {command} --project=projects/789
"""
@staticmethod
def Args(parser):
base.URI_FLAG.RemoveFromParser(parser)
flags.CreateParentFlag(required=True).AddToParser(parser)
def Run(self, args):
parent = parsing.GetParentResourceNameFromArgs(args)
page_size = args.page_size
limit = args.limit
client = clients.EffectiveETDCustomModuleClient()
return client.List(
page_size=page_size,
parent=parent,
limit=limit,
)

View File

@@ -0,0 +1,84 @@
# -*- 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 to update a ETD custom module."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.scc.manage.etd import clients
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.scc.manage import constants
from googlecloudsdk.command_lib.scc.manage import flags
from googlecloudsdk.command_lib.scc.manage import parsing
from googlecloudsdk.core.console import console_io
@base.ReleaseTracks(base.ReleaseTrack.GA, base.ReleaseTrack.ALPHA)
class Update(base.Command):
"""Update an Event Threat Detection custom module.
## EXAMPLES
To update an Event Threat Detection custom module with ID 123456 for
organization 123, run:
$ {command} 123456
--organization=organizations/123 --enablement-state="ENABLED"
--custom-config-file=custom_config.json
"""
@staticmethod
def Args(parser):
flags.CreateModuleIdOrNameArg(
module_type=constants.CustomModuleType.ETD
).AddToParser(parser)
flags.CreateParentFlag(required=False).AddToParser(parser)
flags.CreateValidateOnlyFlag(required=False).AddToParser(parser)
flags.CreateUpdateFlags(
required=True,
module_type=constants.CustomModuleType.ETD,
file_type='JSON',
).AddToParser(parser)
def Run(self, args):
name = parsing.GetModuleNameFromArgs(
args, module_type=constants.CustomModuleType.ETD
)
validate_only = args.validate_only
custom_config = parsing.GetConfigValueFromArgs(args.custom_config_file)
enablement_state = parsing.GetEnablementStateFromArgs(
args.enablement_state, module_type=constants.CustomModuleType.ETD
)
update_mask = parsing.CreateUpdateMaskFromArgs(args)
if not validate_only:
console_io.PromptContinue(
message=(
'Are you sure you want to update the Event Threat Detection'
' custom module {}?\n'.format(name)
),
cancel_on_no=True,
)
client = clients.ETDCustomModuleClient()
return client.Update(
name=name,
validate_only=validate_only,
custom_config=custom_config,
enablement_state=enablement_state,
update_mask=update_mask,
)

View File

@@ -0,0 +1,64 @@
# -*- 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 to validate an ETD custom module."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.scc.manage.etd import clients
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.scc.manage import flags
from googlecloudsdk.command_lib.scc.manage import parsing
@base.ReleaseTracks(base.ReleaseTrack.GA, base.ReleaseTrack.ALPHA)
class Validate(base.Command):
"""Command to validate an ETD custom module.
## EXAMPLES
To validate an Event Threat Detection custom module 'config.json' with a
module type 'CONFIGURABLE_BAD_IP', run:
$ {command}
--organization=organizations/252600681248
--custom-config-file=config.json
--module-type=CONFIGURABLE_BAD_IP
You can also specify the parent more generally:
$ {command}
--parent=organizations/252600681248
--custom-config-file=config.json
--module-type=CONFIGURABLE_BAD_IP
"""
@staticmethod
def Args(parser):
flags.CreateParentFlag(required=True).AddToParser(parser)
flags.CreateEtdCustomConfigFilePathFlag(required=True).AddToParser(parser)
flags.CreateModuleTypeFlag(required=True).AddToParser(parser)
def Run(self, args):
parent = parsing.GetParentResourceNameFromArgs(args)
custom_config = parsing.ParseJSONFile(args.custom_config_file)
module_type = args.module_type
client = clients.ETDCustomModuleClient()
return client.Validate(
parent=parent, custom_config_json=custom_config, module_type=module_type
)