|
37 | 37 | from google.api_core import operation # type: ignore
|
38 | 38 | from google.api_core import operation_async # type: ignore
|
39 | 39 | from google.cloud.securitycenter_v1.services.security_center import pagers
|
| 40 | +from google.cloud.securitycenter_v1.types import external_system as gcs_external_system |
40 | 41 | from google.cloud.securitycenter_v1.types import finding
|
41 | 42 | from google.cloud.securitycenter_v1.types import finding as gcs_finding
|
42 | 43 | from google.cloud.securitycenter_v1.types import indicator
|
@@ -200,6 +201,27 @@ def parse_asset_path(path: str) -> Dict[str, str]:
|
200 | 201 | )
|
201 | 202 | return m.groupdict() if m else {}
|
202 | 203 |
|
| 204 | + @staticmethod |
| 205 | + def external_system_path( |
| 206 | + organization: str, source: str, finding: str, externalsystem: str, |
| 207 | + ) -> str: |
| 208 | + """Returns a fully-qualified external_system string.""" |
| 209 | + return "organizations/{organization}/sources/{source}/findings/{finding}/externalSystems/{externalsystem}".format( |
| 210 | + organization=organization, |
| 211 | + source=source, |
| 212 | + finding=finding, |
| 213 | + externalsystem=externalsystem, |
| 214 | + ) |
| 215 | + |
| 216 | + @staticmethod |
| 217 | + def parse_external_system_path(path: str) -> Dict[str, str]: |
| 218 | + """Parses a external_system path into its component segments.""" |
| 219 | + m = re.match( |
| 220 | + r"^organizations/(?P<organization>.+?)/sources/(?P<source>.+?)/findings/(?P<finding>.+?)/externalSystems/(?P<externalsystem>.+?)$", |
| 221 | + path, |
| 222 | + ) |
| 223 | + return m.groupdict() if m else {} |
| 224 | + |
203 | 225 | @staticmethod
|
204 | 226 | def finding_path(organization: str, source: str, finding: str,) -> str:
|
205 | 227 | """Returns a fully-qualified finding string."""
|
@@ -2584,6 +2606,91 @@ def test_iam_permissions(
|
2584 | 2606 | # Done; return the response.
|
2585 | 2607 | return response
|
2586 | 2608 |
|
| 2609 | + def update_external_system( |
| 2610 | + self, |
| 2611 | + request: Union[securitycenter_service.UpdateExternalSystemRequest, dict] = None, |
| 2612 | + *, |
| 2613 | + external_system: gcs_external_system.ExternalSystem = None, |
| 2614 | + update_mask: field_mask_pb2.FieldMask = None, |
| 2615 | + retry: OptionalRetry = gapic_v1.method.DEFAULT, |
| 2616 | + timeout: float = None, |
| 2617 | + metadata: Sequence[Tuple[str, str]] = (), |
| 2618 | + ) -> gcs_external_system.ExternalSystem: |
| 2619 | + r"""Updates external system. This is for a given finding. |
| 2620 | +
|
| 2621 | + Args: |
| 2622 | + request (Union[google.cloud.securitycenter_v1.types.UpdateExternalSystemRequest, dict]): |
| 2623 | + The request object. Request message for updating a |
| 2624 | + ExternalSystem resource. |
| 2625 | + external_system (google.cloud.securitycenter_v1.types.ExternalSystem): |
| 2626 | + Required. The external system |
| 2627 | + resource to update. |
| 2628 | +
|
| 2629 | + This corresponds to the ``external_system`` field |
| 2630 | + on the ``request`` instance; if ``request`` is provided, this |
| 2631 | + should not be set. |
| 2632 | + update_mask (google.protobuf.field_mask_pb2.FieldMask): |
| 2633 | + The FieldMask to use when updating |
| 2634 | + the external system resource. |
| 2635 | + If empty all mutable fields will be |
| 2636 | + updated. |
| 2637 | +
|
| 2638 | + This corresponds to the ``update_mask`` field |
| 2639 | + on the ``request`` instance; if ``request`` is provided, this |
| 2640 | + should not be set. |
| 2641 | + retry (google.api_core.retry.Retry): Designation of what errors, if any, |
| 2642 | + should be retried. |
| 2643 | + timeout (float): The timeout for this request. |
| 2644 | + metadata (Sequence[Tuple[str, str]]): Strings which should be |
| 2645 | + sent along with the request as metadata. |
| 2646 | +
|
| 2647 | + Returns: |
| 2648 | + google.cloud.securitycenter_v1.types.ExternalSystem: |
| 2649 | + Representation of third party |
| 2650 | + SIEM/SOAR fields within SCC. |
| 2651 | +
|
| 2652 | + """ |
| 2653 | + # Create or coerce a protobuf request object. |
| 2654 | + # Sanity check: If we got a request object, we should *not* have |
| 2655 | + # gotten any keyword arguments that map to the request. |
| 2656 | + has_flattened_params = any([external_system, update_mask]) |
| 2657 | + if request is not None and has_flattened_params: |
| 2658 | + raise ValueError( |
| 2659 | + "If the `request` argument is set, then none of " |
| 2660 | + "the individual field arguments should be set." |
| 2661 | + ) |
| 2662 | + |
| 2663 | + # Minor optimization to avoid making a copy if the user passes |
| 2664 | + # in a securitycenter_service.UpdateExternalSystemRequest. |
| 2665 | + # There's no risk of modifying the input as we've already verified |
| 2666 | + # there are no flattened fields. |
| 2667 | + if not isinstance(request, securitycenter_service.UpdateExternalSystemRequest): |
| 2668 | + request = securitycenter_service.UpdateExternalSystemRequest(request) |
| 2669 | + # If we have keyword arguments corresponding to fields on the |
| 2670 | + # request, apply these. |
| 2671 | + if external_system is not None: |
| 2672 | + request.external_system = external_system |
| 2673 | + if update_mask is not None: |
| 2674 | + request.update_mask = update_mask |
| 2675 | + |
| 2676 | + # Wrap the RPC method; this adds retry and timeout information, |
| 2677 | + # and friendly error handling. |
| 2678 | + rpc = self._transport._wrapped_methods[self._transport.update_external_system] |
| 2679 | + |
| 2680 | + # Certain fields should be provided within the metadata header; |
| 2681 | + # add these here. |
| 2682 | + metadata = tuple(metadata) + ( |
| 2683 | + gapic_v1.routing_header.to_grpc_metadata( |
| 2684 | + (("external_system.name", request.external_system.name),) |
| 2685 | + ), |
| 2686 | + ) |
| 2687 | + |
| 2688 | + # Send the request. |
| 2689 | + response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) |
| 2690 | + |
| 2691 | + # Done; return the response. |
| 2692 | + return response |
| 2693 | + |
2587 | 2694 | def update_finding(
|
2588 | 2695 | self,
|
2589 | 2696 | request: Union[securitycenter_service.UpdateFindingRequest, dict] = None,
|
|
0 commit comments