Skip to content
This repository has been archived by the owner on Sep 5, 2023. It is now read-only.

Commit

Permalink
Integrate Python GAPIC Microgenerator in googleapis. This PR uses usi…
Browse files Browse the repository at this point in the history
…ng documentai as an example. Depends on googleapis/gapic-generator-python#402

PiperOrigin-RevId: 309824146

Source-Author: Google APIs <noreply@google.com>
Source-Date: Mon May 4 15:06:44 2020 -0700
Source-Repo: googleapis/googleapis
Source-Sha: e0f9d9e1f9de890db765be46f45ca8490723e3eb
Source-Link: googleapis/googleapis@e0f9d9e
  • Loading branch information
yoshi-automation committed Jun 25, 2020
1 parent 4291037 commit ade9dd0
Show file tree
Hide file tree
Showing 25 changed files with 759 additions and 1,002 deletions.
6 changes: 3 additions & 3 deletions google/cloud/websecurityscanner_v1alpha/gapic/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ class TargetPlatform(enum.IntEnum):
Cloud platforms supported by Cloud Web Security Scanner.
Attributes:
TARGET_PLATFORM_UNSPECIFIED (int): The target platform is unknown. Requests with this enum value will be
rejected with INVALID\_ARGUMENT error.
TARGET_PLATFORM_UNSPECIFIED (int): The target platform is unknown. Requests with this enum value will
be rejected with INVALID_ARGUMENT error.
APP_ENGINE (int): Google App Engine service.
COMPUTE (int): Google Compute Engine service.
"""
Expand All @@ -98,7 +98,7 @@ class UserAgent(enum.IntEnum):
Type of user agents used for scanning.
Attributes:
USER_AGENT_UNSPECIFIED (int): The user agent is unknown. Service will default to CHROME\_LINUX.
USER_AGENT_UNSPECIFIED (int): The user agent is unknown. Service will default to CHROME_LINUX.
CHROME_LINUX (int): Chrome on Linux. This is the service default if unspecified.
CHROME_ANDROID (int): Chrome on Android.
SAFARI_IPHONE (int): Safari on IPhone.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,30 +113,30 @@ def channel(self):
return self._channel

@property
def create_scan_config(self):
"""Return the gRPC stub for :meth:`WebSecurityScannerClient.create_scan_config`.
def delete_scan_config(self):
"""Return the gRPC stub for :meth:`WebSecurityScannerClient.delete_scan_config`.
Creates a new ScanConfig.
Deletes an existing ScanConfig and its child resources.
Returns:
Callable: A callable which accepts the appropriate
deserialized request object and returns a
deserialized response object.
"""
return self._stubs["web_security_scanner_stub"].CreateScanConfig
return self._stubs["web_security_scanner_stub"].DeleteScanConfig

@property
def delete_scan_config(self):
"""Return the gRPC stub for :meth:`WebSecurityScannerClient.delete_scan_config`.
def create_scan_config(self):
"""Return the gRPC stub for :meth:`WebSecurityScannerClient.create_scan_config`.
Deletes an existing ScanConfig and its child resources.
Creates a new ScanConfig.
Returns:
Callable: A callable which accepts the appropriate
deserialized request object and returns a
deserialized response object.
"""
return self._stubs["web_security_scanner_stub"].DeleteScanConfig
return self._stubs["web_security_scanner_stub"].CreateScanConfig

@property
def get_scan_config(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,36 +236,28 @@ def __init__(
self._inner_api_calls = {}

# Service calls
def create_scan_config(
def delete_scan_config(
self,
parent,
scan_config,
name,
retry=google.api_core.gapic_v1.method.DEFAULT,
timeout=google.api_core.gapic_v1.method.DEFAULT,
metadata=None,
):
"""
Creates a new ScanConfig.
Deletes an existing ScanConfig and its child resources.
Example:
>>> from google.cloud import websecurityscanner_v1alpha
>>>
>>> client = websecurityscanner_v1alpha.WebSecurityScannerClient()
>>>
>>> parent = client.project_path('[PROJECT]')
>>>
>>> # TODO: Initialize `scan_config`:
>>> scan_config = {}
>>> name = client.scan_config_path('[PROJECT]', '[SCAN_CONFIG]')
>>>
>>> response = client.create_scan_config(parent, scan_config)
>>> client.delete_scan_config(name)
Args:
parent (str): Required. The parent resource name where the scan is created, which should be a
project resource name in the format 'projects/{projectId}'.
scan_config (Union[dict, ~google.cloud.websecurityscanner_v1alpha.types.ScanConfig]): Required. The ScanConfig to be created.
If a dict is provided, it must be of the same form as the protobuf
message :class:`~google.cloud.websecurityscanner_v1alpha.types.ScanConfig`
name (str): Required. The resource name of the ScanConfig to be deleted. The name follows the
format of 'projects/{projectId}/scanConfigs/{scanConfigId}'.
retry (Optional[google.api_core.retry.Retry]): A retry object used
to retry requests. If ``None`` is specified, requests will
be retried using a default configuration.
Expand All @@ -275,9 +267,6 @@ def create_scan_config(
metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata
that is provided to the method.
Returns:
A :class:`~google.cloud.websecurityscanner_v1alpha.types.ScanConfig` instance.
Raises:
google.api_core.exceptions.GoogleAPICallError: If the request
failed for any reason.
Expand All @@ -286,24 +275,22 @@ def create_scan_config(
ValueError: If the parameters are invalid.
"""
# Wrap the transport method to add retry and timeout logic.
if "create_scan_config" not in self._inner_api_calls:
if "delete_scan_config" not in self._inner_api_calls:
self._inner_api_calls[
"create_scan_config"
"delete_scan_config"
] = google.api_core.gapic_v1.method.wrap_method(
self.transport.create_scan_config,
default_retry=self._method_configs["CreateScanConfig"].retry,
default_timeout=self._method_configs["CreateScanConfig"].timeout,
self.transport.delete_scan_config,
default_retry=self._method_configs["DeleteScanConfig"].retry,
default_timeout=self._method_configs["DeleteScanConfig"].timeout,
client_info=self._client_info,
)

request = web_security_scanner_pb2.CreateScanConfigRequest(
parent=parent, scan_config=scan_config
)
request = web_security_scanner_pb2.DeleteScanConfigRequest(name=name)
if metadata is None:
metadata = []
metadata = list(metadata)
try:
routing_header = [("parent", parent)]
routing_header = [("name", name)]
except AttributeError:
pass
else:
Expand All @@ -312,32 +299,40 @@ def create_scan_config(
)
metadata.append(routing_metadata)

return self._inner_api_calls["create_scan_config"](
self._inner_api_calls["delete_scan_config"](
request, retry=retry, timeout=timeout, metadata=metadata
)

def delete_scan_config(
def create_scan_config(
self,
name,
parent,
scan_config,
retry=google.api_core.gapic_v1.method.DEFAULT,
timeout=google.api_core.gapic_v1.method.DEFAULT,
metadata=None,
):
"""
Deletes an existing ScanConfig and its child resources.
Creates a new ScanConfig.
Example:
>>> from google.cloud import websecurityscanner_v1alpha
>>>
>>> client = websecurityscanner_v1alpha.WebSecurityScannerClient()
>>>
>>> name = client.scan_config_path('[PROJECT]', '[SCAN_CONFIG]')
>>> parent = client.project_path('[PROJECT]')
>>>
>>> client.delete_scan_config(name)
>>> # TODO: Initialize `scan_config`:
>>> scan_config = {}
>>>
>>> response = client.create_scan_config(parent, scan_config)
Args:
name (str): Required. The resource name of the ScanConfig to be deleted. The name follows the
format of 'projects/{projectId}/scanConfigs/{scanConfigId}'.
parent (str): Required. The parent resource name where the scan is created, which should be a
project resource name in the format 'projects/{projectId}'.
scan_config (Union[dict, ~google.cloud.websecurityscanner_v1alpha.types.ScanConfig]): Required. The ScanConfig to be created.
If a dict is provided, it must be of the same form as the protobuf
message :class:`~google.cloud.websecurityscanner_v1alpha.types.ScanConfig`
retry (Optional[google.api_core.retry.Retry]): A retry object used
to retry requests. If ``None`` is specified, requests will
be retried using a default configuration.
Expand All @@ -347,6 +342,9 @@ def delete_scan_config(
metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata
that is provided to the method.
Returns:
A :class:`~google.cloud.websecurityscanner_v1alpha.types.ScanConfig` instance.
Raises:
google.api_core.exceptions.GoogleAPICallError: If the request
failed for any reason.
Expand All @@ -355,22 +353,24 @@ def delete_scan_config(
ValueError: If the parameters are invalid.
"""
# Wrap the transport method to add retry and timeout logic.
if "delete_scan_config" not in self._inner_api_calls:
if "create_scan_config" not in self._inner_api_calls:
self._inner_api_calls[
"delete_scan_config"
"create_scan_config"
] = google.api_core.gapic_v1.method.wrap_method(
self.transport.delete_scan_config,
default_retry=self._method_configs["DeleteScanConfig"].retry,
default_timeout=self._method_configs["DeleteScanConfig"].timeout,
self.transport.create_scan_config,
default_retry=self._method_configs["CreateScanConfig"].retry,
default_timeout=self._method_configs["CreateScanConfig"].timeout,
client_info=self._client_info,
)

request = web_security_scanner_pb2.DeleteScanConfigRequest(name=name)
request = web_security_scanner_pb2.CreateScanConfigRequest(
parent=parent, scan_config=scan_config
)
if metadata is None:
metadata = []
metadata = list(metadata)
try:
routing_header = [("name", name)]
routing_header = [("parent", parent)]
except AttributeError:
pass
else:
Expand All @@ -379,7 +379,7 @@ def delete_scan_config(
)
metadata.append(routing_metadata)

self._inner_api_calls["delete_scan_config"](
return self._inner_api_calls["create_scan_config"](
request, retry=retry, timeout=timeout, metadata=metadata
)

Expand Down Expand Up @@ -588,8 +588,8 @@ def update_scan_config(
If a dict is provided, it must be of the same form as the protobuf
message :class:`~google.cloud.websecurityscanner_v1alpha.types.ScanConfig`
update_mask (Union[dict, ~google.cloud.websecurityscanner_v1alpha.types.FieldMask]): Required. The update mask applies to the resource. For the ``FieldMask``
definition, see
update_mask (Union[dict, ~google.cloud.websecurityscanner_v1alpha.types.FieldMask]): Required. The update mask applies to the resource. For the
``FieldMask`` definition, see
https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask
If a dict is provided, it must be of the same form as the protobuf
Expand Down Expand Up @@ -1177,8 +1177,8 @@ def list_findings(
parent (str): Required. The parent resource name, which should be a scan run resource name in the
format
'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'.
filter_ (str): Required. The filter expression. The expression must be in the format: .
Supported field: 'finding\_type'. Supported operator: '='.
filter_ (str): Required. The filter expression. The expression must be in the
format: . Supported field: 'finding_type'. Supported operator: '='.
page_size (int): The maximum number of resources contained in the
underlying API response. If page streaming is performed per-
resource, this parameter does not affect the return value. If page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
}
},
"methods": {
"CreateScanConfig": {
"DeleteScanConfig": {
"timeout_millis": 60000,
"retry_codes_name": "non_idempotent",
"retry_codes_name": "idempotent",
"retry_params_name": "default",
},
"DeleteScanConfig": {
"CreateScanConfig": {
"timeout_millis": 60000,
"retry_codes_name": "idempotent",
"retry_codes_name": "non_idempotent",
"retry_params_name": "default",
},
"GetScanConfig": {
Expand Down
33 changes: 13 additions & 20 deletions google/cloud/websecurityscanner_v1alpha/proto/crawled_url_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ade9dd0

Please sign in to comment.