diff --git a/google/cloud/websecurityscanner_v1/services/web_security_scanner/async_client.py b/google/cloud/websecurityscanner_v1/services/web_security_scanner/async_client.py index a877e7f..3a6f8dd 100644 --- a/google/cloud/websecurityscanner_v1/services/web_security_scanner/async_client.py +++ b/google/cloud/websecurityscanner_v1/services/web_security_scanner/async_client.py @@ -932,6 +932,12 @@ async def list_finding_type_stats( # Done; return the response. return response + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc, tb): + await self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/websecurityscanner_v1/services/web_security_scanner/client.py b/google/cloud/websecurityscanner_v1/services/web_security_scanner/client.py index 4bb4719..48a7e6e 100644 --- a/google/cloud/websecurityscanner_v1/services/web_security_scanner/client.py +++ b/google/cloud/websecurityscanner_v1/services/web_security_scanner/client.py @@ -364,10 +364,7 @@ def __init__( client_cert_source_for_mtls=client_cert_source_func, quota_project_id=client_options.quota_project_id, client_info=client_info, - always_use_jwt_access=( - Transport == type(self).get_transport_class("grpc") - or Transport == type(self).get_transport_class("grpc_asyncio") - ), + always_use_jwt_access=True, ) def create_scan_config( @@ -1050,6 +1047,19 @@ def list_finding_type_stats( # Done; return the response. return response + def __enter__(self): + return self + + def __exit__(self, type, value, traceback): + """Releases underlying transport's resources. + + .. warning:: + ONLY use as a context manager if the transport is NOT shared + with other clients! Exiting the with block will CLOSE the transport + and may cause errors in other clients! + """ + self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/websecurityscanner_v1/services/web_security_scanner/transports/base.py b/google/cloud/websecurityscanner_v1/services/web_security_scanner/transports/base.py index 13530f8..2b93700 100644 --- a/google/cloud/websecurityscanner_v1/services/web_security_scanner/transports/base.py +++ b/google/cloud/websecurityscanner_v1/services/web_security_scanner/transports/base.py @@ -307,6 +307,15 @@ def _prep_wrapped_messages(self, client_info): ), } + def close(self): + """Closes resources associated with the transport. + + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! + """ + raise NotImplementedError() + @property def create_scan_config( self, diff --git a/google/cloud/websecurityscanner_v1/services/web_security_scanner/transports/grpc.py b/google/cloud/websecurityscanner_v1/services/web_security_scanner/transports/grpc.py index b8767c3..88d3592 100644 --- a/google/cloud/websecurityscanner_v1/services/web_security_scanner/transports/grpc.py +++ b/google/cloud/websecurityscanner_v1/services/web_security_scanner/transports/grpc.py @@ -592,5 +592,8 @@ def list_finding_type_stats( ) return self._stubs["list_finding_type_stats"] + def close(self): + self.grpc_channel.close() + __all__ = ("WebSecurityScannerGrpcTransport",) diff --git a/google/cloud/websecurityscanner_v1/services/web_security_scanner/transports/grpc_asyncio.py b/google/cloud/websecurityscanner_v1/services/web_security_scanner/transports/grpc_asyncio.py index 6de2096..e668731 100644 --- a/google/cloud/websecurityscanner_v1/services/web_security_scanner/transports/grpc_asyncio.py +++ b/google/cloud/websecurityscanner_v1/services/web_security_scanner/transports/grpc_asyncio.py @@ -607,5 +607,8 @@ def list_finding_type_stats( ) return self._stubs["list_finding_type_stats"] + def close(self): + return self.grpc_channel.close() + __all__ = ("WebSecurityScannerGrpcAsyncIOTransport",) diff --git a/google/cloud/websecurityscanner_v1/types/finding_addon.py b/google/cloud/websecurityscanner_v1/types/finding_addon.py index 9fddb89..af58e84 100644 --- a/google/cloud/websecurityscanner_v1/types/finding_addon.py +++ b/google/cloud/websecurityscanner_v1/types/finding_addon.py @@ -31,6 +31,7 @@ class Form(proto.Message): r"""! Information about a vulnerability with an HTML. + Attributes: action_uri (str): ! The URI where to send the form when it's @@ -46,6 +47,7 @@ class Form(proto.Message): class OutdatedLibrary(proto.Message): r"""Information reported for an outdated library. + Attributes: library_name (str): The name of the outdated library. @@ -78,6 +80,7 @@ class ViolatingResource(proto.Message): class VulnerableParameters(proto.Message): r"""Information about vulnerable request parameters. + Attributes: parameter_names (Sequence[str]): The vulnerable parameter names. @@ -88,6 +91,7 @@ class VulnerableParameters(proto.Message): class VulnerableHeaders(proto.Message): r"""Information about vulnerable or missing HTTP Headers. + Attributes: headers (Sequence[google.cloud.websecurityscanner_v1.types.VulnerableHeaders.Header]): List of vulnerable headers. @@ -97,6 +101,7 @@ class VulnerableHeaders(proto.Message): class Header(proto.Message): r"""Describes a HTTP Header. + Attributes: name (str): Header name. @@ -113,6 +118,7 @@ class Header(proto.Message): class Xss(proto.Message): r"""Information reported for an XSS. + Attributes: stack_traces (Sequence[str]): Stack traces leading to the point where the diff --git a/google/cloud/websecurityscanner_v1/types/scan_config.py b/google/cloud/websecurityscanner_v1/types/scan_config.py index b8b5154..9cbdc2b 100644 --- a/google/cloud/websecurityscanner_v1/types/scan_config.py +++ b/google/cloud/websecurityscanner_v1/types/scan_config.py @@ -97,6 +97,7 @@ class ExportToSecurityCommandCenter(proto.Enum): class Authentication(proto.Message): r"""Scan authentication configuration. + Attributes: google_account (google.cloud.websecurityscanner_v1.types.ScanConfig.Authentication.GoogleAccount): Authentication using a Google account. @@ -199,6 +200,7 @@ class IapTestServiceAccountInfo(proto.Message): class Schedule(proto.Message): r"""Scan schedule configuration. + Attributes: schedule_time (google.protobuf.timestamp_pb2.Timestamp): A timestamp indicates when the next run will diff --git a/google/cloud/websecurityscanner_v1/types/web_security_scanner.py b/google/cloud/websecurityscanner_v1/types/web_security_scanner.py index be87be7..4bee64f 100644 --- a/google/cloud/websecurityscanner_v1/types/web_security_scanner.py +++ b/google/cloud/websecurityscanner_v1/types/web_security_scanner.py @@ -52,6 +52,7 @@ class CreateScanConfigRequest(proto.Message): r"""Request for the ``CreateScanConfig`` method. + Attributes: parent (str): Required. The parent resource name where the @@ -70,6 +71,7 @@ class CreateScanConfigRequest(proto.Message): class DeleteScanConfigRequest(proto.Message): r"""Request for the ``DeleteScanConfig`` method. + Attributes: name (str): Required. The resource name of the ScanConfig @@ -82,6 +84,7 @@ class DeleteScanConfigRequest(proto.Message): class GetScanConfigRequest(proto.Message): r"""Request for the ``GetScanConfig`` method. + Attributes: name (str): Required. The resource name of the ScanConfig @@ -94,6 +97,7 @@ class GetScanConfigRequest(proto.Message): class ListScanConfigsRequest(proto.Message): r"""Request for the ``ListScanConfigs`` method. + Attributes: parent (str): Required. The parent resource name, which @@ -118,6 +122,7 @@ class ListScanConfigsRequest(proto.Message): class UpdateScanConfigRequest(proto.Message): r"""Request for the ``UpdateScanConfigRequest`` method. + Attributes: scan_config (google.cloud.websecurityscanner_v1.types.ScanConfig): Required. The ScanConfig to be updated. The @@ -140,6 +145,7 @@ class UpdateScanConfigRequest(proto.Message): class ListScanConfigsResponse(proto.Message): r"""Response for the ``ListScanConfigs`` method. + Attributes: scan_configs (Sequence[google.cloud.websecurityscanner_v1.types.ScanConfig]): The list of ScanConfigs returned. @@ -161,6 +167,7 @@ def raw_page(self): class StartScanRunRequest(proto.Message): r"""Request for the ``StartScanRun`` method. + Attributes: name (str): Required. The resource name of the ScanConfig @@ -173,6 +180,7 @@ class StartScanRunRequest(proto.Message): class GetScanRunRequest(proto.Message): r"""Request for the ``GetScanRun`` method. + Attributes: name (str): Required. The resource name of the ScanRun to @@ -185,6 +193,7 @@ class GetScanRunRequest(proto.Message): class ListScanRunsRequest(proto.Message): r"""Request for the ``ListScanRuns`` method. + Attributes: parent (str): Required. The parent resource name, which @@ -209,6 +218,7 @@ class ListScanRunsRequest(proto.Message): class ListScanRunsResponse(proto.Message): r"""Response for the ``ListScanRuns`` method. + Attributes: scan_runs (Sequence[google.cloud.websecurityscanner_v1.types.ScanRun]): The list of ScanRuns returned. @@ -228,6 +238,7 @@ def raw_page(self): class StopScanRunRequest(proto.Message): r"""Request for the ``StopScanRun`` method. + Attributes: name (str): Required. The resource name of the ScanRun to @@ -240,6 +251,7 @@ class StopScanRunRequest(proto.Message): class ListCrawledUrlsRequest(proto.Message): r"""Request for the ``ListCrawledUrls`` method. + Attributes: parent (str): Required. The parent resource name, which @@ -264,6 +276,7 @@ class ListCrawledUrlsRequest(proto.Message): class ListCrawledUrlsResponse(proto.Message): r"""Response for the ``ListCrawledUrls`` method. + Attributes: crawled_urls (Sequence[google.cloud.websecurityscanner_v1.types.CrawledUrl]): The list of CrawledUrls returned. @@ -285,6 +298,7 @@ def raw_page(self): class GetFindingRequest(proto.Message): r"""Request for the ``GetFinding`` method. + Attributes: name (str): Required. The resource name of the Finding to @@ -297,6 +311,7 @@ class GetFindingRequest(proto.Message): class ListFindingsRequest(proto.Message): r"""Request for the ``ListFindings`` method. + Attributes: parent (str): Required. The parent resource name, which @@ -325,6 +340,7 @@ class ListFindingsRequest(proto.Message): class ListFindingsResponse(proto.Message): r"""Response for the ``ListFindings`` method. + Attributes: findings (Sequence[google.cloud.websecurityscanner_v1.types.Finding]): The list of Findings returned. @@ -344,6 +360,7 @@ def raw_page(self): class ListFindingTypeStatsRequest(proto.Message): r"""Request for the ``ListFindingTypeStats`` method. + Attributes: parent (str): Required. The parent resource name, which @@ -356,6 +373,7 @@ class ListFindingTypeStatsRequest(proto.Message): class ListFindingTypeStatsResponse(proto.Message): r"""Response for the ``ListFindingTypeStats`` method. + Attributes: finding_type_stats (Sequence[google.cloud.websecurityscanner_v1.types.FindingTypeStats]): The list of FindingTypeStats returned. diff --git a/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/async_client.py b/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/async_client.py index f333926..c583dee 100644 --- a/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/async_client.py +++ b/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/async_client.py @@ -1282,6 +1282,12 @@ async def list_finding_type_stats( # Done; return the response. return response + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc, tb): + await self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/client.py b/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/client.py index d8c650f..c9e29b0 100644 --- a/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/client.py +++ b/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/client.py @@ -395,10 +395,7 @@ def __init__( client_cert_source_for_mtls=client_cert_source_func, quota_project_id=client_options.quota_project_id, client_info=client_info, - always_use_jwt_access=( - Transport == type(self).get_transport_class("grpc") - or Transport == type(self).get_transport_class("grpc_asyncio") - ), + always_use_jwt_access=True, ) def create_scan_config( @@ -1412,6 +1409,19 @@ def list_finding_type_stats( # Done; return the response. return response + def __enter__(self): + return self + + def __exit__(self, type, value, traceback): + """Releases underlying transport's resources. + + .. warning:: + ONLY use as a context manager if the transport is NOT shared + with other clients! Exiting the with block will CLOSE the transport + and may cause errors in other clients! + """ + self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/transports/base.py b/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/transports/base.py index 0d32f74..fd96199 100644 --- a/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/transports/base.py +++ b/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/transports/base.py @@ -308,6 +308,15 @@ def _prep_wrapped_messages(self, client_info): ), } + def close(self): + """Closes resources associated with the transport. + + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! + """ + raise NotImplementedError() + @property def create_scan_config( self, diff --git a/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/transports/grpc.py b/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/transports/grpc.py index 4b25911..bd74e69 100644 --- a/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/transports/grpc.py +++ b/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/transports/grpc.py @@ -593,5 +593,8 @@ def list_finding_type_stats( ) return self._stubs["list_finding_type_stats"] + def close(self): + self.grpc_channel.close() + __all__ = ("WebSecurityScannerGrpcTransport",) diff --git a/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/transports/grpc_asyncio.py b/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/transports/grpc_asyncio.py index 400e2b1..8aaa757 100644 --- a/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/transports/grpc_asyncio.py +++ b/google/cloud/websecurityscanner_v1alpha/services/web_security_scanner/transports/grpc_asyncio.py @@ -608,5 +608,8 @@ def list_finding_type_stats( ) return self._stubs["list_finding_type_stats"] + def close(self): + return self.grpc_channel.close() + __all__ = ("WebSecurityScannerGrpcAsyncIOTransport",) diff --git a/google/cloud/websecurityscanner_v1alpha/types/finding_addon.py b/google/cloud/websecurityscanner_v1alpha/types/finding_addon.py index a1ce6ff..8c796aa 100644 --- a/google/cloud/websecurityscanner_v1alpha/types/finding_addon.py +++ b/google/cloud/websecurityscanner_v1alpha/types/finding_addon.py @@ -30,6 +30,7 @@ class OutdatedLibrary(proto.Message): r"""Information reported for an outdated library. + Attributes: library_name (str): The name of the outdated library. @@ -62,6 +63,7 @@ class ViolatingResource(proto.Message): class VulnerableParameters(proto.Message): r"""Information about vulnerable request parameters. + Attributes: parameter_names (Sequence[str]): The vulnerable parameter names. @@ -72,6 +74,7 @@ class VulnerableParameters(proto.Message): class VulnerableHeaders(proto.Message): r"""Information about vulnerable or missing HTTP Headers. + Attributes: headers (Sequence[google.cloud.websecurityscanner_v1alpha.types.VulnerableHeaders.Header]): List of vulnerable headers. @@ -81,6 +84,7 @@ class VulnerableHeaders(proto.Message): class Header(proto.Message): r"""Describes a HTTP Header. + Attributes: name (str): Header name. @@ -97,6 +101,7 @@ class Header(proto.Message): class Xss(proto.Message): r"""Information reported for an XSS. + Attributes: stack_traces (Sequence[str]): Stack traces leading to the point where the diff --git a/google/cloud/websecurityscanner_v1alpha/types/scan_config.py b/google/cloud/websecurityscanner_v1alpha/types/scan_config.py index 966d62a..961efb0 100644 --- a/google/cloud/websecurityscanner_v1alpha/types/scan_config.py +++ b/google/cloud/websecurityscanner_v1alpha/types/scan_config.py @@ -79,6 +79,7 @@ class TargetPlatform(proto.Enum): class Authentication(proto.Message): r"""Scan authentication configuration. + Attributes: google_account (google.cloud.websecurityscanner_v1alpha.types.ScanConfig.Authentication.GoogleAccount): Authentication using a Google account. @@ -140,6 +141,7 @@ class CustomAccount(proto.Message): class Schedule(proto.Message): r"""Scan schedule configuration. + Attributes: schedule_time (google.protobuf.timestamp_pb2.Timestamp): A timestamp indicates when the next run will diff --git a/google/cloud/websecurityscanner_v1alpha/types/web_security_scanner.py b/google/cloud/websecurityscanner_v1alpha/types/web_security_scanner.py index d134a3c..dafdc97 100644 --- a/google/cloud/websecurityscanner_v1alpha/types/web_security_scanner.py +++ b/google/cloud/websecurityscanner_v1alpha/types/web_security_scanner.py @@ -52,6 +52,7 @@ class CreateScanConfigRequest(proto.Message): r"""Request for the ``CreateScanConfig`` method. + Attributes: parent (str): Required. The parent resource name where the @@ -70,6 +71,7 @@ class CreateScanConfigRequest(proto.Message): class DeleteScanConfigRequest(proto.Message): r"""Request for the ``DeleteScanConfig`` method. + Attributes: name (str): Required. The resource name of the ScanConfig @@ -82,6 +84,7 @@ class DeleteScanConfigRequest(proto.Message): class GetScanConfigRequest(proto.Message): r"""Request for the ``GetScanConfig`` method. + Attributes: name (str): Required. The resource name of the ScanConfig @@ -94,6 +97,7 @@ class GetScanConfigRequest(proto.Message): class ListScanConfigsRequest(proto.Message): r"""Request for the ``ListScanConfigs`` method. + Attributes: parent (str): Required. The parent resource name, which @@ -118,6 +122,7 @@ class ListScanConfigsRequest(proto.Message): class UpdateScanConfigRequest(proto.Message): r"""Request for the ``UpdateScanConfigRequest`` method. + Attributes: scan_config (google.cloud.websecurityscanner_v1alpha.types.ScanConfig): Required. The ScanConfig to be updated. The @@ -140,6 +145,7 @@ class UpdateScanConfigRequest(proto.Message): class ListScanConfigsResponse(proto.Message): r"""Response for the ``ListScanConfigs`` method. + Attributes: scan_configs (Sequence[google.cloud.websecurityscanner_v1alpha.types.ScanConfig]): The list of ScanConfigs returned. @@ -161,6 +167,7 @@ def raw_page(self): class StartScanRunRequest(proto.Message): r"""Request for the ``StartScanRun`` method. + Attributes: name (str): Required. The resource name of the ScanConfig @@ -173,6 +180,7 @@ class StartScanRunRequest(proto.Message): class GetScanRunRequest(proto.Message): r"""Request for the ``GetScanRun`` method. + Attributes: name (str): Required. The resource name of the ScanRun to @@ -185,6 +193,7 @@ class GetScanRunRequest(proto.Message): class ListScanRunsRequest(proto.Message): r"""Request for the ``ListScanRuns`` method. + Attributes: parent (str): Required. The parent resource name, which @@ -209,6 +218,7 @@ class ListScanRunsRequest(proto.Message): class ListScanRunsResponse(proto.Message): r"""Response for the ``ListScanRuns`` method. + Attributes: scan_runs (Sequence[google.cloud.websecurityscanner_v1alpha.types.ScanRun]): The list of ScanRuns returned. @@ -228,6 +238,7 @@ def raw_page(self): class StopScanRunRequest(proto.Message): r"""Request for the ``StopScanRun`` method. + Attributes: name (str): Required. The resource name of the ScanRun to @@ -240,6 +251,7 @@ class StopScanRunRequest(proto.Message): class ListCrawledUrlsRequest(proto.Message): r"""Request for the ``ListCrawledUrls`` method. + Attributes: parent (str): Required. The parent resource name, which @@ -264,6 +276,7 @@ class ListCrawledUrlsRequest(proto.Message): class ListCrawledUrlsResponse(proto.Message): r"""Response for the ``ListCrawledUrls`` method. + Attributes: crawled_urls (Sequence[google.cloud.websecurityscanner_v1alpha.types.CrawledUrl]): The list of CrawledUrls returned. @@ -285,6 +298,7 @@ def raw_page(self): class GetFindingRequest(proto.Message): r"""Request for the ``GetFinding`` method. + Attributes: name (str): Required. The resource name of the Finding to @@ -297,6 +311,7 @@ class GetFindingRequest(proto.Message): class ListFindingsRequest(proto.Message): r"""Request for the ``ListFindings`` method. + Attributes: parent (str): Required. The parent resource name, which @@ -326,6 +341,7 @@ class ListFindingsRequest(proto.Message): class ListFindingsResponse(proto.Message): r"""Response for the ``ListFindings`` method. + Attributes: findings (Sequence[google.cloud.websecurityscanner_v1alpha.types.Finding]): The list of Findings returned. @@ -345,6 +361,7 @@ def raw_page(self): class ListFindingTypeStatsRequest(proto.Message): r"""Request for the ``ListFindingTypeStats`` method. + Attributes: parent (str): Required. The parent resource name, which @@ -357,6 +374,7 @@ class ListFindingTypeStatsRequest(proto.Message): class ListFindingTypeStatsResponse(proto.Message): r"""Response for the ``ListFindingTypeStats`` method. + Attributes: finding_type_stats (Sequence[google.cloud.websecurityscanner_v1alpha.types.FindingTypeStats]): The list of FindingTypeStats returned. diff --git a/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/async_client.py b/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/async_client.py index 99824a4..22b8058 100644 --- a/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/async_client.py +++ b/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/async_client.py @@ -1284,6 +1284,12 @@ async def list_finding_type_stats( # Done; return the response. return response + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc, tb): + await self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/client.py b/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/client.py index 736ae09..a680680 100644 --- a/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/client.py +++ b/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/client.py @@ -397,10 +397,7 @@ def __init__( client_cert_source_for_mtls=client_cert_source_func, quota_project_id=client_options.quota_project_id, client_info=client_info, - always_use_jwt_access=( - Transport == type(self).get_transport_class("grpc") - or Transport == type(self).get_transport_class("grpc_asyncio") - ), + always_use_jwt_access=True, ) def create_scan_config( @@ -1414,6 +1411,19 @@ def list_finding_type_stats( # Done; return the response. return response + def __enter__(self): + return self + + def __exit__(self, type, value, traceback): + """Releases underlying transport's resources. + + .. warning:: + ONLY use as a context manager if the transport is NOT shared + with other clients! Exiting the with block will CLOSE the transport + and may cause errors in other clients! + """ + self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/transports/base.py b/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/transports/base.py index 2dbb73a..e965c8f 100644 --- a/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/transports/base.py +++ b/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/transports/base.py @@ -308,6 +308,15 @@ def _prep_wrapped_messages(self, client_info): ), } + def close(self): + """Closes resources associated with the transport. + + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! + """ + raise NotImplementedError() + @property def create_scan_config( self, diff --git a/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/transports/grpc.py b/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/transports/grpc.py index 1bc7090..0a979a2 100644 --- a/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/transports/grpc.py +++ b/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/transports/grpc.py @@ -593,5 +593,8 @@ def list_finding_type_stats( ) return self._stubs["list_finding_type_stats"] + def close(self): + self.grpc_channel.close() + __all__ = ("WebSecurityScannerGrpcTransport",) diff --git a/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/transports/grpc_asyncio.py b/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/transports/grpc_asyncio.py index b7649be..690ccc7 100644 --- a/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/transports/grpc_asyncio.py +++ b/google/cloud/websecurityscanner_v1beta/services/web_security_scanner/transports/grpc_asyncio.py @@ -608,5 +608,8 @@ def list_finding_type_stats( ) return self._stubs["list_finding_type_stats"] + def close(self): + return self.grpc_channel.close() + __all__ = ("WebSecurityScannerGrpcAsyncIOTransport",) diff --git a/google/cloud/websecurityscanner_v1beta/types/finding_addon.py b/google/cloud/websecurityscanner_v1beta/types/finding_addon.py index cd44522..9afe6b1 100644 --- a/google/cloud/websecurityscanner_v1beta/types/finding_addon.py +++ b/google/cloud/websecurityscanner_v1beta/types/finding_addon.py @@ -31,6 +31,7 @@ class Form(proto.Message): r"""! Information about a vulnerability with an HTML. + Attributes: action_uri (str): ! The URI where to send the form when it's @@ -46,6 +47,7 @@ class Form(proto.Message): class OutdatedLibrary(proto.Message): r"""Information reported for an outdated library. + Attributes: library_name (str): The name of the outdated library. @@ -78,6 +80,7 @@ class ViolatingResource(proto.Message): class VulnerableParameters(proto.Message): r"""Information about vulnerable request parameters. + Attributes: parameter_names (Sequence[str]): The vulnerable parameter names. @@ -88,6 +91,7 @@ class VulnerableParameters(proto.Message): class VulnerableHeaders(proto.Message): r"""Information about vulnerable or missing HTTP Headers. + Attributes: headers (Sequence[google.cloud.websecurityscanner_v1beta.types.VulnerableHeaders.Header]): List of vulnerable headers. @@ -97,6 +101,7 @@ class VulnerableHeaders(proto.Message): class Header(proto.Message): r"""Describes a HTTP Header. + Attributes: name (str): Header name. @@ -113,6 +118,7 @@ class Header(proto.Message): class Xss(proto.Message): r"""Information reported for an XSS. + Attributes: stack_traces (Sequence[str]): Stack traces leading to the point where the diff --git a/google/cloud/websecurityscanner_v1beta/types/scan_config.py b/google/cloud/websecurityscanner_v1beta/types/scan_config.py index 3b553c7..c7418da 100644 --- a/google/cloud/websecurityscanner_v1beta/types/scan_config.py +++ b/google/cloud/websecurityscanner_v1beta/types/scan_config.py @@ -102,6 +102,7 @@ class ExportToSecurityCommandCenter(proto.Enum): class Authentication(proto.Message): r"""Scan authentication configuration. + Attributes: google_account (google.cloud.websecurityscanner_v1beta.types.ScanConfig.Authentication.GoogleAccount): Authentication using a Google account. @@ -163,6 +164,7 @@ class CustomAccount(proto.Message): class Schedule(proto.Message): r"""Scan schedule configuration. + Attributes: schedule_time (google.protobuf.timestamp_pb2.Timestamp): A timestamp indicates when the next run will diff --git a/google/cloud/websecurityscanner_v1beta/types/web_security_scanner.py b/google/cloud/websecurityscanner_v1beta/types/web_security_scanner.py index 5b50ec3..a2536f7 100644 --- a/google/cloud/websecurityscanner_v1beta/types/web_security_scanner.py +++ b/google/cloud/websecurityscanner_v1beta/types/web_security_scanner.py @@ -52,6 +52,7 @@ class CreateScanConfigRequest(proto.Message): r"""Request for the ``CreateScanConfig`` method. + Attributes: parent (str): Required. The parent resource name where the @@ -70,6 +71,7 @@ class CreateScanConfigRequest(proto.Message): class DeleteScanConfigRequest(proto.Message): r"""Request for the ``DeleteScanConfig`` method. + Attributes: name (str): Required. The resource name of the ScanConfig @@ -82,6 +84,7 @@ class DeleteScanConfigRequest(proto.Message): class GetScanConfigRequest(proto.Message): r"""Request for the ``GetScanConfig`` method. + Attributes: name (str): Required. The resource name of the ScanConfig @@ -94,6 +97,7 @@ class GetScanConfigRequest(proto.Message): class ListScanConfigsRequest(proto.Message): r"""Request for the ``ListScanConfigs`` method. + Attributes: parent (str): Required. The parent resource name, which @@ -118,6 +122,7 @@ class ListScanConfigsRequest(proto.Message): class UpdateScanConfigRequest(proto.Message): r"""Request for the ``UpdateScanConfigRequest`` method. + Attributes: scan_config (google.cloud.websecurityscanner_v1beta.types.ScanConfig): Required. The ScanConfig to be updated. The @@ -140,6 +145,7 @@ class UpdateScanConfigRequest(proto.Message): class ListScanConfigsResponse(proto.Message): r"""Response for the ``ListScanConfigs`` method. + Attributes: scan_configs (Sequence[google.cloud.websecurityscanner_v1beta.types.ScanConfig]): The list of ScanConfigs returned. @@ -161,6 +167,7 @@ def raw_page(self): class StartScanRunRequest(proto.Message): r"""Request for the ``StartScanRun`` method. + Attributes: name (str): Required. The resource name of the ScanConfig @@ -173,6 +180,7 @@ class StartScanRunRequest(proto.Message): class GetScanRunRequest(proto.Message): r"""Request for the ``GetScanRun`` method. + Attributes: name (str): Required. The resource name of the ScanRun to @@ -185,6 +193,7 @@ class GetScanRunRequest(proto.Message): class ListScanRunsRequest(proto.Message): r"""Request for the ``ListScanRuns`` method. + Attributes: parent (str): Required. The parent resource name, which @@ -209,6 +218,7 @@ class ListScanRunsRequest(proto.Message): class ListScanRunsResponse(proto.Message): r"""Response for the ``ListScanRuns`` method. + Attributes: scan_runs (Sequence[google.cloud.websecurityscanner_v1beta.types.ScanRun]): The list of ScanRuns returned. @@ -228,6 +238,7 @@ def raw_page(self): class StopScanRunRequest(proto.Message): r"""Request for the ``StopScanRun`` method. + Attributes: name (str): Required. The resource name of the ScanRun to @@ -240,6 +251,7 @@ class StopScanRunRequest(proto.Message): class ListCrawledUrlsRequest(proto.Message): r"""Request for the ``ListCrawledUrls`` method. + Attributes: parent (str): Required. The parent resource name, which @@ -264,6 +276,7 @@ class ListCrawledUrlsRequest(proto.Message): class ListCrawledUrlsResponse(proto.Message): r"""Response for the ``ListCrawledUrls`` method. + Attributes: crawled_urls (Sequence[google.cloud.websecurityscanner_v1beta.types.CrawledUrl]): The list of CrawledUrls returned. @@ -285,6 +298,7 @@ def raw_page(self): class GetFindingRequest(proto.Message): r"""Request for the ``GetFinding`` method. + Attributes: name (str): Required. The resource name of the Finding to @@ -297,6 +311,7 @@ class GetFindingRequest(proto.Message): class ListFindingsRequest(proto.Message): r"""Request for the ``ListFindings`` method. + Attributes: parent (str): Required. The parent resource name, which @@ -326,6 +341,7 @@ class ListFindingsRequest(proto.Message): class ListFindingsResponse(proto.Message): r"""Response for the ``ListFindings`` method. + Attributes: findings (Sequence[google.cloud.websecurityscanner_v1beta.types.Finding]): The list of Findings returned. @@ -345,6 +361,7 @@ def raw_page(self): class ListFindingTypeStatsRequest(proto.Message): r"""Request for the ``ListFindingTypeStats`` method. + Attributes: parent (str): Required. The parent resource name, which @@ -357,6 +374,7 @@ class ListFindingTypeStatsRequest(proto.Message): class ListFindingTypeStatsResponse(proto.Message): r"""Response for the ``ListFindingTypeStats`` method. + Attributes: finding_type_stats (Sequence[google.cloud.websecurityscanner_v1beta.types.FindingTypeStats]): The list of FindingTypeStats returned. diff --git a/tests/unit/gapic/websecurityscanner_v1/test_web_security_scanner.py b/tests/unit/gapic/websecurityscanner_v1/test_web_security_scanner.py index e939fb1..4b4a425 100644 --- a/tests/unit/gapic/websecurityscanner_v1/test_web_security_scanner.py +++ b/tests/unit/gapic/websecurityscanner_v1/test_web_security_scanner.py @@ -29,6 +29,7 @@ from google.api_core import gapic_v1 from google.api_core import grpc_helpers from google.api_core import grpc_helpers_async +from google.api_core import path_template from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.websecurityscanner_v1.services.web_security_scanner import ( @@ -3330,6 +3331,9 @@ def test_web_security_scanner_base_transport(): with pytest.raises(NotImplementedError): getattr(transport, method)(request=object()) + with pytest.raises(NotImplementedError): + transport.close() + @requires_google_auth_gte_1_25_0 def test_web_security_scanner_base_transport_with_credentials_file(): @@ -3818,3 +3822,49 @@ def test_client_withDEFAULT_CLIENT_INFO(): credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) + + +@pytest.mark.asyncio +async def test_transport_close_async(): + client = WebSecurityScannerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + ) + with mock.patch.object( + type(getattr(client.transport, "grpc_channel")), "close" + ) as close: + async with client: + close.assert_not_called() + close.assert_called_once() + + +def test_transport_close(): + transports = { + "grpc": "_grpc_channel", + } + + for transport, close_name in transports.items(): + client = WebSecurityScannerClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + with mock.patch.object( + type(getattr(client.transport, close_name)), "close" + ) as close: + with client: + close.assert_not_called() + close.assert_called_once() + + +def test_client_ctx(): + transports = [ + "grpc", + ] + for transport in transports: + client = WebSecurityScannerClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + # Test client calls underlying transport. + with mock.patch.object(type(client.transport), "close") as close: + close.assert_not_called() + with client: + pass + close.assert_called() diff --git a/tests/unit/gapic/websecurityscanner_v1alpha/test_web_security_scanner.py b/tests/unit/gapic/websecurityscanner_v1alpha/test_web_security_scanner.py index dd05f7d..20441d8 100644 --- a/tests/unit/gapic/websecurityscanner_v1alpha/test_web_security_scanner.py +++ b/tests/unit/gapic/websecurityscanner_v1alpha/test_web_security_scanner.py @@ -29,6 +29,7 @@ from google.api_core import gapic_v1 from google.api_core import grpc_helpers from google.api_core import grpc_helpers_async +from google.api_core import path_template from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.websecurityscanner_v1alpha.services.web_security_scanner import ( @@ -4269,6 +4270,9 @@ def test_web_security_scanner_base_transport(): with pytest.raises(NotImplementedError): getattr(transport, method)(request=object()) + with pytest.raises(NotImplementedError): + transport.close() + @requires_google_auth_gte_1_25_0 def test_web_security_scanner_base_transport_with_credentials_file(): @@ -4803,3 +4807,49 @@ def test_client_withDEFAULT_CLIENT_INFO(): credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) + + +@pytest.mark.asyncio +async def test_transport_close_async(): + client = WebSecurityScannerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + ) + with mock.patch.object( + type(getattr(client.transport, "grpc_channel")), "close" + ) as close: + async with client: + close.assert_not_called() + close.assert_called_once() + + +def test_transport_close(): + transports = { + "grpc": "_grpc_channel", + } + + for transport, close_name in transports.items(): + client = WebSecurityScannerClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + with mock.patch.object( + type(getattr(client.transport, close_name)), "close" + ) as close: + with client: + close.assert_not_called() + close.assert_called_once() + + +def test_client_ctx(): + transports = [ + "grpc", + ] + for transport in transports: + client = WebSecurityScannerClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + # Test client calls underlying transport. + with mock.patch.object(type(client.transport), "close") as close: + close.assert_not_called() + with client: + pass + close.assert_called() diff --git a/tests/unit/gapic/websecurityscanner_v1beta/test_web_security_scanner.py b/tests/unit/gapic/websecurityscanner_v1beta/test_web_security_scanner.py index 3569589..e8da1b1 100644 --- a/tests/unit/gapic/websecurityscanner_v1beta/test_web_security_scanner.py +++ b/tests/unit/gapic/websecurityscanner_v1beta/test_web_security_scanner.py @@ -29,6 +29,7 @@ from google.api_core import gapic_v1 from google.api_core import grpc_helpers from google.api_core import grpc_helpers_async +from google.api_core import path_template from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.websecurityscanner_v1beta.services.web_security_scanner import ( @@ -4314,6 +4315,9 @@ def test_web_security_scanner_base_transport(): with pytest.raises(NotImplementedError): getattr(transport, method)(request=object()) + with pytest.raises(NotImplementedError): + transport.close() + @requires_google_auth_gte_1_25_0 def test_web_security_scanner_base_transport_with_credentials_file(): @@ -4848,3 +4852,49 @@ def test_client_withDEFAULT_CLIENT_INFO(): credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) + + +@pytest.mark.asyncio +async def test_transport_close_async(): + client = WebSecurityScannerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + ) + with mock.patch.object( + type(getattr(client.transport, "grpc_channel")), "close" + ) as close: + async with client: + close.assert_not_called() + close.assert_called_once() + + +def test_transport_close(): + transports = { + "grpc": "_grpc_channel", + } + + for transport, close_name in transports.items(): + client = WebSecurityScannerClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + with mock.patch.object( + type(getattr(client.transport, close_name)), "close" + ) as close: + with client: + close.assert_not_called() + close.assert_called_once() + + +def test_client_ctx(): + transports = [ + "grpc", + ] + for transport in transports: + client = WebSecurityScannerClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + # Test client calls underlying transport. + with mock.patch.object(type(client.transport), "close") as close: + close.assert_not_called() + with client: + pass + close.assert_called()