diff --git a/packages/google-cloud-recaptcha-enterprise/CONTRIBUTING.rst b/packages/google-cloud-recaptcha-enterprise/CONTRIBUTING.rst index 4d30470bc081..8bb54d46d4ae 100644 --- a/packages/google-cloud-recaptcha-enterprise/CONTRIBUTING.rst +++ b/packages/google-cloud-recaptcha-enterprise/CONTRIBUTING.rst @@ -143,12 +143,12 @@ Running System Tests $ nox -s system # Run a single system test - $ nox -s system- -- -k + $ nox -s system-3.11 -- -k .. note:: - System tests are only configured to run under Python. + System tests are only configured to run under Python 3.8, 3.9, 3.10 and 3.11. For expediency, we do not run them in older versions of Python 3. This alone will not run the tests. You'll need to change some local diff --git a/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise/__init__.py b/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise/__init__.py index 34cd4cba0f78..8ebb7b210598 100644 --- a/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise/__init__.py +++ b/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise/__init__.py @@ -30,18 +30,28 @@ AndroidKeySettings, AnnotateAssessmentRequest, AnnotateAssessmentResponse, + AppleDeveloperId, Assessment, ChallengeMetrics, CreateAssessmentRequest, + CreateFirewallPolicyRequest, CreateKeyRequest, + DeleteFirewallPolicyRequest, DeleteKeyRequest, EndpointVerificationInfo, Event, + FirewallAction, + FirewallPolicy, + FirewallPolicyAssessment, FraudPreventionAssessment, + FraudSignals, + GetFirewallPolicyRequest, GetKeyRequest, GetMetricsRequest, IOSKeySettings, Key, + ListFirewallPoliciesRequest, + ListFirewallPoliciesResponse, ListKeysRequest, ListKeysResponse, ListRelatedAccountGroupMembershipsRequest, @@ -64,6 +74,7 @@ TokenProperties, TransactionData, TransactionEvent, + UpdateFirewallPolicyRequest, UpdateKeyRequest, WafSettings, WebKeySettings, @@ -77,18 +88,28 @@ "AndroidKeySettings", "AnnotateAssessmentRequest", "AnnotateAssessmentResponse", + "AppleDeveloperId", "Assessment", "ChallengeMetrics", "CreateAssessmentRequest", + "CreateFirewallPolicyRequest", "CreateKeyRequest", + "DeleteFirewallPolicyRequest", "DeleteKeyRequest", "EndpointVerificationInfo", "Event", + "FirewallAction", + "FirewallPolicy", + "FirewallPolicyAssessment", "FraudPreventionAssessment", + "FraudSignals", + "GetFirewallPolicyRequest", "GetKeyRequest", "GetMetricsRequest", "IOSKeySettings", "Key", + "ListFirewallPoliciesRequest", + "ListFirewallPoliciesResponse", "ListKeysRequest", "ListKeysResponse", "ListRelatedAccountGroupMembershipsRequest", @@ -111,6 +132,7 @@ "TokenProperties", "TransactionData", "TransactionEvent", + "UpdateFirewallPolicyRequest", "UpdateKeyRequest", "WafSettings", "WebKeySettings", diff --git a/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise/gapic_version.py b/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise/gapic_version.py index 394a70bae1a3..360a0d13ebdd 100644 --- a/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise/gapic_version.py +++ b/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.12.2" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/__init__.py b/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/__init__.py index ca7088dac1fb..3fe58a774915 100644 --- a/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/__init__.py +++ b/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/__init__.py @@ -28,18 +28,28 @@ AndroidKeySettings, AnnotateAssessmentRequest, AnnotateAssessmentResponse, + AppleDeveloperId, Assessment, ChallengeMetrics, CreateAssessmentRequest, + CreateFirewallPolicyRequest, CreateKeyRequest, + DeleteFirewallPolicyRequest, DeleteKeyRequest, EndpointVerificationInfo, Event, + FirewallAction, + FirewallPolicy, + FirewallPolicyAssessment, FraudPreventionAssessment, + FraudSignals, + GetFirewallPolicyRequest, GetKeyRequest, GetMetricsRequest, IOSKeySettings, Key, + ListFirewallPoliciesRequest, + ListFirewallPoliciesResponse, ListKeysRequest, ListKeysResponse, ListRelatedAccountGroupMembershipsRequest, @@ -62,6 +72,7 @@ TokenProperties, TransactionData, TransactionEvent, + UpdateFirewallPolicyRequest, UpdateKeyRequest, WafSettings, WebKeySettings, @@ -74,18 +85,28 @@ "AndroidKeySettings", "AnnotateAssessmentRequest", "AnnotateAssessmentResponse", + "AppleDeveloperId", "Assessment", "ChallengeMetrics", "CreateAssessmentRequest", + "CreateFirewallPolicyRequest", "CreateKeyRequest", + "DeleteFirewallPolicyRequest", "DeleteKeyRequest", "EndpointVerificationInfo", "Event", + "FirewallAction", + "FirewallPolicy", + "FirewallPolicyAssessment", "FraudPreventionAssessment", + "FraudSignals", + "GetFirewallPolicyRequest", "GetKeyRequest", "GetMetricsRequest", "IOSKeySettings", "Key", + "ListFirewallPoliciesRequest", + "ListFirewallPoliciesResponse", "ListKeysRequest", "ListKeysResponse", "ListRelatedAccountGroupMembershipsRequest", @@ -109,6 +130,7 @@ "TokenProperties", "TransactionData", "TransactionEvent", + "UpdateFirewallPolicyRequest", "UpdateKeyRequest", "WafSettings", "WebKeySettings", diff --git a/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/gapic_metadata.json b/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/gapic_metadata.json index c44d90362737..d074d52bec70 100644 --- a/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/gapic_metadata.json +++ b/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/gapic_metadata.json @@ -20,16 +20,31 @@ "create_assessment" ] }, + "CreateFirewallPolicy": { + "methods": [ + "create_firewall_policy" + ] + }, "CreateKey": { "methods": [ "create_key" ] }, + "DeleteFirewallPolicy": { + "methods": [ + "delete_firewall_policy" + ] + }, "DeleteKey": { "methods": [ "delete_key" ] }, + "GetFirewallPolicy": { + "methods": [ + "get_firewall_policy" + ] + }, "GetKey": { "methods": [ "get_key" @@ -40,6 +55,11 @@ "get_metrics" ] }, + "ListFirewallPolicies": { + "methods": [ + "list_firewall_policies" + ] + }, "ListKeys": { "methods": [ "list_keys" @@ -70,6 +90,11 @@ "search_related_account_group_memberships" ] }, + "UpdateFirewallPolicy": { + "methods": [ + "update_firewall_policy" + ] + }, "UpdateKey": { "methods": [ "update_key" @@ -90,16 +115,31 @@ "create_assessment" ] }, + "CreateFirewallPolicy": { + "methods": [ + "create_firewall_policy" + ] + }, "CreateKey": { "methods": [ "create_key" ] }, + "DeleteFirewallPolicy": { + "methods": [ + "delete_firewall_policy" + ] + }, "DeleteKey": { "methods": [ "delete_key" ] }, + "GetFirewallPolicy": { + "methods": [ + "get_firewall_policy" + ] + }, "GetKey": { "methods": [ "get_key" @@ -110,6 +150,11 @@ "get_metrics" ] }, + "ListFirewallPolicies": { + "methods": [ + "list_firewall_policies" + ] + }, "ListKeys": { "methods": [ "list_keys" @@ -140,6 +185,11 @@ "search_related_account_group_memberships" ] }, + "UpdateFirewallPolicy": { + "methods": [ + "update_firewall_policy" + ] + }, "UpdateKey": { "methods": [ "update_key" diff --git a/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/gapic_version.py b/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/gapic_version.py index 394a70bae1a3..360a0d13ebdd 100644 --- a/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/gapic_version.py +++ b/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.12.2" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/async_client.py b/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/async_client.py index fe8008a2ff4a..a5c20557e7fc 100644 --- a/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/async_client.py +++ b/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/async_client.py @@ -67,6 +67,12 @@ class RecaptchaEnterpriseServiceAsyncClient: parse_assessment_path = staticmethod( RecaptchaEnterpriseServiceClient.parse_assessment_path ) + firewall_policy_path = staticmethod( + RecaptchaEnterpriseServiceClient.firewall_policy_path + ) + parse_firewall_policy_path = staticmethod( + RecaptchaEnterpriseServiceClient.parse_firewall_policy_path + ) key_path = staticmethod(RecaptchaEnterpriseServiceClient.key_path) parse_key_path = staticmethod(RecaptchaEnterpriseServiceClient.parse_key_path) metrics_path = staticmethod(RecaptchaEnterpriseServiceClient.metrics_path) @@ -292,9 +298,9 @@ async def sample_create_assessment(): The request object. The create assessment request message. parent (:class:`str`): - Required. The name of the project in - which the assessment will be created, in - the format "projects/{project}". + Required. The name of the project in which the + assessment will be created, in the format + ``projects/{project}``. This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this @@ -409,9 +415,8 @@ async def sample_annotate_assessment(): The request object. The request message to annotate an Assessment. name (:class:`str`): - Required. The resource name of the - Assessment, in the format - "projects/{project}/assessments/{assessment}". + Required. The resource name of the Assessment, in the + format ``projects/{project}/assessments/{assessment}``. This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this @@ -528,9 +533,8 @@ async def sample_create_key(): request (Optional[Union[google.cloud.recaptchaenterprise_v1.types.CreateKeyRequest, dict]]): The request object. The create key request message. parent (:class:`str`): - Required. The name of the project in - which the key will be created, in the - format "projects/{project}". + Required. The name of the project in which the key will + be created, in the format ``projects/{project}``. This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this @@ -642,10 +646,9 @@ async def sample_list_keys(): request (Optional[Union[google.cloud.recaptchaenterprise_v1.types.ListKeysRequest, dict]]): The request object. The list keys request message. parent (:class:`str`): - Required. The name of the project - that contains the keys that will be - listed, in the format - "projects/{project}". + Required. The name of the project that contains the keys + that will be listed, in the format + ``projects/{project}``. This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this @@ -762,9 +765,9 @@ async def sample_retrieve_legacy_secret_key(): The request object. The retrieve legacy secret key request message. key (:class:`str`): - Required. The public key name linked - to the requested secret key in the - format "projects/{project}/keys/{key}". + Required. The public key name linked to the requested + secret key in the format + ``projects/{project}/keys/{key}``. This corresponds to the ``key`` field on the ``request`` instance; if ``request`` is provided, this @@ -865,9 +868,8 @@ async def sample_get_key(): request (Optional[Union[google.cloud.recaptchaenterprise_v1.types.GetKeyRequest, dict]]): The request object. The get key request message. name (:class:`str`): - Required. The name of the requested - key, in the format - "projects/{project}/keys/{key}". + Required. The name of the requested key, in the format + ``projects/{project}/keys/{key}``. This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this @@ -1080,9 +1082,8 @@ async def sample_delete_key(): request (Optional[Union[google.cloud.recaptchaenterprise_v1.types.DeleteKeyRequest, dict]]): The request object. The delete key request message. name (:class:`str`): - Required. The name of the key to be - deleted, in the format - "projects/{project}/keys/{key}". + Required. The name of the key to be deleted, in the + format ``projects/{project}/keys/{key}``. This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this @@ -1144,9 +1145,9 @@ async def migrate_key( Enterprise. Once a key is migrated, it can be used from either product. SiteVerify requests are billed as CreateAssessment calls. You must be authenticated as one - of the current owners of the reCAPTCHA Site Key, and - your user must have the reCAPTCHA Enterprise Admin IAM - role in the destination project. + of the current owners of the reCAPTCHA Key, and your + user must have the reCAPTCHA Enterprise Admin IAM role + in the destination project. .. code-block:: python @@ -1260,9 +1261,8 @@ async def sample_get_metrics(): request (Optional[Union[google.cloud.recaptchaenterprise_v1.types.GetMetricsRequest, dict]]): The request object. The get metrics request message. name (:class:`str`): - Required. The name of the requested - metrics, in the format - "projects/{project}/keys/{key}/metrics". + Required. The name of the requested metrics, in the + format ``projects/{project}/keys/{key}/metrics``. This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this @@ -1319,6 +1319,556 @@ async def sample_get_metrics(): # Done; return the response. return response + async def create_firewall_policy( + self, + request: Optional[ + Union[recaptchaenterprise.CreateFirewallPolicyRequest, dict] + ] = None, + *, + parent: Optional[str] = None, + firewall_policy: Optional[recaptchaenterprise.FirewallPolicy] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> recaptchaenterprise.FirewallPolicy: + r"""Creates a new FirewallPolicy, specifying conditions + at which reCAPTCHA Enterprise actions can be executed. A + project may have a maximum of 1000 policies. + + .. 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 recaptchaenterprise_v1 + + async def sample_create_firewall_policy(): + # Create a client + client = recaptchaenterprise_v1.RecaptchaEnterpriseServiceAsyncClient() + + # Initialize request argument(s) + request = recaptchaenterprise_v1.CreateFirewallPolicyRequest( + parent="parent_value", + ) + + # Make the request + response = await client.create_firewall_policy(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.recaptchaenterprise_v1.types.CreateFirewallPolicyRequest, dict]]): + The request object. The create firewall policy request + message. + parent (:class:`str`): + Required. The name of the project this policy will apply + to, in the format ``projects/{project}``. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + firewall_policy (:class:`google.cloud.recaptchaenterprise_v1.types.FirewallPolicy`): + Required. Information to create the + policy. + + This corresponds to the ``firewall_policy`` 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.recaptchaenterprise_v1.types.FirewallPolicy: + A FirewallPolicy represents a single + matching pattern and resulting actions + to take. + + """ + # 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, firewall_policy]) + 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 = recaptchaenterprise.CreateFirewallPolicyRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if firewall_policy is not None: + request.firewall_policy = firewall_policy + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.create_firewall_policy, + 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 list_firewall_policies( + self, + request: Optional[ + Union[recaptchaenterprise.ListFirewallPoliciesRequest, dict] + ] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListFirewallPoliciesAsyncPager: + r"""Returns the list of all firewall policies that belong + to a project. + + .. 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 recaptchaenterprise_v1 + + async def sample_list_firewall_policies(): + # Create a client + client = recaptchaenterprise_v1.RecaptchaEnterpriseServiceAsyncClient() + + # Initialize request argument(s) + request = recaptchaenterprise_v1.ListFirewallPoliciesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_firewall_policies(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Optional[Union[google.cloud.recaptchaenterprise_v1.types.ListFirewallPoliciesRequest, dict]]): + The request object. The list firewall policies request + message. + parent (:class:`str`): + Required. The name of the project to list the policies + for, in the format ``projects/{project}``. + + This corresponds to the ``parent`` 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.recaptchaenterprise_v1.services.recaptcha_enterprise_service.pagers.ListFirewallPoliciesAsyncPager: + Response to request to list firewall + policies belonging to a key. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # 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]) + 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 = recaptchaenterprise.ListFirewallPoliciesRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.list_firewall_policies, + 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, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__aiter__` convenience method. + response = pagers.ListFirewallPoliciesAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_firewall_policy( + self, + request: Optional[ + Union[recaptchaenterprise.GetFirewallPolicyRequest, dict] + ] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> recaptchaenterprise.FirewallPolicy: + r"""Returns the specified firewall policy. + + .. 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 recaptchaenterprise_v1 + + async def sample_get_firewall_policy(): + # Create a client + client = recaptchaenterprise_v1.RecaptchaEnterpriseServiceAsyncClient() + + # Initialize request argument(s) + request = recaptchaenterprise_v1.GetFirewallPolicyRequest( + name="name_value", + ) + + # Make the request + response = await client.get_firewall_policy(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.recaptchaenterprise_v1.types.GetFirewallPolicyRequest, dict]]): + The request object. The get firewall policy request + message. + name (:class:`str`): + Required. The name of the requested policy, in the + format + ``projects/{project}/firewallpolicies/{firewallpolicy}``. + + This corresponds to the ``name`` 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.recaptchaenterprise_v1.types.FirewallPolicy: + A FirewallPolicy represents a single + matching pattern and resulting actions + to take. + + """ + # 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([name]) + 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 = recaptchaenterprise.GetFirewallPolicyRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.get_firewall_policy, + 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((("name", request.name),)), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def update_firewall_policy( + self, + request: Optional[ + Union[recaptchaenterprise.UpdateFirewallPolicyRequest, dict] + ] = None, + *, + firewall_policy: Optional[recaptchaenterprise.FirewallPolicy] = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> recaptchaenterprise.FirewallPolicy: + r"""Updates the specified firewall policy. + + .. 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 recaptchaenterprise_v1 + + async def sample_update_firewall_policy(): + # Create a client + client = recaptchaenterprise_v1.RecaptchaEnterpriseServiceAsyncClient() + + # Initialize request argument(s) + request = recaptchaenterprise_v1.UpdateFirewallPolicyRequest( + ) + + # Make the request + response = await client.update_firewall_policy(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.recaptchaenterprise_v1.types.UpdateFirewallPolicyRequest, dict]]): + The request object. The update firewall policy request + message. + firewall_policy (:class:`google.cloud.recaptchaenterprise_v1.types.FirewallPolicy`): + Required. The policy to update. + This corresponds to the ``firewall_policy`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Optional. The mask to control which + fields of the policy get updated. If the + mask is not present, all fields will be + updated. + + This corresponds to the ``update_mask`` 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.recaptchaenterprise_v1.types.FirewallPolicy: + A FirewallPolicy represents a single + matching pattern and resulting actions + to take. + + """ + # 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([firewall_policy, update_mask]) + 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 = recaptchaenterprise.UpdateFirewallPolicyRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if firewall_policy is not None: + request.firewall_policy = firewall_policy + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.update_firewall_policy, + 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( + (("firewall_policy.name", request.firewall_policy.name),) + ), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def delete_firewall_policy( + self, + request: Optional[ + Union[recaptchaenterprise.DeleteFirewallPolicyRequest, dict] + ] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes the specified firewall policy. + + .. 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 recaptchaenterprise_v1 + + async def sample_delete_firewall_policy(): + # Create a client + client = recaptchaenterprise_v1.RecaptchaEnterpriseServiceAsyncClient() + + # Initialize request argument(s) + request = recaptchaenterprise_v1.DeleteFirewallPolicyRequest( + name="name_value", + ) + + # Make the request + await client.delete_firewall_policy(request=request) + + Args: + request (Optional[Union[google.cloud.recaptchaenterprise_v1.types.DeleteFirewallPolicyRequest, dict]]): + The request object. The delete firewall policy request + message. + name (:class:`str`): + Required. The name of the policy to be deleted, in the + format + ``projects/{project}/firewallpolicies/{firewallpolicy}``. + + This corresponds to the ``name`` 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. + """ + # 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([name]) + 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 = recaptchaenterprise.DeleteFirewallPolicyRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.delete_firewall_policy, + 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((("name", request.name),)), + ) + + # Send the request. + await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + async def list_related_account_groups( self, request: Optional[ @@ -1364,9 +1914,9 @@ async def sample_list_related_account_groups(): The request object. The request message to list related account groups. parent (:class:`str`): - Required. The name of the project to - list related account groups from, in the - format "projects/{project}". + Required. The name of the project to list related + account groups from, in the format + ``projects/{project}``. This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this @@ -1600,22 +2150,18 @@ async def sample_search_related_account_group_memberships(): The request object. The request message to search related account group memberships. project (:class:`str`): - Required. The name of the project to - search related account group memberships - from. Specify the project name in the - following format: - - "projects/{project}". + Required. The name of the project to search related + account group memberships from. Specify the project name + in the following format: ``projects/{project}``. This corresponds to the ``project`` field on the ``request`` instance; if ``request`` is provided, this should not be set. hashed_account_id (:class:`bytes`): - Optional. The unique stable hashed user identifier we - should search connections to. The identifier should - correspond to a ``hashed_account_id`` provided in a - previous ``CreateAssessment`` or ``AnnotateAssessment`` - call. + Optional. The unique stable hashed user identifier used + to search connections. The identifier should correspond + to a ``hashed_account_id`` provided in a previous + ``CreateAssessment`` or ``AnnotateAssessment`` call. This corresponds to the ``hashed_account_id`` field on the ``request`` instance; if ``request`` is provided, this diff --git a/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/client.py b/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/client.py index 5348ff22c6e3..48b517e811d8 100644 --- a/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/client.py +++ b/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/client.py @@ -199,6 +199,26 @@ def parse_assessment_path(path: str) -> Dict[str, str]: ) return m.groupdict() if m else {} + @staticmethod + def firewall_policy_path( + project: str, + firewallpolicy: str, + ) -> str: + """Returns a fully-qualified firewall_policy string.""" + return "projects/{project}/firewallpolicies/{firewallpolicy}".format( + project=project, + firewallpolicy=firewallpolicy, + ) + + @staticmethod + def parse_firewall_policy_path(path: str) -> Dict[str, str]: + """Parses a firewall_policy path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/firewallpolicies/(?P.+?)$", + path, + ) + return m.groupdict() if m else {} + @staticmethod def key_path( project: str, @@ -565,9 +585,9 @@ def sample_create_assessment(): The request object. The create assessment request message. parent (str): - Required. The name of the project in - which the assessment will be created, in - the format "projects/{project}". + Required. The name of the project in which the + assessment will be created, in the format + ``projects/{project}``. This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this @@ -682,9 +702,8 @@ def sample_annotate_assessment(): The request object. The request message to annotate an Assessment. name (str): - Required. The resource name of the - Assessment, in the format - "projects/{project}/assessments/{assessment}". + Required. The resource name of the Assessment, in the + format ``projects/{project}/assessments/{assessment}``. This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this @@ -801,9 +820,8 @@ def sample_create_key(): request (Union[google.cloud.recaptchaenterprise_v1.types.CreateKeyRequest, dict]): The request object. The create key request message. parent (str): - Required. The name of the project in - which the key will be created, in the - format "projects/{project}". + Required. The name of the project in which the key will + be created, in the format ``projects/{project}``. This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this @@ -915,10 +933,9 @@ def sample_list_keys(): request (Union[google.cloud.recaptchaenterprise_v1.types.ListKeysRequest, dict]): The request object. The list keys request message. parent (str): - Required. The name of the project - that contains the keys that will be - listed, in the format - "projects/{project}". + Required. The name of the project that contains the keys + that will be listed, in the format + ``projects/{project}``. This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this @@ -1035,9 +1052,9 @@ def sample_retrieve_legacy_secret_key(): The request object. The retrieve legacy secret key request message. key (str): - Required. The public key name linked - to the requested secret key in the - format "projects/{project}/keys/{key}". + Required. The public key name linked to the requested + secret key in the format + ``projects/{project}/keys/{key}``. This corresponds to the ``key`` field on the ``request`` instance; if ``request`` is provided, this @@ -1140,9 +1157,8 @@ def sample_get_key(): request (Union[google.cloud.recaptchaenterprise_v1.types.GetKeyRequest, dict]): The request object. The get key request message. name (str): - Required. The name of the requested - key, in the format - "projects/{project}/keys/{key}". + Required. The name of the requested key, in the format + ``projects/{project}/keys/{key}``. This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this @@ -1355,9 +1371,8 @@ def sample_delete_key(): request (Union[google.cloud.recaptchaenterprise_v1.types.DeleteKeyRequest, dict]): The request object. The delete key request message. name (str): - Required. The name of the key to be - deleted, in the format - "projects/{project}/keys/{key}". + Required. The name of the key to be deleted, in the + format ``projects/{project}/keys/{key}``. This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this @@ -1419,9 +1434,9 @@ def migrate_key( Enterprise. Once a key is migrated, it can be used from either product. SiteVerify requests are billed as CreateAssessment calls. You must be authenticated as one - of the current owners of the reCAPTCHA Site Key, and - your user must have the reCAPTCHA Enterprise Admin IAM - role in the destination project. + of the current owners of the reCAPTCHA Key, and your + user must have the reCAPTCHA Enterprise Admin IAM role + in the destination project. .. code-block:: python @@ -1536,9 +1551,8 @@ def sample_get_metrics(): request (Union[google.cloud.recaptchaenterprise_v1.types.GetMetricsRequest, dict]): The request object. The get metrics request message. name (str): - Required. The name of the requested - metrics, in the format - "projects/{project}/keys/{key}/metrics". + Required. The name of the requested metrics, in the + format ``projects/{project}/keys/{key}/metrics``. This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this @@ -1595,6 +1609,556 @@ def sample_get_metrics(): # Done; return the response. return response + def create_firewall_policy( + self, + request: Optional[ + Union[recaptchaenterprise.CreateFirewallPolicyRequest, dict] + ] = None, + *, + parent: Optional[str] = None, + firewall_policy: Optional[recaptchaenterprise.FirewallPolicy] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> recaptchaenterprise.FirewallPolicy: + r"""Creates a new FirewallPolicy, specifying conditions + at which reCAPTCHA Enterprise actions can be executed. A + project may have a maximum of 1000 policies. + + .. 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 recaptchaenterprise_v1 + + def sample_create_firewall_policy(): + # Create a client + client = recaptchaenterprise_v1.RecaptchaEnterpriseServiceClient() + + # Initialize request argument(s) + request = recaptchaenterprise_v1.CreateFirewallPolicyRequest( + parent="parent_value", + ) + + # Make the request + response = client.create_firewall_policy(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.recaptchaenterprise_v1.types.CreateFirewallPolicyRequest, dict]): + The request object. The create firewall policy request + message. + parent (str): + Required. The name of the project this policy will apply + to, in the format ``projects/{project}``. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + firewall_policy (google.cloud.recaptchaenterprise_v1.types.FirewallPolicy): + Required. Information to create the + policy. + + This corresponds to the ``firewall_policy`` 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.recaptchaenterprise_v1.types.FirewallPolicy: + A FirewallPolicy represents a single + matching pattern and resulting actions + to take. + + """ + # 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, firewall_policy]) + 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." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a recaptchaenterprise.CreateFirewallPolicyRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, recaptchaenterprise.CreateFirewallPolicyRequest): + request = recaptchaenterprise.CreateFirewallPolicyRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if firewall_policy is not None: + request.firewall_policy = firewall_policy + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_firewall_policy] + + # 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 = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def list_firewall_policies( + self, + request: Optional[ + Union[recaptchaenterprise.ListFirewallPoliciesRequest, dict] + ] = None, + *, + parent: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> pagers.ListFirewallPoliciesPager: + r"""Returns the list of all firewall policies that belong + to a project. + + .. 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 recaptchaenterprise_v1 + + def sample_list_firewall_policies(): + # Create a client + client = recaptchaenterprise_v1.RecaptchaEnterpriseServiceClient() + + # Initialize request argument(s) + request = recaptchaenterprise_v1.ListFirewallPoliciesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_firewall_policies(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.recaptchaenterprise_v1.types.ListFirewallPoliciesRequest, dict]): + The request object. The list firewall policies request + message. + parent (str): + Required. The name of the project to list the policies + for, in the format ``projects/{project}``. + + This corresponds to the ``parent`` 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.recaptchaenterprise_v1.services.recaptcha_enterprise_service.pagers.ListFirewallPoliciesPager: + Response to request to list firewall + policies belonging to a key. + Iterating over this object will yield + results and resolve additional pages + automatically. + + """ + # 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]) + 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." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a recaptchaenterprise.ListFirewallPoliciesRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, recaptchaenterprise.ListFirewallPoliciesRequest): + request = recaptchaenterprise.ListFirewallPoliciesRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.list_firewall_policies] + + # 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 = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # This method is paged; wrap the response in a pager, which provides + # an `__iter__` convenience method. + response = pagers.ListFirewallPoliciesPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_firewall_policy( + self, + request: Optional[ + Union[recaptchaenterprise.GetFirewallPolicyRequest, dict] + ] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> recaptchaenterprise.FirewallPolicy: + r"""Returns the specified firewall policy. + + .. 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 recaptchaenterprise_v1 + + def sample_get_firewall_policy(): + # Create a client + client = recaptchaenterprise_v1.RecaptchaEnterpriseServiceClient() + + # Initialize request argument(s) + request = recaptchaenterprise_v1.GetFirewallPolicyRequest( + name="name_value", + ) + + # Make the request + response = client.get_firewall_policy(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.recaptchaenterprise_v1.types.GetFirewallPolicyRequest, dict]): + The request object. The get firewall policy request + message. + name (str): + Required. The name of the requested policy, in the + format + ``projects/{project}/firewallpolicies/{firewallpolicy}``. + + This corresponds to the ``name`` 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.recaptchaenterprise_v1.types.FirewallPolicy: + A FirewallPolicy represents a single + matching pattern and resulting actions + to take. + + """ + # 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([name]) + 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." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a recaptchaenterprise.GetFirewallPolicyRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, recaptchaenterprise.GetFirewallPolicyRequest): + request = recaptchaenterprise.GetFirewallPolicyRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.get_firewall_policy] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def update_firewall_policy( + self, + request: Optional[ + Union[recaptchaenterprise.UpdateFirewallPolicyRequest, dict] + ] = None, + *, + firewall_policy: Optional[recaptchaenterprise.FirewallPolicy] = None, + update_mask: Optional[field_mask_pb2.FieldMask] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> recaptchaenterprise.FirewallPolicy: + r"""Updates the specified firewall policy. + + .. 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 recaptchaenterprise_v1 + + def sample_update_firewall_policy(): + # Create a client + client = recaptchaenterprise_v1.RecaptchaEnterpriseServiceClient() + + # Initialize request argument(s) + request = recaptchaenterprise_v1.UpdateFirewallPolicyRequest( + ) + + # Make the request + response = client.update_firewall_policy(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.recaptchaenterprise_v1.types.UpdateFirewallPolicyRequest, dict]): + The request object. The update firewall policy request + message. + firewall_policy (google.cloud.recaptchaenterprise_v1.types.FirewallPolicy): + Required. The policy to update. + This corresponds to the ``firewall_policy`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Optional. The mask to control which + fields of the policy get updated. If the + mask is not present, all fields will be + updated. + + This corresponds to the ``update_mask`` 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.recaptchaenterprise_v1.types.FirewallPolicy: + A FirewallPolicy represents a single + matching pattern and resulting actions + to take. + + """ + # 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([firewall_policy, update_mask]) + 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." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a recaptchaenterprise.UpdateFirewallPolicyRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, recaptchaenterprise.UpdateFirewallPolicyRequest): + request = recaptchaenterprise.UpdateFirewallPolicyRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if firewall_policy is not None: + request.firewall_policy = firewall_policy + if update_mask is not None: + request.update_mask = update_mask + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.update_firewall_policy] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("firewall_policy.name", request.firewall_policy.name),) + ), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def delete_firewall_policy( + self, + request: Optional[ + Union[recaptchaenterprise.DeleteFirewallPolicyRequest, dict] + ] = None, + *, + name: Optional[str] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> None: + r"""Deletes the specified firewall policy. + + .. 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 recaptchaenterprise_v1 + + def sample_delete_firewall_policy(): + # Create a client + client = recaptchaenterprise_v1.RecaptchaEnterpriseServiceClient() + + # Initialize request argument(s) + request = recaptchaenterprise_v1.DeleteFirewallPolicyRequest( + name="name_value", + ) + + # Make the request + client.delete_firewall_policy(request=request) + + Args: + request (Union[google.cloud.recaptchaenterprise_v1.types.DeleteFirewallPolicyRequest, dict]): + The request object. The delete firewall policy request + message. + name (str): + Required. The name of the policy to be deleted, in the + format + ``projects/{project}/firewallpolicies/{firewallpolicy}``. + + This corresponds to the ``name`` 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. + """ + # 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([name]) + 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." + ) + + # Minor optimization to avoid making a copy if the user passes + # in a recaptchaenterprise.DeleteFirewallPolicyRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, recaptchaenterprise.DeleteFirewallPolicyRequest): + request = recaptchaenterprise.DeleteFirewallPolicyRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if name is not None: + request.name = name + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.delete_firewall_policy] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)), + ) + + # Send the request. + rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + def list_related_account_groups( self, request: Optional[ @@ -1640,9 +2204,9 @@ def sample_list_related_account_groups(): The request object. The request message to list related account groups. parent (str): - Required. The name of the project to - list related account groups from, in the - format "projects/{project}". + Required. The name of the project to list related + account groups from, in the format + ``projects/{project}``. This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this @@ -1884,22 +2448,18 @@ def sample_search_related_account_group_memberships(): The request object. The request message to search related account group memberships. project (str): - Required. The name of the project to - search related account group memberships - from. Specify the project name in the - following format: - - "projects/{project}". + Required. The name of the project to search related + account group memberships from. Specify the project name + in the following format: ``projects/{project}``. This corresponds to the ``project`` field on the ``request`` instance; if ``request`` is provided, this should not be set. hashed_account_id (bytes): - Optional. The unique stable hashed user identifier we - should search connections to. The identifier should - correspond to a ``hashed_account_id`` provided in a - previous ``CreateAssessment`` or ``AnnotateAssessment`` - call. + Optional. The unique stable hashed user identifier used + to search connections. The identifier should correspond + to a ``hashed_account_id`` provided in a previous + ``CreateAssessment`` or ``AnnotateAssessment`` call. This corresponds to the ``hashed_account_id`` field on the ``request`` instance; if ``request`` is provided, this diff --git a/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/pagers.py b/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/pagers.py index 5aa75952eca7..f655a3b12f6c 100644 --- a/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/pagers.py +++ b/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/pagers.py @@ -155,6 +155,138 @@ def __repr__(self) -> str: return "{0}<{1!r}>".format(self.__class__.__name__, self._response) +class ListFirewallPoliciesPager: + """A pager for iterating through ``list_firewall_policies`` requests. + + This class thinly wraps an initial + :class:`google.cloud.recaptchaenterprise_v1.types.ListFirewallPoliciesResponse` object, and + provides an ``__iter__`` method to iterate through its + ``firewall_policies`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListFirewallPolicies`` requests and continue to iterate + through the ``firewall_policies`` field on the + corresponding responses. + + All the usual :class:`google.cloud.recaptchaenterprise_v1.types.ListFirewallPoliciesResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[..., recaptchaenterprise.ListFirewallPoliciesResponse], + request: recaptchaenterprise.ListFirewallPoliciesRequest, + response: recaptchaenterprise.ListFirewallPoliciesResponse, + *, + metadata: Sequence[Tuple[str, str]] = () + ): + """Instantiate the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.recaptchaenterprise_v1.types.ListFirewallPoliciesRequest): + The initial request object. + response (google.cloud.recaptchaenterprise_v1.types.ListFirewallPoliciesResponse): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = recaptchaenterprise.ListFirewallPoliciesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[recaptchaenterprise.ListFirewallPoliciesResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = self._method(self._request, metadata=self._metadata) + yield self._response + + def __iter__(self) -> Iterator[recaptchaenterprise.FirewallPolicy]: + for page in self.pages: + yield from page.firewall_policies + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + +class ListFirewallPoliciesAsyncPager: + """A pager for iterating through ``list_firewall_policies`` requests. + + This class thinly wraps an initial + :class:`google.cloud.recaptchaenterprise_v1.types.ListFirewallPoliciesResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``firewall_policies`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListFirewallPolicies`` requests and continue to iterate + through the ``firewall_policies`` field on the + corresponding responses. + + All the usual :class:`google.cloud.recaptchaenterprise_v1.types.ListFirewallPoliciesResponse` + attributes are available on the pager. If multiple requests are made, only + the most recent response is retained, and thus used for attribute lookup. + """ + + def __init__( + self, + method: Callable[ + ..., Awaitable[recaptchaenterprise.ListFirewallPoliciesResponse] + ], + request: recaptchaenterprise.ListFirewallPoliciesRequest, + response: recaptchaenterprise.ListFirewallPoliciesResponse, + *, + metadata: Sequence[Tuple[str, str]] = () + ): + """Instantiates the pager. + + Args: + method (Callable): The method that was originally called, and + which instantiated this pager. + request (google.cloud.recaptchaenterprise_v1.types.ListFirewallPoliciesRequest): + The initial request object. + response (google.cloud.recaptchaenterprise_v1.types.ListFirewallPoliciesResponse): + The initial response object. + metadata (Sequence[Tuple[str, str]]): Strings which should be + sent along with the request as metadata. + """ + self._method = method + self._request = recaptchaenterprise.ListFirewallPoliciesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages( + self, + ) -> AsyncIterator[recaptchaenterprise.ListFirewallPoliciesResponse]: + yield self._response + while self._response.next_page_token: + self._request.page_token = self._response.next_page_token + self._response = await self._method(self._request, metadata=self._metadata) + yield self._response + + def __aiter__(self) -> AsyncIterator[recaptchaenterprise.FirewallPolicy]: + async def async_generator(): + async for page in self.pages: + for response in page.firewall_policies: + yield response + + return async_generator() + + def __repr__(self) -> str: + return "{0}<{1!r}>".format(self.__class__.__name__, self._response) + + class ListRelatedAccountGroupsPager: """A pager for iterating through ``list_related_account_groups`` requests. diff --git a/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/transports/base.py b/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/transports/base.py index bb7ff15a7dd1..868f6e283331 100644 --- a/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/transports/base.py +++ b/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/transports/base.py @@ -173,6 +173,31 @@ def _prep_wrapped_messages(self, client_info): default_timeout=None, client_info=client_info, ), + self.create_firewall_policy: gapic_v1.method.wrap_method( + self.create_firewall_policy, + default_timeout=None, + client_info=client_info, + ), + self.list_firewall_policies: gapic_v1.method.wrap_method( + self.list_firewall_policies, + default_timeout=None, + client_info=client_info, + ), + self.get_firewall_policy: gapic_v1.method.wrap_method( + self.get_firewall_policy, + default_timeout=None, + client_info=client_info, + ), + self.update_firewall_policy: gapic_v1.method.wrap_method( + self.update_firewall_policy, + default_timeout=None, + client_info=client_info, + ), + self.delete_firewall_policy: gapic_v1.method.wrap_method( + self.delete_firewall_policy, + default_timeout=None, + client_info=client_info, + ), self.list_related_account_groups: gapic_v1.method.wrap_method( self.list_related_account_groups, default_timeout=None, @@ -300,6 +325,63 @@ def get_metrics( ]: raise NotImplementedError() + @property + def create_firewall_policy( + self, + ) -> Callable[ + [recaptchaenterprise.CreateFirewallPolicyRequest], + Union[ + recaptchaenterprise.FirewallPolicy, + Awaitable[recaptchaenterprise.FirewallPolicy], + ], + ]: + raise NotImplementedError() + + @property + def list_firewall_policies( + self, + ) -> Callable[ + [recaptchaenterprise.ListFirewallPoliciesRequest], + Union[ + recaptchaenterprise.ListFirewallPoliciesResponse, + Awaitable[recaptchaenterprise.ListFirewallPoliciesResponse], + ], + ]: + raise NotImplementedError() + + @property + def get_firewall_policy( + self, + ) -> Callable[ + [recaptchaenterprise.GetFirewallPolicyRequest], + Union[ + recaptchaenterprise.FirewallPolicy, + Awaitable[recaptchaenterprise.FirewallPolicy], + ], + ]: + raise NotImplementedError() + + @property + def update_firewall_policy( + self, + ) -> Callable[ + [recaptchaenterprise.UpdateFirewallPolicyRequest], + Union[ + recaptchaenterprise.FirewallPolicy, + Awaitable[recaptchaenterprise.FirewallPolicy], + ], + ]: + raise NotImplementedError() + + @property + def delete_firewall_policy( + self, + ) -> Callable[ + [recaptchaenterprise.DeleteFirewallPolicyRequest], + Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]], + ]: + raise NotImplementedError() + @property def list_related_account_groups( self, diff --git a/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/transports/grpc.py b/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/transports/grpc.py index 5ee23e7652c9..0bafcd582da8 100644 --- a/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/transports/grpc.py +++ b/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/transports/grpc.py @@ -463,9 +463,9 @@ def migrate_key( Enterprise. Once a key is migrated, it can be used from either product. SiteVerify requests are billed as CreateAssessment calls. You must be authenticated as one - of the current owners of the reCAPTCHA Site Key, and - your user must have the reCAPTCHA Enterprise Admin IAM - role in the destination project. + of the current owners of the reCAPTCHA Key, and your + user must have the reCAPTCHA Enterprise Admin IAM role + in the destination project. Returns: Callable[[~.MigrateKeyRequest], @@ -512,6 +512,151 @@ def get_metrics( ) return self._stubs["get_metrics"] + @property + def create_firewall_policy( + self, + ) -> Callable[ + [recaptchaenterprise.CreateFirewallPolicyRequest], + recaptchaenterprise.FirewallPolicy, + ]: + r"""Return a callable for the create firewall policy method over gRPC. + + Creates a new FirewallPolicy, specifying conditions + at which reCAPTCHA Enterprise actions can be executed. A + project may have a maximum of 1000 policies. + + Returns: + Callable[[~.CreateFirewallPolicyRequest], + ~.FirewallPolicy]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "create_firewall_policy" not in self._stubs: + self._stubs["create_firewall_policy"] = self.grpc_channel.unary_unary( + "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/CreateFirewallPolicy", + request_serializer=recaptchaenterprise.CreateFirewallPolicyRequest.serialize, + response_deserializer=recaptchaenterprise.FirewallPolicy.deserialize, + ) + return self._stubs["create_firewall_policy"] + + @property + def list_firewall_policies( + self, + ) -> Callable[ + [recaptchaenterprise.ListFirewallPoliciesRequest], + recaptchaenterprise.ListFirewallPoliciesResponse, + ]: + r"""Return a callable for the list firewall policies method over gRPC. + + Returns the list of all firewall policies that belong + to a project. + + Returns: + Callable[[~.ListFirewallPoliciesRequest], + ~.ListFirewallPoliciesResponse]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_firewall_policies" not in self._stubs: + self._stubs["list_firewall_policies"] = self.grpc_channel.unary_unary( + "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/ListFirewallPolicies", + request_serializer=recaptchaenterprise.ListFirewallPoliciesRequest.serialize, + response_deserializer=recaptchaenterprise.ListFirewallPoliciesResponse.deserialize, + ) + return self._stubs["list_firewall_policies"] + + @property + def get_firewall_policy( + self, + ) -> Callable[ + [recaptchaenterprise.GetFirewallPolicyRequest], + recaptchaenterprise.FirewallPolicy, + ]: + r"""Return a callable for the get firewall policy method over gRPC. + + Returns the specified firewall policy. + + Returns: + Callable[[~.GetFirewallPolicyRequest], + ~.FirewallPolicy]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_firewall_policy" not in self._stubs: + self._stubs["get_firewall_policy"] = self.grpc_channel.unary_unary( + "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/GetFirewallPolicy", + request_serializer=recaptchaenterprise.GetFirewallPolicyRequest.serialize, + response_deserializer=recaptchaenterprise.FirewallPolicy.deserialize, + ) + return self._stubs["get_firewall_policy"] + + @property + def update_firewall_policy( + self, + ) -> Callable[ + [recaptchaenterprise.UpdateFirewallPolicyRequest], + recaptchaenterprise.FirewallPolicy, + ]: + r"""Return a callable for the update firewall policy method over gRPC. + + Updates the specified firewall policy. + + Returns: + Callable[[~.UpdateFirewallPolicyRequest], + ~.FirewallPolicy]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "update_firewall_policy" not in self._stubs: + self._stubs["update_firewall_policy"] = self.grpc_channel.unary_unary( + "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/UpdateFirewallPolicy", + request_serializer=recaptchaenterprise.UpdateFirewallPolicyRequest.serialize, + response_deserializer=recaptchaenterprise.FirewallPolicy.deserialize, + ) + return self._stubs["update_firewall_policy"] + + @property + def delete_firewall_policy( + self, + ) -> Callable[[recaptchaenterprise.DeleteFirewallPolicyRequest], empty_pb2.Empty]: + r"""Return a callable for the delete firewall policy method over gRPC. + + Deletes the specified firewall policy. + + Returns: + Callable[[~.DeleteFirewallPolicyRequest], + ~.Empty]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "delete_firewall_policy" not in self._stubs: + self._stubs["delete_firewall_policy"] = self.grpc_channel.unary_unary( + "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/DeleteFirewallPolicy", + request_serializer=recaptchaenterprise.DeleteFirewallPolicyRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs["delete_firewall_policy"] + @property def list_related_account_groups( self, diff --git a/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/transports/grpc_asyncio.py b/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/transports/grpc_asyncio.py index f9f6a740ec24..850bd9deb908 100644 --- a/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/transports/grpc_asyncio.py @@ -478,9 +478,9 @@ def migrate_key( Enterprise. Once a key is migrated, it can be used from either product. SiteVerify requests are billed as CreateAssessment calls. You must be authenticated as one - of the current owners of the reCAPTCHA Site Key, and - your user must have the reCAPTCHA Enterprise Admin IAM - role in the destination project. + of the current owners of the reCAPTCHA Key, and your + user must have the reCAPTCHA Enterprise Admin IAM role + in the destination project. Returns: Callable[[~.MigrateKeyRequest], @@ -529,6 +529,153 @@ def get_metrics( ) return self._stubs["get_metrics"] + @property + def create_firewall_policy( + self, + ) -> Callable[ + [recaptchaenterprise.CreateFirewallPolicyRequest], + Awaitable[recaptchaenterprise.FirewallPolicy], + ]: + r"""Return a callable for the create firewall policy method over gRPC. + + Creates a new FirewallPolicy, specifying conditions + at which reCAPTCHA Enterprise actions can be executed. A + project may have a maximum of 1000 policies. + + Returns: + Callable[[~.CreateFirewallPolicyRequest], + Awaitable[~.FirewallPolicy]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "create_firewall_policy" not in self._stubs: + self._stubs["create_firewall_policy"] = self.grpc_channel.unary_unary( + "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/CreateFirewallPolicy", + request_serializer=recaptchaenterprise.CreateFirewallPolicyRequest.serialize, + response_deserializer=recaptchaenterprise.FirewallPolicy.deserialize, + ) + return self._stubs["create_firewall_policy"] + + @property + def list_firewall_policies( + self, + ) -> Callable[ + [recaptchaenterprise.ListFirewallPoliciesRequest], + Awaitable[recaptchaenterprise.ListFirewallPoliciesResponse], + ]: + r"""Return a callable for the list firewall policies method over gRPC. + + Returns the list of all firewall policies that belong + to a project. + + Returns: + Callable[[~.ListFirewallPoliciesRequest], + Awaitable[~.ListFirewallPoliciesResponse]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "list_firewall_policies" not in self._stubs: + self._stubs["list_firewall_policies"] = self.grpc_channel.unary_unary( + "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/ListFirewallPolicies", + request_serializer=recaptchaenterprise.ListFirewallPoliciesRequest.serialize, + response_deserializer=recaptchaenterprise.ListFirewallPoliciesResponse.deserialize, + ) + return self._stubs["list_firewall_policies"] + + @property + def get_firewall_policy( + self, + ) -> Callable[ + [recaptchaenterprise.GetFirewallPolicyRequest], + Awaitable[recaptchaenterprise.FirewallPolicy], + ]: + r"""Return a callable for the get firewall policy method over gRPC. + + Returns the specified firewall policy. + + Returns: + Callable[[~.GetFirewallPolicyRequest], + Awaitable[~.FirewallPolicy]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "get_firewall_policy" not in self._stubs: + self._stubs["get_firewall_policy"] = self.grpc_channel.unary_unary( + "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/GetFirewallPolicy", + request_serializer=recaptchaenterprise.GetFirewallPolicyRequest.serialize, + response_deserializer=recaptchaenterprise.FirewallPolicy.deserialize, + ) + return self._stubs["get_firewall_policy"] + + @property + def update_firewall_policy( + self, + ) -> Callable[ + [recaptchaenterprise.UpdateFirewallPolicyRequest], + Awaitable[recaptchaenterprise.FirewallPolicy], + ]: + r"""Return a callable for the update firewall policy method over gRPC. + + Updates the specified firewall policy. + + Returns: + Callable[[~.UpdateFirewallPolicyRequest], + Awaitable[~.FirewallPolicy]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "update_firewall_policy" not in self._stubs: + self._stubs["update_firewall_policy"] = self.grpc_channel.unary_unary( + "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/UpdateFirewallPolicy", + request_serializer=recaptchaenterprise.UpdateFirewallPolicyRequest.serialize, + response_deserializer=recaptchaenterprise.FirewallPolicy.deserialize, + ) + return self._stubs["update_firewall_policy"] + + @property + def delete_firewall_policy( + self, + ) -> Callable[ + [recaptchaenterprise.DeleteFirewallPolicyRequest], Awaitable[empty_pb2.Empty] + ]: + r"""Return a callable for the delete firewall policy method over gRPC. + + Deletes the specified firewall policy. + + Returns: + Callable[[~.DeleteFirewallPolicyRequest], + Awaitable[~.Empty]]: + A function that, when called, will call the underlying RPC + on the server. + """ + # Generate a "stub function" on-the-fly which will actually make + # the request. + # gRPC handles serialization and deserialization, so we just need + # to pass in the functions for each. + if "delete_firewall_policy" not in self._stubs: + self._stubs["delete_firewall_policy"] = self.grpc_channel.unary_unary( + "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/DeleteFirewallPolicy", + request_serializer=recaptchaenterprise.DeleteFirewallPolicyRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs["delete_firewall_policy"] + @property def list_related_account_groups( self, diff --git a/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/types/__init__.py b/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/types/__init__.py index 48fc54ce2021..a5376011d620 100644 --- a/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/types/__init__.py +++ b/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/types/__init__.py @@ -19,18 +19,28 @@ AndroidKeySettings, AnnotateAssessmentRequest, AnnotateAssessmentResponse, + AppleDeveloperId, Assessment, ChallengeMetrics, CreateAssessmentRequest, + CreateFirewallPolicyRequest, CreateKeyRequest, + DeleteFirewallPolicyRequest, DeleteKeyRequest, EndpointVerificationInfo, Event, + FirewallAction, + FirewallPolicy, + FirewallPolicyAssessment, FraudPreventionAssessment, + FraudSignals, + GetFirewallPolicyRequest, GetKeyRequest, GetMetricsRequest, IOSKeySettings, Key, + ListFirewallPoliciesRequest, + ListFirewallPoliciesResponse, ListKeysRequest, ListKeysResponse, ListRelatedAccountGroupMembershipsRequest, @@ -53,6 +63,7 @@ TokenProperties, TransactionData, TransactionEvent, + UpdateFirewallPolicyRequest, UpdateKeyRequest, WafSettings, WebKeySettings, @@ -64,18 +75,28 @@ "AndroidKeySettings", "AnnotateAssessmentRequest", "AnnotateAssessmentResponse", + "AppleDeveloperId", "Assessment", "ChallengeMetrics", "CreateAssessmentRequest", + "CreateFirewallPolicyRequest", "CreateKeyRequest", + "DeleteFirewallPolicyRequest", "DeleteKeyRequest", "EndpointVerificationInfo", "Event", + "FirewallAction", + "FirewallPolicy", + "FirewallPolicyAssessment", "FraudPreventionAssessment", + "FraudSignals", + "GetFirewallPolicyRequest", "GetKeyRequest", "GetMetricsRequest", "IOSKeySettings", "Key", + "ListFirewallPoliciesRequest", + "ListFirewallPoliciesResponse", "ListKeysRequest", "ListKeysResponse", "ListRelatedAccountGroupMembershipsRequest", @@ -98,6 +119,7 @@ "TokenProperties", "TransactionData", "TransactionEvent", + "UpdateFirewallPolicyRequest", "UpdateKeyRequest", "WafSettings", "WebKeySettings", diff --git a/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/types/recaptchaenterprise.py b/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/types/recaptchaenterprise.py index 0979b8caabdb..177d365f6303 100644 --- a/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/types/recaptchaenterprise.py +++ b/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/types/recaptchaenterprise.py @@ -19,6 +19,7 @@ from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore +from google.rpc import status_pb2 # type: ignore import proto # type: ignore __protobuf__ = proto.module( @@ -37,6 +38,7 @@ "RiskAnalysis", "TokenProperties", "FraudPreventionAssessment", + "FraudSignals", "AccountDefenderAssessment", "CreateKeyRequest", "ListKeysRequest", @@ -45,6 +47,12 @@ "GetKeyRequest", "UpdateKeyRequest", "DeleteKeyRequest", + "CreateFirewallPolicyRequest", + "ListFirewallPoliciesRequest", + "ListFirewallPoliciesResponse", + "GetFirewallPolicyRequest", + "UpdateFirewallPolicyRequest", + "DeleteFirewallPolicyRequest", "MigrateKeyRequest", "GetMetricsRequest", "Metrics", @@ -54,9 +62,13 @@ "WebKeySettings", "AndroidKeySettings", "IOSKeySettings", + "AppleDeveloperId", "ScoreDistribution", "ScoreMetrics", "ChallengeMetrics", + "FirewallPolicyAssessment", + "FirewallAction", + "FirewallPolicy", "ListRelatedAccountGroupMembershipsRequest", "ListRelatedAccountGroupMembershipsResponse", "ListRelatedAccountGroupsRequest", @@ -75,9 +87,8 @@ class CreateAssessmentRequest(proto.Message): Attributes: parent (str): - Required. The name of the project in which - the assessment will be created, in the format - "projects/{project}". + Required. The name of the project in which the assessment + will be created, in the format ``projects/{project}``. assessment (google.cloud.recaptchaenterprise_v1.types.Assessment): Required. The assessment details. """ @@ -257,9 +268,8 @@ class AnnotateAssessmentRequest(proto.Message): Attributes: name (str): - Required. The resource name of the - Assessment, in the format - "projects/{project}/assessments/{assessment}". + Required. The resource name of the Assessment, in the format + ``projects/{project}/assessments/{assessment}``. annotation (google.cloud.recaptchaenterprise_v1.types.AnnotateAssessmentRequest.Annotation): Optional. The annotation that will be assigned to the Event. This field can be left @@ -617,9 +627,8 @@ class Assessment(proto.Message): Attributes: name (str): - Output only. The resource name for the - Assessment in the format - "projects/{project}/assessments/{assessment}". + Output only. The resource name for the Assessment in the + format ``projects/{project}/assessments/{assessment}``. event (google.cloud.recaptchaenterprise_v1.types.Event): The event being assessed. risk_analysis (google.cloud.recaptchaenterprise_v1.types.RiskAnalysis): @@ -640,9 +649,16 @@ class Assessment(proto.Message): contains the parameters that are used to to check for leaks privately without sharing user credentials. + firewall_policy_assessment (google.cloud.recaptchaenterprise_v1.types.FirewallPolicyAssessment): + Assessment returned when firewall policies belonging to the + project are evaluated using the field + firewall_policy_evaluation. fraud_prevention_assessment (google.cloud.recaptchaenterprise_v1.types.FraudPreventionAssessment): Assessment returned by Fraud Prevention when TransactionData is provided. + fraud_signals (google.cloud.recaptchaenterprise_v1.types.FraudSignals): + Output only. Fraud Signals specific to the + users involved in a payment transaction. """ name: str = proto.Field( @@ -679,11 +695,21 @@ class Assessment(proto.Message): number=8, message="PrivatePasswordLeakVerification", ) + firewall_policy_assessment: "FirewallPolicyAssessment" = proto.Field( + proto.MESSAGE, + number=10, + message="FirewallPolicyAssessment", + ) fraud_prevention_assessment: "FraudPreventionAssessment" = proto.Field( proto.MESSAGE, number=11, message="FraudPreventionAssessment", ) + fraud_signals: "FraudSignals" = proto.Field( + proto.MESSAGE, + number=13, + message="FraudSignals", + ) class Event(proto.Message): @@ -715,6 +741,30 @@ class Event(proto.Message): Optional. Unique stable hashed user identifier for the request. The identifier must be hashed using hmac-sha256 with stable secret. + express (bool): + Optional. Flag for a reCAPTCHA express request for an + assessment without a token. If enabled, ``site_key`` must + reference a SCORE key with WAF feature set to EXPRESS. + requested_uri (str): + Optional. The URI resource the user requested + that triggered an assessment. + waf_token_assessment (bool): + Optional. Flag for running WAF token + assessment. If enabled, the token must be + specified, and have been created by a + WAF-enabled key. + ja3 (str): + Optional. Optional JA3 fingerprint for SSL + clients. + headers (MutableSequence[str]): + Optional. HTTP header information about the + request. + firewall_policy_evaluation (bool): + Optional. Flag for enabling firewall policy + config assessment. If this flag is enabled, the + firewall policy will be evaluated and a + suggested firewall action will be returned in + the response. transaction_data (google.cloud.recaptchaenterprise_v1.types.TransactionData): Optional. Data describing a payment transaction to be assessed. Sending this data @@ -747,6 +797,30 @@ class Event(proto.Message): proto.BYTES, number=6, ) + express: bool = proto.Field( + proto.BOOL, + number=14, + ) + requested_uri: str = proto.Field( + proto.STRING, + number=8, + ) + waf_token_assessment: bool = proto.Field( + proto.BOOL, + number=9, + ) + ja3: str = proto.Field( + proto.STRING, + number=10, + ) + headers: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=11, + ) + firewall_policy_evaluation: bool = proto.Field( + proto.BOOL, + number=12, + ) transaction_data: "TransactionData" = proto.Field( proto.MESSAGE, number=13, @@ -1055,6 +1129,10 @@ class RiskAnalysis(proto.Message): reasons (MutableSequence[google.cloud.recaptchaenterprise_v1.types.RiskAnalysis.ClassificationReason]): Reasons contributing to the risk analysis verdict. + extended_verdict_reasons (MutableSequence[str]): + Extended verdict reasons to be used for + experimentation only. The set of possible + reasons is subject to change. """ class ClassificationReason(proto.Enum): @@ -1104,6 +1182,10 @@ class ClassificationReason(proto.Enum): number=2, enum=ClassificationReason, ) + extended_verdict_reasons: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=3, + ) class TokenProperties(proto.Message): @@ -1203,15 +1285,19 @@ class FraudPreventionAssessment(proto.Message): Attributes: transaction_risk (float): - Probability (0-1) of this transaction being + Probability of this transaction being fraudulent. Summarizes the combined risk of - attack vectors below. + attack vectors below. Values are from 0.0 + (lowest) to 1.0 (highest). stolen_instrument_verdict (google.cloud.recaptchaenterprise_v1.types.FraudPreventionAssessment.StolenInstrumentVerdict): Assessment of this transaction for risk of a stolen instrument. card_testing_verdict (google.cloud.recaptchaenterprise_v1.types.FraudPreventionAssessment.CardTestingVerdict): Assessment of this transaction for risk of being part of a card testing attack. + behavioral_trust_verdict (google.cloud.recaptchaenterprise_v1.types.FraudPreventionAssessment.BehavioralTrustVerdict): + Assessment of this transaction for behavioral + trust. """ class StolenInstrumentVerdict(proto.Message): @@ -1221,8 +1307,9 @@ class StolenInstrumentVerdict(proto.Message): Attributes: risk (float): - Probability (0-1) of this transaction being - executed with a stolen instrument. + Probability of this transaction being + executed with a stolen instrument. Values are + from 0.0 (lowest) to 1.0 (highest). """ risk: float = proto.Field( @@ -1237,8 +1324,9 @@ class CardTestingVerdict(proto.Message): Attributes: risk (float): - Probability (0-1) of this transaction attempt - being part of a card testing attack. + Probability of this transaction attempt being + part of a card testing attack. + Values are from 0.0 (lowest) to 1.0 (highest). """ risk: float = proto.Field( @@ -1246,6 +1334,21 @@ class CardTestingVerdict(proto.Message): number=1, ) + class BehavioralTrustVerdict(proto.Message): + r"""Information about behavioral trust of the transaction. + + Attributes: + trust (float): + Probability of this transaction attempt being + executed in a behaviorally trustworthy way. + Values are from 0.0 (lowest) to 1.0 (highest). + """ + + trust: float = proto.Field( + proto.FLOAT, + number=1, + ) + transaction_risk: float = proto.Field( proto.FLOAT, number=1, @@ -1260,6 +1363,100 @@ class CardTestingVerdict(proto.Message): number=3, message=CardTestingVerdict, ) + behavioral_trust_verdict: BehavioralTrustVerdict = proto.Field( + proto.MESSAGE, + number=4, + message=BehavioralTrustVerdict, + ) + + +class FraudSignals(proto.Message): + r"""Fraud signals describing users and cards involved in the + transaction. + + Attributes: + user_signals (google.cloud.recaptchaenterprise_v1.types.FraudSignals.UserSignals): + Output only. Signals describing the end user + in this transaction. + card_signals (google.cloud.recaptchaenterprise_v1.types.FraudSignals.CardSignals): + Output only. Signals describing the payment + card or cards used in this transaction. + """ + + class UserSignals(proto.Message): + r"""Signals describing the user involved in this transaction. + + Attributes: + active_days_lower_bound (int): + Output only. This user (based on email, + phone, and other identifiers) has been seen on + the internet for at least this number of days. + synthetic_risk (float): + Output only. Likelihood (from 0.0 to 1.0) + this user includes synthetic components in their + identity, such as a randomly generated email + address, temporary phone number, or fake + shipping address. + """ + + active_days_lower_bound: int = proto.Field( + proto.INT32, + number=1, + ) + synthetic_risk: float = proto.Field( + proto.FLOAT, + number=2, + ) + + class CardSignals(proto.Message): + r"""Signals describing the payment card used in this transaction. + + Attributes: + card_labels (MutableSequence[google.cloud.recaptchaenterprise_v1.types.FraudSignals.CardSignals.CardLabel]): + Output only. The labels for the payment card + in this transaction. + """ + + class CardLabel(proto.Enum): + r"""Risk labels describing the card being assessed, such as its + funding mechanism. + + Values: + CARD_LABEL_UNSPECIFIED (0): + No label specified. + PREPAID (1): + This card has been detected as prepaid. + VIRTUAL (2): + This card has been detected as virtual, such + as a card number generated for a single + transaction or merchant. + UNEXPECTED_LOCATION (3): + This card has been detected as being used in + an unexpected geographic location. + """ + CARD_LABEL_UNSPECIFIED = 0 + PREPAID = 1 + VIRTUAL = 2 + UNEXPECTED_LOCATION = 3 + + card_labels: MutableSequence[ + "FraudSignals.CardSignals.CardLabel" + ] = proto.RepeatedField( + proto.ENUM, + number=1, + enum="FraudSignals.CardSignals.CardLabel", + ) + + user_signals: UserSignals = proto.Field( + proto.MESSAGE, + number=1, + message=UserSignals, + ) + card_signals: CardSignals = proto.Field( + proto.MESSAGE, + number=2, + message=CardSignals, + ) class AccountDefenderAssessment(proto.Message): @@ -1312,9 +1509,8 @@ class CreateKeyRequest(proto.Message): Attributes: parent (str): - Required. The name of the project in which - the key will be created, in the format - "projects/{project}". + Required. The name of the project in which the key will be + created, in the format ``projects/{project}``. key (google.cloud.recaptchaenterprise_v1.types.Key): Required. Information to create a reCAPTCHA Enterprise key. @@ -1336,9 +1532,8 @@ class ListKeysRequest(proto.Message): Attributes: parent (str): - Required. The name of the project that - contains the keys that will be listed, in the - format "projects/{project}". + Required. The name of the project that contains the keys + that will be listed, in the format ``projects/{project}``. page_size (int): Optional. The maximum number of keys to return. Default is 10. Max limit is 1000. @@ -1392,9 +1587,8 @@ class RetrieveLegacySecretKeyRequest(proto.Message): Attributes: key (str): - Required. The public key name linked to the - requested secret key in the format - "projects/{project}/keys/{key}". + Required. The public key name linked to the requested secret + key in the format ``projects/{project}/keys/{key}``. """ key: str = proto.Field( @@ -1408,8 +1602,8 @@ class GetKeyRequest(proto.Message): Attributes: name (str): - Required. The name of the requested key, in - the format "projects/{project}/keys/{key}". + Required. The name of the requested key, in the format + ``projects/{project}/keys/{key}``. """ name: str = proto.Field( @@ -1447,8 +1641,142 @@ class DeleteKeyRequest(proto.Message): Attributes: name (str): - Required. The name of the key to be deleted, - in the format "projects/{project}/keys/{key}". + Required. The name of the key to be deleted, in the format + ``projects/{project}/keys/{key}``. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class CreateFirewallPolicyRequest(proto.Message): + r"""The create firewall policy request message. + + Attributes: + parent (str): + Required. The name of the project this policy will apply to, + in the format ``projects/{project}``. + firewall_policy (google.cloud.recaptchaenterprise_v1.types.FirewallPolicy): + Required. Information to create the policy. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + firewall_policy: "FirewallPolicy" = proto.Field( + proto.MESSAGE, + number=2, + message="FirewallPolicy", + ) + + +class ListFirewallPoliciesRequest(proto.Message): + r"""The list firewall policies request message. + + Attributes: + parent (str): + Required. The name of the project to list the policies for, + in the format ``projects/{project}``. + page_size (int): + Optional. The maximum number of policies to + return. Default is 10. Max limit is 1000. + page_token (str): + Optional. The next_page_token value returned from a + previous. ListFirewallPoliciesRequest, if any. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + page_size: int = proto.Field( + proto.INT32, + number=2, + ) + page_token: str = proto.Field( + proto.STRING, + number=3, + ) + + +class ListFirewallPoliciesResponse(proto.Message): + r"""Response to request to list firewall policies belonging to a + key. + + Attributes: + firewall_policies (MutableSequence[google.cloud.recaptchaenterprise_v1.types.FirewallPolicy]): + Policy details. + next_page_token (str): + Token to retrieve the next page of results. + It is set to empty if no policies remain in + results. + """ + + @property + def raw_page(self): + return self + + firewall_policies: MutableSequence["FirewallPolicy"] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="FirewallPolicy", + ) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + + +class GetFirewallPolicyRequest(proto.Message): + r"""The get firewall policy request message. + + Attributes: + name (str): + Required. The name of the requested policy, in the format + ``projects/{project}/firewallpolicies/{firewallpolicy}``. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class UpdateFirewallPolicyRequest(proto.Message): + r"""The update firewall policy request message. + + Attributes: + firewall_policy (google.cloud.recaptchaenterprise_v1.types.FirewallPolicy): + Required. The policy to update. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Optional. The mask to control which fields of + the policy get updated. If the mask is not + present, all fields will be updated. + """ + + firewall_policy: "FirewallPolicy" = proto.Field( + proto.MESSAGE, + number=1, + message="FirewallPolicy", + ) + update_mask: field_mask_pb2.FieldMask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + + +class DeleteFirewallPolicyRequest(proto.Message): + r"""The delete firewall policy request message. + + Attributes: + name (str): + Required. The name of the policy to be deleted, in the + format + ``projects/{project}/firewallpolicies/{firewallpolicy}``. """ name: str = proto.Field( @@ -1462,8 +1790,8 @@ class MigrateKeyRequest(proto.Message): Attributes: name (str): - Required. The name of the key to be migrated, - in the format "projects/{project}/keys/{key}". + Required. The name of the key to be migrated, in the format + ``projects/{project}/keys/{key}``. skip_billing_check (bool): Optional. If true, skips the billing check. A reCAPTCHA Enterprise key or migrated key behaves differently than a @@ -1492,9 +1820,8 @@ class GetMetricsRequest(proto.Message): Attributes: name (str): - Required. The name of the requested metrics, - in the format - "projects/{project}/keys/{key}/metrics". + Required. The name of the requested metrics, in the format + ``projects/{project}/keys/{key}/metrics``. """ name: str = proto.Field( @@ -1508,8 +1835,8 @@ class Metrics(proto.Message): Attributes: name (str): - Output only. The name of the metrics, in the - format "projects/{project}/keys/{key}/metrics". + Output only. The name of the metrics, in the format + ``projects/{project}/keys/{key}/metrics``. start_time (google.protobuf.timestamp_pb2.Timestamp): Inclusive start time aligned to a day (UTC). score_metrics (MutableSequence[google.cloud.recaptchaenterprise_v1.types.ScoreMetrics]): @@ -1578,7 +1905,7 @@ class Key(proto.Message): Attributes: name (str): The resource name for the Key in the format - "projects/{project}/keys/{key}". + ``projects/{project}/keys/{key}``. display_name (str): Human-readable display name of this key. Modifiable by user. @@ -1598,12 +1925,11 @@ class Key(proto.Message): This field is a member of `oneof`_ ``platform_settings``. labels (MutableMapping[str, str]): - See - Creating and managing labels. + See [Creating and managing labels] + (https://cloud.google.com/recaptcha-enterprise/docs/labels). create_time (google.protobuf.timestamp_pb2.Timestamp): Output only. The timestamp corresponding to - the creation of this Key. + the creation of this key. testing_options (google.cloud.recaptchaenterprise_v1.types.TestingOptions): Options for user acceptance testing. waf_settings (google.cloud.recaptchaenterprise_v1.types.WafSettings): @@ -1813,6 +2139,11 @@ class AndroidKeySettings(proto.Message): allowed_package_names (MutableSequence[str]): Android package names of apps allowed to use the key. Example: 'com.companyname.appname' + support_non_google_app_store_distribution (bool): + Set to true for keys that are used in an + Android application that is available for + download in app stores in addition to the Google + Play Store. """ allow_all_package_names: bool = proto.Field( @@ -1823,6 +2154,10 @@ class AndroidKeySettings(proto.Message): proto.STRING, number=1, ) + support_non_google_app_store_distribution: bool = proto.Field( + proto.BOOL, + number=3, + ) class IOSKeySettings(proto.Message): @@ -1835,6 +2170,15 @@ class IOSKeySettings(proto.Message): iOS bundle ids of apps allowed to use the key. Example: 'com.companyname.productname.appname' + apple_developer_id (google.cloud.recaptchaenterprise_v1.types.AppleDeveloperId): + Apple Developer account details for the app + that is protected by the reCAPTCHA Key. + reCAPTCHA Enterprise leverages platform-specific + checks like Apple App Attest and Apple + DeviceCheck to protect your app from abuse. + Providing these fields allows reCAPTCHA + Enterprise to get a better assessment of the + integrity of your app. """ allow_all_bundle_ids: bool = proto.Field( @@ -1845,6 +2189,45 @@ class IOSKeySettings(proto.Message): proto.STRING, number=1, ) + apple_developer_id: "AppleDeveloperId" = proto.Field( + proto.MESSAGE, + number=3, + message="AppleDeveloperId", + ) + + +class AppleDeveloperId(proto.Message): + r"""Contains fields that are required to perform Apple-specific + integrity checks. + + Attributes: + private_key (str): + Required. Input only. A private key + (downloaded as a text file with a .p8 file + extension) generated for your Apple Developer + account. Ensure that Apple DeviceCheck is + enabled for the private key. + key_id (str): + Required. The Apple developer key ID + (10-character string). + team_id (str): + Required. The Apple team ID (10-character + string) owning the provisioning profile used to + build your application. + """ + + private_key: str = proto.Field( + proto.STRING, + number=1, + ) + key_id: str = proto.Field( + proto.STRING, + number=2, + ) + team_id: str = proto.Field( + proto.STRING, + number=3, + ) class ScoreDistribution(proto.Message): @@ -1930,6 +2313,224 @@ class ChallengeMetrics(proto.Message): ) +class FirewallPolicyAssessment(proto.Message): + r"""Policy config assessment. + + Attributes: + error (google.rpc.status_pb2.Status): + If the processing of a policy config fails, an error will be + populated and the firewall_policy will be left empty. + firewall_policy (google.cloud.recaptchaenterprise_v1.types.FirewallPolicy): + Output only. The policy that matched the + request. If more than one policy may match, this + is the first match. If no policy matches the + incoming request, the policy field will be left + empty. + """ + + error: status_pb2.Status = proto.Field( + proto.MESSAGE, + number=5, + message=status_pb2.Status, + ) + firewall_policy: "FirewallPolicy" = proto.Field( + proto.MESSAGE, + number=8, + message="FirewallPolicy", + ) + + +class FirewallAction(proto.Message): + r"""An individual action. Each action represents what to do if a + policy matches. + + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + allow (google.cloud.recaptchaenterprise_v1.types.FirewallAction.AllowAction): + The user request did not match any policy and + should be allowed access to the requested + resource. + + This field is a member of `oneof`_ ``firewall_action_oneof``. + block (google.cloud.recaptchaenterprise_v1.types.FirewallAction.BlockAction): + This action will deny access to a given page. + The user will get an HTTP error code. + + This field is a member of `oneof`_ ``firewall_action_oneof``. + redirect (google.cloud.recaptchaenterprise_v1.types.FirewallAction.RedirectAction): + This action will redirect the request to a + ReCaptcha interstitial to attach a token. + + This field is a member of `oneof`_ ``firewall_action_oneof``. + substitute (google.cloud.recaptchaenterprise_v1.types.FirewallAction.SubstituteAction): + This action will transparently serve a + different page to an offending user. + + This field is a member of `oneof`_ ``firewall_action_oneof``. + set_header (google.cloud.recaptchaenterprise_v1.types.FirewallAction.SetHeaderAction): + This action will set a custom header but + allow the request to continue to the customer + backend. + + This field is a member of `oneof`_ ``firewall_action_oneof``. + """ + + class AllowAction(proto.Message): + r"""An allow action continues processing a request unimpeded.""" + + class BlockAction(proto.Message): + r"""A block action serves an HTTP error code a prevents the + request from hitting the backend. + + """ + + class RedirectAction(proto.Message): + r"""A redirect action returns a 307 (temporary redirect) + response, pointing the user to a ReCaptcha interstitial page to + attach a token. + + """ + + class SubstituteAction(proto.Message): + r"""A substitute action transparently serves a different page + than the one requested. + + Attributes: + path (str): + The address to redirect to. The target is a + relative path in the current host. Example: + "/blog/404.html". + """ + + path: str = proto.Field( + proto.STRING, + number=1, + ) + + class SetHeaderAction(proto.Message): + r"""A set header action sets a header and forwards the request to + the backend. This can be used to trigger custom protection + implemented on the backend. + + Attributes: + key (str): + The header key to set in the request to the + backend server. + value (str): + The header value to set in the request to the + backend server. + """ + + key: str = proto.Field( + proto.STRING, + number=1, + ) + value: str = proto.Field( + proto.STRING, + number=2, + ) + + allow: AllowAction = proto.Field( + proto.MESSAGE, + number=1, + oneof="firewall_action_oneof", + message=AllowAction, + ) + block: BlockAction = proto.Field( + proto.MESSAGE, + number=2, + oneof="firewall_action_oneof", + message=BlockAction, + ) + redirect: RedirectAction = proto.Field( + proto.MESSAGE, + number=5, + oneof="firewall_action_oneof", + message=RedirectAction, + ) + substitute: SubstituteAction = proto.Field( + proto.MESSAGE, + number=3, + oneof="firewall_action_oneof", + message=SubstituteAction, + ) + set_header: SetHeaderAction = proto.Field( + proto.MESSAGE, + number=4, + oneof="firewall_action_oneof", + message=SetHeaderAction, + ) + + +class FirewallPolicy(proto.Message): + r"""A FirewallPolicy represents a single matching pattern and + resulting actions to take. + + Attributes: + name (str): + The resource name for the FirewallPolicy in the format + ``projects/{project}/firewallpolicies/{firewallpolicy}``. + description (str): + A description of what this policy aims to + achieve, for convenience purposes. The + description can at most include 256 UTF-8 + characters. + path (str): + The path for which this policy applies, specified as a glob + pattern. For more information on glob, see the `manual + page `__. + A path has a max length of 200 characters. + condition (str): + A CEL (Common Expression Language) conditional expression + that specifies if this policy applies to an incoming user + request. If this condition evaluates to true and the + requested path matched the path pattern, the associated + actions should be executed by the caller. The condition + string is checked for CEL syntax correctness on creation. + For more information, see the `CEL + spec `__ and its + `language + definition `__. + A condition has a max length of 500 characters. + actions (MutableSequence[google.cloud.recaptchaenterprise_v1.types.FirewallAction]): + The actions that the caller should take regarding user + access. There should be at most one terminal action. A + terminal action is any action that forces a response, such + as ``AllowAction``, ``BlockAction`` or ``SubstituteAction``. + Zero or more non-terminal actions such as ``SetHeader`` + might be specified. A single policy can contain up to 16 + actions. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + description: str = proto.Field( + proto.STRING, + number=2, + ) + path: str = proto.Field( + proto.STRING, + number=4, + ) + condition: str = proto.Field( + proto.STRING, + number=5, + ) + actions: MutableSequence["FirewallAction"] = proto.RepeatedField( + proto.MESSAGE, + number=6, + message="FirewallAction", + ) + + class ListRelatedAccountGroupMembershipsRequest(proto.Message): r"""The request message to list memberships in a related account group. @@ -2002,9 +2603,8 @@ class ListRelatedAccountGroupsRequest(proto.Message): Attributes: parent (str): - Required. The name of the project to list - related account groups from, in the format - "projects/{project}". + Required. The name of the project to list related account + groups from, in the format ``projects/{project}``. page_size (int): Optional. The maximum number of groups to return. The service might return fewer than this @@ -2071,14 +2671,12 @@ class SearchRelatedAccountGroupMembershipsRequest(proto.Message): Attributes: project (str): - Required. The name of the project to search - related account group memberships from. Specify - the project name in the following format: - - "projects/{project}". + Required. The name of the project to search related account + group memberships from. Specify the project name in the + following format: ``projects/{project}``. hashed_account_id (bytes): - Optional. The unique stable hashed user identifier we should - search connections to. The identifier should correspond to a + Optional. The unique stable hashed user identifier used to + search connections. The identifier should correspond to a ``hashed_account_id`` provided in a previous ``CreateAssessment`` or ``AnnotateAssessment`` call. page_size (int): @@ -2212,11 +2810,16 @@ class WafFeature(proto.Enum): ACTION_TOKEN (3): Use reCAPTCHA action-tokens to protect user actions. + EXPRESS (5): + Use reCAPTCHA WAF express protection to + protect any content other than web pages, like + APIs and IoT devices. """ WAF_FEATURE_UNSPECIFIED = 0 CHALLENGE_PAGE = 1 SESSION_TOKEN = 2 ACTION_TOKEN = 3 + EXPRESS = 5 class WafService(proto.Enum): r"""Web Application Firewalls supported by reCAPTCHA Enterprise. @@ -2226,9 +2829,12 @@ class WafService(proto.Enum): Undefined WAF CA (1): Cloud Armor + FASTLY (3): + Fastly """ WAF_SERVICE_UNSPECIFIED = 0 CA = 1 + FASTLY = 3 waf_service: WafService = proto.Field( proto.ENUM, diff --git a/packages/google-cloud-recaptcha-enterprise/noxfile.py b/packages/google-cloud-recaptcha-enterprise/noxfile.py index 9a2acd8b6787..be54712bfa8f 100644 --- a/packages/google-cloud-recaptcha-enterprise/noxfile.py +++ b/packages/google-cloud-recaptcha-enterprise/noxfile.py @@ -46,7 +46,7 @@ UNIT_TEST_EXTRAS = [] UNIT_TEST_EXTRAS_BY_PYTHON = {} -SYSTEM_TEST_PYTHON_VERSIONS = [] +SYSTEM_TEST_PYTHON_VERSIONS = ["3.8", "3.9", "3.10", "3.11"] SYSTEM_TEST_STANDARD_DEPENDENCIES = [ "mock", "pytest", @@ -405,24 +405,3 @@ def prerelease_deps(session): session.run("python", "-c", "import google.auth; print(google.auth.__version__)") session.run("py.test", "tests/unit") - - system_test_path = os.path.join("tests", "system.py") - system_test_folder_path = os.path.join("tests", "system") - - # Only run system tests if found. - if os.path.exists(system_test_path): - session.run( - "py.test", - "--verbose", - f"--junitxml=system_{session.python}_sponge_log.xml", - system_test_path, - *session.posargs, - ) - if os.path.exists(system_test_folder_path): - session.run( - "py.test", - "--verbose", - f"--junitxml=system_{session.python}_sponge_log.xml", - system_test_folder_path, - *session.posargs, - ) diff --git a/packages/google-cloud-recaptcha-enterprise/samples/generated_samples/recaptchaenterprise_v1_generated_recaptcha_enterprise_service_create_firewall_policy_async.py b/packages/google-cloud-recaptcha-enterprise/samples/generated_samples/recaptchaenterprise_v1_generated_recaptcha_enterprise_service_create_firewall_policy_async.py new file mode 100644 index 000000000000..b3fb86c41dc7 --- /dev/null +++ b/packages/google-cloud-recaptcha-enterprise/samples/generated_samples/recaptchaenterprise_v1_generated_recaptcha_enterprise_service_create_firewall_policy_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateFirewallPolicy +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-recaptcha-enterprise + + +# [START recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_CreateFirewallPolicy_async] +# 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 recaptchaenterprise_v1 + + +async def sample_create_firewall_policy(): + # Create a client + client = recaptchaenterprise_v1.RecaptchaEnterpriseServiceAsyncClient() + + # Initialize request argument(s) + request = recaptchaenterprise_v1.CreateFirewallPolicyRequest( + parent="parent_value", + ) + + # Make the request + response = await client.create_firewall_policy(request=request) + + # Handle the response + print(response) + +# [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_CreateFirewallPolicy_async] diff --git a/packages/google-cloud-recaptcha-enterprise/samples/generated_samples/recaptchaenterprise_v1_generated_recaptcha_enterprise_service_create_firewall_policy_sync.py b/packages/google-cloud-recaptcha-enterprise/samples/generated_samples/recaptchaenterprise_v1_generated_recaptcha_enterprise_service_create_firewall_policy_sync.py new file mode 100644 index 000000000000..4430efef5dff --- /dev/null +++ b/packages/google-cloud-recaptcha-enterprise/samples/generated_samples/recaptchaenterprise_v1_generated_recaptcha_enterprise_service_create_firewall_policy_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateFirewallPolicy +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-recaptcha-enterprise + + +# [START recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_CreateFirewallPolicy_sync] +# 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 recaptchaenterprise_v1 + + +def sample_create_firewall_policy(): + # Create a client + client = recaptchaenterprise_v1.RecaptchaEnterpriseServiceClient() + + # Initialize request argument(s) + request = recaptchaenterprise_v1.CreateFirewallPolicyRequest( + parent="parent_value", + ) + + # Make the request + response = client.create_firewall_policy(request=request) + + # Handle the response + print(response) + +# [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_CreateFirewallPolicy_sync] diff --git a/packages/google-cloud-recaptcha-enterprise/samples/generated_samples/recaptchaenterprise_v1_generated_recaptcha_enterprise_service_delete_firewall_policy_async.py b/packages/google-cloud-recaptcha-enterprise/samples/generated_samples/recaptchaenterprise_v1_generated_recaptcha_enterprise_service_delete_firewall_policy_async.py new file mode 100644 index 000000000000..b5871ba98c2e --- /dev/null +++ b/packages/google-cloud-recaptcha-enterprise/samples/generated_samples/recaptchaenterprise_v1_generated_recaptcha_enterprise_service_delete_firewall_policy_async.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteFirewallPolicy +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-recaptcha-enterprise + + +# [START recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_DeleteFirewallPolicy_async] +# 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 recaptchaenterprise_v1 + + +async def sample_delete_firewall_policy(): + # Create a client + client = recaptchaenterprise_v1.RecaptchaEnterpriseServiceAsyncClient() + + # Initialize request argument(s) + request = recaptchaenterprise_v1.DeleteFirewallPolicyRequest( + name="name_value", + ) + + # Make the request + await client.delete_firewall_policy(request=request) + + +# [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_DeleteFirewallPolicy_async] diff --git a/packages/google-cloud-recaptcha-enterprise/samples/generated_samples/recaptchaenterprise_v1_generated_recaptcha_enterprise_service_delete_firewall_policy_sync.py b/packages/google-cloud-recaptcha-enterprise/samples/generated_samples/recaptchaenterprise_v1_generated_recaptcha_enterprise_service_delete_firewall_policy_sync.py new file mode 100644 index 000000000000..6f2381e33a2e --- /dev/null +++ b/packages/google-cloud-recaptcha-enterprise/samples/generated_samples/recaptchaenterprise_v1_generated_recaptcha_enterprise_service_delete_firewall_policy_sync.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteFirewallPolicy +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-recaptcha-enterprise + + +# [START recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_DeleteFirewallPolicy_sync] +# 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 recaptchaenterprise_v1 + + +def sample_delete_firewall_policy(): + # Create a client + client = recaptchaenterprise_v1.RecaptchaEnterpriseServiceClient() + + # Initialize request argument(s) + request = recaptchaenterprise_v1.DeleteFirewallPolicyRequest( + name="name_value", + ) + + # Make the request + client.delete_firewall_policy(request=request) + + +# [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_DeleteFirewallPolicy_sync] diff --git a/packages/google-cloud-recaptcha-enterprise/samples/generated_samples/recaptchaenterprise_v1_generated_recaptcha_enterprise_service_get_firewall_policy_async.py b/packages/google-cloud-recaptcha-enterprise/samples/generated_samples/recaptchaenterprise_v1_generated_recaptcha_enterprise_service_get_firewall_policy_async.py new file mode 100644 index 000000000000..6b04f430c7d3 --- /dev/null +++ b/packages/google-cloud-recaptcha-enterprise/samples/generated_samples/recaptchaenterprise_v1_generated_recaptcha_enterprise_service_get_firewall_policy_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetFirewallPolicy +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-recaptcha-enterprise + + +# [START recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_GetFirewallPolicy_async] +# 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 recaptchaenterprise_v1 + + +async def sample_get_firewall_policy(): + # Create a client + client = recaptchaenterprise_v1.RecaptchaEnterpriseServiceAsyncClient() + + # Initialize request argument(s) + request = recaptchaenterprise_v1.GetFirewallPolicyRequest( + name="name_value", + ) + + # Make the request + response = await client.get_firewall_policy(request=request) + + # Handle the response + print(response) + +# [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_GetFirewallPolicy_async] diff --git a/packages/google-cloud-recaptcha-enterprise/samples/generated_samples/recaptchaenterprise_v1_generated_recaptcha_enterprise_service_get_firewall_policy_sync.py b/packages/google-cloud-recaptcha-enterprise/samples/generated_samples/recaptchaenterprise_v1_generated_recaptcha_enterprise_service_get_firewall_policy_sync.py new file mode 100644 index 000000000000..60b77faff477 --- /dev/null +++ b/packages/google-cloud-recaptcha-enterprise/samples/generated_samples/recaptchaenterprise_v1_generated_recaptcha_enterprise_service_get_firewall_policy_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetFirewallPolicy +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-recaptcha-enterprise + + +# [START recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_GetFirewallPolicy_sync] +# 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 recaptchaenterprise_v1 + + +def sample_get_firewall_policy(): + # Create a client + client = recaptchaenterprise_v1.RecaptchaEnterpriseServiceClient() + + # Initialize request argument(s) + request = recaptchaenterprise_v1.GetFirewallPolicyRequest( + name="name_value", + ) + + # Make the request + response = client.get_firewall_policy(request=request) + + # Handle the response + print(response) + +# [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_GetFirewallPolicy_sync] diff --git a/packages/google-cloud-recaptcha-enterprise/samples/generated_samples/recaptchaenterprise_v1_generated_recaptcha_enterprise_service_list_firewall_policies_async.py b/packages/google-cloud-recaptcha-enterprise/samples/generated_samples/recaptchaenterprise_v1_generated_recaptcha_enterprise_service_list_firewall_policies_async.py new file mode 100644 index 000000000000..76f964abede3 --- /dev/null +++ b/packages/google-cloud-recaptcha-enterprise/samples/generated_samples/recaptchaenterprise_v1_generated_recaptcha_enterprise_service_list_firewall_policies_async.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListFirewallPolicies +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-recaptcha-enterprise + + +# [START recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_ListFirewallPolicies_async] +# 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 recaptchaenterprise_v1 + + +async def sample_list_firewall_policies(): + # Create a client + client = recaptchaenterprise_v1.RecaptchaEnterpriseServiceAsyncClient() + + # Initialize request argument(s) + request = recaptchaenterprise_v1.ListFirewallPoliciesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_firewall_policies(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_ListFirewallPolicies_async] diff --git a/packages/google-cloud-recaptcha-enterprise/samples/generated_samples/recaptchaenterprise_v1_generated_recaptcha_enterprise_service_list_firewall_policies_sync.py b/packages/google-cloud-recaptcha-enterprise/samples/generated_samples/recaptchaenterprise_v1_generated_recaptcha_enterprise_service_list_firewall_policies_sync.py new file mode 100644 index 000000000000..9d5112ca15ae --- /dev/null +++ b/packages/google-cloud-recaptcha-enterprise/samples/generated_samples/recaptchaenterprise_v1_generated_recaptcha_enterprise_service_list_firewall_policies_sync.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListFirewallPolicies +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-recaptcha-enterprise + + +# [START recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_ListFirewallPolicies_sync] +# 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 recaptchaenterprise_v1 + + +def sample_list_firewall_policies(): + # Create a client + client = recaptchaenterprise_v1.RecaptchaEnterpriseServiceClient() + + # Initialize request argument(s) + request = recaptchaenterprise_v1.ListFirewallPoliciesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_firewall_policies(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_ListFirewallPolicies_sync] diff --git a/packages/google-cloud-recaptcha-enterprise/samples/generated_samples/recaptchaenterprise_v1_generated_recaptcha_enterprise_service_update_firewall_policy_async.py b/packages/google-cloud-recaptcha-enterprise/samples/generated_samples/recaptchaenterprise_v1_generated_recaptcha_enterprise_service_update_firewall_policy_async.py new file mode 100644 index 000000000000..cea91eed43d5 --- /dev/null +++ b/packages/google-cloud-recaptcha-enterprise/samples/generated_samples/recaptchaenterprise_v1_generated_recaptcha_enterprise_service_update_firewall_policy_async.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateFirewallPolicy +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-recaptcha-enterprise + + +# [START recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_UpdateFirewallPolicy_async] +# 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 recaptchaenterprise_v1 + + +async def sample_update_firewall_policy(): + # Create a client + client = recaptchaenterprise_v1.RecaptchaEnterpriseServiceAsyncClient() + + # Initialize request argument(s) + request = recaptchaenterprise_v1.UpdateFirewallPolicyRequest( + ) + + # Make the request + response = await client.update_firewall_policy(request=request) + + # Handle the response + print(response) + +# [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_UpdateFirewallPolicy_async] diff --git a/packages/google-cloud-recaptcha-enterprise/samples/generated_samples/recaptchaenterprise_v1_generated_recaptcha_enterprise_service_update_firewall_policy_sync.py b/packages/google-cloud-recaptcha-enterprise/samples/generated_samples/recaptchaenterprise_v1_generated_recaptcha_enterprise_service_update_firewall_policy_sync.py new file mode 100644 index 000000000000..887c76e47df3 --- /dev/null +++ b/packages/google-cloud-recaptcha-enterprise/samples/generated_samples/recaptchaenterprise_v1_generated_recaptcha_enterprise_service_update_firewall_policy_sync.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateFirewallPolicy +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-recaptcha-enterprise + + +# [START recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_UpdateFirewallPolicy_sync] +# 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 recaptchaenterprise_v1 + + +def sample_update_firewall_policy(): + # Create a client + client = recaptchaenterprise_v1.RecaptchaEnterpriseServiceClient() + + # Initialize request argument(s) + request = recaptchaenterprise_v1.UpdateFirewallPolicyRequest( + ) + + # Make the request + response = client.update_firewall_policy(request=request) + + # Handle the response + print(response) + +# [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_UpdateFirewallPolicy_sync] diff --git a/packages/google-cloud-recaptcha-enterprise/samples/generated_samples/snippet_metadata_google.cloud.recaptchaenterprise.v1.json b/packages/google-cloud-recaptcha-enterprise/samples/generated_samples/snippet_metadata_google.cloud.recaptchaenterprise.v1.json index c484ef1b904b..c27c8f1b6ce9 100644 --- a/packages/google-cloud-recaptcha-enterprise/samples/generated_samples/snippet_metadata_google.cloud.recaptchaenterprise.v1.json +++ b/packages/google-cloud-recaptcha-enterprise/samples/generated_samples/snippet_metadata_google.cloud.recaptchaenterprise.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-recaptcha-enterprise", - "version": "1.12.2" + "version": "0.1.0" }, "snippets": [ { @@ -349,6 +349,175 @@ ], "title": "recaptchaenterprise_v1_generated_recaptcha_enterprise_service_create_assessment_sync.py" }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.recaptchaenterprise_v1.RecaptchaEnterpriseServiceAsyncClient", + "shortName": "RecaptchaEnterpriseServiceAsyncClient" + }, + "fullName": "google.cloud.recaptchaenterprise_v1.RecaptchaEnterpriseServiceAsyncClient.create_firewall_policy", + "method": { + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.CreateFirewallPolicy", + "service": { + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService", + "shortName": "RecaptchaEnterpriseService" + }, + "shortName": "CreateFirewallPolicy" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.recaptchaenterprise_v1.types.CreateFirewallPolicyRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "firewall_policy", + "type": "google.cloud.recaptchaenterprise_v1.types.FirewallPolicy" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.recaptchaenterprise_v1.types.FirewallPolicy", + "shortName": "create_firewall_policy" + }, + "description": "Sample for CreateFirewallPolicy", + "file": "recaptchaenterprise_v1_generated_recaptcha_enterprise_service_create_firewall_policy_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_CreateFirewallPolicy_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "recaptchaenterprise_v1_generated_recaptcha_enterprise_service_create_firewall_policy_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.recaptchaenterprise_v1.RecaptchaEnterpriseServiceClient", + "shortName": "RecaptchaEnterpriseServiceClient" + }, + "fullName": "google.cloud.recaptchaenterprise_v1.RecaptchaEnterpriseServiceClient.create_firewall_policy", + "method": { + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.CreateFirewallPolicy", + "service": { + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService", + "shortName": "RecaptchaEnterpriseService" + }, + "shortName": "CreateFirewallPolicy" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.recaptchaenterprise_v1.types.CreateFirewallPolicyRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "firewall_policy", + "type": "google.cloud.recaptchaenterprise_v1.types.FirewallPolicy" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.recaptchaenterprise_v1.types.FirewallPolicy", + "shortName": "create_firewall_policy" + }, + "description": "Sample for CreateFirewallPolicy", + "file": "recaptchaenterprise_v1_generated_recaptcha_enterprise_service_create_firewall_policy_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_CreateFirewallPolicy_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "recaptchaenterprise_v1_generated_recaptcha_enterprise_service_create_firewall_policy_sync.py" + }, { "canonical": true, "clientMethod": { @@ -526,19 +695,19 @@ "fullName": "google.cloud.recaptchaenterprise_v1.RecaptchaEnterpriseServiceAsyncClient", "shortName": "RecaptchaEnterpriseServiceAsyncClient" }, - "fullName": "google.cloud.recaptchaenterprise_v1.RecaptchaEnterpriseServiceAsyncClient.delete_key", + "fullName": "google.cloud.recaptchaenterprise_v1.RecaptchaEnterpriseServiceAsyncClient.delete_firewall_policy", "method": { - "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.DeleteKey", + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.DeleteFirewallPolicy", "service": { "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService", "shortName": "RecaptchaEnterpriseService" }, - "shortName": "DeleteKey" + "shortName": "DeleteFirewallPolicy" }, "parameters": [ { "name": "request", - "type": "google.cloud.recaptchaenterprise_v1.types.DeleteKeyRequest" + "type": "google.cloud.recaptchaenterprise_v1.types.DeleteFirewallPolicyRequest" }, { "name": "name", @@ -557,21 +726,493 @@ "type": "Sequence[Tuple[str, str]" } ], - "shortName": "delete_key" + "shortName": "delete_firewall_policy" + }, + "description": "Sample for DeleteFirewallPolicy", + "file": "recaptchaenterprise_v1_generated_recaptcha_enterprise_service_delete_firewall_policy_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_DeleteFirewallPolicy_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "recaptchaenterprise_v1_generated_recaptcha_enterprise_service_delete_firewall_policy_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.recaptchaenterprise_v1.RecaptchaEnterpriseServiceClient", + "shortName": "RecaptchaEnterpriseServiceClient" + }, + "fullName": "google.cloud.recaptchaenterprise_v1.RecaptchaEnterpriseServiceClient.delete_firewall_policy", + "method": { + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.DeleteFirewallPolicy", + "service": { + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService", + "shortName": "RecaptchaEnterpriseService" + }, + "shortName": "DeleteFirewallPolicy" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.recaptchaenterprise_v1.types.DeleteFirewallPolicyRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_firewall_policy" + }, + "description": "Sample for DeleteFirewallPolicy", + "file": "recaptchaenterprise_v1_generated_recaptcha_enterprise_service_delete_firewall_policy_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_DeleteFirewallPolicy_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "recaptchaenterprise_v1_generated_recaptcha_enterprise_service_delete_firewall_policy_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.recaptchaenterprise_v1.RecaptchaEnterpriseServiceAsyncClient", + "shortName": "RecaptchaEnterpriseServiceAsyncClient" + }, + "fullName": "google.cloud.recaptchaenterprise_v1.RecaptchaEnterpriseServiceAsyncClient.delete_key", + "method": { + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.DeleteKey", + "service": { + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService", + "shortName": "RecaptchaEnterpriseService" + }, + "shortName": "DeleteKey" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.recaptchaenterprise_v1.types.DeleteKeyRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_key" + }, + "description": "Sample for DeleteKey", + "file": "recaptchaenterprise_v1_generated_recaptcha_enterprise_service_delete_key_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_DeleteKey_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "recaptchaenterprise_v1_generated_recaptcha_enterprise_service_delete_key_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.recaptchaenterprise_v1.RecaptchaEnterpriseServiceClient", + "shortName": "RecaptchaEnterpriseServiceClient" + }, + "fullName": "google.cloud.recaptchaenterprise_v1.RecaptchaEnterpriseServiceClient.delete_key", + "method": { + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.DeleteKey", + "service": { + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService", + "shortName": "RecaptchaEnterpriseService" + }, + "shortName": "DeleteKey" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.recaptchaenterprise_v1.types.DeleteKeyRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_key" + }, + "description": "Sample for DeleteKey", + "file": "recaptchaenterprise_v1_generated_recaptcha_enterprise_service_delete_key_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_DeleteKey_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "type": "RESPONSE_HANDLING" + } + ], + "title": "recaptchaenterprise_v1_generated_recaptcha_enterprise_service_delete_key_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.recaptchaenterprise_v1.RecaptchaEnterpriseServiceAsyncClient", + "shortName": "RecaptchaEnterpriseServiceAsyncClient" + }, + "fullName": "google.cloud.recaptchaenterprise_v1.RecaptchaEnterpriseServiceAsyncClient.get_firewall_policy", + "method": { + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.GetFirewallPolicy", + "service": { + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService", + "shortName": "RecaptchaEnterpriseService" + }, + "shortName": "GetFirewallPolicy" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.recaptchaenterprise_v1.types.GetFirewallPolicyRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.recaptchaenterprise_v1.types.FirewallPolicy", + "shortName": "get_firewall_policy" + }, + "description": "Sample for GetFirewallPolicy", + "file": "recaptchaenterprise_v1_generated_recaptcha_enterprise_service_get_firewall_policy_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_GetFirewallPolicy_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "recaptchaenterprise_v1_generated_recaptcha_enterprise_service_get_firewall_policy_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.recaptchaenterprise_v1.RecaptchaEnterpriseServiceClient", + "shortName": "RecaptchaEnterpriseServiceClient" + }, + "fullName": "google.cloud.recaptchaenterprise_v1.RecaptchaEnterpriseServiceClient.get_firewall_policy", + "method": { + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.GetFirewallPolicy", + "service": { + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService", + "shortName": "RecaptchaEnterpriseService" + }, + "shortName": "GetFirewallPolicy" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.recaptchaenterprise_v1.types.GetFirewallPolicyRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.recaptchaenterprise_v1.types.FirewallPolicy", + "shortName": "get_firewall_policy" + }, + "description": "Sample for GetFirewallPolicy", + "file": "recaptchaenterprise_v1_generated_recaptcha_enterprise_service_get_firewall_policy_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_GetFirewallPolicy_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "recaptchaenterprise_v1_generated_recaptcha_enterprise_service_get_firewall_policy_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.recaptchaenterprise_v1.RecaptchaEnterpriseServiceAsyncClient", + "shortName": "RecaptchaEnterpriseServiceAsyncClient" + }, + "fullName": "google.cloud.recaptchaenterprise_v1.RecaptchaEnterpriseServiceAsyncClient.get_key", + "method": { + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.GetKey", + "service": { + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService", + "shortName": "RecaptchaEnterpriseService" + }, + "shortName": "GetKey" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.recaptchaenterprise_v1.types.GetKeyRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.recaptchaenterprise_v1.types.Key", + "shortName": "get_key" }, - "description": "Sample for DeleteKey", - "file": "recaptchaenterprise_v1_generated_recaptcha_enterprise_service_delete_key_async.py", + "description": "Sample for GetKey", + "file": "recaptchaenterprise_v1_generated_recaptcha_enterprise_service_get_key_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_DeleteKey_async", + "regionTag": "recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_GetKey_async", "segments": [ { - "end": 49, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 49, + "end": 51, "start": 27, "type": "SHORT" }, @@ -586,15 +1227,17 @@ "type": "REQUEST_INITIALIZATION" }, { + "end": 48, "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 50, + "end": 52, + "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "recaptchaenterprise_v1_generated_recaptcha_enterprise_service_delete_key_async.py" + "title": "recaptchaenterprise_v1_generated_recaptcha_enterprise_service_get_key_async.py" }, { "canonical": true, @@ -603,19 +1246,19 @@ "fullName": "google.cloud.recaptchaenterprise_v1.RecaptchaEnterpriseServiceClient", "shortName": "RecaptchaEnterpriseServiceClient" }, - "fullName": "google.cloud.recaptchaenterprise_v1.RecaptchaEnterpriseServiceClient.delete_key", + "fullName": "google.cloud.recaptchaenterprise_v1.RecaptchaEnterpriseServiceClient.get_key", "method": { - "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.DeleteKey", + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.GetKey", "service": { "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService", "shortName": "RecaptchaEnterpriseService" }, - "shortName": "DeleteKey" + "shortName": "GetKey" }, "parameters": [ { "name": "request", - "type": "google.cloud.recaptchaenterprise_v1.types.DeleteKeyRequest" + "type": "google.cloud.recaptchaenterprise_v1.types.GetKeyRequest" }, { "name": "name", @@ -634,21 +1277,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "shortName": "delete_key" + "resultType": "google.cloud.recaptchaenterprise_v1.types.Key", + "shortName": "get_key" }, - "description": "Sample for DeleteKey", - "file": "recaptchaenterprise_v1_generated_recaptcha_enterprise_service_delete_key_sync.py", + "description": "Sample for GetKey", + "file": "recaptchaenterprise_v1_generated_recaptcha_enterprise_service_get_key_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_DeleteKey_sync", + "regionTag": "recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_GetKey_sync", "segments": [ { - "end": 49, + "end": 51, "start": 27, "type": "FULL" }, { - "end": 49, + "end": 51, "start": 27, "type": "SHORT" }, @@ -663,15 +1307,17 @@ "type": "REQUEST_INITIALIZATION" }, { + "end": 48, "start": 46, "type": "REQUEST_EXECUTION" }, { - "end": 50, + "end": 52, + "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "recaptchaenterprise_v1_generated_recaptcha_enterprise_service_delete_key_sync.py" + "title": "recaptchaenterprise_v1_generated_recaptcha_enterprise_service_get_key_sync.py" }, { "canonical": true, @@ -681,19 +1327,19 @@ "fullName": "google.cloud.recaptchaenterprise_v1.RecaptchaEnterpriseServiceAsyncClient", "shortName": "RecaptchaEnterpriseServiceAsyncClient" }, - "fullName": "google.cloud.recaptchaenterprise_v1.RecaptchaEnterpriseServiceAsyncClient.get_key", + "fullName": "google.cloud.recaptchaenterprise_v1.RecaptchaEnterpriseServiceAsyncClient.get_metrics", "method": { - "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.GetKey", + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.GetMetrics", "service": { "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService", "shortName": "RecaptchaEnterpriseService" }, - "shortName": "GetKey" + "shortName": "GetMetrics" }, "parameters": [ { "name": "request", - "type": "google.cloud.recaptchaenterprise_v1.types.GetKeyRequest" + "type": "google.cloud.recaptchaenterprise_v1.types.GetMetricsRequest" }, { "name": "name", @@ -712,14 +1358,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.recaptchaenterprise_v1.types.Key", - "shortName": "get_key" + "resultType": "google.cloud.recaptchaenterprise_v1.types.Metrics", + "shortName": "get_metrics" }, - "description": "Sample for GetKey", - "file": "recaptchaenterprise_v1_generated_recaptcha_enterprise_service_get_key_async.py", + "description": "Sample for GetMetrics", + "file": "recaptchaenterprise_v1_generated_recaptcha_enterprise_service_get_metrics_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_GetKey_async", + "regionTag": "recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_GetMetrics_async", "segments": [ { "end": 51, @@ -752,7 +1398,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "recaptchaenterprise_v1_generated_recaptcha_enterprise_service_get_key_async.py" + "title": "recaptchaenterprise_v1_generated_recaptcha_enterprise_service_get_metrics_async.py" }, { "canonical": true, @@ -761,19 +1407,19 @@ "fullName": "google.cloud.recaptchaenterprise_v1.RecaptchaEnterpriseServiceClient", "shortName": "RecaptchaEnterpriseServiceClient" }, - "fullName": "google.cloud.recaptchaenterprise_v1.RecaptchaEnterpriseServiceClient.get_key", + "fullName": "google.cloud.recaptchaenterprise_v1.RecaptchaEnterpriseServiceClient.get_metrics", "method": { - "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.GetKey", + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.GetMetrics", "service": { "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService", "shortName": "RecaptchaEnterpriseService" }, - "shortName": "GetKey" + "shortName": "GetMetrics" }, "parameters": [ { "name": "request", - "type": "google.cloud.recaptchaenterprise_v1.types.GetKeyRequest" + "type": "google.cloud.recaptchaenterprise_v1.types.GetMetricsRequest" }, { "name": "name", @@ -792,14 +1438,14 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.recaptchaenterprise_v1.types.Key", - "shortName": "get_key" + "resultType": "google.cloud.recaptchaenterprise_v1.types.Metrics", + "shortName": "get_metrics" }, - "description": "Sample for GetKey", - "file": "recaptchaenterprise_v1_generated_recaptcha_enterprise_service_get_key_sync.py", + "description": "Sample for GetMetrics", + "file": "recaptchaenterprise_v1_generated_recaptcha_enterprise_service_get_metrics_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_GetKey_sync", + "regionTag": "recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_GetMetrics_sync", "segments": [ { "end": 51, @@ -832,7 +1478,7 @@ "type": "RESPONSE_HANDLING" } ], - "title": "recaptchaenterprise_v1_generated_recaptcha_enterprise_service_get_key_sync.py" + "title": "recaptchaenterprise_v1_generated_recaptcha_enterprise_service_get_metrics_sync.py" }, { "canonical": true, @@ -842,22 +1488,22 @@ "fullName": "google.cloud.recaptchaenterprise_v1.RecaptchaEnterpriseServiceAsyncClient", "shortName": "RecaptchaEnterpriseServiceAsyncClient" }, - "fullName": "google.cloud.recaptchaenterprise_v1.RecaptchaEnterpriseServiceAsyncClient.get_metrics", + "fullName": "google.cloud.recaptchaenterprise_v1.RecaptchaEnterpriseServiceAsyncClient.list_firewall_policies", "method": { - "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.GetMetrics", + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.ListFirewallPolicies", "service": { "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService", "shortName": "RecaptchaEnterpriseService" }, - "shortName": "GetMetrics" + "shortName": "ListFirewallPolicies" }, "parameters": [ { "name": "request", - "type": "google.cloud.recaptchaenterprise_v1.types.GetMetricsRequest" + "type": "google.cloud.recaptchaenterprise_v1.types.ListFirewallPoliciesRequest" }, { - "name": "name", + "name": "parent", "type": "str" }, { @@ -873,22 +1519,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.recaptchaenterprise_v1.types.Metrics", - "shortName": "get_metrics" + "resultType": "google.cloud.recaptchaenterprise_v1.services.recaptcha_enterprise_service.pagers.ListFirewallPoliciesAsyncPager", + "shortName": "list_firewall_policies" }, - "description": "Sample for GetMetrics", - "file": "recaptchaenterprise_v1_generated_recaptcha_enterprise_service_get_metrics_async.py", + "description": "Sample for ListFirewallPolicies", + "file": "recaptchaenterprise_v1_generated_recaptcha_enterprise_service_list_firewall_policies_async.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_GetMetrics_async", + "regionTag": "recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_ListFirewallPolicies_async", "segments": [ { - "end": 51, + "end": 52, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 52, "start": 27, "type": "SHORT" }, @@ -908,12 +1554,12 @@ "type": "REQUEST_EXECUTION" }, { - "end": 52, + "end": 53, "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "recaptchaenterprise_v1_generated_recaptcha_enterprise_service_get_metrics_async.py" + "title": "recaptchaenterprise_v1_generated_recaptcha_enterprise_service_list_firewall_policies_async.py" }, { "canonical": true, @@ -922,22 +1568,22 @@ "fullName": "google.cloud.recaptchaenterprise_v1.RecaptchaEnterpriseServiceClient", "shortName": "RecaptchaEnterpriseServiceClient" }, - "fullName": "google.cloud.recaptchaenterprise_v1.RecaptchaEnterpriseServiceClient.get_metrics", + "fullName": "google.cloud.recaptchaenterprise_v1.RecaptchaEnterpriseServiceClient.list_firewall_policies", "method": { - "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.GetMetrics", + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.ListFirewallPolicies", "service": { "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService", "shortName": "RecaptchaEnterpriseService" }, - "shortName": "GetMetrics" + "shortName": "ListFirewallPolicies" }, "parameters": [ { "name": "request", - "type": "google.cloud.recaptchaenterprise_v1.types.GetMetricsRequest" + "type": "google.cloud.recaptchaenterprise_v1.types.ListFirewallPoliciesRequest" }, { - "name": "name", + "name": "parent", "type": "str" }, { @@ -953,22 +1599,22 @@ "type": "Sequence[Tuple[str, str]" } ], - "resultType": "google.cloud.recaptchaenterprise_v1.types.Metrics", - "shortName": "get_metrics" + "resultType": "google.cloud.recaptchaenterprise_v1.services.recaptcha_enterprise_service.pagers.ListFirewallPoliciesPager", + "shortName": "list_firewall_policies" }, - "description": "Sample for GetMetrics", - "file": "recaptchaenterprise_v1_generated_recaptcha_enterprise_service_get_metrics_sync.py", + "description": "Sample for ListFirewallPolicies", + "file": "recaptchaenterprise_v1_generated_recaptcha_enterprise_service_list_firewall_policies_sync.py", "language": "PYTHON", "origin": "API_DEFINITION", - "regionTag": "recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_GetMetrics_sync", + "regionTag": "recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_ListFirewallPolicies_sync", "segments": [ { - "end": 51, + "end": 52, "start": 27, "type": "FULL" }, { - "end": 51, + "end": 52, "start": 27, "type": "SHORT" }, @@ -988,12 +1634,12 @@ "type": "REQUEST_EXECUTION" }, { - "end": 52, + "end": 53, "start": 49, "type": "RESPONSE_HANDLING" } ], - "title": "recaptchaenterprise_v1_generated_recaptcha_enterprise_service_get_metrics_sync.py" + "title": "recaptchaenterprise_v1_generated_recaptcha_enterprise_service_list_firewall_policies_sync.py" }, { "canonical": true, @@ -1961,6 +2607,175 @@ ], "title": "recaptchaenterprise_v1_generated_recaptcha_enterprise_service_search_related_account_group_memberships_sync.py" }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.recaptchaenterprise_v1.RecaptchaEnterpriseServiceAsyncClient", + "shortName": "RecaptchaEnterpriseServiceAsyncClient" + }, + "fullName": "google.cloud.recaptchaenterprise_v1.RecaptchaEnterpriseServiceAsyncClient.update_firewall_policy", + "method": { + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.UpdateFirewallPolicy", + "service": { + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService", + "shortName": "RecaptchaEnterpriseService" + }, + "shortName": "UpdateFirewallPolicy" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.recaptchaenterprise_v1.types.UpdateFirewallPolicyRequest" + }, + { + "name": "firewall_policy", + "type": "google.cloud.recaptchaenterprise_v1.types.FirewallPolicy" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.recaptchaenterprise_v1.types.FirewallPolicy", + "shortName": "update_firewall_policy" + }, + "description": "Sample for UpdateFirewallPolicy", + "file": "recaptchaenterprise_v1_generated_recaptcha_enterprise_service_update_firewall_policy_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_UpdateFirewallPolicy_async", + "segments": [ + { + "end": 50, + "start": 27, + "type": "FULL" + }, + { + "end": 50, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 47, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 51, + "start": 48, + "type": "RESPONSE_HANDLING" + } + ], + "title": "recaptchaenterprise_v1_generated_recaptcha_enterprise_service_update_firewall_policy_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.recaptchaenterprise_v1.RecaptchaEnterpriseServiceClient", + "shortName": "RecaptchaEnterpriseServiceClient" + }, + "fullName": "google.cloud.recaptchaenterprise_v1.RecaptchaEnterpriseServiceClient.update_firewall_policy", + "method": { + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.UpdateFirewallPolicy", + "service": { + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService", + "shortName": "RecaptchaEnterpriseService" + }, + "shortName": "UpdateFirewallPolicy" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.recaptchaenterprise_v1.types.UpdateFirewallPolicyRequest" + }, + { + "name": "firewall_policy", + "type": "google.cloud.recaptchaenterprise_v1.types.FirewallPolicy" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.recaptchaenterprise_v1.types.FirewallPolicy", + "shortName": "update_firewall_policy" + }, + "description": "Sample for UpdateFirewallPolicy", + "file": "recaptchaenterprise_v1_generated_recaptcha_enterprise_service_update_firewall_policy_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_UpdateFirewallPolicy_sync", + "segments": [ + { + "end": 50, + "start": 27, + "type": "FULL" + }, + { + "end": 50, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 44, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 47, + "start": 45, + "type": "REQUEST_EXECUTION" + }, + { + "end": 51, + "start": 48, + "type": "RESPONSE_HANDLING" + } + ], + "title": "recaptchaenterprise_v1_generated_recaptcha_enterprise_service_update_firewall_policy_sync.py" + }, { "canonical": true, "clientMethod": { diff --git a/packages/google-cloud-recaptcha-enterprise/scripts/fixup_recaptchaenterprise_v1_keywords.py b/packages/google-cloud-recaptcha-enterprise/scripts/fixup_recaptchaenterprise_v1_keywords.py index ca80cf9d5da8..23414045041e 100644 --- a/packages/google-cloud-recaptcha-enterprise/scripts/fixup_recaptchaenterprise_v1_keywords.py +++ b/packages/google-cloud-recaptcha-enterprise/scripts/fixup_recaptchaenterprise_v1_keywords.py @@ -41,16 +41,21 @@ class recaptchaenterpriseCallTransformer(cst.CSTTransformer): METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { 'annotate_assessment': ('name', 'annotation', 'reasons', 'hashed_account_id', 'transaction_event', ), 'create_assessment': ('parent', 'assessment', ), + 'create_firewall_policy': ('parent', 'firewall_policy', ), 'create_key': ('parent', 'key', ), + 'delete_firewall_policy': ('name', ), 'delete_key': ('name', ), + 'get_firewall_policy': ('name', ), 'get_key': ('name', ), 'get_metrics': ('name', ), + 'list_firewall_policies': ('parent', 'page_size', 'page_token', ), 'list_keys': ('parent', 'page_size', 'page_token', ), 'list_related_account_group_memberships': ('parent', 'page_size', 'page_token', ), 'list_related_account_groups': ('parent', 'page_size', 'page_token', ), 'migrate_key': ('name', 'skip_billing_check', ), 'retrieve_legacy_secret_key': ('key', ), 'search_related_account_group_memberships': ('project', 'hashed_account_id', 'page_size', 'page_token', ), + 'update_firewall_policy': ('firewall_policy', 'update_mask', ), 'update_key': ('key', 'update_mask', ), } diff --git a/packages/google-cloud-recaptcha-enterprise/tests/unit/gapic/recaptchaenterprise_v1/test_recaptcha_enterprise_service.py b/packages/google-cloud-recaptcha-enterprise/tests/unit/gapic/recaptchaenterprise_v1/test_recaptcha_enterprise_service.py index 5b8e2cf9df8f..8e9f2b9f8927 100644 --- a/packages/google-cloud-recaptcha-enterprise/tests/unit/gapic/recaptchaenterprise_v1/test_recaptcha_enterprise_service.py +++ b/packages/google-cloud-recaptcha-enterprise/tests/unit/gapic/recaptchaenterprise_v1/test_recaptcha_enterprise_service.py @@ -31,8 +31,10 @@ from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.oauth2 import service_account +from google.protobuf import any_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore +from google.rpc import status_pb2 # type: ignore import grpc from grpc.experimental import aio from proto.marshal.rules import wrappers @@ -3225,6 +3227,1483 @@ async def test_get_metrics_flattened_error_async(): ) +@pytest.mark.parametrize( + "request_type", + [ + recaptchaenterprise.CreateFirewallPolicyRequest, + dict, + ], +) +def test_create_firewall_policy(request_type, transport: str = "grpc"): + client = RecaptchaEnterpriseServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_firewall_policy), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = recaptchaenterprise.FirewallPolicy( + name="name_value", + description="description_value", + path="path_value", + condition="condition_value", + ) + response = client.create_firewall_policy(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == recaptchaenterprise.CreateFirewallPolicyRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, recaptchaenterprise.FirewallPolicy) + assert response.name == "name_value" + assert response.description == "description_value" + assert response.path == "path_value" + assert response.condition == "condition_value" + + +def test_create_firewall_policy_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = RecaptchaEnterpriseServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_firewall_policy), "__call__" + ) as call: + client.create_firewall_policy() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == recaptchaenterprise.CreateFirewallPolicyRequest() + + +@pytest.mark.asyncio +async def test_create_firewall_policy_async( + transport: str = "grpc_asyncio", + request_type=recaptchaenterprise.CreateFirewallPolicyRequest, +): + client = RecaptchaEnterpriseServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_firewall_policy), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + recaptchaenterprise.FirewallPolicy( + name="name_value", + description="description_value", + path="path_value", + condition="condition_value", + ) + ) + response = await client.create_firewall_policy(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == recaptchaenterprise.CreateFirewallPolicyRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, recaptchaenterprise.FirewallPolicy) + assert response.name == "name_value" + assert response.description == "description_value" + assert response.path == "path_value" + assert response.condition == "condition_value" + + +@pytest.mark.asyncio +async def test_create_firewall_policy_async_from_dict(): + await test_create_firewall_policy_async(request_type=dict) + + +def test_create_firewall_policy_field_headers(): + client = RecaptchaEnterpriseServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = recaptchaenterprise.CreateFirewallPolicyRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_firewall_policy), "__call__" + ) as call: + call.return_value = recaptchaenterprise.FirewallPolicy() + client.create_firewall_policy(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_create_firewall_policy_field_headers_async(): + client = RecaptchaEnterpriseServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = recaptchaenterprise.CreateFirewallPolicyRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_firewall_policy), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + recaptchaenterprise.FirewallPolicy() + ) + await client.create_firewall_policy(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +def test_create_firewall_policy_flattened(): + client = RecaptchaEnterpriseServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_firewall_policy), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = recaptchaenterprise.FirewallPolicy() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_firewall_policy( + parent="parent_value", + firewall_policy=recaptchaenterprise.FirewallPolicy(name="name_value"), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].firewall_policy + mock_val = recaptchaenterprise.FirewallPolicy(name="name_value") + assert arg == mock_val + + +def test_create_firewall_policy_flattened_error(): + client = RecaptchaEnterpriseServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_firewall_policy( + recaptchaenterprise.CreateFirewallPolicyRequest(), + parent="parent_value", + firewall_policy=recaptchaenterprise.FirewallPolicy(name="name_value"), + ) + + +@pytest.mark.asyncio +async def test_create_firewall_policy_flattened_async(): + client = RecaptchaEnterpriseServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_firewall_policy), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = recaptchaenterprise.FirewallPolicy() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + recaptchaenterprise.FirewallPolicy() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_firewall_policy( + parent="parent_value", + firewall_policy=recaptchaenterprise.FirewallPolicy(name="name_value"), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].firewall_policy + mock_val = recaptchaenterprise.FirewallPolicy(name="name_value") + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_create_firewall_policy_flattened_error_async(): + client = RecaptchaEnterpriseServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.create_firewall_policy( + recaptchaenterprise.CreateFirewallPolicyRequest(), + parent="parent_value", + firewall_policy=recaptchaenterprise.FirewallPolicy(name="name_value"), + ) + + +@pytest.mark.parametrize( + "request_type", + [ + recaptchaenterprise.ListFirewallPoliciesRequest, + dict, + ], +) +def test_list_firewall_policies(request_type, transport: str = "grpc"): + client = RecaptchaEnterpriseServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_firewall_policies), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = recaptchaenterprise.ListFirewallPoliciesResponse( + next_page_token="next_page_token_value", + ) + response = client.list_firewall_policies(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == recaptchaenterprise.ListFirewallPoliciesRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListFirewallPoliciesPager) + assert response.next_page_token == "next_page_token_value" + + +def test_list_firewall_policies_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = RecaptchaEnterpriseServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_firewall_policies), "__call__" + ) as call: + client.list_firewall_policies() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == recaptchaenterprise.ListFirewallPoliciesRequest() + + +@pytest.mark.asyncio +async def test_list_firewall_policies_async( + transport: str = "grpc_asyncio", + request_type=recaptchaenterprise.ListFirewallPoliciesRequest, +): + client = RecaptchaEnterpriseServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_firewall_policies), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + recaptchaenterprise.ListFirewallPoliciesResponse( + next_page_token="next_page_token_value", + ) + ) + response = await client.list_firewall_policies(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == recaptchaenterprise.ListFirewallPoliciesRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListFirewallPoliciesAsyncPager) + assert response.next_page_token == "next_page_token_value" + + +@pytest.mark.asyncio +async def test_list_firewall_policies_async_from_dict(): + await test_list_firewall_policies_async(request_type=dict) + + +def test_list_firewall_policies_field_headers(): + client = RecaptchaEnterpriseServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = recaptchaenterprise.ListFirewallPoliciesRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_firewall_policies), "__call__" + ) as call: + call.return_value = recaptchaenterprise.ListFirewallPoliciesResponse() + client.list_firewall_policies(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_list_firewall_policies_field_headers_async(): + client = RecaptchaEnterpriseServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = recaptchaenterprise.ListFirewallPoliciesRequest() + + request.parent = "parent_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_firewall_policies), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + recaptchaenterprise.ListFirewallPoliciesResponse() + ) + await client.list_firewall_policies(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] + + +def test_list_firewall_policies_flattened(): + client = RecaptchaEnterpriseServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_firewall_policies), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = recaptchaenterprise.ListFirewallPoliciesResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_firewall_policies( + parent="parent_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + + +def test_list_firewall_policies_flattened_error(): + client = RecaptchaEnterpriseServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_firewall_policies( + recaptchaenterprise.ListFirewallPoliciesRequest(), + parent="parent_value", + ) + + +@pytest.mark.asyncio +async def test_list_firewall_policies_flattened_async(): + client = RecaptchaEnterpriseServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_firewall_policies), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = recaptchaenterprise.ListFirewallPoliciesResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + recaptchaenterprise.ListFirewallPoliciesResponse() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_firewall_policies( + parent="parent_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_list_firewall_policies_flattened_error_async(): + client = RecaptchaEnterpriseServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.list_firewall_policies( + recaptchaenterprise.ListFirewallPoliciesRequest(), + parent="parent_value", + ) + + +def test_list_firewall_policies_pager(transport_name: str = "grpc"): + client = RecaptchaEnterpriseServiceClient( + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_firewall_policies), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + recaptchaenterprise.ListFirewallPoliciesResponse( + firewall_policies=[ + recaptchaenterprise.FirewallPolicy(), + recaptchaenterprise.FirewallPolicy(), + recaptchaenterprise.FirewallPolicy(), + ], + next_page_token="abc", + ), + recaptchaenterprise.ListFirewallPoliciesResponse( + firewall_policies=[], + next_page_token="def", + ), + recaptchaenterprise.ListFirewallPoliciesResponse( + firewall_policies=[ + recaptchaenterprise.FirewallPolicy(), + ], + next_page_token="ghi", + ), + recaptchaenterprise.ListFirewallPoliciesResponse( + firewall_policies=[ + recaptchaenterprise.FirewallPolicy(), + recaptchaenterprise.FirewallPolicy(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("parent", ""),)), + ) + pager = client.list_firewall_policies(request={}) + + assert pager._metadata == metadata + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, recaptchaenterprise.FirewallPolicy) for i in results) + + +def test_list_firewall_policies_pages(transport_name: str = "grpc"): + client = RecaptchaEnterpriseServiceClient( + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_firewall_policies), "__call__" + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + recaptchaenterprise.ListFirewallPoliciesResponse( + firewall_policies=[ + recaptchaenterprise.FirewallPolicy(), + recaptchaenterprise.FirewallPolicy(), + recaptchaenterprise.FirewallPolicy(), + ], + next_page_token="abc", + ), + recaptchaenterprise.ListFirewallPoliciesResponse( + firewall_policies=[], + next_page_token="def", + ), + recaptchaenterprise.ListFirewallPoliciesResponse( + firewall_policies=[ + recaptchaenterprise.FirewallPolicy(), + ], + next_page_token="ghi", + ), + recaptchaenterprise.ListFirewallPoliciesResponse( + firewall_policies=[ + recaptchaenterprise.FirewallPolicy(), + recaptchaenterprise.FirewallPolicy(), + ], + ), + RuntimeError, + ) + pages = list(client.list_firewall_policies(request={}).pages) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.asyncio +async def test_list_firewall_policies_async_pager(): + client = RecaptchaEnterpriseServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_firewall_policies), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + recaptchaenterprise.ListFirewallPoliciesResponse( + firewall_policies=[ + recaptchaenterprise.FirewallPolicy(), + recaptchaenterprise.FirewallPolicy(), + recaptchaenterprise.FirewallPolicy(), + ], + next_page_token="abc", + ), + recaptchaenterprise.ListFirewallPoliciesResponse( + firewall_policies=[], + next_page_token="def", + ), + recaptchaenterprise.ListFirewallPoliciesResponse( + firewall_policies=[ + recaptchaenterprise.FirewallPolicy(), + ], + next_page_token="ghi", + ), + recaptchaenterprise.ListFirewallPoliciesResponse( + firewall_policies=[ + recaptchaenterprise.FirewallPolicy(), + recaptchaenterprise.FirewallPolicy(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_firewall_policies( + request={}, + ) + assert async_pager.next_page_token == "abc" + responses = [] + async for response in async_pager: # pragma: no branch + responses.append(response) + + assert len(responses) == 6 + assert all(isinstance(i, recaptchaenterprise.FirewallPolicy) for i in responses) + + +@pytest.mark.asyncio +async def test_list_firewall_policies_async_pages(): + client = RecaptchaEnterpriseServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_firewall_policies), + "__call__", + new_callable=mock.AsyncMock, + ) as call: + # Set the response to a series of pages. + call.side_effect = ( + recaptchaenterprise.ListFirewallPoliciesResponse( + firewall_policies=[ + recaptchaenterprise.FirewallPolicy(), + recaptchaenterprise.FirewallPolicy(), + recaptchaenterprise.FirewallPolicy(), + ], + next_page_token="abc", + ), + recaptchaenterprise.ListFirewallPoliciesResponse( + firewall_policies=[], + next_page_token="def", + ), + recaptchaenterprise.ListFirewallPoliciesResponse( + firewall_policies=[ + recaptchaenterprise.FirewallPolicy(), + ], + next_page_token="ghi", + ), + recaptchaenterprise.ListFirewallPoliciesResponse( + firewall_policies=[ + recaptchaenterprise.FirewallPolicy(), + recaptchaenterprise.FirewallPolicy(), + ], + ), + RuntimeError, + ) + pages = [] + # Workaround issue in python 3.9 related to code coverage by adding `# pragma: no branch` + # See https://github.com/googleapis/gapic-generator-python/pull/1174#issuecomment-1025132372 + async for page_ in ( # pragma: no branch + await client.list_firewall_policies(request={}) + ).pages: + pages.append(page_) + for page_, token in zip(pages, ["abc", "def", "ghi", ""]): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.parametrize( + "request_type", + [ + recaptchaenterprise.GetFirewallPolicyRequest, + dict, + ], +) +def test_get_firewall_policy(request_type, transport: str = "grpc"): + client = RecaptchaEnterpriseServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_firewall_policy), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = recaptchaenterprise.FirewallPolicy( + name="name_value", + description="description_value", + path="path_value", + condition="condition_value", + ) + response = client.get_firewall_policy(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == recaptchaenterprise.GetFirewallPolicyRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, recaptchaenterprise.FirewallPolicy) + assert response.name == "name_value" + assert response.description == "description_value" + assert response.path == "path_value" + assert response.condition == "condition_value" + + +def test_get_firewall_policy_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = RecaptchaEnterpriseServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_firewall_policy), "__call__" + ) as call: + client.get_firewall_policy() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == recaptchaenterprise.GetFirewallPolicyRequest() + + +@pytest.mark.asyncio +async def test_get_firewall_policy_async( + transport: str = "grpc_asyncio", + request_type=recaptchaenterprise.GetFirewallPolicyRequest, +): + client = RecaptchaEnterpriseServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_firewall_policy), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + recaptchaenterprise.FirewallPolicy( + name="name_value", + description="description_value", + path="path_value", + condition="condition_value", + ) + ) + response = await client.get_firewall_policy(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == recaptchaenterprise.GetFirewallPolicyRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, recaptchaenterprise.FirewallPolicy) + assert response.name == "name_value" + assert response.description == "description_value" + assert response.path == "path_value" + assert response.condition == "condition_value" + + +@pytest.mark.asyncio +async def test_get_firewall_policy_async_from_dict(): + await test_get_firewall_policy_async(request_type=dict) + + +def test_get_firewall_policy_field_headers(): + client = RecaptchaEnterpriseServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = recaptchaenterprise.GetFirewallPolicyRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_firewall_policy), "__call__" + ) as call: + call.return_value = recaptchaenterprise.FirewallPolicy() + client.get_firewall_policy(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_get_firewall_policy_field_headers_async(): + client = RecaptchaEnterpriseServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = recaptchaenterprise.GetFirewallPolicyRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_firewall_policy), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + recaptchaenterprise.FirewallPolicy() + ) + await client.get_firewall_policy(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +def test_get_firewall_policy_flattened(): + client = RecaptchaEnterpriseServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_firewall_policy), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = recaptchaenterprise.FirewallPolicy() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_firewall_policy( + name="name_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +def test_get_firewall_policy_flattened_error(): + client = RecaptchaEnterpriseServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_firewall_policy( + recaptchaenterprise.GetFirewallPolicyRequest(), + name="name_value", + ) + + +@pytest.mark.asyncio +async def test_get_firewall_policy_flattened_async(): + client = RecaptchaEnterpriseServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_firewall_policy), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = recaptchaenterprise.FirewallPolicy() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + recaptchaenterprise.FirewallPolicy() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_firewall_policy( + name="name_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_get_firewall_policy_flattened_error_async(): + client = RecaptchaEnterpriseServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.get_firewall_policy( + recaptchaenterprise.GetFirewallPolicyRequest(), + name="name_value", + ) + + +@pytest.mark.parametrize( + "request_type", + [ + recaptchaenterprise.UpdateFirewallPolicyRequest, + dict, + ], +) +def test_update_firewall_policy(request_type, transport: str = "grpc"): + client = RecaptchaEnterpriseServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_firewall_policy), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = recaptchaenterprise.FirewallPolicy( + name="name_value", + description="description_value", + path="path_value", + condition="condition_value", + ) + response = client.update_firewall_policy(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == recaptchaenterprise.UpdateFirewallPolicyRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, recaptchaenterprise.FirewallPolicy) + assert response.name == "name_value" + assert response.description == "description_value" + assert response.path == "path_value" + assert response.condition == "condition_value" + + +def test_update_firewall_policy_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = RecaptchaEnterpriseServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_firewall_policy), "__call__" + ) as call: + client.update_firewall_policy() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == recaptchaenterprise.UpdateFirewallPolicyRequest() + + +@pytest.mark.asyncio +async def test_update_firewall_policy_async( + transport: str = "grpc_asyncio", + request_type=recaptchaenterprise.UpdateFirewallPolicyRequest, +): + client = RecaptchaEnterpriseServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_firewall_policy), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + recaptchaenterprise.FirewallPolicy( + name="name_value", + description="description_value", + path="path_value", + condition="condition_value", + ) + ) + response = await client.update_firewall_policy(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == recaptchaenterprise.UpdateFirewallPolicyRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, recaptchaenterprise.FirewallPolicy) + assert response.name == "name_value" + assert response.description == "description_value" + assert response.path == "path_value" + assert response.condition == "condition_value" + + +@pytest.mark.asyncio +async def test_update_firewall_policy_async_from_dict(): + await test_update_firewall_policy_async(request_type=dict) + + +def test_update_firewall_policy_field_headers(): + client = RecaptchaEnterpriseServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = recaptchaenterprise.UpdateFirewallPolicyRequest() + + request.firewall_policy.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_firewall_policy), "__call__" + ) as call: + call.return_value = recaptchaenterprise.FirewallPolicy() + client.update_firewall_policy(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "firewall_policy.name=name_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_update_firewall_policy_field_headers_async(): + client = RecaptchaEnterpriseServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = recaptchaenterprise.UpdateFirewallPolicyRequest() + + request.firewall_policy.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_firewall_policy), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + recaptchaenterprise.FirewallPolicy() + ) + await client.update_firewall_policy(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "firewall_policy.name=name_value", + ) in kw["metadata"] + + +def test_update_firewall_policy_flattened(): + client = RecaptchaEnterpriseServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_firewall_policy), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = recaptchaenterprise.FirewallPolicy() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_firewall_policy( + firewall_policy=recaptchaenterprise.FirewallPolicy(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].firewall_policy + mock_val = recaptchaenterprise.FirewallPolicy(name="name_value") + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + assert arg == mock_val + + +def test_update_firewall_policy_flattened_error(): + client = RecaptchaEnterpriseServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_firewall_policy( + recaptchaenterprise.UpdateFirewallPolicyRequest(), + firewall_policy=recaptchaenterprise.FirewallPolicy(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +@pytest.mark.asyncio +async def test_update_firewall_policy_flattened_async(): + client = RecaptchaEnterpriseServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_firewall_policy), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = recaptchaenterprise.FirewallPolicy() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + recaptchaenterprise.FirewallPolicy() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_firewall_policy( + firewall_policy=recaptchaenterprise.FirewallPolicy(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].firewall_policy + mock_val = recaptchaenterprise.FirewallPolicy(name="name_value") + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_update_firewall_policy_flattened_error_async(): + client = RecaptchaEnterpriseServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.update_firewall_policy( + recaptchaenterprise.UpdateFirewallPolicyRequest(), + firewall_policy=recaptchaenterprise.FirewallPolicy(name="name_value"), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), + ) + + +@pytest.mark.parametrize( + "request_type", + [ + recaptchaenterprise.DeleteFirewallPolicyRequest, + dict, + ], +) +def test_delete_firewall_policy(request_type, transport: str = "grpc"): + client = RecaptchaEnterpriseServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_firewall_policy), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = None + response = client.delete_firewall_policy(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == recaptchaenterprise.DeleteFirewallPolicyRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +def test_delete_firewall_policy_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = RecaptchaEnterpriseServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_firewall_policy), "__call__" + ) as call: + client.delete_firewall_policy() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == recaptchaenterprise.DeleteFirewallPolicyRequest() + + +@pytest.mark.asyncio +async def test_delete_firewall_policy_async( + transport: str = "grpc_asyncio", + request_type=recaptchaenterprise.DeleteFirewallPolicyRequest, +): + client = RecaptchaEnterpriseServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_firewall_policy), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + response = await client.delete_firewall_policy(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == recaptchaenterprise.DeleteFirewallPolicyRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +@pytest.mark.asyncio +async def test_delete_firewall_policy_async_from_dict(): + await test_delete_firewall_policy_async(request_type=dict) + + +def test_delete_firewall_policy_field_headers(): + client = RecaptchaEnterpriseServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = recaptchaenterprise.DeleteFirewallPolicyRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_firewall_policy), "__call__" + ) as call: + call.return_value = None + client.delete_firewall_policy(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_delete_firewall_policy_field_headers_async(): + client = RecaptchaEnterpriseServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = recaptchaenterprise.DeleteFirewallPolicyRequest() + + request.name = "name_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_firewall_policy), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + await client.delete_firewall_policy(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] + + +def test_delete_firewall_policy_flattened(): + client = RecaptchaEnterpriseServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_firewall_policy), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = None + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.delete_firewall_policy( + name="name_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +def test_delete_firewall_policy_flattened_error(): + client = RecaptchaEnterpriseServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_firewall_policy( + recaptchaenterprise.DeleteFirewallPolicyRequest(), + name="name_value", + ) + + +@pytest.mark.asyncio +async def test_delete_firewall_policy_flattened_async(): + client = RecaptchaEnterpriseServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_firewall_policy), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = None + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.delete_firewall_policy( + name="name_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_delete_firewall_policy_flattened_error_async(): + client = RecaptchaEnterpriseServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.delete_firewall_policy( + recaptchaenterprise.DeleteFirewallPolicyRequest(), + name="name_value", + ) + + @pytest.mark.parametrize( "request_type", [ @@ -4763,6 +6242,11 @@ def test_recaptcha_enterprise_service_base_transport(): "delete_key", "migrate_key", "get_metrics", + "create_firewall_policy", + "list_firewall_policies", + "get_firewall_policy", + "update_firewall_policy", + "delete_firewall_policy", "list_related_account_groups", "list_related_account_group_memberships", "search_related_account_group_memberships", @@ -5138,9 +6622,34 @@ def test_parse_assessment_path(): assert expected == actual -def test_key_path(): +def test_firewall_policy_path(): project = "oyster" - key = "nudibranch" + firewallpolicy = "nudibranch" + expected = "projects/{project}/firewallpolicies/{firewallpolicy}".format( + project=project, + firewallpolicy=firewallpolicy, + ) + actual = RecaptchaEnterpriseServiceClient.firewall_policy_path( + project, firewallpolicy + ) + assert expected == actual + + +def test_parse_firewall_policy_path(): + expected = { + "project": "cuttlefish", + "firewallpolicy": "mussel", + } + path = RecaptchaEnterpriseServiceClient.firewall_policy_path(**expected) + + # Check that the path construction is reversible. + actual = RecaptchaEnterpriseServiceClient.parse_firewall_policy_path(path) + assert expected == actual + + +def test_key_path(): + project = "winkle" + key = "nautilus" expected = "projects/{project}/keys/{key}".format( project=project, key=key, @@ -5151,8 +6660,8 @@ def test_key_path(): def test_parse_key_path(): expected = { - "project": "cuttlefish", - "key": "mussel", + "project": "scallop", + "key": "abalone", } path = RecaptchaEnterpriseServiceClient.key_path(**expected) @@ -5162,8 +6671,8 @@ def test_parse_key_path(): def test_metrics_path(): - project = "winkle" - key = "nautilus" + project = "squid" + key = "clam" expected = "projects/{project}/keys/{key}/metrics".format( project=project, key=key, @@ -5174,8 +6683,8 @@ def test_metrics_path(): def test_parse_metrics_path(): expected = { - "project": "scallop", - "key": "abalone", + "project": "whelk", + "key": "octopus", } path = RecaptchaEnterpriseServiceClient.metrics_path(**expected) @@ -5185,8 +6694,8 @@ def test_parse_metrics_path(): def test_related_account_group_path(): - project = "squid" - relatedaccountgroup = "clam" + project = "oyster" + relatedaccountgroup = "nudibranch" expected = "projects/{project}/relatedaccountgroups/{relatedaccountgroup}".format( project=project, relatedaccountgroup=relatedaccountgroup, @@ -5199,8 +6708,8 @@ def test_related_account_group_path(): def test_parse_related_account_group_path(): expected = { - "project": "whelk", - "relatedaccountgroup": "octopus", + "project": "cuttlefish", + "relatedaccountgroup": "mussel", } path = RecaptchaEnterpriseServiceClient.related_account_group_path(**expected) @@ -5210,9 +6719,9 @@ def test_parse_related_account_group_path(): def test_related_account_group_membership_path(): - project = "oyster" - relatedaccountgroup = "nudibranch" - membership = "cuttlefish" + project = "winkle" + relatedaccountgroup = "nautilus" + membership = "scallop" expected = "projects/{project}/relatedaccountgroups/{relatedaccountgroup}/memberships/{membership}".format( project=project, relatedaccountgroup=relatedaccountgroup, @@ -5226,9 +6735,9 @@ def test_related_account_group_membership_path(): def test_parse_related_account_group_membership_path(): expected = { - "project": "mussel", - "relatedaccountgroup": "winkle", - "membership": "nautilus", + "project": "abalone", + "relatedaccountgroup": "squid", + "membership": "clam", } path = RecaptchaEnterpriseServiceClient.related_account_group_membership_path( **expected @@ -5244,7 +6753,7 @@ def test_parse_related_account_group_membership_path(): def test_common_billing_account_path(): - billing_account = "scallop" + billing_account = "whelk" expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -5256,7 +6765,7 @@ def test_common_billing_account_path(): def test_parse_common_billing_account_path(): expected = { - "billing_account": "abalone", + "billing_account": "octopus", } path = RecaptchaEnterpriseServiceClient.common_billing_account_path(**expected) @@ -5266,7 +6775,7 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): - folder = "squid" + folder = "oyster" expected = "folders/{folder}".format( folder=folder, ) @@ -5276,7 +6785,7 @@ def test_common_folder_path(): def test_parse_common_folder_path(): expected = { - "folder": "clam", + "folder": "nudibranch", } path = RecaptchaEnterpriseServiceClient.common_folder_path(**expected) @@ -5286,7 +6795,7 @@ def test_parse_common_folder_path(): def test_common_organization_path(): - organization = "whelk" + organization = "cuttlefish" expected = "organizations/{organization}".format( organization=organization, ) @@ -5296,7 +6805,7 @@ def test_common_organization_path(): def test_parse_common_organization_path(): expected = { - "organization": "octopus", + "organization": "mussel", } path = RecaptchaEnterpriseServiceClient.common_organization_path(**expected) @@ -5306,7 +6815,7 @@ def test_parse_common_organization_path(): def test_common_project_path(): - project = "oyster" + project = "winkle" expected = "projects/{project}".format( project=project, ) @@ -5316,7 +6825,7 @@ def test_common_project_path(): def test_parse_common_project_path(): expected = { - "project": "nudibranch", + "project": "nautilus", } path = RecaptchaEnterpriseServiceClient.common_project_path(**expected) @@ -5326,8 +6835,8 @@ def test_parse_common_project_path(): def test_common_location_path(): - project = "cuttlefish" - location = "mussel" + project = "scallop" + location = "abalone" expected = "projects/{project}/locations/{location}".format( project=project, location=location, @@ -5338,8 +6847,8 @@ def test_common_location_path(): def test_parse_common_location_path(): expected = { - "project": "winkle", - "location": "nautilus", + "project": "squid", + "location": "clam", } path = RecaptchaEnterpriseServiceClient.common_location_path(**expected)