Skip to content

Commit

Permalink
feat: Added resource type and display_name field to the FindingResult (
Browse files Browse the repository at this point in the history
…#248)

...and supported them in the filter for ListFindings and GroupFindings. 

- [ ] Regenerate this pull request now.

PiperOrigin-RevId: 408362247

Source-Link: googleapis/googleapis@4d71c45

Source-Link: googleapis/googleapis-gen@058c449
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMDU4YzQ0OTg5ZGRiYTk1M2FhMWNjNjc0ODY2MjQyYTg2NzdmZTMzYSJ9

docs: list oneofs in docstring
fix(deps): require google-api-core >= 1.28.0
fix(deps): drop packaging dependency
feat: add display_name to the resource which is surfaced in NotificationMessage
  • Loading branch information
gcf-owl-bot[bot] authored Nov 9, 2021
1 parent 49bf50f commit 8fab653
Show file tree
Hide file tree
Showing 26 changed files with 368 additions and 624 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
from google.auth.exceptions import MutualTLSChannelError # type: ignore
from google.oauth2 import service_account # type: ignore

OptionalRetry = Union[retries.Retry, object]

from google.api_core import operation # type: ignore
from google.api_core import operation_async # type: ignore
from google.cloud.securitycenter_v1.services.security_center import pagers
Expand Down Expand Up @@ -465,7 +467,7 @@ def create_source(
*,
parent: str = None,
source: gcs_source.Source = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> gcs_source.Source:
Expand Down Expand Up @@ -552,7 +554,7 @@ def create_finding(
parent: str = None,
finding_id: str = None,
finding: gcs_finding.Finding = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> gcs_finding.Finding:
Expand Down Expand Up @@ -658,7 +660,7 @@ def create_notification_config(
parent: str = None,
config_id: str = None,
notification_config: gcs_notification_config.NotificationConfig = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> gcs_notification_config.NotificationConfig:
Expand Down Expand Up @@ -763,7 +765,7 @@ def delete_notification_config(
] = None,
*,
name: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> None:
Expand Down Expand Up @@ -832,7 +834,7 @@ def get_iam_policy(
request: Union[iam_policy_pb2.GetIamPolicyRequest, dict] = None,
*,
resource: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> policy_pb2.Policy:
Expand Down Expand Up @@ -960,7 +962,7 @@ def get_notification_config(
] = None,
*,
name: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> notification_config.NotificationConfig:
Expand Down Expand Up @@ -1038,7 +1040,7 @@ def get_organization_settings(
] = None,
*,
name: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> organization_settings.OrganizationSettings:
Expand Down Expand Up @@ -1115,7 +1117,7 @@ def get_source(
request: Union[securitycenter_service.GetSourceRequest, dict] = None,
*,
name: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> source.Source:
Expand Down Expand Up @@ -1190,7 +1192,7 @@ def group_assets(
self,
request: Union[securitycenter_service.GroupAssetsRequest, dict] = None,
*,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> pagers.GroupAssetsPager:
Expand Down Expand Up @@ -1252,7 +1254,7 @@ def group_findings(
*,
parent: str = None,
group_by: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> pagers.GroupFindingsPager:
Expand Down Expand Up @@ -1367,7 +1369,7 @@ def list_assets(
self,
request: Union[securitycenter_service.ListAssetsRequest, dict] = None,
*,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> pagers.ListAssetsPager:
Expand Down Expand Up @@ -1424,7 +1426,7 @@ def list_findings(
self,
request: Union[securitycenter_service.ListFindingsRequest, dict] = None,
*,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> pagers.ListFindingsPager:
Expand Down Expand Up @@ -1489,7 +1491,7 @@ def list_notification_configs(
] = None,
*,
parent: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> pagers.ListNotificationConfigsPager:
Expand Down Expand Up @@ -1574,7 +1576,7 @@ def list_sources(
request: Union[securitycenter_service.ListSourcesRequest, dict] = None,
*,
parent: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> pagers.ListSourcesPager:
Expand Down Expand Up @@ -1654,7 +1656,7 @@ def run_asset_discovery(
request: Union[securitycenter_service.RunAssetDiscoveryRequest, dict] = None,
*,
parent: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation.Operation:
Expand Down Expand Up @@ -1744,7 +1746,7 @@ def set_finding_state(
name: str = None,
state: finding.Finding.State = None,
start_time: timestamp_pb2.Timestamp = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> finding.Finding:
Expand Down Expand Up @@ -1843,7 +1845,7 @@ def set_iam_policy(
request: Union[iam_policy_pb2.SetIamPolicyRequest, dict] = None,
*,
resource: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> policy_pb2.Policy:
Expand Down Expand Up @@ -1970,7 +1972,7 @@ def test_iam_permissions(
*,
resource: str = None,
permissions: Sequence[str] = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> iam_policy_pb2.TestIamPermissionsResponse:
Expand Down Expand Up @@ -2052,7 +2054,7 @@ def update_finding(
request: Union[securitycenter_service.UpdateFindingRequest, dict] = None,
*,
finding: gcs_finding.Finding = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> gcs_finding.Finding:
Expand Down Expand Up @@ -2141,7 +2143,7 @@ def update_notification_config(
*,
notification_config: gcs_notification_config.NotificationConfig = None,
update_mask: field_mask_pb2.FieldMask = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> gcs_notification_config.NotificationConfig:
Expand Down Expand Up @@ -2236,7 +2238,7 @@ def update_organization_settings(
] = None,
*,
organization_settings: gcs_organization_settings.OrganizationSettings = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> gcs_organization_settings.OrganizationSettings:
Expand Down Expand Up @@ -2314,7 +2316,7 @@ def update_source(
request: Union[securitycenter_service.UpdateSourceRequest, dict] = None,
*,
source: gcs_source.Source = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> gcs_source.Source:
Expand Down Expand Up @@ -2391,7 +2393,7 @@ def update_security_marks(
request: Union[securitycenter_service.UpdateSecurityMarksRequest, dict] = None,
*,
security_marks: gcs_security_marks.SecurityMarks = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> gcs_security_marks.SecurityMarks:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#
import abc
from typing import Awaitable, Callable, Dict, Optional, Sequence, Union
import packaging.version
import pkg_resources

import google.auth # type: ignore
Expand Down Expand Up @@ -55,15 +54,6 @@
except pkg_resources.DistributionNotFound:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()

try:
# google.auth.__version__ was added in 1.26.0
_GOOGLE_AUTH_VERSION = google.auth.__version__
except AttributeError:
try: # try pkg_resources if it is available
_GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version
except pkg_resources.DistributionNotFound: # pragma: NO COVER
_GOOGLE_AUTH_VERSION = None


class SecurityCenterTransport(abc.ABC):
"""Abstract transport class for SecurityCenter."""
Expand Down Expand Up @@ -113,7 +103,7 @@ def __init__(
host += ":443"
self._host = host

scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)
scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES}

# Save the scopes.
self._scopes = scopes
Expand Down Expand Up @@ -146,29 +136,6 @@ def __init__(
# Save the credentials.
self._credentials = credentials

# TODO(busunkim): This method is in the base transport
# to avoid duplicating code across the transport classes. These functions
# should be deleted once the minimum required versions of google-auth is increased.

# TODO: Remove this function once google-auth >= 1.25.0 is required
@classmethod
def _get_scopes_kwargs(
cls, host: str, scopes: Optional[Sequence[str]]
) -> Dict[str, Optional[Sequence[str]]]:
"""Returns scopes kwargs to pass to google-auth methods depending on the google-auth version"""

scopes_kwargs = {}

if _GOOGLE_AUTH_VERSION and (
packaging.version.parse(_GOOGLE_AUTH_VERSION)
>= packaging.version.parse("1.25.0")
):
scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES}
else:
scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES}

return scopes_kwargs

def _prep_wrapped_messages(self, client_info):
# Precompute the wrapped methods.
self._wrapped_methods = {
Expand Down Expand Up @@ -395,7 +362,7 @@ def close(self):
raise NotImplementedError()

@property
def operations_client(self) -> operations_v1.OperationsClient:
def operations_client(self):
"""Return the client designed to process long-running operations."""
raise NotImplementedError()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def __init__(
self._grpc_channel = None
self._ssl_channel_credentials = ssl_channel_credentials
self._stubs: Dict[str, Callable] = {}
self._operations_client = None
self._operations_client: Optional[operations_v1.OperationsClient] = None

if api_mtls_endpoint:
warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from google.api_core import operations_v1 # type: ignore
from google.auth import credentials as ga_credentials # type: ignore
from google.auth.transport.grpc import SslCredentials # type: ignore
import packaging.version

import grpc # type: ignore
from grpc.experimental import aio # type: ignore
Expand Down Expand Up @@ -175,7 +174,7 @@ def __init__(
self._grpc_channel = None
self._ssl_channel_credentials = ssl_channel_credentials
self._stubs: Dict[str, Callable] = {}
self._operations_client = None
self._operations_client: Optional[operations_v1.OperationsAsyncClient] = None

if api_mtls_endpoint:
warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ class NotificationConfig(proto.Message):
configuration to send notifications for create/update events of
findings, assets and etc.
.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
Attributes:
name (str):
The relative resource name of this notification config. See:
Expand All @@ -47,6 +50,7 @@ class NotificationConfig(proto.Message):
streaming_config (google.cloud.securitycenter_v1.types.NotificationConfig.StreamingConfig):
The config for triggering streaming-based
notifications.
This field is a member of `oneof`_ ``notify_config``.
"""

class StreamingConfig(proto.Message):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,16 @@
class NotificationMessage(proto.Message):
r"""Cloud SCC's Notification
.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
Attributes:
notification_config_name (str):
Name of the notification config that
generated current notification.
finding (google.cloud.securitycenter_v1.types.Finding):
If it's a Finding based notification config,
this field will be populated.
This field is a member of `oneof`_ ``event``.
resource (google.cloud.securitycenter_v1.types.Resource):
The Cloud resource tied to this
notification's Finding.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ class Resource(proto.Message):
folder is the deepest nested folder, and the
last folder is the folder directly under the
Organization.
display_name (str):
The human readable name of the resource.
"""

name = proto.Field(proto.STRING, number=1,)
Expand All @@ -57,6 +59,7 @@ class Resource(proto.Message):
parent_display_name = proto.Field(proto.STRING, number=5,)
type_ = proto.Field(proto.STRING, number=6,)
folders = proto.RepeatedField(proto.MESSAGE, number=7, message=folder.Folder,)
display_name = proto.Field(proto.STRING, number=8,)


__all__ = tuple(sorted(__protobuf__.manifest))
Loading

0 comments on commit 8fab653

Please sign in to comment.