Skip to content

Commit

Permalink
feat: Add SimulateSecurityHealthAnalyticsCustomModule API for testing…
Browse files Browse the repository at this point in the history
… SHA custom module (#11854)

- [ ] Regenerate this pull request now.

PiperOrigin-RevId: 574612611

Source-Link:
googleapis/googleapis@c768e7a

Source-Link:
googleapis/googleapis-gen@e5502fc
Copy-Tag:
eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXNlY3VyaXR5Y2VudGVyLy5Pd2xCb3QueWFtbCIsImgiOiJlNTUwMmZjMTdlY2VhY2ExYzIzNTJmZDJhNjE0Yzc2ZWM2M2VmOGU0In0=

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Victor Chudnovsky <[email protected]>
  • Loading branch information
3 people authored Oct 24, 2023
1 parent 2d1eb36 commit 6055a99
Show file tree
Hide file tree
Showing 23 changed files with 1,682 additions and 10 deletions.
12 changes: 6 additions & 6 deletions packages/google-cloud-securitycenter/docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,24 @@ API Reference
.. toctree::
:maxdepth: 2

securitycenter_v1/services
securitycenter_v1/types
securitycenter_v1/services_
securitycenter_v1/types_

API Reference
-------------
.. toctree::
:maxdepth: 2

securitycenter_v1beta1/services
securitycenter_v1beta1/types
securitycenter_v1beta1/services_
securitycenter_v1beta1/types_

API Reference
-------------
.. toctree::
:maxdepth: 2

securitycenter_v1p1beta1/services
securitycenter_v1p1beta1/types
securitycenter_v1p1beta1/services_
securitycenter_v1p1beta1/types_


Changelog
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Services for Google Cloud Securitycenter v1p1beta1 API
======================================================
.. toctree::
:maxdepth: 2

security_center
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Types for Google Cloud Securitycenter v1p1beta1 API
===================================================

.. automodule:: google.cloud.securitycenter_v1p1beta1.types
:members:
:show-inheritance:
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@
RunAssetDiscoveryRequest,
SetFindingStateRequest,
SetMuteRequest,
SimulateSecurityHealthAnalyticsCustomModuleRequest,
SimulateSecurityHealthAnalyticsCustomModuleResponse,
UpdateBigQueryExportRequest,
UpdateExternalSystemRequest,
UpdateFindingRequest,
Expand Down Expand Up @@ -226,6 +228,8 @@
"RunAssetDiscoveryRequest",
"SetFindingStateRequest",
"SetMuteRequest",
"SimulateSecurityHealthAnalyticsCustomModuleRequest",
"SimulateSecurityHealthAnalyticsCustomModuleResponse",
"UpdateBigQueryExportRequest",
"UpdateExternalSystemRequest",
"UpdateFindingRequest",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@
RunAssetDiscoveryRequest,
SetFindingStateRequest,
SetMuteRequest,
SimulateSecurityHealthAnalyticsCustomModuleRequest,
SimulateSecurityHealthAnalyticsCustomModuleResponse,
UpdateBigQueryExportRequest,
UpdateExternalSystemRequest,
UpdateFindingRequest,
Expand Down Expand Up @@ -202,6 +204,8 @@
"ServiceAccountDelegationInfo",
"SetFindingStateRequest",
"SetMuteRequest",
"SimulateSecurityHealthAnalyticsCustomModuleRequest",
"SimulateSecurityHealthAnalyticsCustomModuleResponse",
"Source",
"UpdateBigQueryExportRequest",
"UpdateExternalSystemRequest",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,11 @@
"set_mute"
]
},
"SimulateSecurityHealthAnalyticsCustomModule": {
"methods": [
"simulate_security_health_analytics_custom_module"
]
},
"TestIamPermissions": {
"methods": [
"test_iam_permissions"
Expand Down Expand Up @@ -405,6 +410,11 @@
"set_mute"
]
},
"SimulateSecurityHealthAnalyticsCustomModule": {
"methods": [
"simulate_security_health_analytics_custom_module"
]
},
"TestIamPermissions": {
"methods": [
"test_iam_permissions"
Expand Down Expand Up @@ -630,6 +640,11 @@
"set_mute"
]
},
"SimulateSecurityHealthAnalyticsCustomModule": {
"methods": [
"simulate_security_health_analytics_custom_module"
]
},
"TestIamPermissions": {
"methods": [
"test_iam_permissions"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4355,6 +4355,151 @@ async def sample_test_iam_permissions():
# Done; return the response.
return response

async def simulate_security_health_analytics_custom_module(
self,
request: Optional[
Union[
securitycenter_service.SimulateSecurityHealthAnalyticsCustomModuleRequest,
dict,
]
] = None,
*,
parent: Optional[str] = None,
custom_config: Optional[
security_health_analytics_custom_config.CustomConfig
] = None,
resource: Optional[
securitycenter_service.SimulateSecurityHealthAnalyticsCustomModuleRequest.SimulatedResource
] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> securitycenter_service.SimulateSecurityHealthAnalyticsCustomModuleResponse:
r"""Simulates a given SecurityHealthAnalyticsCustomModule
and Resource.
.. code-block:: python
# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in:
# https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import securitycenter_v1
async def sample_simulate_security_health_analytics_custom_module():
# Create a client
client = securitycenter_v1.SecurityCenterAsyncClient()
# Initialize request argument(s)
resource = securitycenter_v1.SimulatedResource()
resource.resource_type = "resource_type_value"
request = securitycenter_v1.SimulateSecurityHealthAnalyticsCustomModuleRequest(
parent="parent_value",
resource=resource,
)
# Make the request
response = await client.simulate_security_health_analytics_custom_module(request=request)
# Handle the response
print(response)
Args:
request (Optional[Union[google.cloud.securitycenter_v1.types.SimulateSecurityHealthAnalyticsCustomModuleRequest, dict]]):
The request object. Request message to simulate a
CustomConfig against a given test
resource. Maximum size of the request is
4 MB by default.
parent (:class:`str`):
Required. The relative resource name of the
organization, project, or folder. See:
https://cloud.google.com/apis/design/resource_names#relative_resource_name
An example is: "organizations/{organization_id}".
This corresponds to the ``parent`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
custom_config (:class:`google.cloud.securitycenter_v1.types.CustomConfig`):
Required. The user specified custom
configuration to test.
This corresponds to the ``custom_config`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
resource (:class:`google.cloud.securitycenter_v1.types.SimulateSecurityHealthAnalyticsCustomModuleRequest.SimulatedResource`):
Required. Resource data to simulate
custom module against.
This corresponds to the ``resource`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
google.cloud.securitycenter_v1.types.SimulateSecurityHealthAnalyticsCustomModuleResponse:
Response message for simulating a
SecurityHealthAnalyticsCustomModule
against a given resource.
"""
# Create or coerce a protobuf request object.
# Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([parent, custom_config, resource])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)

request = (
securitycenter_service.SimulateSecurityHealthAnalyticsCustomModuleRequest(
request
)
)

# If we have keyword arguments corresponding to fields on the
# request, apply these.
if parent is not None:
request.parent = parent
if custom_config is not None:
request.custom_config = custom_config
if resource is not None:
request.resource = resource

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.simulate_security_health_analytics_custom_module,
default_timeout=None,
client_info=DEFAULT_CLIENT_INFO,
)

# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
)

# Send the request.
response = await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)

# Done; return the response.
return response

async def update_external_system(
self,
request: Optional[
Expand Down
Loading

0 comments on commit 6055a99

Please sign in to comment.