From cfde6bd9cfc8281c4a11518e9dc6b7f790426d75 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Fri, 5 Jan 2024 09:53:56 +0000 Subject: [PATCH 1/3] docs: updates on multiple comments, syncing terminology and clarifying some aspects PiperOrigin-RevId: 595909478 Source-Link: https://github.com/googleapis/googleapis/commit/a903ba835e1b7d747eb235e186d07b479b2b1270 Source-Link: https://github.com/googleapis/googleapis-gen/commit/c8f2c82600606bf2dc69b56f5dad9a4ca2f5a998 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXNlY3VyaXR5Y2VudGVybWFuYWdlbWVudC8uT3dsQm90LnlhbWwiLCJoIjoiYzhmMmM4MjYwMDYwNmJmMmRjNjliNTZmNWRhZDlhNGNhMmY1YTk5OCJ9 --- .../v1/.coveragerc | 13 + .../v1/.flake8 | 33 + .../v1/MANIFEST.in | 2 + .../v1/README.rst | 49 + .../v1/docs/_static/custom.css | 3 + .../v1/docs/conf.py | 376 + .../v1/docs/index.rst | 7 + .../security_center_management.rst | 10 + .../securitycentermanagement_v1/services_.rst | 6 + .../securitycentermanagement_v1/types_.rst | 6 + .../securitycentermanagement/__init__.py | 91 + .../securitycentermanagement/gapic_version.py | 16 + .../cloud/securitycentermanagement/py.typed | 2 + .../securitycentermanagement_v1/__init__.py | 92 + .../gapic_metadata.json | 298 + .../gapic_version.py | 16 + .../securitycentermanagement_v1/py.typed | 2 + .../services/__init__.py | 15 + .../security_center_management/__init__.py | 22 + .../async_client.py | 2501 ++++ .../security_center_management/client.py | 2653 ++++ .../security_center_management/pagers.py | 744 + .../transports/__init__.py | 38 + .../transports/base.py | 488 + .../transports/grpc.py | 818 ++ .../transports/grpc_asyncio.py | 817 ++ .../transports/rest.py | 2627 ++++ .../types/__init__.py | 84 + .../types/security_center_management.py | 1771 +++ .../v1/mypy.ini | 3 + .../v1/noxfile.py | 177 + ...nt_threat_detection_custom_module_async.py | 52 + ...ent_threat_detection_custom_module_sync.py | 52 + ...ty_health_analytics_custom_module_async.py | 52 + ...ity_health_analytics_custom_module_sync.py | 52 + ...nt_threat_detection_custom_module_async.py | 50 + ...ent_threat_detection_custom_module_sync.py | 50 + ...ty_health_analytics_custom_module_async.py | 50 + ...ity_health_analytics_custom_module_sync.py | 50 + ...nt_threat_detection_custom_module_async.py | 52 + ...ent_threat_detection_custom_module_sync.py | 52 + ...ty_health_analytics_custom_module_async.py | 52 + ...ity_health_analytics_custom_module_sync.py | 52 + ...nt_threat_detection_custom_module_async.py | 52 + ...ent_threat_detection_custom_module_sync.py | 52 + ...ty_health_analytics_custom_module_async.py | 52 + ...ity_health_analytics_custom_module_sync.py | 52 + ...t_threat_detection_custom_modules_async.py | 53 + ...nt_threat_detection_custom_modules_sync.py | 53 + ...y_health_analytics_custom_modules_async.py | 53 + ...ty_health_analytics_custom_modules_sync.py | 53 + ...t_threat_detection_custom_modules_async.py | 53 + ...nt_threat_detection_custom_modules_sync.py | 53 + ...y_health_analytics_custom_modules_async.py | 53 + ...ty_health_analytics_custom_modules_sync.py | 53 + ...t_threat_detection_custom_modules_async.py | 53 + ...nt_threat_detection_custom_modules_sync.py | 53 + ...y_health_analytics_custom_modules_async.py | 53 + ...ty_health_analytics_custom_modules_sync.py | 53 + ...ty_health_analytics_custom_module_async.py | 56 + ...ity_health_analytics_custom_module_sync.py | 56 + ...nt_threat_detection_custom_module_async.py | 51 + ...ent_threat_detection_custom_module_sync.py | 51 + ...ty_health_analytics_custom_module_async.py | 51 + ...ity_health_analytics_custom_module_sync.py | 51 + ...nt_threat_detection_custom_module_async.py | 54 + ...ent_threat_detection_custom_module_sync.py | 54 + ...gle.cloud.securitycentermanagement.v1.json | 2941 ++++ ...up_securitycentermanagement_v1_keywords.py | 193 + .../v1/setup.py | 91 + .../v1/testing/constraints-3.10.txt | 7 + .../v1/testing/constraints-3.11.txt | 7 + .../v1/testing/constraints-3.12.txt | 7 + .../v1/testing/constraints-3.7.txt | 10 + .../v1/testing/constraints-3.8.txt | 7 + .../v1/testing/constraints-3.9.txt | 7 + .../v1/tests/__init__.py | 16 + .../v1/tests/unit/__init__.py | 16 + .../v1/tests/unit/gapic/__init__.py | 16 + .../securitycentermanagement_v1/__init__.py | 16 + .../test_security_center_management.py | 12019 ++++++++++++++++ 81 files changed, 31017 insertions(+) create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/.coveragerc create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/.flake8 create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/MANIFEST.in create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/README.rst create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/docs/_static/custom.css create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/docs/conf.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/docs/index.rst create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/docs/securitycentermanagement_v1/security_center_management.rst create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/docs/securitycentermanagement_v1/services_.rst create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/docs/securitycentermanagement_v1/types_.rst create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement/__init__.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement/gapic_version.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement/py.typed create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/__init__.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/gapic_metadata.json create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/gapic_version.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/py.typed create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/__init__.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/__init__.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/async_client.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/client.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/pagers.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/__init__.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/base.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/grpc.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/grpc_asyncio.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/rest.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/types/__init__.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/types/security_center_management.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/mypy.ini create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/noxfile.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_create_event_threat_detection_custom_module_async.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_create_event_threat_detection_custom_module_sync.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_create_security_health_analytics_custom_module_async.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_create_security_health_analytics_custom_module_sync.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_delete_event_threat_detection_custom_module_async.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_delete_event_threat_detection_custom_module_sync.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_delete_security_health_analytics_custom_module_async.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_delete_security_health_analytics_custom_module_sync.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_effective_event_threat_detection_custom_module_async.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_effective_event_threat_detection_custom_module_sync.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_effective_security_health_analytics_custom_module_async.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_effective_security_health_analytics_custom_module_sync.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_event_threat_detection_custom_module_async.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_event_threat_detection_custom_module_sync.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_security_health_analytics_custom_module_async.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_security_health_analytics_custom_module_sync.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_descendant_event_threat_detection_custom_modules_async.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_descendant_event_threat_detection_custom_modules_sync.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_descendant_security_health_analytics_custom_modules_async.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_descendant_security_health_analytics_custom_modules_sync.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_effective_event_threat_detection_custom_modules_async.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_effective_event_threat_detection_custom_modules_sync.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_effective_security_health_analytics_custom_modules_async.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_effective_security_health_analytics_custom_modules_sync.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_event_threat_detection_custom_modules_async.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_event_threat_detection_custom_modules_sync.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_security_health_analytics_custom_modules_async.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_security_health_analytics_custom_modules_sync.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_simulate_security_health_analytics_custom_module_async.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_simulate_security_health_analytics_custom_module_sync.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_update_event_threat_detection_custom_module_async.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_update_event_threat_detection_custom_module_sync.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_update_security_health_analytics_custom_module_async.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_update_security_health_analytics_custom_module_sync.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_validate_event_threat_detection_custom_module_async.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_validate_event_threat_detection_custom_module_sync.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/snippet_metadata_google.cloud.securitycentermanagement.v1.json create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/scripts/fixup_securitycentermanagement_v1_keywords.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/setup.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/testing/constraints-3.10.txt create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/testing/constraints-3.11.txt create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/testing/constraints-3.12.txt create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/testing/constraints-3.7.txt create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/testing/constraints-3.8.txt create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/testing/constraints-3.9.txt create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/tests/__init__.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/tests/unit/__init__.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/tests/unit/gapic/__init__.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/tests/unit/gapic/securitycentermanagement_v1/__init__.py create mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/tests/unit/gapic/securitycentermanagement_v1/test_security_center_management.py diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/.coveragerc b/owl-bot-staging/google-cloud-securitycentermanagement/v1/.coveragerc new file mode 100644 index 000000000000..866d4d24017c --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/.coveragerc @@ -0,0 +1,13 @@ +[run] +branch = True + +[report] +show_missing = True +omit = + google/cloud/securitycentermanagement/__init__.py + google/cloud/securitycentermanagement/gapic_version.py +exclude_lines = + # Re-enable the standard pragma + pragma: NO COVER + # Ignore debug-only repr + def __repr__ diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/.flake8 b/owl-bot-staging/google-cloud-securitycentermanagement/v1/.flake8 new file mode 100644 index 000000000000..29227d4cf419 --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/.flake8 @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +# +# Copyright 2020 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 +# +# https://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 by synthtool. DO NOT EDIT! +[flake8] +ignore = E203, E266, E501, W503 +exclude = + # Exclude generated code. + **/proto/** + **/gapic/** + **/services/** + **/types/** + *_pb2.py + + # Standard linting exemptions. + **/.nox/** + __pycache__, + .git, + *.pyc, + conf.py diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/MANIFEST.in b/owl-bot-staging/google-cloud-securitycentermanagement/v1/MANIFEST.in new file mode 100644 index 000000000000..c0ed60a0af08 --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/MANIFEST.in @@ -0,0 +1,2 @@ +recursive-include google/cloud/securitycentermanagement *.py +recursive-include google/cloud/securitycentermanagement_v1 *.py diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/README.rst b/owl-bot-staging/google-cloud-securitycentermanagement/v1/README.rst new file mode 100644 index 000000000000..152c83ba9bf7 --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/README.rst @@ -0,0 +1,49 @@ +Python Client for Google Cloud Securitycentermanagement API +================================================= + +Quick Start +----------- + +In order to use this library, you first need to go through the following steps: + +1. `Select or create a Cloud Platform project.`_ +2. `Enable billing for your project.`_ +3. Enable the Google Cloud Securitycentermanagement API. +4. `Setup Authentication.`_ + +.. _Select or create a Cloud Platform project.: https://console.cloud.google.com/project +.. _Enable billing for your project.: https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project +.. _Setup Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html + +Installation +~~~~~~~~~~~~ + +Install this library in a `virtualenv`_ using pip. `virtualenv`_ is a tool to +create isolated Python environments. The basic problem it addresses is one of +dependencies and versions, and indirectly permissions. + +With `virtualenv`_, it's possible to install this library without needing system +install permissions, and without clashing with the installed system +dependencies. + +.. _`virtualenv`: https://virtualenv.pypa.io/en/latest/ + + +Mac/Linux +^^^^^^^^^ + +.. code-block:: console + + python3 -m venv + source /bin/activate + /bin/pip install /path/to/library + + +Windows +^^^^^^^ + +.. code-block:: console + + python3 -m venv + \Scripts\activate + \Scripts\pip.exe install \path\to\library diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/docs/_static/custom.css b/owl-bot-staging/google-cloud-securitycentermanagement/v1/docs/_static/custom.css new file mode 100644 index 000000000000..06423be0b592 --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/docs/_static/custom.css @@ -0,0 +1,3 @@ +dl.field-list > dt { + min-width: 100px +} diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/docs/conf.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/docs/conf.py new file mode 100644 index 000000000000..0eb0d885ae4b --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/docs/conf.py @@ -0,0 +1,376 @@ +# -*- 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. +# +# +# google-cloud-securitycentermanagement documentation build configuration file +# +# This file is execfile()d with the current directory set to its +# containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys +import os +import shlex + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +sys.path.insert(0, os.path.abspath("..")) + +__version__ = "0.1.0" + +# -- General configuration ------------------------------------------------ + +# If your documentation needs a minimal Sphinx version, state it here. +needs_sphinx = "4.0.1" + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + "sphinx.ext.autodoc", + "sphinx.ext.autosummary", + "sphinx.ext.intersphinx", + "sphinx.ext.coverage", + "sphinx.ext.napoleon", + "sphinx.ext.todo", + "sphinx.ext.viewcode", +] + +# autodoc/autosummary flags +autoclass_content = "both" +autodoc_default_flags = ["members"] +autosummary_generate = True + + +# Add any paths that contain templates here, relative to this directory. +templates_path = ["_templates"] + +# Allow markdown includes (so releases.md can include CHANGLEOG.md) +# http://www.sphinx-doc.org/en/master/markdown.html +source_parsers = {".md": "recommonmark.parser.CommonMarkParser"} + +# The suffix(es) of source filenames. +# You can specify multiple suffix as a list of string: +source_suffix = [".rst", ".md"] + +# The encoding of source files. +# source_encoding = 'utf-8-sig' + +# The root toctree document. +root_doc = "index" + +# General information about the project. +project = u"google-cloud-securitycentermanagement" +copyright = u"2023, Google, LLC" +author = u"Google APIs" # TODO: autogenerate this bit + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The full version, including alpha/beta/rc tags. +release = __version__ +# The short X.Y version. +version = ".".join(release.split(".")[0:2]) + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +language = 'en' + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +# today = '' +# Else, today_fmt is used as the format for a strftime call. +# today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = ["_build"] + +# The reST default role (used for this markup: `text`) to use for all +# documents. +# default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +# add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +# add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +# show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = "sphinx" + +# A list of ignored prefixes for module index sorting. +# modindex_common_prefix = [] + +# If true, keep warnings as "system message" paragraphs in the built documents. +# keep_warnings = False + +# If true, `todo` and `todoList` produce output, else they produce nothing. +todo_include_todos = True + + +# -- Options for HTML output ---------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +html_theme = "alabaster" + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +html_theme_options = { + "description": "Google Cloud Client Libraries for Python", + "github_user": "googleapis", + "github_repo": "google-cloud-python", + "github_banner": True, + "font_family": "'Roboto', Georgia, sans", + "head_font_family": "'Roboto', Georgia, serif", + "code_font_family": "'Roboto Mono', 'Consolas', monospace", +} + +# Add any paths that contain custom themes here, relative to this directory. +# html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +# html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +# html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +# html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +# html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ["_static"] + +# Add any extra paths that contain custom files (such as robots.txt or +# .htaccess) here, relative to this directory. These files are copied +# directly to the root of the documentation. +# html_extra_path = [] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +# html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +# html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +# html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +# html_additional_pages = {} + +# If false, no module index is generated. +# html_domain_indices = True + +# If false, no index is generated. +# html_use_index = True + +# If true, the index is split into individual pages for each letter. +# html_split_index = False + +# If true, links to the reST sources are added to the pages. +# html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +# html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +# html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +# html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +# html_file_suffix = None + +# Language to be used for generating the HTML full-text search index. +# Sphinx supports the following languages: +# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' +# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr' +# html_search_language = 'en' + +# A dictionary with options for the search language support, empty by default. +# Now only 'ja' uses this config value +# html_search_options = {'type': 'default'} + +# The name of a javascript file (relative to the configuration directory) that +# implements a search results scorer. If empty, the default will be used. +# html_search_scorer = 'scorer.js' + +# Output file base name for HTML help builder. +htmlhelp_basename = "google-cloud-securitycentermanagement-doc" + +# -- Options for warnings ------------------------------------------------------ + + +suppress_warnings = [ + # Temporarily suppress this to avoid "more than one target found for + # cross-reference" warning, which are intractable for us to avoid while in + # a mono-repo. + # See https://github.com/sphinx-doc/sphinx/blob + # /2a65ffeef5c107c19084fabdd706cdff3f52d93c/sphinx/domains/python.py#L843 + "ref.python" +] + +# -- Options for LaTeX output --------------------------------------------- + +latex_elements = { + # The paper size ('letterpaper' or 'a4paper'). + # 'papersize': 'letterpaper', + # The font size ('10pt', '11pt' or '12pt'). + # 'pointsize': '10pt', + # Additional stuff for the LaTeX preamble. + # 'preamble': '', + # Latex figure (float) alignment + # 'figure_align': 'htbp', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). +latex_documents = [ + ( + root_doc, + "google-cloud-securitycentermanagement.tex", + u"google-cloud-securitycentermanagement Documentation", + author, + "manual", + ) +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +# latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +# latex_use_parts = False + +# If true, show page references after internal links. +# latex_show_pagerefs = False + +# If true, show URL addresses after external links. +# latex_show_urls = False + +# Documents to append as an appendix to all manuals. +# latex_appendices = [] + +# If false, no module index is generated. +# latex_domain_indices = True + + +# -- Options for manual page output --------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + ( + root_doc, + "google-cloud-securitycentermanagement", + u"Google Cloud Securitycentermanagement Documentation", + [author], + 1, + ) +] + +# If true, show URL addresses after external links. +# man_show_urls = False + + +# -- Options for Texinfo output ------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + ( + root_doc, + "google-cloud-securitycentermanagement", + u"google-cloud-securitycentermanagement Documentation", + author, + "google-cloud-securitycentermanagement", + "GAPIC library for Google Cloud Securitycentermanagement API", + "APIs", + ) +] + +# Documents to append as an appendix to all manuals. +# texinfo_appendices = [] + +# If false, no module index is generated. +# texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +# texinfo_show_urls = 'footnote' + +# If true, do not generate a @detailmenu in the "Top" node's menu. +# texinfo_no_detailmenu = False + + +# Example configuration for intersphinx: refer to the Python standard library. +intersphinx_mapping = { + "python": ("http://python.readthedocs.org/en/latest/", None), + "gax": ("https://gax-python.readthedocs.org/en/latest/", None), + "google-auth": ("https://google-auth.readthedocs.io/en/stable", None), + "google-gax": ("https://gax-python.readthedocs.io/en/latest/", None), + "google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None), + "grpc": ("https://grpc.io/grpc/python/", None), + "requests": ("http://requests.kennethreitz.org/en/stable/", None), + "proto": ("https://proto-plus-python.readthedocs.io/en/stable", None), + "protobuf": ("https://googleapis.dev/python/protobuf/latest/", None), +} + + +# Napoleon settings +napoleon_google_docstring = True +napoleon_numpy_docstring = True +napoleon_include_private_with_doc = False +napoleon_include_special_with_doc = True +napoleon_use_admonition_for_examples = False +napoleon_use_admonition_for_notes = False +napoleon_use_admonition_for_references = False +napoleon_use_ivar = False +napoleon_use_param = True +napoleon_use_rtype = True diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/docs/index.rst b/owl-bot-staging/google-cloud-securitycentermanagement/v1/docs/index.rst new file mode 100644 index 000000000000..c6c66dbbf5f0 --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/docs/index.rst @@ -0,0 +1,7 @@ +API Reference +------------- +.. toctree:: + :maxdepth: 2 + + securitycentermanagement_v1/services + securitycentermanagement_v1/types diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/docs/securitycentermanagement_v1/security_center_management.rst b/owl-bot-staging/google-cloud-securitycentermanagement/v1/docs/securitycentermanagement_v1/security_center_management.rst new file mode 100644 index 000000000000..b3c4450ffa9d --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/docs/securitycentermanagement_v1/security_center_management.rst @@ -0,0 +1,10 @@ +SecurityCenterManagement +------------------------------------------ + +.. automodule:: google.cloud.securitycentermanagement_v1.services.security_center_management + :members: + :inherited-members: + +.. automodule:: google.cloud.securitycentermanagement_v1.services.security_center_management.pagers + :members: + :inherited-members: diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/docs/securitycentermanagement_v1/services_.rst b/owl-bot-staging/google-cloud-securitycentermanagement/v1/docs/securitycentermanagement_v1/services_.rst new file mode 100644 index 000000000000..6643c9eb98b0 --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/docs/securitycentermanagement_v1/services_.rst @@ -0,0 +1,6 @@ +Services for Google Cloud Securitycentermanagement v1 API +========================================================= +.. toctree:: + :maxdepth: 2 + + security_center_management diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/docs/securitycentermanagement_v1/types_.rst b/owl-bot-staging/google-cloud-securitycentermanagement/v1/docs/securitycentermanagement_v1/types_.rst new file mode 100644 index 000000000000..508e249b3abf --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/docs/securitycentermanagement_v1/types_.rst @@ -0,0 +1,6 @@ +Types for Google Cloud Securitycentermanagement v1 API +====================================================== + +.. automodule:: google.cloud.securitycentermanagement_v1.types + :members: + :show-inheritance: diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement/__init__.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement/__init__.py new file mode 100644 index 000000000000..14e9ea1b1f5e --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement/__init__.py @@ -0,0 +1,91 @@ +# -*- 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. +# +from google.cloud.securitycentermanagement import gapic_version as package_version + +__version__ = package_version.__version__ + + +from google.cloud.securitycentermanagement_v1.services.security_center_management.client import SecurityCenterManagementClient +from google.cloud.securitycentermanagement_v1.services.security_center_management.async_client import SecurityCenterManagementAsyncClient + +from google.cloud.securitycentermanagement_v1.types.security_center_management import CreateEventThreatDetectionCustomModuleRequest +from google.cloud.securitycentermanagement_v1.types.security_center_management import CreateSecurityHealthAnalyticsCustomModuleRequest +from google.cloud.securitycentermanagement_v1.types.security_center_management import CustomConfig +from google.cloud.securitycentermanagement_v1.types.security_center_management import DeleteEventThreatDetectionCustomModuleRequest +from google.cloud.securitycentermanagement_v1.types.security_center_management import DeleteSecurityHealthAnalyticsCustomModuleRequest +from google.cloud.securitycentermanagement_v1.types.security_center_management import EffectiveEventThreatDetectionCustomModule +from google.cloud.securitycentermanagement_v1.types.security_center_management import EffectiveSecurityHealthAnalyticsCustomModule +from google.cloud.securitycentermanagement_v1.types.security_center_management import EventThreatDetectionCustomModule +from google.cloud.securitycentermanagement_v1.types.security_center_management import GetEffectiveEventThreatDetectionCustomModuleRequest +from google.cloud.securitycentermanagement_v1.types.security_center_management import GetEffectiveSecurityHealthAnalyticsCustomModuleRequest +from google.cloud.securitycentermanagement_v1.types.security_center_management import GetEventThreatDetectionCustomModuleRequest +from google.cloud.securitycentermanagement_v1.types.security_center_management import GetSecurityHealthAnalyticsCustomModuleRequest +from google.cloud.securitycentermanagement_v1.types.security_center_management import ListDescendantEventThreatDetectionCustomModulesRequest +from google.cloud.securitycentermanagement_v1.types.security_center_management import ListDescendantEventThreatDetectionCustomModulesResponse +from google.cloud.securitycentermanagement_v1.types.security_center_management import ListDescendantSecurityHealthAnalyticsCustomModulesRequest +from google.cloud.securitycentermanagement_v1.types.security_center_management import ListDescendantSecurityHealthAnalyticsCustomModulesResponse +from google.cloud.securitycentermanagement_v1.types.security_center_management import ListEffectiveEventThreatDetectionCustomModulesRequest +from google.cloud.securitycentermanagement_v1.types.security_center_management import ListEffectiveEventThreatDetectionCustomModulesResponse +from google.cloud.securitycentermanagement_v1.types.security_center_management import ListEffectiveSecurityHealthAnalyticsCustomModulesRequest +from google.cloud.securitycentermanagement_v1.types.security_center_management import ListEffectiveSecurityHealthAnalyticsCustomModulesResponse +from google.cloud.securitycentermanagement_v1.types.security_center_management import ListEventThreatDetectionCustomModulesRequest +from google.cloud.securitycentermanagement_v1.types.security_center_management import ListEventThreatDetectionCustomModulesResponse +from google.cloud.securitycentermanagement_v1.types.security_center_management import ListSecurityHealthAnalyticsCustomModulesRequest +from google.cloud.securitycentermanagement_v1.types.security_center_management import ListSecurityHealthAnalyticsCustomModulesResponse +from google.cloud.securitycentermanagement_v1.types.security_center_management import SecurityHealthAnalyticsCustomModule +from google.cloud.securitycentermanagement_v1.types.security_center_management import SimulatedFinding +from google.cloud.securitycentermanagement_v1.types.security_center_management import SimulateSecurityHealthAnalyticsCustomModuleRequest +from google.cloud.securitycentermanagement_v1.types.security_center_management import SimulateSecurityHealthAnalyticsCustomModuleResponse +from google.cloud.securitycentermanagement_v1.types.security_center_management import UpdateEventThreatDetectionCustomModuleRequest +from google.cloud.securitycentermanagement_v1.types.security_center_management import UpdateSecurityHealthAnalyticsCustomModuleRequest +from google.cloud.securitycentermanagement_v1.types.security_center_management import ValidateEventThreatDetectionCustomModuleRequest +from google.cloud.securitycentermanagement_v1.types.security_center_management import ValidateEventThreatDetectionCustomModuleResponse + +__all__ = ('SecurityCenterManagementClient', + 'SecurityCenterManagementAsyncClient', + 'CreateEventThreatDetectionCustomModuleRequest', + 'CreateSecurityHealthAnalyticsCustomModuleRequest', + 'CustomConfig', + 'DeleteEventThreatDetectionCustomModuleRequest', + 'DeleteSecurityHealthAnalyticsCustomModuleRequest', + 'EffectiveEventThreatDetectionCustomModule', + 'EffectiveSecurityHealthAnalyticsCustomModule', + 'EventThreatDetectionCustomModule', + 'GetEffectiveEventThreatDetectionCustomModuleRequest', + 'GetEffectiveSecurityHealthAnalyticsCustomModuleRequest', + 'GetEventThreatDetectionCustomModuleRequest', + 'GetSecurityHealthAnalyticsCustomModuleRequest', + 'ListDescendantEventThreatDetectionCustomModulesRequest', + 'ListDescendantEventThreatDetectionCustomModulesResponse', + 'ListDescendantSecurityHealthAnalyticsCustomModulesRequest', + 'ListDescendantSecurityHealthAnalyticsCustomModulesResponse', + 'ListEffectiveEventThreatDetectionCustomModulesRequest', + 'ListEffectiveEventThreatDetectionCustomModulesResponse', + 'ListEffectiveSecurityHealthAnalyticsCustomModulesRequest', + 'ListEffectiveSecurityHealthAnalyticsCustomModulesResponse', + 'ListEventThreatDetectionCustomModulesRequest', + 'ListEventThreatDetectionCustomModulesResponse', + 'ListSecurityHealthAnalyticsCustomModulesRequest', + 'ListSecurityHealthAnalyticsCustomModulesResponse', + 'SecurityHealthAnalyticsCustomModule', + 'SimulatedFinding', + 'SimulateSecurityHealthAnalyticsCustomModuleRequest', + 'SimulateSecurityHealthAnalyticsCustomModuleResponse', + 'UpdateEventThreatDetectionCustomModuleRequest', + 'UpdateSecurityHealthAnalyticsCustomModuleRequest', + 'ValidateEventThreatDetectionCustomModuleRequest', + 'ValidateEventThreatDetectionCustomModuleResponse', +) diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement/gapic_version.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement/gapic_version.py new file mode 100644 index 000000000000..360a0d13ebdd --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement/gapic_version.py @@ -0,0 +1,16 @@ +# -*- 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. +# +__version__ = "0.0.0" # {x-release-please-version} diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement/py.typed b/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement/py.typed new file mode 100644 index 000000000000..6303193f649f --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-cloud-securitycentermanagement package uses inline types. diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/__init__.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/__init__.py new file mode 100644 index 000000000000..8055dca9ed4c --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/__init__.py @@ -0,0 +1,92 @@ +# -*- 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. +# +from google.cloud.securitycentermanagement_v1 import gapic_version as package_version + +__version__ = package_version.__version__ + + +from .services.security_center_management import SecurityCenterManagementClient +from .services.security_center_management import SecurityCenterManagementAsyncClient + +from .types.security_center_management import CreateEventThreatDetectionCustomModuleRequest +from .types.security_center_management import CreateSecurityHealthAnalyticsCustomModuleRequest +from .types.security_center_management import CustomConfig +from .types.security_center_management import DeleteEventThreatDetectionCustomModuleRequest +from .types.security_center_management import DeleteSecurityHealthAnalyticsCustomModuleRequest +from .types.security_center_management import EffectiveEventThreatDetectionCustomModule +from .types.security_center_management import EffectiveSecurityHealthAnalyticsCustomModule +from .types.security_center_management import EventThreatDetectionCustomModule +from .types.security_center_management import GetEffectiveEventThreatDetectionCustomModuleRequest +from .types.security_center_management import GetEffectiveSecurityHealthAnalyticsCustomModuleRequest +from .types.security_center_management import GetEventThreatDetectionCustomModuleRequest +from .types.security_center_management import GetSecurityHealthAnalyticsCustomModuleRequest +from .types.security_center_management import ListDescendantEventThreatDetectionCustomModulesRequest +from .types.security_center_management import ListDescendantEventThreatDetectionCustomModulesResponse +from .types.security_center_management import ListDescendantSecurityHealthAnalyticsCustomModulesRequest +from .types.security_center_management import ListDescendantSecurityHealthAnalyticsCustomModulesResponse +from .types.security_center_management import ListEffectiveEventThreatDetectionCustomModulesRequest +from .types.security_center_management import ListEffectiveEventThreatDetectionCustomModulesResponse +from .types.security_center_management import ListEffectiveSecurityHealthAnalyticsCustomModulesRequest +from .types.security_center_management import ListEffectiveSecurityHealthAnalyticsCustomModulesResponse +from .types.security_center_management import ListEventThreatDetectionCustomModulesRequest +from .types.security_center_management import ListEventThreatDetectionCustomModulesResponse +from .types.security_center_management import ListSecurityHealthAnalyticsCustomModulesRequest +from .types.security_center_management import ListSecurityHealthAnalyticsCustomModulesResponse +from .types.security_center_management import SecurityHealthAnalyticsCustomModule +from .types.security_center_management import SimulatedFinding +from .types.security_center_management import SimulateSecurityHealthAnalyticsCustomModuleRequest +from .types.security_center_management import SimulateSecurityHealthAnalyticsCustomModuleResponse +from .types.security_center_management import UpdateEventThreatDetectionCustomModuleRequest +from .types.security_center_management import UpdateSecurityHealthAnalyticsCustomModuleRequest +from .types.security_center_management import ValidateEventThreatDetectionCustomModuleRequest +from .types.security_center_management import ValidateEventThreatDetectionCustomModuleResponse + +__all__ = ( + 'SecurityCenterManagementAsyncClient', +'CreateEventThreatDetectionCustomModuleRequest', +'CreateSecurityHealthAnalyticsCustomModuleRequest', +'CustomConfig', +'DeleteEventThreatDetectionCustomModuleRequest', +'DeleteSecurityHealthAnalyticsCustomModuleRequest', +'EffectiveEventThreatDetectionCustomModule', +'EffectiveSecurityHealthAnalyticsCustomModule', +'EventThreatDetectionCustomModule', +'GetEffectiveEventThreatDetectionCustomModuleRequest', +'GetEffectiveSecurityHealthAnalyticsCustomModuleRequest', +'GetEventThreatDetectionCustomModuleRequest', +'GetSecurityHealthAnalyticsCustomModuleRequest', +'ListDescendantEventThreatDetectionCustomModulesRequest', +'ListDescendantEventThreatDetectionCustomModulesResponse', +'ListDescendantSecurityHealthAnalyticsCustomModulesRequest', +'ListDescendantSecurityHealthAnalyticsCustomModulesResponse', +'ListEffectiveEventThreatDetectionCustomModulesRequest', +'ListEffectiveEventThreatDetectionCustomModulesResponse', +'ListEffectiveSecurityHealthAnalyticsCustomModulesRequest', +'ListEffectiveSecurityHealthAnalyticsCustomModulesResponse', +'ListEventThreatDetectionCustomModulesRequest', +'ListEventThreatDetectionCustomModulesResponse', +'ListSecurityHealthAnalyticsCustomModulesRequest', +'ListSecurityHealthAnalyticsCustomModulesResponse', +'SecurityCenterManagementClient', +'SecurityHealthAnalyticsCustomModule', +'SimulateSecurityHealthAnalyticsCustomModuleRequest', +'SimulateSecurityHealthAnalyticsCustomModuleResponse', +'SimulatedFinding', +'UpdateEventThreatDetectionCustomModuleRequest', +'UpdateSecurityHealthAnalyticsCustomModuleRequest', +'ValidateEventThreatDetectionCustomModuleRequest', +'ValidateEventThreatDetectionCustomModuleResponse', +) diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/gapic_metadata.json b/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/gapic_metadata.json new file mode 100644 index 000000000000..bc19f51f6a72 --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/gapic_metadata.json @@ -0,0 +1,298 @@ + { + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "python", + "libraryPackage": "google.cloud.securitycentermanagement_v1", + "protoPackage": "google.cloud.securitycentermanagement.v1", + "schema": "1.0", + "services": { + "SecurityCenterManagement": { + "clients": { + "grpc": { + "libraryClient": "SecurityCenterManagementClient", + "rpcs": { + "CreateEventThreatDetectionCustomModule": { + "methods": [ + "create_event_threat_detection_custom_module" + ] + }, + "CreateSecurityHealthAnalyticsCustomModule": { + "methods": [ + "create_security_health_analytics_custom_module" + ] + }, + "DeleteEventThreatDetectionCustomModule": { + "methods": [ + "delete_event_threat_detection_custom_module" + ] + }, + "DeleteSecurityHealthAnalyticsCustomModule": { + "methods": [ + "delete_security_health_analytics_custom_module" + ] + }, + "GetEffectiveEventThreatDetectionCustomModule": { + "methods": [ + "get_effective_event_threat_detection_custom_module" + ] + }, + "GetEffectiveSecurityHealthAnalyticsCustomModule": { + "methods": [ + "get_effective_security_health_analytics_custom_module" + ] + }, + "GetEventThreatDetectionCustomModule": { + "methods": [ + "get_event_threat_detection_custom_module" + ] + }, + "GetSecurityHealthAnalyticsCustomModule": { + "methods": [ + "get_security_health_analytics_custom_module" + ] + }, + "ListDescendantEventThreatDetectionCustomModules": { + "methods": [ + "list_descendant_event_threat_detection_custom_modules" + ] + }, + "ListDescendantSecurityHealthAnalyticsCustomModules": { + "methods": [ + "list_descendant_security_health_analytics_custom_modules" + ] + }, + "ListEffectiveEventThreatDetectionCustomModules": { + "methods": [ + "list_effective_event_threat_detection_custom_modules" + ] + }, + "ListEffectiveSecurityHealthAnalyticsCustomModules": { + "methods": [ + "list_effective_security_health_analytics_custom_modules" + ] + }, + "ListEventThreatDetectionCustomModules": { + "methods": [ + "list_event_threat_detection_custom_modules" + ] + }, + "ListSecurityHealthAnalyticsCustomModules": { + "methods": [ + "list_security_health_analytics_custom_modules" + ] + }, + "SimulateSecurityHealthAnalyticsCustomModule": { + "methods": [ + "simulate_security_health_analytics_custom_module" + ] + }, + "UpdateEventThreatDetectionCustomModule": { + "methods": [ + "update_event_threat_detection_custom_module" + ] + }, + "UpdateSecurityHealthAnalyticsCustomModule": { + "methods": [ + "update_security_health_analytics_custom_module" + ] + }, + "ValidateEventThreatDetectionCustomModule": { + "methods": [ + "validate_event_threat_detection_custom_module" + ] + } + } + }, + "grpc-async": { + "libraryClient": "SecurityCenterManagementAsyncClient", + "rpcs": { + "CreateEventThreatDetectionCustomModule": { + "methods": [ + "create_event_threat_detection_custom_module" + ] + }, + "CreateSecurityHealthAnalyticsCustomModule": { + "methods": [ + "create_security_health_analytics_custom_module" + ] + }, + "DeleteEventThreatDetectionCustomModule": { + "methods": [ + "delete_event_threat_detection_custom_module" + ] + }, + "DeleteSecurityHealthAnalyticsCustomModule": { + "methods": [ + "delete_security_health_analytics_custom_module" + ] + }, + "GetEffectiveEventThreatDetectionCustomModule": { + "methods": [ + "get_effective_event_threat_detection_custom_module" + ] + }, + "GetEffectiveSecurityHealthAnalyticsCustomModule": { + "methods": [ + "get_effective_security_health_analytics_custom_module" + ] + }, + "GetEventThreatDetectionCustomModule": { + "methods": [ + "get_event_threat_detection_custom_module" + ] + }, + "GetSecurityHealthAnalyticsCustomModule": { + "methods": [ + "get_security_health_analytics_custom_module" + ] + }, + "ListDescendantEventThreatDetectionCustomModules": { + "methods": [ + "list_descendant_event_threat_detection_custom_modules" + ] + }, + "ListDescendantSecurityHealthAnalyticsCustomModules": { + "methods": [ + "list_descendant_security_health_analytics_custom_modules" + ] + }, + "ListEffectiveEventThreatDetectionCustomModules": { + "methods": [ + "list_effective_event_threat_detection_custom_modules" + ] + }, + "ListEffectiveSecurityHealthAnalyticsCustomModules": { + "methods": [ + "list_effective_security_health_analytics_custom_modules" + ] + }, + "ListEventThreatDetectionCustomModules": { + "methods": [ + "list_event_threat_detection_custom_modules" + ] + }, + "ListSecurityHealthAnalyticsCustomModules": { + "methods": [ + "list_security_health_analytics_custom_modules" + ] + }, + "SimulateSecurityHealthAnalyticsCustomModule": { + "methods": [ + "simulate_security_health_analytics_custom_module" + ] + }, + "UpdateEventThreatDetectionCustomModule": { + "methods": [ + "update_event_threat_detection_custom_module" + ] + }, + "UpdateSecurityHealthAnalyticsCustomModule": { + "methods": [ + "update_security_health_analytics_custom_module" + ] + }, + "ValidateEventThreatDetectionCustomModule": { + "methods": [ + "validate_event_threat_detection_custom_module" + ] + } + } + }, + "rest": { + "libraryClient": "SecurityCenterManagementClient", + "rpcs": { + "CreateEventThreatDetectionCustomModule": { + "methods": [ + "create_event_threat_detection_custom_module" + ] + }, + "CreateSecurityHealthAnalyticsCustomModule": { + "methods": [ + "create_security_health_analytics_custom_module" + ] + }, + "DeleteEventThreatDetectionCustomModule": { + "methods": [ + "delete_event_threat_detection_custom_module" + ] + }, + "DeleteSecurityHealthAnalyticsCustomModule": { + "methods": [ + "delete_security_health_analytics_custom_module" + ] + }, + "GetEffectiveEventThreatDetectionCustomModule": { + "methods": [ + "get_effective_event_threat_detection_custom_module" + ] + }, + "GetEffectiveSecurityHealthAnalyticsCustomModule": { + "methods": [ + "get_effective_security_health_analytics_custom_module" + ] + }, + "GetEventThreatDetectionCustomModule": { + "methods": [ + "get_event_threat_detection_custom_module" + ] + }, + "GetSecurityHealthAnalyticsCustomModule": { + "methods": [ + "get_security_health_analytics_custom_module" + ] + }, + "ListDescendantEventThreatDetectionCustomModules": { + "methods": [ + "list_descendant_event_threat_detection_custom_modules" + ] + }, + "ListDescendantSecurityHealthAnalyticsCustomModules": { + "methods": [ + "list_descendant_security_health_analytics_custom_modules" + ] + }, + "ListEffectiveEventThreatDetectionCustomModules": { + "methods": [ + "list_effective_event_threat_detection_custom_modules" + ] + }, + "ListEffectiveSecurityHealthAnalyticsCustomModules": { + "methods": [ + "list_effective_security_health_analytics_custom_modules" + ] + }, + "ListEventThreatDetectionCustomModules": { + "methods": [ + "list_event_threat_detection_custom_modules" + ] + }, + "ListSecurityHealthAnalyticsCustomModules": { + "methods": [ + "list_security_health_analytics_custom_modules" + ] + }, + "SimulateSecurityHealthAnalyticsCustomModule": { + "methods": [ + "simulate_security_health_analytics_custom_module" + ] + }, + "UpdateEventThreatDetectionCustomModule": { + "methods": [ + "update_event_threat_detection_custom_module" + ] + }, + "UpdateSecurityHealthAnalyticsCustomModule": { + "methods": [ + "update_security_health_analytics_custom_module" + ] + }, + "ValidateEventThreatDetectionCustomModule": { + "methods": [ + "validate_event_threat_detection_custom_module" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/gapic_version.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/gapic_version.py new file mode 100644 index 000000000000..360a0d13ebdd --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/gapic_version.py @@ -0,0 +1,16 @@ +# -*- 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. +# +__version__ = "0.0.0" # {x-release-please-version} diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/py.typed b/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/py.typed new file mode 100644 index 000000000000..6303193f649f --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/py.typed @@ -0,0 +1,2 @@ +# Marker file for PEP 561. +# The google-cloud-securitycentermanagement package uses inline types. diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/__init__.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/__init__.py new file mode 100644 index 000000000000..89a37dc92c5a --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/__init__.py @@ -0,0 +1,15 @@ +# -*- 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. +# diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/__init__.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/__init__.py new file mode 100644 index 000000000000..2e8ab1204d6a --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/__init__.py @@ -0,0 +1,22 @@ +# -*- 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. +# +from .client import SecurityCenterManagementClient +from .async_client import SecurityCenterManagementAsyncClient + +__all__ = ( + 'SecurityCenterManagementClient', + 'SecurityCenterManagementAsyncClient', +) diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/async_client.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/async_client.py new file mode 100644 index 000000000000..fcaade62cbd6 --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/async_client.py @@ -0,0 +1,2501 @@ +# -*- 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. +# +from collections import OrderedDict +import functools +import re +from typing import Dict, Mapping, MutableMapping, MutableSequence, Optional, Sequence, Tuple, Type, Union + +from google.cloud.securitycentermanagement_v1 import gapic_version as package_version + +from google.api_core.client_options import ClientOptions +from google.api_core import exceptions as core_exceptions +from google.api_core import gapic_v1 +from google.api_core import retry_async as retries +from google.auth import credentials as ga_credentials # type: ignore +from google.oauth2 import service_account # type: ignore + +try: + OptionalRetry = Union[retries.AsyncRetry, gapic_v1.method._MethodDefault] +except AttributeError: # pragma: NO COVER + OptionalRetry = Union[retries.AsyncRetry, object] # type: ignore + +from google.cloud.location import locations_pb2 # type: ignore +from google.cloud.securitycentermanagement_v1.services.security_center_management import pagers +from google.cloud.securitycentermanagement_v1.types import security_center_management +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from .transports.base import SecurityCenterManagementTransport, DEFAULT_CLIENT_INFO +from .transports.grpc_asyncio import SecurityCenterManagementGrpcAsyncIOTransport +from .client import SecurityCenterManagementClient + + +class SecurityCenterManagementAsyncClient: + """Service describing handlers for resources""" + + _client: SecurityCenterManagementClient + + DEFAULT_ENDPOINT = SecurityCenterManagementClient.DEFAULT_ENDPOINT + DEFAULT_MTLS_ENDPOINT = SecurityCenterManagementClient.DEFAULT_MTLS_ENDPOINT + + effective_event_threat_detection_custom_module_path = staticmethod(SecurityCenterManagementClient.effective_event_threat_detection_custom_module_path) + parse_effective_event_threat_detection_custom_module_path = staticmethod(SecurityCenterManagementClient.parse_effective_event_threat_detection_custom_module_path) + effective_security_health_analytics_custom_module_path = staticmethod(SecurityCenterManagementClient.effective_security_health_analytics_custom_module_path) + parse_effective_security_health_analytics_custom_module_path = staticmethod(SecurityCenterManagementClient.parse_effective_security_health_analytics_custom_module_path) + event_threat_detection_custom_module_path = staticmethod(SecurityCenterManagementClient.event_threat_detection_custom_module_path) + parse_event_threat_detection_custom_module_path = staticmethod(SecurityCenterManagementClient.parse_event_threat_detection_custom_module_path) + finding_path = staticmethod(SecurityCenterManagementClient.finding_path) + parse_finding_path = staticmethod(SecurityCenterManagementClient.parse_finding_path) + security_health_analytics_custom_module_path = staticmethod(SecurityCenterManagementClient.security_health_analytics_custom_module_path) + parse_security_health_analytics_custom_module_path = staticmethod(SecurityCenterManagementClient.parse_security_health_analytics_custom_module_path) + common_billing_account_path = staticmethod(SecurityCenterManagementClient.common_billing_account_path) + parse_common_billing_account_path = staticmethod(SecurityCenterManagementClient.parse_common_billing_account_path) + common_folder_path = staticmethod(SecurityCenterManagementClient.common_folder_path) + parse_common_folder_path = staticmethod(SecurityCenterManagementClient.parse_common_folder_path) + common_organization_path = staticmethod(SecurityCenterManagementClient.common_organization_path) + parse_common_organization_path = staticmethod(SecurityCenterManagementClient.parse_common_organization_path) + common_project_path = staticmethod(SecurityCenterManagementClient.common_project_path) + parse_common_project_path = staticmethod(SecurityCenterManagementClient.parse_common_project_path) + common_location_path = staticmethod(SecurityCenterManagementClient.common_location_path) + parse_common_location_path = staticmethod(SecurityCenterManagementClient.parse_common_location_path) + + @classmethod + def from_service_account_info(cls, info: dict, *args, **kwargs): + """Creates an instance of this client using the provided credentials + info. + + Args: + info (dict): The service account private key info. + args: Additional arguments to pass to the constructor. + kwargs: Additional arguments to pass to the constructor. + + Returns: + SecurityCenterManagementAsyncClient: The constructed client. + """ + return SecurityCenterManagementClient.from_service_account_info.__func__(SecurityCenterManagementAsyncClient, info, *args, **kwargs) # type: ignore + + @classmethod + def from_service_account_file(cls, filename: str, *args, **kwargs): + """Creates an instance of this client using the provided credentials + file. + + Args: + filename (str): The path to the service account private key json + file. + args: Additional arguments to pass to the constructor. + kwargs: Additional arguments to pass to the constructor. + + Returns: + SecurityCenterManagementAsyncClient: The constructed client. + """ + return SecurityCenterManagementClient.from_service_account_file.__func__(SecurityCenterManagementAsyncClient, filename, *args, **kwargs) # type: ignore + + from_service_account_json = from_service_account_file + + @classmethod + def get_mtls_endpoint_and_cert_source(cls, client_options: Optional[ClientOptions] = None): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variable is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + return SecurityCenterManagementClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + + @property + def transport(self) -> SecurityCenterManagementTransport: + """Returns the transport used by the client instance. + + Returns: + SecurityCenterManagementTransport: The transport used by the client instance. + """ + return self._client.transport + + get_transport_class = functools.partial(type(SecurityCenterManagementClient).get_transport_class, type(SecurityCenterManagementClient)) + + def __init__(self, *, + credentials: Optional[ga_credentials.Credentials] = None, + transport: Union[str, SecurityCenterManagementTransport] = "grpc_asyncio", + client_options: Optional[ClientOptions] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiates the security center management client. + + Args: + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + transport (Union[str, ~.SecurityCenterManagementTransport]): The + transport to use. If set to None, a transport is chosen + automatically. + client_options (ClientOptions): Custom options for the client. It + won't take effect if a ``transport`` instance is provided. + (1) The ``api_endpoint`` property can be used to override the + default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT + environment variable can also be used to override the endpoint: + "always" (always use the default mTLS endpoint), "never" (always + use the default regular endpoint) and "auto" (auto switch to the + default mTLS endpoint if client certificate is present, this is + the default value). However, the ``api_endpoint`` property takes + precedence if provided. + (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable + is "true", then the ``client_cert_source`` property can be used + to provide client certificate for mutual TLS transport. If + not provided, the default SSL client certificate will be used if + present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not + set, no client certificate will be used. + + Raises: + google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport + creation failed for any reason. + """ + self._client = SecurityCenterManagementClient( + credentials=credentials, + transport=transport, + client_options=client_options, + client_info=client_info, + + ) + + async def list_effective_security_health_analytics_custom_modules(self, + request: Optional[Union[security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest, 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.ListEffectiveSecurityHealthAnalyticsCustomModulesAsyncPager: + r"""Returns a list of all + EffectiveSecurityHealthAnalyticsCustomModules for the + given parent. This includes resident modules defined at + the scope of the parent, and inherited modules, + inherited from CRM ancestors (no descendants). + + .. 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 securitycentermanagement_v1 + + async def sample_list_effective_security_health_analytics_custom_modules(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_effective_security_health_analytics_custom_modules(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Optional[Union[google.cloud.securitycentermanagement_v1.types.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest, dict]]): + The request object. Request message for listing effective + Security Health Analytics custom + modules. + parent (:class:`str`): + Required. Name of parent to list + effective custom modules. Its format is + "organizations/{organization}/locations/{location}", + "folders/{folder}/locations/{location}", + or + "projects/{project}/locations/{location}" + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): 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.securitycentermanagement_v1.services.security_center_management.pagers.ListEffectiveSecurityHealthAnalyticsCustomModulesAsyncPager: + Response message for listing + effective Security Health Analytics + custom modules. + + 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 = security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest(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_effective_security_health_analytics_custom_modules, + default_retry=retries.AsyncRetry( +initial=0.1,maximum=60.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.DeadlineExceeded, + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + 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.ListEffectiveSecurityHealthAnalyticsCustomModulesAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_effective_security_health_analytics_custom_module(self, + request: Optional[Union[security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest, 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]] = (), + ) -> security_center_management.EffectiveSecurityHealthAnalyticsCustomModule: + r"""Gets details of a single + EffectiveSecurityHealthAnalyticsCustomModule. + + .. 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 securitycentermanagement_v1 + + async def sample_get_effective_security_health_analytics_custom_module(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest( + name="name_value", + ) + + # Make the request + response = await client.get_effective_security_health_analytics_custom_module(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.securitycentermanagement_v1.types.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest, dict]]): + The request object. Message for getting a + EffectiveSecurityHealthAnalyticsCustomModule + name (:class:`str`): + Required. The resource name of the SHA custom module. + + Its format is: + + - "organizations/{organization}/locations/{location}/effectiveSecurityHealthAnalyticsCustomModules/{module_id}". + - "folders/{folder}/locations/{location}/effectiveSecurityHealthAnalyticsCustomModules/{module_id}". + - "projects/{project}/locations/{location}/effectiveSecurityHealthAnalyticsCustomModules/{module_id}". + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): 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.securitycentermanagement_v1.types.EffectiveSecurityHealthAnalyticsCustomModule: + An EffectiveSecurityHealthAnalyticsCustomModule is the representation of + a Security Health Analytics custom module at a + specified level of the resource hierarchy: + organization, folder, or project. If a custom module + is inherited from a parent organization or folder, + the value of the enablementState property in + EffectiveSecurityHealthAnalyticsCustomModule is set + to the value that is effective in the parent, instead + of INHERITED. For example, if the module is enabled + in a parent organization or folder, the effective + enablement_state for the module in all child folders + or projects is also enabled. + EffectiveSecurityHealthAnalyticsCustomModule is + read-only. + + """ + # 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 = security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest(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_effective_security_health_analytics_custom_module, + default_retry=retries.AsyncRetry( +initial=0.1,maximum=60.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.DeadlineExceeded, + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + 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 list_security_health_analytics_custom_modules(self, + request: Optional[Union[security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest, 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.ListSecurityHealthAnalyticsCustomModulesAsyncPager: + r"""Returns a list of all + SecurityHealthAnalyticsCustomModules for the given + parent. This includes resident modules defined at the + scope of the parent, and inherited modules, inherited + from CRM ancestors (no descendants). + + .. 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 securitycentermanagement_v1 + + async def sample_list_security_health_analytics_custom_modules(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.ListSecurityHealthAnalyticsCustomModulesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_security_health_analytics_custom_modules(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Optional[Union[google.cloud.securitycentermanagement_v1.types.ListSecurityHealthAnalyticsCustomModulesRequest, dict]]): + The request object. Request message for listing Security + Health Analytics custom modules. + parent (:class:`str`): + Required. Name of parent to list + custom modules. Its format is + "organizations/{organization}/locations/{location}", + "folders/{folder}/locations/{location}", + or + "projects/{project}/locations/{location}" + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): 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.securitycentermanagement_v1.services.security_center_management.pagers.ListSecurityHealthAnalyticsCustomModulesAsyncPager: + Response message for listing Security + Health Analytics custom modules. + 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 = security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest(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_security_health_analytics_custom_modules, + default_retry=retries.AsyncRetry( +initial=0.1,maximum=60.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.DeadlineExceeded, + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + 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.ListSecurityHealthAnalyticsCustomModulesAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def list_descendant_security_health_analytics_custom_modules(self, + request: Optional[Union[security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest, 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.ListDescendantSecurityHealthAnalyticsCustomModulesAsyncPager: + r"""Returns a list of all resident + SecurityHealthAnalyticsCustomModules under the given CRM + parent and all of the parent’s CRM descendants. + + .. 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 securitycentermanagement_v1 + + async def sample_list_descendant_security_health_analytics_custom_modules(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.ListDescendantSecurityHealthAnalyticsCustomModulesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_descendant_security_health_analytics_custom_modules(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Optional[Union[google.cloud.securitycentermanagement_v1.types.ListDescendantSecurityHealthAnalyticsCustomModulesRequest, dict]]): + The request object. Request message for listing + descendant Security Health Analytics + custom modules. + parent (:class:`str`): + Required. Name of parent to list + custom modules. Its format is + "organizations/{organization}/locations/{location}", + "folders/{folder}/locations/{location}", + or + "projects/{project}/locations/{location}" + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): 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.securitycentermanagement_v1.services.security_center_management.pagers.ListDescendantSecurityHealthAnalyticsCustomModulesAsyncPager: + Response message for listing + descendant Security Health Analytics + custom modules. + + 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 = security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest(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_descendant_security_health_analytics_custom_modules, + default_retry=retries.AsyncRetry( +initial=0.1,maximum=60.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.DeadlineExceeded, + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + 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.ListDescendantSecurityHealthAnalyticsCustomModulesAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_security_health_analytics_custom_module(self, + request: Optional[Union[security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest, 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]] = (), + ) -> security_center_management.SecurityHealthAnalyticsCustomModule: + r"""Retrieves a SecurityHealthAnalyticsCustomModule. + + .. 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 securitycentermanagement_v1 + + async def sample_get_security_health_analytics_custom_module(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.GetSecurityHealthAnalyticsCustomModuleRequest( + name="name_value", + ) + + # Make the request + response = await client.get_security_health_analytics_custom_module(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.securitycentermanagement_v1.types.GetSecurityHealthAnalyticsCustomModuleRequest, dict]]): + The request object. Message for getting a + SecurityHealthAnalyticsCustomModule + name (:class:`str`): + Required. Name of the resource + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): 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.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule: + Represents an instance of a Security + Health Analytics custom module, + including its full module name, display + name, enablement state, and last updated + time. You can create a custom module at + the organization, folder, or project + level. Custom modules that you create at + the organization or folder level are + inherited by the child folders and + projects. + + """ + # 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 = security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest(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_security_health_analytics_custom_module, + default_retry=retries.AsyncRetry( +initial=0.1,maximum=60.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.DeadlineExceeded, + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + 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 create_security_health_analytics_custom_module(self, + request: Optional[Union[security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest, dict]] = None, + *, + parent: Optional[str] = None, + security_health_analytics_custom_module: Optional[security_center_management.SecurityHealthAnalyticsCustomModule] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> security_center_management.SecurityHealthAnalyticsCustomModule: + r"""Creates a resident + SecurityHealthAnalyticsCustomModule at the scope of the + given CRM parent, and also creates inherited + SecurityHealthAnalyticsCustomModules for all CRM + descendants of the given parent. These modules are + enabled by default. + + .. 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 securitycentermanagement_v1 + + async def sample_create_security_health_analytics_custom_module(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.CreateSecurityHealthAnalyticsCustomModuleRequest( + parent="parent_value", + ) + + # Make the request + response = await client.create_security_health_analytics_custom_module(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.securitycentermanagement_v1.types.CreateSecurityHealthAnalyticsCustomModuleRequest, dict]]): + The request object. Message for creating a + SecurityHealthAnalyticsCustomModule + parent (:class:`str`): + Required. Name of the parent for the + module. Its format is + "organizations/{organization}/locations/{location}", + "folders/{folder}/locations/{location}", + or + "projects/{project}/locations/{location}" + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + security_health_analytics_custom_module (:class:`google.cloud.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule`): + Required. The resource being created + This corresponds to the ``security_health_analytics_custom_module`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): 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.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule: + Represents an instance of a Security + Health Analytics custom module, + including its full module name, display + name, enablement state, and last updated + time. You can create a custom module at + the organization, folder, or project + level. Custom modules that you create at + the organization or folder level are + inherited by the child folders and + projects. + + """ + # 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, security_health_analytics_custom_module]) + 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 = security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if security_health_analytics_custom_module is not None: + request.security_health_analytics_custom_module = security_health_analytics_custom_module + + # 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_security_health_analytics_custom_module, + default_timeout=60.0, + 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 update_security_health_analytics_custom_module(self, + request: Optional[Union[security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest, dict]] = None, + *, + security_health_analytics_custom_module: Optional[security_center_management.SecurityHealthAnalyticsCustomModule] = 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]] = (), + ) -> security_center_management.SecurityHealthAnalyticsCustomModule: + r"""Updates the SecurityHealthAnalyticsCustomModule under + the given name based on the given update mask. Updating + the enablement state is supported on both resident and + inherited modules (though resident modules cannot have + an enablement state of "inherited"). Updating the + display name and custom config of a module is supported + on resident modules only. + + .. 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 securitycentermanagement_v1 + + async def sample_update_security_health_analytics_custom_module(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.UpdateSecurityHealthAnalyticsCustomModuleRequest( + ) + + # Make the request + response = await client.update_security_health_analytics_custom_module(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.securitycentermanagement_v1.types.UpdateSecurityHealthAnalyticsCustomModuleRequest, dict]]): + The request object. Message for updating a + SecurityHealthAnalyticsCustomModule + security_health_analytics_custom_module (:class:`google.cloud.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule`): + Required. The resource being updated + This corresponds to the ``security_health_analytics_custom_module`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Required. Field mask is used to specify the fields to be + overwritten in the SecurityHealthAnalyticsCustomModule + resource by the update. The fields specified in the + update_mask are relative to the resource, not the full + request. A field will be overwritten if it is in the + mask. If the user does not provide a mask then all + fields will be overwritten. + + 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_async.AsyncRetry): 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.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule: + Represents an instance of a Security + Health Analytics custom module, + including its full module name, display + name, enablement state, and last updated + time. You can create a custom module at + the organization, folder, or project + level. Custom modules that you create at + the organization or folder level are + inherited by the child folders and + projects. + + """ + # 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([security_health_analytics_custom_module, 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 = security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if security_health_analytics_custom_module is not None: + request.security_health_analytics_custom_module = security_health_analytics_custom_module + 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_security_health_analytics_custom_module, + default_timeout=60.0, + 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(( + ("security_health_analytics_custom_module.name", request.security_health_analytics_custom_module.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def delete_security_health_analytics_custom_module(self, + request: Optional[Union[security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest, 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 + SecurityHealthAnalyticsCustomModule and all of its + descendants in the CRM hierarchy. This method is only + supported for resident custom modules. + + .. 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 securitycentermanagement_v1 + + async def sample_delete_security_health_analytics_custom_module(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.DeleteSecurityHealthAnalyticsCustomModuleRequest( + name="name_value", + ) + + # Make the request + await client.delete_security_health_analytics_custom_module(request=request) + + Args: + request (Optional[Union[google.cloud.securitycentermanagement_v1.types.DeleteSecurityHealthAnalyticsCustomModuleRequest, dict]]): + The request object. Message for deleting a + SecurityHealthAnalyticsCustomModule + name (:class:`str`): + Required. The resource name of the SHA custom module. + + Its format is: + + - "organizations/{organization}/locations/{location}/securityHealthAnalyticsCustomModules/{security_health_analytics_custom_module}". + - "folders/{folder}/locations/{location}/securityHealthAnalyticsCustomModules/{security_health_analytics_custom_module}". + - "projects/{project}/locations/{location}/securityHealthAnalyticsCustomModules/{security_health_analytics_custom_module}". + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): 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 = security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest(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_security_health_analytics_custom_module, + default_timeout=60.0, + 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 simulate_security_health_analytics_custom_module(self, + request: Optional[Union[security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest, dict]] = None, + *, + parent: Optional[str] = None, + custom_config: Optional[security_center_management.CustomConfig] = None, + resource: Optional[security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest.SimulatedResource] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse: + r"""Simulates a given SecurityHealthAnalyticsCustomModule + and Resource. + + .. 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 securitycentermanagement_v1 + + async def sample_simulate_security_health_analytics_custom_module(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() + + # Initialize request argument(s) + resource = securitycentermanagement_v1.SimulatedResource() + resource.resource_type = "resource_type_value" + + request = securitycentermanagement_v1.SimulateSecurityHealthAnalyticsCustomModuleRequest( + parent="parent_value", + resource=resource, + ) + + # Make the request + response = await client.simulate_security_health_analytics_custom_module(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.securitycentermanagement_v1.types.SimulateSecurityHealthAnalyticsCustomModuleRequest, dict]]): + The request object. Request message to simulate a + CustomConfig against a given test + resource. Maximum size of the request is + 4 MB by default. + parent (:class:`str`): + Required. The relative resource name of the + organization, project, or folder. For more information + about relative resource names, see `Relative Resource + Name `__ + Example: ``organizations/{organization_id}``. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + custom_config (:class:`google.cloud.securitycentermanagement_v1.types.CustomConfig`): + Required. The custom configuration + that you need to test. + + This corresponds to the ``custom_config`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + resource (:class:`google.cloud.securitycentermanagement_v1.types.SimulateSecurityHealthAnalyticsCustomModuleRequest.SimulatedResource`): + Required. Resource data to simulate + custom module against. + + This corresponds to the ``resource`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): 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.securitycentermanagement_v1.types.SimulateSecurityHealthAnalyticsCustomModuleResponse: + Response message for simulating a SecurityHealthAnalyticsCustomModule + against a given resource. + + """ + # 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, custom_config, resource]) + 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 = security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if custom_config is not None: + request.custom_config = custom_config + if resource is not None: + request.resource = resource + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.simulate_security_health_analytics_custom_module, + default_retry=retries.AsyncRetry( +initial=0.1,maximum=60.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.DeadlineExceeded, + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + 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_effective_event_threat_detection_custom_modules(self, + request: Optional[Union[security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest, 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.ListEffectiveEventThreatDetectionCustomModulesAsyncPager: + r"""Lists all effective Event Threat Detection custom + modules for the given parent. This includes resident + modules defined at the scope of the parent along with + modules inherited from its ancestors. + + .. 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 securitycentermanagement_v1 + + async def sample_list_effective_event_threat_detection_custom_modules(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.ListEffectiveEventThreatDetectionCustomModulesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_effective_event_threat_detection_custom_modules(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Optional[Union[google.cloud.securitycentermanagement_v1.types.ListEffectiveEventThreatDetectionCustomModulesRequest, dict]]): + The request object. Request message for listing effective + Event Threat Detection custom modules. + parent (:class:`str`): + Required. Name of parent to list + effective custom modules. Its format is + "organizations/{organization}/locations/{location}", + "folders/{folder}/locations/{location}", + or + "projects/{project}/locations/{location}" + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): 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.securitycentermanagement_v1.services.security_center_management.pagers.ListEffectiveEventThreatDetectionCustomModulesAsyncPager: + Response message for listing + effective Event Threat Detection custom + modules. + + 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 = security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest(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_effective_event_threat_detection_custom_modules, + default_retry=retries.AsyncRetry( +initial=0.1,maximum=60.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.DeadlineExceeded, + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + 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.ListEffectiveEventThreatDetectionCustomModulesAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_effective_event_threat_detection_custom_module(self, + request: Optional[Union[security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest, 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]] = (), + ) -> security_center_management.EffectiveEventThreatDetectionCustomModule: + r"""Gets an effective ETD custom module. Retrieves the effective + module at the given level. The difference between an + EffectiveCustomModule and a CustomModule is that the fields for + an EffectiveCustomModule are computed from ancestors if needed. + For example, the enablement_state for a CustomModule can be + either ENABLED, DISABLED, or INHERITED. Where as the + enablement_state for an EffectiveCustomModule is always computed + to ENABLED or DISABLED (the effective enablement_state). + + .. 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 securitycentermanagement_v1 + + async def sample_get_effective_event_threat_detection_custom_module(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.GetEffectiveEventThreatDetectionCustomModuleRequest( + name="name_value", + ) + + # Make the request + response = await client.get_effective_event_threat_detection_custom_module(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.securitycentermanagement_v1.types.GetEffectiveEventThreatDetectionCustomModuleRequest, dict]]): + The request object. Message for getting a + EffectiveEventThreatDetectionCustomModule + name (:class:`str`): + Required. The resource name of the ETD custom module. + + Its format is: + + - "organizations/{organization}/locations/{location}/effectiveEventThreatDetectionCustomModules/{effective_event_threat_detection_custom_module}". + - "folders/{folder}/locations/{location}/effectiveEventThreatDetectionCustomModules/{effective_event_threat_detection_custom_module}". + - "projects/{project}/locations/{location}/effectiveEventThreatDetectionCustomModules/{effective_event_threat_detection_custom_module}". + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): 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.securitycentermanagement_v1.types.EffectiveEventThreatDetectionCustomModule: + An EffectiveEventThreatDetectionCustomModule is the representation of + EventThreatDetectionCustomModule at a given level + taking hierarchy into account and resolving various + fields accordingly. e.g. if the module is enabled at + the ancestor level, effective modules at all + descendant levels will have enablement_state set to + ENABLED. Similarly, if module.inherited is set, then + effective module's config will contain the ancestor's + config details. + EffectiveEventThreatDetectionCustomModule is + read-only. + + """ + # 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 = security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest(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_effective_event_threat_detection_custom_module, + default_retry=retries.AsyncRetry( +initial=0.1,maximum=60.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.DeadlineExceeded, + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + 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 list_event_threat_detection_custom_modules(self, + request: Optional[Union[security_center_management.ListEventThreatDetectionCustomModulesRequest, 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.ListEventThreatDetectionCustomModulesAsyncPager: + r"""Lists all Event Threat Detection custom modules for + the given Resource Manager parent. This includes + resident modules defined at the scope of the parent + along with modules inherited from ancestors. + + .. 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 securitycentermanagement_v1 + + async def sample_list_event_threat_detection_custom_modules(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.ListEventThreatDetectionCustomModulesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_event_threat_detection_custom_modules(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Optional[Union[google.cloud.securitycentermanagement_v1.types.ListEventThreatDetectionCustomModulesRequest, dict]]): + The request object. Request message for listing Event + Threat Detection custom modules. + parent (:class:`str`): + Required. Name of parent to list + custom modules. Its format is + "organizations/{organization}/locations/{location}", + "folders/{folder}/locations/{location}", + or + "projects/{project}/locations/{location}" + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): 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.securitycentermanagement_v1.services.security_center_management.pagers.ListEventThreatDetectionCustomModulesAsyncPager: + Response message for listing Event + Threat Detection custom modules. + 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 = security_center_management.ListEventThreatDetectionCustomModulesRequest(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_event_threat_detection_custom_modules, + default_retry=retries.AsyncRetry( +initial=0.1,maximum=60.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.DeadlineExceeded, + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + 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.ListEventThreatDetectionCustomModulesAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def list_descendant_event_threat_detection_custom_modules(self, + request: Optional[Union[security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest, 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.ListDescendantEventThreatDetectionCustomModulesAsyncPager: + r"""Lists all resident Event Threat Detection custom + modules under the given Resource Manager parent and its + descendants. + + .. 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 securitycentermanagement_v1 + + async def sample_list_descendant_event_threat_detection_custom_modules(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.ListDescendantEventThreatDetectionCustomModulesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_descendant_event_threat_detection_custom_modules(request=request) + + # Handle the response + async for response in page_result: + print(response) + + Args: + request (Optional[Union[google.cloud.securitycentermanagement_v1.types.ListDescendantEventThreatDetectionCustomModulesRequest, dict]]): + The request object. Request message for listing + descendant Event Threat Detection custom + modules. + parent (:class:`str`): + Required. Name of parent to list + custom modules. Its format is + "organizations/{organization}/locations/{location}", + "folders/{folder}/locations/{location}", + or + "projects/{project}/locations/{location}" + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): 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.securitycentermanagement_v1.services.security_center_management.pagers.ListDescendantEventThreatDetectionCustomModulesAsyncPager: + Response message for listing + descendant Event Threat Detection custom + modules. + + 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 = security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest(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_descendant_event_threat_detection_custom_modules, + default_retry=retries.AsyncRetry( +initial=0.1,maximum=60.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.DeadlineExceeded, + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + 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.ListDescendantEventThreatDetectionCustomModulesAsyncPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def get_event_threat_detection_custom_module(self, + request: Optional[Union[security_center_management.GetEventThreatDetectionCustomModuleRequest, 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]] = (), + ) -> security_center_management.EventThreatDetectionCustomModule: + r"""Gets an Event Threat Detection custom module. + + .. 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 securitycentermanagement_v1 + + async def sample_get_event_threat_detection_custom_module(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.GetEventThreatDetectionCustomModuleRequest( + name="name_value", + ) + + # Make the request + response = await client.get_event_threat_detection_custom_module(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.securitycentermanagement_v1.types.GetEventThreatDetectionCustomModuleRequest, dict]]): + The request object. Message for getting a + EventThreatDetectionCustomModule + name (:class:`str`): + Required. The resource name of the ETD custom module. + + Its format is: + + - "organizations/{organization}/locations/{location}/eventThreatDetectionCustomModules/{event_threat_detection_custom_module}". + - "folders/{folder}/locations/{location}/eventThreatDetectionCustomModules/{event_threat_detection_custom_module}". + - "projects/{project}/locations/{location}/eventThreatDetectionCustomModules/{event_threat_detection_custom_module}". + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): 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.securitycentermanagement_v1.types.EventThreatDetectionCustomModule: + An event threat detection custom + module is a Cloud SCC resource that + contains the configuration and + enablement state of a custom module, + which enables ETD to write certain + findings to Cloud SCC. + + """ + # 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 = security_center_management.GetEventThreatDetectionCustomModuleRequest(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_event_threat_detection_custom_module, + default_retry=retries.AsyncRetry( +initial=0.1,maximum=60.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.DeadlineExceeded, + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + 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 create_event_threat_detection_custom_module(self, + request: Optional[Union[security_center_management.CreateEventThreatDetectionCustomModuleRequest, dict]] = None, + *, + parent: Optional[str] = None, + event_threat_detection_custom_module: Optional[security_center_management.EventThreatDetectionCustomModule] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> security_center_management.EventThreatDetectionCustomModule: + r"""Creates a resident Event Threat Detection custom + module at the scope of the given Resource Manager + parent, and also creates inherited custom modules for + all descendants of the given parent. These modules are + enabled by default. + + .. 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 securitycentermanagement_v1 + + async def sample_create_event_threat_detection_custom_module(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.CreateEventThreatDetectionCustomModuleRequest( + parent="parent_value", + ) + + # Make the request + response = await client.create_event_threat_detection_custom_module(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.securitycentermanagement_v1.types.CreateEventThreatDetectionCustomModuleRequest, dict]]): + The request object. Message for creating a + EventThreatDetectionCustomModule + parent (:class:`str`): + Required. Name of parent for the + module. Its format is + "organizations/{organization}/locations/{location}", + "folders/{folder}/locations/{location}", + or + "projects/{project}/locations/{location}" + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + event_threat_detection_custom_module (:class:`google.cloud.securitycentermanagement_v1.types.EventThreatDetectionCustomModule`): + Required. The module to create. The + event_threat_detection_custom_module.name will be + ignored and server generated. + + This corresponds to the ``event_threat_detection_custom_module`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): 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.securitycentermanagement_v1.types.EventThreatDetectionCustomModule: + An event threat detection custom + module is a Cloud SCC resource that + contains the configuration and + enablement state of a custom module, + which enables ETD to write certain + findings to Cloud SCC. + + """ + # 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, event_threat_detection_custom_module]) + 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 = security_center_management.CreateEventThreatDetectionCustomModuleRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if event_threat_detection_custom_module is not None: + request.event_threat_detection_custom_module = event_threat_detection_custom_module + + # 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_event_threat_detection_custom_module, + default_timeout=60.0, + 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 update_event_threat_detection_custom_module(self, + request: Optional[Union[security_center_management.UpdateEventThreatDetectionCustomModuleRequest, dict]] = None, + *, + event_threat_detection_custom_module: Optional[security_center_management.EventThreatDetectionCustomModule] = 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]] = (), + ) -> security_center_management.EventThreatDetectionCustomModule: + r"""Updates the Event Threat Detection custom module with + the given name based on the given update mask. Updating + the enablement state is supported for both resident and + inherited modules (though resident modules cannot have + an enablement state of "inherited"). Updating the + display name or configuration of a module is supported + for resident modules only. The type of a module cannot + be changed. + + .. 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 securitycentermanagement_v1 + + async def sample_update_event_threat_detection_custom_module(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.UpdateEventThreatDetectionCustomModuleRequest( + ) + + # Make the request + response = await client.update_event_threat_detection_custom_module(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.securitycentermanagement_v1.types.UpdateEventThreatDetectionCustomModuleRequest, dict]]): + The request object. Message for updating a + EventThreatDetectionCustomModule + event_threat_detection_custom_module (:class:`google.cloud.securitycentermanagement_v1.types.EventThreatDetectionCustomModule`): + Required. The module being updated + This corresponds to the ``event_threat_detection_custom_module`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): + Required. Field mask is used to specify the fields to be + overwritten in the EventThreatDetectionCustomModule + resource by the update. The fields specified in the + update_mask are relative to the resource, not the full + request. A field will be overwritten if it is in the + mask. If the user does not provide a mask then all + fields will be overwritten. + + 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_async.AsyncRetry): 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.securitycentermanagement_v1.types.EventThreatDetectionCustomModule: + An event threat detection custom + module is a Cloud SCC resource that + contains the configuration and + enablement state of a custom module, + which enables ETD to write certain + findings to Cloud SCC. + + """ + # 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([event_threat_detection_custom_module, 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 = security_center_management.UpdateEventThreatDetectionCustomModuleRequest(request) + + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if event_threat_detection_custom_module is not None: + request.event_threat_detection_custom_module = event_threat_detection_custom_module + 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_event_threat_detection_custom_module, + default_timeout=60.0, + 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(( + ("event_threat_detection_custom_module.name", request.event_threat_detection_custom_module.name), + )), + ) + + # Send the request. + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + async def delete_event_threat_detection_custom_module(self, + request: Optional[Union[security_center_management.DeleteEventThreatDetectionCustomModuleRequest, 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 Event Threat Detection custom + module and all of its descendants in the Resource + Manager hierarchy. This method is only supported for + resident custom modules. + + .. 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 securitycentermanagement_v1 + + async def sample_delete_event_threat_detection_custom_module(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.DeleteEventThreatDetectionCustomModuleRequest( + name="name_value", + ) + + # Make the request + await client.delete_event_threat_detection_custom_module(request=request) + + Args: + request (Optional[Union[google.cloud.securitycentermanagement_v1.types.DeleteEventThreatDetectionCustomModuleRequest, dict]]): + The request object. Message for deleting a + EventThreatDetectionCustomModule + name (:class:`str`): + Required. The resource name of the ETD custom module. + + Its format is: + + - "organizations/{organization}/locations/{location}/eventThreatDetectionCustomModules/{event_threat_detection_custom_module}". + - "folders/{folder}/locations/{location}/eventThreatDetectionCustomModules/{event_threat_detection_custom_module}". + - "projects/{project}/locations/{location}/eventThreatDetectionCustomModules/{event_threat_detection_custom_module}". + + This corresponds to the ``name`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + retry (google.api_core.retry_async.AsyncRetry): 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 = security_center_management.DeleteEventThreatDetectionCustomModuleRequest(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_event_threat_detection_custom_module, + default_timeout=60.0, + 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 validate_event_threat_detection_custom_module(self, + request: Optional[Union[security_center_management.ValidateEventThreatDetectionCustomModuleRequest, dict]] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> security_center_management.ValidateEventThreatDetectionCustomModuleResponse: + r"""Validates the given Event Threat Detection custom + module. + + .. 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 securitycentermanagement_v1 + + async def sample_validate_event_threat_detection_custom_module(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.ValidateEventThreatDetectionCustomModuleRequest( + parent="parent_value", + raw_text="raw_text_value", + type_="type__value", + ) + + # Make the request + response = await client.validate_event_threat_detection_custom_module(request=request) + + # Handle the response + print(response) + + Args: + request (Optional[Union[google.cloud.securitycentermanagement_v1.types.ValidateEventThreatDetectionCustomModuleRequest, dict]]): + The request object. Request to validate an Event Threat + Detection custom module. + retry (google.api_core.retry_async.AsyncRetry): 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.securitycentermanagement_v1.types.ValidateEventThreatDetectionCustomModuleResponse: + Response to validating an Event + Threat Detection custom module. + + """ + # Create or coerce a protobuf request object. + request = security_center_management.ValidateEventThreatDetectionCustomModuleRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method_async.wrap_method( + self._client._transport.validate_event_threat_detection_custom_module, + default_retry=retries.AsyncRetry( +initial=0.1,maximum=60.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.DeadlineExceeded, + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + 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 get_location( + self, + request: Optional[locations_pb2.GetLocationRequest] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> locations_pb2.Location: + r"""Gets information about a location. + + Args: + request (:class:`~.location_pb2.GetLocationRequest`): + The request object. Request message for + `GetLocation` method. + retry (google.api_core.retry_async.AsyncRetry): 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: + ~.location_pb2.Location: + Location object. + """ + # Create or coerce a protobuf request object. + # The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + if isinstance(request, dict): + request = locations_pb2.GetLocationRequest(**request) + + # 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_location, + 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 list_locations( + self, + request: Optional[locations_pb2.ListLocationsRequest] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> locations_pb2.ListLocationsResponse: + r"""Lists information about the supported locations for this service. + + Args: + request (:class:`~.location_pb2.ListLocationsRequest`): + The request object. Request message for + `ListLocations` method. + retry (google.api_core.retry_async.AsyncRetry): 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: + ~.location_pb2.ListLocationsResponse: + Response message for ``ListLocations`` method. + """ + # Create or coerce a protobuf request object. + # The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + if isinstance(request, dict): + request = locations_pb2.ListLocationsRequest(**request) + + # 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_locations, + 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 __aenter__(self) -> "SecurityCenterManagementAsyncClient": + return self + + async def __aexit__(self, exc_type, exc, tb): + await self.transport.close() + +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) + + +__all__ = ( + "SecurityCenterManagementAsyncClient", +) diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/client.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/client.py new file mode 100644 index 000000000000..7031f8462341 --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/client.py @@ -0,0 +1,2653 @@ +# -*- 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. +# +from collections import OrderedDict +import os +import re +from typing import Dict, Mapping, MutableMapping, MutableSequence, Optional, Sequence, Tuple, Type, Union, cast + +from google.cloud.securitycentermanagement_v1 import gapic_version as package_version + +from google.api_core import client_options as client_options_lib +from google.api_core import exceptions as core_exceptions +from google.api_core import gapic_v1 +from google.api_core import retry as retries +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport import mtls # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore +from google.auth.exceptions import MutualTLSChannelError # type: ignore +from google.oauth2 import service_account # type: ignore + +try: + OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] +except AttributeError: # pragma: NO COVER + OptionalRetry = Union[retries.Retry, object] # type: ignore + +from google.cloud.location import locations_pb2 # type: ignore +from google.cloud.securitycentermanagement_v1.services.security_center_management import pagers +from google.cloud.securitycentermanagement_v1.types import security_center_management +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from .transports.base import SecurityCenterManagementTransport, DEFAULT_CLIENT_INFO +from .transports.grpc import SecurityCenterManagementGrpcTransport +from .transports.grpc_asyncio import SecurityCenterManagementGrpcAsyncIOTransport +from .transports.rest import SecurityCenterManagementRestTransport + + +class SecurityCenterManagementClientMeta(type): + """Metaclass for the SecurityCenterManagement client. + + This provides class-level methods for building and retrieving + support objects (e.g. transport) without polluting the client instance + objects. + """ + _transport_registry = OrderedDict() # type: Dict[str, Type[SecurityCenterManagementTransport]] + _transport_registry["grpc"] = SecurityCenterManagementGrpcTransport + _transport_registry["grpc_asyncio"] = SecurityCenterManagementGrpcAsyncIOTransport + _transport_registry["rest"] = SecurityCenterManagementRestTransport + + def get_transport_class(cls, + label: Optional[str] = None, + ) -> Type[SecurityCenterManagementTransport]: + """Returns an appropriate transport class. + + Args: + label: The name of the desired transport. If none is + provided, then the first transport in the registry is used. + + Returns: + The transport class to use. + """ + # If a specific transport is requested, return that one. + if label: + return cls._transport_registry[label] + + # No transport is requested; return the default (that is, the first one + # in the dictionary). + return next(iter(cls._transport_registry.values())) + + +class SecurityCenterManagementClient(metaclass=SecurityCenterManagementClientMeta): + """Service describing handlers for resources""" + + @staticmethod + def _get_default_mtls_endpoint(api_endpoint): + """Converts api endpoint to mTLS endpoint. + + Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to + "*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively. + Args: + api_endpoint (Optional[str]): the api endpoint to convert. + Returns: + str: converted mTLS api endpoint. + """ + if not api_endpoint: + return api_endpoint + + mtls_endpoint_re = re.compile( + r"(?P[^.]+)(?P\.mtls)?(?P\.sandbox)?(?P\.googleapis\.com)?" + ) + + m = mtls_endpoint_re.match(api_endpoint) + name, mtls, sandbox, googledomain = m.groups() + if mtls or not googledomain: + return api_endpoint + + if sandbox: + return api_endpoint.replace( + "sandbox.googleapis.com", "mtls.sandbox.googleapis.com" + ) + + return api_endpoint.replace(".googleapis.com", ".mtls.googleapis.com") + + DEFAULT_ENDPOINT = "securitycentermanagement.googleapis.com" + DEFAULT_MTLS_ENDPOINT = _get_default_mtls_endpoint.__func__( # type: ignore + DEFAULT_ENDPOINT + ) + + @classmethod + def from_service_account_info(cls, info: dict, *args, **kwargs): + """Creates an instance of this client using the provided credentials + info. + + Args: + info (dict): The service account private key info. + args: Additional arguments to pass to the constructor. + kwargs: Additional arguments to pass to the constructor. + + Returns: + SecurityCenterManagementClient: The constructed client. + """ + credentials = service_account.Credentials.from_service_account_info(info) + kwargs["credentials"] = credentials + return cls(*args, **kwargs) + + @classmethod + def from_service_account_file(cls, filename: str, *args, **kwargs): + """Creates an instance of this client using the provided credentials + file. + + Args: + filename (str): The path to the service account private key json + file. + args: Additional arguments to pass to the constructor. + kwargs: Additional arguments to pass to the constructor. + + Returns: + SecurityCenterManagementClient: The constructed client. + """ + credentials = service_account.Credentials.from_service_account_file( + filename) + kwargs["credentials"] = credentials + return cls(*args, **kwargs) + + from_service_account_json = from_service_account_file + + @property + def transport(self) -> SecurityCenterManagementTransport: + """Returns the transport used by the client instance. + + Returns: + SecurityCenterManagementTransport: The transport used by the client + instance. + """ + return self._transport + + @staticmethod + def effective_event_threat_detection_custom_module_path(organization: str,location: str,effective_event_threat_detection_custom_module: str,) -> str: + """Returns a fully-qualified effective_event_threat_detection_custom_module string.""" + return "organizations/{organization}/locations/{location}/effectiveEventThreatDetectionCustomModules/{effective_event_threat_detection_custom_module}".format(organization=organization, location=location, effective_event_threat_detection_custom_module=effective_event_threat_detection_custom_module, ) + + @staticmethod + def parse_effective_event_threat_detection_custom_module_path(path: str) -> Dict[str,str]: + """Parses a effective_event_threat_detection_custom_module path into its component segments.""" + m = re.match(r"^organizations/(?P.+?)/locations/(?P.+?)/effectiveEventThreatDetectionCustomModules/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def effective_security_health_analytics_custom_module_path(organization: str,location: str,effective_security_health_analytics_custom_module: str,) -> str: + """Returns a fully-qualified effective_security_health_analytics_custom_module string.""" + return "organizations/{organization}/locations/{location}/effectiveSecurityHealthAnalyticsCustomModules/{effective_security_health_analytics_custom_module}".format(organization=organization, location=location, effective_security_health_analytics_custom_module=effective_security_health_analytics_custom_module, ) + + @staticmethod + def parse_effective_security_health_analytics_custom_module_path(path: str) -> Dict[str,str]: + """Parses a effective_security_health_analytics_custom_module path into its component segments.""" + m = re.match(r"^organizations/(?P.+?)/locations/(?P.+?)/effectiveSecurityHealthAnalyticsCustomModules/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def event_threat_detection_custom_module_path(organization: str,location: str,event_threat_detection_custom_module: str,) -> str: + """Returns a fully-qualified event_threat_detection_custom_module string.""" + return "organizations/{organization}/locations/{location}/eventThreatDetectionCustomModules/{event_threat_detection_custom_module}".format(organization=organization, location=location, event_threat_detection_custom_module=event_threat_detection_custom_module, ) + + @staticmethod + def parse_event_threat_detection_custom_module_path(path: str) -> Dict[str,str]: + """Parses a event_threat_detection_custom_module path into its component segments.""" + m = re.match(r"^organizations/(?P.+?)/locations/(?P.+?)/eventThreatDetectionCustomModules/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def finding_path(organization: str,source: str,finding: str,) -> str: + """Returns a fully-qualified finding string.""" + return "organizations/{organization}/sources/{source}/findings/{finding}".format(organization=organization, source=source, finding=finding, ) + + @staticmethod + def parse_finding_path(path: str) -> Dict[str,str]: + """Parses a finding path into its component segments.""" + m = re.match(r"^organizations/(?P.+?)/sources/(?P.+?)/findings/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def security_health_analytics_custom_module_path(organization: str,location: str,security_health_analytics_custom_module: str,) -> str: + """Returns a fully-qualified security_health_analytics_custom_module string.""" + return "organizations/{organization}/locations/{location}/securityHealthAnalyticsCustomModules/{security_health_analytics_custom_module}".format(organization=organization, location=location, security_health_analytics_custom_module=security_health_analytics_custom_module, ) + + @staticmethod + def parse_security_health_analytics_custom_module_path(path: str) -> Dict[str,str]: + """Parses a security_health_analytics_custom_module path into its component segments.""" + m = re.match(r"^organizations/(?P.+?)/locations/(?P.+?)/securityHealthAnalyticsCustomModules/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_billing_account_path(billing_account: str, ) -> str: + """Returns a fully-qualified billing_account string.""" + return "billingAccounts/{billing_account}".format(billing_account=billing_account, ) + + @staticmethod + def parse_common_billing_account_path(path: str) -> Dict[str,str]: + """Parse a billing_account path into its component segments.""" + m = re.match(r"^billingAccounts/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_folder_path(folder: str, ) -> str: + """Returns a fully-qualified folder string.""" + return "folders/{folder}".format(folder=folder, ) + + @staticmethod + def parse_common_folder_path(path: str) -> Dict[str,str]: + """Parse a folder path into its component segments.""" + m = re.match(r"^folders/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_organization_path(organization: str, ) -> str: + """Returns a fully-qualified organization string.""" + return "organizations/{organization}".format(organization=organization, ) + + @staticmethod + def parse_common_organization_path(path: str) -> Dict[str,str]: + """Parse a organization path into its component segments.""" + m = re.match(r"^organizations/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_project_path(project: str, ) -> str: + """Returns a fully-qualified project string.""" + return "projects/{project}".format(project=project, ) + + @staticmethod + def parse_common_project_path(path: str) -> Dict[str,str]: + """Parse a project path into its component segments.""" + m = re.match(r"^projects/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_location_path(project: str, location: str, ) -> str: + """Returns a fully-qualified location string.""" + return "projects/{project}/locations/{location}".format(project=project, location=location, ) + + @staticmethod + def parse_common_location_path(path: str) -> Dict[str,str]: + """Parse a location path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) + return m.groupdict() if m else {} + + @classmethod + def get_mtls_endpoint_and_cert_source(cls, client_options: Optional[client_options_lib.ClientOptions] = None): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variable is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + if client_options is None: + client_options = client_options_lib.ClientOptions() + use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") + use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") + if use_client_cert not in ("true", "false"): + raise ValueError("Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`") + if use_mtls_endpoint not in ("auto", "never", "always"): + raise MutualTLSChannelError("Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`") + + # Figure out the client cert source to use. + client_cert_source = None + if use_client_cert == "true": + if client_options.client_cert_source: + client_cert_source = client_options.client_cert_source + elif mtls.has_default_client_cert_source(): + client_cert_source = mtls.default_client_cert_source() + + # Figure out which api endpoint to use. + if client_options.api_endpoint is not None: + api_endpoint = client_options.api_endpoint + elif use_mtls_endpoint == "always" or (use_mtls_endpoint == "auto" and client_cert_source): + api_endpoint = cls.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = cls.DEFAULT_ENDPOINT + + return api_endpoint, client_cert_source + + def __init__(self, *, + credentials: Optional[ga_credentials.Credentials] = None, + transport: Optional[Union[str, SecurityCenterManagementTransport]] = None, + client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + ) -> None: + """Instantiates the security center management client. + + Args: + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + transport (Union[str, SecurityCenterManagementTransport]): The + transport to use. If set to None, a transport is chosen + automatically. + client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]): Custom options for the + client. It won't take effect if a ``transport`` instance is provided. + (1) The ``api_endpoint`` property can be used to override the + default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT + environment variable can also be used to override the endpoint: + "always" (always use the default mTLS endpoint), "never" (always + use the default regular endpoint) and "auto" (auto switch to the + default mTLS endpoint if client certificate is present, this is + the default value). However, the ``api_endpoint`` property takes + precedence if provided. + (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable + is "true", then the ``client_cert_source`` property can be used + to provide client certificate for mutual TLS transport. If + not provided, the default SSL client certificate will be used if + present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not + set, no client certificate will be used. + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing + your own client library. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport + creation failed for any reason. + """ + if isinstance(client_options, dict): + client_options = client_options_lib.from_dict(client_options) + if client_options is None: + client_options = client_options_lib.ClientOptions() + client_options = cast(client_options_lib.ClientOptions, client_options) + + api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source(client_options) + + api_key_value = getattr(client_options, "api_key", None) + if api_key_value and credentials: + raise ValueError("client_options.api_key and credentials are mutually exclusive") + + # Save or instantiate the transport. + # Ordinarily, we provide the transport, but allowing a custom transport + # instance provides an extensibility point for unusual situations. + if isinstance(transport, SecurityCenterManagementTransport): + # transport is a SecurityCenterManagementTransport instance. + if credentials or client_options.credentials_file or api_key_value: + raise ValueError("When providing a transport instance, " + "provide its credentials directly.") + if client_options.scopes: + raise ValueError( + "When providing a transport instance, provide its scopes " + "directly." + ) + self._transport = transport + else: + import google.auth._default # type: ignore + + if api_key_value and hasattr(google.auth._default, "get_api_key_credentials"): + credentials = google.auth._default.get_api_key_credentials(api_key_value) + + Transport = type(self).get_transport_class(transport) + self._transport = Transport( + credentials=credentials, + credentials_file=client_options.credentials_file, + host=api_endpoint, + scopes=client_options.scopes, + client_cert_source_for_mtls=client_cert_source_func, + quota_project_id=client_options.quota_project_id, + client_info=client_info, + always_use_jwt_access=True, + api_audience=client_options.api_audience, + ) + + def list_effective_security_health_analytics_custom_modules(self, + request: Optional[Union[security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest, 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.ListEffectiveSecurityHealthAnalyticsCustomModulesPager: + r"""Returns a list of all + EffectiveSecurityHealthAnalyticsCustomModules for the + given parent. This includes resident modules defined at + the scope of the parent, and inherited modules, + inherited from CRM ancestors (no descendants). + + .. 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 securitycentermanagement_v1 + + def sample_list_effective_security_health_analytics_custom_modules(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_effective_security_health_analytics_custom_modules(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.securitycentermanagement_v1.types.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest, dict]): + The request object. Request message for listing effective + Security Health Analytics custom + modules. + parent (str): + Required. Name of parent to list + effective custom modules. Its format is + "organizations/{organization}/locations/{location}", + "folders/{folder}/locations/{location}", + or + "projects/{project}/locations/{location}" + + 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.securitycentermanagement_v1.services.security_center_management.pagers.ListEffectiveSecurityHealthAnalyticsCustomModulesPager: + Response message for listing + effective Security Health Analytics + custom modules. + + 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 security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest): + request = security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest(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_effective_security_health_analytics_custom_modules] + + # 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.ListEffectiveSecurityHealthAnalyticsCustomModulesPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_effective_security_health_analytics_custom_module(self, + request: Optional[Union[security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest, 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]] = (), + ) -> security_center_management.EffectiveSecurityHealthAnalyticsCustomModule: + r"""Gets details of a single + EffectiveSecurityHealthAnalyticsCustomModule. + + .. 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 securitycentermanagement_v1 + + def sample_get_effective_security_health_analytics_custom_module(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest( + name="name_value", + ) + + # Make the request + response = client.get_effective_security_health_analytics_custom_module(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.securitycentermanagement_v1.types.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest, dict]): + The request object. Message for getting a + EffectiveSecurityHealthAnalyticsCustomModule + name (str): + Required. The resource name of the SHA custom module. + + Its format is: + + - "organizations/{organization}/locations/{location}/effectiveSecurityHealthAnalyticsCustomModules/{module_id}". + - "folders/{folder}/locations/{location}/effectiveSecurityHealthAnalyticsCustomModules/{module_id}". + - "projects/{project}/locations/{location}/effectiveSecurityHealthAnalyticsCustomModules/{module_id}". + + 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.securitycentermanagement_v1.types.EffectiveSecurityHealthAnalyticsCustomModule: + An EffectiveSecurityHealthAnalyticsCustomModule is the representation of + a Security Health Analytics custom module at a + specified level of the resource hierarchy: + organization, folder, or project. If a custom module + is inherited from a parent organization or folder, + the value of the enablementState property in + EffectiveSecurityHealthAnalyticsCustomModule is set + to the value that is effective in the parent, instead + of INHERITED. For example, if the module is enabled + in a parent organization or folder, the effective + enablement_state for the module in all child folders + or projects is also enabled. + EffectiveSecurityHealthAnalyticsCustomModule is + read-only. + + """ + # 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 security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest): + request = security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest(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_effective_security_health_analytics_custom_module] + + # 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 list_security_health_analytics_custom_modules(self, + request: Optional[Union[security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest, 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.ListSecurityHealthAnalyticsCustomModulesPager: + r"""Returns a list of all + SecurityHealthAnalyticsCustomModules for the given + parent. This includes resident modules defined at the + scope of the parent, and inherited modules, inherited + from CRM ancestors (no descendants). + + .. 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 securitycentermanagement_v1 + + def sample_list_security_health_analytics_custom_modules(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.ListSecurityHealthAnalyticsCustomModulesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_security_health_analytics_custom_modules(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.securitycentermanagement_v1.types.ListSecurityHealthAnalyticsCustomModulesRequest, dict]): + The request object. Request message for listing Security + Health Analytics custom modules. + parent (str): + Required. Name of parent to list + custom modules. Its format is + "organizations/{organization}/locations/{location}", + "folders/{folder}/locations/{location}", + or + "projects/{project}/locations/{location}" + + 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.securitycentermanagement_v1.services.security_center_management.pagers.ListSecurityHealthAnalyticsCustomModulesPager: + Response message for listing Security + Health Analytics custom modules. + 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 security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest): + request = security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest(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_security_health_analytics_custom_modules] + + # 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.ListSecurityHealthAnalyticsCustomModulesPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def list_descendant_security_health_analytics_custom_modules(self, + request: Optional[Union[security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest, 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.ListDescendantSecurityHealthAnalyticsCustomModulesPager: + r"""Returns a list of all resident + SecurityHealthAnalyticsCustomModules under the given CRM + parent and all of the parent’s CRM descendants. + + .. 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 securitycentermanagement_v1 + + def sample_list_descendant_security_health_analytics_custom_modules(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.ListDescendantSecurityHealthAnalyticsCustomModulesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_descendant_security_health_analytics_custom_modules(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.securitycentermanagement_v1.types.ListDescendantSecurityHealthAnalyticsCustomModulesRequest, dict]): + The request object. Request message for listing + descendant Security Health Analytics + custom modules. + parent (str): + Required. Name of parent to list + custom modules. Its format is + "organizations/{organization}/locations/{location}", + "folders/{folder}/locations/{location}", + or + "projects/{project}/locations/{location}" + + 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.securitycentermanagement_v1.services.security_center_management.pagers.ListDescendantSecurityHealthAnalyticsCustomModulesPager: + Response message for listing + descendant Security Health Analytics + custom modules. + + 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 security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest): + request = security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest(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_descendant_security_health_analytics_custom_modules] + + # 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.ListDescendantSecurityHealthAnalyticsCustomModulesPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_security_health_analytics_custom_module(self, + request: Optional[Union[security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest, 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]] = (), + ) -> security_center_management.SecurityHealthAnalyticsCustomModule: + r"""Retrieves a SecurityHealthAnalyticsCustomModule. + + .. 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 securitycentermanagement_v1 + + def sample_get_security_health_analytics_custom_module(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.GetSecurityHealthAnalyticsCustomModuleRequest( + name="name_value", + ) + + # Make the request + response = client.get_security_health_analytics_custom_module(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.securitycentermanagement_v1.types.GetSecurityHealthAnalyticsCustomModuleRequest, dict]): + The request object. Message for getting a + SecurityHealthAnalyticsCustomModule + name (str): + Required. Name of the resource + 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.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule: + Represents an instance of a Security + Health Analytics custom module, + including its full module name, display + name, enablement state, and last updated + time. You can create a custom module at + the organization, folder, or project + level. Custom modules that you create at + the organization or folder level are + inherited by the child folders and + projects. + + """ + # 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 security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest): + request = security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest(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_security_health_analytics_custom_module] + + # 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 create_security_health_analytics_custom_module(self, + request: Optional[Union[security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest, dict]] = None, + *, + parent: Optional[str] = None, + security_health_analytics_custom_module: Optional[security_center_management.SecurityHealthAnalyticsCustomModule] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> security_center_management.SecurityHealthAnalyticsCustomModule: + r"""Creates a resident + SecurityHealthAnalyticsCustomModule at the scope of the + given CRM parent, and also creates inherited + SecurityHealthAnalyticsCustomModules for all CRM + descendants of the given parent. These modules are + enabled by default. + + .. 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 securitycentermanagement_v1 + + def sample_create_security_health_analytics_custom_module(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.CreateSecurityHealthAnalyticsCustomModuleRequest( + parent="parent_value", + ) + + # Make the request + response = client.create_security_health_analytics_custom_module(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.securitycentermanagement_v1.types.CreateSecurityHealthAnalyticsCustomModuleRequest, dict]): + The request object. Message for creating a + SecurityHealthAnalyticsCustomModule + parent (str): + Required. Name of the parent for the + module. Its format is + "organizations/{organization}/locations/{location}", + "folders/{folder}/locations/{location}", + or + "projects/{project}/locations/{location}" + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + security_health_analytics_custom_module (google.cloud.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule): + Required. The resource being created + This corresponds to the ``security_health_analytics_custom_module`` 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.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule: + Represents an instance of a Security + Health Analytics custom module, + including its full module name, display + name, enablement state, and last updated + time. You can create a custom module at + the organization, folder, or project + level. Custom modules that you create at + the organization or folder level are + inherited by the child folders and + projects. + + """ + # 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, security_health_analytics_custom_module]) + 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 security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest): + request = security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if security_health_analytics_custom_module is not None: + request.security_health_analytics_custom_module = security_health_analytics_custom_module + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_security_health_analytics_custom_module] + + # 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 update_security_health_analytics_custom_module(self, + request: Optional[Union[security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest, dict]] = None, + *, + security_health_analytics_custom_module: Optional[security_center_management.SecurityHealthAnalyticsCustomModule] = 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]] = (), + ) -> security_center_management.SecurityHealthAnalyticsCustomModule: + r"""Updates the SecurityHealthAnalyticsCustomModule under + the given name based on the given update mask. Updating + the enablement state is supported on both resident and + inherited modules (though resident modules cannot have + an enablement state of "inherited"). Updating the + display name and custom config of a module is supported + on resident modules only. + + .. 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 securitycentermanagement_v1 + + def sample_update_security_health_analytics_custom_module(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.UpdateSecurityHealthAnalyticsCustomModuleRequest( + ) + + # Make the request + response = client.update_security_health_analytics_custom_module(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.securitycentermanagement_v1.types.UpdateSecurityHealthAnalyticsCustomModuleRequest, dict]): + The request object. Message for updating a + SecurityHealthAnalyticsCustomModule + security_health_analytics_custom_module (google.cloud.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule): + Required. The resource being updated + This corresponds to the ``security_health_analytics_custom_module`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. Field mask is used to specify the fields to be + overwritten in the SecurityHealthAnalyticsCustomModule + resource by the update. The fields specified in the + update_mask are relative to the resource, not the full + request. A field will be overwritten if it is in the + mask. If the user does not provide a mask then all + fields will be overwritten. + + 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.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule: + Represents an instance of a Security + Health Analytics custom module, + including its full module name, display + name, enablement state, and last updated + time. You can create a custom module at + the organization, folder, or project + level. Custom modules that you create at + the organization or folder level are + inherited by the child folders and + projects. + + """ + # 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([security_health_analytics_custom_module, 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 security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest): + request = security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if security_health_analytics_custom_module is not None: + request.security_health_analytics_custom_module = security_health_analytics_custom_module + 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_security_health_analytics_custom_module] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("security_health_analytics_custom_module.name", request.security_health_analytics_custom_module.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def delete_security_health_analytics_custom_module(self, + request: Optional[Union[security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest, 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 + SecurityHealthAnalyticsCustomModule and all of its + descendants in the CRM hierarchy. This method is only + supported for resident custom modules. + + .. 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 securitycentermanagement_v1 + + def sample_delete_security_health_analytics_custom_module(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.DeleteSecurityHealthAnalyticsCustomModuleRequest( + name="name_value", + ) + + # Make the request + client.delete_security_health_analytics_custom_module(request=request) + + Args: + request (Union[google.cloud.securitycentermanagement_v1.types.DeleteSecurityHealthAnalyticsCustomModuleRequest, dict]): + The request object. Message for deleting a + SecurityHealthAnalyticsCustomModule + name (str): + Required. The resource name of the SHA custom module. + + Its format is: + + - "organizations/{organization}/locations/{location}/securityHealthAnalyticsCustomModules/{security_health_analytics_custom_module}". + - "folders/{folder}/locations/{location}/securityHealthAnalyticsCustomModules/{security_health_analytics_custom_module}". + - "projects/{project}/locations/{location}/securityHealthAnalyticsCustomModules/{security_health_analytics_custom_module}". + + 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 security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest): + request = security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest(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_security_health_analytics_custom_module] + + # 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 simulate_security_health_analytics_custom_module(self, + request: Optional[Union[security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest, dict]] = None, + *, + parent: Optional[str] = None, + custom_config: Optional[security_center_management.CustomConfig] = None, + resource: Optional[security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest.SimulatedResource] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse: + r"""Simulates a given SecurityHealthAnalyticsCustomModule + and Resource. + + .. 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 securitycentermanagement_v1 + + def sample_simulate_security_health_analytics_custom_module(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementClient() + + # Initialize request argument(s) + resource = securitycentermanagement_v1.SimulatedResource() + resource.resource_type = "resource_type_value" + + request = securitycentermanagement_v1.SimulateSecurityHealthAnalyticsCustomModuleRequest( + parent="parent_value", + resource=resource, + ) + + # Make the request + response = client.simulate_security_health_analytics_custom_module(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.securitycentermanagement_v1.types.SimulateSecurityHealthAnalyticsCustomModuleRequest, dict]): + The request object. Request message to simulate a + CustomConfig against a given test + resource. Maximum size of the request is + 4 MB by default. + parent (str): + Required. The relative resource name of the + organization, project, or folder. For more information + about relative resource names, see `Relative Resource + Name `__ + Example: ``organizations/{organization_id}``. + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + custom_config (google.cloud.securitycentermanagement_v1.types.CustomConfig): + Required. The custom configuration + that you need to test. + + This corresponds to the ``custom_config`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + resource (google.cloud.securitycentermanagement_v1.types.SimulateSecurityHealthAnalyticsCustomModuleRequest.SimulatedResource): + Required. Resource data to simulate + custom module against. + + This corresponds to the ``resource`` 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.securitycentermanagement_v1.types.SimulateSecurityHealthAnalyticsCustomModuleResponse: + Response message for simulating a SecurityHealthAnalyticsCustomModule + against a given resource. + + """ + # 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, custom_config, resource]) + 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 security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest): + request = security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if custom_config is not None: + request.custom_config = custom_config + if resource is not None: + request.resource = resource + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.simulate_security_health_analytics_custom_module] + + # 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_effective_event_threat_detection_custom_modules(self, + request: Optional[Union[security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest, 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.ListEffectiveEventThreatDetectionCustomModulesPager: + r"""Lists all effective Event Threat Detection custom + modules for the given parent. This includes resident + modules defined at the scope of the parent along with + modules inherited from its ancestors. + + .. 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 securitycentermanagement_v1 + + def sample_list_effective_event_threat_detection_custom_modules(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.ListEffectiveEventThreatDetectionCustomModulesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_effective_event_threat_detection_custom_modules(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.securitycentermanagement_v1.types.ListEffectiveEventThreatDetectionCustomModulesRequest, dict]): + The request object. Request message for listing effective + Event Threat Detection custom modules. + parent (str): + Required. Name of parent to list + effective custom modules. Its format is + "organizations/{organization}/locations/{location}", + "folders/{folder}/locations/{location}", + or + "projects/{project}/locations/{location}" + + 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.securitycentermanagement_v1.services.security_center_management.pagers.ListEffectiveEventThreatDetectionCustomModulesPager: + Response message for listing + effective Event Threat Detection custom + modules. + + 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 security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest): + request = security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest(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_effective_event_threat_detection_custom_modules] + + # 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.ListEffectiveEventThreatDetectionCustomModulesPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_effective_event_threat_detection_custom_module(self, + request: Optional[Union[security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest, 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]] = (), + ) -> security_center_management.EffectiveEventThreatDetectionCustomModule: + r"""Gets an effective ETD custom module. Retrieves the effective + module at the given level. The difference between an + EffectiveCustomModule and a CustomModule is that the fields for + an EffectiveCustomModule are computed from ancestors if needed. + For example, the enablement_state for a CustomModule can be + either ENABLED, DISABLED, or INHERITED. Where as the + enablement_state for an EffectiveCustomModule is always computed + to ENABLED or DISABLED (the effective enablement_state). + + .. 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 securitycentermanagement_v1 + + def sample_get_effective_event_threat_detection_custom_module(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.GetEffectiveEventThreatDetectionCustomModuleRequest( + name="name_value", + ) + + # Make the request + response = client.get_effective_event_threat_detection_custom_module(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.securitycentermanagement_v1.types.GetEffectiveEventThreatDetectionCustomModuleRequest, dict]): + The request object. Message for getting a + EffectiveEventThreatDetectionCustomModule + name (str): + Required. The resource name of the ETD custom module. + + Its format is: + + - "organizations/{organization}/locations/{location}/effectiveEventThreatDetectionCustomModules/{effective_event_threat_detection_custom_module}". + - "folders/{folder}/locations/{location}/effectiveEventThreatDetectionCustomModules/{effective_event_threat_detection_custom_module}". + - "projects/{project}/locations/{location}/effectiveEventThreatDetectionCustomModules/{effective_event_threat_detection_custom_module}". + + 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.securitycentermanagement_v1.types.EffectiveEventThreatDetectionCustomModule: + An EffectiveEventThreatDetectionCustomModule is the representation of + EventThreatDetectionCustomModule at a given level + taking hierarchy into account and resolving various + fields accordingly. e.g. if the module is enabled at + the ancestor level, effective modules at all + descendant levels will have enablement_state set to + ENABLED. Similarly, if module.inherited is set, then + effective module's config will contain the ancestor's + config details. + EffectiveEventThreatDetectionCustomModule is + read-only. + + """ + # 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 security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest): + request = security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest(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_effective_event_threat_detection_custom_module] + + # 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 list_event_threat_detection_custom_modules(self, + request: Optional[Union[security_center_management.ListEventThreatDetectionCustomModulesRequest, 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.ListEventThreatDetectionCustomModulesPager: + r"""Lists all Event Threat Detection custom modules for + the given Resource Manager parent. This includes + resident modules defined at the scope of the parent + along with modules inherited from ancestors. + + .. 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 securitycentermanagement_v1 + + def sample_list_event_threat_detection_custom_modules(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.ListEventThreatDetectionCustomModulesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_event_threat_detection_custom_modules(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.securitycentermanagement_v1.types.ListEventThreatDetectionCustomModulesRequest, dict]): + The request object. Request message for listing Event + Threat Detection custom modules. + parent (str): + Required. Name of parent to list + custom modules. Its format is + "organizations/{organization}/locations/{location}", + "folders/{folder}/locations/{location}", + or + "projects/{project}/locations/{location}" + + 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.securitycentermanagement_v1.services.security_center_management.pagers.ListEventThreatDetectionCustomModulesPager: + Response message for listing Event + Threat Detection custom modules. + 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 security_center_management.ListEventThreatDetectionCustomModulesRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, security_center_management.ListEventThreatDetectionCustomModulesRequest): + request = security_center_management.ListEventThreatDetectionCustomModulesRequest(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_event_threat_detection_custom_modules] + + # 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.ListEventThreatDetectionCustomModulesPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def list_descendant_event_threat_detection_custom_modules(self, + request: Optional[Union[security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest, 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.ListDescendantEventThreatDetectionCustomModulesPager: + r"""Lists all resident Event Threat Detection custom + modules under the given Resource Manager parent and its + descendants. + + .. 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 securitycentermanagement_v1 + + def sample_list_descendant_event_threat_detection_custom_modules(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.ListDescendantEventThreatDetectionCustomModulesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_descendant_event_threat_detection_custom_modules(request=request) + + # Handle the response + for response in page_result: + print(response) + + Args: + request (Union[google.cloud.securitycentermanagement_v1.types.ListDescendantEventThreatDetectionCustomModulesRequest, dict]): + The request object. Request message for listing + descendant Event Threat Detection custom + modules. + parent (str): + Required. Name of parent to list + custom modules. Its format is + "organizations/{organization}/locations/{location}", + "folders/{folder}/locations/{location}", + or + "projects/{project}/locations/{location}" + + 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.securitycentermanagement_v1.services.security_center_management.pagers.ListDescendantEventThreatDetectionCustomModulesPager: + Response message for listing + descendant Event Threat Detection custom + modules. + + 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 security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest): + request = security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest(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_descendant_event_threat_detection_custom_modules] + + # 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.ListDescendantEventThreatDetectionCustomModulesPager( + method=rpc, + request=request, + response=response, + metadata=metadata, + ) + + # Done; return the response. + return response + + def get_event_threat_detection_custom_module(self, + request: Optional[Union[security_center_management.GetEventThreatDetectionCustomModuleRequest, 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]] = (), + ) -> security_center_management.EventThreatDetectionCustomModule: + r"""Gets an Event Threat Detection custom module. + + .. 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 securitycentermanagement_v1 + + def sample_get_event_threat_detection_custom_module(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.GetEventThreatDetectionCustomModuleRequest( + name="name_value", + ) + + # Make the request + response = client.get_event_threat_detection_custom_module(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.securitycentermanagement_v1.types.GetEventThreatDetectionCustomModuleRequest, dict]): + The request object. Message for getting a + EventThreatDetectionCustomModule + name (str): + Required. The resource name of the ETD custom module. + + Its format is: + + - "organizations/{organization}/locations/{location}/eventThreatDetectionCustomModules/{event_threat_detection_custom_module}". + - "folders/{folder}/locations/{location}/eventThreatDetectionCustomModules/{event_threat_detection_custom_module}". + - "projects/{project}/locations/{location}/eventThreatDetectionCustomModules/{event_threat_detection_custom_module}". + + 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.securitycentermanagement_v1.types.EventThreatDetectionCustomModule: + An event threat detection custom + module is a Cloud SCC resource that + contains the configuration and + enablement state of a custom module, + which enables ETD to write certain + findings to Cloud SCC. + + """ + # 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 security_center_management.GetEventThreatDetectionCustomModuleRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, security_center_management.GetEventThreatDetectionCustomModuleRequest): + request = security_center_management.GetEventThreatDetectionCustomModuleRequest(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_event_threat_detection_custom_module] + + # 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 create_event_threat_detection_custom_module(self, + request: Optional[Union[security_center_management.CreateEventThreatDetectionCustomModuleRequest, dict]] = None, + *, + parent: Optional[str] = None, + event_threat_detection_custom_module: Optional[security_center_management.EventThreatDetectionCustomModule] = None, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> security_center_management.EventThreatDetectionCustomModule: + r"""Creates a resident Event Threat Detection custom + module at the scope of the given Resource Manager + parent, and also creates inherited custom modules for + all descendants of the given parent. These modules are + enabled by default. + + .. 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 securitycentermanagement_v1 + + def sample_create_event_threat_detection_custom_module(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.CreateEventThreatDetectionCustomModuleRequest( + parent="parent_value", + ) + + # Make the request + response = client.create_event_threat_detection_custom_module(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.securitycentermanagement_v1.types.CreateEventThreatDetectionCustomModuleRequest, dict]): + The request object. Message for creating a + EventThreatDetectionCustomModule + parent (str): + Required. Name of parent for the + module. Its format is + "organizations/{organization}/locations/{location}", + "folders/{folder}/locations/{location}", + or + "projects/{project}/locations/{location}" + + This corresponds to the ``parent`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + event_threat_detection_custom_module (google.cloud.securitycentermanagement_v1.types.EventThreatDetectionCustomModule): + Required. The module to create. The + event_threat_detection_custom_module.name will be + ignored and server generated. + + This corresponds to the ``event_threat_detection_custom_module`` 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.securitycentermanagement_v1.types.EventThreatDetectionCustomModule: + An event threat detection custom + module is a Cloud SCC resource that + contains the configuration and + enablement state of a custom module, + which enables ETD to write certain + findings to Cloud SCC. + + """ + # 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, event_threat_detection_custom_module]) + 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 security_center_management.CreateEventThreatDetectionCustomModuleRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, security_center_management.CreateEventThreatDetectionCustomModuleRequest): + request = security_center_management.CreateEventThreatDetectionCustomModuleRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if parent is not None: + request.parent = parent + if event_threat_detection_custom_module is not None: + request.event_threat_detection_custom_module = event_threat_detection_custom_module + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.create_event_threat_detection_custom_module] + + # 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 update_event_threat_detection_custom_module(self, + request: Optional[Union[security_center_management.UpdateEventThreatDetectionCustomModuleRequest, dict]] = None, + *, + event_threat_detection_custom_module: Optional[security_center_management.EventThreatDetectionCustomModule] = 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]] = (), + ) -> security_center_management.EventThreatDetectionCustomModule: + r"""Updates the Event Threat Detection custom module with + the given name based on the given update mask. Updating + the enablement state is supported for both resident and + inherited modules (though resident modules cannot have + an enablement state of "inherited"). Updating the + display name or configuration of a module is supported + for resident modules only. The type of a module cannot + be changed. + + .. 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 securitycentermanagement_v1 + + def sample_update_event_threat_detection_custom_module(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.UpdateEventThreatDetectionCustomModuleRequest( + ) + + # Make the request + response = client.update_event_threat_detection_custom_module(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.securitycentermanagement_v1.types.UpdateEventThreatDetectionCustomModuleRequest, dict]): + The request object. Message for updating a + EventThreatDetectionCustomModule + event_threat_detection_custom_module (google.cloud.securitycentermanagement_v1.types.EventThreatDetectionCustomModule): + Required. The module being updated + This corresponds to the ``event_threat_detection_custom_module`` field + on the ``request`` instance; if ``request`` is provided, this + should not be set. + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. Field mask is used to specify the fields to be + overwritten in the EventThreatDetectionCustomModule + resource by the update. The fields specified in the + update_mask are relative to the resource, not the full + request. A field will be overwritten if it is in the + mask. If the user does not provide a mask then all + fields will be overwritten. + + 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.securitycentermanagement_v1.types.EventThreatDetectionCustomModule: + An event threat detection custom + module is a Cloud SCC resource that + contains the configuration and + enablement state of a custom module, + which enables ETD to write certain + findings to Cloud SCC. + + """ + # 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([event_threat_detection_custom_module, 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 security_center_management.UpdateEventThreatDetectionCustomModuleRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, security_center_management.UpdateEventThreatDetectionCustomModuleRequest): + request = security_center_management.UpdateEventThreatDetectionCustomModuleRequest(request) + # If we have keyword arguments corresponding to fields on the + # request, apply these. + if event_threat_detection_custom_module is not None: + request.event_threat_detection_custom_module = event_threat_detection_custom_module + 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_event_threat_detection_custom_module] + + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ("event_threat_detection_custom_module.name", request.event_threat_detection_custom_module.name), + )), + ) + + # Send the request. + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) + + # Done; return the response. + return response + + def delete_event_threat_detection_custom_module(self, + request: Optional[Union[security_center_management.DeleteEventThreatDetectionCustomModuleRequest, 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 Event Threat Detection custom + module and all of its descendants in the Resource + Manager hierarchy. This method is only supported for + resident custom modules. + + .. 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 securitycentermanagement_v1 + + def sample_delete_event_threat_detection_custom_module(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.DeleteEventThreatDetectionCustomModuleRequest( + name="name_value", + ) + + # Make the request + client.delete_event_threat_detection_custom_module(request=request) + + Args: + request (Union[google.cloud.securitycentermanagement_v1.types.DeleteEventThreatDetectionCustomModuleRequest, dict]): + The request object. Message for deleting a + EventThreatDetectionCustomModule + name (str): + Required. The resource name of the ETD custom module. + + Its format is: + + - "organizations/{organization}/locations/{location}/eventThreatDetectionCustomModules/{event_threat_detection_custom_module}". + - "folders/{folder}/locations/{location}/eventThreatDetectionCustomModules/{event_threat_detection_custom_module}". + - "projects/{project}/locations/{location}/eventThreatDetectionCustomModules/{event_threat_detection_custom_module}". + + 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 security_center_management.DeleteEventThreatDetectionCustomModuleRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, security_center_management.DeleteEventThreatDetectionCustomModuleRequest): + request = security_center_management.DeleteEventThreatDetectionCustomModuleRequest(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_event_threat_detection_custom_module] + + # 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 validate_event_threat_detection_custom_module(self, + request: Optional[Union[security_center_management.ValidateEventThreatDetectionCustomModuleRequest, dict]] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> security_center_management.ValidateEventThreatDetectionCustomModuleResponse: + r"""Validates the given Event Threat Detection custom + module. + + .. 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 securitycentermanagement_v1 + + def sample_validate_event_threat_detection_custom_module(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.ValidateEventThreatDetectionCustomModuleRequest( + parent="parent_value", + raw_text="raw_text_value", + type_="type__value", + ) + + # Make the request + response = client.validate_event_threat_detection_custom_module(request=request) + + # Handle the response + print(response) + + Args: + request (Union[google.cloud.securitycentermanagement_v1.types.ValidateEventThreatDetectionCustomModuleRequest, dict]): + The request object. Request to validate an Event Threat + Detection custom module. + 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.securitycentermanagement_v1.types.ValidateEventThreatDetectionCustomModuleResponse: + Response to validating an Event + Threat Detection custom module. + + """ + # Create or coerce a protobuf request object. + # Minor optimization to avoid making a copy if the user passes + # in a security_center_management.ValidateEventThreatDetectionCustomModuleRequest. + # There's no risk of modifying the input as we've already verified + # there are no flattened fields. + if not isinstance(request, security_center_management.ValidateEventThreatDetectionCustomModuleRequest): + request = security_center_management.ValidateEventThreatDetectionCustomModuleRequest(request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = self._transport._wrapped_methods[self._transport.validate_event_threat_detection_custom_module] + + # 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 __enter__(self) -> "SecurityCenterManagementClient": + return self + + def __exit__(self, type, value, traceback): + """Releases underlying transport's resources. + + .. warning:: + ONLY use as a context manager if the transport is NOT shared + with other clients! Exiting the with block will CLOSE the transport + and may cause errors in other clients! + """ + self.transport.close() + + def get_location( + self, + request: Optional[locations_pb2.GetLocationRequest] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> locations_pb2.Location: + r"""Gets information about a location. + + Args: + request (:class:`~.location_pb2.GetLocationRequest`): + The request object. Request message for + `GetLocation` method. + 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: + ~.location_pb2.Location: + Location object. + """ + # Create or coerce a protobuf request object. + # The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + if isinstance(request, dict): + request = locations_pb2.GetLocationRequest(**request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._transport.get_location, + 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 = rpc( + request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + def list_locations( + self, + request: Optional[locations_pb2.ListLocationsRequest] = None, + *, + retry: OptionalRetry = gapic_v1.method.DEFAULT, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, + metadata: Sequence[Tuple[str, str]] = (), + ) -> locations_pb2.ListLocationsResponse: + r"""Lists information about the supported locations for this service. + + Args: + request (:class:`~.location_pb2.ListLocationsRequest`): + The request object. Request message for + `ListLocations` method. + 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: + ~.location_pb2.ListLocationsResponse: + Response message for ``ListLocations`` method. + """ + # Create or coerce a protobuf request object. + # The request isn't a proto-plus wrapped type, + # so it must be constructed via keyword expansion. + if isinstance(request, dict): + request = locations_pb2.ListLocationsRequest(**request) + + # Wrap the RPC method; this adds retry and timeout information, + # and friendly error handling. + rpc = gapic_v1.method.wrap_method( + self._transport.list_locations, + 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 = rpc( + request, retry=retry, timeout=timeout, metadata=metadata,) + + # Done; return the response. + return response + + +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) + + +__all__ = ( + "SecurityCenterManagementClient", +) diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/pagers.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/pagers.py new file mode 100644 index 000000000000..3caca15d9f13 --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/pagers.py @@ -0,0 +1,744 @@ +# -*- 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. +# +from typing import Any, AsyncIterator, Awaitable, Callable, Sequence, Tuple, Optional, Iterator + +from google.cloud.securitycentermanagement_v1.types import security_center_management + + +class ListEffectiveSecurityHealthAnalyticsCustomModulesPager: + """A pager for iterating through ``list_effective_security_health_analytics_custom_modules`` requests. + + This class thinly wraps an initial + :class:`google.cloud.securitycentermanagement_v1.types.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse` object, and + provides an ``__iter__`` method to iterate through its + ``effective_security_health_analytics_custom_modules`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListEffectiveSecurityHealthAnalyticsCustomModules`` requests and continue to iterate + through the ``effective_security_health_analytics_custom_modules`` field on the + corresponding responses. + + All the usual :class:`google.cloud.securitycentermanagement_v1.types.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse` + 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[..., security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse], + request: security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest, + response: security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse, + *, + 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.securitycentermanagement_v1.types.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest): + The initial request object. + response (google.cloud.securitycentermanagement_v1.types.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse): + 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 = security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse]: + 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[security_center_management.EffectiveSecurityHealthAnalyticsCustomModule]: + for page in self.pages: + yield from page.effective_security_health_analytics_custom_modules + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListEffectiveSecurityHealthAnalyticsCustomModulesAsyncPager: + """A pager for iterating through ``list_effective_security_health_analytics_custom_modules`` requests. + + This class thinly wraps an initial + :class:`google.cloud.securitycentermanagement_v1.types.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``effective_security_health_analytics_custom_modules`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListEffectiveSecurityHealthAnalyticsCustomModules`` requests and continue to iterate + through the ``effective_security_health_analytics_custom_modules`` field on the + corresponding responses. + + All the usual :class:`google.cloud.securitycentermanagement_v1.types.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse` + 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[security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse]], + request: security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest, + response: security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse, + *, + 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.securitycentermanagement_v1.types.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest): + The initial request object. + response (google.cloud.securitycentermanagement_v1.types.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse): + 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 = security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse]: + 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[security_center_management.EffectiveSecurityHealthAnalyticsCustomModule]: + async def async_generator(): + async for page in self.pages: + for response in page.effective_security_health_analytics_custom_modules: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListSecurityHealthAnalyticsCustomModulesPager: + """A pager for iterating through ``list_security_health_analytics_custom_modules`` requests. + + This class thinly wraps an initial + :class:`google.cloud.securitycentermanagement_v1.types.ListSecurityHealthAnalyticsCustomModulesResponse` object, and + provides an ``__iter__`` method to iterate through its + ``security_health_analytics_custom_modules`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListSecurityHealthAnalyticsCustomModules`` requests and continue to iterate + through the ``security_health_analytics_custom_modules`` field on the + corresponding responses. + + All the usual :class:`google.cloud.securitycentermanagement_v1.types.ListSecurityHealthAnalyticsCustomModulesResponse` + 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[..., security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse], + request: security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest, + response: security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse, + *, + 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.securitycentermanagement_v1.types.ListSecurityHealthAnalyticsCustomModulesRequest): + The initial request object. + response (google.cloud.securitycentermanagement_v1.types.ListSecurityHealthAnalyticsCustomModulesResponse): + 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 = security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse]: + 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[security_center_management.SecurityHealthAnalyticsCustomModule]: + for page in self.pages: + yield from page.security_health_analytics_custom_modules + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListSecurityHealthAnalyticsCustomModulesAsyncPager: + """A pager for iterating through ``list_security_health_analytics_custom_modules`` requests. + + This class thinly wraps an initial + :class:`google.cloud.securitycentermanagement_v1.types.ListSecurityHealthAnalyticsCustomModulesResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``security_health_analytics_custom_modules`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListSecurityHealthAnalyticsCustomModules`` requests and continue to iterate + through the ``security_health_analytics_custom_modules`` field on the + corresponding responses. + + All the usual :class:`google.cloud.securitycentermanagement_v1.types.ListSecurityHealthAnalyticsCustomModulesResponse` + 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[security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse]], + request: security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest, + response: security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse, + *, + 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.securitycentermanagement_v1.types.ListSecurityHealthAnalyticsCustomModulesRequest): + The initial request object. + response (google.cloud.securitycentermanagement_v1.types.ListSecurityHealthAnalyticsCustomModulesResponse): + 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 = security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse]: + 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[security_center_management.SecurityHealthAnalyticsCustomModule]: + async def async_generator(): + async for page in self.pages: + for response in page.security_health_analytics_custom_modules: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListDescendantSecurityHealthAnalyticsCustomModulesPager: + """A pager for iterating through ``list_descendant_security_health_analytics_custom_modules`` requests. + + This class thinly wraps an initial + :class:`google.cloud.securitycentermanagement_v1.types.ListDescendantSecurityHealthAnalyticsCustomModulesResponse` object, and + provides an ``__iter__`` method to iterate through its + ``security_health_analytics_custom_modules`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListDescendantSecurityHealthAnalyticsCustomModules`` requests and continue to iterate + through the ``security_health_analytics_custom_modules`` field on the + corresponding responses. + + All the usual :class:`google.cloud.securitycentermanagement_v1.types.ListDescendantSecurityHealthAnalyticsCustomModulesResponse` + 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[..., security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse], + request: security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest, + response: security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse, + *, + 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.securitycentermanagement_v1.types.ListDescendantSecurityHealthAnalyticsCustomModulesRequest): + The initial request object. + response (google.cloud.securitycentermanagement_v1.types.ListDescendantSecurityHealthAnalyticsCustomModulesResponse): + 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 = security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse]: + 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[security_center_management.SecurityHealthAnalyticsCustomModule]: + for page in self.pages: + yield from page.security_health_analytics_custom_modules + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListDescendantSecurityHealthAnalyticsCustomModulesAsyncPager: + """A pager for iterating through ``list_descendant_security_health_analytics_custom_modules`` requests. + + This class thinly wraps an initial + :class:`google.cloud.securitycentermanagement_v1.types.ListDescendantSecurityHealthAnalyticsCustomModulesResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``security_health_analytics_custom_modules`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListDescendantSecurityHealthAnalyticsCustomModules`` requests and continue to iterate + through the ``security_health_analytics_custom_modules`` field on the + corresponding responses. + + All the usual :class:`google.cloud.securitycentermanagement_v1.types.ListDescendantSecurityHealthAnalyticsCustomModulesResponse` + 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[security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse]], + request: security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest, + response: security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse, + *, + 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.securitycentermanagement_v1.types.ListDescendantSecurityHealthAnalyticsCustomModulesRequest): + The initial request object. + response (google.cloud.securitycentermanagement_v1.types.ListDescendantSecurityHealthAnalyticsCustomModulesResponse): + 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 = security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse]: + 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[security_center_management.SecurityHealthAnalyticsCustomModule]: + async def async_generator(): + async for page in self.pages: + for response in page.security_health_analytics_custom_modules: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListEffectiveEventThreatDetectionCustomModulesPager: + """A pager for iterating through ``list_effective_event_threat_detection_custom_modules`` requests. + + This class thinly wraps an initial + :class:`google.cloud.securitycentermanagement_v1.types.ListEffectiveEventThreatDetectionCustomModulesResponse` object, and + provides an ``__iter__`` method to iterate through its + ``effective_event_threat_detection_custom_modules`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListEffectiveEventThreatDetectionCustomModules`` requests and continue to iterate + through the ``effective_event_threat_detection_custom_modules`` field on the + corresponding responses. + + All the usual :class:`google.cloud.securitycentermanagement_v1.types.ListEffectiveEventThreatDetectionCustomModulesResponse` + 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[..., security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse], + request: security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest, + response: security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse, + *, + 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.securitycentermanagement_v1.types.ListEffectiveEventThreatDetectionCustomModulesRequest): + The initial request object. + response (google.cloud.securitycentermanagement_v1.types.ListEffectiveEventThreatDetectionCustomModulesResponse): + 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 = security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse]: + 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[security_center_management.EffectiveEventThreatDetectionCustomModule]: + for page in self.pages: + yield from page.effective_event_threat_detection_custom_modules + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListEffectiveEventThreatDetectionCustomModulesAsyncPager: + """A pager for iterating through ``list_effective_event_threat_detection_custom_modules`` requests. + + This class thinly wraps an initial + :class:`google.cloud.securitycentermanagement_v1.types.ListEffectiveEventThreatDetectionCustomModulesResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``effective_event_threat_detection_custom_modules`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListEffectiveEventThreatDetectionCustomModules`` requests and continue to iterate + through the ``effective_event_threat_detection_custom_modules`` field on the + corresponding responses. + + All the usual :class:`google.cloud.securitycentermanagement_v1.types.ListEffectiveEventThreatDetectionCustomModulesResponse` + 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[security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse]], + request: security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest, + response: security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse, + *, + 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.securitycentermanagement_v1.types.ListEffectiveEventThreatDetectionCustomModulesRequest): + The initial request object. + response (google.cloud.securitycentermanagement_v1.types.ListEffectiveEventThreatDetectionCustomModulesResponse): + 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 = security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse]: + 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[security_center_management.EffectiveEventThreatDetectionCustomModule]: + async def async_generator(): + async for page in self.pages: + for response in page.effective_event_threat_detection_custom_modules: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListEventThreatDetectionCustomModulesPager: + """A pager for iterating through ``list_event_threat_detection_custom_modules`` requests. + + This class thinly wraps an initial + :class:`google.cloud.securitycentermanagement_v1.types.ListEventThreatDetectionCustomModulesResponse` object, and + provides an ``__iter__`` method to iterate through its + ``event_threat_detection_custom_modules`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListEventThreatDetectionCustomModules`` requests and continue to iterate + through the ``event_threat_detection_custom_modules`` field on the + corresponding responses. + + All the usual :class:`google.cloud.securitycentermanagement_v1.types.ListEventThreatDetectionCustomModulesResponse` + 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[..., security_center_management.ListEventThreatDetectionCustomModulesResponse], + request: security_center_management.ListEventThreatDetectionCustomModulesRequest, + response: security_center_management.ListEventThreatDetectionCustomModulesResponse, + *, + 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.securitycentermanagement_v1.types.ListEventThreatDetectionCustomModulesRequest): + The initial request object. + response (google.cloud.securitycentermanagement_v1.types.ListEventThreatDetectionCustomModulesResponse): + 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 = security_center_management.ListEventThreatDetectionCustomModulesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[security_center_management.ListEventThreatDetectionCustomModulesResponse]: + 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[security_center_management.EventThreatDetectionCustomModule]: + for page in self.pages: + yield from page.event_threat_detection_custom_modules + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListEventThreatDetectionCustomModulesAsyncPager: + """A pager for iterating through ``list_event_threat_detection_custom_modules`` requests. + + This class thinly wraps an initial + :class:`google.cloud.securitycentermanagement_v1.types.ListEventThreatDetectionCustomModulesResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``event_threat_detection_custom_modules`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListEventThreatDetectionCustomModules`` requests and continue to iterate + through the ``event_threat_detection_custom_modules`` field on the + corresponding responses. + + All the usual :class:`google.cloud.securitycentermanagement_v1.types.ListEventThreatDetectionCustomModulesResponse` + 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[security_center_management.ListEventThreatDetectionCustomModulesResponse]], + request: security_center_management.ListEventThreatDetectionCustomModulesRequest, + response: security_center_management.ListEventThreatDetectionCustomModulesResponse, + *, + 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.securitycentermanagement_v1.types.ListEventThreatDetectionCustomModulesRequest): + The initial request object. + response (google.cloud.securitycentermanagement_v1.types.ListEventThreatDetectionCustomModulesResponse): + 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 = security_center_management.ListEventThreatDetectionCustomModulesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[security_center_management.ListEventThreatDetectionCustomModulesResponse]: + 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[security_center_management.EventThreatDetectionCustomModule]: + async def async_generator(): + async for page in self.pages: + for response in page.event_threat_detection_custom_modules: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListDescendantEventThreatDetectionCustomModulesPager: + """A pager for iterating through ``list_descendant_event_threat_detection_custom_modules`` requests. + + This class thinly wraps an initial + :class:`google.cloud.securitycentermanagement_v1.types.ListDescendantEventThreatDetectionCustomModulesResponse` object, and + provides an ``__iter__`` method to iterate through its + ``event_threat_detection_custom_modules`` field. + + If there are more pages, the ``__iter__`` method will make additional + ``ListDescendantEventThreatDetectionCustomModules`` requests and continue to iterate + through the ``event_threat_detection_custom_modules`` field on the + corresponding responses. + + All the usual :class:`google.cloud.securitycentermanagement_v1.types.ListDescendantEventThreatDetectionCustomModulesResponse` + 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[..., security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse], + request: security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest, + response: security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse, + *, + 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.securitycentermanagement_v1.types.ListDescendantEventThreatDetectionCustomModulesRequest): + The initial request object. + response (google.cloud.securitycentermanagement_v1.types.ListDescendantEventThreatDetectionCustomModulesResponse): + 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 = security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + def pages(self) -> Iterator[security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse]: + 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[security_center_management.EventThreatDetectionCustomModule]: + for page in self.pages: + yield from page.event_threat_detection_custom_modules + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + + +class ListDescendantEventThreatDetectionCustomModulesAsyncPager: + """A pager for iterating through ``list_descendant_event_threat_detection_custom_modules`` requests. + + This class thinly wraps an initial + :class:`google.cloud.securitycentermanagement_v1.types.ListDescendantEventThreatDetectionCustomModulesResponse` object, and + provides an ``__aiter__`` method to iterate through its + ``event_threat_detection_custom_modules`` field. + + If there are more pages, the ``__aiter__`` method will make additional + ``ListDescendantEventThreatDetectionCustomModules`` requests and continue to iterate + through the ``event_threat_detection_custom_modules`` field on the + corresponding responses. + + All the usual :class:`google.cloud.securitycentermanagement_v1.types.ListDescendantEventThreatDetectionCustomModulesResponse` + 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[security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse]], + request: security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest, + response: security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse, + *, + 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.securitycentermanagement_v1.types.ListDescendantEventThreatDetectionCustomModulesRequest): + The initial request object. + response (google.cloud.securitycentermanagement_v1.types.ListDescendantEventThreatDetectionCustomModulesResponse): + 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 = security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest(request) + self._response = response + self._metadata = metadata + + def __getattr__(self, name: str) -> Any: + return getattr(self._response, name) + + @property + async def pages(self) -> AsyncIterator[security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse]: + 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[security_center_management.EventThreatDetectionCustomModule]: + async def async_generator(): + async for page in self.pages: + for response in page.event_threat_detection_custom_modules: + yield response + + return async_generator() + + def __repr__(self) -> str: + return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/__init__.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/__init__.py new file mode 100644 index 000000000000..33264c4d84cf --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/__init__.py @@ -0,0 +1,38 @@ +# -*- 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. +# +from collections import OrderedDict +from typing import Dict, Type + +from .base import SecurityCenterManagementTransport +from .grpc import SecurityCenterManagementGrpcTransport +from .grpc_asyncio import SecurityCenterManagementGrpcAsyncIOTransport +from .rest import SecurityCenterManagementRestTransport +from .rest import SecurityCenterManagementRestInterceptor + + +# Compile a registry of transports. +_transport_registry = OrderedDict() # type: Dict[str, Type[SecurityCenterManagementTransport]] +_transport_registry['grpc'] = SecurityCenterManagementGrpcTransport +_transport_registry['grpc_asyncio'] = SecurityCenterManagementGrpcAsyncIOTransport +_transport_registry['rest'] = SecurityCenterManagementRestTransport + +__all__ = ( + 'SecurityCenterManagementTransport', + 'SecurityCenterManagementGrpcTransport', + 'SecurityCenterManagementGrpcAsyncIOTransport', + 'SecurityCenterManagementRestTransport', + 'SecurityCenterManagementRestInterceptor', +) diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/base.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/base.py new file mode 100644 index 000000000000..a7b4edfb139e --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/base.py @@ -0,0 +1,488 @@ +# -*- 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. +# +import abc +from typing import Awaitable, Callable, Dict, Optional, Sequence, Union + +from google.cloud.securitycentermanagement_v1 import gapic_version as package_version + +import google.auth # type: ignore +import google.api_core +from google.api_core import exceptions as core_exceptions +from google.api_core import gapic_v1 +from google.api_core import retry as retries +from google.auth import credentials as ga_credentials # type: ignore +from google.oauth2 import service_account # type: ignore + +from google.cloud.location import locations_pb2 # type: ignore +from google.cloud.securitycentermanagement_v1.types import security_center_management +from google.protobuf import empty_pb2 # type: ignore + +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) + + +class SecurityCenterManagementTransport(abc.ABC): + """Abstract transport class for SecurityCenterManagement.""" + + AUTH_SCOPES = ( + 'https://www.googleapis.com/auth/cloud-platform', + ) + + DEFAULT_HOST: str = 'securitycentermanagement.googleapis.com' + def __init__( + self, *, + host: str = DEFAULT_HOST, + credentials: Optional[ga_credentials.Credentials] = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + always_use_jwt_access: Optional[bool] = False, + api_audience: Optional[str] = None, + **kwargs, + ) -> None: + """Instantiate the transport. + + Args: + host (Optional[str]): + The hostname to connect to. + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is mutually exclusive with credentials. + scopes (Optional[Sequence[str]]): A list of scopes. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing + your own client library. + always_use_jwt_access (Optional[bool]): Whether self signed JWT should + be used for service account credentials. + """ + + scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES} + + # Save the scopes. + self._scopes = scopes + + # If no credentials are provided, then determine the appropriate + # defaults. + if credentials and credentials_file: + raise core_exceptions.DuplicateCredentialArgs("'credentials_file' and 'credentials' are mutually exclusive") + + if credentials_file is not None: + credentials, _ = google.auth.load_credentials_from_file( + credentials_file, + **scopes_kwargs, + quota_project_id=quota_project_id + ) + elif credentials is None: + credentials, _ = google.auth.default(**scopes_kwargs, quota_project_id=quota_project_id) + # Don't apply audience if the credentials file passed from user. + if hasattr(credentials, "with_gdch_audience"): + credentials = credentials.with_gdch_audience(api_audience if api_audience else host) + + # If the credentials are service account credentials, then always try to use self signed JWT. + if always_use_jwt_access and isinstance(credentials, service_account.Credentials) and hasattr(service_account.Credentials, "with_always_use_jwt_access"): + credentials = credentials.with_always_use_jwt_access(True) + + # Save the credentials. + self._credentials = credentials + + # Save the hostname. Default to port 443 (HTTPS) if none is specified. + if ':' not in host: + host += ':443' + self._host = host + + def _prep_wrapped_messages(self, client_info): + # Precompute the wrapped methods. + self._wrapped_methods = { + self.list_effective_security_health_analytics_custom_modules: gapic_v1.method.wrap_method( + self.list_effective_security_health_analytics_custom_modules, + default_retry=retries.Retry( +initial=0.1,maximum=60.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.DeadlineExceeded, + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.get_effective_security_health_analytics_custom_module: gapic_v1.method.wrap_method( + self.get_effective_security_health_analytics_custom_module, + default_retry=retries.Retry( +initial=0.1,maximum=60.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.DeadlineExceeded, + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.list_security_health_analytics_custom_modules: gapic_v1.method.wrap_method( + self.list_security_health_analytics_custom_modules, + default_retry=retries.Retry( +initial=0.1,maximum=60.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.DeadlineExceeded, + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.list_descendant_security_health_analytics_custom_modules: gapic_v1.method.wrap_method( + self.list_descendant_security_health_analytics_custom_modules, + default_retry=retries.Retry( +initial=0.1,maximum=60.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.DeadlineExceeded, + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.get_security_health_analytics_custom_module: gapic_v1.method.wrap_method( + self.get_security_health_analytics_custom_module, + default_retry=retries.Retry( +initial=0.1,maximum=60.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.DeadlineExceeded, + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.create_security_health_analytics_custom_module: gapic_v1.method.wrap_method( + self.create_security_health_analytics_custom_module, + default_timeout=60.0, + client_info=client_info, + ), + self.update_security_health_analytics_custom_module: gapic_v1.method.wrap_method( + self.update_security_health_analytics_custom_module, + default_timeout=60.0, + client_info=client_info, + ), + self.delete_security_health_analytics_custom_module: gapic_v1.method.wrap_method( + self.delete_security_health_analytics_custom_module, + default_timeout=60.0, + client_info=client_info, + ), + self.simulate_security_health_analytics_custom_module: gapic_v1.method.wrap_method( + self.simulate_security_health_analytics_custom_module, + default_retry=retries.Retry( +initial=0.1,maximum=60.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.DeadlineExceeded, + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.list_effective_event_threat_detection_custom_modules: gapic_v1.method.wrap_method( + self.list_effective_event_threat_detection_custom_modules, + default_retry=retries.Retry( +initial=0.1,maximum=60.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.DeadlineExceeded, + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.get_effective_event_threat_detection_custom_module: gapic_v1.method.wrap_method( + self.get_effective_event_threat_detection_custom_module, + default_retry=retries.Retry( +initial=0.1,maximum=60.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.DeadlineExceeded, + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.list_event_threat_detection_custom_modules: gapic_v1.method.wrap_method( + self.list_event_threat_detection_custom_modules, + default_retry=retries.Retry( +initial=0.1,maximum=60.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.DeadlineExceeded, + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.list_descendant_event_threat_detection_custom_modules: gapic_v1.method.wrap_method( + self.list_descendant_event_threat_detection_custom_modules, + default_retry=retries.Retry( +initial=0.1,maximum=60.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.DeadlineExceeded, + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.get_event_threat_detection_custom_module: gapic_v1.method.wrap_method( + self.get_event_threat_detection_custom_module, + default_retry=retries.Retry( +initial=0.1,maximum=60.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.DeadlineExceeded, + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + self.create_event_threat_detection_custom_module: gapic_v1.method.wrap_method( + self.create_event_threat_detection_custom_module, + default_timeout=60.0, + client_info=client_info, + ), + self.update_event_threat_detection_custom_module: gapic_v1.method.wrap_method( + self.update_event_threat_detection_custom_module, + default_timeout=60.0, + client_info=client_info, + ), + self.delete_event_threat_detection_custom_module: gapic_v1.method.wrap_method( + self.delete_event_threat_detection_custom_module, + default_timeout=60.0, + client_info=client_info, + ), + self.validate_event_threat_detection_custom_module: gapic_v1.method.wrap_method( + self.validate_event_threat_detection_custom_module, + default_retry=retries.Retry( +initial=0.1,maximum=60.0,multiplier=1.3, predicate=retries.if_exception_type( + core_exceptions.DeadlineExceeded, + core_exceptions.ServiceUnavailable, + ), + deadline=60.0, + ), + default_timeout=60.0, + client_info=client_info, + ), + } + + def close(self): + """Closes resources associated with the transport. + + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! + """ + raise NotImplementedError() + + @property + def list_effective_security_health_analytics_custom_modules(self) -> Callable[ + [security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest], + Union[ + security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse, + Awaitable[security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse] + ]]: + raise NotImplementedError() + + @property + def get_effective_security_health_analytics_custom_module(self) -> Callable[ + [security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest], + Union[ + security_center_management.EffectiveSecurityHealthAnalyticsCustomModule, + Awaitable[security_center_management.EffectiveSecurityHealthAnalyticsCustomModule] + ]]: + raise NotImplementedError() + + @property + def list_security_health_analytics_custom_modules(self) -> Callable[ + [security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest], + Union[ + security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse, + Awaitable[security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse] + ]]: + raise NotImplementedError() + + @property + def list_descendant_security_health_analytics_custom_modules(self) -> Callable[ + [security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest], + Union[ + security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse, + Awaitable[security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse] + ]]: + raise NotImplementedError() + + @property + def get_security_health_analytics_custom_module(self) -> Callable[ + [security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest], + Union[ + security_center_management.SecurityHealthAnalyticsCustomModule, + Awaitable[security_center_management.SecurityHealthAnalyticsCustomModule] + ]]: + raise NotImplementedError() + + @property + def create_security_health_analytics_custom_module(self) -> Callable[ + [security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest], + Union[ + security_center_management.SecurityHealthAnalyticsCustomModule, + Awaitable[security_center_management.SecurityHealthAnalyticsCustomModule] + ]]: + raise NotImplementedError() + + @property + def update_security_health_analytics_custom_module(self) -> Callable[ + [security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest], + Union[ + security_center_management.SecurityHealthAnalyticsCustomModule, + Awaitable[security_center_management.SecurityHealthAnalyticsCustomModule] + ]]: + raise NotImplementedError() + + @property + def delete_security_health_analytics_custom_module(self) -> Callable[ + [security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest], + Union[ + empty_pb2.Empty, + Awaitable[empty_pb2.Empty] + ]]: + raise NotImplementedError() + + @property + def simulate_security_health_analytics_custom_module(self) -> Callable[ + [security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest], + Union[ + security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse, + Awaitable[security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse] + ]]: + raise NotImplementedError() + + @property + def list_effective_event_threat_detection_custom_modules(self) -> Callable[ + [security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest], + Union[ + security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse, + Awaitable[security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse] + ]]: + raise NotImplementedError() + + @property + def get_effective_event_threat_detection_custom_module(self) -> Callable[ + [security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest], + Union[ + security_center_management.EffectiveEventThreatDetectionCustomModule, + Awaitable[security_center_management.EffectiveEventThreatDetectionCustomModule] + ]]: + raise NotImplementedError() + + @property + def list_event_threat_detection_custom_modules(self) -> Callable[ + [security_center_management.ListEventThreatDetectionCustomModulesRequest], + Union[ + security_center_management.ListEventThreatDetectionCustomModulesResponse, + Awaitable[security_center_management.ListEventThreatDetectionCustomModulesResponse] + ]]: + raise NotImplementedError() + + @property + def list_descendant_event_threat_detection_custom_modules(self) -> Callable[ + [security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest], + Union[ + security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse, + Awaitable[security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse] + ]]: + raise NotImplementedError() + + @property + def get_event_threat_detection_custom_module(self) -> Callable[ + [security_center_management.GetEventThreatDetectionCustomModuleRequest], + Union[ + security_center_management.EventThreatDetectionCustomModule, + Awaitable[security_center_management.EventThreatDetectionCustomModule] + ]]: + raise NotImplementedError() + + @property + def create_event_threat_detection_custom_module(self) -> Callable[ + [security_center_management.CreateEventThreatDetectionCustomModuleRequest], + Union[ + security_center_management.EventThreatDetectionCustomModule, + Awaitable[security_center_management.EventThreatDetectionCustomModule] + ]]: + raise NotImplementedError() + + @property + def update_event_threat_detection_custom_module(self) -> Callable[ + [security_center_management.UpdateEventThreatDetectionCustomModuleRequest], + Union[ + security_center_management.EventThreatDetectionCustomModule, + Awaitable[security_center_management.EventThreatDetectionCustomModule] + ]]: + raise NotImplementedError() + + @property + def delete_event_threat_detection_custom_module(self) -> Callable[ + [security_center_management.DeleteEventThreatDetectionCustomModuleRequest], + Union[ + empty_pb2.Empty, + Awaitable[empty_pb2.Empty] + ]]: + raise NotImplementedError() + + @property + def validate_event_threat_detection_custom_module(self) -> Callable[ + [security_center_management.ValidateEventThreatDetectionCustomModuleRequest], + Union[ + security_center_management.ValidateEventThreatDetectionCustomModuleResponse, + Awaitable[security_center_management.ValidateEventThreatDetectionCustomModuleResponse] + ]]: + raise NotImplementedError() + + @property + def get_location(self, + ) -> Callable[ + [locations_pb2.GetLocationRequest], + Union[locations_pb2.Location, Awaitable[locations_pb2.Location]], + ]: + raise NotImplementedError() + + @property + def list_locations(self, + ) -> Callable[ + [locations_pb2.ListLocationsRequest], + Union[locations_pb2.ListLocationsResponse, Awaitable[locations_pb2.ListLocationsResponse]], + ]: + raise NotImplementedError() + + @property + def kind(self) -> str: + raise NotImplementedError() + + +__all__ = ( + 'SecurityCenterManagementTransport', +) diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/grpc.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/grpc.py new file mode 100644 index 000000000000..31d6cc96af89 --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/grpc.py @@ -0,0 +1,818 @@ +# -*- 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. +# +import warnings +from typing import Callable, Dict, Optional, Sequence, Tuple, Union + +from google.api_core import grpc_helpers +from google.api_core import gapic_v1 +import google.auth # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore + +import grpc # type: ignore + +from google.cloud.location import locations_pb2 # type: ignore +from google.cloud.securitycentermanagement_v1.types import security_center_management +from google.protobuf import empty_pb2 # type: ignore +from .base import SecurityCenterManagementTransport, DEFAULT_CLIENT_INFO + + +class SecurityCenterManagementGrpcTransport(SecurityCenterManagementTransport): + """gRPC backend transport for SecurityCenterManagement. + + Service describing handlers for resources + + This class defines the same methods as the primary client, so the + primary client can load the underlying transport implementation + and call it. + + It sends protocol buffers over the wire using gRPC (which is built on + top of HTTP/2); the ``grpcio`` package must be installed. + """ + _stubs: Dict[str, Callable] + + def __init__(self, *, + host: str = 'securitycentermanagement.googleapis.com', + credentials: Optional[ga_credentials.Credentials] = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + channel: Optional[grpc.Channel] = None, + api_mtls_endpoint: Optional[str] = None, + client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None, + ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None, + client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None, + quota_project_id: Optional[str] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + always_use_jwt_access: Optional[bool] = False, + api_audience: Optional[str] = None, + ) -> None: + """Instantiate the transport. + + Args: + host (Optional[str]): + The hostname to connect to. + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + This argument is ignored if ``channel`` is provided. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is ignored if ``channel`` is provided. + scopes (Optional(Sequence[str])): A list of scopes. This argument is + ignored if ``channel`` is provided. + channel (Optional[grpc.Channel]): A ``Channel`` instance through + which to make calls. + api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. + If provided, it overrides the ``host`` argument and tries to create + a mutual TLS channel with client SSL credentials from + ``client_cert_source`` or application default SSL credentials. + client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): + Deprecated. A callback to provide client SSL certificate bytes and + private key bytes, both in PEM format. It is ignored if + ``api_mtls_endpoint`` is None. + ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials + for the grpc channel. It is ignored if ``channel`` is provided. + client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): + A callback to provide client certificate bytes and private key bytes, + both in PEM format. It is used to configure a mutual TLS channel. It is + ignored if ``channel`` or ``ssl_channel_credentials`` is provided. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing + your own client library. + always_use_jwt_access (Optional[bool]): Whether self signed JWT should + be used for service account credentials. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport + creation failed for any reason. + google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` + and ``credentials_file`` are passed. + """ + self._grpc_channel = None + self._ssl_channel_credentials = ssl_channel_credentials + self._stubs: Dict[str, Callable] = {} + + if api_mtls_endpoint: + warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) + if client_cert_source: + warnings.warn("client_cert_source is deprecated", DeprecationWarning) + + if channel: + # Ignore credentials if a channel was passed. + credentials = False + # If a channel was explicitly provided, set it. + self._grpc_channel = channel + self._ssl_channel_credentials = None + + else: + if api_mtls_endpoint: + host = api_mtls_endpoint + + # Create SSL credentials with client_cert_source or application + # default SSL credentials. + if client_cert_source: + cert, key = client_cert_source() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + else: + self._ssl_channel_credentials = SslCredentials().ssl_credentials + + else: + if client_cert_source_for_mtls and not ssl_channel_credentials: + cert, key = client_cert_source_for_mtls() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + + # The base transport sets the host, credentials and scopes + super().__init__( + host=host, + credentials=credentials, + credentials_file=credentials_file, + scopes=scopes, + quota_project_id=quota_project_id, + client_info=client_info, + always_use_jwt_access=always_use_jwt_access, + api_audience=api_audience, + ) + + if not self._grpc_channel: + self._grpc_channel = type(self).create_channel( + self._host, + # use the credentials which are saved + credentials=self._credentials, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, + scopes=self._scopes, + ssl_credentials=self._ssl_channel_credentials, + quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + # Wrap messages. This must be done after self._grpc_channel exists + self._prep_wrapped_messages(client_info) + + @classmethod + def create_channel(cls, + host: str = 'securitycentermanagement.googleapis.com', + credentials: Optional[ga_credentials.Credentials] = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, + **kwargs) -> grpc.Channel: + """Create and return a gRPC channel object. + Args: + host (Optional[str]): The host for the channel to use. + credentials (Optional[~.Credentials]): The + authorization credentials to attach to requests. These + credentials identify this application to the service. If + none are specified, the client will attempt to ascertain + the credentials from the environment. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is mutually exclusive with credentials. + scopes (Optional[Sequence[str]]): A optional list of scopes needed for this + service. These are only used when credentials are not specified and + are passed to :func:`google.auth.default`. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + kwargs (Optional[dict]): Keyword arguments, which are passed to the + channel creation. + Returns: + grpc.Channel: A gRPC channel object. + + Raises: + google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` + and ``credentials_file`` are passed. + """ + + return grpc_helpers.create_channel( + host, + credentials=credentials, + credentials_file=credentials_file, + quota_project_id=quota_project_id, + default_scopes=cls.AUTH_SCOPES, + scopes=scopes, + default_host=cls.DEFAULT_HOST, + **kwargs + ) + + @property + def grpc_channel(self) -> grpc.Channel: + """Return the channel designed to connect to this service. + """ + return self._grpc_channel + + @property + def list_effective_security_health_analytics_custom_modules(self) -> Callable[ + [security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest], + security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse]: + r"""Return a callable for the list effective security health + analytics custom modules method over gRPC. + + Returns a list of all + EffectiveSecurityHealthAnalyticsCustomModules for the + given parent. This includes resident modules defined at + the scope of the parent, and inherited modules, + inherited from CRM ancestors (no descendants). + + Returns: + Callable[[~.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest], + ~.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse]: + 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_effective_security_health_analytics_custom_modules' not in self._stubs: + self._stubs['list_effective_security_health_analytics_custom_modules'] = self.grpc_channel.unary_unary( + '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/ListEffectiveSecurityHealthAnalyticsCustomModules', + request_serializer=security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest.serialize, + response_deserializer=security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse.deserialize, + ) + return self._stubs['list_effective_security_health_analytics_custom_modules'] + + @property + def get_effective_security_health_analytics_custom_module(self) -> Callable[ + [security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest], + security_center_management.EffectiveSecurityHealthAnalyticsCustomModule]: + r"""Return a callable for the get effective security health + analytics custom module method over gRPC. + + Gets details of a single + EffectiveSecurityHealthAnalyticsCustomModule. + + Returns: + Callable[[~.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest], + ~.EffectiveSecurityHealthAnalyticsCustomModule]: + 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_effective_security_health_analytics_custom_module' not in self._stubs: + self._stubs['get_effective_security_health_analytics_custom_module'] = self.grpc_channel.unary_unary( + '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/GetEffectiveSecurityHealthAnalyticsCustomModule', + request_serializer=security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest.serialize, + response_deserializer=security_center_management.EffectiveSecurityHealthAnalyticsCustomModule.deserialize, + ) + return self._stubs['get_effective_security_health_analytics_custom_module'] + + @property + def list_security_health_analytics_custom_modules(self) -> Callable[ + [security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest], + security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse]: + r"""Return a callable for the list security health analytics + custom modules method over gRPC. + + Returns a list of all + SecurityHealthAnalyticsCustomModules for the given + parent. This includes resident modules defined at the + scope of the parent, and inherited modules, inherited + from CRM ancestors (no descendants). + + Returns: + Callable[[~.ListSecurityHealthAnalyticsCustomModulesRequest], + ~.ListSecurityHealthAnalyticsCustomModulesResponse]: + 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_security_health_analytics_custom_modules' not in self._stubs: + self._stubs['list_security_health_analytics_custom_modules'] = self.grpc_channel.unary_unary( + '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/ListSecurityHealthAnalyticsCustomModules', + request_serializer=security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest.serialize, + response_deserializer=security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse.deserialize, + ) + return self._stubs['list_security_health_analytics_custom_modules'] + + @property + def list_descendant_security_health_analytics_custom_modules(self) -> Callable[ + [security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest], + security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse]: + r"""Return a callable for the list descendant security + health analytics custom modules method over gRPC. + + Returns a list of all resident + SecurityHealthAnalyticsCustomModules under the given CRM + parent and all of the parent’s CRM descendants. + + Returns: + Callable[[~.ListDescendantSecurityHealthAnalyticsCustomModulesRequest], + ~.ListDescendantSecurityHealthAnalyticsCustomModulesResponse]: + 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_descendant_security_health_analytics_custom_modules' not in self._stubs: + self._stubs['list_descendant_security_health_analytics_custom_modules'] = self.grpc_channel.unary_unary( + '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/ListDescendantSecurityHealthAnalyticsCustomModules', + request_serializer=security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest.serialize, + response_deserializer=security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse.deserialize, + ) + return self._stubs['list_descendant_security_health_analytics_custom_modules'] + + @property + def get_security_health_analytics_custom_module(self) -> Callable[ + [security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest], + security_center_management.SecurityHealthAnalyticsCustomModule]: + r"""Return a callable for the get security health analytics + custom module method over gRPC. + + Retrieves a SecurityHealthAnalyticsCustomModule. + + Returns: + Callable[[~.GetSecurityHealthAnalyticsCustomModuleRequest], + ~.SecurityHealthAnalyticsCustomModule]: + 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_security_health_analytics_custom_module' not in self._stubs: + self._stubs['get_security_health_analytics_custom_module'] = self.grpc_channel.unary_unary( + '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/GetSecurityHealthAnalyticsCustomModule', + request_serializer=security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest.serialize, + response_deserializer=security_center_management.SecurityHealthAnalyticsCustomModule.deserialize, + ) + return self._stubs['get_security_health_analytics_custom_module'] + + @property + def create_security_health_analytics_custom_module(self) -> Callable[ + [security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest], + security_center_management.SecurityHealthAnalyticsCustomModule]: + r"""Return a callable for the create security health + analytics custom module method over gRPC. + + Creates a resident + SecurityHealthAnalyticsCustomModule at the scope of the + given CRM parent, and also creates inherited + SecurityHealthAnalyticsCustomModules for all CRM + descendants of the given parent. These modules are + enabled by default. + + Returns: + Callable[[~.CreateSecurityHealthAnalyticsCustomModuleRequest], + ~.SecurityHealthAnalyticsCustomModule]: + 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_security_health_analytics_custom_module' not in self._stubs: + self._stubs['create_security_health_analytics_custom_module'] = self.grpc_channel.unary_unary( + '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/CreateSecurityHealthAnalyticsCustomModule', + request_serializer=security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest.serialize, + response_deserializer=security_center_management.SecurityHealthAnalyticsCustomModule.deserialize, + ) + return self._stubs['create_security_health_analytics_custom_module'] + + @property + def update_security_health_analytics_custom_module(self) -> Callable[ + [security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest], + security_center_management.SecurityHealthAnalyticsCustomModule]: + r"""Return a callable for the update security health + analytics custom module method over gRPC. + + Updates the SecurityHealthAnalyticsCustomModule under + the given name based on the given update mask. Updating + the enablement state is supported on both resident and + inherited modules (though resident modules cannot have + an enablement state of "inherited"). Updating the + display name and custom config of a module is supported + on resident modules only. + + Returns: + Callable[[~.UpdateSecurityHealthAnalyticsCustomModuleRequest], + ~.SecurityHealthAnalyticsCustomModule]: + 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_security_health_analytics_custom_module' not in self._stubs: + self._stubs['update_security_health_analytics_custom_module'] = self.grpc_channel.unary_unary( + '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/UpdateSecurityHealthAnalyticsCustomModule', + request_serializer=security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest.serialize, + response_deserializer=security_center_management.SecurityHealthAnalyticsCustomModule.deserialize, + ) + return self._stubs['update_security_health_analytics_custom_module'] + + @property + def delete_security_health_analytics_custom_module(self) -> Callable[ + [security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest], + empty_pb2.Empty]: + r"""Return a callable for the delete security health + analytics custom module method over gRPC. + + Deletes the specified + SecurityHealthAnalyticsCustomModule and all of its + descendants in the CRM hierarchy. This method is only + supported for resident custom modules. + + Returns: + Callable[[~.DeleteSecurityHealthAnalyticsCustomModuleRequest], + ~.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_security_health_analytics_custom_module' not in self._stubs: + self._stubs['delete_security_health_analytics_custom_module'] = self.grpc_channel.unary_unary( + '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/DeleteSecurityHealthAnalyticsCustomModule', + request_serializer=security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs['delete_security_health_analytics_custom_module'] + + @property + def simulate_security_health_analytics_custom_module(self) -> Callable[ + [security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest], + security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse]: + r"""Return a callable for the simulate security health + analytics custom module method over gRPC. + + Simulates a given SecurityHealthAnalyticsCustomModule + and Resource. + + Returns: + Callable[[~.SimulateSecurityHealthAnalyticsCustomModuleRequest], + ~.SimulateSecurityHealthAnalyticsCustomModuleResponse]: + 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 'simulate_security_health_analytics_custom_module' not in self._stubs: + self._stubs['simulate_security_health_analytics_custom_module'] = self.grpc_channel.unary_unary( + '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/SimulateSecurityHealthAnalyticsCustomModule', + request_serializer=security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest.serialize, + response_deserializer=security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse.deserialize, + ) + return self._stubs['simulate_security_health_analytics_custom_module'] + + @property + def list_effective_event_threat_detection_custom_modules(self) -> Callable[ + [security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest], + security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse]: + r"""Return a callable for the list effective event threat + detection custom modules method over gRPC. + + Lists all effective Event Threat Detection custom + modules for the given parent. This includes resident + modules defined at the scope of the parent along with + modules inherited from its ancestors. + + Returns: + Callable[[~.ListEffectiveEventThreatDetectionCustomModulesRequest], + ~.ListEffectiveEventThreatDetectionCustomModulesResponse]: + 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_effective_event_threat_detection_custom_modules' not in self._stubs: + self._stubs['list_effective_event_threat_detection_custom_modules'] = self.grpc_channel.unary_unary( + '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/ListEffectiveEventThreatDetectionCustomModules', + request_serializer=security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest.serialize, + response_deserializer=security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse.deserialize, + ) + return self._stubs['list_effective_event_threat_detection_custom_modules'] + + @property + def get_effective_event_threat_detection_custom_module(self) -> Callable[ + [security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest], + security_center_management.EffectiveEventThreatDetectionCustomModule]: + r"""Return a callable for the get effective event threat + detection custom module method over gRPC. + + Gets an effective ETD custom module. Retrieves the effective + module at the given level. The difference between an + EffectiveCustomModule and a CustomModule is that the fields for + an EffectiveCustomModule are computed from ancestors if needed. + For example, the enablement_state for a CustomModule can be + either ENABLED, DISABLED, or INHERITED. Where as the + enablement_state for an EffectiveCustomModule is always computed + to ENABLED or DISABLED (the effective enablement_state). + + Returns: + Callable[[~.GetEffectiveEventThreatDetectionCustomModuleRequest], + ~.EffectiveEventThreatDetectionCustomModule]: + 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_effective_event_threat_detection_custom_module' not in self._stubs: + self._stubs['get_effective_event_threat_detection_custom_module'] = self.grpc_channel.unary_unary( + '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/GetEffectiveEventThreatDetectionCustomModule', + request_serializer=security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest.serialize, + response_deserializer=security_center_management.EffectiveEventThreatDetectionCustomModule.deserialize, + ) + return self._stubs['get_effective_event_threat_detection_custom_module'] + + @property + def list_event_threat_detection_custom_modules(self) -> Callable[ + [security_center_management.ListEventThreatDetectionCustomModulesRequest], + security_center_management.ListEventThreatDetectionCustomModulesResponse]: + r"""Return a callable for the list event threat detection + custom modules method over gRPC. + + Lists all Event Threat Detection custom modules for + the given Resource Manager parent. This includes + resident modules defined at the scope of the parent + along with modules inherited from ancestors. + + Returns: + Callable[[~.ListEventThreatDetectionCustomModulesRequest], + ~.ListEventThreatDetectionCustomModulesResponse]: + 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_event_threat_detection_custom_modules' not in self._stubs: + self._stubs['list_event_threat_detection_custom_modules'] = self.grpc_channel.unary_unary( + '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/ListEventThreatDetectionCustomModules', + request_serializer=security_center_management.ListEventThreatDetectionCustomModulesRequest.serialize, + response_deserializer=security_center_management.ListEventThreatDetectionCustomModulesResponse.deserialize, + ) + return self._stubs['list_event_threat_detection_custom_modules'] + + @property + def list_descendant_event_threat_detection_custom_modules(self) -> Callable[ + [security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest], + security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse]: + r"""Return a callable for the list descendant event threat + detection custom modules method over gRPC. + + Lists all resident Event Threat Detection custom + modules under the given Resource Manager parent and its + descendants. + + Returns: + Callable[[~.ListDescendantEventThreatDetectionCustomModulesRequest], + ~.ListDescendantEventThreatDetectionCustomModulesResponse]: + 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_descendant_event_threat_detection_custom_modules' not in self._stubs: + self._stubs['list_descendant_event_threat_detection_custom_modules'] = self.grpc_channel.unary_unary( + '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/ListDescendantEventThreatDetectionCustomModules', + request_serializer=security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest.serialize, + response_deserializer=security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse.deserialize, + ) + return self._stubs['list_descendant_event_threat_detection_custom_modules'] + + @property + def get_event_threat_detection_custom_module(self) -> Callable[ + [security_center_management.GetEventThreatDetectionCustomModuleRequest], + security_center_management.EventThreatDetectionCustomModule]: + r"""Return a callable for the get event threat detection + custom module method over gRPC. + + Gets an Event Threat Detection custom module. + + Returns: + Callable[[~.GetEventThreatDetectionCustomModuleRequest], + ~.EventThreatDetectionCustomModule]: + 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_event_threat_detection_custom_module' not in self._stubs: + self._stubs['get_event_threat_detection_custom_module'] = self.grpc_channel.unary_unary( + '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/GetEventThreatDetectionCustomModule', + request_serializer=security_center_management.GetEventThreatDetectionCustomModuleRequest.serialize, + response_deserializer=security_center_management.EventThreatDetectionCustomModule.deserialize, + ) + return self._stubs['get_event_threat_detection_custom_module'] + + @property + def create_event_threat_detection_custom_module(self) -> Callable[ + [security_center_management.CreateEventThreatDetectionCustomModuleRequest], + security_center_management.EventThreatDetectionCustomModule]: + r"""Return a callable for the create event threat detection + custom module method over gRPC. + + Creates a resident Event Threat Detection custom + module at the scope of the given Resource Manager + parent, and also creates inherited custom modules for + all descendants of the given parent. These modules are + enabled by default. + + Returns: + Callable[[~.CreateEventThreatDetectionCustomModuleRequest], + ~.EventThreatDetectionCustomModule]: + 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_event_threat_detection_custom_module' not in self._stubs: + self._stubs['create_event_threat_detection_custom_module'] = self.grpc_channel.unary_unary( + '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/CreateEventThreatDetectionCustomModule', + request_serializer=security_center_management.CreateEventThreatDetectionCustomModuleRequest.serialize, + response_deserializer=security_center_management.EventThreatDetectionCustomModule.deserialize, + ) + return self._stubs['create_event_threat_detection_custom_module'] + + @property + def update_event_threat_detection_custom_module(self) -> Callable[ + [security_center_management.UpdateEventThreatDetectionCustomModuleRequest], + security_center_management.EventThreatDetectionCustomModule]: + r"""Return a callable for the update event threat detection + custom module method over gRPC. + + Updates the Event Threat Detection custom module with + the given name based on the given update mask. Updating + the enablement state is supported for both resident and + inherited modules (though resident modules cannot have + an enablement state of "inherited"). Updating the + display name or configuration of a module is supported + for resident modules only. The type of a module cannot + be changed. + + Returns: + Callable[[~.UpdateEventThreatDetectionCustomModuleRequest], + ~.EventThreatDetectionCustomModule]: + 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_event_threat_detection_custom_module' not in self._stubs: + self._stubs['update_event_threat_detection_custom_module'] = self.grpc_channel.unary_unary( + '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/UpdateEventThreatDetectionCustomModule', + request_serializer=security_center_management.UpdateEventThreatDetectionCustomModuleRequest.serialize, + response_deserializer=security_center_management.EventThreatDetectionCustomModule.deserialize, + ) + return self._stubs['update_event_threat_detection_custom_module'] + + @property + def delete_event_threat_detection_custom_module(self) -> Callable[ + [security_center_management.DeleteEventThreatDetectionCustomModuleRequest], + empty_pb2.Empty]: + r"""Return a callable for the delete event threat detection + custom module method over gRPC. + + Deletes the specified Event Threat Detection custom + module and all of its descendants in the Resource + Manager hierarchy. This method is only supported for + resident custom modules. + + Returns: + Callable[[~.DeleteEventThreatDetectionCustomModuleRequest], + ~.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_event_threat_detection_custom_module' not in self._stubs: + self._stubs['delete_event_threat_detection_custom_module'] = self.grpc_channel.unary_unary( + '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/DeleteEventThreatDetectionCustomModule', + request_serializer=security_center_management.DeleteEventThreatDetectionCustomModuleRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs['delete_event_threat_detection_custom_module'] + + @property + def validate_event_threat_detection_custom_module(self) -> Callable[ + [security_center_management.ValidateEventThreatDetectionCustomModuleRequest], + security_center_management.ValidateEventThreatDetectionCustomModuleResponse]: + r"""Return a callable for the validate event threat + detection custom module method over gRPC. + + Validates the given Event Threat Detection custom + module. + + Returns: + Callable[[~.ValidateEventThreatDetectionCustomModuleRequest], + ~.ValidateEventThreatDetectionCustomModuleResponse]: + 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 'validate_event_threat_detection_custom_module' not in self._stubs: + self._stubs['validate_event_threat_detection_custom_module'] = self.grpc_channel.unary_unary( + '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/ValidateEventThreatDetectionCustomModule', + request_serializer=security_center_management.ValidateEventThreatDetectionCustomModuleRequest.serialize, + response_deserializer=security_center_management.ValidateEventThreatDetectionCustomModuleResponse.deserialize, + ) + return self._stubs['validate_event_threat_detection_custom_module'] + + def close(self): + self.grpc_channel.close() + + @property + def list_locations( + self, + ) -> Callable[[locations_pb2.ListLocationsRequest], locations_pb2.ListLocationsResponse]: + r"""Return a callable for the list locations method over gRPC. + """ + # 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_locations" not in self._stubs: + self._stubs["list_locations"] = self.grpc_channel.unary_unary( + "/google.cloud.location.Locations/ListLocations", + request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, + response_deserializer=locations_pb2.ListLocationsResponse.FromString, + ) + return self._stubs["list_locations"] + + @property + def get_location( + self, + ) -> Callable[[locations_pb2.GetLocationRequest], locations_pb2.Location]: + r"""Return a callable for the list locations method over gRPC. + """ + # 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_location" not in self._stubs: + self._stubs["get_location"] = self.grpc_channel.unary_unary( + "/google.cloud.location.Locations/GetLocation", + request_serializer=locations_pb2.GetLocationRequest.SerializeToString, + response_deserializer=locations_pb2.Location.FromString, + ) + return self._stubs["get_location"] + + @property + def kind(self) -> str: + return "grpc" + + +__all__ = ( + 'SecurityCenterManagementGrpcTransport', +) diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/grpc_asyncio.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/grpc_asyncio.py new file mode 100644 index 000000000000..02d66be5c1a3 --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/grpc_asyncio.py @@ -0,0 +1,817 @@ +# -*- 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. +# +import warnings +from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union + +from google.api_core import gapic_v1 +from google.api_core import grpc_helpers_async +from google.auth import credentials as ga_credentials # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore + +import grpc # type: ignore +from grpc.experimental import aio # type: ignore + +from google.cloud.location import locations_pb2 # type: ignore +from google.cloud.securitycentermanagement_v1.types import security_center_management +from google.protobuf import empty_pb2 # type: ignore +from .base import SecurityCenterManagementTransport, DEFAULT_CLIENT_INFO +from .grpc import SecurityCenterManagementGrpcTransport + + +class SecurityCenterManagementGrpcAsyncIOTransport(SecurityCenterManagementTransport): + """gRPC AsyncIO backend transport for SecurityCenterManagement. + + Service describing handlers for resources + + This class defines the same methods as the primary client, so the + primary client can load the underlying transport implementation + and call it. + + It sends protocol buffers over the wire using gRPC (which is built on + top of HTTP/2); the ``grpcio`` package must be installed. + """ + + _grpc_channel: aio.Channel + _stubs: Dict[str, Callable] = {} + + @classmethod + def create_channel(cls, + host: str = 'securitycentermanagement.googleapis.com', + credentials: Optional[ga_credentials.Credentials] = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, + **kwargs) -> aio.Channel: + """Create and return a gRPC AsyncIO channel object. + Args: + host (Optional[str]): The host for the channel to use. + credentials (Optional[~.Credentials]): The + authorization credentials to attach to requests. These + credentials identify this application to the service. If + none are specified, the client will attempt to ascertain + the credentials from the environment. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is ignored if ``channel`` is provided. + scopes (Optional[Sequence[str]]): A optional list of scopes needed for this + service. These are only used when credentials are not specified and + are passed to :func:`google.auth.default`. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + kwargs (Optional[dict]): Keyword arguments, which are passed to the + channel creation. + Returns: + aio.Channel: A gRPC AsyncIO channel object. + """ + + return grpc_helpers_async.create_channel( + host, + credentials=credentials, + credentials_file=credentials_file, + quota_project_id=quota_project_id, + default_scopes=cls.AUTH_SCOPES, + scopes=scopes, + default_host=cls.DEFAULT_HOST, + **kwargs + ) + + def __init__(self, *, + host: str = 'securitycentermanagement.googleapis.com', + credentials: Optional[ga_credentials.Credentials] = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + channel: Optional[aio.Channel] = None, + api_mtls_endpoint: Optional[str] = None, + client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None, + ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None, + client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None, + quota_project_id: Optional[str] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + always_use_jwt_access: Optional[bool] = False, + api_audience: Optional[str] = None, + ) -> None: + """Instantiate the transport. + + Args: + host (Optional[str]): + The hostname to connect to. + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + This argument is ignored if ``channel`` is provided. + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is ignored if ``channel`` is provided. + scopes (Optional[Sequence[str]]): A optional list of scopes needed for this + service. These are only used when credentials are not specified and + are passed to :func:`google.auth.default`. + channel (Optional[aio.Channel]): A ``Channel`` instance through + which to make calls. + api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. + If provided, it overrides the ``host`` argument and tries to create + a mutual TLS channel with client SSL credentials from + ``client_cert_source`` or application default SSL credentials. + client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): + Deprecated. A callback to provide client SSL certificate bytes and + private key bytes, both in PEM format. It is ignored if + ``api_mtls_endpoint`` is None. + ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials + for the grpc channel. It is ignored if ``channel`` is provided. + client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): + A callback to provide client certificate bytes and private key bytes, + both in PEM format. It is used to configure a mutual TLS channel. It is + ignored if ``channel`` or ``ssl_channel_credentials`` is provided. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing + your own client library. + always_use_jwt_access (Optional[bool]): Whether self signed JWT should + be used for service account credentials. + + Raises: + google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport + creation failed for any reason. + google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` + and ``credentials_file`` are passed. + """ + self._grpc_channel = None + self._ssl_channel_credentials = ssl_channel_credentials + self._stubs: Dict[str, Callable] = {} + + if api_mtls_endpoint: + warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) + if client_cert_source: + warnings.warn("client_cert_source is deprecated", DeprecationWarning) + + if channel: + # Ignore credentials if a channel was passed. + credentials = False + # If a channel was explicitly provided, set it. + self._grpc_channel = channel + self._ssl_channel_credentials = None + else: + if api_mtls_endpoint: + host = api_mtls_endpoint + + # Create SSL credentials with client_cert_source or application + # default SSL credentials. + if client_cert_source: + cert, key = client_cert_source() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + else: + self._ssl_channel_credentials = SslCredentials().ssl_credentials + + else: + if client_cert_source_for_mtls and not ssl_channel_credentials: + cert, key = client_cert_source_for_mtls() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + + # The base transport sets the host, credentials and scopes + super().__init__( + host=host, + credentials=credentials, + credentials_file=credentials_file, + scopes=scopes, + quota_project_id=quota_project_id, + client_info=client_info, + always_use_jwt_access=always_use_jwt_access, + api_audience=api_audience, + ) + + if not self._grpc_channel: + self._grpc_channel = type(self).create_channel( + self._host, + # use the credentials which are saved + credentials=self._credentials, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, + scopes=self._scopes, + ssl_credentials=self._ssl_channel_credentials, + quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + # Wrap messages. This must be done after self._grpc_channel exists + self._prep_wrapped_messages(client_info) + + @property + def grpc_channel(self) -> aio.Channel: + """Create the channel designed to connect to this service. + + This property caches on the instance; repeated calls return + the same channel. + """ + # Return the channel from cache. + return self._grpc_channel + + @property + def list_effective_security_health_analytics_custom_modules(self) -> Callable[ + [security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest], + Awaitable[security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse]]: + r"""Return a callable for the list effective security health + analytics custom modules method over gRPC. + + Returns a list of all + EffectiveSecurityHealthAnalyticsCustomModules for the + given parent. This includes resident modules defined at + the scope of the parent, and inherited modules, + inherited from CRM ancestors (no descendants). + + Returns: + Callable[[~.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest], + Awaitable[~.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse]]: + 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_effective_security_health_analytics_custom_modules' not in self._stubs: + self._stubs['list_effective_security_health_analytics_custom_modules'] = self.grpc_channel.unary_unary( + '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/ListEffectiveSecurityHealthAnalyticsCustomModules', + request_serializer=security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest.serialize, + response_deserializer=security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse.deserialize, + ) + return self._stubs['list_effective_security_health_analytics_custom_modules'] + + @property + def get_effective_security_health_analytics_custom_module(self) -> Callable[ + [security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest], + Awaitable[security_center_management.EffectiveSecurityHealthAnalyticsCustomModule]]: + r"""Return a callable for the get effective security health + analytics custom module method over gRPC. + + Gets details of a single + EffectiveSecurityHealthAnalyticsCustomModule. + + Returns: + Callable[[~.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest], + Awaitable[~.EffectiveSecurityHealthAnalyticsCustomModule]]: + 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_effective_security_health_analytics_custom_module' not in self._stubs: + self._stubs['get_effective_security_health_analytics_custom_module'] = self.grpc_channel.unary_unary( + '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/GetEffectiveSecurityHealthAnalyticsCustomModule', + request_serializer=security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest.serialize, + response_deserializer=security_center_management.EffectiveSecurityHealthAnalyticsCustomModule.deserialize, + ) + return self._stubs['get_effective_security_health_analytics_custom_module'] + + @property + def list_security_health_analytics_custom_modules(self) -> Callable[ + [security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest], + Awaitable[security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse]]: + r"""Return a callable for the list security health analytics + custom modules method over gRPC. + + Returns a list of all + SecurityHealthAnalyticsCustomModules for the given + parent. This includes resident modules defined at the + scope of the parent, and inherited modules, inherited + from CRM ancestors (no descendants). + + Returns: + Callable[[~.ListSecurityHealthAnalyticsCustomModulesRequest], + Awaitable[~.ListSecurityHealthAnalyticsCustomModulesResponse]]: + 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_security_health_analytics_custom_modules' not in self._stubs: + self._stubs['list_security_health_analytics_custom_modules'] = self.grpc_channel.unary_unary( + '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/ListSecurityHealthAnalyticsCustomModules', + request_serializer=security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest.serialize, + response_deserializer=security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse.deserialize, + ) + return self._stubs['list_security_health_analytics_custom_modules'] + + @property + def list_descendant_security_health_analytics_custom_modules(self) -> Callable[ + [security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest], + Awaitable[security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse]]: + r"""Return a callable for the list descendant security + health analytics custom modules method over gRPC. + + Returns a list of all resident + SecurityHealthAnalyticsCustomModules under the given CRM + parent and all of the parent’s CRM descendants. + + Returns: + Callable[[~.ListDescendantSecurityHealthAnalyticsCustomModulesRequest], + Awaitable[~.ListDescendantSecurityHealthAnalyticsCustomModulesResponse]]: + 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_descendant_security_health_analytics_custom_modules' not in self._stubs: + self._stubs['list_descendant_security_health_analytics_custom_modules'] = self.grpc_channel.unary_unary( + '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/ListDescendantSecurityHealthAnalyticsCustomModules', + request_serializer=security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest.serialize, + response_deserializer=security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse.deserialize, + ) + return self._stubs['list_descendant_security_health_analytics_custom_modules'] + + @property + def get_security_health_analytics_custom_module(self) -> Callable[ + [security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest], + Awaitable[security_center_management.SecurityHealthAnalyticsCustomModule]]: + r"""Return a callable for the get security health analytics + custom module method over gRPC. + + Retrieves a SecurityHealthAnalyticsCustomModule. + + Returns: + Callable[[~.GetSecurityHealthAnalyticsCustomModuleRequest], + Awaitable[~.SecurityHealthAnalyticsCustomModule]]: + 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_security_health_analytics_custom_module' not in self._stubs: + self._stubs['get_security_health_analytics_custom_module'] = self.grpc_channel.unary_unary( + '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/GetSecurityHealthAnalyticsCustomModule', + request_serializer=security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest.serialize, + response_deserializer=security_center_management.SecurityHealthAnalyticsCustomModule.deserialize, + ) + return self._stubs['get_security_health_analytics_custom_module'] + + @property + def create_security_health_analytics_custom_module(self) -> Callable[ + [security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest], + Awaitable[security_center_management.SecurityHealthAnalyticsCustomModule]]: + r"""Return a callable for the create security health + analytics custom module method over gRPC. + + Creates a resident + SecurityHealthAnalyticsCustomModule at the scope of the + given CRM parent, and also creates inherited + SecurityHealthAnalyticsCustomModules for all CRM + descendants of the given parent. These modules are + enabled by default. + + Returns: + Callable[[~.CreateSecurityHealthAnalyticsCustomModuleRequest], + Awaitable[~.SecurityHealthAnalyticsCustomModule]]: + 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_security_health_analytics_custom_module' not in self._stubs: + self._stubs['create_security_health_analytics_custom_module'] = self.grpc_channel.unary_unary( + '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/CreateSecurityHealthAnalyticsCustomModule', + request_serializer=security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest.serialize, + response_deserializer=security_center_management.SecurityHealthAnalyticsCustomModule.deserialize, + ) + return self._stubs['create_security_health_analytics_custom_module'] + + @property + def update_security_health_analytics_custom_module(self) -> Callable[ + [security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest], + Awaitable[security_center_management.SecurityHealthAnalyticsCustomModule]]: + r"""Return a callable for the update security health + analytics custom module method over gRPC. + + Updates the SecurityHealthAnalyticsCustomModule under + the given name based on the given update mask. Updating + the enablement state is supported on both resident and + inherited modules (though resident modules cannot have + an enablement state of "inherited"). Updating the + display name and custom config of a module is supported + on resident modules only. + + Returns: + Callable[[~.UpdateSecurityHealthAnalyticsCustomModuleRequest], + Awaitable[~.SecurityHealthAnalyticsCustomModule]]: + 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_security_health_analytics_custom_module' not in self._stubs: + self._stubs['update_security_health_analytics_custom_module'] = self.grpc_channel.unary_unary( + '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/UpdateSecurityHealthAnalyticsCustomModule', + request_serializer=security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest.serialize, + response_deserializer=security_center_management.SecurityHealthAnalyticsCustomModule.deserialize, + ) + return self._stubs['update_security_health_analytics_custom_module'] + + @property + def delete_security_health_analytics_custom_module(self) -> Callable[ + [security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest], + Awaitable[empty_pb2.Empty]]: + r"""Return a callable for the delete security health + analytics custom module method over gRPC. + + Deletes the specified + SecurityHealthAnalyticsCustomModule and all of its + descendants in the CRM hierarchy. This method is only + supported for resident custom modules. + + Returns: + Callable[[~.DeleteSecurityHealthAnalyticsCustomModuleRequest], + 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_security_health_analytics_custom_module' not in self._stubs: + self._stubs['delete_security_health_analytics_custom_module'] = self.grpc_channel.unary_unary( + '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/DeleteSecurityHealthAnalyticsCustomModule', + request_serializer=security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs['delete_security_health_analytics_custom_module'] + + @property + def simulate_security_health_analytics_custom_module(self) -> Callable[ + [security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest], + Awaitable[security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse]]: + r"""Return a callable for the simulate security health + analytics custom module method over gRPC. + + Simulates a given SecurityHealthAnalyticsCustomModule + and Resource. + + Returns: + Callable[[~.SimulateSecurityHealthAnalyticsCustomModuleRequest], + Awaitable[~.SimulateSecurityHealthAnalyticsCustomModuleResponse]]: + 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 'simulate_security_health_analytics_custom_module' not in self._stubs: + self._stubs['simulate_security_health_analytics_custom_module'] = self.grpc_channel.unary_unary( + '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/SimulateSecurityHealthAnalyticsCustomModule', + request_serializer=security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest.serialize, + response_deserializer=security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse.deserialize, + ) + return self._stubs['simulate_security_health_analytics_custom_module'] + + @property + def list_effective_event_threat_detection_custom_modules(self) -> Callable[ + [security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest], + Awaitable[security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse]]: + r"""Return a callable for the list effective event threat + detection custom modules method over gRPC. + + Lists all effective Event Threat Detection custom + modules for the given parent. This includes resident + modules defined at the scope of the parent along with + modules inherited from its ancestors. + + Returns: + Callable[[~.ListEffectiveEventThreatDetectionCustomModulesRequest], + Awaitable[~.ListEffectiveEventThreatDetectionCustomModulesResponse]]: + 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_effective_event_threat_detection_custom_modules' not in self._stubs: + self._stubs['list_effective_event_threat_detection_custom_modules'] = self.grpc_channel.unary_unary( + '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/ListEffectiveEventThreatDetectionCustomModules', + request_serializer=security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest.serialize, + response_deserializer=security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse.deserialize, + ) + return self._stubs['list_effective_event_threat_detection_custom_modules'] + + @property + def get_effective_event_threat_detection_custom_module(self) -> Callable[ + [security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest], + Awaitable[security_center_management.EffectiveEventThreatDetectionCustomModule]]: + r"""Return a callable for the get effective event threat + detection custom module method over gRPC. + + Gets an effective ETD custom module. Retrieves the effective + module at the given level. The difference between an + EffectiveCustomModule and a CustomModule is that the fields for + an EffectiveCustomModule are computed from ancestors if needed. + For example, the enablement_state for a CustomModule can be + either ENABLED, DISABLED, or INHERITED. Where as the + enablement_state for an EffectiveCustomModule is always computed + to ENABLED or DISABLED (the effective enablement_state). + + Returns: + Callable[[~.GetEffectiveEventThreatDetectionCustomModuleRequest], + Awaitable[~.EffectiveEventThreatDetectionCustomModule]]: + 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_effective_event_threat_detection_custom_module' not in self._stubs: + self._stubs['get_effective_event_threat_detection_custom_module'] = self.grpc_channel.unary_unary( + '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/GetEffectiveEventThreatDetectionCustomModule', + request_serializer=security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest.serialize, + response_deserializer=security_center_management.EffectiveEventThreatDetectionCustomModule.deserialize, + ) + return self._stubs['get_effective_event_threat_detection_custom_module'] + + @property + def list_event_threat_detection_custom_modules(self) -> Callable[ + [security_center_management.ListEventThreatDetectionCustomModulesRequest], + Awaitable[security_center_management.ListEventThreatDetectionCustomModulesResponse]]: + r"""Return a callable for the list event threat detection + custom modules method over gRPC. + + Lists all Event Threat Detection custom modules for + the given Resource Manager parent. This includes + resident modules defined at the scope of the parent + along with modules inherited from ancestors. + + Returns: + Callable[[~.ListEventThreatDetectionCustomModulesRequest], + Awaitable[~.ListEventThreatDetectionCustomModulesResponse]]: + 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_event_threat_detection_custom_modules' not in self._stubs: + self._stubs['list_event_threat_detection_custom_modules'] = self.grpc_channel.unary_unary( + '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/ListEventThreatDetectionCustomModules', + request_serializer=security_center_management.ListEventThreatDetectionCustomModulesRequest.serialize, + response_deserializer=security_center_management.ListEventThreatDetectionCustomModulesResponse.deserialize, + ) + return self._stubs['list_event_threat_detection_custom_modules'] + + @property + def list_descendant_event_threat_detection_custom_modules(self) -> Callable[ + [security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest], + Awaitable[security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse]]: + r"""Return a callable for the list descendant event threat + detection custom modules method over gRPC. + + Lists all resident Event Threat Detection custom + modules under the given Resource Manager parent and its + descendants. + + Returns: + Callable[[~.ListDescendantEventThreatDetectionCustomModulesRequest], + Awaitable[~.ListDescendantEventThreatDetectionCustomModulesResponse]]: + 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_descendant_event_threat_detection_custom_modules' not in self._stubs: + self._stubs['list_descendant_event_threat_detection_custom_modules'] = self.grpc_channel.unary_unary( + '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/ListDescendantEventThreatDetectionCustomModules', + request_serializer=security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest.serialize, + response_deserializer=security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse.deserialize, + ) + return self._stubs['list_descendant_event_threat_detection_custom_modules'] + + @property + def get_event_threat_detection_custom_module(self) -> Callable[ + [security_center_management.GetEventThreatDetectionCustomModuleRequest], + Awaitable[security_center_management.EventThreatDetectionCustomModule]]: + r"""Return a callable for the get event threat detection + custom module method over gRPC. + + Gets an Event Threat Detection custom module. + + Returns: + Callable[[~.GetEventThreatDetectionCustomModuleRequest], + Awaitable[~.EventThreatDetectionCustomModule]]: + 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_event_threat_detection_custom_module' not in self._stubs: + self._stubs['get_event_threat_detection_custom_module'] = self.grpc_channel.unary_unary( + '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/GetEventThreatDetectionCustomModule', + request_serializer=security_center_management.GetEventThreatDetectionCustomModuleRequest.serialize, + response_deserializer=security_center_management.EventThreatDetectionCustomModule.deserialize, + ) + return self._stubs['get_event_threat_detection_custom_module'] + + @property + def create_event_threat_detection_custom_module(self) -> Callable[ + [security_center_management.CreateEventThreatDetectionCustomModuleRequest], + Awaitable[security_center_management.EventThreatDetectionCustomModule]]: + r"""Return a callable for the create event threat detection + custom module method over gRPC. + + Creates a resident Event Threat Detection custom + module at the scope of the given Resource Manager + parent, and also creates inherited custom modules for + all descendants of the given parent. These modules are + enabled by default. + + Returns: + Callable[[~.CreateEventThreatDetectionCustomModuleRequest], + Awaitable[~.EventThreatDetectionCustomModule]]: + 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_event_threat_detection_custom_module' not in self._stubs: + self._stubs['create_event_threat_detection_custom_module'] = self.grpc_channel.unary_unary( + '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/CreateEventThreatDetectionCustomModule', + request_serializer=security_center_management.CreateEventThreatDetectionCustomModuleRequest.serialize, + response_deserializer=security_center_management.EventThreatDetectionCustomModule.deserialize, + ) + return self._stubs['create_event_threat_detection_custom_module'] + + @property + def update_event_threat_detection_custom_module(self) -> Callable[ + [security_center_management.UpdateEventThreatDetectionCustomModuleRequest], + Awaitable[security_center_management.EventThreatDetectionCustomModule]]: + r"""Return a callable for the update event threat detection + custom module method over gRPC. + + Updates the Event Threat Detection custom module with + the given name based on the given update mask. Updating + the enablement state is supported for both resident and + inherited modules (though resident modules cannot have + an enablement state of "inherited"). Updating the + display name or configuration of a module is supported + for resident modules only. The type of a module cannot + be changed. + + Returns: + Callable[[~.UpdateEventThreatDetectionCustomModuleRequest], + Awaitable[~.EventThreatDetectionCustomModule]]: + 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_event_threat_detection_custom_module' not in self._stubs: + self._stubs['update_event_threat_detection_custom_module'] = self.grpc_channel.unary_unary( + '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/UpdateEventThreatDetectionCustomModule', + request_serializer=security_center_management.UpdateEventThreatDetectionCustomModuleRequest.serialize, + response_deserializer=security_center_management.EventThreatDetectionCustomModule.deserialize, + ) + return self._stubs['update_event_threat_detection_custom_module'] + + @property + def delete_event_threat_detection_custom_module(self) -> Callable[ + [security_center_management.DeleteEventThreatDetectionCustomModuleRequest], + Awaitable[empty_pb2.Empty]]: + r"""Return a callable for the delete event threat detection + custom module method over gRPC. + + Deletes the specified Event Threat Detection custom + module and all of its descendants in the Resource + Manager hierarchy. This method is only supported for + resident custom modules. + + Returns: + Callable[[~.DeleteEventThreatDetectionCustomModuleRequest], + 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_event_threat_detection_custom_module' not in self._stubs: + self._stubs['delete_event_threat_detection_custom_module'] = self.grpc_channel.unary_unary( + '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/DeleteEventThreatDetectionCustomModule', + request_serializer=security_center_management.DeleteEventThreatDetectionCustomModuleRequest.serialize, + response_deserializer=empty_pb2.Empty.FromString, + ) + return self._stubs['delete_event_threat_detection_custom_module'] + + @property + def validate_event_threat_detection_custom_module(self) -> Callable[ + [security_center_management.ValidateEventThreatDetectionCustomModuleRequest], + Awaitable[security_center_management.ValidateEventThreatDetectionCustomModuleResponse]]: + r"""Return a callable for the validate event threat + detection custom module method over gRPC. + + Validates the given Event Threat Detection custom + module. + + Returns: + Callable[[~.ValidateEventThreatDetectionCustomModuleRequest], + Awaitable[~.ValidateEventThreatDetectionCustomModuleResponse]]: + 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 'validate_event_threat_detection_custom_module' not in self._stubs: + self._stubs['validate_event_threat_detection_custom_module'] = self.grpc_channel.unary_unary( + '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/ValidateEventThreatDetectionCustomModule', + request_serializer=security_center_management.ValidateEventThreatDetectionCustomModuleRequest.serialize, + response_deserializer=security_center_management.ValidateEventThreatDetectionCustomModuleResponse.deserialize, + ) + return self._stubs['validate_event_threat_detection_custom_module'] + + def close(self): + return self.grpc_channel.close() + + @property + def list_locations( + self, + ) -> Callable[[locations_pb2.ListLocationsRequest], locations_pb2.ListLocationsResponse]: + r"""Return a callable for the list locations method over gRPC. + """ + # 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_locations" not in self._stubs: + self._stubs["list_locations"] = self.grpc_channel.unary_unary( + "/google.cloud.location.Locations/ListLocations", + request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, + response_deserializer=locations_pb2.ListLocationsResponse.FromString, + ) + return self._stubs["list_locations"] + + @property + def get_location( + self, + ) -> Callable[[locations_pb2.GetLocationRequest], locations_pb2.Location]: + r"""Return a callable for the list locations method over gRPC. + """ + # 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_location" not in self._stubs: + self._stubs["get_location"] = self.grpc_channel.unary_unary( + "/google.cloud.location.Locations/GetLocation", + request_serializer=locations_pb2.GetLocationRequest.SerializeToString, + response_deserializer=locations_pb2.Location.FromString, + ) + return self._stubs["get_location"] + + +__all__ = ( + 'SecurityCenterManagementGrpcAsyncIOTransport', +) diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/rest.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/rest.py new file mode 100644 index 000000000000..33dcd48632c8 --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/rest.py @@ -0,0 +1,2627 @@ +# -*- 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. +# + +from google.auth.transport.requests import AuthorizedSession # type: ignore +import json # type: ignore +import grpc # type: ignore +from google.auth.transport.grpc import SslCredentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore +from google.api_core import exceptions as core_exceptions +from google.api_core import retry as retries +from google.api_core import rest_helpers +from google.api_core import rest_streaming +from google.api_core import path_template +from google.api_core import gapic_v1 + +from google.protobuf import json_format +from google.cloud.location import locations_pb2 # type: ignore +from requests import __version__ as requests_version +import dataclasses +import re +from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union +import warnings + +try: + OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] +except AttributeError: # pragma: NO COVER + OptionalRetry = Union[retries.Retry, object] # type: ignore + + +from google.cloud.securitycentermanagement_v1.types import security_center_management +from google.protobuf import empty_pb2 # type: ignore + +from .base import SecurityCenterManagementTransport, DEFAULT_CLIENT_INFO as BASE_DEFAULT_CLIENT_INFO + + +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version, + grpc_version=None, + rest_version=requests_version, +) + + +class SecurityCenterManagementRestInterceptor: + """Interceptor for SecurityCenterManagement. + + Interceptors are used to manipulate requests, request metadata, and responses + in arbitrary ways. + Example use cases include: + * Logging + * Verifying requests according to service or custom semantics + * Stripping extraneous information from responses + + These use cases and more can be enabled by injecting an + instance of a custom subclass when constructing the SecurityCenterManagementRestTransport. + + .. code-block:: python + class MyCustomSecurityCenterManagementInterceptor(SecurityCenterManagementRestInterceptor): + def pre_create_event_threat_detection_custom_module(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_create_event_threat_detection_custom_module(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_create_security_health_analytics_custom_module(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_create_security_health_analytics_custom_module(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_delete_event_threat_detection_custom_module(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def pre_delete_security_health_analytics_custom_module(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def pre_get_effective_event_threat_detection_custom_module(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get_effective_event_threat_detection_custom_module(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_get_effective_security_health_analytics_custom_module(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get_effective_security_health_analytics_custom_module(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_get_event_threat_detection_custom_module(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get_event_threat_detection_custom_module(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_get_security_health_analytics_custom_module(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_get_security_health_analytics_custom_module(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_list_descendant_event_threat_detection_custom_modules(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_descendant_event_threat_detection_custom_modules(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_list_descendant_security_health_analytics_custom_modules(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_descendant_security_health_analytics_custom_modules(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_list_effective_event_threat_detection_custom_modules(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_effective_event_threat_detection_custom_modules(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_list_effective_security_health_analytics_custom_modules(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_effective_security_health_analytics_custom_modules(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_list_event_threat_detection_custom_modules(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_event_threat_detection_custom_modules(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_list_security_health_analytics_custom_modules(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_list_security_health_analytics_custom_modules(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_simulate_security_health_analytics_custom_module(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_simulate_security_health_analytics_custom_module(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_update_event_threat_detection_custom_module(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_update_event_threat_detection_custom_module(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_update_security_health_analytics_custom_module(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_update_security_health_analytics_custom_module(self, response): + logging.log(f"Received response: {response}") + return response + + def pre_validate_event_threat_detection_custom_module(self, request, metadata): + logging.log(f"Received request: {request}") + return request, metadata + + def post_validate_event_threat_detection_custom_module(self, response): + logging.log(f"Received response: {response}") + return response + + transport = SecurityCenterManagementRestTransport(interceptor=MyCustomSecurityCenterManagementInterceptor()) + client = SecurityCenterManagementClient(transport=transport) + + + """ + def pre_create_event_threat_detection_custom_module(self, request: security_center_management.CreateEventThreatDetectionCustomModuleRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[security_center_management.CreateEventThreatDetectionCustomModuleRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for create_event_threat_detection_custom_module + + Override in a subclass to manipulate the request or metadata + before they are sent to the SecurityCenterManagement server. + """ + return request, metadata + + def post_create_event_threat_detection_custom_module(self, response: security_center_management.EventThreatDetectionCustomModule) -> security_center_management.EventThreatDetectionCustomModule: + """Post-rpc interceptor for create_event_threat_detection_custom_module + + Override in a subclass to manipulate the response + after it is returned by the SecurityCenterManagement server but before + it is returned to user code. + """ + return response + def pre_create_security_health_analytics_custom_module(self, request: security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for create_security_health_analytics_custom_module + + Override in a subclass to manipulate the request or metadata + before they are sent to the SecurityCenterManagement server. + """ + return request, metadata + + def post_create_security_health_analytics_custom_module(self, response: security_center_management.SecurityHealthAnalyticsCustomModule) -> security_center_management.SecurityHealthAnalyticsCustomModule: + """Post-rpc interceptor for create_security_health_analytics_custom_module + + Override in a subclass to manipulate the response + after it is returned by the SecurityCenterManagement server but before + it is returned to user code. + """ + return response + def pre_delete_event_threat_detection_custom_module(self, request: security_center_management.DeleteEventThreatDetectionCustomModuleRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[security_center_management.DeleteEventThreatDetectionCustomModuleRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for delete_event_threat_detection_custom_module + + Override in a subclass to manipulate the request or metadata + before they are sent to the SecurityCenterManagement server. + """ + return request, metadata + + def pre_delete_security_health_analytics_custom_module(self, request: security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for delete_security_health_analytics_custom_module + + Override in a subclass to manipulate the request or metadata + before they are sent to the SecurityCenterManagement server. + """ + return request, metadata + + def pre_get_effective_event_threat_detection_custom_module(self, request: security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for get_effective_event_threat_detection_custom_module + + Override in a subclass to manipulate the request or metadata + before they are sent to the SecurityCenterManagement server. + """ + return request, metadata + + def post_get_effective_event_threat_detection_custom_module(self, response: security_center_management.EffectiveEventThreatDetectionCustomModule) -> security_center_management.EffectiveEventThreatDetectionCustomModule: + """Post-rpc interceptor for get_effective_event_threat_detection_custom_module + + Override in a subclass to manipulate the response + after it is returned by the SecurityCenterManagement server but before + it is returned to user code. + """ + return response + def pre_get_effective_security_health_analytics_custom_module(self, request: security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for get_effective_security_health_analytics_custom_module + + Override in a subclass to manipulate the request or metadata + before they are sent to the SecurityCenterManagement server. + """ + return request, metadata + + def post_get_effective_security_health_analytics_custom_module(self, response: security_center_management.EffectiveSecurityHealthAnalyticsCustomModule) -> security_center_management.EffectiveSecurityHealthAnalyticsCustomModule: + """Post-rpc interceptor for get_effective_security_health_analytics_custom_module + + Override in a subclass to manipulate the response + after it is returned by the SecurityCenterManagement server but before + it is returned to user code. + """ + return response + def pre_get_event_threat_detection_custom_module(self, request: security_center_management.GetEventThreatDetectionCustomModuleRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[security_center_management.GetEventThreatDetectionCustomModuleRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for get_event_threat_detection_custom_module + + Override in a subclass to manipulate the request or metadata + before they are sent to the SecurityCenterManagement server. + """ + return request, metadata + + def post_get_event_threat_detection_custom_module(self, response: security_center_management.EventThreatDetectionCustomModule) -> security_center_management.EventThreatDetectionCustomModule: + """Post-rpc interceptor for get_event_threat_detection_custom_module + + Override in a subclass to manipulate the response + after it is returned by the SecurityCenterManagement server but before + it is returned to user code. + """ + return response + def pre_get_security_health_analytics_custom_module(self, request: security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for get_security_health_analytics_custom_module + + Override in a subclass to manipulate the request or metadata + before they are sent to the SecurityCenterManagement server. + """ + return request, metadata + + def post_get_security_health_analytics_custom_module(self, response: security_center_management.SecurityHealthAnalyticsCustomModule) -> security_center_management.SecurityHealthAnalyticsCustomModule: + """Post-rpc interceptor for get_security_health_analytics_custom_module + + Override in a subclass to manipulate the response + after it is returned by the SecurityCenterManagement server but before + it is returned to user code. + """ + return response + def pre_list_descendant_event_threat_detection_custom_modules(self, request: security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for list_descendant_event_threat_detection_custom_modules + + Override in a subclass to manipulate the request or metadata + before they are sent to the SecurityCenterManagement server. + """ + return request, metadata + + def post_list_descendant_event_threat_detection_custom_modules(self, response: security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse) -> security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse: + """Post-rpc interceptor for list_descendant_event_threat_detection_custom_modules + + Override in a subclass to manipulate the response + after it is returned by the SecurityCenterManagement server but before + it is returned to user code. + """ + return response + def pre_list_descendant_security_health_analytics_custom_modules(self, request: security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for list_descendant_security_health_analytics_custom_modules + + Override in a subclass to manipulate the request or metadata + before they are sent to the SecurityCenterManagement server. + """ + return request, metadata + + def post_list_descendant_security_health_analytics_custom_modules(self, response: security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse) -> security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse: + """Post-rpc interceptor for list_descendant_security_health_analytics_custom_modules + + Override in a subclass to manipulate the response + after it is returned by the SecurityCenterManagement server but before + it is returned to user code. + """ + return response + def pre_list_effective_event_threat_detection_custom_modules(self, request: security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for list_effective_event_threat_detection_custom_modules + + Override in a subclass to manipulate the request or metadata + before they are sent to the SecurityCenterManagement server. + """ + return request, metadata + + def post_list_effective_event_threat_detection_custom_modules(self, response: security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse) -> security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse: + """Post-rpc interceptor for list_effective_event_threat_detection_custom_modules + + Override in a subclass to manipulate the response + after it is returned by the SecurityCenterManagement server but before + it is returned to user code. + """ + return response + def pre_list_effective_security_health_analytics_custom_modules(self, request: security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for list_effective_security_health_analytics_custom_modules + + Override in a subclass to manipulate the request or metadata + before they are sent to the SecurityCenterManagement server. + """ + return request, metadata + + def post_list_effective_security_health_analytics_custom_modules(self, response: security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse) -> security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse: + """Post-rpc interceptor for list_effective_security_health_analytics_custom_modules + + Override in a subclass to manipulate the response + after it is returned by the SecurityCenterManagement server but before + it is returned to user code. + """ + return response + def pre_list_event_threat_detection_custom_modules(self, request: security_center_management.ListEventThreatDetectionCustomModulesRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[security_center_management.ListEventThreatDetectionCustomModulesRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for list_event_threat_detection_custom_modules + + Override in a subclass to manipulate the request or metadata + before they are sent to the SecurityCenterManagement server. + """ + return request, metadata + + def post_list_event_threat_detection_custom_modules(self, response: security_center_management.ListEventThreatDetectionCustomModulesResponse) -> security_center_management.ListEventThreatDetectionCustomModulesResponse: + """Post-rpc interceptor for list_event_threat_detection_custom_modules + + Override in a subclass to manipulate the response + after it is returned by the SecurityCenterManagement server but before + it is returned to user code. + """ + return response + def pre_list_security_health_analytics_custom_modules(self, request: security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for list_security_health_analytics_custom_modules + + Override in a subclass to manipulate the request or metadata + before they are sent to the SecurityCenterManagement server. + """ + return request, metadata + + def post_list_security_health_analytics_custom_modules(self, response: security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse) -> security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse: + """Post-rpc interceptor for list_security_health_analytics_custom_modules + + Override in a subclass to manipulate the response + after it is returned by the SecurityCenterManagement server but before + it is returned to user code. + """ + return response + def pre_simulate_security_health_analytics_custom_module(self, request: security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for simulate_security_health_analytics_custom_module + + Override in a subclass to manipulate the request or metadata + before they are sent to the SecurityCenterManagement server. + """ + return request, metadata + + def post_simulate_security_health_analytics_custom_module(self, response: security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse) -> security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse: + """Post-rpc interceptor for simulate_security_health_analytics_custom_module + + Override in a subclass to manipulate the response + after it is returned by the SecurityCenterManagement server but before + it is returned to user code. + """ + return response + def pre_update_event_threat_detection_custom_module(self, request: security_center_management.UpdateEventThreatDetectionCustomModuleRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[security_center_management.UpdateEventThreatDetectionCustomModuleRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for update_event_threat_detection_custom_module + + Override in a subclass to manipulate the request or metadata + before they are sent to the SecurityCenterManagement server. + """ + return request, metadata + + def post_update_event_threat_detection_custom_module(self, response: security_center_management.EventThreatDetectionCustomModule) -> security_center_management.EventThreatDetectionCustomModule: + """Post-rpc interceptor for update_event_threat_detection_custom_module + + Override in a subclass to manipulate the response + after it is returned by the SecurityCenterManagement server but before + it is returned to user code. + """ + return response + def pre_update_security_health_analytics_custom_module(self, request: security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for update_security_health_analytics_custom_module + + Override in a subclass to manipulate the request or metadata + before they are sent to the SecurityCenterManagement server. + """ + return request, metadata + + def post_update_security_health_analytics_custom_module(self, response: security_center_management.SecurityHealthAnalyticsCustomModule) -> security_center_management.SecurityHealthAnalyticsCustomModule: + """Post-rpc interceptor for update_security_health_analytics_custom_module + + Override in a subclass to manipulate the response + after it is returned by the SecurityCenterManagement server but before + it is returned to user code. + """ + return response + def pre_validate_event_threat_detection_custom_module(self, request: security_center_management.ValidateEventThreatDetectionCustomModuleRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[security_center_management.ValidateEventThreatDetectionCustomModuleRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for validate_event_threat_detection_custom_module + + Override in a subclass to manipulate the request or metadata + before they are sent to the SecurityCenterManagement server. + """ + return request, metadata + + def post_validate_event_threat_detection_custom_module(self, response: security_center_management.ValidateEventThreatDetectionCustomModuleResponse) -> security_center_management.ValidateEventThreatDetectionCustomModuleResponse: + """Post-rpc interceptor for validate_event_threat_detection_custom_module + + Override in a subclass to manipulate the response + after it is returned by the SecurityCenterManagement server but before + it is returned to user code. + """ + return response + + def pre_get_location( + self, request: locations_pb2.GetLocationRequest, metadata: Sequence[Tuple[str, str]] + ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for get_location + + Override in a subclass to manipulate the request or metadata + before they are sent to the SecurityCenterManagement server. + """ + return request, metadata + + def post_get_location( + self, response: locations_pb2.Location + ) -> locations_pb2.Location: + """Post-rpc interceptor for get_location + + Override in a subclass to manipulate the response + after it is returned by the SecurityCenterManagement server but before + it is returned to user code. + """ + return response + def pre_list_locations( + self, request: locations_pb2.ListLocationsRequest, metadata: Sequence[Tuple[str, str]] + ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, str]]]: + """Pre-rpc interceptor for list_locations + + Override in a subclass to manipulate the request or metadata + before they are sent to the SecurityCenterManagement server. + """ + return request, metadata + + def post_list_locations( + self, response: locations_pb2.ListLocationsResponse + ) -> locations_pb2.ListLocationsResponse: + """Post-rpc interceptor for list_locations + + Override in a subclass to manipulate the response + after it is returned by the SecurityCenterManagement server but before + it is returned to user code. + """ + return response + + +@dataclasses.dataclass +class SecurityCenterManagementRestStub: + _session: AuthorizedSession + _host: str + _interceptor: SecurityCenterManagementRestInterceptor + + +class SecurityCenterManagementRestTransport(SecurityCenterManagementTransport): + """REST backend transport for SecurityCenterManagement. + + Service describing handlers for resources + + This class defines the same methods as the primary client, so the + primary client can load the underlying transport implementation + and call it. + + It sends JSON representations of protocol buffers over HTTP/1.1 + + """ + + def __init__(self, *, + host: str = 'securitycentermanagement.googleapis.com', + credentials: Optional[ga_credentials.Credentials] = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + client_cert_source_for_mtls: Optional[Callable[[ + ], Tuple[bytes, bytes]]] = None, + quota_project_id: Optional[str] = None, + client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + always_use_jwt_access: Optional[bool] = False, + url_scheme: str = 'https', + interceptor: Optional[SecurityCenterManagementRestInterceptor] = None, + api_audience: Optional[str] = None, + ) -> None: + """Instantiate the transport. + + Args: + host (Optional[str]): + The hostname to connect to. + credentials (Optional[google.auth.credentials.Credentials]): The + authorization credentials to attach to requests. These + credentials identify the application to the service; if none + are specified, the client will attempt to ascertain the + credentials from the environment. + + credentials_file (Optional[str]): A file with credentials that can + be loaded with :func:`google.auth.load_credentials_from_file`. + This argument is ignored if ``channel`` is provided. + scopes (Optional(Sequence[str])): A list of scopes. This argument is + ignored if ``channel`` is provided. + client_cert_source_for_mtls (Callable[[], Tuple[bytes, bytes]]): Client + certificate to configure mutual TLS HTTP channel. It is ignored + if ``channel`` is provided. + quota_project_id (Optional[str]): An optional project to use for billing + and quota. + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you are developing + your own client library. + always_use_jwt_access (Optional[bool]): Whether self signed JWT should + be used for service account credentials. + url_scheme: the protocol scheme for the API endpoint. Normally + "https", but for testing or local servers, + "http" can be specified. + """ + # Run the base constructor + # TODO(yon-mg): resolve other ctor params i.e. scopes, quota, etc. + # TODO: When custom host (api_endpoint) is set, `scopes` must *also* be set on the + # credentials object + maybe_url_match = re.match("^(?Phttp(?:s)?://)?(?P.*)$", host) + if maybe_url_match is None: + raise ValueError(f"Unexpected hostname structure: {host}") # pragma: NO COVER + + url_match_items = maybe_url_match.groupdict() + + host = f"{url_scheme}://{host}" if not url_match_items["scheme"] else host + + super().__init__( + host=host, + credentials=credentials, + client_info=client_info, + always_use_jwt_access=always_use_jwt_access, + api_audience=api_audience + ) + self._session = AuthorizedSession( + self._credentials, default_host=self.DEFAULT_HOST) + if client_cert_source_for_mtls: + self._session.configure_mtls_channel(client_cert_source_for_mtls) + self._interceptor = interceptor or SecurityCenterManagementRestInterceptor() + self._prep_wrapped_messages(client_info) + + class _CreateEventThreatDetectionCustomModule(SecurityCenterManagementRestStub): + def __hash__(self): + return hash("CreateEventThreatDetectionCustomModule") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: security_center_management.CreateEventThreatDetectionCustomModuleRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> security_center_management.EventThreatDetectionCustomModule: + r"""Call the create event threat + detection custom module method over HTTP. + + Args: + request (~.security_center_management.CreateEventThreatDetectionCustomModuleRequest): + The request object. Message for creating a + EventThreatDetectionCustomModule + 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: + ~.security_center_management.EventThreatDetectionCustomModule: + An event threat detection custom + module is a Cloud SCC resource that + contains the configuration and + enablement state of a custom module, + which enables ETD to write certain + findings to Cloud SCC. + + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'post', + 'uri': '/v1/{parent=projects/*/locations/*}/eventThreatDetectionCustomModules', + 'body': 'event_threat_detection_custom_module', + }, +{ + 'method': 'post', + 'uri': '/v1/{parent=folders/*/locations/*}/eventThreatDetectionCustomModules', + 'body': 'event_threat_detection_custom_module', + }, +{ + 'method': 'post', + 'uri': '/v1/{parent=organizations/*/locations/*}/eventThreatDetectionCustomModules', + 'body': 'event_threat_detection_custom_module', + }, + ] + request, metadata = self._interceptor.pre_create_event_threat_detection_custom_module(request, metadata) + pb_request = security_center_management.CreateEventThreatDetectionCustomModuleRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request['body'], + including_default_value_fields=False, + use_integers_for_enums=True + ) + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = security_center_management.EventThreatDetectionCustomModule() + pb_resp = security_center_management.EventThreatDetectionCustomModule.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_event_threat_detection_custom_module(resp) + return resp + + class _CreateSecurityHealthAnalyticsCustomModule(SecurityCenterManagementRestStub): + def __hash__(self): + return hash("CreateSecurityHealthAnalyticsCustomModule") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> security_center_management.SecurityHealthAnalyticsCustomModule: + r"""Call the create security health + analytics custom module method over HTTP. + + Args: + request (~.security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest): + The request object. Message for creating a + SecurityHealthAnalyticsCustomModule + 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: + ~.security_center_management.SecurityHealthAnalyticsCustomModule: + Represents an instance of a Security + Health Analytics custom module, + including its full module name, display + name, enablement state, and last updated + time. You can create a custom module at + the organization, folder, or project + level. Custom modules that you create at + the organization or folder level are + inherited by the child folders and + projects. + + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'post', + 'uri': '/v1/{parent=projects/*/locations/*}/securityHealthAnalyticsCustomModules', + 'body': 'security_health_analytics_custom_module', + }, +{ + 'method': 'post', + 'uri': '/v1/{parent=folders/*/locations/*}/securityHealthAnalyticsCustomModules', + 'body': 'security_health_analytics_custom_module', + }, +{ + 'method': 'post', + 'uri': '/v1/{parent=organizations/*/locations/*}/securityHealthAnalyticsCustomModules', + 'body': 'security_health_analytics_custom_module', + }, + ] + request, metadata = self._interceptor.pre_create_security_health_analytics_custom_module(request, metadata) + pb_request = security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request['body'], + including_default_value_fields=False, + use_integers_for_enums=True + ) + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = security_center_management.SecurityHealthAnalyticsCustomModule() + pb_resp = security_center_management.SecurityHealthAnalyticsCustomModule.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_security_health_analytics_custom_module(resp) + return resp + + class _DeleteEventThreatDetectionCustomModule(SecurityCenterManagementRestStub): + def __hash__(self): + return hash("DeleteEventThreatDetectionCustomModule") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: security_center_management.DeleteEventThreatDetectionCustomModuleRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ): + r"""Call the delete event threat + detection custom module method over HTTP. + + Args: + request (~.security_center_management.DeleteEventThreatDetectionCustomModuleRequest): + The request object. Message for deleting a + EventThreatDetectionCustomModule + 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. + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'delete', + 'uri': '/v1/{name=projects/*/locations/*/eventThreatDetectionCustomModules/*}', + }, +{ + 'method': 'delete', + 'uri': '/v1/{name=folders/*/locations/*/eventThreatDetectionCustomModules/*}', + }, +{ + 'method': 'delete', + 'uri': '/v1/{name=organizations/*/locations/*/eventThreatDetectionCustomModules/*}', + }, + ] + request, metadata = self._interceptor.pre_delete_event_threat_detection_custom_module(request, metadata) + pb_request = security_center_management.DeleteEventThreatDetectionCustomModuleRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + class _DeleteSecurityHealthAnalyticsCustomModule(SecurityCenterManagementRestStub): + def __hash__(self): + return hash("DeleteSecurityHealthAnalyticsCustomModule") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ): + r"""Call the delete security health + analytics custom module method over HTTP. + + Args: + request (~.security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest): + The request object. Message for deleting a + SecurityHealthAnalyticsCustomModule + 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. + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'delete', + 'uri': '/v1/{name=projects/*/locations/*/securityHealthAnalyticsCustomModules/*}', + }, +{ + 'method': 'delete', + 'uri': '/v1/{name=folders/*/locations/*/securityHealthAnalyticsCustomModules/*}', + }, +{ + 'method': 'delete', + 'uri': '/v1/{name=organizations/*/locations/*/securityHealthAnalyticsCustomModules/*}', + }, + ] + request, metadata = self._interceptor.pre_delete_security_health_analytics_custom_module(request, metadata) + pb_request = security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + class _GetEffectiveEventThreatDetectionCustomModule(SecurityCenterManagementRestStub): + def __hash__(self): + return hash("GetEffectiveEventThreatDetectionCustomModule") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> security_center_management.EffectiveEventThreatDetectionCustomModule: + r"""Call the get effective event + threat detection custom module method over HTTP. + + Args: + request (~.security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest): + The request object. Message for getting a + EffectiveEventThreatDetectionCustomModule + 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: + ~.security_center_management.EffectiveEventThreatDetectionCustomModule: + An EffectiveEventThreatDetectionCustomModule is the + representation of EventThreatDetectionCustomModule at a + given level taking hierarchy into account and resolving + various fields accordingly. e.g. if the module is + enabled at the ancestor level, effective modules at all + descendant levels will have enablement_state set to + ENABLED. Similarly, if module.inherited is set, then + effective module's config will contain the ancestor's + config details. + EffectiveEventThreatDetectionCustomModule is read-only. + + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{name=projects/*/locations/*/effectiveEventThreatDetectionCustomModules/*}', + }, +{ + 'method': 'get', + 'uri': '/v1/{name=folders/*/locations/*/effectiveEventThreatDetectionCustomModules/*}', + }, +{ + 'method': 'get', + 'uri': '/v1/{name=organizations/*/locations/*/effectiveEventThreatDetectionCustomModules/*}', + }, + ] + request, metadata = self._interceptor.pre_get_effective_event_threat_detection_custom_module(request, metadata) + pb_request = security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = security_center_management.EffectiveEventThreatDetectionCustomModule() + pb_resp = security_center_management.EffectiveEventThreatDetectionCustomModule.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_effective_event_threat_detection_custom_module(resp) + return resp + + class _GetEffectiveSecurityHealthAnalyticsCustomModule(SecurityCenterManagementRestStub): + def __hash__(self): + return hash("GetEffectiveSecurityHealthAnalyticsCustomModule") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> security_center_management.EffectiveSecurityHealthAnalyticsCustomModule: + r"""Call the get effective security + health analytics custom module method over HTTP. + + Args: + request (~.security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest): + The request object. Message for getting a + EffectiveSecurityHealthAnalyticsCustomModule + 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: + ~.security_center_management.EffectiveSecurityHealthAnalyticsCustomModule: + An EffectiveSecurityHealthAnalyticsCustomModule is the + representation of a Security Health Analytics custom + module at a specified level of the resource hierarchy: + organization, folder, or project. If a custom module is + inherited from a parent organization or folder, the + value of the ``enablementState`` property in + EffectiveSecurityHealthAnalyticsCustomModule is set to + the value that is effective in the parent, instead of + ``INHERITED``. For example, if the module is enabled in + a parent organization or folder, the effective + enablement_state for the module in all child folders or + projects is also ``enabled``. + EffectiveSecurityHealthAnalyticsCustomModule is + read-only. + + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{name=projects/*/locations/*/effectiveSecurityHealthAnalyticsCustomModules/*}', + }, +{ + 'method': 'get', + 'uri': '/v1/{name=folders/*/locations/*/effectiveSecurityHealthAnalyticsCustomModules/*}', + }, +{ + 'method': 'get', + 'uri': '/v1/{name=organizations/*/locations/*/effectiveSecurityHealthAnalyticsCustomModules/*}', + }, + ] + request, metadata = self._interceptor.pre_get_effective_security_health_analytics_custom_module(request, metadata) + pb_request = security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = security_center_management.EffectiveSecurityHealthAnalyticsCustomModule() + pb_resp = security_center_management.EffectiveSecurityHealthAnalyticsCustomModule.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_effective_security_health_analytics_custom_module(resp) + return resp + + class _GetEventThreatDetectionCustomModule(SecurityCenterManagementRestStub): + def __hash__(self): + return hash("GetEventThreatDetectionCustomModule") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: security_center_management.GetEventThreatDetectionCustomModuleRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> security_center_management.EventThreatDetectionCustomModule: + r"""Call the get event threat + detection custom module method over HTTP. + + Args: + request (~.security_center_management.GetEventThreatDetectionCustomModuleRequest): + The request object. Message for getting a + EventThreatDetectionCustomModule + 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: + ~.security_center_management.EventThreatDetectionCustomModule: + An event threat detection custom + module is a Cloud SCC resource that + contains the configuration and + enablement state of a custom module, + which enables ETD to write certain + findings to Cloud SCC. + + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{name=projects/*/locations/*/eventThreatDetectionCustomModules/*}', + }, +{ + 'method': 'get', + 'uri': '/v1/{name=folders/*/locations/*/eventThreatDetectionCustomModules/*}', + }, +{ + 'method': 'get', + 'uri': '/v1/{name=organizations/*/locations/*/eventThreatDetectionCustomModules/*}', + }, + ] + request, metadata = self._interceptor.pre_get_event_threat_detection_custom_module(request, metadata) + pb_request = security_center_management.GetEventThreatDetectionCustomModuleRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = security_center_management.EventThreatDetectionCustomModule() + pb_resp = security_center_management.EventThreatDetectionCustomModule.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_event_threat_detection_custom_module(resp) + return resp + + class _GetSecurityHealthAnalyticsCustomModule(SecurityCenterManagementRestStub): + def __hash__(self): + return hash("GetSecurityHealthAnalyticsCustomModule") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> security_center_management.SecurityHealthAnalyticsCustomModule: + r"""Call the get security health + analytics custom module method over HTTP. + + Args: + request (~.security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest): + The request object. Message for getting a + SecurityHealthAnalyticsCustomModule + 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: + ~.security_center_management.SecurityHealthAnalyticsCustomModule: + Represents an instance of a Security + Health Analytics custom module, + including its full module name, display + name, enablement state, and last updated + time. You can create a custom module at + the organization, folder, or project + level. Custom modules that you create at + the organization or folder level are + inherited by the child folders and + projects. + + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{name=projects/*/locations/*/securityHealthAnalyticsCustomModules/*}', + }, +{ + 'method': 'get', + 'uri': '/v1/{name=folders/*/locations/*/securityHealthAnalyticsCustomModules/*}', + }, +{ + 'method': 'get', + 'uri': '/v1/{name=organizations/*/locations/*/securityHealthAnalyticsCustomModules/*}', + }, + ] + request, metadata = self._interceptor.pre_get_security_health_analytics_custom_module(request, metadata) + pb_request = security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = security_center_management.SecurityHealthAnalyticsCustomModule() + pb_resp = security_center_management.SecurityHealthAnalyticsCustomModule.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_security_health_analytics_custom_module(resp) + return resp + + class _ListDescendantEventThreatDetectionCustomModules(SecurityCenterManagementRestStub): + def __hash__(self): + return hash("ListDescendantEventThreatDetectionCustomModules") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse: + r"""Call the list descendant event + threat detection custom modules method over HTTP. + + Args: + request (~.security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest): + The request object. Request message for listing + descendant Event Threat Detection custom + modules. + 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: + ~.security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse: + Response message for listing + descendant Event Threat Detection custom + modules. + + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{parent=projects/*/locations/*}/eventThreatDetectionCustomModules:listDescendant', + }, +{ + 'method': 'get', + 'uri': '/v1/{parent=folders/*/locations/*}/eventThreatDetectionCustomModules:listDescendant', + }, +{ + 'method': 'get', + 'uri': '/v1/{parent=organizations/*/locations/*}/eventThreatDetectionCustomModules:listDescendant', + }, + ] + request, metadata = self._interceptor.pre_list_descendant_event_threat_detection_custom_modules(request, metadata) + pb_request = security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse() + pb_resp = security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_descendant_event_threat_detection_custom_modules(resp) + return resp + + class _ListDescendantSecurityHealthAnalyticsCustomModules(SecurityCenterManagementRestStub): + def __hash__(self): + return hash("ListDescendantSecurityHealthAnalyticsCustomModules") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse: + r"""Call the list descendant security + health analytics custom modules method over HTTP. + + Args: + request (~.security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest): + The request object. Request message for listing + descendant Security Health Analytics + custom modules. + 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: + ~.security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse: + Response message for listing + descendant Security Health Analytics + custom modules. + + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{parent=projects/*/locations/*}/securityHealthAnalyticsCustomModules:listDescendant', + }, +{ + 'method': 'get', + 'uri': '/v1/{parent=folders/*/locations/*}/securityHealthAnalyticsCustomModules:listDescendant', + }, +{ + 'method': 'get', + 'uri': '/v1/{parent=organizations/*/locations/*}/securityHealthAnalyticsCustomModules:listDescendant', + }, + ] + request, metadata = self._interceptor.pre_list_descendant_security_health_analytics_custom_modules(request, metadata) + pb_request = security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse() + pb_resp = security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_descendant_security_health_analytics_custom_modules(resp) + return resp + + class _ListEffectiveEventThreatDetectionCustomModules(SecurityCenterManagementRestStub): + def __hash__(self): + return hash("ListEffectiveEventThreatDetectionCustomModules") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse: + r"""Call the list effective event + threat detection custom modules method over HTTP. + + Args: + request (~.security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest): + The request object. Request message for listing effective + Event Threat Detection custom modules. + 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: + ~.security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse: + Response message for listing + effective Event Threat Detection custom + modules. + + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{parent=projects/*/locations/*}/effectiveEventThreatDetectionCustomModules', + }, +{ + 'method': 'get', + 'uri': '/v1/{parent=folders/*/locations/*}/effectiveEventThreatDetectionCustomModules', + }, +{ + 'method': 'get', + 'uri': '/v1/{parent=organizations/*/locations/*}/effectiveEventThreatDetectionCustomModules', + }, + ] + request, metadata = self._interceptor.pre_list_effective_event_threat_detection_custom_modules(request, metadata) + pb_request = security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse() + pb_resp = security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_effective_event_threat_detection_custom_modules(resp) + return resp + + class _ListEffectiveSecurityHealthAnalyticsCustomModules(SecurityCenterManagementRestStub): + def __hash__(self): + return hash("ListEffectiveSecurityHealthAnalyticsCustomModules") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse: + r"""Call the list effective security + health analytics custom modules method over HTTP. + + Args: + request (~.security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest): + The request object. Request message for listing effective + Security Health Analytics custom + modules. + 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: + ~.security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse: + Response message for listing + effective Security Health Analytics + custom modules. + + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{parent=projects/*/locations/*}/effectiveSecurityHealthAnalyticsCustomModules', + }, +{ + 'method': 'get', + 'uri': '/v1/{parent=folders/*/locations/*}/effectiveSecurityHealthAnalyticsCustomModules', + }, +{ + 'method': 'get', + 'uri': '/v1/{parent=organizations/*/locations/*}/effectiveSecurityHealthAnalyticsCustomModules', + }, + ] + request, metadata = self._interceptor.pre_list_effective_security_health_analytics_custom_modules(request, metadata) + pb_request = security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse() + pb_resp = security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_effective_security_health_analytics_custom_modules(resp) + return resp + + class _ListEventThreatDetectionCustomModules(SecurityCenterManagementRestStub): + def __hash__(self): + return hash("ListEventThreatDetectionCustomModules") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: security_center_management.ListEventThreatDetectionCustomModulesRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> security_center_management.ListEventThreatDetectionCustomModulesResponse: + r"""Call the list event threat + detection custom modules method over HTTP. + + Args: + request (~.security_center_management.ListEventThreatDetectionCustomModulesRequest): + The request object. Request message for listing Event + Threat Detection custom modules. + 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: + ~.security_center_management.ListEventThreatDetectionCustomModulesResponse: + Response message for listing Event + Threat Detection custom modules. + + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{parent=projects/*/locations/*}/eventThreatDetectionCustomModules', + }, +{ + 'method': 'get', + 'uri': '/v1/{parent=folders/*/locations/*}/eventThreatDetectionCustomModules', + }, +{ + 'method': 'get', + 'uri': '/v1/{parent=organizations/*/locations/*}/eventThreatDetectionCustomModules', + }, + ] + request, metadata = self._interceptor.pre_list_event_threat_detection_custom_modules(request, metadata) + pb_request = security_center_management.ListEventThreatDetectionCustomModulesRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = security_center_management.ListEventThreatDetectionCustomModulesResponse() + pb_resp = security_center_management.ListEventThreatDetectionCustomModulesResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_event_threat_detection_custom_modules(resp) + return resp + + class _ListSecurityHealthAnalyticsCustomModules(SecurityCenterManagementRestStub): + def __hash__(self): + return hash("ListSecurityHealthAnalyticsCustomModules") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse: + r"""Call the list security health + analytics custom modules method over HTTP. + + Args: + request (~.security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest): + The request object. Request message for listing Security + Health Analytics custom modules. + 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: + ~.security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse: + Response message for listing Security + Health Analytics custom modules. + + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{parent=projects/*/locations/*}/securityHealthAnalyticsCustomModules', + }, +{ + 'method': 'get', + 'uri': '/v1/{parent=folders/*/locations/*}/securityHealthAnalyticsCustomModules', + }, +{ + 'method': 'get', + 'uri': '/v1/{parent=organizations/*/locations/*}/securityHealthAnalyticsCustomModules', + }, + ] + request, metadata = self._interceptor.pre_list_security_health_analytics_custom_modules(request, metadata) + pb_request = security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse() + pb_resp = security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_security_health_analytics_custom_modules(resp) + return resp + + class _SimulateSecurityHealthAnalyticsCustomModule(SecurityCenterManagementRestStub): + def __hash__(self): + return hash("SimulateSecurityHealthAnalyticsCustomModule") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse: + r"""Call the simulate security health + analytics custom module method over HTTP. + + Args: + request (~.security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest): + The request object. Request message to simulate a + CustomConfig against a given test + resource. Maximum size of the request is + 4 MB by default. + 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: + ~.security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse: + Response message for simulating a + ``SecurityHealthAnalyticsCustomModule`` against a given + resource. + + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'post', + 'uri': '/v1/{parent=projects/*/locations/*}/securityHealthAnalyticsCustomModules:simulate', + 'body': '*', + }, +{ + 'method': 'post', + 'uri': '/v1/{parent=folders/*/locations/*}/securityHealthAnalyticsCustomModules:simulate', + 'body': '*', + }, +{ + 'method': 'post', + 'uri': '/v1/{parent=organizations/*/locations/*}/securityHealthAnalyticsCustomModules:simulate', + 'body': '*', + }, + ] + request, metadata = self._interceptor.pre_simulate_security_health_analytics_custom_module(request, metadata) + pb_request = security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request['body'], + including_default_value_fields=False, + use_integers_for_enums=True + ) + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse() + pb_resp = security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_simulate_security_health_analytics_custom_module(resp) + return resp + + class _UpdateEventThreatDetectionCustomModule(SecurityCenterManagementRestStub): + def __hash__(self): + return hash("UpdateEventThreatDetectionCustomModule") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + "updateMask" : {}, } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: security_center_management.UpdateEventThreatDetectionCustomModuleRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> security_center_management.EventThreatDetectionCustomModule: + r"""Call the update event threat + detection custom module method over HTTP. + + Args: + request (~.security_center_management.UpdateEventThreatDetectionCustomModuleRequest): + The request object. Message for updating a + EventThreatDetectionCustomModule + 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: + ~.security_center_management.EventThreatDetectionCustomModule: + An event threat detection custom + module is a Cloud SCC resource that + contains the configuration and + enablement state of a custom module, + which enables ETD to write certain + findings to Cloud SCC. + + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'patch', + 'uri': '/v1/{event_threat_detection_custom_module.name=projects/*/locations/*/eventThreatDetectionCustomModules/*}', + 'body': 'event_threat_detection_custom_module', + }, +{ + 'method': 'patch', + 'uri': '/v1/{event_threat_detection_custom_module.name=folders/*/locations/*/eventThreatDetectionCustomModules/*}', + 'body': 'event_threat_detection_custom_module', + }, +{ + 'method': 'patch', + 'uri': '/v1/{event_threat_detection_custom_module.name=organizations/*/locations/*/eventThreatDetectionCustomModules/*}', + 'body': 'event_threat_detection_custom_module', + }, + ] + request, metadata = self._interceptor.pre_update_event_threat_detection_custom_module(request, metadata) + pb_request = security_center_management.UpdateEventThreatDetectionCustomModuleRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request['body'], + including_default_value_fields=False, + use_integers_for_enums=True + ) + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = security_center_management.EventThreatDetectionCustomModule() + pb_resp = security_center_management.EventThreatDetectionCustomModule.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_event_threat_detection_custom_module(resp) + return resp + + class _UpdateSecurityHealthAnalyticsCustomModule(SecurityCenterManagementRestStub): + def __hash__(self): + return hash("UpdateSecurityHealthAnalyticsCustomModule") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + "updateMask" : {}, } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> security_center_management.SecurityHealthAnalyticsCustomModule: + r"""Call the update security health + analytics custom module method over HTTP. + + Args: + request (~.security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest): + The request object. Message for updating a + SecurityHealthAnalyticsCustomModule + 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: + ~.security_center_management.SecurityHealthAnalyticsCustomModule: + Represents an instance of a Security + Health Analytics custom module, + including its full module name, display + name, enablement state, and last updated + time. You can create a custom module at + the organization, folder, or project + level. Custom modules that you create at + the organization or folder level are + inherited by the child folders and + projects. + + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'patch', + 'uri': '/v1/{security_health_analytics_custom_module.name=projects/*/locations/*/securityHealthAnalyticsCustomModules/*}', + 'body': 'security_health_analytics_custom_module', + }, +{ + 'method': 'patch', + 'uri': '/v1/{security_health_analytics_custom_module.name=folders/*/locations/*/securityHealthAnalyticsCustomModules/*}', + 'body': 'security_health_analytics_custom_module', + }, +{ + 'method': 'patch', + 'uri': '/v1/{security_health_analytics_custom_module.name=organizations/*/locations/*/securityHealthAnalyticsCustomModules/*}', + 'body': 'security_health_analytics_custom_module', + }, + ] + request, metadata = self._interceptor.pre_update_security_health_analytics_custom_module(request, metadata) + pb_request = security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request['body'], + including_default_value_fields=False, + use_integers_for_enums=True + ) + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = security_center_management.SecurityHealthAnalyticsCustomModule() + pb_resp = security_center_management.SecurityHealthAnalyticsCustomModule.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_security_health_analytics_custom_module(resp) + return resp + + class _ValidateEventThreatDetectionCustomModule(SecurityCenterManagementRestStub): + def __hash__(self): + return hash("ValidateEventThreatDetectionCustomModule") + + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { + } + + @classmethod + def _get_unset_required_fields(cls, message_dict): + return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} + + def __call__(self, + request: security_center_management.ValidateEventThreatDetectionCustomModuleRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> security_center_management.ValidateEventThreatDetectionCustomModuleResponse: + r"""Call the validate event threat + detection custom module method over HTTP. + + Args: + request (~.security_center_management.ValidateEventThreatDetectionCustomModuleRequest): + The request object. Request to validate an Event Threat + Detection custom module. + 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: + ~.security_center_management.ValidateEventThreatDetectionCustomModuleResponse: + Response to validating an Event + Threat Detection custom module. + + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'post', + 'uri': '/v1/{parent=projects/*/locations/*}/eventThreatDetectionCustomModules:validate', + 'body': '*', + }, +{ + 'method': 'post', + 'uri': '/v1/{parent=folders/*/locations/*}/eventThreatDetectionCustomModules:validate', + 'body': '*', + }, +{ + 'method': 'post', + 'uri': '/v1/{parent=organizations/*/locations/*}/eventThreatDetectionCustomModules:validate', + 'body': '*', + }, + ] + request, metadata = self._interceptor.pre_validate_event_threat_detection_custom_module(request, metadata) + pb_request = security_center_management.ValidateEventThreatDetectionCustomModuleRequest.pb(request) + transcoded_request = path_template.transcode(http_options, pb_request) + + # Jsonify the request body + + body = json_format.MessageToJson( + transcoded_request['body'], + including_default_value_fields=False, + use_integers_for_enums=True + ) + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json_format.MessageToJson( + transcoded_request['query_params'], + including_default_value_fields=False, + use_integers_for_enums=True, + )) + query_params.update(self._get_unset_required_fields(query_params)) + + query_params["$alt"] = "json;enum-encoding=int" + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params, strict=True), + data=body, + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + # Return the response + resp = security_center_management.ValidateEventThreatDetectionCustomModuleResponse() + pb_resp = security_center_management.ValidateEventThreatDetectionCustomModuleResponse.pb(resp) + + json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_validate_event_threat_detection_custom_module(resp) + return resp + + @property + def create_event_threat_detection_custom_module(self) -> Callable[ + [security_center_management.CreateEventThreatDetectionCustomModuleRequest], + security_center_management.EventThreatDetectionCustomModule]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._CreateEventThreatDetectionCustomModule(self._session, self._host, self._interceptor) # type: ignore + + @property + def create_security_health_analytics_custom_module(self) -> Callable[ + [security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest], + security_center_management.SecurityHealthAnalyticsCustomModule]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._CreateSecurityHealthAnalyticsCustomModule(self._session, self._host, self._interceptor) # type: ignore + + @property + def delete_event_threat_detection_custom_module(self) -> Callable[ + [security_center_management.DeleteEventThreatDetectionCustomModuleRequest], + empty_pb2.Empty]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._DeleteEventThreatDetectionCustomModule(self._session, self._host, self._interceptor) # type: ignore + + @property + def delete_security_health_analytics_custom_module(self) -> Callable[ + [security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest], + empty_pb2.Empty]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._DeleteSecurityHealthAnalyticsCustomModule(self._session, self._host, self._interceptor) # type: ignore + + @property + def get_effective_event_threat_detection_custom_module(self) -> Callable[ + [security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest], + security_center_management.EffectiveEventThreatDetectionCustomModule]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._GetEffectiveEventThreatDetectionCustomModule(self._session, self._host, self._interceptor) # type: ignore + + @property + def get_effective_security_health_analytics_custom_module(self) -> Callable[ + [security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest], + security_center_management.EffectiveSecurityHealthAnalyticsCustomModule]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._GetEffectiveSecurityHealthAnalyticsCustomModule(self._session, self._host, self._interceptor) # type: ignore + + @property + def get_event_threat_detection_custom_module(self) -> Callable[ + [security_center_management.GetEventThreatDetectionCustomModuleRequest], + security_center_management.EventThreatDetectionCustomModule]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._GetEventThreatDetectionCustomModule(self._session, self._host, self._interceptor) # type: ignore + + @property + def get_security_health_analytics_custom_module(self) -> Callable[ + [security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest], + security_center_management.SecurityHealthAnalyticsCustomModule]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._GetSecurityHealthAnalyticsCustomModule(self._session, self._host, self._interceptor) # type: ignore + + @property + def list_descendant_event_threat_detection_custom_modules(self) -> Callable[ + [security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest], + security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._ListDescendantEventThreatDetectionCustomModules(self._session, self._host, self._interceptor) # type: ignore + + @property + def list_descendant_security_health_analytics_custom_modules(self) -> Callable[ + [security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest], + security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._ListDescendantSecurityHealthAnalyticsCustomModules(self._session, self._host, self._interceptor) # type: ignore + + @property + def list_effective_event_threat_detection_custom_modules(self) -> Callable[ + [security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest], + security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._ListEffectiveEventThreatDetectionCustomModules(self._session, self._host, self._interceptor) # type: ignore + + @property + def list_effective_security_health_analytics_custom_modules(self) -> Callable[ + [security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest], + security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._ListEffectiveSecurityHealthAnalyticsCustomModules(self._session, self._host, self._interceptor) # type: ignore + + @property + def list_event_threat_detection_custom_modules(self) -> Callable[ + [security_center_management.ListEventThreatDetectionCustomModulesRequest], + security_center_management.ListEventThreatDetectionCustomModulesResponse]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._ListEventThreatDetectionCustomModules(self._session, self._host, self._interceptor) # type: ignore + + @property + def list_security_health_analytics_custom_modules(self) -> Callable[ + [security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest], + security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._ListSecurityHealthAnalyticsCustomModules(self._session, self._host, self._interceptor) # type: ignore + + @property + def simulate_security_health_analytics_custom_module(self) -> Callable[ + [security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest], + security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._SimulateSecurityHealthAnalyticsCustomModule(self._session, self._host, self._interceptor) # type: ignore + + @property + def update_event_threat_detection_custom_module(self) -> Callable[ + [security_center_management.UpdateEventThreatDetectionCustomModuleRequest], + security_center_management.EventThreatDetectionCustomModule]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._UpdateEventThreatDetectionCustomModule(self._session, self._host, self._interceptor) # type: ignore + + @property + def update_security_health_analytics_custom_module(self) -> Callable[ + [security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest], + security_center_management.SecurityHealthAnalyticsCustomModule]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._UpdateSecurityHealthAnalyticsCustomModule(self._session, self._host, self._interceptor) # type: ignore + + @property + def validate_event_threat_detection_custom_module(self) -> Callable[ + [security_center_management.ValidateEventThreatDetectionCustomModuleRequest], + security_center_management.ValidateEventThreatDetectionCustomModuleResponse]: + # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. + # In C++ this would require a dynamic_cast + return self._ValidateEventThreatDetectionCustomModule(self._session, self._host, self._interceptor) # type: ignore + + @property + def get_location(self): + return self._GetLocation(self._session, self._host, self._interceptor) # type: ignore + + class _GetLocation(SecurityCenterManagementRestStub): + def __call__(self, + request: locations_pb2.GetLocationRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> locations_pb2.Location: + + r"""Call the get location method over HTTP. + + Args: + request (locations_pb2.GetLocationRequest): + The request object for GetLocation method. + 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: + locations_pb2.Location: Response from GetLocation method. + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{name=projects/*/locations/*}', + }, + ] + + request, metadata = self._interceptor.pre_get_location(request, metadata) + request_kwargs = json_format.MessageToDict(request) + transcoded_request = path_template.transcode( + http_options, **request_kwargs) + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json.dumps(transcoded_request['query_params'])) + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + resp = locations_pb2.Location() + resp = json_format.Parse(response.content.decode("utf-8"), resp) + resp = self._interceptor.post_get_location(resp) + return resp + + @property + def list_locations(self): + return self._ListLocations(self._session, self._host, self._interceptor) # type: ignore + + class _ListLocations(SecurityCenterManagementRestStub): + def __call__(self, + request: locations_pb2.ListLocationsRequest, *, + retry: OptionalRetry=gapic_v1.method.DEFAULT, + timeout: Optional[float]=None, + metadata: Sequence[Tuple[str, str]]=(), + ) -> locations_pb2.ListLocationsResponse: + + r"""Call the list locations method over HTTP. + + Args: + request (locations_pb2.ListLocationsRequest): + The request object for ListLocations method. + 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: + locations_pb2.ListLocationsResponse: Response from ListLocations method. + """ + + http_options: List[Dict[str, str]] = [{ + 'method': 'get', + 'uri': '/v1/{name=projects/*}/locations', + }, + ] + + request, metadata = self._interceptor.pre_list_locations(request, metadata) + request_kwargs = json_format.MessageToDict(request) + transcoded_request = path_template.transcode( + http_options, **request_kwargs) + + uri = transcoded_request['uri'] + method = transcoded_request['method'] + + # Jsonify the query params + query_params = json.loads(json.dumps(transcoded_request['query_params'])) + + # Send the request + headers = dict(metadata) + headers['Content-Type'] = 'application/json' + + response = getattr(self._session, method)( + "{host}{uri}".format(host=self._host, uri=uri), + timeout=timeout, + headers=headers, + params=rest_helpers.flatten_query_params(query_params), + ) + + # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception + # subclass. + if response.status_code >= 400: + raise core_exceptions.from_http_response(response) + + resp = locations_pb2.ListLocationsResponse() + resp = json_format.Parse(response.content.decode("utf-8"), resp) + resp = self._interceptor.post_list_locations(resp) + return resp + + @property + def kind(self) -> str: + return "rest" + + def close(self): + self._session.close() + + +__all__=( + 'SecurityCenterManagementRestTransport', +) diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/types/__init__.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/types/__init__.py new file mode 100644 index 000000000000..f04c46589738 --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/types/__init__.py @@ -0,0 +1,84 @@ +# -*- 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. +# +from .security_center_management import ( + CreateEventThreatDetectionCustomModuleRequest, + CreateSecurityHealthAnalyticsCustomModuleRequest, + CustomConfig, + DeleteEventThreatDetectionCustomModuleRequest, + DeleteSecurityHealthAnalyticsCustomModuleRequest, + EffectiveEventThreatDetectionCustomModule, + EffectiveSecurityHealthAnalyticsCustomModule, + EventThreatDetectionCustomModule, + GetEffectiveEventThreatDetectionCustomModuleRequest, + GetEffectiveSecurityHealthAnalyticsCustomModuleRequest, + GetEventThreatDetectionCustomModuleRequest, + GetSecurityHealthAnalyticsCustomModuleRequest, + ListDescendantEventThreatDetectionCustomModulesRequest, + ListDescendantEventThreatDetectionCustomModulesResponse, + ListDescendantSecurityHealthAnalyticsCustomModulesRequest, + ListDescendantSecurityHealthAnalyticsCustomModulesResponse, + ListEffectiveEventThreatDetectionCustomModulesRequest, + ListEffectiveEventThreatDetectionCustomModulesResponse, + ListEffectiveSecurityHealthAnalyticsCustomModulesRequest, + ListEffectiveSecurityHealthAnalyticsCustomModulesResponse, + ListEventThreatDetectionCustomModulesRequest, + ListEventThreatDetectionCustomModulesResponse, + ListSecurityHealthAnalyticsCustomModulesRequest, + ListSecurityHealthAnalyticsCustomModulesResponse, + SecurityHealthAnalyticsCustomModule, + SimulatedFinding, + SimulateSecurityHealthAnalyticsCustomModuleRequest, + SimulateSecurityHealthAnalyticsCustomModuleResponse, + UpdateEventThreatDetectionCustomModuleRequest, + UpdateSecurityHealthAnalyticsCustomModuleRequest, + ValidateEventThreatDetectionCustomModuleRequest, + ValidateEventThreatDetectionCustomModuleResponse, +) + +__all__ = ( + 'CreateEventThreatDetectionCustomModuleRequest', + 'CreateSecurityHealthAnalyticsCustomModuleRequest', + 'CustomConfig', + 'DeleteEventThreatDetectionCustomModuleRequest', + 'DeleteSecurityHealthAnalyticsCustomModuleRequest', + 'EffectiveEventThreatDetectionCustomModule', + 'EffectiveSecurityHealthAnalyticsCustomModule', + 'EventThreatDetectionCustomModule', + 'GetEffectiveEventThreatDetectionCustomModuleRequest', + 'GetEffectiveSecurityHealthAnalyticsCustomModuleRequest', + 'GetEventThreatDetectionCustomModuleRequest', + 'GetSecurityHealthAnalyticsCustomModuleRequest', + 'ListDescendantEventThreatDetectionCustomModulesRequest', + 'ListDescendantEventThreatDetectionCustomModulesResponse', + 'ListDescendantSecurityHealthAnalyticsCustomModulesRequest', + 'ListDescendantSecurityHealthAnalyticsCustomModulesResponse', + 'ListEffectiveEventThreatDetectionCustomModulesRequest', + 'ListEffectiveEventThreatDetectionCustomModulesResponse', + 'ListEffectiveSecurityHealthAnalyticsCustomModulesRequest', + 'ListEffectiveSecurityHealthAnalyticsCustomModulesResponse', + 'ListEventThreatDetectionCustomModulesRequest', + 'ListEventThreatDetectionCustomModulesResponse', + 'ListSecurityHealthAnalyticsCustomModulesRequest', + 'ListSecurityHealthAnalyticsCustomModulesResponse', + 'SecurityHealthAnalyticsCustomModule', + 'SimulatedFinding', + 'SimulateSecurityHealthAnalyticsCustomModuleRequest', + 'SimulateSecurityHealthAnalyticsCustomModuleResponse', + 'UpdateEventThreatDetectionCustomModuleRequest', + 'UpdateSecurityHealthAnalyticsCustomModuleRequest', + 'ValidateEventThreatDetectionCustomModuleRequest', + 'ValidateEventThreatDetectionCustomModuleResponse', +) diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/types/security_center_management.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/types/security_center_management.py new file mode 100644 index 000000000000..9fc59ef014c3 --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/types/security_center_management.py @@ -0,0 +1,1771 @@ +# -*- 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. +# +from __future__ import annotations + +from typing import MutableMapping, MutableSequence + +import proto # type: ignore + +from google.iam.v1 import policy_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.rpc import status_pb2 # type: ignore +from google.type import expr_pb2 # type: ignore + + +__protobuf__ = proto.module( + package='google.cloud.securitycentermanagement.v1', + manifest={ + 'EffectiveSecurityHealthAnalyticsCustomModule', + 'ListEffectiveSecurityHealthAnalyticsCustomModulesRequest', + 'ListEffectiveSecurityHealthAnalyticsCustomModulesResponse', + 'GetEffectiveSecurityHealthAnalyticsCustomModuleRequest', + 'SecurityHealthAnalyticsCustomModule', + 'CustomConfig', + 'ListSecurityHealthAnalyticsCustomModulesRequest', + 'ListSecurityHealthAnalyticsCustomModulesResponse', + 'ListDescendantSecurityHealthAnalyticsCustomModulesRequest', + 'ListDescendantSecurityHealthAnalyticsCustomModulesResponse', + 'GetSecurityHealthAnalyticsCustomModuleRequest', + 'CreateSecurityHealthAnalyticsCustomModuleRequest', + 'UpdateSecurityHealthAnalyticsCustomModuleRequest', + 'DeleteSecurityHealthAnalyticsCustomModuleRequest', + 'SimulateSecurityHealthAnalyticsCustomModuleRequest', + 'SimulatedFinding', + 'SimulateSecurityHealthAnalyticsCustomModuleResponse', + 'EffectiveEventThreatDetectionCustomModule', + 'ListEffectiveEventThreatDetectionCustomModulesRequest', + 'ListEffectiveEventThreatDetectionCustomModulesResponse', + 'GetEffectiveEventThreatDetectionCustomModuleRequest', + 'EventThreatDetectionCustomModule', + 'ListEventThreatDetectionCustomModulesRequest', + 'ListEventThreatDetectionCustomModulesResponse', + 'ListDescendantEventThreatDetectionCustomModulesRequest', + 'ListDescendantEventThreatDetectionCustomModulesResponse', + 'GetEventThreatDetectionCustomModuleRequest', + 'CreateEventThreatDetectionCustomModuleRequest', + 'UpdateEventThreatDetectionCustomModuleRequest', + 'DeleteEventThreatDetectionCustomModuleRequest', + 'ValidateEventThreatDetectionCustomModuleRequest', + 'ValidateEventThreatDetectionCustomModuleResponse', + }, +) + + +class EffectiveSecurityHealthAnalyticsCustomModule(proto.Message): + r"""An EffectiveSecurityHealthAnalyticsCustomModule is the + representation of a Security Health Analytics custom module at a + specified level of the resource hierarchy: organization, folder, or + project. If a custom module is inherited from a parent organization + or folder, the value of the ``enablementState`` property in + EffectiveSecurityHealthAnalyticsCustomModule is set to the value + that is effective in the parent, instead of ``INHERITED``. For + example, if the module is enabled in a parent organization or + folder, the effective enablement_state for the module in all child + folders or projects is also ``enabled``. + EffectiveSecurityHealthAnalyticsCustomModule is read-only. + + Attributes: + name (str): + Output only. The resource name of the custom module. Its + format is + "organizations/{organization}/locations/{location}/effectiveSecurityHealthAnalyticsCustomModules/{effective_security_health_analytics_custom_module}", + or + "folders/{folder}/locations/{location}/effectiveSecurityHealthAnalyticsCustomModules/{effective_security_health_analytics_custom_module}", + or + "projects/{project}/locations/{location}/effectiveSecurityHealthAnalyticsCustomModules/{effective_security_health_analytics_custom_module}". + custom_config (google.cloud.securitycentermanagement_v1.types.CustomConfig): + Output only. The user-specified configuration + for the module. + enablement_state (google.cloud.securitycentermanagement_v1.types.EffectiveSecurityHealthAnalyticsCustomModule.EnablementState): + Output only. The effective state of + enablement for the module at the given level of + the hierarchy. + display_name (str): + Output only. The display name for the custom + module. The name must be between 1 and 128 + characters, start with a lowercase letter, and + contain alphanumeric characters or underscores + only. + """ + class EnablementState(proto.Enum): + r"""The enablement state of the module. + + Values: + ENABLEMENT_STATE_UNSPECIFIED (0): + Unspecified enablement state. + ENABLED (1): + The module is enabled at the given level. + DISABLED (2): + The module is disabled at the given level. + """ + ENABLEMENT_STATE_UNSPECIFIED = 0 + ENABLED = 1 + DISABLED = 2 + + name: str = proto.Field( + proto.STRING, + number=1, + ) + custom_config: 'CustomConfig' = proto.Field( + proto.MESSAGE, + number=2, + message='CustomConfig', + ) + enablement_state: EnablementState = proto.Field( + proto.ENUM, + number=3, + enum=EnablementState, + ) + display_name: str = proto.Field( + proto.STRING, + number=4, + ) + + +class ListEffectiveSecurityHealthAnalyticsCustomModulesRequest(proto.Message): + r"""Request message for listing effective Security Health + Analytics custom modules. + + Attributes: + parent (str): + Required. Name of parent to list effective + custom modules. Its format is + "organizations/{organization}/locations/{location}", + "folders/{folder}/locations/{location}", + or + "projects/{project}/locations/{location}". + page_size (int): + Optional. The maximum number of results to + return in a single response. Default is 10, + minimum is 1, maximum is 1000. + page_token (str): + Optional. The value returned by the last call + indicating a continuation + """ + + 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 ListEffectiveSecurityHealthAnalyticsCustomModulesResponse(proto.Message): + r"""Response message for listing effective Security Health + Analytics custom modules. + + Attributes: + effective_security_health_analytics_custom_modules (MutableSequence[google.cloud.securitycentermanagement_v1.types.EffectiveSecurityHealthAnalyticsCustomModule]): + The list of + EffectiveSecurityHealthAnalyticsCustomModule + next_page_token (str): + A token identifying a page of results the + server should return. + """ + + @property + def raw_page(self): + return self + + effective_security_health_analytics_custom_modules: MutableSequence['EffectiveSecurityHealthAnalyticsCustomModule'] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message='EffectiveSecurityHealthAnalyticsCustomModule', + ) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + + +class GetEffectiveSecurityHealthAnalyticsCustomModuleRequest(proto.Message): + r"""Message for getting a + EffectiveSecurityHealthAnalyticsCustomModule + + Attributes: + name (str): + Required. The resource name of the SHA custom module. + + Its format is: + + - "organizations/{organization}/locations/{location}/effectiveSecurityHealthAnalyticsCustomModules/{module_id}". + - "folders/{folder}/locations/{location}/effectiveSecurityHealthAnalyticsCustomModules/{module_id}". + - "projects/{project}/locations/{location}/effectiveSecurityHealthAnalyticsCustomModules/{module_id}". + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class SecurityHealthAnalyticsCustomModule(proto.Message): + r"""Represents an instance of a Security Health Analytics custom + module, including its full module name, display name, enablement + state, and last updated time. You can create a custom module at + the organization, folder, or project level. Custom modules that + you create at the organization or folder level are inherited by + the child folders and projects. + + Attributes: + name (str): + Immutable. The resource name of the custom module. Its + format is + "organizations/{organization}/locations/{location}/securityHealthAnalyticsCustomModules/{security_health_analytics_custom_module}", + or + "folders/{folder}/locations/{location}/securityHealthAnalyticsCustomModules/{security_health_analytics_custom_module}", + or + "projects/{project}/locations/{location}/securityHealthAnalyticsCustomModules/{security_health_analytics_custom_module}" + + The id {customModule} is server-generated and is not user + settable. It will be a numeric id containing 1-20 digits. + display_name (str): + Optional. The display name of the Security + Health Analytics custom module. This display + name becomes the finding category for all + findings that are returned by this custom + module. The display name must be between 1 and + 128 characters, start with a lowercase letter, + and contain alphanumeric characters or + underscores only. + enablement_state (google.cloud.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule.EnablementState): + Optional. The enablement state of the custom + module. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time at which the custom + module was last updated. + last_editor (str): + Output only. The editor that last updated the + custom module. + ancestor_module (str): + Output only. Specifies the organization or + folder from which the custom module is + inherited. If empty, indicates that the custom + module was created in the organization, folder, + or project in which you are viewing the custom + module. + custom_config (google.cloud.securitycentermanagement_v1.types.CustomConfig): + Optional. The user specified custom + configuration for the module. + """ + class EnablementState(proto.Enum): + r"""Possible enablement states of a custom module. + + Values: + ENABLEMENT_STATE_UNSPECIFIED (0): + Unspecified enablement state. + ENABLED (1): + The module is enabled at the given CRM + resource. + DISABLED (2): + The module is disabled at the given CRM + resource. + INHERITED (3): + State is inherited from an ancestor module. The module will + either be effectively ENABLED or DISABLED based on its + closest non-inherited ancestor module in the CRM hierarchy. + Attempting to set a top level module (module with no parent) + to the INHERITED state will result in an INVALID_ARGUMENT + error. + """ + ENABLEMENT_STATE_UNSPECIFIED = 0 + ENABLED = 1 + DISABLED = 2 + INHERITED = 3 + + name: str = proto.Field( + proto.STRING, + number=1, + ) + display_name: str = proto.Field( + proto.STRING, + number=2, + ) + enablement_state: EnablementState = proto.Field( + proto.ENUM, + number=3, + enum=EnablementState, + ) + update_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=4, + message=timestamp_pb2.Timestamp, + ) + last_editor: str = proto.Field( + proto.STRING, + number=5, + ) + ancestor_module: str = proto.Field( + proto.STRING, + number=6, + ) + custom_config: 'CustomConfig' = proto.Field( + proto.MESSAGE, + number=7, + message='CustomConfig', + ) + + +class CustomConfig(proto.Message): + r"""Defines the properties in a custom module configuration for + Security Health Analytics. Use the custom module configuration + to create custom detectors that generate custom findings for + resources that you specify. + + Attributes: + predicate (google.type.expr_pb2.Expr): + Optional. The CEL expression to evaluate to + produce findings. When the expression evaluates + to true against a resource, a finding is + generated. + custom_output (google.cloud.securitycentermanagement_v1.types.CustomConfig.CustomOutputSpec): + Optional. Custom output properties. + resource_selector (google.cloud.securitycentermanagement_v1.types.CustomConfig.ResourceSelector): + Optional. The CAI resource types that the + custom module operates on (see + go/gcp-cai-doc/supported-asset-types). Each + custom module can specify up to 5 resource + types. + severity (google.cloud.securitycentermanagement_v1.types.CustomConfig.Severity): + Optional. The severity to assign to findings + generated by the module. + description (str): + Optional. Text that describes the + vulnerability or misconfiguration that the + custom module detects. This explanation is + returned with each finding instance to help + investigators understand the detected issue. The + text must be enclosed in quotation marks. + recommendation (str): + Optional. An explanation of the recommended steps that + security teams can take to resolve the detected issue. This + explanation is returned with each finding generated by this + module in the ``nextSteps`` property of the finding JSON. + """ + class Severity(proto.Enum): + r"""Defines the valid value options for the severity of a + finding. + + Values: + SEVERITY_UNSPECIFIED (0): + Unspecified severity. + CRITICAL (1): + Critical severity. + HIGH (2): + High severity. + MEDIUM (3): + Medium severity. + LOW (4): + Low severity. + """ + SEVERITY_UNSPECIFIED = 0 + CRITICAL = 1 + HIGH = 2 + MEDIUM = 3 + LOW = 4 + + class CustomOutputSpec(proto.Message): + r"""A set of optional name-value pairs that define custom source + properties to return with each finding that is generated by the + custom module. The custom source properties that are defined here + are included in the finding JSON under ``sourceProperties``. + + Attributes: + properties (MutableSequence[google.cloud.securitycentermanagement_v1.types.CustomConfig.CustomOutputSpec.Property]): + Optional. A list of custom output properties + to add to the finding. + """ + + class Property(proto.Message): + r"""An individual name-value pair that defines a custom source + property. + + Attributes: + name (str): + Optional. Name of the property for the custom + output. + value_expression (google.type.expr_pb2.Expr): + Optional. The CEL expression for the custom + output. A resource property can be specified to + return the value of the property or a text + string enclosed in quotation marks. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + value_expression: expr_pb2.Expr = proto.Field( + proto.MESSAGE, + number=2, + message=expr_pb2.Expr, + ) + + properties: MutableSequence['CustomConfig.CustomOutputSpec.Property'] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message='CustomConfig.CustomOutputSpec.Property', + ) + + class ResourceSelector(proto.Message): + r"""Resource for selecting resource type. + + Attributes: + resource_types (MutableSequence[str]): + Optional. The resource types to run the + detector on. + """ + + resource_types: MutableSequence[str] = proto.RepeatedField( + proto.STRING, + number=1, + ) + + predicate: expr_pb2.Expr = proto.Field( + proto.MESSAGE, + number=1, + message=expr_pb2.Expr, + ) + custom_output: CustomOutputSpec = proto.Field( + proto.MESSAGE, + number=2, + message=CustomOutputSpec, + ) + resource_selector: ResourceSelector = proto.Field( + proto.MESSAGE, + number=3, + message=ResourceSelector, + ) + severity: Severity = proto.Field( + proto.ENUM, + number=4, + enum=Severity, + ) + description: str = proto.Field( + proto.STRING, + number=5, + ) + recommendation: str = proto.Field( + proto.STRING, + number=6, + ) + + +class ListSecurityHealthAnalyticsCustomModulesRequest(proto.Message): + r"""Request message for listing Security Health Analytics custom + modules. + + Attributes: + parent (str): + Required. Name of parent to list custom + modules. Its format is + "organizations/{organization}/locations/{location}", + "folders/{folder}/locations/{location}", + or + "projects/{project}/locations/{location}". + page_size (int): + Optional. The maximum number of results to + return in a single response. Default is 10, + minimum is 1, maximum is 1000. + page_token (str): + Optional. A token identifying a page of + results the server should return. + """ + + 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 ListSecurityHealthAnalyticsCustomModulesResponse(proto.Message): + r"""Response message for listing Security Health Analytics custom + modules. + + Attributes: + security_health_analytics_custom_modules (MutableSequence[google.cloud.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule]): + The list of + SecurityHealthAnalyticsCustomModules + next_page_token (str): + A token identifying a page of results the + server should return. + """ + + @property + def raw_page(self): + return self + + security_health_analytics_custom_modules: MutableSequence['SecurityHealthAnalyticsCustomModule'] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message='SecurityHealthAnalyticsCustomModule', + ) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + + +class ListDescendantSecurityHealthAnalyticsCustomModulesRequest(proto.Message): + r"""Request message for listing descendant Security Health + Analytics custom modules. + + Attributes: + parent (str): + Required. Name of parent to list custom + modules. Its format is + "organizations/{organization}/locations/{location}", + "folders/{folder}/locations/{location}", + or + "projects/{project}/locations/{location}". + page_size (int): + Optional. The maximum number of results to + return in a single response. Default is 10, + minimum is 1, maximum is 1000. + page_token (str): + Optional. A token identifying a page of + results the server should return. + """ + + 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 ListDescendantSecurityHealthAnalyticsCustomModulesResponse(proto.Message): + r"""Response message for listing descendant Security Health + Analytics custom modules. + + Attributes: + security_health_analytics_custom_modules (MutableSequence[google.cloud.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule]): + The list of + SecurityHealthAnalyticsCustomModules + next_page_token (str): + A token identifying a page of results the + server should return. + """ + + @property + def raw_page(self): + return self + + security_health_analytics_custom_modules: MutableSequence['SecurityHealthAnalyticsCustomModule'] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message='SecurityHealthAnalyticsCustomModule', + ) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + + +class GetSecurityHealthAnalyticsCustomModuleRequest(proto.Message): + r"""Message for getting a SecurityHealthAnalyticsCustomModule + + Attributes: + name (str): + Required. Name of the resource + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class CreateSecurityHealthAnalyticsCustomModuleRequest(proto.Message): + r"""Message for creating a SecurityHealthAnalyticsCustomModule + + Attributes: + parent (str): + Required. Name of the parent for the module. + Its format is + "organizations/{organization}/locations/{location}", + "folders/{folder}/locations/{location}", + or + "projects/{project}/locations/{location}". + security_health_analytics_custom_module (google.cloud.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule): + Required. The resource being created + validate_only (bool): + Optional. When set to true, only validations + (including IAM checks) will done for the request + (no module will be created). An OK response + indicates the request is valid while an error + response indicates the request is invalid. Note + that a subsequent request to actually create the + module could still fail because: + + 1. the state could have changed (e.g. IAM + permission lost) or + 2. A failure occurred during creation of the + module. Defaults to false. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + security_health_analytics_custom_module: 'SecurityHealthAnalyticsCustomModule' = proto.Field( + proto.MESSAGE, + number=2, + message='SecurityHealthAnalyticsCustomModule', + ) + validate_only: bool = proto.Field( + proto.BOOL, + number=3, + ) + + +class UpdateSecurityHealthAnalyticsCustomModuleRequest(proto.Message): + r"""Message for updating a SecurityHealthAnalyticsCustomModule + + Attributes: + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. Field mask is used to specify the fields to be + overwritten in the SecurityHealthAnalyticsCustomModule + resource by the update. The fields specified in the + update_mask are relative to the resource, not the full + request. A field will be overwritten if it is in the mask. + If the user does not provide a mask then all fields will be + overwritten. + security_health_analytics_custom_module (google.cloud.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule): + Required. The resource being updated + validate_only (bool): + Optional. When set to true, only validations + (including IAM checks) will done for the request + (module will not be updated). An OK response + indicates the request is valid while an error + response indicates the request is invalid. Note + that a subsequent request to actually update the + module could still fail because 1. the state + could have changed (e.g. IAM permission lost) or + 2. A failure occurred while trying to update the + module. + """ + + update_mask: field_mask_pb2.FieldMask = proto.Field( + proto.MESSAGE, + number=1, + message=field_mask_pb2.FieldMask, + ) + security_health_analytics_custom_module: 'SecurityHealthAnalyticsCustomModule' = proto.Field( + proto.MESSAGE, + number=2, + message='SecurityHealthAnalyticsCustomModule', + ) + validate_only: bool = proto.Field( + proto.BOOL, + number=3, + ) + + +class DeleteSecurityHealthAnalyticsCustomModuleRequest(proto.Message): + r"""Message for deleting a SecurityHealthAnalyticsCustomModule + + Attributes: + name (str): + Required. The resource name of the SHA custom module. + + Its format is: + + - "organizations/{organization}/locations/{location}/securityHealthAnalyticsCustomModules/{security_health_analytics_custom_module}". + - "folders/{folder}/locations/{location}/securityHealthAnalyticsCustomModules/{security_health_analytics_custom_module}". + - "projects/{project}/locations/{location}/securityHealthAnalyticsCustomModules/{security_health_analytics_custom_module}". + validate_only (bool): + Optional. When set to true, only validations + (including IAM checks) will done for the request + (module will not be deleted). An OK response + indicates the request is valid while an error + response indicates the request is invalid. Note + that a subsequent request to actually delete the + module could still fail because 1. the state + could have changed (e.g. IAM permission lost) or + 2. A failure occurred while trying to delete the + module. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + validate_only: bool = proto.Field( + proto.BOOL, + number=2, + ) + + +class SimulateSecurityHealthAnalyticsCustomModuleRequest(proto.Message): + r"""Request message to simulate a CustomConfig against a given + test resource. Maximum size of the request is 4 MB by default. + + Attributes: + parent (str): + Required. The relative resource name of the organization, + project, or folder. For more information about relative + resource names, see `Relative Resource + Name `__ + Example: ``organizations/{organization_id}``. + custom_config (google.cloud.securitycentermanagement_v1.types.CustomConfig): + Required. The custom configuration that you + need to test. + resource (google.cloud.securitycentermanagement_v1.types.SimulateSecurityHealthAnalyticsCustomModuleRequest.SimulatedResource): + Required. Resource data to simulate custom + module against. + """ + + class SimulatedResource(proto.Message): + r"""Manually constructed resource name. If the custom module evaluates + against only the resource data, you can omit the ``iam_policy_data`` + field. If it evaluates only the ``iam_policy_data`` field, you can + omit the resource data. + + Attributes: + resource_type (str): + Required. The type of the resource, for example, + ``compute.googleapis.com/Disk``. + resource_data (google.protobuf.struct_pb2.Struct): + Optional. A representation of the Google + Cloud resource. Should match the Google Cloud + resource JSON format. + iam_policy_data (google.iam.v1.policy_pb2.Policy): + Optional. A representation of the IAM policy. + """ + + resource_type: str = proto.Field( + proto.STRING, + number=1, + ) + resource_data: struct_pb2.Struct = proto.Field( + proto.MESSAGE, + number=2, + message=struct_pb2.Struct, + ) + iam_policy_data: policy_pb2.Policy = proto.Field( + proto.MESSAGE, + number=3, + message=policy_pb2.Policy, + ) + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + custom_config: 'CustomConfig' = proto.Field( + proto.MESSAGE, + number=2, + message='CustomConfig', + ) + resource: SimulatedResource = proto.Field( + proto.MESSAGE, + number=3, + message=SimulatedResource, + ) + + +class SimulatedFinding(proto.Message): + r"""A subset of the fields of the Security Center Finding proto. + The minimum set of fields needed to represent a simulated + finding from a SHA custom module. + + Attributes: + name (str): + Identifier. The `relative resource + name `__ + of the finding. Example: + "organizations/{organization_id}/sources/{source_id}/findings/{finding_id}", + "folders/{folder_id}/sources/{source_id}/findings/{finding_id}", + "projects/{project_id}/sources/{source_id}/findings/{finding_id}". + parent (str): + The relative resource name of the source the finding belongs + to. See: + https://cloud.google.com/apis/design/resource_names#relative_resource_name + This field is immutable after creation time. For example: + "organizations/{organization_id}/sources/{source_id}". + resource_name (str): + For findings on Google Cloud resources, the full resource + name of the Google Cloud resource this finding is for. See: + https://cloud.google.com/apis/design/resource_names#full_resource_name + When the finding is for a non-Google Cloud resource, the + resourceName can be a customer or partner defined string. + This field is immutable after creation time. + category (str): + The additional taxonomy group within findings from a given + source. This field is immutable after creation time. + Example: "XSS_FLASH_INJECTION". + state (google.cloud.securitycentermanagement_v1.types.SimulatedFinding.State): + Output only. The state of the finding. + source_properties (MutableMapping[str, google.protobuf.struct_pb2.Value]): + Source specific properties. These properties are managed by + the source that writes the finding. The key names in the + source_properties map must be between 1 and 255 characters, + and must start with a letter and contain alphanumeric + characters or underscores only. + event_time (google.protobuf.timestamp_pb2.Timestamp): + The time the finding was first detected. If + an existing finding is updated, then this is the + time the update occurred. For example, if the + finding represents an open firewall, this + property captures the time the detector believes + the firewall became open. The accuracy is + determined by the detector. If the finding is + later resolved, then this time reflects when the + finding was resolved. This must not be set to a + value greater than the current timestamp. + severity (google.cloud.securitycentermanagement_v1.types.SimulatedFinding.Severity): + The severity of the finding. This field is + managed by the source that writes the finding. + finding_class (google.cloud.securitycentermanagement_v1.types.SimulatedFinding.FindingClass): + The class of the finding. + """ + class State(proto.Enum): + r"""The state of the finding. + + Values: + STATE_UNSPECIFIED (0): + Unspecified state. + ACTIVE (1): + The finding requires attention and has not + been addressed yet. + INACTIVE (2): + The finding has been fixed, triaged as a + non-issue or otherwise addressed and is no + longer active. + """ + STATE_UNSPECIFIED = 0 + ACTIVE = 1 + INACTIVE = 2 + + class Severity(proto.Enum): + r"""The severity of the finding. + + Values: + SEVERITY_UNSPECIFIED (0): + This value is used for findings when a source + doesn't write a severity value. + CRITICAL (1): + Vulnerability: + + A critical vulnerability is easily discoverable + by an external actor, exploitable, and results + in the direct ability to execute arbitrary code, + exfiltrate data, and otherwise gain additional + access and privileges to cloud resources and + workloads. Examples include publicly accessible + unprotected user data and public SSH access with + weak or no passwords. + + Threat: + + Indicates a threat that is able to access, + modify, or delete data or execute unauthorized + code within existing resources. + HIGH (2): + Vulnerability: + + A high risk vulnerability can be easily + discovered and exploited in combination with + other vulnerabilities in order to gain direct + access and the ability to execute arbitrary + code, exfiltrate data, and otherwise gain + additional access and privileges to cloud + resources and workloads. An example is a + database with weak or no passwords that is only + accessible internally. This database could + easily be compromised by an actor that had + access to the internal network. + + Threat: + + Indicates a threat that is able to create new + computational resources in an environment but + not able to access data or execute code in + existing resources. + MEDIUM (3): + Vulnerability: + + A medium risk vulnerability could be used by an + actor to gain access to resources or privileges + that enable them to eventually (through multiple + steps or a complex exploit) gain access and the + ability to execute arbitrary code or exfiltrate + data. An example is a service account with + access to more projects than it should have. If + an actor gains access to the service account, + they could potentially use that access to + manipulate a project the service account was not + intended to. + + Threat: + + Indicates a threat that is able to cause + operational impact but may not access data or + execute unauthorized code. + LOW (4): + Vulnerability: + + A low risk vulnerability hampers a security + organization's ability to detect vulnerabilities + or active threats in their deployment, or + prevents the root cause investigation of + security issues. An example is monitoring and + logs being disabled for resource configurations + and access. + + Threat: + + Indicates a threat that has obtained minimal + access to an environment but is not able to + access data, execute code, or create resources. + """ + SEVERITY_UNSPECIFIED = 0 + CRITICAL = 1 + HIGH = 2 + MEDIUM = 3 + LOW = 4 + + class FindingClass(proto.Enum): + r"""Represents what kind of Finding it is. + + Values: + FINDING_CLASS_UNSPECIFIED (0): + Unspecified finding class. + THREAT (1): + Describes unwanted or malicious activity. + VULNERABILITY (2): + Describes a potential weakness in software + that increases risk to Confidentiality & + Integrity & Availability. + MISCONFIGURATION (3): + Describes a potential weakness in cloud + resource/asset configuration that increases + risk. + OBSERVATION (4): + Describes a security observation that is for + informational purposes. + SCC_ERROR (5): + Describes an error that prevents some SCC + functionality. + POSTURE_VIOLATION (6): + Describes a potential security risk due to a + change in the security posture. + """ + FINDING_CLASS_UNSPECIFIED = 0 + THREAT = 1 + VULNERABILITY = 2 + MISCONFIGURATION = 3 + OBSERVATION = 4 + SCC_ERROR = 5 + POSTURE_VIOLATION = 6 + + name: str = proto.Field( + proto.STRING, + number=1, + ) + parent: str = proto.Field( + proto.STRING, + number=2, + ) + resource_name: str = proto.Field( + proto.STRING, + number=3, + ) + category: str = proto.Field( + proto.STRING, + number=4, + ) + state: State = proto.Field( + proto.ENUM, + number=5, + enum=State, + ) + source_properties: MutableMapping[str, struct_pb2.Value] = proto.MapField( + proto.STRING, + proto.MESSAGE, + number=6, + message=struct_pb2.Value, + ) + event_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=7, + message=timestamp_pb2.Timestamp, + ) + severity: Severity = proto.Field( + proto.ENUM, + number=8, + enum=Severity, + ) + finding_class: FindingClass = proto.Field( + proto.ENUM, + number=9, + enum=FindingClass, + ) + + +class SimulateSecurityHealthAnalyticsCustomModuleResponse(proto.Message): + r"""Response message for simulating a + ``SecurityHealthAnalyticsCustomModule`` against a given resource. + + Attributes: + result (google.cloud.securitycentermanagement_v1.types.SimulateSecurityHealthAnalyticsCustomModuleResponse.SimulatedResult): + Result for test case in the corresponding + request. + """ + + class SimulatedResult(proto.Message): + r"""Possible test result. + + 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: + finding (google.cloud.securitycentermanagement_v1.types.SimulatedFinding): + Finding that would be published for the test + case, if a violation is detected. + + This field is a member of `oneof`_ ``result``. + no_violation (google.protobuf.empty_pb2.Empty): + Indicates that the test case does not trigger + any violation. + + This field is a member of `oneof`_ ``result``. + error (google.rpc.status_pb2.Status): + Error encountered during the test. + + This field is a member of `oneof`_ ``result``. + """ + + finding: 'SimulatedFinding' = proto.Field( + proto.MESSAGE, + number=1, + oneof='result', + message='SimulatedFinding', + ) + no_violation: empty_pb2.Empty = proto.Field( + proto.MESSAGE, + number=2, + oneof='result', + message=empty_pb2.Empty, + ) + error: status_pb2.Status = proto.Field( + proto.MESSAGE, + number=3, + oneof='result', + message=status_pb2.Status, + ) + + result: SimulatedResult = proto.Field( + proto.MESSAGE, + number=1, + message=SimulatedResult, + ) + + +class EffectiveEventThreatDetectionCustomModule(proto.Message): + r"""An EffectiveEventThreatDetectionCustomModule is the representation + of EventThreatDetectionCustomModule at a given level taking + hierarchy into account and resolving various fields accordingly. + e.g. if the module is enabled at the ancestor level, effective + modules at all descendant levels will have enablement_state set to + ENABLED. Similarly, if module.inherited is set, then effective + module's config will contain the ancestor's config details. + EffectiveEventThreatDetectionCustomModule is read-only. + + Attributes: + name (str): + Immutable. The resource name of the ETD custom module. + + Its format is: + + - "organizations/{organization}/locations/{location}/effectiveEventThreatDetectionCustomModules/{effective_event_threat_detection_custom_module}". + - "folders/{folder}/locations/{location}/effectiveEventThreatDetectionCustomModules/{effective_event_threat_detection_custom_module}". + - "projects/{project}/locations/{location}/effectiveEventThreatDetectionCustomModules/{effective_event_threat_detection_custom_module}". + config (google.protobuf.struct_pb2.Struct): + Output only. Config for the effective module. + enablement_state (google.cloud.securitycentermanagement_v1.types.EffectiveEventThreatDetectionCustomModule.EnablementState): + Output only. The effective state of + enablement for the module at the given level of + the hierarchy. + type_ (str): + Output only. Type for the module. e.g. CONFIGURABLE_BAD_IP. + display_name (str): + Output only. The human readable name to be + displayed for the module. + description (str): + Output only. The description for the module. + """ + class EnablementState(proto.Enum): + r"""The enablement state of the module. + + Values: + ENABLEMENT_STATE_UNSPECIFIED (0): + Unspecified enablement state. + ENABLED (1): + The module is enabled at the given level. + DISABLED (2): + The module is disabled at the given level. + """ + ENABLEMENT_STATE_UNSPECIFIED = 0 + ENABLED = 1 + DISABLED = 2 + + name: str = proto.Field( + proto.STRING, + number=1, + ) + config: struct_pb2.Struct = proto.Field( + proto.MESSAGE, + number=2, + message=struct_pb2.Struct, + ) + enablement_state: EnablementState = proto.Field( + proto.ENUM, + number=3, + enum=EnablementState, + ) + type_: str = proto.Field( + proto.STRING, + number=4, + ) + display_name: str = proto.Field( + proto.STRING, + number=5, + ) + description: str = proto.Field( + proto.STRING, + number=6, + ) + + +class ListEffectiveEventThreatDetectionCustomModulesRequest(proto.Message): + r"""Request message for listing effective Event Threat Detection + custom modules. + + Attributes: + parent (str): + Required. Name of parent to list effective + custom modules. Its format is + "organizations/{organization}/locations/{location}", + "folders/{folder}/locations/{location}", + or + "projects/{project}/locations/{location}". + page_size (int): + Optional. The maximum number of results to + return in a single response. Default is 10, + minimum is 1, maximum is 1000. + page_token (str): + Optional. The value returned by the last call + indicating a continuation + """ + + 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 ListEffectiveEventThreatDetectionCustomModulesResponse(proto.Message): + r"""Response message for listing effective Event Threat Detection + custom modules. + + Attributes: + effective_event_threat_detection_custom_modules (MutableSequence[google.cloud.securitycentermanagement_v1.types.EffectiveEventThreatDetectionCustomModule]): + The list of + EffectiveEventThreatDetectionCustomModules + next_page_token (str): + A token identifying a page of results the + server should return. + """ + + @property + def raw_page(self): + return self + + effective_event_threat_detection_custom_modules: MutableSequence['EffectiveEventThreatDetectionCustomModule'] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message='EffectiveEventThreatDetectionCustomModule', + ) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + + +class GetEffectiveEventThreatDetectionCustomModuleRequest(proto.Message): + r"""Message for getting a + EffectiveEventThreatDetectionCustomModule + + Attributes: + name (str): + Required. The resource name of the ETD custom module. + + Its format is: + + - "organizations/{organization}/locations/{location}/effectiveEventThreatDetectionCustomModules/{effective_event_threat_detection_custom_module}". + - "folders/{folder}/locations/{location}/effectiveEventThreatDetectionCustomModules/{effective_event_threat_detection_custom_module}". + - "projects/{project}/locations/{location}/effectiveEventThreatDetectionCustomModules/{effective_event_threat_detection_custom_module}". + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class EventThreatDetectionCustomModule(proto.Message): + r"""An event threat detection custom module is a Cloud SCC + resource that contains the configuration and enablement state of + a custom module, which enables ETD to write certain findings to + Cloud SCC. + + Attributes: + name (str): + Immutable. The resource name of the ETD custom module. + + Its format is: + + - "organizations/{organization}/locations/{location}/eventThreatDetectionCustomModules/{event_threat_detection_custom_module}". + - "folders/{folder}/locations/{location}/eventThreatDetectionCustomModules/{event_threat_detection_custom_module}". + - "projects/{project}/locations/{location}/eventThreatDetectionCustomModules/{event_threat_detection_custom_module}". + config (google.protobuf.struct_pb2.Struct): + Optional. Config for the module. For the + resident module, its config value is defined at + this level. For the inherited module, its config + value is inherited from the ancestor module. + ancestor_module (str): + Output only. The closest ancestor module that + this module inherits the enablement state from. + If empty, indicates that the custom module was + created in the requesting parent organization, + folder, or project. The format is the same as + the EventThreatDetectionCustomModule resource + name. + enablement_state (google.cloud.securitycentermanagement_v1.types.EventThreatDetectionCustomModule.EnablementState): + Optional. The state of enablement for the + module at the given level of the hierarchy. + type_ (str): + Optional. Type for the module. e.g. CONFIGURABLE_BAD_IP. + display_name (str): + Optional. The human readable name to be + displayed for the module. + description (str): + Optional. The description for the module. + update_time (google.protobuf.timestamp_pb2.Timestamp): + Output only. The time the module was last + updated. + last_editor (str): + Output only. The editor the module was last + updated by. + """ + class EnablementState(proto.Enum): + r"""The enablement state of the module. + + Values: + ENABLEMENT_STATE_UNSPECIFIED (0): + Unspecified enablement state. + ENABLED (1): + The module is enabled at the given level. + DISABLED (2): + The module is disabled at the given level. + INHERITED (3): + State is inherited from an ancestor module. + The module will either be effectively ENABLED or + DISABLED based on its closest non-inherited + ancestor module in the CRM hierarchy. Attempting + to set a top level module (module with no + parent) to the INHERITED state will result in an + error. + """ + ENABLEMENT_STATE_UNSPECIFIED = 0 + ENABLED = 1 + DISABLED = 2 + INHERITED = 3 + + name: str = proto.Field( + proto.STRING, + number=1, + ) + config: struct_pb2.Struct = proto.Field( + proto.MESSAGE, + number=2, + message=struct_pb2.Struct, + ) + ancestor_module: str = proto.Field( + proto.STRING, + number=3, + ) + enablement_state: EnablementState = proto.Field( + proto.ENUM, + number=4, + enum=EnablementState, + ) + type_: str = proto.Field( + proto.STRING, + number=5, + ) + display_name: str = proto.Field( + proto.STRING, + number=6, + ) + description: str = proto.Field( + proto.STRING, + number=7, + ) + update_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=8, + message=timestamp_pb2.Timestamp, + ) + last_editor: str = proto.Field( + proto.STRING, + number=9, + ) + + +class ListEventThreatDetectionCustomModulesRequest(proto.Message): + r"""Request message for listing Event Threat Detection custom + modules. + + Attributes: + parent (str): + Required. Name of parent to list custom + modules. Its format is + "organizations/{organization}/locations/{location}", + "folders/{folder}/locations/{location}", + or + "projects/{project}/locations/{location}". + page_size (int): + Optional. The maximum number of modules to + return. The service may return fewer than this + value. If unspecified, at most 10 configs will + be returned. The maximum value is 1000; values + above 1000 will be coerced to 1000. + page_token (str): + Optional. A page token, received from a previous + ``ListEventThreatDetectionCustomModules`` call. Provide this + to retrieve the subsequent page. + + When paginating, all other parameters provided to + ``ListEventThreatDetectionCustomModules`` must match the + call that provided the page token. + """ + + 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 ListEventThreatDetectionCustomModulesResponse(proto.Message): + r"""Response message for listing Event Threat Detection custom + modules. + + Attributes: + event_threat_detection_custom_modules (MutableSequence[google.cloud.securitycentermanagement_v1.types.EventThreatDetectionCustomModule]): + The list of EventThreatDetectionCustomModules + next_page_token (str): + A token identifying a page of results the + server should return. + """ + + @property + def raw_page(self): + return self + + event_threat_detection_custom_modules: MutableSequence['EventThreatDetectionCustomModule'] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message='EventThreatDetectionCustomModule', + ) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + + +class ListDescendantEventThreatDetectionCustomModulesRequest(proto.Message): + r"""Request message for listing descendant Event Threat Detection + custom modules. + + Attributes: + parent (str): + Required. Name of parent to list custom + modules. Its format is + "organizations/{organization}/locations/{location}", + "folders/{folder}/locations/{location}", + or + "projects/{project}/locations/{location}". + page_size (int): + Optional. The maximum number of modules to + return. The service may return fewer than this + value. If unspecified, at most 10 configs will + be returned. The maximum value is 1000; values + above 1000 will be coerced to 1000. + page_token (str): + Optional. A token identifying a page of + results the server should return. + """ + + 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 ListDescendantEventThreatDetectionCustomModulesResponse(proto.Message): + r"""Response message for listing descendant Event Threat + Detection custom modules. + + Attributes: + event_threat_detection_custom_modules (MutableSequence[google.cloud.securitycentermanagement_v1.types.EventThreatDetectionCustomModule]): + The list of EventThreatDetectionCustomModules + next_page_token (str): + A token identifying a page of results the + server should return. + """ + + @property + def raw_page(self): + return self + + event_threat_detection_custom_modules: MutableSequence['EventThreatDetectionCustomModule'] = proto.RepeatedField( + proto.MESSAGE, + number=1, + message='EventThreatDetectionCustomModule', + ) + next_page_token: str = proto.Field( + proto.STRING, + number=2, + ) + + +class GetEventThreatDetectionCustomModuleRequest(proto.Message): + r"""Message for getting a EventThreatDetectionCustomModule + + Attributes: + name (str): + Required. The resource name of the ETD custom module. + + Its format is: + + - "organizations/{organization}/locations/{location}/eventThreatDetectionCustomModules/{event_threat_detection_custom_module}". + - "folders/{folder}/locations/{location}/eventThreatDetectionCustomModules/{event_threat_detection_custom_module}". + - "projects/{project}/locations/{location}/eventThreatDetectionCustomModules/{event_threat_detection_custom_module}". + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + + +class CreateEventThreatDetectionCustomModuleRequest(proto.Message): + r"""Message for creating a EventThreatDetectionCustomModule + + Attributes: + parent (str): + Required. Name of parent for the module. Its + format is + "organizations/{organization}/locations/{location}", + "folders/{folder}/locations/{location}", + or + "projects/{project}/locations/{location}". + event_threat_detection_custom_module (google.cloud.securitycentermanagement_v1.types.EventThreatDetectionCustomModule): + Required. The module to create. The + event_threat_detection_custom_module.name will be ignored + and server generated. + validate_only (bool): + Optional. When set to true, only validations + (including IAM checks) will done for the request + (no module will be created). An OK response + indicates the request is valid while an error + response indicates the request is invalid. Note + that a subsequent request to actually create the + module could still fail because 1. the state + could have changed (e.g. IAM permission lost) or + 2. A failure occurred during creation of the + module. + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + event_threat_detection_custom_module: 'EventThreatDetectionCustomModule' = proto.Field( + proto.MESSAGE, + number=3, + message='EventThreatDetectionCustomModule', + ) + validate_only: bool = proto.Field( + proto.BOOL, + number=4, + ) + + +class UpdateEventThreatDetectionCustomModuleRequest(proto.Message): + r"""Message for updating a EventThreatDetectionCustomModule + + Attributes: + update_mask (google.protobuf.field_mask_pb2.FieldMask): + Required. Field mask is used to specify the fields to be + overwritten in the EventThreatDetectionCustomModule resource + by the update. The fields specified in the update_mask are + relative to the resource, not the full request. A field will + be overwritten if it is in the mask. If the user does not + provide a mask then all fields will be overwritten. + event_threat_detection_custom_module (google.cloud.securitycentermanagement_v1.types.EventThreatDetectionCustomModule): + Required. The module being updated + validate_only (bool): + Optional. When set to true, only validations + (including IAM checks) will done for the request + (module will not be updated). An OK response + indicates the request is valid while an error + response indicates the request is invalid. Note + that a subsequent request to actually update the + module could still fail because 1. the state + could have changed (e.g. IAM permission lost) or + 2. A failure occurred while trying to update the + module. + """ + + update_mask: field_mask_pb2.FieldMask = proto.Field( + proto.MESSAGE, + number=1, + message=field_mask_pb2.FieldMask, + ) + event_threat_detection_custom_module: 'EventThreatDetectionCustomModule' = proto.Field( + proto.MESSAGE, + number=2, + message='EventThreatDetectionCustomModule', + ) + validate_only: bool = proto.Field( + proto.BOOL, + number=3, + ) + + +class DeleteEventThreatDetectionCustomModuleRequest(proto.Message): + r"""Message for deleting a EventThreatDetectionCustomModule + + Attributes: + name (str): + Required. The resource name of the ETD custom module. + + Its format is: + + - "organizations/{organization}/locations/{location}/eventThreatDetectionCustomModules/{event_threat_detection_custom_module}". + - "folders/{folder}/locations/{location}/eventThreatDetectionCustomModules/{event_threat_detection_custom_module}". + - "projects/{project}/locations/{location}/eventThreatDetectionCustomModules/{event_threat_detection_custom_module}". + validate_only (bool): + Optional. When set to true, only validations + (including IAM checks) will done for the request + (module will not be deleted). An OK response + indicates the request is valid while an error + response indicates the request is invalid. Note + that a subsequent request to actually delete the + module could still fail because 1. the state + could have changed (e.g. IAM permission lost) or + 2. A failure occurred while trying to delete the + module. + """ + + name: str = proto.Field( + proto.STRING, + number=1, + ) + validate_only: bool = proto.Field( + proto.BOOL, + number=2, + ) + + +class ValidateEventThreatDetectionCustomModuleRequest(proto.Message): + r"""Request to validate an Event Threat Detection custom module. + + Attributes: + parent (str): + Required. Resource name of the parent to validate the Custom + Module under. + + Its format is: + + - "organizations/{organization}/locations/{location}". + raw_text (str): + Required. The raw text of the module's + contents. Used to generate error messages. + type_ (str): + Required. The type of the module (e.g. CONFIGURABLE_BAD_IP). + """ + + parent: str = proto.Field( + proto.STRING, + number=1, + ) + raw_text: str = proto.Field( + proto.STRING, + number=2, + ) + type_: str = proto.Field( + proto.STRING, + number=3, + ) + + +class ValidateEventThreatDetectionCustomModuleResponse(proto.Message): + r"""Response to validating an Event Threat Detection custom + module. + + Attributes: + errors (MutableSequence[google.cloud.securitycentermanagement_v1.types.ValidateEventThreatDetectionCustomModuleResponse.CustomModuleValidationError]): + A list of errors returned by the validator. + If the list is empty, there were no errors. + """ + + class CustomModuleValidationError(proto.Message): + r"""An error encountered while validating the uploaded + configuration of an Event Threat Detection Custom Module. + + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + description (str): + A description of the error, suitable for + human consumption. Required. + field_path (str): + The path, in RFC 8901 JSON Pointer format, to + the field that failed validation. This may be + left empty if no specific field is affected. + start (google.cloud.securitycentermanagement_v1.types.ValidateEventThreatDetectionCustomModuleResponse.Position): + The initial position of the error in the + uploaded text version of the module. This field + may be omitted if no specific position applies, + or if one could not be computed. + + This field is a member of `oneof`_ ``_start``. + end (google.cloud.securitycentermanagement_v1.types.ValidateEventThreatDetectionCustomModuleResponse.Position): + The end position of the error in the uploaded + text version of the module. This field may be + omitted if no specific position applies, or if + one could not be computed.. + + This field is a member of `oneof`_ ``_end``. + """ + + description: str = proto.Field( + proto.STRING, + number=1, + ) + field_path: str = proto.Field( + proto.STRING, + number=2, + ) + start: 'ValidateEventThreatDetectionCustomModuleResponse.Position' = proto.Field( + proto.MESSAGE, + number=3, + optional=True, + message='ValidateEventThreatDetectionCustomModuleResponse.Position', + ) + end: 'ValidateEventThreatDetectionCustomModuleResponse.Position' = proto.Field( + proto.MESSAGE, + number=4, + optional=True, + message='ValidateEventThreatDetectionCustomModuleResponse.Position', + ) + + class Position(proto.Message): + r"""A position in the uploaded text version of a module. + + Attributes: + line_number (int): + The line position in the text + column_number (int): + The column position in the line + """ + + line_number: int = proto.Field( + proto.INT32, + number=1, + ) + column_number: int = proto.Field( + proto.INT32, + number=2, + ) + + errors: MutableSequence[CustomModuleValidationError] = proto.RepeatedField( + proto.MESSAGE, + number=2, + message=CustomModuleValidationError, + ) + + +__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/mypy.ini b/owl-bot-staging/google-cloud-securitycentermanagement/v1/mypy.ini new file mode 100644 index 000000000000..574c5aed394b --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/mypy.ini @@ -0,0 +1,3 @@ +[mypy] +python_version = 3.7 +namespace_packages = True diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/noxfile.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/noxfile.py new file mode 100644 index 000000000000..295627896224 --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/noxfile.py @@ -0,0 +1,177 @@ +# -*- 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. +# +import os +import pathlib +import shutil +import subprocess +import sys + + +import nox # type: ignore + +ALL_PYTHON = [ + "3.7", + "3.8", + "3.9", + "3.10", + "3.11", + "3.12" +] + +CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() + +LOWER_BOUND_CONSTRAINTS_FILE = CURRENT_DIRECTORY / "constraints.txt" +PACKAGE_NAME = 'google-cloud-securitycentermanagement' + +BLACK_VERSION = "black==22.3.0" +BLACK_PATHS = ["docs", "google", "tests", "samples", "noxfile.py", "setup.py"] +DEFAULT_PYTHON_VERSION = "3.12" + +nox.sessions = [ + "unit", + "cover", + "mypy", + "check_lower_bounds" + # exclude update_lower_bounds from default + "docs", + "blacken", + "lint", +] + +@nox.session(python=ALL_PYTHON) +def unit(session): + """Run the unit test suite.""" + + session.install('coverage', 'pytest', 'pytest-cov', 'pytest-asyncio', 'asyncmock; python_version < "3.8"') + session.install('-e', '.') + + session.run( + 'py.test', + '--quiet', + '--cov=google/cloud/securitycentermanagement_v1/', + '--cov=tests/', + '--cov-config=.coveragerc', + '--cov-report=term', + '--cov-report=html', + os.path.join('tests', 'unit', ''.join(session.posargs)) + ) + + +@nox.session(python=DEFAULT_PYTHON_VERSION) +def cover(session): + """Run the final coverage report. + This outputs the coverage report aggregating coverage from the unit + test runs (not system test runs), and then erases coverage data. + """ + session.install("coverage", "pytest-cov") + session.run("coverage", "report", "--show-missing", "--fail-under=100") + + session.run("coverage", "erase") + + +@nox.session(python=ALL_PYTHON) +def mypy(session): + """Run the type checker.""" + session.install( + 'mypy', + 'types-requests', + 'types-protobuf' + ) + session.install('.') + session.run( + 'mypy', + '-p', + 'google', + ) + + +@nox.session +def update_lower_bounds(session): + """Update lower bounds in constraints.txt to match setup.py""" + session.install('google-cloud-testutils') + session.install('.') + + session.run( + 'lower-bound-checker', + 'update', + '--package-name', + PACKAGE_NAME, + '--constraints-file', + str(LOWER_BOUND_CONSTRAINTS_FILE), + ) + + +@nox.session +def check_lower_bounds(session): + """Check lower bounds in setup.py are reflected in constraints file""" + session.install('google-cloud-testutils') + session.install('.') + + session.run( + 'lower-bound-checker', + 'check', + '--package-name', + PACKAGE_NAME, + '--constraints-file', + str(LOWER_BOUND_CONSTRAINTS_FILE), + ) + +@nox.session(python=DEFAULT_PYTHON_VERSION) +def docs(session): + """Build the docs for this library.""" + + session.install("-e", ".") + session.install("sphinx==7.0.1", "alabaster", "recommonmark") + + shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True) + session.run( + "sphinx-build", + "-W", # warnings as errors + "-T", # show full traceback on exception + "-N", # no colors + "-b", + "html", + "-d", + os.path.join("docs", "_build", "doctrees", ""), + os.path.join("docs", ""), + os.path.join("docs", "_build", "html", ""), + ) + + +@nox.session(python=DEFAULT_PYTHON_VERSION) +def lint(session): + """Run linters. + + Returns a failure if the linters find linting errors or sufficiently + serious code quality issues. + """ + session.install("flake8", BLACK_VERSION) + session.run( + "black", + "--check", + *BLACK_PATHS, + ) + session.run("flake8", "google", "tests", "samples") + + +@nox.session(python=DEFAULT_PYTHON_VERSION) +def blacken(session): + """Run black. Format code to uniform standard.""" + session.install(BLACK_VERSION) + session.run( + "black", + *BLACK_PATHS, + ) diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_create_event_threat_detection_custom_module_async.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_create_event_threat_detection_custom_module_async.py new file mode 100644 index 000000000000..c967fe467d57 --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_create_event_threat_detection_custom_module_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 CreateEventThreatDetectionCustomModule +# 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-securitycentermanagement + + +# [START securitycentermanagement_v1_generated_SecurityCenterManagement_CreateEventThreatDetectionCustomModule_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 securitycentermanagement_v1 + + +async def sample_create_event_threat_detection_custom_module(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.CreateEventThreatDetectionCustomModuleRequest( + parent="parent_value", + ) + + # Make the request + response = await client.create_event_threat_detection_custom_module(request=request) + + # Handle the response + print(response) + +# [END securitycentermanagement_v1_generated_SecurityCenterManagement_CreateEventThreatDetectionCustomModule_async] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_create_event_threat_detection_custom_module_sync.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_create_event_threat_detection_custom_module_sync.py new file mode 100644 index 000000000000..be59c3f2a0c6 --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_create_event_threat_detection_custom_module_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 CreateEventThreatDetectionCustomModule +# 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-securitycentermanagement + + +# [START securitycentermanagement_v1_generated_SecurityCenterManagement_CreateEventThreatDetectionCustomModule_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 securitycentermanagement_v1 + + +def sample_create_event_threat_detection_custom_module(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.CreateEventThreatDetectionCustomModuleRequest( + parent="parent_value", + ) + + # Make the request + response = client.create_event_threat_detection_custom_module(request=request) + + # Handle the response + print(response) + +# [END securitycentermanagement_v1_generated_SecurityCenterManagement_CreateEventThreatDetectionCustomModule_sync] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_create_security_health_analytics_custom_module_async.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_create_security_health_analytics_custom_module_async.py new file mode 100644 index 000000000000..42e6609609ef --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_create_security_health_analytics_custom_module_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 CreateSecurityHealthAnalyticsCustomModule +# 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-securitycentermanagement + + +# [START securitycentermanagement_v1_generated_SecurityCenterManagement_CreateSecurityHealthAnalyticsCustomModule_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 securitycentermanagement_v1 + + +async def sample_create_security_health_analytics_custom_module(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.CreateSecurityHealthAnalyticsCustomModuleRequest( + parent="parent_value", + ) + + # Make the request + response = await client.create_security_health_analytics_custom_module(request=request) + + # Handle the response + print(response) + +# [END securitycentermanagement_v1_generated_SecurityCenterManagement_CreateSecurityHealthAnalyticsCustomModule_async] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_create_security_health_analytics_custom_module_sync.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_create_security_health_analytics_custom_module_sync.py new file mode 100644 index 000000000000..9bed1b55abf8 --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_create_security_health_analytics_custom_module_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 CreateSecurityHealthAnalyticsCustomModule +# 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-securitycentermanagement + + +# [START securitycentermanagement_v1_generated_SecurityCenterManagement_CreateSecurityHealthAnalyticsCustomModule_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 securitycentermanagement_v1 + + +def sample_create_security_health_analytics_custom_module(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.CreateSecurityHealthAnalyticsCustomModuleRequest( + parent="parent_value", + ) + + # Make the request + response = client.create_security_health_analytics_custom_module(request=request) + + # Handle the response + print(response) + +# [END securitycentermanagement_v1_generated_SecurityCenterManagement_CreateSecurityHealthAnalyticsCustomModule_sync] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_delete_event_threat_detection_custom_module_async.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_delete_event_threat_detection_custom_module_async.py new file mode 100644 index 000000000000..e628c0c2a012 --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_delete_event_threat_detection_custom_module_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 DeleteEventThreatDetectionCustomModule +# 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-securitycentermanagement + + +# [START securitycentermanagement_v1_generated_SecurityCenterManagement_DeleteEventThreatDetectionCustomModule_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 securitycentermanagement_v1 + + +async def sample_delete_event_threat_detection_custom_module(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.DeleteEventThreatDetectionCustomModuleRequest( + name="name_value", + ) + + # Make the request + await client.delete_event_threat_detection_custom_module(request=request) + + +# [END securitycentermanagement_v1_generated_SecurityCenterManagement_DeleteEventThreatDetectionCustomModule_async] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_delete_event_threat_detection_custom_module_sync.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_delete_event_threat_detection_custom_module_sync.py new file mode 100644 index 000000000000..24d967206eda --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_delete_event_threat_detection_custom_module_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 DeleteEventThreatDetectionCustomModule +# 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-securitycentermanagement + + +# [START securitycentermanagement_v1_generated_SecurityCenterManagement_DeleteEventThreatDetectionCustomModule_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 securitycentermanagement_v1 + + +def sample_delete_event_threat_detection_custom_module(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.DeleteEventThreatDetectionCustomModuleRequest( + name="name_value", + ) + + # Make the request + client.delete_event_threat_detection_custom_module(request=request) + + +# [END securitycentermanagement_v1_generated_SecurityCenterManagement_DeleteEventThreatDetectionCustomModule_sync] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_delete_security_health_analytics_custom_module_async.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_delete_security_health_analytics_custom_module_async.py new file mode 100644 index 000000000000..1ebe5c7aaabe --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_delete_security_health_analytics_custom_module_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 DeleteSecurityHealthAnalyticsCustomModule +# 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-securitycentermanagement + + +# [START securitycentermanagement_v1_generated_SecurityCenterManagement_DeleteSecurityHealthAnalyticsCustomModule_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 securitycentermanagement_v1 + + +async def sample_delete_security_health_analytics_custom_module(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.DeleteSecurityHealthAnalyticsCustomModuleRequest( + name="name_value", + ) + + # Make the request + await client.delete_security_health_analytics_custom_module(request=request) + + +# [END securitycentermanagement_v1_generated_SecurityCenterManagement_DeleteSecurityHealthAnalyticsCustomModule_async] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_delete_security_health_analytics_custom_module_sync.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_delete_security_health_analytics_custom_module_sync.py new file mode 100644 index 000000000000..7c6293d24466 --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_delete_security_health_analytics_custom_module_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 DeleteSecurityHealthAnalyticsCustomModule +# 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-securitycentermanagement + + +# [START securitycentermanagement_v1_generated_SecurityCenterManagement_DeleteSecurityHealthAnalyticsCustomModule_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 securitycentermanagement_v1 + + +def sample_delete_security_health_analytics_custom_module(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.DeleteSecurityHealthAnalyticsCustomModuleRequest( + name="name_value", + ) + + # Make the request + client.delete_security_health_analytics_custom_module(request=request) + + +# [END securitycentermanagement_v1_generated_SecurityCenterManagement_DeleteSecurityHealthAnalyticsCustomModule_sync] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_effective_event_threat_detection_custom_module_async.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_effective_event_threat_detection_custom_module_async.py new file mode 100644 index 000000000000..9ce55980d0ff --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_effective_event_threat_detection_custom_module_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 GetEffectiveEventThreatDetectionCustomModule +# 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-securitycentermanagement + + +# [START securitycentermanagement_v1_generated_SecurityCenterManagement_GetEffectiveEventThreatDetectionCustomModule_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 securitycentermanagement_v1 + + +async def sample_get_effective_event_threat_detection_custom_module(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.GetEffectiveEventThreatDetectionCustomModuleRequest( + name="name_value", + ) + + # Make the request + response = await client.get_effective_event_threat_detection_custom_module(request=request) + + # Handle the response + print(response) + +# [END securitycentermanagement_v1_generated_SecurityCenterManagement_GetEffectiveEventThreatDetectionCustomModule_async] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_effective_event_threat_detection_custom_module_sync.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_effective_event_threat_detection_custom_module_sync.py new file mode 100644 index 000000000000..9ff55729a3cf --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_effective_event_threat_detection_custom_module_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 GetEffectiveEventThreatDetectionCustomModule +# 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-securitycentermanagement + + +# [START securitycentermanagement_v1_generated_SecurityCenterManagement_GetEffectiveEventThreatDetectionCustomModule_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 securitycentermanagement_v1 + + +def sample_get_effective_event_threat_detection_custom_module(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.GetEffectiveEventThreatDetectionCustomModuleRequest( + name="name_value", + ) + + # Make the request + response = client.get_effective_event_threat_detection_custom_module(request=request) + + # Handle the response + print(response) + +# [END securitycentermanagement_v1_generated_SecurityCenterManagement_GetEffectiveEventThreatDetectionCustomModule_sync] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_effective_security_health_analytics_custom_module_async.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_effective_security_health_analytics_custom_module_async.py new file mode 100644 index 000000000000..2058072391fe --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_effective_security_health_analytics_custom_module_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 GetEffectiveSecurityHealthAnalyticsCustomModule +# 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-securitycentermanagement + + +# [START securitycentermanagement_v1_generated_SecurityCenterManagement_GetEffectiveSecurityHealthAnalyticsCustomModule_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 securitycentermanagement_v1 + + +async def sample_get_effective_security_health_analytics_custom_module(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest( + name="name_value", + ) + + # Make the request + response = await client.get_effective_security_health_analytics_custom_module(request=request) + + # Handle the response + print(response) + +# [END securitycentermanagement_v1_generated_SecurityCenterManagement_GetEffectiveSecurityHealthAnalyticsCustomModule_async] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_effective_security_health_analytics_custom_module_sync.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_effective_security_health_analytics_custom_module_sync.py new file mode 100644 index 000000000000..bf8826b475a1 --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_effective_security_health_analytics_custom_module_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 GetEffectiveSecurityHealthAnalyticsCustomModule +# 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-securitycentermanagement + + +# [START securitycentermanagement_v1_generated_SecurityCenterManagement_GetEffectiveSecurityHealthAnalyticsCustomModule_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 securitycentermanagement_v1 + + +def sample_get_effective_security_health_analytics_custom_module(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest( + name="name_value", + ) + + # Make the request + response = client.get_effective_security_health_analytics_custom_module(request=request) + + # Handle the response + print(response) + +# [END securitycentermanagement_v1_generated_SecurityCenterManagement_GetEffectiveSecurityHealthAnalyticsCustomModule_sync] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_event_threat_detection_custom_module_async.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_event_threat_detection_custom_module_async.py new file mode 100644 index 000000000000..7f85605372e2 --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_event_threat_detection_custom_module_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 GetEventThreatDetectionCustomModule +# 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-securitycentermanagement + + +# [START securitycentermanagement_v1_generated_SecurityCenterManagement_GetEventThreatDetectionCustomModule_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 securitycentermanagement_v1 + + +async def sample_get_event_threat_detection_custom_module(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.GetEventThreatDetectionCustomModuleRequest( + name="name_value", + ) + + # Make the request + response = await client.get_event_threat_detection_custom_module(request=request) + + # Handle the response + print(response) + +# [END securitycentermanagement_v1_generated_SecurityCenterManagement_GetEventThreatDetectionCustomModule_async] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_event_threat_detection_custom_module_sync.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_event_threat_detection_custom_module_sync.py new file mode 100644 index 000000000000..dec845db1712 --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_event_threat_detection_custom_module_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 GetEventThreatDetectionCustomModule +# 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-securitycentermanagement + + +# [START securitycentermanagement_v1_generated_SecurityCenterManagement_GetEventThreatDetectionCustomModule_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 securitycentermanagement_v1 + + +def sample_get_event_threat_detection_custom_module(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.GetEventThreatDetectionCustomModuleRequest( + name="name_value", + ) + + # Make the request + response = client.get_event_threat_detection_custom_module(request=request) + + # Handle the response + print(response) + +# [END securitycentermanagement_v1_generated_SecurityCenterManagement_GetEventThreatDetectionCustomModule_sync] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_security_health_analytics_custom_module_async.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_security_health_analytics_custom_module_async.py new file mode 100644 index 000000000000..768dd7bb766a --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_security_health_analytics_custom_module_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 GetSecurityHealthAnalyticsCustomModule +# 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-securitycentermanagement + + +# [START securitycentermanagement_v1_generated_SecurityCenterManagement_GetSecurityHealthAnalyticsCustomModule_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 securitycentermanagement_v1 + + +async def sample_get_security_health_analytics_custom_module(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.GetSecurityHealthAnalyticsCustomModuleRequest( + name="name_value", + ) + + # Make the request + response = await client.get_security_health_analytics_custom_module(request=request) + + # Handle the response + print(response) + +# [END securitycentermanagement_v1_generated_SecurityCenterManagement_GetSecurityHealthAnalyticsCustomModule_async] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_security_health_analytics_custom_module_sync.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_security_health_analytics_custom_module_sync.py new file mode 100644 index 000000000000..eae37c7729ab --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_security_health_analytics_custom_module_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 GetSecurityHealthAnalyticsCustomModule +# 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-securitycentermanagement + + +# [START securitycentermanagement_v1_generated_SecurityCenterManagement_GetSecurityHealthAnalyticsCustomModule_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 securitycentermanagement_v1 + + +def sample_get_security_health_analytics_custom_module(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.GetSecurityHealthAnalyticsCustomModuleRequest( + name="name_value", + ) + + # Make the request + response = client.get_security_health_analytics_custom_module(request=request) + + # Handle the response + print(response) + +# [END securitycentermanagement_v1_generated_SecurityCenterManagement_GetSecurityHealthAnalyticsCustomModule_sync] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_descendant_event_threat_detection_custom_modules_async.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_descendant_event_threat_detection_custom_modules_async.py new file mode 100644 index 000000000000..dcd0684a187e --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_descendant_event_threat_detection_custom_modules_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 ListDescendantEventThreatDetectionCustomModules +# 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-securitycentermanagement + + +# [START securitycentermanagement_v1_generated_SecurityCenterManagement_ListDescendantEventThreatDetectionCustomModules_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 securitycentermanagement_v1 + + +async def sample_list_descendant_event_threat_detection_custom_modules(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.ListDescendantEventThreatDetectionCustomModulesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_descendant_event_threat_detection_custom_modules(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END securitycentermanagement_v1_generated_SecurityCenterManagement_ListDescendantEventThreatDetectionCustomModules_async] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_descendant_event_threat_detection_custom_modules_sync.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_descendant_event_threat_detection_custom_modules_sync.py new file mode 100644 index 000000000000..0eca9fd0adb3 --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_descendant_event_threat_detection_custom_modules_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 ListDescendantEventThreatDetectionCustomModules +# 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-securitycentermanagement + + +# [START securitycentermanagement_v1_generated_SecurityCenterManagement_ListDescendantEventThreatDetectionCustomModules_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 securitycentermanagement_v1 + + +def sample_list_descendant_event_threat_detection_custom_modules(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.ListDescendantEventThreatDetectionCustomModulesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_descendant_event_threat_detection_custom_modules(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END securitycentermanagement_v1_generated_SecurityCenterManagement_ListDescendantEventThreatDetectionCustomModules_sync] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_descendant_security_health_analytics_custom_modules_async.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_descendant_security_health_analytics_custom_modules_async.py new file mode 100644 index 000000000000..1366af79fae3 --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_descendant_security_health_analytics_custom_modules_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 ListDescendantSecurityHealthAnalyticsCustomModules +# 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-securitycentermanagement + + +# [START securitycentermanagement_v1_generated_SecurityCenterManagement_ListDescendantSecurityHealthAnalyticsCustomModules_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 securitycentermanagement_v1 + + +async def sample_list_descendant_security_health_analytics_custom_modules(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.ListDescendantSecurityHealthAnalyticsCustomModulesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_descendant_security_health_analytics_custom_modules(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END securitycentermanagement_v1_generated_SecurityCenterManagement_ListDescendantSecurityHealthAnalyticsCustomModules_async] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_descendant_security_health_analytics_custom_modules_sync.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_descendant_security_health_analytics_custom_modules_sync.py new file mode 100644 index 000000000000..e153a54a40cf --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_descendant_security_health_analytics_custom_modules_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 ListDescendantSecurityHealthAnalyticsCustomModules +# 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-securitycentermanagement + + +# [START securitycentermanagement_v1_generated_SecurityCenterManagement_ListDescendantSecurityHealthAnalyticsCustomModules_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 securitycentermanagement_v1 + + +def sample_list_descendant_security_health_analytics_custom_modules(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.ListDescendantSecurityHealthAnalyticsCustomModulesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_descendant_security_health_analytics_custom_modules(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END securitycentermanagement_v1_generated_SecurityCenterManagement_ListDescendantSecurityHealthAnalyticsCustomModules_sync] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_effective_event_threat_detection_custom_modules_async.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_effective_event_threat_detection_custom_modules_async.py new file mode 100644 index 000000000000..1e36fc7b4be8 --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_effective_event_threat_detection_custom_modules_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 ListEffectiveEventThreatDetectionCustomModules +# 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-securitycentermanagement + + +# [START securitycentermanagement_v1_generated_SecurityCenterManagement_ListEffectiveEventThreatDetectionCustomModules_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 securitycentermanagement_v1 + + +async def sample_list_effective_event_threat_detection_custom_modules(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.ListEffectiveEventThreatDetectionCustomModulesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_effective_event_threat_detection_custom_modules(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END securitycentermanagement_v1_generated_SecurityCenterManagement_ListEffectiveEventThreatDetectionCustomModules_async] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_effective_event_threat_detection_custom_modules_sync.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_effective_event_threat_detection_custom_modules_sync.py new file mode 100644 index 000000000000..1b4514d693dc --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_effective_event_threat_detection_custom_modules_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 ListEffectiveEventThreatDetectionCustomModules +# 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-securitycentermanagement + + +# [START securitycentermanagement_v1_generated_SecurityCenterManagement_ListEffectiveEventThreatDetectionCustomModules_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 securitycentermanagement_v1 + + +def sample_list_effective_event_threat_detection_custom_modules(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.ListEffectiveEventThreatDetectionCustomModulesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_effective_event_threat_detection_custom_modules(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END securitycentermanagement_v1_generated_SecurityCenterManagement_ListEffectiveEventThreatDetectionCustomModules_sync] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_effective_security_health_analytics_custom_modules_async.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_effective_security_health_analytics_custom_modules_async.py new file mode 100644 index 000000000000..99890cad5845 --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_effective_security_health_analytics_custom_modules_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 ListEffectiveSecurityHealthAnalyticsCustomModules +# 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-securitycentermanagement + + +# [START securitycentermanagement_v1_generated_SecurityCenterManagement_ListEffectiveSecurityHealthAnalyticsCustomModules_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 securitycentermanagement_v1 + + +async def sample_list_effective_security_health_analytics_custom_modules(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_effective_security_health_analytics_custom_modules(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END securitycentermanagement_v1_generated_SecurityCenterManagement_ListEffectiveSecurityHealthAnalyticsCustomModules_async] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_effective_security_health_analytics_custom_modules_sync.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_effective_security_health_analytics_custom_modules_sync.py new file mode 100644 index 000000000000..360bf12b0349 --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_effective_security_health_analytics_custom_modules_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 ListEffectiveSecurityHealthAnalyticsCustomModules +# 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-securitycentermanagement + + +# [START securitycentermanagement_v1_generated_SecurityCenterManagement_ListEffectiveSecurityHealthAnalyticsCustomModules_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 securitycentermanagement_v1 + + +def sample_list_effective_security_health_analytics_custom_modules(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_effective_security_health_analytics_custom_modules(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END securitycentermanagement_v1_generated_SecurityCenterManagement_ListEffectiveSecurityHealthAnalyticsCustomModules_sync] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_event_threat_detection_custom_modules_async.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_event_threat_detection_custom_modules_async.py new file mode 100644 index 000000000000..342770053297 --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_event_threat_detection_custom_modules_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 ListEventThreatDetectionCustomModules +# 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-securitycentermanagement + + +# [START securitycentermanagement_v1_generated_SecurityCenterManagement_ListEventThreatDetectionCustomModules_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 securitycentermanagement_v1 + + +async def sample_list_event_threat_detection_custom_modules(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.ListEventThreatDetectionCustomModulesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_event_threat_detection_custom_modules(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END securitycentermanagement_v1_generated_SecurityCenterManagement_ListEventThreatDetectionCustomModules_async] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_event_threat_detection_custom_modules_sync.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_event_threat_detection_custom_modules_sync.py new file mode 100644 index 000000000000..930926c99d3e --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_event_threat_detection_custom_modules_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 ListEventThreatDetectionCustomModules +# 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-securitycentermanagement + + +# [START securitycentermanagement_v1_generated_SecurityCenterManagement_ListEventThreatDetectionCustomModules_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 securitycentermanagement_v1 + + +def sample_list_event_threat_detection_custom_modules(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.ListEventThreatDetectionCustomModulesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_event_threat_detection_custom_modules(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END securitycentermanagement_v1_generated_SecurityCenterManagement_ListEventThreatDetectionCustomModules_sync] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_security_health_analytics_custom_modules_async.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_security_health_analytics_custom_modules_async.py new file mode 100644 index 000000000000..5e670b94cd08 --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_security_health_analytics_custom_modules_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 ListSecurityHealthAnalyticsCustomModules +# 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-securitycentermanagement + + +# [START securitycentermanagement_v1_generated_SecurityCenterManagement_ListSecurityHealthAnalyticsCustomModules_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 securitycentermanagement_v1 + + +async def sample_list_security_health_analytics_custom_modules(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.ListSecurityHealthAnalyticsCustomModulesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_security_health_analytics_custom_modules(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END securitycentermanagement_v1_generated_SecurityCenterManagement_ListSecurityHealthAnalyticsCustomModules_async] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_security_health_analytics_custom_modules_sync.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_security_health_analytics_custom_modules_sync.py new file mode 100644 index 000000000000..ee54a8250216 --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_security_health_analytics_custom_modules_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 ListSecurityHealthAnalyticsCustomModules +# 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-securitycentermanagement + + +# [START securitycentermanagement_v1_generated_SecurityCenterManagement_ListSecurityHealthAnalyticsCustomModules_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 securitycentermanagement_v1 + + +def sample_list_security_health_analytics_custom_modules(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.ListSecurityHealthAnalyticsCustomModulesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_security_health_analytics_custom_modules(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END securitycentermanagement_v1_generated_SecurityCenterManagement_ListSecurityHealthAnalyticsCustomModules_sync] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_simulate_security_health_analytics_custom_module_async.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_simulate_security_health_analytics_custom_module_async.py new file mode 100644 index 000000000000..a6331f7231ec --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_simulate_security_health_analytics_custom_module_async.py @@ -0,0 +1,56 @@ +# -*- 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 SimulateSecurityHealthAnalyticsCustomModule +# 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-securitycentermanagement + + +# [START securitycentermanagement_v1_generated_SecurityCenterManagement_SimulateSecurityHealthAnalyticsCustomModule_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 securitycentermanagement_v1 + + +async def sample_simulate_security_health_analytics_custom_module(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() + + # Initialize request argument(s) + resource = securitycentermanagement_v1.SimulatedResource() + resource.resource_type = "resource_type_value" + + request = securitycentermanagement_v1.SimulateSecurityHealthAnalyticsCustomModuleRequest( + parent="parent_value", + resource=resource, + ) + + # Make the request + response = await client.simulate_security_health_analytics_custom_module(request=request) + + # Handle the response + print(response) + +# [END securitycentermanagement_v1_generated_SecurityCenterManagement_SimulateSecurityHealthAnalyticsCustomModule_async] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_simulate_security_health_analytics_custom_module_sync.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_simulate_security_health_analytics_custom_module_sync.py new file mode 100644 index 000000000000..ae16b2ed67a1 --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_simulate_security_health_analytics_custom_module_sync.py @@ -0,0 +1,56 @@ +# -*- 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 SimulateSecurityHealthAnalyticsCustomModule +# 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-securitycentermanagement + + +# [START securitycentermanagement_v1_generated_SecurityCenterManagement_SimulateSecurityHealthAnalyticsCustomModule_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 securitycentermanagement_v1 + + +def sample_simulate_security_health_analytics_custom_module(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementClient() + + # Initialize request argument(s) + resource = securitycentermanagement_v1.SimulatedResource() + resource.resource_type = "resource_type_value" + + request = securitycentermanagement_v1.SimulateSecurityHealthAnalyticsCustomModuleRequest( + parent="parent_value", + resource=resource, + ) + + # Make the request + response = client.simulate_security_health_analytics_custom_module(request=request) + + # Handle the response + print(response) + +# [END securitycentermanagement_v1_generated_SecurityCenterManagement_SimulateSecurityHealthAnalyticsCustomModule_sync] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_update_event_threat_detection_custom_module_async.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_update_event_threat_detection_custom_module_async.py new file mode 100644 index 000000000000..a7f9a8c8f88b --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_update_event_threat_detection_custom_module_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 UpdateEventThreatDetectionCustomModule +# 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-securitycentermanagement + + +# [START securitycentermanagement_v1_generated_SecurityCenterManagement_UpdateEventThreatDetectionCustomModule_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 securitycentermanagement_v1 + + +async def sample_update_event_threat_detection_custom_module(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.UpdateEventThreatDetectionCustomModuleRequest( + ) + + # Make the request + response = await client.update_event_threat_detection_custom_module(request=request) + + # Handle the response + print(response) + +# [END securitycentermanagement_v1_generated_SecurityCenterManagement_UpdateEventThreatDetectionCustomModule_async] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_update_event_threat_detection_custom_module_sync.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_update_event_threat_detection_custom_module_sync.py new file mode 100644 index 000000000000..36c12eebff9e --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_update_event_threat_detection_custom_module_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 UpdateEventThreatDetectionCustomModule +# 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-securitycentermanagement + + +# [START securitycentermanagement_v1_generated_SecurityCenterManagement_UpdateEventThreatDetectionCustomModule_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 securitycentermanagement_v1 + + +def sample_update_event_threat_detection_custom_module(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.UpdateEventThreatDetectionCustomModuleRequest( + ) + + # Make the request + response = client.update_event_threat_detection_custom_module(request=request) + + # Handle the response + print(response) + +# [END securitycentermanagement_v1_generated_SecurityCenterManagement_UpdateEventThreatDetectionCustomModule_sync] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_update_security_health_analytics_custom_module_async.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_update_security_health_analytics_custom_module_async.py new file mode 100644 index 000000000000..1ccf3db9d4fb --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_update_security_health_analytics_custom_module_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 UpdateSecurityHealthAnalyticsCustomModule +# 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-securitycentermanagement + + +# [START securitycentermanagement_v1_generated_SecurityCenterManagement_UpdateSecurityHealthAnalyticsCustomModule_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 securitycentermanagement_v1 + + +async def sample_update_security_health_analytics_custom_module(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.UpdateSecurityHealthAnalyticsCustomModuleRequest( + ) + + # Make the request + response = await client.update_security_health_analytics_custom_module(request=request) + + # Handle the response + print(response) + +# [END securitycentermanagement_v1_generated_SecurityCenterManagement_UpdateSecurityHealthAnalyticsCustomModule_async] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_update_security_health_analytics_custom_module_sync.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_update_security_health_analytics_custom_module_sync.py new file mode 100644 index 000000000000..f9b0a0c5509f --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_update_security_health_analytics_custom_module_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 UpdateSecurityHealthAnalyticsCustomModule +# 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-securitycentermanagement + + +# [START securitycentermanagement_v1_generated_SecurityCenterManagement_UpdateSecurityHealthAnalyticsCustomModule_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 securitycentermanagement_v1 + + +def sample_update_security_health_analytics_custom_module(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.UpdateSecurityHealthAnalyticsCustomModuleRequest( + ) + + # Make the request + response = client.update_security_health_analytics_custom_module(request=request) + + # Handle the response + print(response) + +# [END securitycentermanagement_v1_generated_SecurityCenterManagement_UpdateSecurityHealthAnalyticsCustomModule_sync] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_validate_event_threat_detection_custom_module_async.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_validate_event_threat_detection_custom_module_async.py new file mode 100644 index 000000000000..006c9e451079 --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_validate_event_threat_detection_custom_module_async.py @@ -0,0 +1,54 @@ +# -*- 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 ValidateEventThreatDetectionCustomModule +# 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-securitycentermanagement + + +# [START securitycentermanagement_v1_generated_SecurityCenterManagement_ValidateEventThreatDetectionCustomModule_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 securitycentermanagement_v1 + + +async def sample_validate_event_threat_detection_custom_module(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.ValidateEventThreatDetectionCustomModuleRequest( + parent="parent_value", + raw_text="raw_text_value", + type_="type__value", + ) + + # Make the request + response = await client.validate_event_threat_detection_custom_module(request=request) + + # Handle the response + print(response) + +# [END securitycentermanagement_v1_generated_SecurityCenterManagement_ValidateEventThreatDetectionCustomModule_async] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_validate_event_threat_detection_custom_module_sync.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_validate_event_threat_detection_custom_module_sync.py new file mode 100644 index 000000000000..9236fc49ec08 --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_validate_event_threat_detection_custom_module_sync.py @@ -0,0 +1,54 @@ +# -*- 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 ValidateEventThreatDetectionCustomModule +# 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-securitycentermanagement + + +# [START securitycentermanagement_v1_generated_SecurityCenterManagement_ValidateEventThreatDetectionCustomModule_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 securitycentermanagement_v1 + + +def sample_validate_event_threat_detection_custom_module(): + # Create a client + client = securitycentermanagement_v1.SecurityCenterManagementClient() + + # Initialize request argument(s) + request = securitycentermanagement_v1.ValidateEventThreatDetectionCustomModuleRequest( + parent="parent_value", + raw_text="raw_text_value", + type_="type__value", + ) + + # Make the request + response = client.validate_event_threat_detection_custom_module(request=request) + + # Handle the response + print(response) + +# [END securitycentermanagement_v1_generated_SecurityCenterManagement_ValidateEventThreatDetectionCustomModule_sync] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/snippet_metadata_google.cloud.securitycentermanagement.v1.json b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/snippet_metadata_google.cloud.securitycentermanagement.v1.json new file mode 100644 index 000000000000..8e50d8fef945 --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/snippet_metadata_google.cloud.securitycentermanagement.v1.json @@ -0,0 +1,2941 @@ +{ + "clientLibrary": { + "apis": [ + { + "id": "google.cloud.securitycentermanagement.v1", + "version": "v1" + } + ], + "language": "PYTHON", + "name": "google-cloud-securitycentermanagement", + "version": "0.1.0" + }, + "snippets": [ + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient", + "shortName": "SecurityCenterManagementAsyncClient" + }, + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient.create_event_threat_detection_custom_module", + "method": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.CreateEventThreatDetectionCustomModule", + "service": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "shortName": "SecurityCenterManagement" + }, + "shortName": "CreateEventThreatDetectionCustomModule" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securitycentermanagement_v1.types.CreateEventThreatDetectionCustomModuleRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "event_threat_detection_custom_module", + "type": "google.cloud.securitycentermanagement_v1.types.EventThreatDetectionCustomModule" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.securitycentermanagement_v1.types.EventThreatDetectionCustomModule", + "shortName": "create_event_threat_detection_custom_module" + }, + "description": "Sample for CreateEventThreatDetectionCustomModule", + "file": "securitycentermanagement_v1_generated_security_center_management_create_event_threat_detection_custom_module_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_CreateEventThreatDetectionCustomModule_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": "securitycentermanagement_v1_generated_security_center_management_create_event_threat_detection_custom_module_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient", + "shortName": "SecurityCenterManagementClient" + }, + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient.create_event_threat_detection_custom_module", + "method": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.CreateEventThreatDetectionCustomModule", + "service": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "shortName": "SecurityCenterManagement" + }, + "shortName": "CreateEventThreatDetectionCustomModule" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securitycentermanagement_v1.types.CreateEventThreatDetectionCustomModuleRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "event_threat_detection_custom_module", + "type": "google.cloud.securitycentermanagement_v1.types.EventThreatDetectionCustomModule" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.securitycentermanagement_v1.types.EventThreatDetectionCustomModule", + "shortName": "create_event_threat_detection_custom_module" + }, + "description": "Sample for CreateEventThreatDetectionCustomModule", + "file": "securitycentermanagement_v1_generated_security_center_management_create_event_threat_detection_custom_module_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_CreateEventThreatDetectionCustomModule_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": "securitycentermanagement_v1_generated_security_center_management_create_event_threat_detection_custom_module_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient", + "shortName": "SecurityCenterManagementAsyncClient" + }, + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient.create_security_health_analytics_custom_module", + "method": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.CreateSecurityHealthAnalyticsCustomModule", + "service": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "shortName": "SecurityCenterManagement" + }, + "shortName": "CreateSecurityHealthAnalyticsCustomModule" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securitycentermanagement_v1.types.CreateSecurityHealthAnalyticsCustomModuleRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "security_health_analytics_custom_module", + "type": "google.cloud.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule", + "shortName": "create_security_health_analytics_custom_module" + }, + "description": "Sample for CreateSecurityHealthAnalyticsCustomModule", + "file": "securitycentermanagement_v1_generated_security_center_management_create_security_health_analytics_custom_module_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_CreateSecurityHealthAnalyticsCustomModule_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": "securitycentermanagement_v1_generated_security_center_management_create_security_health_analytics_custom_module_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient", + "shortName": "SecurityCenterManagementClient" + }, + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient.create_security_health_analytics_custom_module", + "method": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.CreateSecurityHealthAnalyticsCustomModule", + "service": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "shortName": "SecurityCenterManagement" + }, + "shortName": "CreateSecurityHealthAnalyticsCustomModule" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securitycentermanagement_v1.types.CreateSecurityHealthAnalyticsCustomModuleRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "security_health_analytics_custom_module", + "type": "google.cloud.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule", + "shortName": "create_security_health_analytics_custom_module" + }, + "description": "Sample for CreateSecurityHealthAnalyticsCustomModule", + "file": "securitycentermanagement_v1_generated_security_center_management_create_security_health_analytics_custom_module_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_CreateSecurityHealthAnalyticsCustomModule_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": "securitycentermanagement_v1_generated_security_center_management_create_security_health_analytics_custom_module_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient", + "shortName": "SecurityCenterManagementAsyncClient" + }, + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient.delete_event_threat_detection_custom_module", + "method": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.DeleteEventThreatDetectionCustomModule", + "service": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "shortName": "SecurityCenterManagement" + }, + "shortName": "DeleteEventThreatDetectionCustomModule" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securitycentermanagement_v1.types.DeleteEventThreatDetectionCustomModuleRequest" + }, + { + "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_event_threat_detection_custom_module" + }, + "description": "Sample for DeleteEventThreatDetectionCustomModule", + "file": "securitycentermanagement_v1_generated_security_center_management_delete_event_threat_detection_custom_module_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_DeleteEventThreatDetectionCustomModule_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": "securitycentermanagement_v1_generated_security_center_management_delete_event_threat_detection_custom_module_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient", + "shortName": "SecurityCenterManagementClient" + }, + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient.delete_event_threat_detection_custom_module", + "method": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.DeleteEventThreatDetectionCustomModule", + "service": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "shortName": "SecurityCenterManagement" + }, + "shortName": "DeleteEventThreatDetectionCustomModule" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securitycentermanagement_v1.types.DeleteEventThreatDetectionCustomModuleRequest" + }, + { + "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_event_threat_detection_custom_module" + }, + "description": "Sample for DeleteEventThreatDetectionCustomModule", + "file": "securitycentermanagement_v1_generated_security_center_management_delete_event_threat_detection_custom_module_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_DeleteEventThreatDetectionCustomModule_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": "securitycentermanagement_v1_generated_security_center_management_delete_event_threat_detection_custom_module_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient", + "shortName": "SecurityCenterManagementAsyncClient" + }, + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient.delete_security_health_analytics_custom_module", + "method": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.DeleteSecurityHealthAnalyticsCustomModule", + "service": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "shortName": "SecurityCenterManagement" + }, + "shortName": "DeleteSecurityHealthAnalyticsCustomModule" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securitycentermanagement_v1.types.DeleteSecurityHealthAnalyticsCustomModuleRequest" + }, + { + "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_security_health_analytics_custom_module" + }, + "description": "Sample for DeleteSecurityHealthAnalyticsCustomModule", + "file": "securitycentermanagement_v1_generated_security_center_management_delete_security_health_analytics_custom_module_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_DeleteSecurityHealthAnalyticsCustomModule_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": "securitycentermanagement_v1_generated_security_center_management_delete_security_health_analytics_custom_module_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient", + "shortName": "SecurityCenterManagementClient" + }, + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient.delete_security_health_analytics_custom_module", + "method": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.DeleteSecurityHealthAnalyticsCustomModule", + "service": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "shortName": "SecurityCenterManagement" + }, + "shortName": "DeleteSecurityHealthAnalyticsCustomModule" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securitycentermanagement_v1.types.DeleteSecurityHealthAnalyticsCustomModuleRequest" + }, + { + "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_security_health_analytics_custom_module" + }, + "description": "Sample for DeleteSecurityHealthAnalyticsCustomModule", + "file": "securitycentermanagement_v1_generated_security_center_management_delete_security_health_analytics_custom_module_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_DeleteSecurityHealthAnalyticsCustomModule_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": "securitycentermanagement_v1_generated_security_center_management_delete_security_health_analytics_custom_module_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient", + "shortName": "SecurityCenterManagementAsyncClient" + }, + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient.get_effective_event_threat_detection_custom_module", + "method": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.GetEffectiveEventThreatDetectionCustomModule", + "service": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "shortName": "SecurityCenterManagement" + }, + "shortName": "GetEffectiveEventThreatDetectionCustomModule" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securitycentermanagement_v1.types.GetEffectiveEventThreatDetectionCustomModuleRequest" + }, + { + "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.securitycentermanagement_v1.types.EffectiveEventThreatDetectionCustomModule", + "shortName": "get_effective_event_threat_detection_custom_module" + }, + "description": "Sample for GetEffectiveEventThreatDetectionCustomModule", + "file": "securitycentermanagement_v1_generated_security_center_management_get_effective_event_threat_detection_custom_module_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_GetEffectiveEventThreatDetectionCustomModule_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": "securitycentermanagement_v1_generated_security_center_management_get_effective_event_threat_detection_custom_module_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient", + "shortName": "SecurityCenterManagementClient" + }, + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient.get_effective_event_threat_detection_custom_module", + "method": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.GetEffectiveEventThreatDetectionCustomModule", + "service": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "shortName": "SecurityCenterManagement" + }, + "shortName": "GetEffectiveEventThreatDetectionCustomModule" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securitycentermanagement_v1.types.GetEffectiveEventThreatDetectionCustomModuleRequest" + }, + { + "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.securitycentermanagement_v1.types.EffectiveEventThreatDetectionCustomModule", + "shortName": "get_effective_event_threat_detection_custom_module" + }, + "description": "Sample for GetEffectiveEventThreatDetectionCustomModule", + "file": "securitycentermanagement_v1_generated_security_center_management_get_effective_event_threat_detection_custom_module_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_GetEffectiveEventThreatDetectionCustomModule_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": "securitycentermanagement_v1_generated_security_center_management_get_effective_event_threat_detection_custom_module_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient", + "shortName": "SecurityCenterManagementAsyncClient" + }, + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient.get_effective_security_health_analytics_custom_module", + "method": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.GetEffectiveSecurityHealthAnalyticsCustomModule", + "service": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "shortName": "SecurityCenterManagement" + }, + "shortName": "GetEffectiveSecurityHealthAnalyticsCustomModule" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securitycentermanagement_v1.types.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest" + }, + { + "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.securitycentermanagement_v1.types.EffectiveSecurityHealthAnalyticsCustomModule", + "shortName": "get_effective_security_health_analytics_custom_module" + }, + "description": "Sample for GetEffectiveSecurityHealthAnalyticsCustomModule", + "file": "securitycentermanagement_v1_generated_security_center_management_get_effective_security_health_analytics_custom_module_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_GetEffectiveSecurityHealthAnalyticsCustomModule_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": "securitycentermanagement_v1_generated_security_center_management_get_effective_security_health_analytics_custom_module_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient", + "shortName": "SecurityCenterManagementClient" + }, + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient.get_effective_security_health_analytics_custom_module", + "method": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.GetEffectiveSecurityHealthAnalyticsCustomModule", + "service": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "shortName": "SecurityCenterManagement" + }, + "shortName": "GetEffectiveSecurityHealthAnalyticsCustomModule" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securitycentermanagement_v1.types.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest" + }, + { + "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.securitycentermanagement_v1.types.EffectiveSecurityHealthAnalyticsCustomModule", + "shortName": "get_effective_security_health_analytics_custom_module" + }, + "description": "Sample for GetEffectiveSecurityHealthAnalyticsCustomModule", + "file": "securitycentermanagement_v1_generated_security_center_management_get_effective_security_health_analytics_custom_module_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_GetEffectiveSecurityHealthAnalyticsCustomModule_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": "securitycentermanagement_v1_generated_security_center_management_get_effective_security_health_analytics_custom_module_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient", + "shortName": "SecurityCenterManagementAsyncClient" + }, + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient.get_event_threat_detection_custom_module", + "method": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.GetEventThreatDetectionCustomModule", + "service": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "shortName": "SecurityCenterManagement" + }, + "shortName": "GetEventThreatDetectionCustomModule" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securitycentermanagement_v1.types.GetEventThreatDetectionCustomModuleRequest" + }, + { + "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.securitycentermanagement_v1.types.EventThreatDetectionCustomModule", + "shortName": "get_event_threat_detection_custom_module" + }, + "description": "Sample for GetEventThreatDetectionCustomModule", + "file": "securitycentermanagement_v1_generated_security_center_management_get_event_threat_detection_custom_module_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_GetEventThreatDetectionCustomModule_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": "securitycentermanagement_v1_generated_security_center_management_get_event_threat_detection_custom_module_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient", + "shortName": "SecurityCenterManagementClient" + }, + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient.get_event_threat_detection_custom_module", + "method": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.GetEventThreatDetectionCustomModule", + "service": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "shortName": "SecurityCenterManagement" + }, + "shortName": "GetEventThreatDetectionCustomModule" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securitycentermanagement_v1.types.GetEventThreatDetectionCustomModuleRequest" + }, + { + "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.securitycentermanagement_v1.types.EventThreatDetectionCustomModule", + "shortName": "get_event_threat_detection_custom_module" + }, + "description": "Sample for GetEventThreatDetectionCustomModule", + "file": "securitycentermanagement_v1_generated_security_center_management_get_event_threat_detection_custom_module_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_GetEventThreatDetectionCustomModule_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": "securitycentermanagement_v1_generated_security_center_management_get_event_threat_detection_custom_module_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient", + "shortName": "SecurityCenterManagementAsyncClient" + }, + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient.get_security_health_analytics_custom_module", + "method": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.GetSecurityHealthAnalyticsCustomModule", + "service": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "shortName": "SecurityCenterManagement" + }, + "shortName": "GetSecurityHealthAnalyticsCustomModule" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securitycentermanagement_v1.types.GetSecurityHealthAnalyticsCustomModuleRequest" + }, + { + "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.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule", + "shortName": "get_security_health_analytics_custom_module" + }, + "description": "Sample for GetSecurityHealthAnalyticsCustomModule", + "file": "securitycentermanagement_v1_generated_security_center_management_get_security_health_analytics_custom_module_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_GetSecurityHealthAnalyticsCustomModule_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": "securitycentermanagement_v1_generated_security_center_management_get_security_health_analytics_custom_module_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient", + "shortName": "SecurityCenterManagementClient" + }, + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient.get_security_health_analytics_custom_module", + "method": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.GetSecurityHealthAnalyticsCustomModule", + "service": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "shortName": "SecurityCenterManagement" + }, + "shortName": "GetSecurityHealthAnalyticsCustomModule" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securitycentermanagement_v1.types.GetSecurityHealthAnalyticsCustomModuleRequest" + }, + { + "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.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule", + "shortName": "get_security_health_analytics_custom_module" + }, + "description": "Sample for GetSecurityHealthAnalyticsCustomModule", + "file": "securitycentermanagement_v1_generated_security_center_management_get_security_health_analytics_custom_module_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_GetSecurityHealthAnalyticsCustomModule_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": "securitycentermanagement_v1_generated_security_center_management_get_security_health_analytics_custom_module_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient", + "shortName": "SecurityCenterManagementAsyncClient" + }, + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient.list_descendant_event_threat_detection_custom_modules", + "method": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.ListDescendantEventThreatDetectionCustomModules", + "service": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "shortName": "SecurityCenterManagement" + }, + "shortName": "ListDescendantEventThreatDetectionCustomModules" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securitycentermanagement_v1.types.ListDescendantEventThreatDetectionCustomModulesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.securitycentermanagement_v1.services.security_center_management.pagers.ListDescendantEventThreatDetectionCustomModulesAsyncPager", + "shortName": "list_descendant_event_threat_detection_custom_modules" + }, + "description": "Sample for ListDescendantEventThreatDetectionCustomModules", + "file": "securitycentermanagement_v1_generated_security_center_management_list_descendant_event_threat_detection_custom_modules_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_ListDescendantEventThreatDetectionCustomModules_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "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": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securitycentermanagement_v1_generated_security_center_management_list_descendant_event_threat_detection_custom_modules_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient", + "shortName": "SecurityCenterManagementClient" + }, + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient.list_descendant_event_threat_detection_custom_modules", + "method": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.ListDescendantEventThreatDetectionCustomModules", + "service": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "shortName": "SecurityCenterManagement" + }, + "shortName": "ListDescendantEventThreatDetectionCustomModules" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securitycentermanagement_v1.types.ListDescendantEventThreatDetectionCustomModulesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.securitycentermanagement_v1.services.security_center_management.pagers.ListDescendantEventThreatDetectionCustomModulesPager", + "shortName": "list_descendant_event_threat_detection_custom_modules" + }, + "description": "Sample for ListDescendantEventThreatDetectionCustomModules", + "file": "securitycentermanagement_v1_generated_security_center_management_list_descendant_event_threat_detection_custom_modules_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_ListDescendantEventThreatDetectionCustomModules_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "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": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securitycentermanagement_v1_generated_security_center_management_list_descendant_event_threat_detection_custom_modules_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient", + "shortName": "SecurityCenterManagementAsyncClient" + }, + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient.list_descendant_security_health_analytics_custom_modules", + "method": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.ListDescendantSecurityHealthAnalyticsCustomModules", + "service": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "shortName": "SecurityCenterManagement" + }, + "shortName": "ListDescendantSecurityHealthAnalyticsCustomModules" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securitycentermanagement_v1.types.ListDescendantSecurityHealthAnalyticsCustomModulesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.securitycentermanagement_v1.services.security_center_management.pagers.ListDescendantSecurityHealthAnalyticsCustomModulesAsyncPager", + "shortName": "list_descendant_security_health_analytics_custom_modules" + }, + "description": "Sample for ListDescendantSecurityHealthAnalyticsCustomModules", + "file": "securitycentermanagement_v1_generated_security_center_management_list_descendant_security_health_analytics_custom_modules_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_ListDescendantSecurityHealthAnalyticsCustomModules_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "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": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securitycentermanagement_v1_generated_security_center_management_list_descendant_security_health_analytics_custom_modules_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient", + "shortName": "SecurityCenterManagementClient" + }, + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient.list_descendant_security_health_analytics_custom_modules", + "method": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.ListDescendantSecurityHealthAnalyticsCustomModules", + "service": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "shortName": "SecurityCenterManagement" + }, + "shortName": "ListDescendantSecurityHealthAnalyticsCustomModules" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securitycentermanagement_v1.types.ListDescendantSecurityHealthAnalyticsCustomModulesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.securitycentermanagement_v1.services.security_center_management.pagers.ListDescendantSecurityHealthAnalyticsCustomModulesPager", + "shortName": "list_descendant_security_health_analytics_custom_modules" + }, + "description": "Sample for ListDescendantSecurityHealthAnalyticsCustomModules", + "file": "securitycentermanagement_v1_generated_security_center_management_list_descendant_security_health_analytics_custom_modules_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_ListDescendantSecurityHealthAnalyticsCustomModules_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "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": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securitycentermanagement_v1_generated_security_center_management_list_descendant_security_health_analytics_custom_modules_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient", + "shortName": "SecurityCenterManagementAsyncClient" + }, + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient.list_effective_event_threat_detection_custom_modules", + "method": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.ListEffectiveEventThreatDetectionCustomModules", + "service": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "shortName": "SecurityCenterManagement" + }, + "shortName": "ListEffectiveEventThreatDetectionCustomModules" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securitycentermanagement_v1.types.ListEffectiveEventThreatDetectionCustomModulesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.securitycentermanagement_v1.services.security_center_management.pagers.ListEffectiveEventThreatDetectionCustomModulesAsyncPager", + "shortName": "list_effective_event_threat_detection_custom_modules" + }, + "description": "Sample for ListEffectiveEventThreatDetectionCustomModules", + "file": "securitycentermanagement_v1_generated_security_center_management_list_effective_event_threat_detection_custom_modules_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_ListEffectiveEventThreatDetectionCustomModules_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "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": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securitycentermanagement_v1_generated_security_center_management_list_effective_event_threat_detection_custom_modules_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient", + "shortName": "SecurityCenterManagementClient" + }, + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient.list_effective_event_threat_detection_custom_modules", + "method": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.ListEffectiveEventThreatDetectionCustomModules", + "service": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "shortName": "SecurityCenterManagement" + }, + "shortName": "ListEffectiveEventThreatDetectionCustomModules" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securitycentermanagement_v1.types.ListEffectiveEventThreatDetectionCustomModulesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.securitycentermanagement_v1.services.security_center_management.pagers.ListEffectiveEventThreatDetectionCustomModulesPager", + "shortName": "list_effective_event_threat_detection_custom_modules" + }, + "description": "Sample for ListEffectiveEventThreatDetectionCustomModules", + "file": "securitycentermanagement_v1_generated_security_center_management_list_effective_event_threat_detection_custom_modules_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_ListEffectiveEventThreatDetectionCustomModules_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "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": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securitycentermanagement_v1_generated_security_center_management_list_effective_event_threat_detection_custom_modules_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient", + "shortName": "SecurityCenterManagementAsyncClient" + }, + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient.list_effective_security_health_analytics_custom_modules", + "method": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.ListEffectiveSecurityHealthAnalyticsCustomModules", + "service": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "shortName": "SecurityCenterManagement" + }, + "shortName": "ListEffectiveSecurityHealthAnalyticsCustomModules" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securitycentermanagement_v1.types.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.securitycentermanagement_v1.services.security_center_management.pagers.ListEffectiveSecurityHealthAnalyticsCustomModulesAsyncPager", + "shortName": "list_effective_security_health_analytics_custom_modules" + }, + "description": "Sample for ListEffectiveSecurityHealthAnalyticsCustomModules", + "file": "securitycentermanagement_v1_generated_security_center_management_list_effective_security_health_analytics_custom_modules_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_ListEffectiveSecurityHealthAnalyticsCustomModules_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "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": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securitycentermanagement_v1_generated_security_center_management_list_effective_security_health_analytics_custom_modules_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient", + "shortName": "SecurityCenterManagementClient" + }, + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient.list_effective_security_health_analytics_custom_modules", + "method": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.ListEffectiveSecurityHealthAnalyticsCustomModules", + "service": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "shortName": "SecurityCenterManagement" + }, + "shortName": "ListEffectiveSecurityHealthAnalyticsCustomModules" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securitycentermanagement_v1.types.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.securitycentermanagement_v1.services.security_center_management.pagers.ListEffectiveSecurityHealthAnalyticsCustomModulesPager", + "shortName": "list_effective_security_health_analytics_custom_modules" + }, + "description": "Sample for ListEffectiveSecurityHealthAnalyticsCustomModules", + "file": "securitycentermanagement_v1_generated_security_center_management_list_effective_security_health_analytics_custom_modules_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_ListEffectiveSecurityHealthAnalyticsCustomModules_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "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": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securitycentermanagement_v1_generated_security_center_management_list_effective_security_health_analytics_custom_modules_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient", + "shortName": "SecurityCenterManagementAsyncClient" + }, + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient.list_event_threat_detection_custom_modules", + "method": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.ListEventThreatDetectionCustomModules", + "service": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "shortName": "SecurityCenterManagement" + }, + "shortName": "ListEventThreatDetectionCustomModules" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securitycentermanagement_v1.types.ListEventThreatDetectionCustomModulesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.securitycentermanagement_v1.services.security_center_management.pagers.ListEventThreatDetectionCustomModulesAsyncPager", + "shortName": "list_event_threat_detection_custom_modules" + }, + "description": "Sample for ListEventThreatDetectionCustomModules", + "file": "securitycentermanagement_v1_generated_security_center_management_list_event_threat_detection_custom_modules_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_ListEventThreatDetectionCustomModules_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "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": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securitycentermanagement_v1_generated_security_center_management_list_event_threat_detection_custom_modules_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient", + "shortName": "SecurityCenterManagementClient" + }, + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient.list_event_threat_detection_custom_modules", + "method": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.ListEventThreatDetectionCustomModules", + "service": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "shortName": "SecurityCenterManagement" + }, + "shortName": "ListEventThreatDetectionCustomModules" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securitycentermanagement_v1.types.ListEventThreatDetectionCustomModulesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.securitycentermanagement_v1.services.security_center_management.pagers.ListEventThreatDetectionCustomModulesPager", + "shortName": "list_event_threat_detection_custom_modules" + }, + "description": "Sample for ListEventThreatDetectionCustomModules", + "file": "securitycentermanagement_v1_generated_security_center_management_list_event_threat_detection_custom_modules_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_ListEventThreatDetectionCustomModules_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "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": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securitycentermanagement_v1_generated_security_center_management_list_event_threat_detection_custom_modules_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient", + "shortName": "SecurityCenterManagementAsyncClient" + }, + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient.list_security_health_analytics_custom_modules", + "method": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.ListSecurityHealthAnalyticsCustomModules", + "service": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "shortName": "SecurityCenterManagement" + }, + "shortName": "ListSecurityHealthAnalyticsCustomModules" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securitycentermanagement_v1.types.ListSecurityHealthAnalyticsCustomModulesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.securitycentermanagement_v1.services.security_center_management.pagers.ListSecurityHealthAnalyticsCustomModulesAsyncPager", + "shortName": "list_security_health_analytics_custom_modules" + }, + "description": "Sample for ListSecurityHealthAnalyticsCustomModules", + "file": "securitycentermanagement_v1_generated_security_center_management_list_security_health_analytics_custom_modules_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_ListSecurityHealthAnalyticsCustomModules_async", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "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": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securitycentermanagement_v1_generated_security_center_management_list_security_health_analytics_custom_modules_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient", + "shortName": "SecurityCenterManagementClient" + }, + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient.list_security_health_analytics_custom_modules", + "method": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.ListSecurityHealthAnalyticsCustomModules", + "service": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "shortName": "SecurityCenterManagement" + }, + "shortName": "ListSecurityHealthAnalyticsCustomModules" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securitycentermanagement_v1.types.ListSecurityHealthAnalyticsCustomModulesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.securitycentermanagement_v1.services.security_center_management.pagers.ListSecurityHealthAnalyticsCustomModulesPager", + "shortName": "list_security_health_analytics_custom_modules" + }, + "description": "Sample for ListSecurityHealthAnalyticsCustomModules", + "file": "securitycentermanagement_v1_generated_security_center_management_list_security_health_analytics_custom_modules_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_ListSecurityHealthAnalyticsCustomModules_sync", + "segments": [ + { + "end": 52, + "start": 27, + "type": "FULL" + }, + { + "end": 52, + "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": 53, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securitycentermanagement_v1_generated_security_center_management_list_security_health_analytics_custom_modules_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient", + "shortName": "SecurityCenterManagementAsyncClient" + }, + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient.simulate_security_health_analytics_custom_module", + "method": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.SimulateSecurityHealthAnalyticsCustomModule", + "service": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "shortName": "SecurityCenterManagement" + }, + "shortName": "SimulateSecurityHealthAnalyticsCustomModule" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securitycentermanagement_v1.types.SimulateSecurityHealthAnalyticsCustomModuleRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "custom_config", + "type": "google.cloud.securitycentermanagement_v1.types.CustomConfig" + }, + { + "name": "resource", + "type": "google.cloud.securitycentermanagement_v1.types.SimulateSecurityHealthAnalyticsCustomModuleRequest.SimulatedResource" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.securitycentermanagement_v1.types.SimulateSecurityHealthAnalyticsCustomModuleResponse", + "shortName": "simulate_security_health_analytics_custom_module" + }, + "description": "Sample for SimulateSecurityHealthAnalyticsCustomModule", + "file": "securitycentermanagement_v1_generated_security_center_management_simulate_security_health_analytics_custom_module_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_SimulateSecurityHealthAnalyticsCustomModule_async", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 49, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 50, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securitycentermanagement_v1_generated_security_center_management_simulate_security_health_analytics_custom_module_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient", + "shortName": "SecurityCenterManagementClient" + }, + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient.simulate_security_health_analytics_custom_module", + "method": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.SimulateSecurityHealthAnalyticsCustomModule", + "service": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "shortName": "SecurityCenterManagement" + }, + "shortName": "SimulateSecurityHealthAnalyticsCustomModule" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securitycentermanagement_v1.types.SimulateSecurityHealthAnalyticsCustomModuleRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "custom_config", + "type": "google.cloud.securitycentermanagement_v1.types.CustomConfig" + }, + { + "name": "resource", + "type": "google.cloud.securitycentermanagement_v1.types.SimulateSecurityHealthAnalyticsCustomModuleRequest.SimulatedResource" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.securitycentermanagement_v1.types.SimulateSecurityHealthAnalyticsCustomModuleResponse", + "shortName": "simulate_security_health_analytics_custom_module" + }, + "description": "Sample for SimulateSecurityHealthAnalyticsCustomModule", + "file": "securitycentermanagement_v1_generated_security_center_management_simulate_security_health_analytics_custom_module_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_SimulateSecurityHealthAnalyticsCustomModule_sync", + "segments": [ + { + "end": 55, + "start": 27, + "type": "FULL" + }, + { + "end": 55, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 49, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 52, + "start": 50, + "type": "REQUEST_EXECUTION" + }, + { + "end": 56, + "start": 53, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securitycentermanagement_v1_generated_security_center_management_simulate_security_health_analytics_custom_module_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient", + "shortName": "SecurityCenterManagementAsyncClient" + }, + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient.update_event_threat_detection_custom_module", + "method": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.UpdateEventThreatDetectionCustomModule", + "service": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "shortName": "SecurityCenterManagement" + }, + "shortName": "UpdateEventThreatDetectionCustomModule" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securitycentermanagement_v1.types.UpdateEventThreatDetectionCustomModuleRequest" + }, + { + "name": "event_threat_detection_custom_module", + "type": "google.cloud.securitycentermanagement_v1.types.EventThreatDetectionCustomModule" + }, + { + "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.securitycentermanagement_v1.types.EventThreatDetectionCustomModule", + "shortName": "update_event_threat_detection_custom_module" + }, + "description": "Sample for UpdateEventThreatDetectionCustomModule", + "file": "securitycentermanagement_v1_generated_security_center_management_update_event_threat_detection_custom_module_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_UpdateEventThreatDetectionCustomModule_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": "securitycentermanagement_v1_generated_security_center_management_update_event_threat_detection_custom_module_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient", + "shortName": "SecurityCenterManagementClient" + }, + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient.update_event_threat_detection_custom_module", + "method": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.UpdateEventThreatDetectionCustomModule", + "service": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "shortName": "SecurityCenterManagement" + }, + "shortName": "UpdateEventThreatDetectionCustomModule" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securitycentermanagement_v1.types.UpdateEventThreatDetectionCustomModuleRequest" + }, + { + "name": "event_threat_detection_custom_module", + "type": "google.cloud.securitycentermanagement_v1.types.EventThreatDetectionCustomModule" + }, + { + "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.securitycentermanagement_v1.types.EventThreatDetectionCustomModule", + "shortName": "update_event_threat_detection_custom_module" + }, + "description": "Sample for UpdateEventThreatDetectionCustomModule", + "file": "securitycentermanagement_v1_generated_security_center_management_update_event_threat_detection_custom_module_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_UpdateEventThreatDetectionCustomModule_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": "securitycentermanagement_v1_generated_security_center_management_update_event_threat_detection_custom_module_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient", + "shortName": "SecurityCenterManagementAsyncClient" + }, + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient.update_security_health_analytics_custom_module", + "method": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.UpdateSecurityHealthAnalyticsCustomModule", + "service": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "shortName": "SecurityCenterManagement" + }, + "shortName": "UpdateSecurityHealthAnalyticsCustomModule" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securitycentermanagement_v1.types.UpdateSecurityHealthAnalyticsCustomModuleRequest" + }, + { + "name": "security_health_analytics_custom_module", + "type": "google.cloud.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule" + }, + { + "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.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule", + "shortName": "update_security_health_analytics_custom_module" + }, + "description": "Sample for UpdateSecurityHealthAnalyticsCustomModule", + "file": "securitycentermanagement_v1_generated_security_center_management_update_security_health_analytics_custom_module_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_UpdateSecurityHealthAnalyticsCustomModule_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": "securitycentermanagement_v1_generated_security_center_management_update_security_health_analytics_custom_module_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient", + "shortName": "SecurityCenterManagementClient" + }, + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient.update_security_health_analytics_custom_module", + "method": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.UpdateSecurityHealthAnalyticsCustomModule", + "service": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "shortName": "SecurityCenterManagement" + }, + "shortName": "UpdateSecurityHealthAnalyticsCustomModule" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securitycentermanagement_v1.types.UpdateSecurityHealthAnalyticsCustomModuleRequest" + }, + { + "name": "security_health_analytics_custom_module", + "type": "google.cloud.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule" + }, + { + "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.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule", + "shortName": "update_security_health_analytics_custom_module" + }, + "description": "Sample for UpdateSecurityHealthAnalyticsCustomModule", + "file": "securitycentermanagement_v1_generated_security_center_management_update_security_health_analytics_custom_module_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_UpdateSecurityHealthAnalyticsCustomModule_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": "securitycentermanagement_v1_generated_security_center_management_update_security_health_analytics_custom_module_sync.py" + }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient", + "shortName": "SecurityCenterManagementAsyncClient" + }, + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient.validate_event_threat_detection_custom_module", + "method": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.ValidateEventThreatDetectionCustomModule", + "service": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "shortName": "SecurityCenterManagement" + }, + "shortName": "ValidateEventThreatDetectionCustomModule" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securitycentermanagement_v1.types.ValidateEventThreatDetectionCustomModuleRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.securitycentermanagement_v1.types.ValidateEventThreatDetectionCustomModuleResponse", + "shortName": "validate_event_threat_detection_custom_module" + }, + "description": "Sample for ValidateEventThreatDetectionCustomModule", + "file": "securitycentermanagement_v1_generated_security_center_management_validate_event_threat_detection_custom_module_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_ValidateEventThreatDetectionCustomModule_async", + "segments": [ + { + "end": 53, + "start": 27, + "type": "FULL" + }, + { + "end": 53, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 47, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 50, + "start": 48, + "type": "REQUEST_EXECUTION" + }, + { + "end": 54, + "start": 51, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securitycentermanagement_v1_generated_security_center_management_validate_event_threat_detection_custom_module_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient", + "shortName": "SecurityCenterManagementClient" + }, + "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient.validate_event_threat_detection_custom_module", + "method": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.ValidateEventThreatDetectionCustomModule", + "service": { + "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", + "shortName": "SecurityCenterManagement" + }, + "shortName": "ValidateEventThreatDetectionCustomModule" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.securitycentermanagement_v1.types.ValidateEventThreatDetectionCustomModuleRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.securitycentermanagement_v1.types.ValidateEventThreatDetectionCustomModuleResponse", + "shortName": "validate_event_threat_detection_custom_module" + }, + "description": "Sample for ValidateEventThreatDetectionCustomModule", + "file": "securitycentermanagement_v1_generated_security_center_management_validate_event_threat_detection_custom_module_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_ValidateEventThreatDetectionCustomModule_sync", + "segments": [ + { + "end": 53, + "start": 27, + "type": "FULL" + }, + { + "end": 53, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 47, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 50, + "start": 48, + "type": "REQUEST_EXECUTION" + }, + { + "end": 54, + "start": 51, + "type": "RESPONSE_HANDLING" + } + ], + "title": "securitycentermanagement_v1_generated_security_center_management_validate_event_threat_detection_custom_module_sync.py" + } + ] +} diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/scripts/fixup_securitycentermanagement_v1_keywords.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/scripts/fixup_securitycentermanagement_v1_keywords.py new file mode 100644 index 000000000000..778802ae9931 --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/scripts/fixup_securitycentermanagement_v1_keywords.py @@ -0,0 +1,193 @@ +#! /usr/bin/env python3 +# -*- 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. +# +import argparse +import os +import libcst as cst +import pathlib +import sys +from typing import (Any, Callable, Dict, List, Sequence, Tuple) + + +def partition( + predicate: Callable[[Any], bool], + iterator: Sequence[Any] +) -> Tuple[List[Any], List[Any]]: + """A stable, out-of-place partition.""" + results = ([], []) + + for i in iterator: + results[int(predicate(i))].append(i) + + # Returns trueList, falseList + return results[1], results[0] + + +class securitycentermanagementCallTransformer(cst.CSTTransformer): + CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') + METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { + 'create_event_threat_detection_custom_module': ('parent', 'event_threat_detection_custom_module', 'validate_only', ), + 'create_security_health_analytics_custom_module': ('parent', 'security_health_analytics_custom_module', 'validate_only', ), + 'delete_event_threat_detection_custom_module': ('name', 'validate_only', ), + 'delete_security_health_analytics_custom_module': ('name', 'validate_only', ), + 'get_effective_event_threat_detection_custom_module': ('name', ), + 'get_effective_security_health_analytics_custom_module': ('name', ), + 'get_event_threat_detection_custom_module': ('name', ), + 'get_security_health_analytics_custom_module': ('name', ), + 'list_descendant_event_threat_detection_custom_modules': ('parent', 'page_size', 'page_token', ), + 'list_descendant_security_health_analytics_custom_modules': ('parent', 'page_size', 'page_token', ), + 'list_effective_event_threat_detection_custom_modules': ('parent', 'page_size', 'page_token', ), + 'list_effective_security_health_analytics_custom_modules': ('parent', 'page_size', 'page_token', ), + 'list_event_threat_detection_custom_modules': ('parent', 'page_size', 'page_token', ), + 'list_security_health_analytics_custom_modules': ('parent', 'page_size', 'page_token', ), + 'simulate_security_health_analytics_custom_module': ('parent', 'custom_config', 'resource', ), + 'update_event_threat_detection_custom_module': ('update_mask', 'event_threat_detection_custom_module', 'validate_only', ), + 'update_security_health_analytics_custom_module': ('update_mask', 'security_health_analytics_custom_module', 'validate_only', ), + 'validate_event_threat_detection_custom_module': ('parent', 'raw_text', 'type_', ), + } + + def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: + try: + key = original.func.attr.value + kword_params = self.METHOD_TO_PARAMS[key] + except (AttributeError, KeyError): + # Either not a method from the API or too convoluted to be sure. + return updated + + # If the existing code is valid, keyword args come after positional args. + # Therefore, all positional args must map to the first parameters. + args, kwargs = partition(lambda a: not bool(a.keyword), updated.args) + if any(k.keyword.value == "request" for k in kwargs): + # We've already fixed this file, don't fix it again. + return updated + + kwargs, ctrl_kwargs = partition( + lambda a: a.keyword.value not in self.CTRL_PARAMS, + kwargs + ) + + args, ctrl_args = args[:len(kword_params)], args[len(kword_params):] + ctrl_kwargs.extend(cst.Arg(value=a.value, keyword=cst.Name(value=ctrl)) + for a, ctrl in zip(ctrl_args, self.CTRL_PARAMS)) + + request_arg = cst.Arg( + value=cst.Dict([ + cst.DictElement( + cst.SimpleString("'{}'".format(name)), +cst.Element(value=arg.value) + ) + # Note: the args + kwargs looks silly, but keep in mind that + # the control parameters had to be stripped out, and that + # those could have been passed positionally or by keyword. + for name, arg in zip(kword_params, args + kwargs)]), + keyword=cst.Name("request") + ) + + return updated.with_changes( + args=[request_arg] + ctrl_kwargs + ) + + +def fix_files( + in_dir: pathlib.Path, + out_dir: pathlib.Path, + *, + transformer=securitycentermanagementCallTransformer(), +): + """Duplicate the input dir to the output dir, fixing file method calls. + + Preconditions: + * in_dir is a real directory + * out_dir is a real, empty directory + """ + pyfile_gen = ( + pathlib.Path(os.path.join(root, f)) + for root, _, files in os.walk(in_dir) + for f in files if os.path.splitext(f)[1] == ".py" + ) + + for fpath in pyfile_gen: + with open(fpath, 'r') as f: + src = f.read() + + # Parse the code and insert method call fixes. + tree = cst.parse_module(src) + updated = tree.visit(transformer) + + # Create the path and directory structure for the new file. + updated_path = out_dir.joinpath(fpath.relative_to(in_dir)) + updated_path.parent.mkdir(parents=True, exist_ok=True) + + # Generate the updated source file at the corresponding path. + with open(updated_path, 'w') as f: + f.write(updated.code) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser( + description="""Fix up source that uses the securitycentermanagement client library. + +The existing sources are NOT overwritten but are copied to output_dir with changes made. + +Note: This tool operates at a best-effort level at converting positional + parameters in client method calls to keyword based parameters. + Cases where it WILL FAIL include + A) * or ** expansion in a method call. + B) Calls via function or method alias (includes free function calls) + C) Indirect or dispatched calls (e.g. the method is looked up dynamically) + + These all constitute false negatives. The tool will also detect false + positives when an API method shares a name with another method. +""") + parser.add_argument( + '-d', + '--input-directory', + required=True, + dest='input_dir', + help='the input directory to walk for python files to fix up', + ) + parser.add_argument( + '-o', + '--output-directory', + required=True, + dest='output_dir', + help='the directory to output files fixed via un-flattening', + ) + args = parser.parse_args() + input_dir = pathlib.Path(args.input_dir) + output_dir = pathlib.Path(args.output_dir) + if not input_dir.is_dir(): + print( + f"input directory '{input_dir}' does not exist or is not a directory", + file=sys.stderr, + ) + sys.exit(-1) + + if not output_dir.is_dir(): + print( + f"output directory '{output_dir}' does not exist or is not a directory", + file=sys.stderr, + ) + sys.exit(-1) + + if os.listdir(output_dir): + print( + f"output directory '{output_dir}' is not empty", + file=sys.stderr, + ) + sys.exit(-1) + + fix_files(input_dir, output_dir) diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/setup.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/setup.py new file mode 100644 index 000000000000..47e47326cd9a --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/setup.py @@ -0,0 +1,91 @@ +# -*- 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. +# +import io +import os +import re + +import setuptools # type: ignore + +package_root = os.path.abspath(os.path.dirname(__file__)) + +name = 'google-cloud-securitycentermanagement' + + +description = "Google Cloud Securitycentermanagement API client library" + +version = None + +with open(os.path.join(package_root, 'google/cloud/securitycentermanagement/gapic_version.py')) as fp: + version_candidates = re.findall(r"(?<=\")\d+.\d+.\d+(?=\")", fp.read()) + assert (len(version_candidates) == 1) + version = version_candidates[0] + +if version[0] == "0": + release_status = "Development Status :: 4 - Beta" +else: + release_status = "Development Status :: 5 - Production/Stable" + +dependencies = [ + "google-api-core[grpc] >= 1.34.0, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,!=2.8.*,!=2.9.*,!=2.10.*", + "proto-plus >= 1.22.3, <2.0.0dev", + "protobuf>=3.19.5,<5.0.0dev,!=3.20.0,!=3.20.1,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5", + "grpc-google-iam-v1 >= 0.12.4, <1.0.0dev", +] +url = "https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-securitycentermanagement" + +package_root = os.path.abspath(os.path.dirname(__file__)) + +readme_filename = os.path.join(package_root, "README.rst") +with io.open(readme_filename, encoding="utf-8") as readme_file: + readme = readme_file.read() + +packages = [ + package + for package in setuptools.find_namespace_packages() + if package.startswith("google") +] + +setuptools.setup( + name=name, + version=version, + description=description, + long_description=readme, + author="Google LLC", + author_email="googleapis-packages@google.com", + license="Apache 2.0", + url=url, + classifiers=[ + release_status, + "Intended Audience :: Developers", + "License :: OSI Approved :: Apache Software License", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Operating System :: OS Independent", + "Topic :: Internet", + ], + platforms="Posix; MacOS X; Windows", + packages=packages, + python_requires=">=3.7", + install_requires=dependencies, + include_package_data=True, + zip_safe=False, +) diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/testing/constraints-3.10.txt b/owl-bot-staging/google-cloud-securitycentermanagement/v1/testing/constraints-3.10.txt new file mode 100644 index 000000000000..ad3f0fa58e2d --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/testing/constraints-3.10.txt @@ -0,0 +1,7 @@ +# -*- coding: utf-8 -*- +# This constraints file is required for unit tests. +# List all library dependencies and extras in this file. +google-api-core +proto-plus +protobuf +grpc-google-iam-v1 diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/testing/constraints-3.11.txt b/owl-bot-staging/google-cloud-securitycentermanagement/v1/testing/constraints-3.11.txt new file mode 100644 index 000000000000..ad3f0fa58e2d --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/testing/constraints-3.11.txt @@ -0,0 +1,7 @@ +# -*- coding: utf-8 -*- +# This constraints file is required for unit tests. +# List all library dependencies and extras in this file. +google-api-core +proto-plus +protobuf +grpc-google-iam-v1 diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/testing/constraints-3.12.txt b/owl-bot-staging/google-cloud-securitycentermanagement/v1/testing/constraints-3.12.txt new file mode 100644 index 000000000000..ad3f0fa58e2d --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/testing/constraints-3.12.txt @@ -0,0 +1,7 @@ +# -*- coding: utf-8 -*- +# This constraints file is required for unit tests. +# List all library dependencies and extras in this file. +google-api-core +proto-plus +protobuf +grpc-google-iam-v1 diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/testing/constraints-3.7.txt b/owl-bot-staging/google-cloud-securitycentermanagement/v1/testing/constraints-3.7.txt new file mode 100644 index 000000000000..44ffd04543a8 --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/testing/constraints-3.7.txt @@ -0,0 +1,10 @@ +# This constraints file is used to check that lower bounds +# are correct in setup.py +# List all library dependencies and extras in this file. +# Pin the version to the lower bound. +# e.g., if setup.py has "google-cloud-foo >= 1.14.0, < 2.0.0dev", +# Then this file should have google-cloud-foo==1.14.0 +google-api-core==1.34.0 +proto-plus==1.22.3 +protobuf==3.19.5 +grpc-google-iam-v1==0.12.4 diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/testing/constraints-3.8.txt b/owl-bot-staging/google-cloud-securitycentermanagement/v1/testing/constraints-3.8.txt new file mode 100644 index 000000000000..ad3f0fa58e2d --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/testing/constraints-3.8.txt @@ -0,0 +1,7 @@ +# -*- coding: utf-8 -*- +# This constraints file is required for unit tests. +# List all library dependencies and extras in this file. +google-api-core +proto-plus +protobuf +grpc-google-iam-v1 diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/testing/constraints-3.9.txt b/owl-bot-staging/google-cloud-securitycentermanagement/v1/testing/constraints-3.9.txt new file mode 100644 index 000000000000..ad3f0fa58e2d --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/testing/constraints-3.9.txt @@ -0,0 +1,7 @@ +# -*- coding: utf-8 -*- +# This constraints file is required for unit tests. +# List all library dependencies and extras in this file. +google-api-core +proto-plus +protobuf +grpc-google-iam-v1 diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/tests/__init__.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/tests/__init__.py new file mode 100644 index 000000000000..1b4db446eb8d --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/tests/__init__.py @@ -0,0 +1,16 @@ + +# -*- 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. +# diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/tests/unit/__init__.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/tests/unit/__init__.py new file mode 100644 index 000000000000..1b4db446eb8d --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/tests/unit/__init__.py @@ -0,0 +1,16 @@ + +# -*- 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. +# diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/tests/unit/gapic/__init__.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/tests/unit/gapic/__init__.py new file mode 100644 index 000000000000..1b4db446eb8d --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/tests/unit/gapic/__init__.py @@ -0,0 +1,16 @@ + +# -*- 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. +# diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/tests/unit/gapic/securitycentermanagement_v1/__init__.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/tests/unit/gapic/securitycentermanagement_v1/__init__.py new file mode 100644 index 000000000000..1b4db446eb8d --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/tests/unit/gapic/securitycentermanagement_v1/__init__.py @@ -0,0 +1,16 @@ + +# -*- 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. +# diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/tests/unit/gapic/securitycentermanagement_v1/test_security_center_management.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/tests/unit/gapic/securitycentermanagement_v1/test_security_center_management.py new file mode 100644 index 000000000000..442d1b229d30 --- /dev/null +++ b/owl-bot-staging/google-cloud-securitycentermanagement/v1/tests/unit/gapic/securitycentermanagement_v1/test_security_center_management.py @@ -0,0 +1,12019 @@ +# -*- 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. +# +import os +# try/except added for compatibility with python < 3.8 +try: + from unittest import mock + from unittest.mock import AsyncMock # pragma: NO COVER +except ImportError: # pragma: NO COVER + import mock + +import grpc +from grpc.experimental import aio +from collections.abc import Iterable +from google.protobuf import json_format +import json +import math +import pytest +from proto.marshal.rules.dates import DurationRule, TimestampRule +from proto.marshal.rules import wrappers +from requests import Response +from requests import Request, PreparedRequest +from requests.sessions import Session +from google.protobuf import json_format + +from google.api_core import client_options +from google.api_core import exceptions as core_exceptions +from google.api_core import gapic_v1 +from google.api_core import grpc_helpers +from google.api_core import grpc_helpers_async +from google.api_core import path_template +from google.auth import credentials as ga_credentials +from google.auth.exceptions import MutualTLSChannelError +from google.cloud.location import locations_pb2 +from google.cloud.securitycentermanagement_v1.services.security_center_management import SecurityCenterManagementAsyncClient +from google.cloud.securitycentermanagement_v1.services.security_center_management import SecurityCenterManagementClient +from google.cloud.securitycentermanagement_v1.services.security_center_management import pagers +from google.cloud.securitycentermanagement_v1.services.security_center_management import transports +from google.cloud.securitycentermanagement_v1.types import security_center_management +from google.iam.v1 import policy_pb2 # type: ignore +from google.oauth2 import service_account +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import struct_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.type import expr_pb2 # type: ignore +import google.auth + + +def client_cert_source_callback(): + return b"cert bytes", b"key bytes" + + +# If default endpoint is localhost, then default mtls endpoint will be the same. +# This method modifies the default endpoint so the client can produce a different +# mtls endpoint for endpoint testing purposes. +def modify_default_endpoint(client): + return "foo.googleapis.com" if ("localhost" in client.DEFAULT_ENDPOINT) else client.DEFAULT_ENDPOINT + + +def test__get_default_mtls_endpoint(): + api_endpoint = "example.googleapis.com" + api_mtls_endpoint = "example.mtls.googleapis.com" + sandbox_endpoint = "example.sandbox.googleapis.com" + sandbox_mtls_endpoint = "example.mtls.sandbox.googleapis.com" + non_googleapi = "api.example.com" + + assert SecurityCenterManagementClient._get_default_mtls_endpoint(None) is None + assert SecurityCenterManagementClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint + assert SecurityCenterManagementClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint + assert SecurityCenterManagementClient._get_default_mtls_endpoint(sandbox_endpoint) == sandbox_mtls_endpoint + assert SecurityCenterManagementClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) == sandbox_mtls_endpoint + assert SecurityCenterManagementClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi + + +@pytest.mark.parametrize("client_class,transport_name", [ + (SecurityCenterManagementClient, "grpc"), + (SecurityCenterManagementAsyncClient, "grpc_asyncio"), + (SecurityCenterManagementClient, "rest"), +]) +def test_security_center_management_client_from_service_account_info(client_class, transport_name): + creds = ga_credentials.AnonymousCredentials() + with mock.patch.object(service_account.Credentials, 'from_service_account_info') as factory: + factory.return_value = creds + info = {"valid": True} + client = client_class.from_service_account_info(info, transport=transport_name) + assert client.transport._credentials == creds + assert isinstance(client, client_class) + + assert client.transport._host == ( + 'securitycentermanagement.googleapis.com:443' + if transport_name in ['grpc', 'grpc_asyncio'] + else + 'https://securitycentermanagement.googleapis.com' + ) + + +@pytest.mark.parametrize("transport_class,transport_name", [ + (transports.SecurityCenterManagementGrpcTransport, "grpc"), + (transports.SecurityCenterManagementGrpcAsyncIOTransport, "grpc_asyncio"), + (transports.SecurityCenterManagementRestTransport, "rest"), +]) +def test_security_center_management_client_service_account_always_use_jwt(transport_class, transport_name): + with mock.patch.object(service_account.Credentials, 'with_always_use_jwt_access', create=True) as use_jwt: + creds = service_account.Credentials(None, None, None) + transport = transport_class(credentials=creds, always_use_jwt_access=True) + use_jwt.assert_called_once_with(True) + + with mock.patch.object(service_account.Credentials, 'with_always_use_jwt_access', create=True) as use_jwt: + creds = service_account.Credentials(None, None, None) + transport = transport_class(credentials=creds, always_use_jwt_access=False) + use_jwt.assert_not_called() + + +@pytest.mark.parametrize("client_class,transport_name", [ + (SecurityCenterManagementClient, "grpc"), + (SecurityCenterManagementAsyncClient, "grpc_asyncio"), + (SecurityCenterManagementClient, "rest"), +]) +def test_security_center_management_client_from_service_account_file(client_class, transport_name): + creds = ga_credentials.AnonymousCredentials() + with mock.patch.object(service_account.Credentials, 'from_service_account_file') as factory: + factory.return_value = creds + client = client_class.from_service_account_file("dummy/file/path.json", transport=transport_name) + assert client.transport._credentials == creds + assert isinstance(client, client_class) + + client = client_class.from_service_account_json("dummy/file/path.json", transport=transport_name) + assert client.transport._credentials == creds + assert isinstance(client, client_class) + + assert client.transport._host == ( + 'securitycentermanagement.googleapis.com:443' + if transport_name in ['grpc', 'grpc_asyncio'] + else + 'https://securitycentermanagement.googleapis.com' + ) + + +def test_security_center_management_client_get_transport_class(): + transport = SecurityCenterManagementClient.get_transport_class() + available_transports = [ + transports.SecurityCenterManagementGrpcTransport, + transports.SecurityCenterManagementRestTransport, + ] + assert transport in available_transports + + transport = SecurityCenterManagementClient.get_transport_class("grpc") + assert transport == transports.SecurityCenterManagementGrpcTransport + + +@pytest.mark.parametrize("client_class,transport_class,transport_name", [ + (SecurityCenterManagementClient, transports.SecurityCenterManagementGrpcTransport, "grpc"), + (SecurityCenterManagementAsyncClient, transports.SecurityCenterManagementGrpcAsyncIOTransport, "grpc_asyncio"), + (SecurityCenterManagementClient, transports.SecurityCenterManagementRestTransport, "rest"), +]) +@mock.patch.object(SecurityCenterManagementClient, "DEFAULT_ENDPOINT", modify_default_endpoint(SecurityCenterManagementClient)) +@mock.patch.object(SecurityCenterManagementAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(SecurityCenterManagementAsyncClient)) +def test_security_center_management_client_client_options(client_class, transport_class, transport_name): + # Check that if channel is provided we won't create a new one. + with mock.patch.object(SecurityCenterManagementClient, 'get_transport_class') as gtc: + transport = transport_class( + credentials=ga_credentials.AnonymousCredentials() + ) + client = client_class(transport=transport) + gtc.assert_not_called() + + # Check that if channel is provided via str we will create a new one. + with mock.patch.object(SecurityCenterManagementClient, 'get_transport_class') as gtc: + client = client_class(transport=transport_name) + gtc.assert_called() + + # Check the case api_endpoint is provided. + options = client_options.ClientOptions(api_endpoint="squid.clam.whelk") + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(transport=transport_name, client_options=options) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host="squid.clam.whelk", + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience=None, + ) + + # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is + # "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience=None, + ) + + # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is + # "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_MTLS_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience=None, + ) + + # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has + # unsupported value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): + with pytest.raises(MutualTLSChannelError): + client = client_class(transport=transport_name) + + # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}): + with pytest.raises(ValueError): + client = client_class(transport=transport_name) + + # Check the case quota_project_id is provided + options = client_options.ClientOptions(quota_project_id="octopus") + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id="octopus", + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience=None, + ) + # Check the case api_endpoint is provided + options = client_options.ClientOptions(api_audience="https://language.googleapis.com") + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience="https://language.googleapis.com" + ) + +@pytest.mark.parametrize("client_class,transport_class,transport_name,use_client_cert_env", [ + (SecurityCenterManagementClient, transports.SecurityCenterManagementGrpcTransport, "grpc", "true"), + (SecurityCenterManagementAsyncClient, transports.SecurityCenterManagementGrpcAsyncIOTransport, "grpc_asyncio", "true"), + (SecurityCenterManagementClient, transports.SecurityCenterManagementGrpcTransport, "grpc", "false"), + (SecurityCenterManagementAsyncClient, transports.SecurityCenterManagementGrpcAsyncIOTransport, "grpc_asyncio", "false"), + (SecurityCenterManagementClient, transports.SecurityCenterManagementRestTransport, "rest", "true"), + (SecurityCenterManagementClient, transports.SecurityCenterManagementRestTransport, "rest", "false"), +]) +@mock.patch.object(SecurityCenterManagementClient, "DEFAULT_ENDPOINT", modify_default_endpoint(SecurityCenterManagementClient)) +@mock.patch.object(SecurityCenterManagementAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(SecurityCenterManagementAsyncClient)) +@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) +def test_security_center_management_client_mtls_env_auto(client_class, transport_class, transport_name, use_client_cert_env): + # This tests the endpoint autoswitch behavior. Endpoint is autoswitched to the default + # mtls endpoint, if GOOGLE_API_USE_CLIENT_CERTIFICATE is "true" and client cert exists. + + # Check the case client_cert_source is provided. Whether client cert is used depends on + # GOOGLE_API_USE_CLIENT_CERTIFICATE value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): + options = client_options.ClientOptions(client_cert_source=client_cert_source_callback) + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + + if use_client_cert_env == "false": + expected_client_cert_source = None + expected_host = client.DEFAULT_ENDPOINT + else: + expected_client_cert_source = client_cert_source_callback + expected_host = client.DEFAULT_MTLS_ENDPOINT + + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=expected_host, + scopes=None, + client_cert_source_for_mtls=expected_client_cert_source, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience=None, + ) + + # Check the case ADC client cert is provided. Whether client cert is used depends on + # GOOGLE_API_USE_CLIENT_CERTIFICATE value. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): + with mock.patch.object(transport_class, '__init__') as patched: + with mock.patch('google.auth.transport.mtls.has_default_client_cert_source', return_value=True): + with mock.patch('google.auth.transport.mtls.default_client_cert_source', return_value=client_cert_source_callback): + if use_client_cert_env == "false": + expected_host = client.DEFAULT_ENDPOINT + expected_client_cert_source = None + else: + expected_host = client.DEFAULT_MTLS_ENDPOINT + expected_client_cert_source = client_cert_source_callback + + patched.return_value = None + client = client_class(transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=expected_host, + scopes=None, + client_cert_source_for_mtls=expected_client_cert_source, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience=None, + ) + + # Check the case client_cert_source and ADC client cert are not provided. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): + with mock.patch.object(transport_class, '__init__') as patched: + with mock.patch("google.auth.transport.mtls.has_default_client_cert_source", return_value=False): + patched.return_value = None + client = client_class(transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience=None, + ) + + +@pytest.mark.parametrize("client_class", [ + SecurityCenterManagementClient, SecurityCenterManagementAsyncClient +]) +@mock.patch.object(SecurityCenterManagementClient, "DEFAULT_ENDPOINT", modify_default_endpoint(SecurityCenterManagementClient)) +@mock.patch.object(SecurityCenterManagementAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(SecurityCenterManagementAsyncClient)) +def test_security_center_management_client_get_mtls_endpoint_and_cert_source(client_class): + mock_client_cert_source = mock.Mock() + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + mock_api_endpoint = "foo" + options = client_options.ClientOptions(client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source(options) + assert api_endpoint == mock_api_endpoint + assert cert_source == mock_client_cert_source + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): + mock_client_cert_source = mock.Mock() + mock_api_endpoint = "foo" + options = client_options.ClientOptions(client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source(options) + assert api_endpoint == mock_api_endpoint + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch('google.auth.transport.mtls.has_default_client_cert_source', return_value=False): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch('google.auth.transport.mtls.has_default_client_cert_source', return_value=True): + with mock.patch('google.auth.transport.mtls.default_client_cert_source', return_value=mock_client_cert_source): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source == mock_client_cert_source + + +@pytest.mark.parametrize("client_class,transport_class,transport_name", [ + (SecurityCenterManagementClient, transports.SecurityCenterManagementGrpcTransport, "grpc"), + (SecurityCenterManagementAsyncClient, transports.SecurityCenterManagementGrpcAsyncIOTransport, "grpc_asyncio"), + (SecurityCenterManagementClient, transports.SecurityCenterManagementRestTransport, "rest"), +]) +def test_security_center_management_client_client_options_scopes(client_class, transport_class, transport_name): + # Check the case scopes are provided. + options = client_options.ClientOptions( + scopes=["1", "2"], + ) + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=["1", "2"], + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience=None, + ) + +@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ + (SecurityCenterManagementClient, transports.SecurityCenterManagementGrpcTransport, "grpc", grpc_helpers), + (SecurityCenterManagementAsyncClient, transports.SecurityCenterManagementGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), + (SecurityCenterManagementClient, transports.SecurityCenterManagementRestTransport, "rest", None), +]) +def test_security_center_management_client_client_options_credentials_file(client_class, transport_class, transport_name, grpc_helpers): + # Check the case credentials file is provided. + options = client_options.ClientOptions( + credentials_file="credentials.json" + ) + + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience=None, + ) + +def test_security_center_management_client_client_options_from_dict(): + with mock.patch('google.cloud.securitycentermanagement_v1.services.security_center_management.transports.SecurityCenterManagementGrpcTransport.__init__') as grpc_transport: + grpc_transport.return_value = None + client = SecurityCenterManagementClient( + client_options={'api_endpoint': 'squid.clam.whelk'} + ) + grpc_transport.assert_called_once_with( + credentials=None, + credentials_file=None, + host="squid.clam.whelk", + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience=None, + ) + + +@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ + (SecurityCenterManagementClient, transports.SecurityCenterManagementGrpcTransport, "grpc", grpc_helpers), + (SecurityCenterManagementAsyncClient, transports.SecurityCenterManagementGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), +]) +def test_security_center_management_client_create_channel_credentials_file(client_class, transport_class, transport_name, grpc_helpers): + # Check the case credentials file is provided. + options = client_options.ClientOptions( + credentials_file="credentials.json" + ) + + with mock.patch.object(transport_class, '__init__') as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience=None, + ) + + # test that the credentials from file are saved and used as the credentials. + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel" + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + file_creds = ga_credentials.AnonymousCredentials() + load_creds.return_value = (file_creds, None) + adc.return_value = (creds, None) + client = client_class(client_options=options, transport=transport_name) + create_channel.assert_called_with( + "securitycentermanagement.googleapis.com:443", + credentials=file_creds, + credentials_file=None, + quota_project_id=None, + default_scopes=( + 'https://www.googleapis.com/auth/cloud-platform', +), + scopes=None, + default_host="securitycentermanagement.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize("request_type", [ + security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest, + dict, +]) +def test_list_effective_security_health_analytics_custom_modules(request_type, transport: str = 'grpc'): + client = SecurityCenterManagementClient( + 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_effective_security_health_analytics_custom_modules), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse( + next_page_token='next_page_token_value', + ) + response = client.list_effective_security_health_analytics_custom_modules(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListEffectiveSecurityHealthAnalyticsCustomModulesPager) + assert response.next_page_token == 'next_page_token_value' + + +def test_list_effective_security_health_analytics_custom_modules_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 = SecurityCenterManagementClient( + 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_effective_security_health_analytics_custom_modules), + '__call__') as call: + client.list_effective_security_health_analytics_custom_modules() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest() + +@pytest.mark.asyncio +async def test_list_effective_security_health_analytics_custom_modules_async(transport: str = 'grpc_asyncio', request_type=security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest): + client = SecurityCenterManagementAsyncClient( + 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_effective_security_health_analytics_custom_modules), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse( + next_page_token='next_page_token_value', + )) + response = await client.list_effective_security_health_analytics_custom_modules(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListEffectiveSecurityHealthAnalyticsCustomModulesAsyncPager) + assert response.next_page_token == 'next_page_token_value' + + +@pytest.mark.asyncio +async def test_list_effective_security_health_analytics_custom_modules_async_from_dict(): + await test_list_effective_security_health_analytics_custom_modules_async(request_type=dict) + + +def test_list_effective_security_health_analytics_custom_modules_field_headers(): + client = SecurityCenterManagementClient( + 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 = security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_effective_security_health_analytics_custom_modules), + '__call__') as call: + call.return_value = security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse() + client.list_effective_security_health_analytics_custom_modules(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_effective_security_health_analytics_custom_modules_field_headers_async(): + client = SecurityCenterManagementAsyncClient( + 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 = security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_effective_security_health_analytics_custom_modules), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse()) + await client.list_effective_security_health_analytics_custom_modules(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_effective_security_health_analytics_custom_modules_flattened(): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_effective_security_health_analytics_custom_modules), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_effective_security_health_analytics_custom_modules( + 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_effective_security_health_analytics_custom_modules_flattened_error(): + client = SecurityCenterManagementClient( + 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_effective_security_health_analytics_custom_modules( + security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest(), + parent='parent_value', + ) + +@pytest.mark.asyncio +async def test_list_effective_security_health_analytics_custom_modules_flattened_async(): + client = SecurityCenterManagementAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_effective_security_health_analytics_custom_modules), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_effective_security_health_analytics_custom_modules( + 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_effective_security_health_analytics_custom_modules_flattened_error_async(): + client = SecurityCenterManagementAsyncClient( + 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_effective_security_health_analytics_custom_modules( + security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest(), + parent='parent_value', + ) + + +def test_list_effective_security_health_analytics_custom_modules_pager(transport_name: str = "grpc"): + client = SecurityCenterManagementClient( + 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_effective_security_health_analytics_custom_modules), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse( + effective_security_health_analytics_custom_modules=[ + security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), + security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), + security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), + ], + next_page_token='abc', + ), + security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse( + effective_security_health_analytics_custom_modules=[], + next_page_token='def', + ), + security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse( + effective_security_health_analytics_custom_modules=[ + security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), + ], + next_page_token='ghi', + ), + security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse( + effective_security_health_analytics_custom_modules=[ + security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), + security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_effective_security_health_analytics_custom_modules(request={}) + + assert pager._metadata == metadata + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, security_center_management.EffectiveSecurityHealthAnalyticsCustomModule) + for i in results) +def test_list_effective_security_health_analytics_custom_modules_pages(transport_name: str = "grpc"): + client = SecurityCenterManagementClient( + 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_effective_security_health_analytics_custom_modules), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse( + effective_security_health_analytics_custom_modules=[ + security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), + security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), + security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), + ], + next_page_token='abc', + ), + security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse( + effective_security_health_analytics_custom_modules=[], + next_page_token='def', + ), + security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse( + effective_security_health_analytics_custom_modules=[ + security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), + ], + next_page_token='ghi', + ), + security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse( + effective_security_health_analytics_custom_modules=[ + security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), + security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), + ], + ), + RuntimeError, + ) + pages = list(client.list_effective_security_health_analytics_custom_modules(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_effective_security_health_analytics_custom_modules_async_pager(): + client = SecurityCenterManagementAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_effective_security_health_analytics_custom_modules), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse( + effective_security_health_analytics_custom_modules=[ + security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), + security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), + security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), + ], + next_page_token='abc', + ), + security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse( + effective_security_health_analytics_custom_modules=[], + next_page_token='def', + ), + security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse( + effective_security_health_analytics_custom_modules=[ + security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), + ], + next_page_token='ghi', + ), + security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse( + effective_security_health_analytics_custom_modules=[ + security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), + security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_effective_security_health_analytics_custom_modules(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, security_center_management.EffectiveSecurityHealthAnalyticsCustomModule) + for i in responses) + + +@pytest.mark.asyncio +async def test_list_effective_security_health_analytics_custom_modules_async_pages(): + client = SecurityCenterManagementAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_effective_security_health_analytics_custom_modules), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse( + effective_security_health_analytics_custom_modules=[ + security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), + security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), + security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), + ], + next_page_token='abc', + ), + security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse( + effective_security_health_analytics_custom_modules=[], + next_page_token='def', + ), + security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse( + effective_security_health_analytics_custom_modules=[ + security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), + ], + next_page_token='ghi', + ), + security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse( + effective_security_health_analytics_custom_modules=[ + security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), + security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), + ], + ), + 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_effective_security_health_analytics_custom_modules(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", [ + security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest, + dict, +]) +def test_get_effective_security_health_analytics_custom_module(request_type, transport: str = 'grpc'): + client = SecurityCenterManagementClient( + 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_effective_security_health_analytics_custom_module), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = security_center_management.EffectiveSecurityHealthAnalyticsCustomModule( + name='name_value', + enablement_state=security_center_management.EffectiveSecurityHealthAnalyticsCustomModule.EnablementState.ENABLED, + display_name='display_name_value', + ) + response = client.get_effective_security_health_analytics_custom_module(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, security_center_management.EffectiveSecurityHealthAnalyticsCustomModule) + assert response.name == 'name_value' + assert response.enablement_state == security_center_management.EffectiveSecurityHealthAnalyticsCustomModule.EnablementState.ENABLED + assert response.display_name == 'display_name_value' + + +def test_get_effective_security_health_analytics_custom_module_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 = SecurityCenterManagementClient( + 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_effective_security_health_analytics_custom_module), + '__call__') as call: + client.get_effective_security_health_analytics_custom_module() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest() + +@pytest.mark.asyncio +async def test_get_effective_security_health_analytics_custom_module_async(transport: str = 'grpc_asyncio', request_type=security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest): + client = SecurityCenterManagementAsyncClient( + 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_effective_security_health_analytics_custom_module), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.EffectiveSecurityHealthAnalyticsCustomModule( + name='name_value', + enablement_state=security_center_management.EffectiveSecurityHealthAnalyticsCustomModule.EnablementState.ENABLED, + display_name='display_name_value', + )) + response = await client.get_effective_security_health_analytics_custom_module(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, security_center_management.EffectiveSecurityHealthAnalyticsCustomModule) + assert response.name == 'name_value' + assert response.enablement_state == security_center_management.EffectiveSecurityHealthAnalyticsCustomModule.EnablementState.ENABLED + assert response.display_name == 'display_name_value' + + +@pytest.mark.asyncio +async def test_get_effective_security_health_analytics_custom_module_async_from_dict(): + await test_get_effective_security_health_analytics_custom_module_async(request_type=dict) + + +def test_get_effective_security_health_analytics_custom_module_field_headers(): + client = SecurityCenterManagementClient( + 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 = security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_effective_security_health_analytics_custom_module), + '__call__') as call: + call.return_value = security_center_management.EffectiveSecurityHealthAnalyticsCustomModule() + client.get_effective_security_health_analytics_custom_module(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_effective_security_health_analytics_custom_module_field_headers_async(): + client = SecurityCenterManagementAsyncClient( + 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 = security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_effective_security_health_analytics_custom_module), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.EffectiveSecurityHealthAnalyticsCustomModule()) + await client.get_effective_security_health_analytics_custom_module(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_effective_security_health_analytics_custom_module_flattened(): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_effective_security_health_analytics_custom_module), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = security_center_management.EffectiveSecurityHealthAnalyticsCustomModule() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_effective_security_health_analytics_custom_module( + 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_effective_security_health_analytics_custom_module_flattened_error(): + client = SecurityCenterManagementClient( + 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_effective_security_health_analytics_custom_module( + security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_get_effective_security_health_analytics_custom_module_flattened_async(): + client = SecurityCenterManagementAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_effective_security_health_analytics_custom_module), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = security_center_management.EffectiveSecurityHealthAnalyticsCustomModule() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.EffectiveSecurityHealthAnalyticsCustomModule()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_effective_security_health_analytics_custom_module( + 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_effective_security_health_analytics_custom_module_flattened_error_async(): + client = SecurityCenterManagementAsyncClient( + 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_effective_security_health_analytics_custom_module( + security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest, + dict, +]) +def test_list_security_health_analytics_custom_modules(request_type, transport: str = 'grpc'): + client = SecurityCenterManagementClient( + 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_security_health_analytics_custom_modules), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse( + next_page_token='next_page_token_value', + ) + response = client.list_security_health_analytics_custom_modules(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListSecurityHealthAnalyticsCustomModulesPager) + assert response.next_page_token == 'next_page_token_value' + + +def test_list_security_health_analytics_custom_modules_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 = SecurityCenterManagementClient( + 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_security_health_analytics_custom_modules), + '__call__') as call: + client.list_security_health_analytics_custom_modules() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest() + +@pytest.mark.asyncio +async def test_list_security_health_analytics_custom_modules_async(transport: str = 'grpc_asyncio', request_type=security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest): + client = SecurityCenterManagementAsyncClient( + 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_security_health_analytics_custom_modules), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse( + next_page_token='next_page_token_value', + )) + response = await client.list_security_health_analytics_custom_modules(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListSecurityHealthAnalyticsCustomModulesAsyncPager) + assert response.next_page_token == 'next_page_token_value' + + +@pytest.mark.asyncio +async def test_list_security_health_analytics_custom_modules_async_from_dict(): + await test_list_security_health_analytics_custom_modules_async(request_type=dict) + + +def test_list_security_health_analytics_custom_modules_field_headers(): + client = SecurityCenterManagementClient( + 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 = security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_security_health_analytics_custom_modules), + '__call__') as call: + call.return_value = security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse() + client.list_security_health_analytics_custom_modules(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_security_health_analytics_custom_modules_field_headers_async(): + client = SecurityCenterManagementAsyncClient( + 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 = security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_security_health_analytics_custom_modules), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse()) + await client.list_security_health_analytics_custom_modules(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_security_health_analytics_custom_modules_flattened(): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_security_health_analytics_custom_modules), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_security_health_analytics_custom_modules( + 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_security_health_analytics_custom_modules_flattened_error(): + client = SecurityCenterManagementClient( + 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_security_health_analytics_custom_modules( + security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest(), + parent='parent_value', + ) + +@pytest.mark.asyncio +async def test_list_security_health_analytics_custom_modules_flattened_async(): + client = SecurityCenterManagementAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_security_health_analytics_custom_modules), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_security_health_analytics_custom_modules( + 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_security_health_analytics_custom_modules_flattened_error_async(): + client = SecurityCenterManagementAsyncClient( + 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_security_health_analytics_custom_modules( + security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest(), + parent='parent_value', + ) + + +def test_list_security_health_analytics_custom_modules_pager(transport_name: str = "grpc"): + client = SecurityCenterManagementClient( + 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_security_health_analytics_custom_modules), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse( + security_health_analytics_custom_modules=[ + security_center_management.SecurityHealthAnalyticsCustomModule(), + security_center_management.SecurityHealthAnalyticsCustomModule(), + security_center_management.SecurityHealthAnalyticsCustomModule(), + ], + next_page_token='abc', + ), + security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse( + security_health_analytics_custom_modules=[], + next_page_token='def', + ), + security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse( + security_health_analytics_custom_modules=[ + security_center_management.SecurityHealthAnalyticsCustomModule(), + ], + next_page_token='ghi', + ), + security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse( + security_health_analytics_custom_modules=[ + security_center_management.SecurityHealthAnalyticsCustomModule(), + security_center_management.SecurityHealthAnalyticsCustomModule(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_security_health_analytics_custom_modules(request={}) + + assert pager._metadata == metadata + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, security_center_management.SecurityHealthAnalyticsCustomModule) + for i in results) +def test_list_security_health_analytics_custom_modules_pages(transport_name: str = "grpc"): + client = SecurityCenterManagementClient( + 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_security_health_analytics_custom_modules), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse( + security_health_analytics_custom_modules=[ + security_center_management.SecurityHealthAnalyticsCustomModule(), + security_center_management.SecurityHealthAnalyticsCustomModule(), + security_center_management.SecurityHealthAnalyticsCustomModule(), + ], + next_page_token='abc', + ), + security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse( + security_health_analytics_custom_modules=[], + next_page_token='def', + ), + security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse( + security_health_analytics_custom_modules=[ + security_center_management.SecurityHealthAnalyticsCustomModule(), + ], + next_page_token='ghi', + ), + security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse( + security_health_analytics_custom_modules=[ + security_center_management.SecurityHealthAnalyticsCustomModule(), + security_center_management.SecurityHealthAnalyticsCustomModule(), + ], + ), + RuntimeError, + ) + pages = list(client.list_security_health_analytics_custom_modules(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_security_health_analytics_custom_modules_async_pager(): + client = SecurityCenterManagementAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_security_health_analytics_custom_modules), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse( + security_health_analytics_custom_modules=[ + security_center_management.SecurityHealthAnalyticsCustomModule(), + security_center_management.SecurityHealthAnalyticsCustomModule(), + security_center_management.SecurityHealthAnalyticsCustomModule(), + ], + next_page_token='abc', + ), + security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse( + security_health_analytics_custom_modules=[], + next_page_token='def', + ), + security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse( + security_health_analytics_custom_modules=[ + security_center_management.SecurityHealthAnalyticsCustomModule(), + ], + next_page_token='ghi', + ), + security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse( + security_health_analytics_custom_modules=[ + security_center_management.SecurityHealthAnalyticsCustomModule(), + security_center_management.SecurityHealthAnalyticsCustomModule(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_security_health_analytics_custom_modules(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, security_center_management.SecurityHealthAnalyticsCustomModule) + for i in responses) + + +@pytest.mark.asyncio +async def test_list_security_health_analytics_custom_modules_async_pages(): + client = SecurityCenterManagementAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_security_health_analytics_custom_modules), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse( + security_health_analytics_custom_modules=[ + security_center_management.SecurityHealthAnalyticsCustomModule(), + security_center_management.SecurityHealthAnalyticsCustomModule(), + security_center_management.SecurityHealthAnalyticsCustomModule(), + ], + next_page_token='abc', + ), + security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse( + security_health_analytics_custom_modules=[], + next_page_token='def', + ), + security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse( + security_health_analytics_custom_modules=[ + security_center_management.SecurityHealthAnalyticsCustomModule(), + ], + next_page_token='ghi', + ), + security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse( + security_health_analytics_custom_modules=[ + security_center_management.SecurityHealthAnalyticsCustomModule(), + security_center_management.SecurityHealthAnalyticsCustomModule(), + ], + ), + 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_security_health_analytics_custom_modules(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", [ + security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest, + dict, +]) +def test_list_descendant_security_health_analytics_custom_modules(request_type, transport: str = 'grpc'): + client = SecurityCenterManagementClient( + 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_descendant_security_health_analytics_custom_modules), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse( + next_page_token='next_page_token_value', + ) + response = client.list_descendant_security_health_analytics_custom_modules(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListDescendantSecurityHealthAnalyticsCustomModulesPager) + assert response.next_page_token == 'next_page_token_value' + + +def test_list_descendant_security_health_analytics_custom_modules_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 = SecurityCenterManagementClient( + 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_descendant_security_health_analytics_custom_modules), + '__call__') as call: + client.list_descendant_security_health_analytics_custom_modules() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest() + +@pytest.mark.asyncio +async def test_list_descendant_security_health_analytics_custom_modules_async(transport: str = 'grpc_asyncio', request_type=security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest): + client = SecurityCenterManagementAsyncClient( + 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_descendant_security_health_analytics_custom_modules), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse( + next_page_token='next_page_token_value', + )) + response = await client.list_descendant_security_health_analytics_custom_modules(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListDescendantSecurityHealthAnalyticsCustomModulesAsyncPager) + assert response.next_page_token == 'next_page_token_value' + + +@pytest.mark.asyncio +async def test_list_descendant_security_health_analytics_custom_modules_async_from_dict(): + await test_list_descendant_security_health_analytics_custom_modules_async(request_type=dict) + + +def test_list_descendant_security_health_analytics_custom_modules_field_headers(): + client = SecurityCenterManagementClient( + 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 = security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_descendant_security_health_analytics_custom_modules), + '__call__') as call: + call.return_value = security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse() + client.list_descendant_security_health_analytics_custom_modules(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_descendant_security_health_analytics_custom_modules_field_headers_async(): + client = SecurityCenterManagementAsyncClient( + 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 = security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_descendant_security_health_analytics_custom_modules), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse()) + await client.list_descendant_security_health_analytics_custom_modules(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_descendant_security_health_analytics_custom_modules_flattened(): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_descendant_security_health_analytics_custom_modules), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_descendant_security_health_analytics_custom_modules( + 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_descendant_security_health_analytics_custom_modules_flattened_error(): + client = SecurityCenterManagementClient( + 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_descendant_security_health_analytics_custom_modules( + security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest(), + parent='parent_value', + ) + +@pytest.mark.asyncio +async def test_list_descendant_security_health_analytics_custom_modules_flattened_async(): + client = SecurityCenterManagementAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_descendant_security_health_analytics_custom_modules), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_descendant_security_health_analytics_custom_modules( + 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_descendant_security_health_analytics_custom_modules_flattened_error_async(): + client = SecurityCenterManagementAsyncClient( + 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_descendant_security_health_analytics_custom_modules( + security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest(), + parent='parent_value', + ) + + +def test_list_descendant_security_health_analytics_custom_modules_pager(transport_name: str = "grpc"): + client = SecurityCenterManagementClient( + 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_descendant_security_health_analytics_custom_modules), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse( + security_health_analytics_custom_modules=[ + security_center_management.SecurityHealthAnalyticsCustomModule(), + security_center_management.SecurityHealthAnalyticsCustomModule(), + security_center_management.SecurityHealthAnalyticsCustomModule(), + ], + next_page_token='abc', + ), + security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse( + security_health_analytics_custom_modules=[], + next_page_token='def', + ), + security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse( + security_health_analytics_custom_modules=[ + security_center_management.SecurityHealthAnalyticsCustomModule(), + ], + next_page_token='ghi', + ), + security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse( + security_health_analytics_custom_modules=[ + security_center_management.SecurityHealthAnalyticsCustomModule(), + security_center_management.SecurityHealthAnalyticsCustomModule(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_descendant_security_health_analytics_custom_modules(request={}) + + assert pager._metadata == metadata + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, security_center_management.SecurityHealthAnalyticsCustomModule) + for i in results) +def test_list_descendant_security_health_analytics_custom_modules_pages(transport_name: str = "grpc"): + client = SecurityCenterManagementClient( + 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_descendant_security_health_analytics_custom_modules), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse( + security_health_analytics_custom_modules=[ + security_center_management.SecurityHealthAnalyticsCustomModule(), + security_center_management.SecurityHealthAnalyticsCustomModule(), + security_center_management.SecurityHealthAnalyticsCustomModule(), + ], + next_page_token='abc', + ), + security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse( + security_health_analytics_custom_modules=[], + next_page_token='def', + ), + security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse( + security_health_analytics_custom_modules=[ + security_center_management.SecurityHealthAnalyticsCustomModule(), + ], + next_page_token='ghi', + ), + security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse( + security_health_analytics_custom_modules=[ + security_center_management.SecurityHealthAnalyticsCustomModule(), + security_center_management.SecurityHealthAnalyticsCustomModule(), + ], + ), + RuntimeError, + ) + pages = list(client.list_descendant_security_health_analytics_custom_modules(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_descendant_security_health_analytics_custom_modules_async_pager(): + client = SecurityCenterManagementAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_descendant_security_health_analytics_custom_modules), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse( + security_health_analytics_custom_modules=[ + security_center_management.SecurityHealthAnalyticsCustomModule(), + security_center_management.SecurityHealthAnalyticsCustomModule(), + security_center_management.SecurityHealthAnalyticsCustomModule(), + ], + next_page_token='abc', + ), + security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse( + security_health_analytics_custom_modules=[], + next_page_token='def', + ), + security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse( + security_health_analytics_custom_modules=[ + security_center_management.SecurityHealthAnalyticsCustomModule(), + ], + next_page_token='ghi', + ), + security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse( + security_health_analytics_custom_modules=[ + security_center_management.SecurityHealthAnalyticsCustomModule(), + security_center_management.SecurityHealthAnalyticsCustomModule(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_descendant_security_health_analytics_custom_modules(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, security_center_management.SecurityHealthAnalyticsCustomModule) + for i in responses) + + +@pytest.mark.asyncio +async def test_list_descendant_security_health_analytics_custom_modules_async_pages(): + client = SecurityCenterManagementAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_descendant_security_health_analytics_custom_modules), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse( + security_health_analytics_custom_modules=[ + security_center_management.SecurityHealthAnalyticsCustomModule(), + security_center_management.SecurityHealthAnalyticsCustomModule(), + security_center_management.SecurityHealthAnalyticsCustomModule(), + ], + next_page_token='abc', + ), + security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse( + security_health_analytics_custom_modules=[], + next_page_token='def', + ), + security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse( + security_health_analytics_custom_modules=[ + security_center_management.SecurityHealthAnalyticsCustomModule(), + ], + next_page_token='ghi', + ), + security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse( + security_health_analytics_custom_modules=[ + security_center_management.SecurityHealthAnalyticsCustomModule(), + security_center_management.SecurityHealthAnalyticsCustomModule(), + ], + ), + 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_descendant_security_health_analytics_custom_modules(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", [ + security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest, + dict, +]) +def test_get_security_health_analytics_custom_module(request_type, transport: str = 'grpc'): + client = SecurityCenterManagementClient( + 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_security_health_analytics_custom_module), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = security_center_management.SecurityHealthAnalyticsCustomModule( + name='name_value', + display_name='display_name_value', + enablement_state=security_center_management.SecurityHealthAnalyticsCustomModule.EnablementState.ENABLED, + last_editor='last_editor_value', + ancestor_module='ancestor_module_value', + ) + response = client.get_security_health_analytics_custom_module(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, security_center_management.SecurityHealthAnalyticsCustomModule) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.enablement_state == security_center_management.SecurityHealthAnalyticsCustomModule.EnablementState.ENABLED + assert response.last_editor == 'last_editor_value' + assert response.ancestor_module == 'ancestor_module_value' + + +def test_get_security_health_analytics_custom_module_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 = SecurityCenterManagementClient( + 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_security_health_analytics_custom_module), + '__call__') as call: + client.get_security_health_analytics_custom_module() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest() + +@pytest.mark.asyncio +async def test_get_security_health_analytics_custom_module_async(transport: str = 'grpc_asyncio', request_type=security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest): + client = SecurityCenterManagementAsyncClient( + 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_security_health_analytics_custom_module), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.SecurityHealthAnalyticsCustomModule( + name='name_value', + display_name='display_name_value', + enablement_state=security_center_management.SecurityHealthAnalyticsCustomModule.EnablementState.ENABLED, + last_editor='last_editor_value', + ancestor_module='ancestor_module_value', + )) + response = await client.get_security_health_analytics_custom_module(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, security_center_management.SecurityHealthAnalyticsCustomModule) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.enablement_state == security_center_management.SecurityHealthAnalyticsCustomModule.EnablementState.ENABLED + assert response.last_editor == 'last_editor_value' + assert response.ancestor_module == 'ancestor_module_value' + + +@pytest.mark.asyncio +async def test_get_security_health_analytics_custom_module_async_from_dict(): + await test_get_security_health_analytics_custom_module_async(request_type=dict) + + +def test_get_security_health_analytics_custom_module_field_headers(): + client = SecurityCenterManagementClient( + 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 = security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_security_health_analytics_custom_module), + '__call__') as call: + call.return_value = security_center_management.SecurityHealthAnalyticsCustomModule() + client.get_security_health_analytics_custom_module(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_security_health_analytics_custom_module_field_headers_async(): + client = SecurityCenterManagementAsyncClient( + 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 = security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_security_health_analytics_custom_module), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.SecurityHealthAnalyticsCustomModule()) + await client.get_security_health_analytics_custom_module(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_security_health_analytics_custom_module_flattened(): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_security_health_analytics_custom_module), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = security_center_management.SecurityHealthAnalyticsCustomModule() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_security_health_analytics_custom_module( + 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_security_health_analytics_custom_module_flattened_error(): + client = SecurityCenterManagementClient( + 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_security_health_analytics_custom_module( + security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_get_security_health_analytics_custom_module_flattened_async(): + client = SecurityCenterManagementAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_security_health_analytics_custom_module), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = security_center_management.SecurityHealthAnalyticsCustomModule() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.SecurityHealthAnalyticsCustomModule()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_security_health_analytics_custom_module( + 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_security_health_analytics_custom_module_flattened_error_async(): + client = SecurityCenterManagementAsyncClient( + 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_security_health_analytics_custom_module( + security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest, + dict, +]) +def test_create_security_health_analytics_custom_module(request_type, transport: str = 'grpc'): + client = SecurityCenterManagementClient( + 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_security_health_analytics_custom_module), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = security_center_management.SecurityHealthAnalyticsCustomModule( + name='name_value', + display_name='display_name_value', + enablement_state=security_center_management.SecurityHealthAnalyticsCustomModule.EnablementState.ENABLED, + last_editor='last_editor_value', + ancestor_module='ancestor_module_value', + ) + response = client.create_security_health_analytics_custom_module(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, security_center_management.SecurityHealthAnalyticsCustomModule) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.enablement_state == security_center_management.SecurityHealthAnalyticsCustomModule.EnablementState.ENABLED + assert response.last_editor == 'last_editor_value' + assert response.ancestor_module == 'ancestor_module_value' + + +def test_create_security_health_analytics_custom_module_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 = SecurityCenterManagementClient( + 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_security_health_analytics_custom_module), + '__call__') as call: + client.create_security_health_analytics_custom_module() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest() + +@pytest.mark.asyncio +async def test_create_security_health_analytics_custom_module_async(transport: str = 'grpc_asyncio', request_type=security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest): + client = SecurityCenterManagementAsyncClient( + 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_security_health_analytics_custom_module), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.SecurityHealthAnalyticsCustomModule( + name='name_value', + display_name='display_name_value', + enablement_state=security_center_management.SecurityHealthAnalyticsCustomModule.EnablementState.ENABLED, + last_editor='last_editor_value', + ancestor_module='ancestor_module_value', + )) + response = await client.create_security_health_analytics_custom_module(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, security_center_management.SecurityHealthAnalyticsCustomModule) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.enablement_state == security_center_management.SecurityHealthAnalyticsCustomModule.EnablementState.ENABLED + assert response.last_editor == 'last_editor_value' + assert response.ancestor_module == 'ancestor_module_value' + + +@pytest.mark.asyncio +async def test_create_security_health_analytics_custom_module_async_from_dict(): + await test_create_security_health_analytics_custom_module_async(request_type=dict) + + +def test_create_security_health_analytics_custom_module_field_headers(): + client = SecurityCenterManagementClient( + 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 = security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_security_health_analytics_custom_module), + '__call__') as call: + call.return_value = security_center_management.SecurityHealthAnalyticsCustomModule() + client.create_security_health_analytics_custom_module(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_security_health_analytics_custom_module_field_headers_async(): + client = SecurityCenterManagementAsyncClient( + 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 = security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_security_health_analytics_custom_module), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.SecurityHealthAnalyticsCustomModule()) + await client.create_security_health_analytics_custom_module(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_security_health_analytics_custom_module_flattened(): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_security_health_analytics_custom_module), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = security_center_management.SecurityHealthAnalyticsCustomModule() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_security_health_analytics_custom_module( + parent='parent_value', + security_health_analytics_custom_module=security_center_management.SecurityHealthAnalyticsCustomModule(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].security_health_analytics_custom_module + mock_val = security_center_management.SecurityHealthAnalyticsCustomModule(name='name_value') + assert arg == mock_val + + +def test_create_security_health_analytics_custom_module_flattened_error(): + client = SecurityCenterManagementClient( + 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_security_health_analytics_custom_module( + security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest(), + parent='parent_value', + security_health_analytics_custom_module=security_center_management.SecurityHealthAnalyticsCustomModule(name='name_value'), + ) + +@pytest.mark.asyncio +async def test_create_security_health_analytics_custom_module_flattened_async(): + client = SecurityCenterManagementAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_security_health_analytics_custom_module), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = security_center_management.SecurityHealthAnalyticsCustomModule() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.SecurityHealthAnalyticsCustomModule()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_security_health_analytics_custom_module( + parent='parent_value', + security_health_analytics_custom_module=security_center_management.SecurityHealthAnalyticsCustomModule(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].security_health_analytics_custom_module + mock_val = security_center_management.SecurityHealthAnalyticsCustomModule(name='name_value') + assert arg == mock_val + +@pytest.mark.asyncio +async def test_create_security_health_analytics_custom_module_flattened_error_async(): + client = SecurityCenterManagementAsyncClient( + 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_security_health_analytics_custom_module( + security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest(), + parent='parent_value', + security_health_analytics_custom_module=security_center_management.SecurityHealthAnalyticsCustomModule(name='name_value'), + ) + + +@pytest.mark.parametrize("request_type", [ + security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest, + dict, +]) +def test_update_security_health_analytics_custom_module(request_type, transport: str = 'grpc'): + client = SecurityCenterManagementClient( + 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_security_health_analytics_custom_module), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = security_center_management.SecurityHealthAnalyticsCustomModule( + name='name_value', + display_name='display_name_value', + enablement_state=security_center_management.SecurityHealthAnalyticsCustomModule.EnablementState.ENABLED, + last_editor='last_editor_value', + ancestor_module='ancestor_module_value', + ) + response = client.update_security_health_analytics_custom_module(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, security_center_management.SecurityHealthAnalyticsCustomModule) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.enablement_state == security_center_management.SecurityHealthAnalyticsCustomModule.EnablementState.ENABLED + assert response.last_editor == 'last_editor_value' + assert response.ancestor_module == 'ancestor_module_value' + + +def test_update_security_health_analytics_custom_module_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 = SecurityCenterManagementClient( + 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_security_health_analytics_custom_module), + '__call__') as call: + client.update_security_health_analytics_custom_module() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest() + +@pytest.mark.asyncio +async def test_update_security_health_analytics_custom_module_async(transport: str = 'grpc_asyncio', request_type=security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest): + client = SecurityCenterManagementAsyncClient( + 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_security_health_analytics_custom_module), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.SecurityHealthAnalyticsCustomModule( + name='name_value', + display_name='display_name_value', + enablement_state=security_center_management.SecurityHealthAnalyticsCustomModule.EnablementState.ENABLED, + last_editor='last_editor_value', + ancestor_module='ancestor_module_value', + )) + response = await client.update_security_health_analytics_custom_module(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, security_center_management.SecurityHealthAnalyticsCustomModule) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.enablement_state == security_center_management.SecurityHealthAnalyticsCustomModule.EnablementState.ENABLED + assert response.last_editor == 'last_editor_value' + assert response.ancestor_module == 'ancestor_module_value' + + +@pytest.mark.asyncio +async def test_update_security_health_analytics_custom_module_async_from_dict(): + await test_update_security_health_analytics_custom_module_async(request_type=dict) + + +def test_update_security_health_analytics_custom_module_field_headers(): + client = SecurityCenterManagementClient( + 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 = security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest() + + request.security_health_analytics_custom_module.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_security_health_analytics_custom_module), + '__call__') as call: + call.return_value = security_center_management.SecurityHealthAnalyticsCustomModule() + client.update_security_health_analytics_custom_module(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', + 'security_health_analytics_custom_module.name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_security_health_analytics_custom_module_field_headers_async(): + client = SecurityCenterManagementAsyncClient( + 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 = security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest() + + request.security_health_analytics_custom_module.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_security_health_analytics_custom_module), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.SecurityHealthAnalyticsCustomModule()) + await client.update_security_health_analytics_custom_module(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', + 'security_health_analytics_custom_module.name=name_value', + ) in kw['metadata'] + + +def test_update_security_health_analytics_custom_module_flattened(): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_security_health_analytics_custom_module), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = security_center_management.SecurityHealthAnalyticsCustomModule() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_security_health_analytics_custom_module( + security_health_analytics_custom_module=security_center_management.SecurityHealthAnalyticsCustomModule(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].security_health_analytics_custom_module + mock_val = security_center_management.SecurityHealthAnalyticsCustomModule(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_security_health_analytics_custom_module_flattened_error(): + client = SecurityCenterManagementClient( + 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_security_health_analytics_custom_module( + security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest(), + security_health_analytics_custom_module=security_center_management.SecurityHealthAnalyticsCustomModule(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + +@pytest.mark.asyncio +async def test_update_security_health_analytics_custom_module_flattened_async(): + client = SecurityCenterManagementAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_security_health_analytics_custom_module), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = security_center_management.SecurityHealthAnalyticsCustomModule() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.SecurityHealthAnalyticsCustomModule()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_security_health_analytics_custom_module( + security_health_analytics_custom_module=security_center_management.SecurityHealthAnalyticsCustomModule(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].security_health_analytics_custom_module + mock_val = security_center_management.SecurityHealthAnalyticsCustomModule(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_security_health_analytics_custom_module_flattened_error_async(): + client = SecurityCenterManagementAsyncClient( + 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_security_health_analytics_custom_module( + security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest(), + security_health_analytics_custom_module=security_center_management.SecurityHealthAnalyticsCustomModule(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.parametrize("request_type", [ + security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest, + dict, +]) +def test_delete_security_health_analytics_custom_module(request_type, transport: str = 'grpc'): + client = SecurityCenterManagementClient( + 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_security_health_analytics_custom_module), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + response = client.delete_security_health_analytics_custom_module(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +def test_delete_security_health_analytics_custom_module_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 = SecurityCenterManagementClient( + 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_security_health_analytics_custom_module), + '__call__') as call: + client.delete_security_health_analytics_custom_module() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest() + +@pytest.mark.asyncio +async def test_delete_security_health_analytics_custom_module_async(transport: str = 'grpc_asyncio', request_type=security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest): + client = SecurityCenterManagementAsyncClient( + 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_security_health_analytics_custom_module), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + response = await client.delete_security_health_analytics_custom_module(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +@pytest.mark.asyncio +async def test_delete_security_health_analytics_custom_module_async_from_dict(): + await test_delete_security_health_analytics_custom_module_async(request_type=dict) + + +def test_delete_security_health_analytics_custom_module_field_headers(): + client = SecurityCenterManagementClient( + 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 = security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_security_health_analytics_custom_module), + '__call__') as call: + call.return_value = None + client.delete_security_health_analytics_custom_module(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_security_health_analytics_custom_module_field_headers_async(): + client = SecurityCenterManagementAsyncClient( + 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 = security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_security_health_analytics_custom_module), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + await client.delete_security_health_analytics_custom_module(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_security_health_analytics_custom_module_flattened(): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_security_health_analytics_custom_module), + '__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_security_health_analytics_custom_module( + 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_security_health_analytics_custom_module_flattened_error(): + client = SecurityCenterManagementClient( + 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_security_health_analytics_custom_module( + security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_delete_security_health_analytics_custom_module_flattened_async(): + client = SecurityCenterManagementAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_security_health_analytics_custom_module), + '__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_security_health_analytics_custom_module( + 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_security_health_analytics_custom_module_flattened_error_async(): + client = SecurityCenterManagementAsyncClient( + 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_security_health_analytics_custom_module( + security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest, + dict, +]) +def test_simulate_security_health_analytics_custom_module(request_type, transport: str = 'grpc'): + client = SecurityCenterManagementClient( + 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.simulate_security_health_analytics_custom_module), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse( + ) + response = client.simulate_security_health_analytics_custom_module(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse) + + +def test_simulate_security_health_analytics_custom_module_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 = SecurityCenterManagementClient( + 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.simulate_security_health_analytics_custom_module), + '__call__') as call: + client.simulate_security_health_analytics_custom_module() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest() + +@pytest.mark.asyncio +async def test_simulate_security_health_analytics_custom_module_async(transport: str = 'grpc_asyncio', request_type=security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest): + client = SecurityCenterManagementAsyncClient( + 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.simulate_security_health_analytics_custom_module), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse( + )) + response = await client.simulate_security_health_analytics_custom_module(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse) + + +@pytest.mark.asyncio +async def test_simulate_security_health_analytics_custom_module_async_from_dict(): + await test_simulate_security_health_analytics_custom_module_async(request_type=dict) + + +def test_simulate_security_health_analytics_custom_module_field_headers(): + client = SecurityCenterManagementClient( + 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 = security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.simulate_security_health_analytics_custom_module), + '__call__') as call: + call.return_value = security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse() + client.simulate_security_health_analytics_custom_module(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_simulate_security_health_analytics_custom_module_field_headers_async(): + client = SecurityCenterManagementAsyncClient( + 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 = security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.simulate_security_health_analytics_custom_module), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse()) + await client.simulate_security_health_analytics_custom_module(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_simulate_security_health_analytics_custom_module_flattened(): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.simulate_security_health_analytics_custom_module), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.simulate_security_health_analytics_custom_module( + parent='parent_value', + custom_config=security_center_management.CustomConfig(predicate=expr_pb2.Expr(expression='expression_value')), + resource=security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest.SimulatedResource(resource_type='resource_type_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].custom_config + mock_val = security_center_management.CustomConfig(predicate=expr_pb2.Expr(expression='expression_value')) + assert arg == mock_val + arg = args[0].resource + mock_val = security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest.SimulatedResource(resource_type='resource_type_value') + assert arg == mock_val + + +def test_simulate_security_health_analytics_custom_module_flattened_error(): + client = SecurityCenterManagementClient( + 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.simulate_security_health_analytics_custom_module( + security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest(), + parent='parent_value', + custom_config=security_center_management.CustomConfig(predicate=expr_pb2.Expr(expression='expression_value')), + resource=security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest.SimulatedResource(resource_type='resource_type_value'), + ) + +@pytest.mark.asyncio +async def test_simulate_security_health_analytics_custom_module_flattened_async(): + client = SecurityCenterManagementAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.simulate_security_health_analytics_custom_module), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.simulate_security_health_analytics_custom_module( + parent='parent_value', + custom_config=security_center_management.CustomConfig(predicate=expr_pb2.Expr(expression='expression_value')), + resource=security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest.SimulatedResource(resource_type='resource_type_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].custom_config + mock_val = security_center_management.CustomConfig(predicate=expr_pb2.Expr(expression='expression_value')) + assert arg == mock_val + arg = args[0].resource + mock_val = security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest.SimulatedResource(resource_type='resource_type_value') + assert arg == mock_val + +@pytest.mark.asyncio +async def test_simulate_security_health_analytics_custom_module_flattened_error_async(): + client = SecurityCenterManagementAsyncClient( + 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.simulate_security_health_analytics_custom_module( + security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest(), + parent='parent_value', + custom_config=security_center_management.CustomConfig(predicate=expr_pb2.Expr(expression='expression_value')), + resource=security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest.SimulatedResource(resource_type='resource_type_value'), + ) + + +@pytest.mark.parametrize("request_type", [ + security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest, + dict, +]) +def test_list_effective_event_threat_detection_custom_modules(request_type, transport: str = 'grpc'): + client = SecurityCenterManagementClient( + 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_effective_event_threat_detection_custom_modules), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse( + next_page_token='next_page_token_value', + ) + response = client.list_effective_event_threat_detection_custom_modules(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListEffectiveEventThreatDetectionCustomModulesPager) + assert response.next_page_token == 'next_page_token_value' + + +def test_list_effective_event_threat_detection_custom_modules_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 = SecurityCenterManagementClient( + 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_effective_event_threat_detection_custom_modules), + '__call__') as call: + client.list_effective_event_threat_detection_custom_modules() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest() + +@pytest.mark.asyncio +async def test_list_effective_event_threat_detection_custom_modules_async(transport: str = 'grpc_asyncio', request_type=security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest): + client = SecurityCenterManagementAsyncClient( + 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_effective_event_threat_detection_custom_modules), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse( + next_page_token='next_page_token_value', + )) + response = await client.list_effective_event_threat_detection_custom_modules(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListEffectiveEventThreatDetectionCustomModulesAsyncPager) + assert response.next_page_token == 'next_page_token_value' + + +@pytest.mark.asyncio +async def test_list_effective_event_threat_detection_custom_modules_async_from_dict(): + await test_list_effective_event_threat_detection_custom_modules_async(request_type=dict) + + +def test_list_effective_event_threat_detection_custom_modules_field_headers(): + client = SecurityCenterManagementClient( + 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 = security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_effective_event_threat_detection_custom_modules), + '__call__') as call: + call.return_value = security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse() + client.list_effective_event_threat_detection_custom_modules(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_effective_event_threat_detection_custom_modules_field_headers_async(): + client = SecurityCenterManagementAsyncClient( + 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 = security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_effective_event_threat_detection_custom_modules), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse()) + await client.list_effective_event_threat_detection_custom_modules(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_effective_event_threat_detection_custom_modules_flattened(): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_effective_event_threat_detection_custom_modules), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_effective_event_threat_detection_custom_modules( + 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_effective_event_threat_detection_custom_modules_flattened_error(): + client = SecurityCenterManagementClient( + 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_effective_event_threat_detection_custom_modules( + security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest(), + parent='parent_value', + ) + +@pytest.mark.asyncio +async def test_list_effective_event_threat_detection_custom_modules_flattened_async(): + client = SecurityCenterManagementAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_effective_event_threat_detection_custom_modules), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_effective_event_threat_detection_custom_modules( + 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_effective_event_threat_detection_custom_modules_flattened_error_async(): + client = SecurityCenterManagementAsyncClient( + 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_effective_event_threat_detection_custom_modules( + security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest(), + parent='parent_value', + ) + + +def test_list_effective_event_threat_detection_custom_modules_pager(transport_name: str = "grpc"): + client = SecurityCenterManagementClient( + 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_effective_event_threat_detection_custom_modules), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse( + effective_event_threat_detection_custom_modules=[ + security_center_management.EffectiveEventThreatDetectionCustomModule(), + security_center_management.EffectiveEventThreatDetectionCustomModule(), + security_center_management.EffectiveEventThreatDetectionCustomModule(), + ], + next_page_token='abc', + ), + security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse( + effective_event_threat_detection_custom_modules=[], + next_page_token='def', + ), + security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse( + effective_event_threat_detection_custom_modules=[ + security_center_management.EffectiveEventThreatDetectionCustomModule(), + ], + next_page_token='ghi', + ), + security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse( + effective_event_threat_detection_custom_modules=[ + security_center_management.EffectiveEventThreatDetectionCustomModule(), + security_center_management.EffectiveEventThreatDetectionCustomModule(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_effective_event_threat_detection_custom_modules(request={}) + + assert pager._metadata == metadata + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, security_center_management.EffectiveEventThreatDetectionCustomModule) + for i in results) +def test_list_effective_event_threat_detection_custom_modules_pages(transport_name: str = "grpc"): + client = SecurityCenterManagementClient( + 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_effective_event_threat_detection_custom_modules), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse( + effective_event_threat_detection_custom_modules=[ + security_center_management.EffectiveEventThreatDetectionCustomModule(), + security_center_management.EffectiveEventThreatDetectionCustomModule(), + security_center_management.EffectiveEventThreatDetectionCustomModule(), + ], + next_page_token='abc', + ), + security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse( + effective_event_threat_detection_custom_modules=[], + next_page_token='def', + ), + security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse( + effective_event_threat_detection_custom_modules=[ + security_center_management.EffectiveEventThreatDetectionCustomModule(), + ], + next_page_token='ghi', + ), + security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse( + effective_event_threat_detection_custom_modules=[ + security_center_management.EffectiveEventThreatDetectionCustomModule(), + security_center_management.EffectiveEventThreatDetectionCustomModule(), + ], + ), + RuntimeError, + ) + pages = list(client.list_effective_event_threat_detection_custom_modules(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_effective_event_threat_detection_custom_modules_async_pager(): + client = SecurityCenterManagementAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_effective_event_threat_detection_custom_modules), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse( + effective_event_threat_detection_custom_modules=[ + security_center_management.EffectiveEventThreatDetectionCustomModule(), + security_center_management.EffectiveEventThreatDetectionCustomModule(), + security_center_management.EffectiveEventThreatDetectionCustomModule(), + ], + next_page_token='abc', + ), + security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse( + effective_event_threat_detection_custom_modules=[], + next_page_token='def', + ), + security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse( + effective_event_threat_detection_custom_modules=[ + security_center_management.EffectiveEventThreatDetectionCustomModule(), + ], + next_page_token='ghi', + ), + security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse( + effective_event_threat_detection_custom_modules=[ + security_center_management.EffectiveEventThreatDetectionCustomModule(), + security_center_management.EffectiveEventThreatDetectionCustomModule(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_effective_event_threat_detection_custom_modules(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, security_center_management.EffectiveEventThreatDetectionCustomModule) + for i in responses) + + +@pytest.mark.asyncio +async def test_list_effective_event_threat_detection_custom_modules_async_pages(): + client = SecurityCenterManagementAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_effective_event_threat_detection_custom_modules), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse( + effective_event_threat_detection_custom_modules=[ + security_center_management.EffectiveEventThreatDetectionCustomModule(), + security_center_management.EffectiveEventThreatDetectionCustomModule(), + security_center_management.EffectiveEventThreatDetectionCustomModule(), + ], + next_page_token='abc', + ), + security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse( + effective_event_threat_detection_custom_modules=[], + next_page_token='def', + ), + security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse( + effective_event_threat_detection_custom_modules=[ + security_center_management.EffectiveEventThreatDetectionCustomModule(), + ], + next_page_token='ghi', + ), + security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse( + effective_event_threat_detection_custom_modules=[ + security_center_management.EffectiveEventThreatDetectionCustomModule(), + security_center_management.EffectiveEventThreatDetectionCustomModule(), + ], + ), + 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_effective_event_threat_detection_custom_modules(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", [ + security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest, + dict, +]) +def test_get_effective_event_threat_detection_custom_module(request_type, transport: str = 'grpc'): + client = SecurityCenterManagementClient( + 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_effective_event_threat_detection_custom_module), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = security_center_management.EffectiveEventThreatDetectionCustomModule( + name='name_value', + enablement_state=security_center_management.EffectiveEventThreatDetectionCustomModule.EnablementState.ENABLED, + type_='type__value', + display_name='display_name_value', + description='description_value', + ) + response = client.get_effective_event_threat_detection_custom_module(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, security_center_management.EffectiveEventThreatDetectionCustomModule) + assert response.name == 'name_value' + assert response.enablement_state == security_center_management.EffectiveEventThreatDetectionCustomModule.EnablementState.ENABLED + assert response.type_ == 'type__value' + assert response.display_name == 'display_name_value' + assert response.description == 'description_value' + + +def test_get_effective_event_threat_detection_custom_module_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 = SecurityCenterManagementClient( + 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_effective_event_threat_detection_custom_module), + '__call__') as call: + client.get_effective_event_threat_detection_custom_module() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest() + +@pytest.mark.asyncio +async def test_get_effective_event_threat_detection_custom_module_async(transport: str = 'grpc_asyncio', request_type=security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest): + client = SecurityCenterManagementAsyncClient( + 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_effective_event_threat_detection_custom_module), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.EffectiveEventThreatDetectionCustomModule( + name='name_value', + enablement_state=security_center_management.EffectiveEventThreatDetectionCustomModule.EnablementState.ENABLED, + type_='type__value', + display_name='display_name_value', + description='description_value', + )) + response = await client.get_effective_event_threat_detection_custom_module(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, security_center_management.EffectiveEventThreatDetectionCustomModule) + assert response.name == 'name_value' + assert response.enablement_state == security_center_management.EffectiveEventThreatDetectionCustomModule.EnablementState.ENABLED + assert response.type_ == 'type__value' + assert response.display_name == 'display_name_value' + assert response.description == 'description_value' + + +@pytest.mark.asyncio +async def test_get_effective_event_threat_detection_custom_module_async_from_dict(): + await test_get_effective_event_threat_detection_custom_module_async(request_type=dict) + + +def test_get_effective_event_threat_detection_custom_module_field_headers(): + client = SecurityCenterManagementClient( + 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 = security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_effective_event_threat_detection_custom_module), + '__call__') as call: + call.return_value = security_center_management.EffectiveEventThreatDetectionCustomModule() + client.get_effective_event_threat_detection_custom_module(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_effective_event_threat_detection_custom_module_field_headers_async(): + client = SecurityCenterManagementAsyncClient( + 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 = security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_effective_event_threat_detection_custom_module), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.EffectiveEventThreatDetectionCustomModule()) + await client.get_effective_event_threat_detection_custom_module(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_effective_event_threat_detection_custom_module_flattened(): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_effective_event_threat_detection_custom_module), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = security_center_management.EffectiveEventThreatDetectionCustomModule() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_effective_event_threat_detection_custom_module( + 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_effective_event_threat_detection_custom_module_flattened_error(): + client = SecurityCenterManagementClient( + 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_effective_event_threat_detection_custom_module( + security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_get_effective_event_threat_detection_custom_module_flattened_async(): + client = SecurityCenterManagementAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_effective_event_threat_detection_custom_module), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = security_center_management.EffectiveEventThreatDetectionCustomModule() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.EffectiveEventThreatDetectionCustomModule()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_effective_event_threat_detection_custom_module( + 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_effective_event_threat_detection_custom_module_flattened_error_async(): + client = SecurityCenterManagementAsyncClient( + 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_effective_event_threat_detection_custom_module( + security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + security_center_management.ListEventThreatDetectionCustomModulesRequest, + dict, +]) +def test_list_event_threat_detection_custom_modules(request_type, transport: str = 'grpc'): + client = SecurityCenterManagementClient( + 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_event_threat_detection_custom_modules), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = security_center_management.ListEventThreatDetectionCustomModulesResponse( + next_page_token='next_page_token_value', + ) + response = client.list_event_threat_detection_custom_modules(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == security_center_management.ListEventThreatDetectionCustomModulesRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListEventThreatDetectionCustomModulesPager) + assert response.next_page_token == 'next_page_token_value' + + +def test_list_event_threat_detection_custom_modules_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 = SecurityCenterManagementClient( + 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_event_threat_detection_custom_modules), + '__call__') as call: + client.list_event_threat_detection_custom_modules() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == security_center_management.ListEventThreatDetectionCustomModulesRequest() + +@pytest.mark.asyncio +async def test_list_event_threat_detection_custom_modules_async(transport: str = 'grpc_asyncio', request_type=security_center_management.ListEventThreatDetectionCustomModulesRequest): + client = SecurityCenterManagementAsyncClient( + 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_event_threat_detection_custom_modules), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.ListEventThreatDetectionCustomModulesResponse( + next_page_token='next_page_token_value', + )) + response = await client.list_event_threat_detection_custom_modules(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == security_center_management.ListEventThreatDetectionCustomModulesRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListEventThreatDetectionCustomModulesAsyncPager) + assert response.next_page_token == 'next_page_token_value' + + +@pytest.mark.asyncio +async def test_list_event_threat_detection_custom_modules_async_from_dict(): + await test_list_event_threat_detection_custom_modules_async(request_type=dict) + + +def test_list_event_threat_detection_custom_modules_field_headers(): + client = SecurityCenterManagementClient( + 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 = security_center_management.ListEventThreatDetectionCustomModulesRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_event_threat_detection_custom_modules), + '__call__') as call: + call.return_value = security_center_management.ListEventThreatDetectionCustomModulesResponse() + client.list_event_threat_detection_custom_modules(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_event_threat_detection_custom_modules_field_headers_async(): + client = SecurityCenterManagementAsyncClient( + 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 = security_center_management.ListEventThreatDetectionCustomModulesRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_event_threat_detection_custom_modules), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.ListEventThreatDetectionCustomModulesResponse()) + await client.list_event_threat_detection_custom_modules(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_event_threat_detection_custom_modules_flattened(): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_event_threat_detection_custom_modules), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = security_center_management.ListEventThreatDetectionCustomModulesResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_event_threat_detection_custom_modules( + 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_event_threat_detection_custom_modules_flattened_error(): + client = SecurityCenterManagementClient( + 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_event_threat_detection_custom_modules( + security_center_management.ListEventThreatDetectionCustomModulesRequest(), + parent='parent_value', + ) + +@pytest.mark.asyncio +async def test_list_event_threat_detection_custom_modules_flattened_async(): + client = SecurityCenterManagementAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_event_threat_detection_custom_modules), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = security_center_management.ListEventThreatDetectionCustomModulesResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.ListEventThreatDetectionCustomModulesResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_event_threat_detection_custom_modules( + 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_event_threat_detection_custom_modules_flattened_error_async(): + client = SecurityCenterManagementAsyncClient( + 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_event_threat_detection_custom_modules( + security_center_management.ListEventThreatDetectionCustomModulesRequest(), + parent='parent_value', + ) + + +def test_list_event_threat_detection_custom_modules_pager(transport_name: str = "grpc"): + client = SecurityCenterManagementClient( + 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_event_threat_detection_custom_modules), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + security_center_management.ListEventThreatDetectionCustomModulesResponse( + event_threat_detection_custom_modules=[ + security_center_management.EventThreatDetectionCustomModule(), + security_center_management.EventThreatDetectionCustomModule(), + security_center_management.EventThreatDetectionCustomModule(), + ], + next_page_token='abc', + ), + security_center_management.ListEventThreatDetectionCustomModulesResponse( + event_threat_detection_custom_modules=[], + next_page_token='def', + ), + security_center_management.ListEventThreatDetectionCustomModulesResponse( + event_threat_detection_custom_modules=[ + security_center_management.EventThreatDetectionCustomModule(), + ], + next_page_token='ghi', + ), + security_center_management.ListEventThreatDetectionCustomModulesResponse( + event_threat_detection_custom_modules=[ + security_center_management.EventThreatDetectionCustomModule(), + security_center_management.EventThreatDetectionCustomModule(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_event_threat_detection_custom_modules(request={}) + + assert pager._metadata == metadata + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, security_center_management.EventThreatDetectionCustomModule) + for i in results) +def test_list_event_threat_detection_custom_modules_pages(transport_name: str = "grpc"): + client = SecurityCenterManagementClient( + 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_event_threat_detection_custom_modules), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + security_center_management.ListEventThreatDetectionCustomModulesResponse( + event_threat_detection_custom_modules=[ + security_center_management.EventThreatDetectionCustomModule(), + security_center_management.EventThreatDetectionCustomModule(), + security_center_management.EventThreatDetectionCustomModule(), + ], + next_page_token='abc', + ), + security_center_management.ListEventThreatDetectionCustomModulesResponse( + event_threat_detection_custom_modules=[], + next_page_token='def', + ), + security_center_management.ListEventThreatDetectionCustomModulesResponse( + event_threat_detection_custom_modules=[ + security_center_management.EventThreatDetectionCustomModule(), + ], + next_page_token='ghi', + ), + security_center_management.ListEventThreatDetectionCustomModulesResponse( + event_threat_detection_custom_modules=[ + security_center_management.EventThreatDetectionCustomModule(), + security_center_management.EventThreatDetectionCustomModule(), + ], + ), + RuntimeError, + ) + pages = list(client.list_event_threat_detection_custom_modules(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_event_threat_detection_custom_modules_async_pager(): + client = SecurityCenterManagementAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_event_threat_detection_custom_modules), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + security_center_management.ListEventThreatDetectionCustomModulesResponse( + event_threat_detection_custom_modules=[ + security_center_management.EventThreatDetectionCustomModule(), + security_center_management.EventThreatDetectionCustomModule(), + security_center_management.EventThreatDetectionCustomModule(), + ], + next_page_token='abc', + ), + security_center_management.ListEventThreatDetectionCustomModulesResponse( + event_threat_detection_custom_modules=[], + next_page_token='def', + ), + security_center_management.ListEventThreatDetectionCustomModulesResponse( + event_threat_detection_custom_modules=[ + security_center_management.EventThreatDetectionCustomModule(), + ], + next_page_token='ghi', + ), + security_center_management.ListEventThreatDetectionCustomModulesResponse( + event_threat_detection_custom_modules=[ + security_center_management.EventThreatDetectionCustomModule(), + security_center_management.EventThreatDetectionCustomModule(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_event_threat_detection_custom_modules(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, security_center_management.EventThreatDetectionCustomModule) + for i in responses) + + +@pytest.mark.asyncio +async def test_list_event_threat_detection_custom_modules_async_pages(): + client = SecurityCenterManagementAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_event_threat_detection_custom_modules), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + security_center_management.ListEventThreatDetectionCustomModulesResponse( + event_threat_detection_custom_modules=[ + security_center_management.EventThreatDetectionCustomModule(), + security_center_management.EventThreatDetectionCustomModule(), + security_center_management.EventThreatDetectionCustomModule(), + ], + next_page_token='abc', + ), + security_center_management.ListEventThreatDetectionCustomModulesResponse( + event_threat_detection_custom_modules=[], + next_page_token='def', + ), + security_center_management.ListEventThreatDetectionCustomModulesResponse( + event_threat_detection_custom_modules=[ + security_center_management.EventThreatDetectionCustomModule(), + ], + next_page_token='ghi', + ), + security_center_management.ListEventThreatDetectionCustomModulesResponse( + event_threat_detection_custom_modules=[ + security_center_management.EventThreatDetectionCustomModule(), + security_center_management.EventThreatDetectionCustomModule(), + ], + ), + 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_event_threat_detection_custom_modules(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", [ + security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest, + dict, +]) +def test_list_descendant_event_threat_detection_custom_modules(request_type, transport: str = 'grpc'): + client = SecurityCenterManagementClient( + 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_descendant_event_threat_detection_custom_modules), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse( + next_page_token='next_page_token_value', + ) + response = client.list_descendant_event_threat_detection_custom_modules(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListDescendantEventThreatDetectionCustomModulesPager) + assert response.next_page_token == 'next_page_token_value' + + +def test_list_descendant_event_threat_detection_custom_modules_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 = SecurityCenterManagementClient( + 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_descendant_event_threat_detection_custom_modules), + '__call__') as call: + client.list_descendant_event_threat_detection_custom_modules() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest() + +@pytest.mark.asyncio +async def test_list_descendant_event_threat_detection_custom_modules_async(transport: str = 'grpc_asyncio', request_type=security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest): + client = SecurityCenterManagementAsyncClient( + 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_descendant_event_threat_detection_custom_modules), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse( + next_page_token='next_page_token_value', + )) + response = await client.list_descendant_event_threat_detection_custom_modules(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListDescendantEventThreatDetectionCustomModulesAsyncPager) + assert response.next_page_token == 'next_page_token_value' + + +@pytest.mark.asyncio +async def test_list_descendant_event_threat_detection_custom_modules_async_from_dict(): + await test_list_descendant_event_threat_detection_custom_modules_async(request_type=dict) + + +def test_list_descendant_event_threat_detection_custom_modules_field_headers(): + client = SecurityCenterManagementClient( + 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 = security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_descendant_event_threat_detection_custom_modules), + '__call__') as call: + call.return_value = security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse() + client.list_descendant_event_threat_detection_custom_modules(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_descendant_event_threat_detection_custom_modules_field_headers_async(): + client = SecurityCenterManagementAsyncClient( + 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 = security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_descendant_event_threat_detection_custom_modules), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse()) + await client.list_descendant_event_threat_detection_custom_modules(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_descendant_event_threat_detection_custom_modules_flattened(): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_descendant_event_threat_detection_custom_modules), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.list_descendant_event_threat_detection_custom_modules( + 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_descendant_event_threat_detection_custom_modules_flattened_error(): + client = SecurityCenterManagementClient( + 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_descendant_event_threat_detection_custom_modules( + security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest(), + parent='parent_value', + ) + +@pytest.mark.asyncio +async def test_list_descendant_event_threat_detection_custom_modules_flattened_async(): + client = SecurityCenterManagementAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_descendant_event_threat_detection_custom_modules), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.list_descendant_event_threat_detection_custom_modules( + 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_descendant_event_threat_detection_custom_modules_flattened_error_async(): + client = SecurityCenterManagementAsyncClient( + 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_descendant_event_threat_detection_custom_modules( + security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest(), + parent='parent_value', + ) + + +def test_list_descendant_event_threat_detection_custom_modules_pager(transport_name: str = "grpc"): + client = SecurityCenterManagementClient( + 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_descendant_event_threat_detection_custom_modules), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse( + event_threat_detection_custom_modules=[ + security_center_management.EventThreatDetectionCustomModule(), + security_center_management.EventThreatDetectionCustomModule(), + security_center_management.EventThreatDetectionCustomModule(), + ], + next_page_token='abc', + ), + security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse( + event_threat_detection_custom_modules=[], + next_page_token='def', + ), + security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse( + event_threat_detection_custom_modules=[ + security_center_management.EventThreatDetectionCustomModule(), + ], + next_page_token='ghi', + ), + security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse( + event_threat_detection_custom_modules=[ + security_center_management.EventThreatDetectionCustomModule(), + security_center_management.EventThreatDetectionCustomModule(), + ], + ), + RuntimeError, + ) + + metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata(( + ('parent', ''), + )), + ) + pager = client.list_descendant_event_threat_detection_custom_modules(request={}) + + assert pager._metadata == metadata + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, security_center_management.EventThreatDetectionCustomModule) + for i in results) +def test_list_descendant_event_threat_detection_custom_modules_pages(transport_name: str = "grpc"): + client = SecurityCenterManagementClient( + 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_descendant_event_threat_detection_custom_modules), + '__call__') as call: + # Set the response to a series of pages. + call.side_effect = ( + security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse( + event_threat_detection_custom_modules=[ + security_center_management.EventThreatDetectionCustomModule(), + security_center_management.EventThreatDetectionCustomModule(), + security_center_management.EventThreatDetectionCustomModule(), + ], + next_page_token='abc', + ), + security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse( + event_threat_detection_custom_modules=[], + next_page_token='def', + ), + security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse( + event_threat_detection_custom_modules=[ + security_center_management.EventThreatDetectionCustomModule(), + ], + next_page_token='ghi', + ), + security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse( + event_threat_detection_custom_modules=[ + security_center_management.EventThreatDetectionCustomModule(), + security_center_management.EventThreatDetectionCustomModule(), + ], + ), + RuntimeError, + ) + pages = list(client.list_descendant_event_threat_detection_custom_modules(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_descendant_event_threat_detection_custom_modules_async_pager(): + client = SecurityCenterManagementAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_descendant_event_threat_detection_custom_modules), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse( + event_threat_detection_custom_modules=[ + security_center_management.EventThreatDetectionCustomModule(), + security_center_management.EventThreatDetectionCustomModule(), + security_center_management.EventThreatDetectionCustomModule(), + ], + next_page_token='abc', + ), + security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse( + event_threat_detection_custom_modules=[], + next_page_token='def', + ), + security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse( + event_threat_detection_custom_modules=[ + security_center_management.EventThreatDetectionCustomModule(), + ], + next_page_token='ghi', + ), + security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse( + event_threat_detection_custom_modules=[ + security_center_management.EventThreatDetectionCustomModule(), + security_center_management.EventThreatDetectionCustomModule(), + ], + ), + RuntimeError, + ) + async_pager = await client.list_descendant_event_threat_detection_custom_modules(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, security_center_management.EventThreatDetectionCustomModule) + for i in responses) + + +@pytest.mark.asyncio +async def test_list_descendant_event_threat_detection_custom_modules_async_pages(): + client = SecurityCenterManagementAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_descendant_event_threat_detection_custom_modules), + '__call__', new_callable=mock.AsyncMock) as call: + # Set the response to a series of pages. + call.side_effect = ( + security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse( + event_threat_detection_custom_modules=[ + security_center_management.EventThreatDetectionCustomModule(), + security_center_management.EventThreatDetectionCustomModule(), + security_center_management.EventThreatDetectionCustomModule(), + ], + next_page_token='abc', + ), + security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse( + event_threat_detection_custom_modules=[], + next_page_token='def', + ), + security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse( + event_threat_detection_custom_modules=[ + security_center_management.EventThreatDetectionCustomModule(), + ], + next_page_token='ghi', + ), + security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse( + event_threat_detection_custom_modules=[ + security_center_management.EventThreatDetectionCustomModule(), + security_center_management.EventThreatDetectionCustomModule(), + ], + ), + 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_descendant_event_threat_detection_custom_modules(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", [ + security_center_management.GetEventThreatDetectionCustomModuleRequest, + dict, +]) +def test_get_event_threat_detection_custom_module(request_type, transport: str = 'grpc'): + client = SecurityCenterManagementClient( + 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_event_threat_detection_custom_module), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = security_center_management.EventThreatDetectionCustomModule( + name='name_value', + ancestor_module='ancestor_module_value', + enablement_state=security_center_management.EventThreatDetectionCustomModule.EnablementState.ENABLED, + type_='type__value', + display_name='display_name_value', + description='description_value', + last_editor='last_editor_value', + ) + response = client.get_event_threat_detection_custom_module(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == security_center_management.GetEventThreatDetectionCustomModuleRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, security_center_management.EventThreatDetectionCustomModule) + assert response.name == 'name_value' + assert response.ancestor_module == 'ancestor_module_value' + assert response.enablement_state == security_center_management.EventThreatDetectionCustomModule.EnablementState.ENABLED + assert response.type_ == 'type__value' + assert response.display_name == 'display_name_value' + assert response.description == 'description_value' + assert response.last_editor == 'last_editor_value' + + +def test_get_event_threat_detection_custom_module_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 = SecurityCenterManagementClient( + 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_event_threat_detection_custom_module), + '__call__') as call: + client.get_event_threat_detection_custom_module() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == security_center_management.GetEventThreatDetectionCustomModuleRequest() + +@pytest.mark.asyncio +async def test_get_event_threat_detection_custom_module_async(transport: str = 'grpc_asyncio', request_type=security_center_management.GetEventThreatDetectionCustomModuleRequest): + client = SecurityCenterManagementAsyncClient( + 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_event_threat_detection_custom_module), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.EventThreatDetectionCustomModule( + name='name_value', + ancestor_module='ancestor_module_value', + enablement_state=security_center_management.EventThreatDetectionCustomModule.EnablementState.ENABLED, + type_='type__value', + display_name='display_name_value', + description='description_value', + last_editor='last_editor_value', + )) + response = await client.get_event_threat_detection_custom_module(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == security_center_management.GetEventThreatDetectionCustomModuleRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, security_center_management.EventThreatDetectionCustomModule) + assert response.name == 'name_value' + assert response.ancestor_module == 'ancestor_module_value' + assert response.enablement_state == security_center_management.EventThreatDetectionCustomModule.EnablementState.ENABLED + assert response.type_ == 'type__value' + assert response.display_name == 'display_name_value' + assert response.description == 'description_value' + assert response.last_editor == 'last_editor_value' + + +@pytest.mark.asyncio +async def test_get_event_threat_detection_custom_module_async_from_dict(): + await test_get_event_threat_detection_custom_module_async(request_type=dict) + + +def test_get_event_threat_detection_custom_module_field_headers(): + client = SecurityCenterManagementClient( + 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 = security_center_management.GetEventThreatDetectionCustomModuleRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_event_threat_detection_custom_module), + '__call__') as call: + call.return_value = security_center_management.EventThreatDetectionCustomModule() + client.get_event_threat_detection_custom_module(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_event_threat_detection_custom_module_field_headers_async(): + client = SecurityCenterManagementAsyncClient( + 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 = security_center_management.GetEventThreatDetectionCustomModuleRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_event_threat_detection_custom_module), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.EventThreatDetectionCustomModule()) + await client.get_event_threat_detection_custom_module(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_event_threat_detection_custom_module_flattened(): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_event_threat_detection_custom_module), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = security_center_management.EventThreatDetectionCustomModule() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.get_event_threat_detection_custom_module( + 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_event_threat_detection_custom_module_flattened_error(): + client = SecurityCenterManagementClient( + 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_event_threat_detection_custom_module( + security_center_management.GetEventThreatDetectionCustomModuleRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_get_event_threat_detection_custom_module_flattened_async(): + client = SecurityCenterManagementAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_event_threat_detection_custom_module), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = security_center_management.EventThreatDetectionCustomModule() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.EventThreatDetectionCustomModule()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.get_event_threat_detection_custom_module( + 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_event_threat_detection_custom_module_flattened_error_async(): + client = SecurityCenterManagementAsyncClient( + 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_event_threat_detection_custom_module( + security_center_management.GetEventThreatDetectionCustomModuleRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + security_center_management.CreateEventThreatDetectionCustomModuleRequest, + dict, +]) +def test_create_event_threat_detection_custom_module(request_type, transport: str = 'grpc'): + client = SecurityCenterManagementClient( + 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_event_threat_detection_custom_module), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = security_center_management.EventThreatDetectionCustomModule( + name='name_value', + ancestor_module='ancestor_module_value', + enablement_state=security_center_management.EventThreatDetectionCustomModule.EnablementState.ENABLED, + type_='type__value', + display_name='display_name_value', + description='description_value', + last_editor='last_editor_value', + ) + response = client.create_event_threat_detection_custom_module(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == security_center_management.CreateEventThreatDetectionCustomModuleRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, security_center_management.EventThreatDetectionCustomModule) + assert response.name == 'name_value' + assert response.ancestor_module == 'ancestor_module_value' + assert response.enablement_state == security_center_management.EventThreatDetectionCustomModule.EnablementState.ENABLED + assert response.type_ == 'type__value' + assert response.display_name == 'display_name_value' + assert response.description == 'description_value' + assert response.last_editor == 'last_editor_value' + + +def test_create_event_threat_detection_custom_module_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 = SecurityCenterManagementClient( + 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_event_threat_detection_custom_module), + '__call__') as call: + client.create_event_threat_detection_custom_module() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == security_center_management.CreateEventThreatDetectionCustomModuleRequest() + +@pytest.mark.asyncio +async def test_create_event_threat_detection_custom_module_async(transport: str = 'grpc_asyncio', request_type=security_center_management.CreateEventThreatDetectionCustomModuleRequest): + client = SecurityCenterManagementAsyncClient( + 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_event_threat_detection_custom_module), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.EventThreatDetectionCustomModule( + name='name_value', + ancestor_module='ancestor_module_value', + enablement_state=security_center_management.EventThreatDetectionCustomModule.EnablementState.ENABLED, + type_='type__value', + display_name='display_name_value', + description='description_value', + last_editor='last_editor_value', + )) + response = await client.create_event_threat_detection_custom_module(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == security_center_management.CreateEventThreatDetectionCustomModuleRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, security_center_management.EventThreatDetectionCustomModule) + assert response.name == 'name_value' + assert response.ancestor_module == 'ancestor_module_value' + assert response.enablement_state == security_center_management.EventThreatDetectionCustomModule.EnablementState.ENABLED + assert response.type_ == 'type__value' + assert response.display_name == 'display_name_value' + assert response.description == 'description_value' + assert response.last_editor == 'last_editor_value' + + +@pytest.mark.asyncio +async def test_create_event_threat_detection_custom_module_async_from_dict(): + await test_create_event_threat_detection_custom_module_async(request_type=dict) + + +def test_create_event_threat_detection_custom_module_field_headers(): + client = SecurityCenterManagementClient( + 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 = security_center_management.CreateEventThreatDetectionCustomModuleRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_event_threat_detection_custom_module), + '__call__') as call: + call.return_value = security_center_management.EventThreatDetectionCustomModule() + client.create_event_threat_detection_custom_module(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_event_threat_detection_custom_module_field_headers_async(): + client = SecurityCenterManagementAsyncClient( + 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 = security_center_management.CreateEventThreatDetectionCustomModuleRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_event_threat_detection_custom_module), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.EventThreatDetectionCustomModule()) + await client.create_event_threat_detection_custom_module(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_event_threat_detection_custom_module_flattened(): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_event_threat_detection_custom_module), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = security_center_management.EventThreatDetectionCustomModule() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.create_event_threat_detection_custom_module( + parent='parent_value', + event_threat_detection_custom_module=security_center_management.EventThreatDetectionCustomModule(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].event_threat_detection_custom_module + mock_val = security_center_management.EventThreatDetectionCustomModule(name='name_value') + assert arg == mock_val + + +def test_create_event_threat_detection_custom_module_flattened_error(): + client = SecurityCenterManagementClient( + 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_event_threat_detection_custom_module( + security_center_management.CreateEventThreatDetectionCustomModuleRequest(), + parent='parent_value', + event_threat_detection_custom_module=security_center_management.EventThreatDetectionCustomModule(name='name_value'), + ) + +@pytest.mark.asyncio +async def test_create_event_threat_detection_custom_module_flattened_async(): + client = SecurityCenterManagementAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_event_threat_detection_custom_module), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = security_center_management.EventThreatDetectionCustomModule() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.EventThreatDetectionCustomModule()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.create_event_threat_detection_custom_module( + parent='parent_value', + event_threat_detection_custom_module=security_center_management.EventThreatDetectionCustomModule(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].event_threat_detection_custom_module + mock_val = security_center_management.EventThreatDetectionCustomModule(name='name_value') + assert arg == mock_val + +@pytest.mark.asyncio +async def test_create_event_threat_detection_custom_module_flattened_error_async(): + client = SecurityCenterManagementAsyncClient( + 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_event_threat_detection_custom_module( + security_center_management.CreateEventThreatDetectionCustomModuleRequest(), + parent='parent_value', + event_threat_detection_custom_module=security_center_management.EventThreatDetectionCustomModule(name='name_value'), + ) + + +@pytest.mark.parametrize("request_type", [ + security_center_management.UpdateEventThreatDetectionCustomModuleRequest, + dict, +]) +def test_update_event_threat_detection_custom_module(request_type, transport: str = 'grpc'): + client = SecurityCenterManagementClient( + 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_event_threat_detection_custom_module), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = security_center_management.EventThreatDetectionCustomModule( + name='name_value', + ancestor_module='ancestor_module_value', + enablement_state=security_center_management.EventThreatDetectionCustomModule.EnablementState.ENABLED, + type_='type__value', + display_name='display_name_value', + description='description_value', + last_editor='last_editor_value', + ) + response = client.update_event_threat_detection_custom_module(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == security_center_management.UpdateEventThreatDetectionCustomModuleRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, security_center_management.EventThreatDetectionCustomModule) + assert response.name == 'name_value' + assert response.ancestor_module == 'ancestor_module_value' + assert response.enablement_state == security_center_management.EventThreatDetectionCustomModule.EnablementState.ENABLED + assert response.type_ == 'type__value' + assert response.display_name == 'display_name_value' + assert response.description == 'description_value' + assert response.last_editor == 'last_editor_value' + + +def test_update_event_threat_detection_custom_module_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 = SecurityCenterManagementClient( + 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_event_threat_detection_custom_module), + '__call__') as call: + client.update_event_threat_detection_custom_module() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == security_center_management.UpdateEventThreatDetectionCustomModuleRequest() + +@pytest.mark.asyncio +async def test_update_event_threat_detection_custom_module_async(transport: str = 'grpc_asyncio', request_type=security_center_management.UpdateEventThreatDetectionCustomModuleRequest): + client = SecurityCenterManagementAsyncClient( + 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_event_threat_detection_custom_module), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.EventThreatDetectionCustomModule( + name='name_value', + ancestor_module='ancestor_module_value', + enablement_state=security_center_management.EventThreatDetectionCustomModule.EnablementState.ENABLED, + type_='type__value', + display_name='display_name_value', + description='description_value', + last_editor='last_editor_value', + )) + response = await client.update_event_threat_detection_custom_module(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == security_center_management.UpdateEventThreatDetectionCustomModuleRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, security_center_management.EventThreatDetectionCustomModule) + assert response.name == 'name_value' + assert response.ancestor_module == 'ancestor_module_value' + assert response.enablement_state == security_center_management.EventThreatDetectionCustomModule.EnablementState.ENABLED + assert response.type_ == 'type__value' + assert response.display_name == 'display_name_value' + assert response.description == 'description_value' + assert response.last_editor == 'last_editor_value' + + +@pytest.mark.asyncio +async def test_update_event_threat_detection_custom_module_async_from_dict(): + await test_update_event_threat_detection_custom_module_async(request_type=dict) + + +def test_update_event_threat_detection_custom_module_field_headers(): + client = SecurityCenterManagementClient( + 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 = security_center_management.UpdateEventThreatDetectionCustomModuleRequest() + + request.event_threat_detection_custom_module.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_event_threat_detection_custom_module), + '__call__') as call: + call.return_value = security_center_management.EventThreatDetectionCustomModule() + client.update_event_threat_detection_custom_module(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', + 'event_threat_detection_custom_module.name=name_value', + ) in kw['metadata'] + + +@pytest.mark.asyncio +async def test_update_event_threat_detection_custom_module_field_headers_async(): + client = SecurityCenterManagementAsyncClient( + 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 = security_center_management.UpdateEventThreatDetectionCustomModuleRequest() + + request.event_threat_detection_custom_module.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_event_threat_detection_custom_module), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.EventThreatDetectionCustomModule()) + await client.update_event_threat_detection_custom_module(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', + 'event_threat_detection_custom_module.name=name_value', + ) in kw['metadata'] + + +def test_update_event_threat_detection_custom_module_flattened(): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_event_threat_detection_custom_module), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = security_center_management.EventThreatDetectionCustomModule() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.update_event_threat_detection_custom_module( + event_threat_detection_custom_module=security_center_management.EventThreatDetectionCustomModule(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].event_threat_detection_custom_module + mock_val = security_center_management.EventThreatDetectionCustomModule(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_event_threat_detection_custom_module_flattened_error(): + client = SecurityCenterManagementClient( + 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_event_threat_detection_custom_module( + security_center_management.UpdateEventThreatDetectionCustomModuleRequest(), + event_threat_detection_custom_module=security_center_management.EventThreatDetectionCustomModule(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + +@pytest.mark.asyncio +async def test_update_event_threat_detection_custom_module_flattened_async(): + client = SecurityCenterManagementAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_event_threat_detection_custom_module), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = security_center_management.EventThreatDetectionCustomModule() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.EventThreatDetectionCustomModule()) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.update_event_threat_detection_custom_module( + event_threat_detection_custom_module=security_center_management.EventThreatDetectionCustomModule(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].event_threat_detection_custom_module + mock_val = security_center_management.EventThreatDetectionCustomModule(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_event_threat_detection_custom_module_flattened_error_async(): + client = SecurityCenterManagementAsyncClient( + 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_event_threat_detection_custom_module( + security_center_management.UpdateEventThreatDetectionCustomModuleRequest(), + event_threat_detection_custom_module=security_center_management.EventThreatDetectionCustomModule(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +@pytest.mark.parametrize("request_type", [ + security_center_management.DeleteEventThreatDetectionCustomModuleRequest, + dict, +]) +def test_delete_event_threat_detection_custom_module(request_type, transport: str = 'grpc'): + client = SecurityCenterManagementClient( + 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_event_threat_detection_custom_module), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = None + response = client.delete_event_threat_detection_custom_module(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == security_center_management.DeleteEventThreatDetectionCustomModuleRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +def test_delete_event_threat_detection_custom_module_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 = SecurityCenterManagementClient( + 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_event_threat_detection_custom_module), + '__call__') as call: + client.delete_event_threat_detection_custom_module() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == security_center_management.DeleteEventThreatDetectionCustomModuleRequest() + +@pytest.mark.asyncio +async def test_delete_event_threat_detection_custom_module_async(transport: str = 'grpc_asyncio', request_type=security_center_management.DeleteEventThreatDetectionCustomModuleRequest): + client = SecurityCenterManagementAsyncClient( + 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_event_threat_detection_custom_module), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + response = await client.delete_event_threat_detection_custom_module(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == security_center_management.DeleteEventThreatDetectionCustomModuleRequest() + + # Establish that the response is the type that we expect. + assert response is None + + +@pytest.mark.asyncio +async def test_delete_event_threat_detection_custom_module_async_from_dict(): + await test_delete_event_threat_detection_custom_module_async(request_type=dict) + + +def test_delete_event_threat_detection_custom_module_field_headers(): + client = SecurityCenterManagementClient( + 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 = security_center_management.DeleteEventThreatDetectionCustomModuleRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_event_threat_detection_custom_module), + '__call__') as call: + call.return_value = None + client.delete_event_threat_detection_custom_module(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_event_threat_detection_custom_module_field_headers_async(): + client = SecurityCenterManagementAsyncClient( + 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 = security_center_management.DeleteEventThreatDetectionCustomModuleRequest() + + request.name = 'name_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_event_threat_detection_custom_module), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + await client.delete_event_threat_detection_custom_module(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_event_threat_detection_custom_module_flattened(): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_event_threat_detection_custom_module), + '__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_event_threat_detection_custom_module( + 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_event_threat_detection_custom_module_flattened_error(): + client = SecurityCenterManagementClient( + 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_event_threat_detection_custom_module( + security_center_management.DeleteEventThreatDetectionCustomModuleRequest(), + name='name_value', + ) + +@pytest.mark.asyncio +async def test_delete_event_threat_detection_custom_module_flattened_async(): + client = SecurityCenterManagementAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_event_threat_detection_custom_module), + '__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_event_threat_detection_custom_module( + 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_event_threat_detection_custom_module_flattened_error_async(): + client = SecurityCenterManagementAsyncClient( + 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_event_threat_detection_custom_module( + security_center_management.DeleteEventThreatDetectionCustomModuleRequest(), + name='name_value', + ) + + +@pytest.mark.parametrize("request_type", [ + security_center_management.ValidateEventThreatDetectionCustomModuleRequest, + dict, +]) +def test_validate_event_threat_detection_custom_module(request_type, transport: str = 'grpc'): + client = SecurityCenterManagementClient( + 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.validate_event_threat_detection_custom_module), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value = security_center_management.ValidateEventThreatDetectionCustomModuleResponse( + ) + response = client.validate_event_threat_detection_custom_module(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == security_center_management.ValidateEventThreatDetectionCustomModuleRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, security_center_management.ValidateEventThreatDetectionCustomModuleResponse) + + +def test_validate_event_threat_detection_custom_module_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 = SecurityCenterManagementClient( + 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.validate_event_threat_detection_custom_module), + '__call__') as call: + client.validate_event_threat_detection_custom_module() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == security_center_management.ValidateEventThreatDetectionCustomModuleRequest() + +@pytest.mark.asyncio +async def test_validate_event_threat_detection_custom_module_async(transport: str = 'grpc_asyncio', request_type=security_center_management.ValidateEventThreatDetectionCustomModuleRequest): + client = SecurityCenterManagementAsyncClient( + 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.validate_event_threat_detection_custom_module), + '__call__') as call: + # Designate an appropriate return value for the call. + call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.ValidateEventThreatDetectionCustomModuleResponse( + )) + response = await client.validate_event_threat_detection_custom_module(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == security_center_management.ValidateEventThreatDetectionCustomModuleRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, security_center_management.ValidateEventThreatDetectionCustomModuleResponse) + + +@pytest.mark.asyncio +async def test_validate_event_threat_detection_custom_module_async_from_dict(): + await test_validate_event_threat_detection_custom_module_async(request_type=dict) + + +def test_validate_event_threat_detection_custom_module_field_headers(): + client = SecurityCenterManagementClient( + 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 = security_center_management.ValidateEventThreatDetectionCustomModuleRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.validate_event_threat_detection_custom_module), + '__call__') as call: + call.return_value = security_center_management.ValidateEventThreatDetectionCustomModuleResponse() + client.validate_event_threat_detection_custom_module(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_validate_event_threat_detection_custom_module_field_headers_async(): + client = SecurityCenterManagementAsyncClient( + 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 = security_center_management.ValidateEventThreatDetectionCustomModuleRequest() + + request.parent = 'parent_value' + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.validate_event_threat_detection_custom_module), + '__call__') as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.ValidateEventThreatDetectionCustomModuleResponse()) + await client.validate_event_threat_detection_custom_module(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'] + + +@pytest.mark.parametrize("request_type", [ + security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest, + dict, +]) +def test_list_effective_security_health_analytics_custom_modules_rest(request_type): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse( + next_page_token='next_page_token_value', + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.list_effective_security_health_analytics_custom_modules(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListEffectiveSecurityHealthAnalyticsCustomModulesPager) + assert response.next_page_token == 'next_page_token_value' + + +def test_list_effective_security_health_analytics_custom_modules_rest_required_fields(request_type=security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest): + transport_class = transports.SecurityCenterManagementRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_effective_security_health_analytics_custom_modules._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = 'parent_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_effective_security_health_analytics_custom_modules._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("page_size", "page_token", )) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == 'parent_value' + + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "get", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.list_effective_security_health_analytics_custom_modules(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_list_effective_security_health_analytics_custom_modules_rest_unset_required_fields(): + transport = transports.SecurityCenterManagementRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.list_effective_security_health_analytics_custom_modules._get_unset_required_fields({}) + assert set(unset_fields) == (set(("pageSize", "pageToken", )) & set(("parent", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_effective_security_health_analytics_custom_modules_rest_interceptors(null_interceptor): + transport = transports.SecurityCenterManagementRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.SecurityCenterManagementRestInterceptor(), + ) + client = SecurityCenterManagementClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "post_list_effective_security_health_analytics_custom_modules") as post, \ + mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "pre_list_effective_security_health_analytics_custom_modules") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest.pb(security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse.to_json(security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse()) + + request = security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse() + + client.list_effective_security_health_analytics_custom_modules(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_list_effective_security_health_analytics_custom_modules_rest_bad_request(transport: str = 'rest', request_type=security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.list_effective_security_health_analytics_custom_modules(request) + + +def test_list_effective_security_health_analytics_custom_modules_rest_flattened(): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse() + + # get arguments that satisfy an http rule for this method + sample_request = {'parent': 'projects/sample1/locations/sample2'} + + # get truthy value for each flattened field + mock_args = dict( + parent='parent_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.list_effective_security_health_analytics_custom_modules(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/effectiveSecurityHealthAnalyticsCustomModules" % client.transport._host, args[1]) + + +def test_list_effective_security_health_analytics_custom_modules_rest_flattened_error(transport: str = 'rest'): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_effective_security_health_analytics_custom_modules( + security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest(), + parent='parent_value', + ) + + +def test_list_effective_security_health_analytics_custom_modules_rest_pager(transport: str = 'rest'): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + #with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse( + effective_security_health_analytics_custom_modules=[ + security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), + security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), + security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), + ], + next_page_token='abc', + ), + security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse( + effective_security_health_analytics_custom_modules=[], + next_page_token='def', + ), + security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse( + effective_security_health_analytics_custom_modules=[ + security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), + ], + next_page_token='ghi', + ), + security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse( + effective_security_health_analytics_custom_modules=[ + security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), + security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple(security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse.to_json(x) for x in response) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode('UTF-8') + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {'parent': 'projects/sample1/locations/sample2'} + + pager = client.list_effective_security_health_analytics_custom_modules(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, security_center_management.EffectiveSecurityHealthAnalyticsCustomModule) + for i in results) + + pages = list(client.list_effective_security_health_analytics_custom_modules(request=sample_request).pages) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.parametrize("request_type", [ + security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest, + dict, +]) +def test_get_effective_security_health_analytics_custom_module_rest(request_type): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/effectiveSecurityHealthAnalyticsCustomModules/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = security_center_management.EffectiveSecurityHealthAnalyticsCustomModule( + name='name_value', + enablement_state=security_center_management.EffectiveSecurityHealthAnalyticsCustomModule.EnablementState.ENABLED, + display_name='display_name_value', + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = security_center_management.EffectiveSecurityHealthAnalyticsCustomModule.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.get_effective_security_health_analytics_custom_module(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, security_center_management.EffectiveSecurityHealthAnalyticsCustomModule) + assert response.name == 'name_value' + assert response.enablement_state == security_center_management.EffectiveSecurityHealthAnalyticsCustomModule.EnablementState.ENABLED + assert response.display_name == 'display_name_value' + + +def test_get_effective_security_health_analytics_custom_module_rest_required_fields(request_type=security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest): + transport_class = transports.SecurityCenterManagementRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_effective_security_health_analytics_custom_module._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = 'name_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_effective_security_health_analytics_custom_module._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == 'name_value' + + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = security_center_management.EffectiveSecurityHealthAnalyticsCustomModule() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "get", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = security_center_management.EffectiveSecurityHealthAnalyticsCustomModule.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.get_effective_security_health_analytics_custom_module(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_get_effective_security_health_analytics_custom_module_rest_unset_required_fields(): + transport = transports.SecurityCenterManagementRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.get_effective_security_health_analytics_custom_module._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_effective_security_health_analytics_custom_module_rest_interceptors(null_interceptor): + transport = transports.SecurityCenterManagementRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.SecurityCenterManagementRestInterceptor(), + ) + client = SecurityCenterManagementClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "post_get_effective_security_health_analytics_custom_module") as post, \ + mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "pre_get_effective_security_health_analytics_custom_module") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest.pb(security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = security_center_management.EffectiveSecurityHealthAnalyticsCustomModule.to_json(security_center_management.EffectiveSecurityHealthAnalyticsCustomModule()) + + request = security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = security_center_management.EffectiveSecurityHealthAnalyticsCustomModule() + + client.get_effective_security_health_analytics_custom_module(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_get_effective_security_health_analytics_custom_module_rest_bad_request(transport: str = 'rest', request_type=security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/effectiveSecurityHealthAnalyticsCustomModules/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.get_effective_security_health_analytics_custom_module(request) + + +def test_get_effective_security_health_analytics_custom_module_rest_flattened(): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = security_center_management.EffectiveSecurityHealthAnalyticsCustomModule() + + # get arguments that satisfy an http rule for this method + sample_request = {'name': 'projects/sample1/locations/sample2/effectiveSecurityHealthAnalyticsCustomModules/sample3'} + + # get truthy value for each flattened field + mock_args = dict( + name='name_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = security_center_management.EffectiveSecurityHealthAnalyticsCustomModule.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.get_effective_security_health_analytics_custom_module(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{name=projects/*/locations/*/effectiveSecurityHealthAnalyticsCustomModules/*}" % client.transport._host, args[1]) + + +def test_get_effective_security_health_analytics_custom_module_rest_flattened_error(transport: str = 'rest'): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_effective_security_health_analytics_custom_module( + security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest(), + name='name_value', + ) + + +def test_get_effective_security_health_analytics_custom_module_rest_error(): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest, + dict, +]) +def test_list_security_health_analytics_custom_modules_rest(request_type): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse( + next_page_token='next_page_token_value', + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.list_security_health_analytics_custom_modules(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListSecurityHealthAnalyticsCustomModulesPager) + assert response.next_page_token == 'next_page_token_value' + + +def test_list_security_health_analytics_custom_modules_rest_required_fields(request_type=security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest): + transport_class = transports.SecurityCenterManagementRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_security_health_analytics_custom_modules._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = 'parent_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_security_health_analytics_custom_modules._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("page_size", "page_token", )) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == 'parent_value' + + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "get", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.list_security_health_analytics_custom_modules(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_list_security_health_analytics_custom_modules_rest_unset_required_fields(): + transport = transports.SecurityCenterManagementRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.list_security_health_analytics_custom_modules._get_unset_required_fields({}) + assert set(unset_fields) == (set(("pageSize", "pageToken", )) & set(("parent", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_security_health_analytics_custom_modules_rest_interceptors(null_interceptor): + transport = transports.SecurityCenterManagementRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.SecurityCenterManagementRestInterceptor(), + ) + client = SecurityCenterManagementClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "post_list_security_health_analytics_custom_modules") as post, \ + mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "pre_list_security_health_analytics_custom_modules") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest.pb(security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse.to_json(security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse()) + + request = security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse() + + client.list_security_health_analytics_custom_modules(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_list_security_health_analytics_custom_modules_rest_bad_request(transport: str = 'rest', request_type=security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.list_security_health_analytics_custom_modules(request) + + +def test_list_security_health_analytics_custom_modules_rest_flattened(): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse() + + # get arguments that satisfy an http rule for this method + sample_request = {'parent': 'projects/sample1/locations/sample2'} + + # get truthy value for each flattened field + mock_args = dict( + parent='parent_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.list_security_health_analytics_custom_modules(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/securityHealthAnalyticsCustomModules" % client.transport._host, args[1]) + + +def test_list_security_health_analytics_custom_modules_rest_flattened_error(transport: str = 'rest'): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_security_health_analytics_custom_modules( + security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest(), + parent='parent_value', + ) + + +def test_list_security_health_analytics_custom_modules_rest_pager(transport: str = 'rest'): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + #with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse( + security_health_analytics_custom_modules=[ + security_center_management.SecurityHealthAnalyticsCustomModule(), + security_center_management.SecurityHealthAnalyticsCustomModule(), + security_center_management.SecurityHealthAnalyticsCustomModule(), + ], + next_page_token='abc', + ), + security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse( + security_health_analytics_custom_modules=[], + next_page_token='def', + ), + security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse( + security_health_analytics_custom_modules=[ + security_center_management.SecurityHealthAnalyticsCustomModule(), + ], + next_page_token='ghi', + ), + security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse( + security_health_analytics_custom_modules=[ + security_center_management.SecurityHealthAnalyticsCustomModule(), + security_center_management.SecurityHealthAnalyticsCustomModule(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple(security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse.to_json(x) for x in response) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode('UTF-8') + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {'parent': 'projects/sample1/locations/sample2'} + + pager = client.list_security_health_analytics_custom_modules(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, security_center_management.SecurityHealthAnalyticsCustomModule) + for i in results) + + pages = list(client.list_security_health_analytics_custom_modules(request=sample_request).pages) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.parametrize("request_type", [ + security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest, + dict, +]) +def test_list_descendant_security_health_analytics_custom_modules_rest(request_type): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse( + next_page_token='next_page_token_value', + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.list_descendant_security_health_analytics_custom_modules(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListDescendantSecurityHealthAnalyticsCustomModulesPager) + assert response.next_page_token == 'next_page_token_value' + + +def test_list_descendant_security_health_analytics_custom_modules_rest_required_fields(request_type=security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest): + transport_class = transports.SecurityCenterManagementRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_descendant_security_health_analytics_custom_modules._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = 'parent_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_descendant_security_health_analytics_custom_modules._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("page_size", "page_token", )) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == 'parent_value' + + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "get", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.list_descendant_security_health_analytics_custom_modules(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_list_descendant_security_health_analytics_custom_modules_rest_unset_required_fields(): + transport = transports.SecurityCenterManagementRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.list_descendant_security_health_analytics_custom_modules._get_unset_required_fields({}) + assert set(unset_fields) == (set(("pageSize", "pageToken", )) & set(("parent", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_descendant_security_health_analytics_custom_modules_rest_interceptors(null_interceptor): + transport = transports.SecurityCenterManagementRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.SecurityCenterManagementRestInterceptor(), + ) + client = SecurityCenterManagementClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "post_list_descendant_security_health_analytics_custom_modules") as post, \ + mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "pre_list_descendant_security_health_analytics_custom_modules") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest.pb(security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse.to_json(security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse()) + + request = security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse() + + client.list_descendant_security_health_analytics_custom_modules(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_list_descendant_security_health_analytics_custom_modules_rest_bad_request(transport: str = 'rest', request_type=security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.list_descendant_security_health_analytics_custom_modules(request) + + +def test_list_descendant_security_health_analytics_custom_modules_rest_flattened(): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse() + + # get arguments that satisfy an http rule for this method + sample_request = {'parent': 'projects/sample1/locations/sample2'} + + # get truthy value for each flattened field + mock_args = dict( + parent='parent_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.list_descendant_security_health_analytics_custom_modules(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/securityHealthAnalyticsCustomModules:listDescendant" % client.transport._host, args[1]) + + +def test_list_descendant_security_health_analytics_custom_modules_rest_flattened_error(transport: str = 'rest'): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_descendant_security_health_analytics_custom_modules( + security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest(), + parent='parent_value', + ) + + +def test_list_descendant_security_health_analytics_custom_modules_rest_pager(transport: str = 'rest'): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + #with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse( + security_health_analytics_custom_modules=[ + security_center_management.SecurityHealthAnalyticsCustomModule(), + security_center_management.SecurityHealthAnalyticsCustomModule(), + security_center_management.SecurityHealthAnalyticsCustomModule(), + ], + next_page_token='abc', + ), + security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse( + security_health_analytics_custom_modules=[], + next_page_token='def', + ), + security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse( + security_health_analytics_custom_modules=[ + security_center_management.SecurityHealthAnalyticsCustomModule(), + ], + next_page_token='ghi', + ), + security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse( + security_health_analytics_custom_modules=[ + security_center_management.SecurityHealthAnalyticsCustomModule(), + security_center_management.SecurityHealthAnalyticsCustomModule(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple(security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse.to_json(x) for x in response) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode('UTF-8') + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {'parent': 'projects/sample1/locations/sample2'} + + pager = client.list_descendant_security_health_analytics_custom_modules(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, security_center_management.SecurityHealthAnalyticsCustomModule) + for i in results) + + pages = list(client.list_descendant_security_health_analytics_custom_modules(request=sample_request).pages) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.parametrize("request_type", [ + security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest, + dict, +]) +def test_get_security_health_analytics_custom_module_rest(request_type): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/securityHealthAnalyticsCustomModules/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = security_center_management.SecurityHealthAnalyticsCustomModule( + name='name_value', + display_name='display_name_value', + enablement_state=security_center_management.SecurityHealthAnalyticsCustomModule.EnablementState.ENABLED, + last_editor='last_editor_value', + ancestor_module='ancestor_module_value', + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = security_center_management.SecurityHealthAnalyticsCustomModule.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.get_security_health_analytics_custom_module(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, security_center_management.SecurityHealthAnalyticsCustomModule) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.enablement_state == security_center_management.SecurityHealthAnalyticsCustomModule.EnablementState.ENABLED + assert response.last_editor == 'last_editor_value' + assert response.ancestor_module == 'ancestor_module_value' + + +def test_get_security_health_analytics_custom_module_rest_required_fields(request_type=security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest): + transport_class = transports.SecurityCenterManagementRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_security_health_analytics_custom_module._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = 'name_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_security_health_analytics_custom_module._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == 'name_value' + + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = security_center_management.SecurityHealthAnalyticsCustomModule() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "get", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = security_center_management.SecurityHealthAnalyticsCustomModule.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.get_security_health_analytics_custom_module(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_get_security_health_analytics_custom_module_rest_unset_required_fields(): + transport = transports.SecurityCenterManagementRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.get_security_health_analytics_custom_module._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_security_health_analytics_custom_module_rest_interceptors(null_interceptor): + transport = transports.SecurityCenterManagementRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.SecurityCenterManagementRestInterceptor(), + ) + client = SecurityCenterManagementClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "post_get_security_health_analytics_custom_module") as post, \ + mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "pre_get_security_health_analytics_custom_module") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest.pb(security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = security_center_management.SecurityHealthAnalyticsCustomModule.to_json(security_center_management.SecurityHealthAnalyticsCustomModule()) + + request = security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = security_center_management.SecurityHealthAnalyticsCustomModule() + + client.get_security_health_analytics_custom_module(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_get_security_health_analytics_custom_module_rest_bad_request(transport: str = 'rest', request_type=security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/securityHealthAnalyticsCustomModules/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.get_security_health_analytics_custom_module(request) + + +def test_get_security_health_analytics_custom_module_rest_flattened(): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = security_center_management.SecurityHealthAnalyticsCustomModule() + + # get arguments that satisfy an http rule for this method + sample_request = {'name': 'projects/sample1/locations/sample2/securityHealthAnalyticsCustomModules/sample3'} + + # get truthy value for each flattened field + mock_args = dict( + name='name_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = security_center_management.SecurityHealthAnalyticsCustomModule.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.get_security_health_analytics_custom_module(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{name=projects/*/locations/*/securityHealthAnalyticsCustomModules/*}" % client.transport._host, args[1]) + + +def test_get_security_health_analytics_custom_module_rest_flattened_error(transport: str = 'rest'): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_security_health_analytics_custom_module( + security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest(), + name='name_value', + ) + + +def test_get_security_health_analytics_custom_module_rest_error(): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest, + dict, +]) +def test_create_security_health_analytics_custom_module_rest(request_type): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request_init["security_health_analytics_custom_module"] = {'name': 'name_value', 'display_name': 'display_name_value', 'enablement_state': 1, 'update_time': {'seconds': 751, 'nanos': 543}, 'last_editor': 'last_editor_value', 'ancestor_module': 'ancestor_module_value', 'custom_config': {'predicate': {'expression': 'expression_value', 'title': 'title_value', 'description': 'description_value', 'location': 'location_value'}, 'custom_output': {'properties': [{'name': 'name_value', 'value_expression': {}}]}, 'resource_selector': {'resource_types': ['resource_types_value1', 'resource_types_value2']}, 'severity': 1, 'description': 'description_value', 'recommendation': 'recommendation_value'}} + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest.meta.fields["security_health_analytics_custom_module"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["security_health_analytics_custom_module"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + {"field": field, "subfield": subfield, "is_repeated": is_repeated} + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["security_health_analytics_custom_module"][field])): + del request_init["security_health_analytics_custom_module"][field][i][subfield] + else: + del request_init["security_health_analytics_custom_module"][field][subfield] + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = security_center_management.SecurityHealthAnalyticsCustomModule( + name='name_value', + display_name='display_name_value', + enablement_state=security_center_management.SecurityHealthAnalyticsCustomModule.EnablementState.ENABLED, + last_editor='last_editor_value', + ancestor_module='ancestor_module_value', + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = security_center_management.SecurityHealthAnalyticsCustomModule.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.create_security_health_analytics_custom_module(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, security_center_management.SecurityHealthAnalyticsCustomModule) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.enablement_state == security_center_management.SecurityHealthAnalyticsCustomModule.EnablementState.ENABLED + assert response.last_editor == 'last_editor_value' + assert response.ancestor_module == 'ancestor_module_value' + + +def test_create_security_health_analytics_custom_module_rest_required_fields(request_type=security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest): + transport_class = transports.SecurityCenterManagementRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_security_health_analytics_custom_module._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = 'parent_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_security_health_analytics_custom_module._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("validate_only", )) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == 'parent_value' + + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = security_center_management.SecurityHealthAnalyticsCustomModule() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "post", + 'query_params': pb_request, + } + transcode_result['body'] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = security_center_management.SecurityHealthAnalyticsCustomModule.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.create_security_health_analytics_custom_module(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_create_security_health_analytics_custom_module_rest_unset_required_fields(): + transport = transports.SecurityCenterManagementRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.create_security_health_analytics_custom_module._get_unset_required_fields({}) + assert set(unset_fields) == (set(("validateOnly", )) & set(("parent", "securityHealthAnalyticsCustomModule", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_create_security_health_analytics_custom_module_rest_interceptors(null_interceptor): + transport = transports.SecurityCenterManagementRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.SecurityCenterManagementRestInterceptor(), + ) + client = SecurityCenterManagementClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "post_create_security_health_analytics_custom_module") as post, \ + mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "pre_create_security_health_analytics_custom_module") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest.pb(security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = security_center_management.SecurityHealthAnalyticsCustomModule.to_json(security_center_management.SecurityHealthAnalyticsCustomModule()) + + request = security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = security_center_management.SecurityHealthAnalyticsCustomModule() + + client.create_security_health_analytics_custom_module(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_create_security_health_analytics_custom_module_rest_bad_request(transport: str = 'rest', request_type=security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.create_security_health_analytics_custom_module(request) + + +def test_create_security_health_analytics_custom_module_rest_flattened(): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = security_center_management.SecurityHealthAnalyticsCustomModule() + + # get arguments that satisfy an http rule for this method + sample_request = {'parent': 'projects/sample1/locations/sample2'} + + # get truthy value for each flattened field + mock_args = dict( + parent='parent_value', + security_health_analytics_custom_module=security_center_management.SecurityHealthAnalyticsCustomModule(name='name_value'), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = security_center_management.SecurityHealthAnalyticsCustomModule.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.create_security_health_analytics_custom_module(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/securityHealthAnalyticsCustomModules" % client.transport._host, args[1]) + + +def test_create_security_health_analytics_custom_module_rest_flattened_error(transport: str = 'rest'): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_security_health_analytics_custom_module( + security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest(), + parent='parent_value', + security_health_analytics_custom_module=security_center_management.SecurityHealthAnalyticsCustomModule(name='name_value'), + ) + + +def test_create_security_health_analytics_custom_module_rest_error(): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest, + dict, +]) +def test_update_security_health_analytics_custom_module_rest(request_type): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'security_health_analytics_custom_module': {'name': 'projects/sample1/locations/sample2/securityHealthAnalyticsCustomModules/sample3'}} + request_init["security_health_analytics_custom_module"] = {'name': 'projects/sample1/locations/sample2/securityHealthAnalyticsCustomModules/sample3', 'display_name': 'display_name_value', 'enablement_state': 1, 'update_time': {'seconds': 751, 'nanos': 543}, 'last_editor': 'last_editor_value', 'ancestor_module': 'ancestor_module_value', 'custom_config': {'predicate': {'expression': 'expression_value', 'title': 'title_value', 'description': 'description_value', 'location': 'location_value'}, 'custom_output': {'properties': [{'name': 'name_value', 'value_expression': {}}]}, 'resource_selector': {'resource_types': ['resource_types_value1', 'resource_types_value2']}, 'severity': 1, 'description': 'description_value', 'recommendation': 'recommendation_value'}} + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest.meta.fields["security_health_analytics_custom_module"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["security_health_analytics_custom_module"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + {"field": field, "subfield": subfield, "is_repeated": is_repeated} + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["security_health_analytics_custom_module"][field])): + del request_init["security_health_analytics_custom_module"][field][i][subfield] + else: + del request_init["security_health_analytics_custom_module"][field][subfield] + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = security_center_management.SecurityHealthAnalyticsCustomModule( + name='name_value', + display_name='display_name_value', + enablement_state=security_center_management.SecurityHealthAnalyticsCustomModule.EnablementState.ENABLED, + last_editor='last_editor_value', + ancestor_module='ancestor_module_value', + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = security_center_management.SecurityHealthAnalyticsCustomModule.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.update_security_health_analytics_custom_module(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, security_center_management.SecurityHealthAnalyticsCustomModule) + assert response.name == 'name_value' + assert response.display_name == 'display_name_value' + assert response.enablement_state == security_center_management.SecurityHealthAnalyticsCustomModule.EnablementState.ENABLED + assert response.last_editor == 'last_editor_value' + assert response.ancestor_module == 'ancestor_module_value' + + +def test_update_security_health_analytics_custom_module_rest_required_fields(request_type=security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest): + transport_class = transports.SecurityCenterManagementRestTransport + + request_init = {} + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_security_health_analytics_custom_module._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_security_health_analytics_custom_module._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("update_mask", "validate_only", )) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = security_center_management.SecurityHealthAnalyticsCustomModule() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "patch", + 'query_params': pb_request, + } + transcode_result['body'] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = security_center_management.SecurityHealthAnalyticsCustomModule.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.update_security_health_analytics_custom_module(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_update_security_health_analytics_custom_module_rest_unset_required_fields(): + transport = transports.SecurityCenterManagementRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.update_security_health_analytics_custom_module._get_unset_required_fields({}) + assert set(unset_fields) == (set(("updateMask", "validateOnly", )) & set(("updateMask", "securityHealthAnalyticsCustomModule", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_update_security_health_analytics_custom_module_rest_interceptors(null_interceptor): + transport = transports.SecurityCenterManagementRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.SecurityCenterManagementRestInterceptor(), + ) + client = SecurityCenterManagementClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "post_update_security_health_analytics_custom_module") as post, \ + mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "pre_update_security_health_analytics_custom_module") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest.pb(security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = security_center_management.SecurityHealthAnalyticsCustomModule.to_json(security_center_management.SecurityHealthAnalyticsCustomModule()) + + request = security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = security_center_management.SecurityHealthAnalyticsCustomModule() + + client.update_security_health_analytics_custom_module(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_update_security_health_analytics_custom_module_rest_bad_request(transport: str = 'rest', request_type=security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'security_health_analytics_custom_module': {'name': 'projects/sample1/locations/sample2/securityHealthAnalyticsCustomModules/sample3'}} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.update_security_health_analytics_custom_module(request) + + +def test_update_security_health_analytics_custom_module_rest_flattened(): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = security_center_management.SecurityHealthAnalyticsCustomModule() + + # get arguments that satisfy an http rule for this method + sample_request = {'security_health_analytics_custom_module': {'name': 'projects/sample1/locations/sample2/securityHealthAnalyticsCustomModules/sample3'}} + + # get truthy value for each flattened field + mock_args = dict( + security_health_analytics_custom_module=security_center_management.SecurityHealthAnalyticsCustomModule(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = security_center_management.SecurityHealthAnalyticsCustomModule.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.update_security_health_analytics_custom_module(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{security_health_analytics_custom_module.name=projects/*/locations/*/securityHealthAnalyticsCustomModules/*}" % client.transport._host, args[1]) + + +def test_update_security_health_analytics_custom_module_rest_flattened_error(transport: str = 'rest'): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_security_health_analytics_custom_module( + security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest(), + security_health_analytics_custom_module=security_center_management.SecurityHealthAnalyticsCustomModule(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +def test_update_security_health_analytics_custom_module_rest_error(): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest, + dict, +]) +def test_delete_security_health_analytics_custom_module_rest(request_type): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/securityHealthAnalyticsCustomModules/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = None + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = '' + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.delete_security_health_analytics_custom_module(request) + + # Establish that the response is the type that we expect. + assert response is None + + +def test_delete_security_health_analytics_custom_module_rest_required_fields(request_type=security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest): + transport_class = transports.SecurityCenterManagementRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_security_health_analytics_custom_module._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = 'name_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_security_health_analytics_custom_module._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("validate_only", )) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == 'name_value' + + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = None + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "delete", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = '' + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.delete_security_health_analytics_custom_module(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_delete_security_health_analytics_custom_module_rest_unset_required_fields(): + transport = transports.SecurityCenterManagementRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.delete_security_health_analytics_custom_module._get_unset_required_fields({}) + assert set(unset_fields) == (set(("validateOnly", )) & set(("name", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_delete_security_health_analytics_custom_module_rest_interceptors(null_interceptor): + transport = transports.SecurityCenterManagementRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.SecurityCenterManagementRestInterceptor(), + ) + client = SecurityCenterManagementClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "pre_delete_security_health_analytics_custom_module") as pre: + pre.assert_not_called() + pb_message = security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest.pb(security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + + request = security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + + client.delete_security_health_analytics_custom_module(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + + +def test_delete_security_health_analytics_custom_module_rest_bad_request(transport: str = 'rest', request_type=security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/securityHealthAnalyticsCustomModules/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.delete_security_health_analytics_custom_module(request) + + +def test_delete_security_health_analytics_custom_module_rest_flattened(): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = None + + # get arguments that satisfy an http rule for this method + sample_request = {'name': 'projects/sample1/locations/sample2/securityHealthAnalyticsCustomModules/sample3'} + + # get truthy value for each flattened field + mock_args = dict( + name='name_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = '' + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.delete_security_health_analytics_custom_module(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{name=projects/*/locations/*/securityHealthAnalyticsCustomModules/*}" % client.transport._host, args[1]) + + +def test_delete_security_health_analytics_custom_module_rest_flattened_error(transport: str = 'rest'): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_security_health_analytics_custom_module( + security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest(), + name='name_value', + ) + + +def test_delete_security_health_analytics_custom_module_rest_error(): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest, + dict, +]) +def test_simulate_security_health_analytics_custom_module_rest(request_type): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse( + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.simulate_security_health_analytics_custom_module(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse) + + +def test_simulate_security_health_analytics_custom_module_rest_required_fields(request_type=security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest): + transport_class = transports.SecurityCenterManagementRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).simulate_security_health_analytics_custom_module._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = 'parent_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).simulate_security_health_analytics_custom_module._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == 'parent_value' + + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "post", + 'query_params': pb_request, + } + transcode_result['body'] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.simulate_security_health_analytics_custom_module(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_simulate_security_health_analytics_custom_module_rest_unset_required_fields(): + transport = transports.SecurityCenterManagementRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.simulate_security_health_analytics_custom_module._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("parent", "customConfig", "resource", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_simulate_security_health_analytics_custom_module_rest_interceptors(null_interceptor): + transport = transports.SecurityCenterManagementRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.SecurityCenterManagementRestInterceptor(), + ) + client = SecurityCenterManagementClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "post_simulate_security_health_analytics_custom_module") as post, \ + mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "pre_simulate_security_health_analytics_custom_module") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest.pb(security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse.to_json(security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse()) + + request = security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse() + + client.simulate_security_health_analytics_custom_module(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_simulate_security_health_analytics_custom_module_rest_bad_request(transport: str = 'rest', request_type=security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.simulate_security_health_analytics_custom_module(request) + + +def test_simulate_security_health_analytics_custom_module_rest_flattened(): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse() + + # get arguments that satisfy an http rule for this method + sample_request = {'parent': 'projects/sample1/locations/sample2'} + + # get truthy value for each flattened field + mock_args = dict( + parent='parent_value', + custom_config=security_center_management.CustomConfig(predicate=expr_pb2.Expr(expression='expression_value')), + resource=security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest.SimulatedResource(resource_type='resource_type_value'), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.simulate_security_health_analytics_custom_module(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/securityHealthAnalyticsCustomModules:simulate" % client.transport._host, args[1]) + + +def test_simulate_security_health_analytics_custom_module_rest_flattened_error(transport: str = 'rest'): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.simulate_security_health_analytics_custom_module( + security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest(), + parent='parent_value', + custom_config=security_center_management.CustomConfig(predicate=expr_pb2.Expr(expression='expression_value')), + resource=security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest.SimulatedResource(resource_type='resource_type_value'), + ) + + +def test_simulate_security_health_analytics_custom_module_rest_error(): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest, + dict, +]) +def test_list_effective_event_threat_detection_custom_modules_rest(request_type): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse( + next_page_token='next_page_token_value', + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.list_effective_event_threat_detection_custom_modules(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListEffectiveEventThreatDetectionCustomModulesPager) + assert response.next_page_token == 'next_page_token_value' + + +def test_list_effective_event_threat_detection_custom_modules_rest_required_fields(request_type=security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest): + transport_class = transports.SecurityCenterManagementRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_effective_event_threat_detection_custom_modules._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = 'parent_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_effective_event_threat_detection_custom_modules._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("page_size", "page_token", )) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == 'parent_value' + + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "get", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.list_effective_event_threat_detection_custom_modules(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_list_effective_event_threat_detection_custom_modules_rest_unset_required_fields(): + transport = transports.SecurityCenterManagementRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.list_effective_event_threat_detection_custom_modules._get_unset_required_fields({}) + assert set(unset_fields) == (set(("pageSize", "pageToken", )) & set(("parent", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_effective_event_threat_detection_custom_modules_rest_interceptors(null_interceptor): + transport = transports.SecurityCenterManagementRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.SecurityCenterManagementRestInterceptor(), + ) + client = SecurityCenterManagementClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "post_list_effective_event_threat_detection_custom_modules") as post, \ + mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "pre_list_effective_event_threat_detection_custom_modules") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest.pb(security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse.to_json(security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse()) + + request = security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse() + + client.list_effective_event_threat_detection_custom_modules(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_list_effective_event_threat_detection_custom_modules_rest_bad_request(transport: str = 'rest', request_type=security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.list_effective_event_threat_detection_custom_modules(request) + + +def test_list_effective_event_threat_detection_custom_modules_rest_flattened(): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse() + + # get arguments that satisfy an http rule for this method + sample_request = {'parent': 'projects/sample1/locations/sample2'} + + # get truthy value for each flattened field + mock_args = dict( + parent='parent_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.list_effective_event_threat_detection_custom_modules(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/effectiveEventThreatDetectionCustomModules" % client.transport._host, args[1]) + + +def test_list_effective_event_threat_detection_custom_modules_rest_flattened_error(transport: str = 'rest'): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_effective_event_threat_detection_custom_modules( + security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest(), + parent='parent_value', + ) + + +def test_list_effective_event_threat_detection_custom_modules_rest_pager(transport: str = 'rest'): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + #with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse( + effective_event_threat_detection_custom_modules=[ + security_center_management.EffectiveEventThreatDetectionCustomModule(), + security_center_management.EffectiveEventThreatDetectionCustomModule(), + security_center_management.EffectiveEventThreatDetectionCustomModule(), + ], + next_page_token='abc', + ), + security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse( + effective_event_threat_detection_custom_modules=[], + next_page_token='def', + ), + security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse( + effective_event_threat_detection_custom_modules=[ + security_center_management.EffectiveEventThreatDetectionCustomModule(), + ], + next_page_token='ghi', + ), + security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse( + effective_event_threat_detection_custom_modules=[ + security_center_management.EffectiveEventThreatDetectionCustomModule(), + security_center_management.EffectiveEventThreatDetectionCustomModule(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple(security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse.to_json(x) for x in response) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode('UTF-8') + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {'parent': 'projects/sample1/locations/sample2'} + + pager = client.list_effective_event_threat_detection_custom_modules(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, security_center_management.EffectiveEventThreatDetectionCustomModule) + for i in results) + + pages = list(client.list_effective_event_threat_detection_custom_modules(request=sample_request).pages) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.parametrize("request_type", [ + security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest, + dict, +]) +def test_get_effective_event_threat_detection_custom_module_rest(request_type): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/effectiveEventThreatDetectionCustomModules/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = security_center_management.EffectiveEventThreatDetectionCustomModule( + name='name_value', + enablement_state=security_center_management.EffectiveEventThreatDetectionCustomModule.EnablementState.ENABLED, + type_='type__value', + display_name='display_name_value', + description='description_value', + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = security_center_management.EffectiveEventThreatDetectionCustomModule.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.get_effective_event_threat_detection_custom_module(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, security_center_management.EffectiveEventThreatDetectionCustomModule) + assert response.name == 'name_value' + assert response.enablement_state == security_center_management.EffectiveEventThreatDetectionCustomModule.EnablementState.ENABLED + assert response.type_ == 'type__value' + assert response.display_name == 'display_name_value' + assert response.description == 'description_value' + + +def test_get_effective_event_threat_detection_custom_module_rest_required_fields(request_type=security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest): + transport_class = transports.SecurityCenterManagementRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_effective_event_threat_detection_custom_module._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = 'name_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_effective_event_threat_detection_custom_module._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == 'name_value' + + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = security_center_management.EffectiveEventThreatDetectionCustomModule() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "get", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = security_center_management.EffectiveEventThreatDetectionCustomModule.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.get_effective_event_threat_detection_custom_module(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_get_effective_event_threat_detection_custom_module_rest_unset_required_fields(): + transport = transports.SecurityCenterManagementRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.get_effective_event_threat_detection_custom_module._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_effective_event_threat_detection_custom_module_rest_interceptors(null_interceptor): + transport = transports.SecurityCenterManagementRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.SecurityCenterManagementRestInterceptor(), + ) + client = SecurityCenterManagementClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "post_get_effective_event_threat_detection_custom_module") as post, \ + mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "pre_get_effective_event_threat_detection_custom_module") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest.pb(security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = security_center_management.EffectiveEventThreatDetectionCustomModule.to_json(security_center_management.EffectiveEventThreatDetectionCustomModule()) + + request = security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = security_center_management.EffectiveEventThreatDetectionCustomModule() + + client.get_effective_event_threat_detection_custom_module(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_get_effective_event_threat_detection_custom_module_rest_bad_request(transport: str = 'rest', request_type=security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/effectiveEventThreatDetectionCustomModules/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.get_effective_event_threat_detection_custom_module(request) + + +def test_get_effective_event_threat_detection_custom_module_rest_flattened(): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = security_center_management.EffectiveEventThreatDetectionCustomModule() + + # get arguments that satisfy an http rule for this method + sample_request = {'name': 'projects/sample1/locations/sample2/effectiveEventThreatDetectionCustomModules/sample3'} + + # get truthy value for each flattened field + mock_args = dict( + name='name_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = security_center_management.EffectiveEventThreatDetectionCustomModule.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.get_effective_event_threat_detection_custom_module(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{name=projects/*/locations/*/effectiveEventThreatDetectionCustomModules/*}" % client.transport._host, args[1]) + + +def test_get_effective_event_threat_detection_custom_module_rest_flattened_error(transport: str = 'rest'): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_effective_event_threat_detection_custom_module( + security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest(), + name='name_value', + ) + + +def test_get_effective_event_threat_detection_custom_module_rest_error(): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + security_center_management.ListEventThreatDetectionCustomModulesRequest, + dict, +]) +def test_list_event_threat_detection_custom_modules_rest(request_type): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = security_center_management.ListEventThreatDetectionCustomModulesResponse( + next_page_token='next_page_token_value', + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = security_center_management.ListEventThreatDetectionCustomModulesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.list_event_threat_detection_custom_modules(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListEventThreatDetectionCustomModulesPager) + assert response.next_page_token == 'next_page_token_value' + + +def test_list_event_threat_detection_custom_modules_rest_required_fields(request_type=security_center_management.ListEventThreatDetectionCustomModulesRequest): + transport_class = transports.SecurityCenterManagementRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_event_threat_detection_custom_modules._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = 'parent_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_event_threat_detection_custom_modules._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("page_size", "page_token", )) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == 'parent_value' + + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = security_center_management.ListEventThreatDetectionCustomModulesResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "get", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = security_center_management.ListEventThreatDetectionCustomModulesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.list_event_threat_detection_custom_modules(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_list_event_threat_detection_custom_modules_rest_unset_required_fields(): + transport = transports.SecurityCenterManagementRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.list_event_threat_detection_custom_modules._get_unset_required_fields({}) + assert set(unset_fields) == (set(("pageSize", "pageToken", )) & set(("parent", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_event_threat_detection_custom_modules_rest_interceptors(null_interceptor): + transport = transports.SecurityCenterManagementRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.SecurityCenterManagementRestInterceptor(), + ) + client = SecurityCenterManagementClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "post_list_event_threat_detection_custom_modules") as post, \ + mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "pre_list_event_threat_detection_custom_modules") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = security_center_management.ListEventThreatDetectionCustomModulesRequest.pb(security_center_management.ListEventThreatDetectionCustomModulesRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = security_center_management.ListEventThreatDetectionCustomModulesResponse.to_json(security_center_management.ListEventThreatDetectionCustomModulesResponse()) + + request = security_center_management.ListEventThreatDetectionCustomModulesRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = security_center_management.ListEventThreatDetectionCustomModulesResponse() + + client.list_event_threat_detection_custom_modules(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_list_event_threat_detection_custom_modules_rest_bad_request(transport: str = 'rest', request_type=security_center_management.ListEventThreatDetectionCustomModulesRequest): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.list_event_threat_detection_custom_modules(request) + + +def test_list_event_threat_detection_custom_modules_rest_flattened(): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = security_center_management.ListEventThreatDetectionCustomModulesResponse() + + # get arguments that satisfy an http rule for this method + sample_request = {'parent': 'projects/sample1/locations/sample2'} + + # get truthy value for each flattened field + mock_args = dict( + parent='parent_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = security_center_management.ListEventThreatDetectionCustomModulesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.list_event_threat_detection_custom_modules(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/eventThreatDetectionCustomModules" % client.transport._host, args[1]) + + +def test_list_event_threat_detection_custom_modules_rest_flattened_error(transport: str = 'rest'): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_event_threat_detection_custom_modules( + security_center_management.ListEventThreatDetectionCustomModulesRequest(), + parent='parent_value', + ) + + +def test_list_event_threat_detection_custom_modules_rest_pager(transport: str = 'rest'): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + #with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + security_center_management.ListEventThreatDetectionCustomModulesResponse( + event_threat_detection_custom_modules=[ + security_center_management.EventThreatDetectionCustomModule(), + security_center_management.EventThreatDetectionCustomModule(), + security_center_management.EventThreatDetectionCustomModule(), + ], + next_page_token='abc', + ), + security_center_management.ListEventThreatDetectionCustomModulesResponse( + event_threat_detection_custom_modules=[], + next_page_token='def', + ), + security_center_management.ListEventThreatDetectionCustomModulesResponse( + event_threat_detection_custom_modules=[ + security_center_management.EventThreatDetectionCustomModule(), + ], + next_page_token='ghi', + ), + security_center_management.ListEventThreatDetectionCustomModulesResponse( + event_threat_detection_custom_modules=[ + security_center_management.EventThreatDetectionCustomModule(), + security_center_management.EventThreatDetectionCustomModule(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple(security_center_management.ListEventThreatDetectionCustomModulesResponse.to_json(x) for x in response) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode('UTF-8') + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {'parent': 'projects/sample1/locations/sample2'} + + pager = client.list_event_threat_detection_custom_modules(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, security_center_management.EventThreatDetectionCustomModule) + for i in results) + + pages = list(client.list_event_threat_detection_custom_modules(request=sample_request).pages) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.parametrize("request_type", [ + security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest, + dict, +]) +def test_list_descendant_event_threat_detection_custom_modules_rest(request_type): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse( + next_page_token='next_page_token_value', + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.list_descendant_event_threat_detection_custom_modules(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListDescendantEventThreatDetectionCustomModulesPager) + assert response.next_page_token == 'next_page_token_value' + + +def test_list_descendant_event_threat_detection_custom_modules_rest_required_fields(request_type=security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest): + transport_class = transports.SecurityCenterManagementRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_descendant_event_threat_detection_custom_modules._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = 'parent_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_descendant_event_threat_detection_custom_modules._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("page_size", "page_token", )) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == 'parent_value' + + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "get", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.list_descendant_event_threat_detection_custom_modules(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_list_descendant_event_threat_detection_custom_modules_rest_unset_required_fields(): + transport = transports.SecurityCenterManagementRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.list_descendant_event_threat_detection_custom_modules._get_unset_required_fields({}) + assert set(unset_fields) == (set(("pageSize", "pageToken", )) & set(("parent", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_list_descendant_event_threat_detection_custom_modules_rest_interceptors(null_interceptor): + transport = transports.SecurityCenterManagementRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.SecurityCenterManagementRestInterceptor(), + ) + client = SecurityCenterManagementClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "post_list_descendant_event_threat_detection_custom_modules") as post, \ + mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "pre_list_descendant_event_threat_detection_custom_modules") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest.pb(security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse.to_json(security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse()) + + request = security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse() + + client.list_descendant_event_threat_detection_custom_modules(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_list_descendant_event_threat_detection_custom_modules_rest_bad_request(transport: str = 'rest', request_type=security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.list_descendant_event_threat_detection_custom_modules(request) + + +def test_list_descendant_event_threat_detection_custom_modules_rest_flattened(): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse() + + # get arguments that satisfy an http rule for this method + sample_request = {'parent': 'projects/sample1/locations/sample2'} + + # get truthy value for each flattened field + mock_args = dict( + parent='parent_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.list_descendant_event_threat_detection_custom_modules(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/eventThreatDetectionCustomModules:listDescendant" % client.transport._host, args[1]) + + +def test_list_descendant_event_threat_detection_custom_modules_rest_flattened_error(transport: str = 'rest'): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.list_descendant_event_threat_detection_custom_modules( + security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest(), + parent='parent_value', + ) + + +def test_list_descendant_event_threat_detection_custom_modules_rest_pager(transport: str = 'rest'): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # TODO(kbandes): remove this mock unless there's a good reason for it. + #with mock.patch.object(path_template, 'transcode') as transcode: + # Set the response as a series of pages + response = ( + security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse( + event_threat_detection_custom_modules=[ + security_center_management.EventThreatDetectionCustomModule(), + security_center_management.EventThreatDetectionCustomModule(), + security_center_management.EventThreatDetectionCustomModule(), + ], + next_page_token='abc', + ), + security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse( + event_threat_detection_custom_modules=[], + next_page_token='def', + ), + security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse( + event_threat_detection_custom_modules=[ + security_center_management.EventThreatDetectionCustomModule(), + ], + next_page_token='ghi', + ), + security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse( + event_threat_detection_custom_modules=[ + security_center_management.EventThreatDetectionCustomModule(), + security_center_management.EventThreatDetectionCustomModule(), + ], + ), + ) + # Two responses for two calls + response = response + response + + # Wrap the values into proper Response objs + response = tuple(security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse.to_json(x) for x in response) + return_values = tuple(Response() for i in response) + for return_val, response_val in zip(return_values, response): + return_val._content = response_val.encode('UTF-8') + return_val.status_code = 200 + req.side_effect = return_values + + sample_request = {'parent': 'projects/sample1/locations/sample2'} + + pager = client.list_descendant_event_threat_detection_custom_modules(request=sample_request) + + results = list(pager) + assert len(results) == 6 + assert all(isinstance(i, security_center_management.EventThreatDetectionCustomModule) + for i in results) + + pages = list(client.list_descendant_event_threat_detection_custom_modules(request=sample_request).pages) + for page_, token in zip(pages, ['abc','def','ghi', '']): + assert page_.raw_page.next_page_token == token + + +@pytest.mark.parametrize("request_type", [ + security_center_management.GetEventThreatDetectionCustomModuleRequest, + dict, +]) +def test_get_event_threat_detection_custom_module_rest(request_type): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/eventThreatDetectionCustomModules/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = security_center_management.EventThreatDetectionCustomModule( + name='name_value', + ancestor_module='ancestor_module_value', + enablement_state=security_center_management.EventThreatDetectionCustomModule.EnablementState.ENABLED, + type_='type__value', + display_name='display_name_value', + description='description_value', + last_editor='last_editor_value', + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = security_center_management.EventThreatDetectionCustomModule.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.get_event_threat_detection_custom_module(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, security_center_management.EventThreatDetectionCustomModule) + assert response.name == 'name_value' + assert response.ancestor_module == 'ancestor_module_value' + assert response.enablement_state == security_center_management.EventThreatDetectionCustomModule.EnablementState.ENABLED + assert response.type_ == 'type__value' + assert response.display_name == 'display_name_value' + assert response.description == 'description_value' + assert response.last_editor == 'last_editor_value' + + +def test_get_event_threat_detection_custom_module_rest_required_fields(request_type=security_center_management.GetEventThreatDetectionCustomModuleRequest): + transport_class = transports.SecurityCenterManagementRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_event_threat_detection_custom_module._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = 'name_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_event_threat_detection_custom_module._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == 'name_value' + + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = security_center_management.EventThreatDetectionCustomModule() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "get", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = security_center_management.EventThreatDetectionCustomModule.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.get_event_threat_detection_custom_module(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_get_event_threat_detection_custom_module_rest_unset_required_fields(): + transport = transports.SecurityCenterManagementRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.get_event_threat_detection_custom_module._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("name", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_get_event_threat_detection_custom_module_rest_interceptors(null_interceptor): + transport = transports.SecurityCenterManagementRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.SecurityCenterManagementRestInterceptor(), + ) + client = SecurityCenterManagementClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "post_get_event_threat_detection_custom_module") as post, \ + mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "pre_get_event_threat_detection_custom_module") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = security_center_management.GetEventThreatDetectionCustomModuleRequest.pb(security_center_management.GetEventThreatDetectionCustomModuleRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = security_center_management.EventThreatDetectionCustomModule.to_json(security_center_management.EventThreatDetectionCustomModule()) + + request = security_center_management.GetEventThreatDetectionCustomModuleRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = security_center_management.EventThreatDetectionCustomModule() + + client.get_event_threat_detection_custom_module(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_get_event_threat_detection_custom_module_rest_bad_request(transport: str = 'rest', request_type=security_center_management.GetEventThreatDetectionCustomModuleRequest): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/eventThreatDetectionCustomModules/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.get_event_threat_detection_custom_module(request) + + +def test_get_event_threat_detection_custom_module_rest_flattened(): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = security_center_management.EventThreatDetectionCustomModule() + + # get arguments that satisfy an http rule for this method + sample_request = {'name': 'projects/sample1/locations/sample2/eventThreatDetectionCustomModules/sample3'} + + # get truthy value for each flattened field + mock_args = dict( + name='name_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = security_center_management.EventThreatDetectionCustomModule.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.get_event_threat_detection_custom_module(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{name=projects/*/locations/*/eventThreatDetectionCustomModules/*}" % client.transport._host, args[1]) + + +def test_get_event_threat_detection_custom_module_rest_flattened_error(transport: str = 'rest'): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.get_event_threat_detection_custom_module( + security_center_management.GetEventThreatDetectionCustomModuleRequest(), + name='name_value', + ) + + +def test_get_event_threat_detection_custom_module_rest_error(): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + security_center_management.CreateEventThreatDetectionCustomModuleRequest, + dict, +]) +def test_create_event_threat_detection_custom_module_rest(request_type): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request_init["event_threat_detection_custom_module"] = {'name': 'name_value', 'config': {'fields': {}}, 'ancestor_module': 'ancestor_module_value', 'enablement_state': 1, 'type_': 'type__value', 'display_name': 'display_name_value', 'description': 'description_value', 'update_time': {'seconds': 751, 'nanos': 543}, 'last_editor': 'last_editor_value'} + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = security_center_management.CreateEventThreatDetectionCustomModuleRequest.meta.fields["event_threat_detection_custom_module"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["event_threat_detection_custom_module"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + {"field": field, "subfield": subfield, "is_repeated": is_repeated} + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["event_threat_detection_custom_module"][field])): + del request_init["event_threat_detection_custom_module"][field][i][subfield] + else: + del request_init["event_threat_detection_custom_module"][field][subfield] + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = security_center_management.EventThreatDetectionCustomModule( + name='name_value', + ancestor_module='ancestor_module_value', + enablement_state=security_center_management.EventThreatDetectionCustomModule.EnablementState.ENABLED, + type_='type__value', + display_name='display_name_value', + description='description_value', + last_editor='last_editor_value', + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = security_center_management.EventThreatDetectionCustomModule.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.create_event_threat_detection_custom_module(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, security_center_management.EventThreatDetectionCustomModule) + assert response.name == 'name_value' + assert response.ancestor_module == 'ancestor_module_value' + assert response.enablement_state == security_center_management.EventThreatDetectionCustomModule.EnablementState.ENABLED + assert response.type_ == 'type__value' + assert response.display_name == 'display_name_value' + assert response.description == 'description_value' + assert response.last_editor == 'last_editor_value' + + +def test_create_event_threat_detection_custom_module_rest_required_fields(request_type=security_center_management.CreateEventThreatDetectionCustomModuleRequest): + transport_class = transports.SecurityCenterManagementRestTransport + + request_init = {} + request_init["parent"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_event_threat_detection_custom_module._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = 'parent_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_event_threat_detection_custom_module._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("validate_only", )) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == 'parent_value' + + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = security_center_management.EventThreatDetectionCustomModule() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "post", + 'query_params': pb_request, + } + transcode_result['body'] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = security_center_management.EventThreatDetectionCustomModule.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.create_event_threat_detection_custom_module(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_create_event_threat_detection_custom_module_rest_unset_required_fields(): + transport = transports.SecurityCenterManagementRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.create_event_threat_detection_custom_module._get_unset_required_fields({}) + assert set(unset_fields) == (set(("validateOnly", )) & set(("parent", "eventThreatDetectionCustomModule", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_create_event_threat_detection_custom_module_rest_interceptors(null_interceptor): + transport = transports.SecurityCenterManagementRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.SecurityCenterManagementRestInterceptor(), + ) + client = SecurityCenterManagementClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "post_create_event_threat_detection_custom_module") as post, \ + mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "pre_create_event_threat_detection_custom_module") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = security_center_management.CreateEventThreatDetectionCustomModuleRequest.pb(security_center_management.CreateEventThreatDetectionCustomModuleRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = security_center_management.EventThreatDetectionCustomModule.to_json(security_center_management.EventThreatDetectionCustomModule()) + + request = security_center_management.CreateEventThreatDetectionCustomModuleRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = security_center_management.EventThreatDetectionCustomModule() + + client.create_event_threat_detection_custom_module(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_create_event_threat_detection_custom_module_rest_bad_request(transport: str = 'rest', request_type=security_center_management.CreateEventThreatDetectionCustomModuleRequest): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.create_event_threat_detection_custom_module(request) + + +def test_create_event_threat_detection_custom_module_rest_flattened(): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = security_center_management.EventThreatDetectionCustomModule() + + # get arguments that satisfy an http rule for this method + sample_request = {'parent': 'projects/sample1/locations/sample2'} + + # get truthy value for each flattened field + mock_args = dict( + parent='parent_value', + event_threat_detection_custom_module=security_center_management.EventThreatDetectionCustomModule(name='name_value'), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = security_center_management.EventThreatDetectionCustomModule.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.create_event_threat_detection_custom_module(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/eventThreatDetectionCustomModules" % client.transport._host, args[1]) + + +def test_create_event_threat_detection_custom_module_rest_flattened_error(transport: str = 'rest'): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.create_event_threat_detection_custom_module( + security_center_management.CreateEventThreatDetectionCustomModuleRequest(), + parent='parent_value', + event_threat_detection_custom_module=security_center_management.EventThreatDetectionCustomModule(name='name_value'), + ) + + +def test_create_event_threat_detection_custom_module_rest_error(): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + security_center_management.UpdateEventThreatDetectionCustomModuleRequest, + dict, +]) +def test_update_event_threat_detection_custom_module_rest(request_type): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'event_threat_detection_custom_module': {'name': 'projects/sample1/locations/sample2/eventThreatDetectionCustomModules/sample3'}} + request_init["event_threat_detection_custom_module"] = {'name': 'projects/sample1/locations/sample2/eventThreatDetectionCustomModules/sample3', 'config': {'fields': {}}, 'ancestor_module': 'ancestor_module_value', 'enablement_state': 1, 'type_': 'type__value', 'display_name': 'display_name_value', 'description': 'description_value', 'update_time': {'seconds': 751, 'nanos': 543}, 'last_editor': 'last_editor_value'} + # The version of a generated dependency at test runtime may differ from the version used during generation. + # Delete any fields which are not present in the current runtime dependency + # See https://github.com/googleapis/gapic-generator-python/issues/1748 + + # Determine if the message type is proto-plus or protobuf + test_field = security_center_management.UpdateEventThreatDetectionCustomModuleRequest.meta.fields["event_threat_detection_custom_module"] + + def get_message_fields(field): + # Given a field which is a message (composite type), return a list with + # all the fields of the message. + # If the field is not a composite type, return an empty list. + message_fields = [] + + if hasattr(field, "message") and field.message: + is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") + + if is_field_type_proto_plus_type: + message_fields = field.message.meta.fields.values() + # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types + else: # pragma: NO COVER + message_fields = field.message.DESCRIPTOR.fields + return message_fields + + runtime_nested_fields = [ + (field.name, nested_field.name) + for field in get_message_fields(test_field) + for nested_field in get_message_fields(field) + ] + + subfields_not_in_runtime = [] + + # For each item in the sample request, create a list of sub fields which are not present at runtime + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for field, value in request_init["event_threat_detection_custom_module"].items(): # pragma: NO COVER + result = None + is_repeated = False + # For repeated fields + if isinstance(value, list) and len(value): + is_repeated = True + result = value[0] + # For fields where the type is another message + if isinstance(value, dict): + result = value + + if result and hasattr(result, "keys"): + for subfield in result.keys(): + if (field, subfield) not in runtime_nested_fields: + subfields_not_in_runtime.append( + {"field": field, "subfield": subfield, "is_repeated": is_repeated} + ) + + # Remove fields from the sample request which are not present in the runtime version of the dependency + # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime + for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER + field = subfield_to_delete.get("field") + field_repeated = subfield_to_delete.get("is_repeated") + subfield = subfield_to_delete.get("subfield") + if subfield: + if field_repeated: + for i in range(0, len(request_init["event_threat_detection_custom_module"][field])): + del request_init["event_threat_detection_custom_module"][field][i][subfield] + else: + del request_init["event_threat_detection_custom_module"][field][subfield] + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = security_center_management.EventThreatDetectionCustomModule( + name='name_value', + ancestor_module='ancestor_module_value', + enablement_state=security_center_management.EventThreatDetectionCustomModule.EnablementState.ENABLED, + type_='type__value', + display_name='display_name_value', + description='description_value', + last_editor='last_editor_value', + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = security_center_management.EventThreatDetectionCustomModule.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.update_event_threat_detection_custom_module(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, security_center_management.EventThreatDetectionCustomModule) + assert response.name == 'name_value' + assert response.ancestor_module == 'ancestor_module_value' + assert response.enablement_state == security_center_management.EventThreatDetectionCustomModule.EnablementState.ENABLED + assert response.type_ == 'type__value' + assert response.display_name == 'display_name_value' + assert response.description == 'description_value' + assert response.last_editor == 'last_editor_value' + + +def test_update_event_threat_detection_custom_module_rest_required_fields(request_type=security_center_management.UpdateEventThreatDetectionCustomModuleRequest): + transport_class = transports.SecurityCenterManagementRestTransport + + request_init = {} + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_event_threat_detection_custom_module._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_event_threat_detection_custom_module._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("update_mask", "validate_only", )) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = security_center_management.EventThreatDetectionCustomModule() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "patch", + 'query_params': pb_request, + } + transcode_result['body'] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = security_center_management.EventThreatDetectionCustomModule.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.update_event_threat_detection_custom_module(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_update_event_threat_detection_custom_module_rest_unset_required_fields(): + transport = transports.SecurityCenterManagementRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.update_event_threat_detection_custom_module._get_unset_required_fields({}) + assert set(unset_fields) == (set(("updateMask", "validateOnly", )) & set(("updateMask", "eventThreatDetectionCustomModule", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_update_event_threat_detection_custom_module_rest_interceptors(null_interceptor): + transport = transports.SecurityCenterManagementRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.SecurityCenterManagementRestInterceptor(), + ) + client = SecurityCenterManagementClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "post_update_event_threat_detection_custom_module") as post, \ + mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "pre_update_event_threat_detection_custom_module") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = security_center_management.UpdateEventThreatDetectionCustomModuleRequest.pb(security_center_management.UpdateEventThreatDetectionCustomModuleRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = security_center_management.EventThreatDetectionCustomModule.to_json(security_center_management.EventThreatDetectionCustomModule()) + + request = security_center_management.UpdateEventThreatDetectionCustomModuleRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = security_center_management.EventThreatDetectionCustomModule() + + client.update_event_threat_detection_custom_module(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_update_event_threat_detection_custom_module_rest_bad_request(transport: str = 'rest', request_type=security_center_management.UpdateEventThreatDetectionCustomModuleRequest): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'event_threat_detection_custom_module': {'name': 'projects/sample1/locations/sample2/eventThreatDetectionCustomModules/sample3'}} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.update_event_threat_detection_custom_module(request) + + +def test_update_event_threat_detection_custom_module_rest_flattened(): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = security_center_management.EventThreatDetectionCustomModule() + + # get arguments that satisfy an http rule for this method + sample_request = {'event_threat_detection_custom_module': {'name': 'projects/sample1/locations/sample2/eventThreatDetectionCustomModules/sample3'}} + + # get truthy value for each flattened field + mock_args = dict( + event_threat_detection_custom_module=security_center_management.EventThreatDetectionCustomModule(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = security_center_management.EventThreatDetectionCustomModule.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.update_event_threat_detection_custom_module(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{event_threat_detection_custom_module.name=projects/*/locations/*/eventThreatDetectionCustomModules/*}" % client.transport._host, args[1]) + + +def test_update_event_threat_detection_custom_module_rest_flattened_error(transport: str = 'rest'): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.update_event_threat_detection_custom_module( + security_center_management.UpdateEventThreatDetectionCustomModuleRequest(), + event_threat_detection_custom_module=security_center_management.EventThreatDetectionCustomModule(name='name_value'), + update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), + ) + + +def test_update_event_threat_detection_custom_module_rest_error(): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + security_center_management.DeleteEventThreatDetectionCustomModuleRequest, + dict, +]) +def test_delete_event_threat_detection_custom_module_rest(request_type): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/eventThreatDetectionCustomModules/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = None + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = '' + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.delete_event_threat_detection_custom_module(request) + + # Establish that the response is the type that we expect. + assert response is None + + +def test_delete_event_threat_detection_custom_module_rest_required_fields(request_type=security_center_management.DeleteEventThreatDetectionCustomModuleRequest): + transport_class = transports.SecurityCenterManagementRestTransport + + request_init = {} + request_init["name"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_event_threat_detection_custom_module._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["name"] = 'name_value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_event_threat_detection_custom_module._get_unset_required_fields(jsonified_request) + # Check that path parameters and body parameters are not mixing in. + assert not set(unset_fields) - set(("validate_only", )) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "name" in jsonified_request + assert jsonified_request["name"] == 'name_value' + + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = None + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "delete", + 'query_params': pb_request, + } + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + json_return_value = '' + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.delete_event_threat_detection_custom_module(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_delete_event_threat_detection_custom_module_rest_unset_required_fields(): + transport = transports.SecurityCenterManagementRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.delete_event_threat_detection_custom_module._get_unset_required_fields({}) + assert set(unset_fields) == (set(("validateOnly", )) & set(("name", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_delete_event_threat_detection_custom_module_rest_interceptors(null_interceptor): + transport = transports.SecurityCenterManagementRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.SecurityCenterManagementRestInterceptor(), + ) + client = SecurityCenterManagementClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "pre_delete_event_threat_detection_custom_module") as pre: + pre.assert_not_called() + pb_message = security_center_management.DeleteEventThreatDetectionCustomModuleRequest.pb(security_center_management.DeleteEventThreatDetectionCustomModuleRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + + request = security_center_management.DeleteEventThreatDetectionCustomModuleRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + + client.delete_event_threat_detection_custom_module(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + + +def test_delete_event_threat_detection_custom_module_rest_bad_request(transport: str = 'rest', request_type=security_center_management.DeleteEventThreatDetectionCustomModuleRequest): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'name': 'projects/sample1/locations/sample2/eventThreatDetectionCustomModules/sample3'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.delete_event_threat_detection_custom_module(request) + + +def test_delete_event_threat_detection_custom_module_rest_flattened(): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = None + + # get arguments that satisfy an http rule for this method + sample_request = {'name': 'projects/sample1/locations/sample2/eventThreatDetectionCustomModules/sample3'} + + # get truthy value for each flattened field + mock_args = dict( + name='name_value', + ) + mock_args.update(sample_request) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = '' + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + client.delete_event_threat_detection_custom_module(**mock_args) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(req.mock_calls) == 1 + _, args, _ = req.mock_calls[0] + assert path_template.validate("%s/v1/{name=projects/*/locations/*/eventThreatDetectionCustomModules/*}" % client.transport._host, args[1]) + + +def test_delete_event_threat_detection_custom_module_rest_flattened_error(transport: str = 'rest'): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.delete_event_threat_detection_custom_module( + security_center_management.DeleteEventThreatDetectionCustomModuleRequest(), + name='name_value', + ) + + +def test_delete_event_threat_detection_custom_module_rest_error(): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +@pytest.mark.parametrize("request_type", [ + security_center_management.ValidateEventThreatDetectionCustomModuleRequest, + dict, +]) +def test_validate_event_threat_detection_custom_module_rest(request_type): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = security_center_management.ValidateEventThreatDetectionCustomModuleResponse( + ) + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + # Convert return value to protobuf type + return_value = security_center_management.ValidateEventThreatDetectionCustomModuleResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + response = client.validate_event_threat_detection_custom_module(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, security_center_management.ValidateEventThreatDetectionCustomModuleResponse) + + +def test_validate_event_threat_detection_custom_module_rest_required_fields(request_type=security_center_management.ValidateEventThreatDetectionCustomModuleRequest): + transport_class = transports.SecurityCenterManagementRestTransport + + request_init = {} + request_init["parent"] = "" + request_init["raw_text"] = "" + request_init["type_"] = "" + request = request_type(**request_init) + pb_request = request_type.pb(request) + jsonified_request = json.loads(json_format.MessageToJson( + pb_request, + including_default_value_fields=False, + use_integers_for_enums=False + )) + + # verify fields with default values are dropped + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).validate_event_threat_detection_custom_module._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with default values are now present + + jsonified_request["parent"] = 'parent_value' + jsonified_request["rawText"] = 'raw_text_value' + jsonified_request["type"] = 'type__value' + + unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).validate_event_threat_detection_custom_module._get_unset_required_fields(jsonified_request) + jsonified_request.update(unset_fields) + + # verify required fields with non-default values are left alone + assert "parent" in jsonified_request + assert jsonified_request["parent"] == 'parent_value' + assert "rawText" in jsonified_request + assert jsonified_request["rawText"] == 'raw_text_value' + assert "type" in jsonified_request + assert jsonified_request["type"] == 'type__value' + + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest', + ) + request = request_type(**request_init) + + # Designate an appropriate value for the returned response. + return_value = security_center_management.ValidateEventThreatDetectionCustomModuleResponse() + # Mock the http request call within the method and fake a response. + with mock.patch.object(Session, 'request') as req: + # We need to mock transcode() because providing default values + # for required fields will fail the real version if the http_options + # expect actual values for those fields. + with mock.patch.object(path_template, 'transcode') as transcode: + # A uri without fields and an empty body will force all the + # request fields to show up in the query_params. + pb_request = request_type.pb(request) + transcode_result = { + 'uri': 'v1/sample_method', + 'method': "post", + 'query_params': pb_request, + } + transcode_result['body'] = pb_request + transcode.return_value = transcode_result + + response_value = Response() + response_value.status_code = 200 + + # Convert return value to protobuf type + return_value = security_center_management.ValidateEventThreatDetectionCustomModuleResponse.pb(return_value) + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.validate_event_threat_detection_custom_module(request) + + expected_params = [ + ('$alt', 'json;enum-encoding=int') + ] + actual_params = req.call_args.kwargs['params'] + assert expected_params == actual_params + + +def test_validate_event_threat_detection_custom_module_rest_unset_required_fields(): + transport = transports.SecurityCenterManagementRestTransport(credentials=ga_credentials.AnonymousCredentials) + + unset_fields = transport.validate_event_threat_detection_custom_module._get_unset_required_fields({}) + assert set(unset_fields) == (set(()) & set(("parent", "rawText", "type", ))) + + +@pytest.mark.parametrize("null_interceptor", [True, False]) +def test_validate_event_threat_detection_custom_module_rest_interceptors(null_interceptor): + transport = transports.SecurityCenterManagementRestTransport( + credentials=ga_credentials.AnonymousCredentials(), + interceptor=None if null_interceptor else transports.SecurityCenterManagementRestInterceptor(), + ) + client = SecurityCenterManagementClient(transport=transport) + with mock.patch.object(type(client.transport._session), "request") as req, \ + mock.patch.object(path_template, "transcode") as transcode, \ + mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "post_validate_event_threat_detection_custom_module") as post, \ + mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "pre_validate_event_threat_detection_custom_module") as pre: + pre.assert_not_called() + post.assert_not_called() + pb_message = security_center_management.ValidateEventThreatDetectionCustomModuleRequest.pb(security_center_management.ValidateEventThreatDetectionCustomModuleRequest()) + transcode.return_value = { + "method": "post", + "uri": "my_uri", + "body": pb_message, + "query_params": pb_message, + } + + req.return_value = Response() + req.return_value.status_code = 200 + req.return_value.request = PreparedRequest() + req.return_value._content = security_center_management.ValidateEventThreatDetectionCustomModuleResponse.to_json(security_center_management.ValidateEventThreatDetectionCustomModuleResponse()) + + request = security_center_management.ValidateEventThreatDetectionCustomModuleRequest() + metadata =[ + ("key", "val"), + ("cephalopod", "squid"), + ] + pre.return_value = request, metadata + post.return_value = security_center_management.ValidateEventThreatDetectionCustomModuleResponse() + + client.validate_event_threat_detection_custom_module(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) + + pre.assert_called_once() + post.assert_called_once() + + +def test_validate_event_threat_detection_custom_module_rest_bad_request(transport: str = 'rest', request_type=security_center_management.ValidateEventThreatDetectionCustomModuleRequest): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # send a request that will satisfy transcoding + request_init = {'parent': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.validate_event_threat_detection_custom_module(request) + + +def test_validate_event_threat_detection_custom_module_rest_error(): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport='rest' + ) + + +def test_credentials_transport_error(): + # It is an error to provide credentials and a transport instance. + transport = transports.SecurityCenterManagementGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # It is an error to provide a credentials file and a transport instance. + transport = transports.SecurityCenterManagementGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = SecurityCenterManagementClient( + client_options={"credentials_file": "credentials.json"}, + transport=transport, + ) + + # It is an error to provide an api_key and a transport instance. + transport = transports.SecurityCenterManagementGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = SecurityCenterManagementClient( + client_options=options, + transport=transport, + ) + + # It is an error to provide an api_key and a credential. + options = mock.Mock() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = SecurityCenterManagementClient( + client_options=options, + credentials=ga_credentials.AnonymousCredentials() + ) + + # It is an error to provide scopes and a transport instance. + transport = transports.SecurityCenterManagementGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + with pytest.raises(ValueError): + client = SecurityCenterManagementClient( + client_options={"scopes": ["1", "2"]}, + transport=transport, + ) + + +def test_transport_instance(): + # A client may be instantiated with a custom transport instance. + transport = transports.SecurityCenterManagementGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + client = SecurityCenterManagementClient(transport=transport) + assert client.transport is transport + +def test_transport_get_channel(): + # A client may be instantiated with a custom transport instance. + transport = transports.SecurityCenterManagementGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + + transport = transports.SecurityCenterManagementGrpcAsyncIOTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + channel = transport.grpc_channel + assert channel + +@pytest.mark.parametrize("transport_class", [ + transports.SecurityCenterManagementGrpcTransport, + transports.SecurityCenterManagementGrpcAsyncIOTransport, + transports.SecurityCenterManagementRestTransport, +]) +def test_transport_adc(transport_class): + # Test default credentials are used if not provided. + with mock.patch.object(google.auth, 'default') as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class() + adc.assert_called_once() + +@pytest.mark.parametrize("transport_name", [ + "grpc", + "rest", +]) +def test_transport_kind(transport_name): + transport = SecurityCenterManagementClient.get_transport_class(transport_name)( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert transport.kind == transport_name + +def test_transport_grpc_default(): + # A client should use the gRPC transport by default. + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.SecurityCenterManagementGrpcTransport, + ) + +def test_security_center_management_base_transport_error(): + # Passing both a credentials object and credentials_file should raise an error + with pytest.raises(core_exceptions.DuplicateCredentialArgs): + transport = transports.SecurityCenterManagementTransport( + credentials=ga_credentials.AnonymousCredentials(), + credentials_file="credentials.json" + ) + + +def test_security_center_management_base_transport(): + # Instantiate the base transport. + with mock.patch('google.cloud.securitycentermanagement_v1.services.security_center_management.transports.SecurityCenterManagementTransport.__init__') as Transport: + Transport.return_value = None + transport = transports.SecurityCenterManagementTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Every method on the transport should just blindly + # raise NotImplementedError. + methods = ( + 'list_effective_security_health_analytics_custom_modules', + 'get_effective_security_health_analytics_custom_module', + 'list_security_health_analytics_custom_modules', + 'list_descendant_security_health_analytics_custom_modules', + 'get_security_health_analytics_custom_module', + 'create_security_health_analytics_custom_module', + 'update_security_health_analytics_custom_module', + 'delete_security_health_analytics_custom_module', + 'simulate_security_health_analytics_custom_module', + 'list_effective_event_threat_detection_custom_modules', + 'get_effective_event_threat_detection_custom_module', + 'list_event_threat_detection_custom_modules', + 'list_descendant_event_threat_detection_custom_modules', + 'get_event_threat_detection_custom_module', + 'create_event_threat_detection_custom_module', + 'update_event_threat_detection_custom_module', + 'delete_event_threat_detection_custom_module', + 'validate_event_threat_detection_custom_module', + 'get_location', + 'list_locations', + ) + for method in methods: + with pytest.raises(NotImplementedError): + getattr(transport, method)(request=object()) + + with pytest.raises(NotImplementedError): + transport.close() + + # Catch all for all remaining methods and properties + remainder = [ + 'kind', + ] + for r in remainder: + with pytest.raises(NotImplementedError): + getattr(transport, r)() + + +def test_security_center_management_base_transport_with_credentials_file(): + # Instantiate the base transport with a credentials file + with mock.patch.object(google.auth, 'load_credentials_from_file', autospec=True) as load_creds, mock.patch('google.cloud.securitycentermanagement_v1.services.security_center_management.transports.SecurityCenterManagementTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.SecurityCenterManagementTransport( + credentials_file="credentials.json", + quota_project_id="octopus", + ) + load_creds.assert_called_once_with("credentials.json", + scopes=None, + default_scopes=( + 'https://www.googleapis.com/auth/cloud-platform', +), + quota_project_id="octopus", + ) + + +def test_security_center_management_base_transport_with_adc(): + # Test the default credentials are used if credentials and credentials_file are None. + with mock.patch.object(google.auth, 'default', autospec=True) as adc, mock.patch('google.cloud.securitycentermanagement_v1.services.security_center_management.transports.SecurityCenterManagementTransport._prep_wrapped_messages') as Transport: + Transport.return_value = None + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.SecurityCenterManagementTransport() + adc.assert_called_once() + + +def test_security_center_management_auth_adc(): + # If no credentials are provided, we should use ADC credentials. + with mock.patch.object(google.auth, 'default', autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + SecurityCenterManagementClient() + adc.assert_called_once_with( + scopes=None, + default_scopes=( + 'https://www.googleapis.com/auth/cloud-platform', +), + quota_project_id=None, + ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.SecurityCenterManagementGrpcTransport, + transports.SecurityCenterManagementGrpcAsyncIOTransport, + ], +) +def test_security_center_management_transport_auth_adc(transport_class): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, 'default', autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + adc.assert_called_once_with( + scopes=["1", "2"], + default_scopes=( 'https://www.googleapis.com/auth/cloud-platform',), + quota_project_id="octopus", + ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.SecurityCenterManagementGrpcTransport, + transports.SecurityCenterManagementGrpcAsyncIOTransport, + transports.SecurityCenterManagementRestTransport, + ], +) +def test_security_center_management_transport_auth_gdch_credentials(transport_class): + host = 'https://language.com' + api_audience_tests = [None, 'https://language2.com'] + api_audience_expect = [host, 'https://language2.com'] + for t, e in zip(api_audience_tests, api_audience_expect): + with mock.patch.object(google.auth, 'default', autospec=True) as adc: + gdch_mock = mock.MagicMock() + type(gdch_mock).with_gdch_audience = mock.PropertyMock(return_value=gdch_mock) + adc.return_value = (gdch_mock, None) + transport_class(host=host, api_audience=t) + gdch_mock.with_gdch_audience.assert_called_once_with( + e + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.SecurityCenterManagementGrpcTransport, grpc_helpers), + (transports.SecurityCenterManagementGrpcAsyncIOTransport, grpc_helpers_async) + ], +) +def test_security_center_management_transport_create_channel(transport_class, grpc_helpers): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class( + quota_project_id="octopus", + scopes=["1", "2"] + ) + + create_channel.assert_called_with( + "securitycentermanagement.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + default_scopes=( + 'https://www.googleapis.com/auth/cloud-platform', +), + scopes=["1", "2"], + default_host="securitycentermanagement.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize("transport_class", [transports.SecurityCenterManagementGrpcTransport, transports.SecurityCenterManagementGrpcAsyncIOTransport]) +def test_security_center_management_grpc_transport_client_cert_source_for_mtls( + transport_class +): + cred = ga_credentials.AnonymousCredentials() + + # Check ssl_channel_credentials is used if provided. + with mock.patch.object(transport_class, "create_channel") as mock_create_channel: + mock_ssl_channel_creds = mock.Mock() + transport_class( + host="squid.clam.whelk", + credentials=cred, + ssl_channel_credentials=mock_ssl_channel_creds + ) + mock_create_channel.assert_called_once_with( + "squid.clam.whelk:443", + credentials=cred, + credentials_file=None, + scopes=None, + ssl_credentials=mock_ssl_channel_creds, + quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + # Check if ssl_channel_credentials is not provided, then client_cert_source_for_mtls + # is used. + with mock.patch.object(transport_class, "create_channel", return_value=mock.Mock()): + with mock.patch("grpc.ssl_channel_credentials") as mock_ssl_cred: + transport_class( + credentials=cred, + client_cert_source_for_mtls=client_cert_source_callback + ) + expected_cert, expected_key = client_cert_source_callback() + mock_ssl_cred.assert_called_once_with( + certificate_chain=expected_cert, + private_key=expected_key + ) + +def test_security_center_management_http_transport_client_cert_source_for_mtls(): + cred = ga_credentials.AnonymousCredentials() + with mock.patch("google.auth.transport.requests.AuthorizedSession.configure_mtls_channel") as mock_configure_mtls_channel: + transports.SecurityCenterManagementRestTransport ( + credentials=cred, + client_cert_source_for_mtls=client_cert_source_callback + ) + mock_configure_mtls_channel.assert_called_once_with(client_cert_source_callback) + + +@pytest.mark.parametrize("transport_name", [ + "grpc", + "grpc_asyncio", + "rest", +]) +def test_security_center_management_host_no_port(transport_name): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + client_options=client_options.ClientOptions(api_endpoint='securitycentermanagement.googleapis.com'), + transport=transport_name, + ) + assert client.transport._host == ( + 'securitycentermanagement.googleapis.com:443' + if transport_name in ['grpc', 'grpc_asyncio'] + else 'https://securitycentermanagement.googleapis.com' + ) + +@pytest.mark.parametrize("transport_name", [ + "grpc", + "grpc_asyncio", + "rest", +]) +def test_security_center_management_host_with_port(transport_name): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + client_options=client_options.ClientOptions(api_endpoint='securitycentermanagement.googleapis.com:8000'), + transport=transport_name, + ) + assert client.transport._host == ( + 'securitycentermanagement.googleapis.com:8000' + if transport_name in ['grpc', 'grpc_asyncio'] + else 'https://securitycentermanagement.googleapis.com:8000' + ) + +@pytest.mark.parametrize("transport_name", [ + "rest", +]) +def test_security_center_management_client_transport_session_collision(transport_name): + creds1 = ga_credentials.AnonymousCredentials() + creds2 = ga_credentials.AnonymousCredentials() + client1 = SecurityCenterManagementClient( + credentials=creds1, + transport=transport_name, + ) + client2 = SecurityCenterManagementClient( + credentials=creds2, + transport=transport_name, + ) + session1 = client1.transport.list_effective_security_health_analytics_custom_modules._session + session2 = client2.transport.list_effective_security_health_analytics_custom_modules._session + assert session1 != session2 + session1 = client1.transport.get_effective_security_health_analytics_custom_module._session + session2 = client2.transport.get_effective_security_health_analytics_custom_module._session + assert session1 != session2 + session1 = client1.transport.list_security_health_analytics_custom_modules._session + session2 = client2.transport.list_security_health_analytics_custom_modules._session + assert session1 != session2 + session1 = client1.transport.list_descendant_security_health_analytics_custom_modules._session + session2 = client2.transport.list_descendant_security_health_analytics_custom_modules._session + assert session1 != session2 + session1 = client1.transport.get_security_health_analytics_custom_module._session + session2 = client2.transport.get_security_health_analytics_custom_module._session + assert session1 != session2 + session1 = client1.transport.create_security_health_analytics_custom_module._session + session2 = client2.transport.create_security_health_analytics_custom_module._session + assert session1 != session2 + session1 = client1.transport.update_security_health_analytics_custom_module._session + session2 = client2.transport.update_security_health_analytics_custom_module._session + assert session1 != session2 + session1 = client1.transport.delete_security_health_analytics_custom_module._session + session2 = client2.transport.delete_security_health_analytics_custom_module._session + assert session1 != session2 + session1 = client1.transport.simulate_security_health_analytics_custom_module._session + session2 = client2.transport.simulate_security_health_analytics_custom_module._session + assert session1 != session2 + session1 = client1.transport.list_effective_event_threat_detection_custom_modules._session + session2 = client2.transport.list_effective_event_threat_detection_custom_modules._session + assert session1 != session2 + session1 = client1.transport.get_effective_event_threat_detection_custom_module._session + session2 = client2.transport.get_effective_event_threat_detection_custom_module._session + assert session1 != session2 + session1 = client1.transport.list_event_threat_detection_custom_modules._session + session2 = client2.transport.list_event_threat_detection_custom_modules._session + assert session1 != session2 + session1 = client1.transport.list_descendant_event_threat_detection_custom_modules._session + session2 = client2.transport.list_descendant_event_threat_detection_custom_modules._session + assert session1 != session2 + session1 = client1.transport.get_event_threat_detection_custom_module._session + session2 = client2.transport.get_event_threat_detection_custom_module._session + assert session1 != session2 + session1 = client1.transport.create_event_threat_detection_custom_module._session + session2 = client2.transport.create_event_threat_detection_custom_module._session + assert session1 != session2 + session1 = client1.transport.update_event_threat_detection_custom_module._session + session2 = client2.transport.update_event_threat_detection_custom_module._session + assert session1 != session2 + session1 = client1.transport.delete_event_threat_detection_custom_module._session + session2 = client2.transport.delete_event_threat_detection_custom_module._session + assert session1 != session2 + session1 = client1.transport.validate_event_threat_detection_custom_module._session + session2 = client2.transport.validate_event_threat_detection_custom_module._session + assert session1 != session2 +def test_security_center_management_grpc_transport_channel(): + channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials()) + + # Check that channel is used if provided. + transport = transports.SecurityCenterManagementGrpcTransport( + host="squid.clam.whelk", + channel=channel, + ) + assert transport.grpc_channel == channel + assert transport._host == "squid.clam.whelk:443" + assert transport._ssl_channel_credentials == None + + +def test_security_center_management_grpc_asyncio_transport_channel(): + channel = aio.secure_channel('http://localhost/', grpc.local_channel_credentials()) + + # Check that channel is used if provided. + transport = transports.SecurityCenterManagementGrpcAsyncIOTransport( + host="squid.clam.whelk", + channel=channel, + ) + assert transport.grpc_channel == channel + assert transport._host == "squid.clam.whelk:443" + assert transport._ssl_channel_credentials == None + + +# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are +# removed from grpc/grpc_asyncio transport constructor. +@pytest.mark.parametrize("transport_class", [transports.SecurityCenterManagementGrpcTransport, transports.SecurityCenterManagementGrpcAsyncIOTransport]) +def test_security_center_management_transport_channel_mtls_with_client_cert_source( + transport_class +): + with mock.patch("grpc.ssl_channel_credentials", autospec=True) as grpc_ssl_channel_cred: + with mock.patch.object(transport_class, "create_channel") as grpc_create_channel: + mock_ssl_cred = mock.Mock() + grpc_ssl_channel_cred.return_value = mock_ssl_cred + + mock_grpc_channel = mock.Mock() + grpc_create_channel.return_value = mock_grpc_channel + + cred = ga_credentials.AnonymousCredentials() + with pytest.warns(DeprecationWarning): + with mock.patch.object(google.auth, 'default') as adc: + adc.return_value = (cred, None) + transport = transport_class( + host="squid.clam.whelk", + api_mtls_endpoint="mtls.squid.clam.whelk", + client_cert_source=client_cert_source_callback, + ) + adc.assert_called_once() + + grpc_ssl_channel_cred.assert_called_once_with( + certificate_chain=b"cert bytes", private_key=b"key bytes" + ) + grpc_create_channel.assert_called_once_with( + "mtls.squid.clam.whelk:443", + credentials=cred, + credentials_file=None, + scopes=None, + ssl_credentials=mock_ssl_cred, + quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + assert transport.grpc_channel == mock_grpc_channel + assert transport._ssl_channel_credentials == mock_ssl_cred + + +# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are +# removed from grpc/grpc_asyncio transport constructor. +@pytest.mark.parametrize("transport_class", [transports.SecurityCenterManagementGrpcTransport, transports.SecurityCenterManagementGrpcAsyncIOTransport]) +def test_security_center_management_transport_channel_mtls_with_adc( + transport_class +): + mock_ssl_cred = mock.Mock() + with mock.patch.multiple( + "google.auth.transport.grpc.SslCredentials", + __init__=mock.Mock(return_value=None), + ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred), + ): + with mock.patch.object(transport_class, "create_channel") as grpc_create_channel: + mock_grpc_channel = mock.Mock() + grpc_create_channel.return_value = mock_grpc_channel + mock_cred = mock.Mock() + + with pytest.warns(DeprecationWarning): + transport = transport_class( + host="squid.clam.whelk", + credentials=mock_cred, + api_mtls_endpoint="mtls.squid.clam.whelk", + client_cert_source=None, + ) + + grpc_create_channel.assert_called_once_with( + "mtls.squid.clam.whelk:443", + credentials=mock_cred, + credentials_file=None, + scopes=None, + ssl_credentials=mock_ssl_cred, + quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + assert transport.grpc_channel == mock_grpc_channel + + +def test_effective_event_threat_detection_custom_module_path(): + organization = "squid" + location = "clam" + effective_event_threat_detection_custom_module = "whelk" + expected = "organizations/{organization}/locations/{location}/effectiveEventThreatDetectionCustomModules/{effective_event_threat_detection_custom_module}".format(organization=organization, location=location, effective_event_threat_detection_custom_module=effective_event_threat_detection_custom_module, ) + actual = SecurityCenterManagementClient.effective_event_threat_detection_custom_module_path(organization, location, effective_event_threat_detection_custom_module) + assert expected == actual + + +def test_parse_effective_event_threat_detection_custom_module_path(): + expected = { + "organization": "octopus", + "location": "oyster", + "effective_event_threat_detection_custom_module": "nudibranch", + } + path = SecurityCenterManagementClient.effective_event_threat_detection_custom_module_path(**expected) + + # Check that the path construction is reversible. + actual = SecurityCenterManagementClient.parse_effective_event_threat_detection_custom_module_path(path) + assert expected == actual + +def test_effective_security_health_analytics_custom_module_path(): + organization = "cuttlefish" + location = "mussel" + effective_security_health_analytics_custom_module = "winkle" + expected = "organizations/{organization}/locations/{location}/effectiveSecurityHealthAnalyticsCustomModules/{effective_security_health_analytics_custom_module}".format(organization=organization, location=location, effective_security_health_analytics_custom_module=effective_security_health_analytics_custom_module, ) + actual = SecurityCenterManagementClient.effective_security_health_analytics_custom_module_path(organization, location, effective_security_health_analytics_custom_module) + assert expected == actual + + +def test_parse_effective_security_health_analytics_custom_module_path(): + expected = { + "organization": "nautilus", + "location": "scallop", + "effective_security_health_analytics_custom_module": "abalone", + } + path = SecurityCenterManagementClient.effective_security_health_analytics_custom_module_path(**expected) + + # Check that the path construction is reversible. + actual = SecurityCenterManagementClient.parse_effective_security_health_analytics_custom_module_path(path) + assert expected == actual + +def test_event_threat_detection_custom_module_path(): + organization = "squid" + location = "clam" + event_threat_detection_custom_module = "whelk" + expected = "organizations/{organization}/locations/{location}/eventThreatDetectionCustomModules/{event_threat_detection_custom_module}".format(organization=organization, location=location, event_threat_detection_custom_module=event_threat_detection_custom_module, ) + actual = SecurityCenterManagementClient.event_threat_detection_custom_module_path(organization, location, event_threat_detection_custom_module) + assert expected == actual + + +def test_parse_event_threat_detection_custom_module_path(): + expected = { + "organization": "octopus", + "location": "oyster", + "event_threat_detection_custom_module": "nudibranch", + } + path = SecurityCenterManagementClient.event_threat_detection_custom_module_path(**expected) + + # Check that the path construction is reversible. + actual = SecurityCenterManagementClient.parse_event_threat_detection_custom_module_path(path) + assert expected == actual + +def test_finding_path(): + organization = "cuttlefish" + source = "mussel" + finding = "winkle" + expected = "organizations/{organization}/sources/{source}/findings/{finding}".format(organization=organization, source=source, finding=finding, ) + actual = SecurityCenterManagementClient.finding_path(organization, source, finding) + assert expected == actual + + +def test_parse_finding_path(): + expected = { + "organization": "nautilus", + "source": "scallop", + "finding": "abalone", + } + path = SecurityCenterManagementClient.finding_path(**expected) + + # Check that the path construction is reversible. + actual = SecurityCenterManagementClient.parse_finding_path(path) + assert expected == actual + +def test_security_health_analytics_custom_module_path(): + organization = "squid" + location = "clam" + security_health_analytics_custom_module = "whelk" + expected = "organizations/{organization}/locations/{location}/securityHealthAnalyticsCustomModules/{security_health_analytics_custom_module}".format(organization=organization, location=location, security_health_analytics_custom_module=security_health_analytics_custom_module, ) + actual = SecurityCenterManagementClient.security_health_analytics_custom_module_path(organization, location, security_health_analytics_custom_module) + assert expected == actual + + +def test_parse_security_health_analytics_custom_module_path(): + expected = { + "organization": "octopus", + "location": "oyster", + "security_health_analytics_custom_module": "nudibranch", + } + path = SecurityCenterManagementClient.security_health_analytics_custom_module_path(**expected) + + # Check that the path construction is reversible. + actual = SecurityCenterManagementClient.parse_security_health_analytics_custom_module_path(path) + assert expected == actual + +def test_common_billing_account_path(): + billing_account = "cuttlefish" + expected = "billingAccounts/{billing_account}".format(billing_account=billing_account, ) + actual = SecurityCenterManagementClient.common_billing_account_path(billing_account) + assert expected == actual + + +def test_parse_common_billing_account_path(): + expected = { + "billing_account": "mussel", + } + path = SecurityCenterManagementClient.common_billing_account_path(**expected) + + # Check that the path construction is reversible. + actual = SecurityCenterManagementClient.parse_common_billing_account_path(path) + assert expected == actual + +def test_common_folder_path(): + folder = "winkle" + expected = "folders/{folder}".format(folder=folder, ) + actual = SecurityCenterManagementClient.common_folder_path(folder) + assert expected == actual + + +def test_parse_common_folder_path(): + expected = { + "folder": "nautilus", + } + path = SecurityCenterManagementClient.common_folder_path(**expected) + + # Check that the path construction is reversible. + actual = SecurityCenterManagementClient.parse_common_folder_path(path) + assert expected == actual + +def test_common_organization_path(): + organization = "scallop" + expected = "organizations/{organization}".format(organization=organization, ) + actual = SecurityCenterManagementClient.common_organization_path(organization) + assert expected == actual + + +def test_parse_common_organization_path(): + expected = { + "organization": "abalone", + } + path = SecurityCenterManagementClient.common_organization_path(**expected) + + # Check that the path construction is reversible. + actual = SecurityCenterManagementClient.parse_common_organization_path(path) + assert expected == actual + +def test_common_project_path(): + project = "squid" + expected = "projects/{project}".format(project=project, ) + actual = SecurityCenterManagementClient.common_project_path(project) + assert expected == actual + + +def test_parse_common_project_path(): + expected = { + "project": "clam", + } + path = SecurityCenterManagementClient.common_project_path(**expected) + + # Check that the path construction is reversible. + actual = SecurityCenterManagementClient.parse_common_project_path(path) + assert expected == actual + +def test_common_location_path(): + project = "whelk" + location = "octopus" + expected = "projects/{project}/locations/{location}".format(project=project, location=location, ) + actual = SecurityCenterManagementClient.common_location_path(project, location) + assert expected == actual + + +def test_parse_common_location_path(): + expected = { + "project": "oyster", + "location": "nudibranch", + } + path = SecurityCenterManagementClient.common_location_path(**expected) + + # Check that the path construction is reversible. + actual = SecurityCenterManagementClient.parse_common_location_path(path) + assert expected == actual + + +def test_client_with_default_client_info(): + client_info = gapic_v1.client_info.ClientInfo() + + with mock.patch.object(transports.SecurityCenterManagementTransport, '_prep_wrapped_messages') as prep: + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, + ) + prep.assert_called_once_with(client_info) + + with mock.patch.object(transports.SecurityCenterManagementTransport, '_prep_wrapped_messages') as prep: + transport_class = SecurityCenterManagementClient.get_transport_class() + transport = transport_class( + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, + ) + prep.assert_called_once_with(client_info) + +@pytest.mark.asyncio +async def test_transport_close_async(): + client = SecurityCenterManagementAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc_asyncio", + ) + with mock.patch.object(type(getattr(client.transport, "grpc_channel")), "close") as close: + async with client: + close.assert_not_called() + close.assert_called_once() + + +def test_get_location_rest_bad_request(transport: str = 'rest', request_type=locations_pb2.GetLocationRequest): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + request = request_type() + request = json_format.ParseDict({'name': 'projects/sample1/locations/sample2'}, request) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.get_location(request) + +@pytest.mark.parametrize("request_type", [ + locations_pb2.GetLocationRequest, + dict, +]) +def test_get_location_rest(request_type): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request_init = {'name': 'projects/sample1/locations/sample2'} + request = request_type(**request_init) + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = locations_pb2.Location() + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.get_location(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, locations_pb2.Location) + +def test_list_locations_rest_bad_request(transport: str = 'rest', request_type=locations_pb2.ListLocationsRequest): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + request = request_type() + request = json_format.ParseDict({'name': 'projects/sample1'}, request) + + # Mock the http request call within the method and fake a BadRequest error. + with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 400 + response_value.request = Request() + req.return_value = response_value + client.list_locations(request) + +@pytest.mark.parametrize("request_type", [ + locations_pb2.ListLocationsRequest, + dict, +]) +def test_list_locations_rest(request_type): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="rest", + ) + request_init = {'name': 'projects/sample1'} + request = request_type(**request_init) + # Mock the http request call within the method and fake a response. + with mock.patch.object(type(client.transport._session), 'request') as req: + # Designate an appropriate value for the returned response. + return_value = locations_pb2.ListLocationsResponse() + + # Wrap the value into a proper Response obj + response_value = Response() + response_value.status_code = 200 + json_return_value = json_format.MessageToJson(return_value) + + response_value._content = json_return_value.encode('UTF-8') + req.return_value = response_value + + response = client.list_locations(request) + + # Establish that the response is the type that we expect. + assert isinstance(response, locations_pb2.ListLocationsResponse) + + +def test_list_locations(transport: str = "grpc"): + client = SecurityCenterManagementClient( + 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 = locations_pb2.ListLocationsRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_locations), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = locations_pb2.ListLocationsResponse() + response = client.list_locations(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 response is the type that we expect. + assert isinstance(response, locations_pb2.ListLocationsResponse) +@pytest.mark.asyncio +async def test_list_locations_async(transport: str = "grpc_asyncio"): + client = SecurityCenterManagementAsyncClient( + 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 = locations_pb2.ListLocationsRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_locations), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + locations_pb2.ListLocationsResponse() + ) + response = await client.list_locations(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 response is the type that we expect. + assert isinstance(response, locations_pb2.ListLocationsResponse) + +def test_list_locations_field_headers(): + client = SecurityCenterManagementClient( + 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 = locations_pb2.ListLocationsRequest() + request.name = "locations" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_locations), "__call__") as call: + call.return_value = locations_pb2.ListLocationsResponse() + + client.list_locations(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=locations",) in kw["metadata"] +@pytest.mark.asyncio +async def test_list_locations_field_headers_async(): + client = SecurityCenterManagementAsyncClient( + 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 = locations_pb2.ListLocationsRequest() + request.name = "locations" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_locations), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + locations_pb2.ListLocationsResponse() + ) + await client.list_locations(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=locations",) in kw["metadata"] + +def test_list_locations_from_dict(): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_locations), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = locations_pb2.ListLocationsResponse() + + response = client.list_locations( + request={ + "name": "locations", + } + ) + call.assert_called() +@pytest.mark.asyncio +async def test_list_locations_from_dict_async(): + client = SecurityCenterManagementAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_locations), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + locations_pb2.ListLocationsResponse() + ) + response = await client.list_locations( + request={ + "name": "locations", + } + ) + call.assert_called() + + +def test_get_location(transport: str = "grpc"): + client = SecurityCenterManagementClient( + 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 = locations_pb2.GetLocationRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_location), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = locations_pb2.Location() + response = client.get_location(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 response is the type that we expect. + assert isinstance(response, locations_pb2.Location) +@pytest.mark.asyncio +async def test_get_location_async(transport: str = "grpc_asyncio"): + client = SecurityCenterManagementAsyncClient( + 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 = locations_pb2.GetLocationRequest() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_location), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + locations_pb2.Location() + ) + response = await client.get_location(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 response is the type that we expect. + assert isinstance(response, locations_pb2.Location) + +def test_get_location_field_headers(): + client = SecurityCenterManagementClient( + 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 = locations_pb2.GetLocationRequest() + request.name = "locations/abc" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_location), "__call__") as call: + call.return_value = locations_pb2.Location() + + client.get_location(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=locations/abc",) in kw["metadata"] +@pytest.mark.asyncio +async def test_get_location_field_headers_async(): + client = SecurityCenterManagementAsyncClient( + 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 = locations_pb2.GetLocationRequest() + request.name = "locations/abc" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_location), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + locations_pb2.Location() + ) + await client.get_location(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=locations/abc",) in kw["metadata"] + +def test_get_location_from_dict(): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_locations), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = locations_pb2.Location() + + response = client.get_location( + request={ + "name": "locations/abc", + } + ) + call.assert_called() +@pytest.mark.asyncio +async def test_get_location_from_dict_async(): + client = SecurityCenterManagementAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_locations), "__call__") as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + locations_pb2.Location() + ) + response = await client.get_location( + request={ + "name": "locations", + } + ) + call.assert_called() + + +def test_transport_close(): + transports = { + "rest": "_session", + "grpc": "_grpc_channel", + } + + for transport, close_name in transports.items(): + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport + ) + with mock.patch.object(type(getattr(client.transport, close_name)), "close") as close: + with client: + close.assert_not_called() + close.assert_called_once() + +def test_client_ctx(): + transports = [ + 'rest', + 'grpc', + ] + for transport in transports: + client = SecurityCenterManagementClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport + ) + # Test client calls underlying transport. + with mock.patch.object(type(client.transport), "close") as close: + close.assert_not_called() + with client: + pass + close.assert_called() + +@pytest.mark.parametrize("client_class,transport_class", [ + (SecurityCenterManagementClient, transports.SecurityCenterManagementGrpcTransport), + (SecurityCenterManagementAsyncClient, transports.SecurityCenterManagementGrpcAsyncIOTransport), +]) +def test_api_key_credentials(client_class, transport_class): + with mock.patch.object( + google.auth._default, "get_api_key_credentials", create=True + ) as get_api_key_credentials: + mock_cred = mock.Mock() + get_api_key_credentials.return_value = mock_cred + options = client_options.ClientOptions() + options.api_key = "api_key" + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=mock_cred, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + api_audience=None, + ) From c6723caeb2199ea6ddc4e08176c344784f61a6f1 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Fri, 5 Jan 2024 09:56:56 +0000 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot=20po?= =?UTF-8?q?st-processor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- .../v1/.coveragerc | 13 - .../v1/.flake8 | 33 - .../v1/MANIFEST.in | 2 - .../v1/README.rst | 49 - .../v1/docs/_static/custom.css | 3 - .../v1/docs/conf.py | 376 - .../v1/docs/index.rst | 7 - .../security_center_management.rst | 10 - .../securitycentermanagement_v1/services_.rst | 6 - .../securitycentermanagement_v1/types_.rst | 6 - .../securitycentermanagement/__init__.py | 91 - .../securitycentermanagement/gapic_version.py | 16 - .../cloud/securitycentermanagement/py.typed | 2 - .../securitycentermanagement_v1/__init__.py | 92 - .../gapic_metadata.json | 298 - .../gapic_version.py | 16 - .../securitycentermanagement_v1/py.typed | 2 - .../services/__init__.py | 15 - .../security_center_management/__init__.py | 22 - .../async_client.py | 2501 ---- .../security_center_management/client.py | 2653 ---- .../security_center_management/pagers.py | 744 - .../transports/__init__.py | 38 - .../transports/base.py | 488 - .../transports/grpc.py | 818 -- .../transports/grpc_asyncio.py | 817 -- .../transports/rest.py | 2627 ---- .../types/__init__.py | 84 - .../types/security_center_management.py | 1771 --- .../v1/mypy.ini | 3 - .../v1/noxfile.py | 177 - ...nt_threat_detection_custom_module_async.py | 52 - ...ent_threat_detection_custom_module_sync.py | 52 - ...ty_health_analytics_custom_module_async.py | 52 - ...ity_health_analytics_custom_module_sync.py | 52 - ...nt_threat_detection_custom_module_async.py | 50 - ...ent_threat_detection_custom_module_sync.py | 50 - ...ty_health_analytics_custom_module_async.py | 50 - ...ity_health_analytics_custom_module_sync.py | 50 - ...nt_threat_detection_custom_module_async.py | 52 - ...ent_threat_detection_custom_module_sync.py | 52 - ...ty_health_analytics_custom_module_async.py | 52 - ...ity_health_analytics_custom_module_sync.py | 52 - ...nt_threat_detection_custom_module_async.py | 52 - ...ent_threat_detection_custom_module_sync.py | 52 - ...ty_health_analytics_custom_module_async.py | 52 - ...ity_health_analytics_custom_module_sync.py | 52 - ...t_threat_detection_custom_modules_async.py | 53 - ...nt_threat_detection_custom_modules_sync.py | 53 - ...y_health_analytics_custom_modules_async.py | 53 - ...ty_health_analytics_custom_modules_sync.py | 53 - ...t_threat_detection_custom_modules_async.py | 53 - ...nt_threat_detection_custom_modules_sync.py | 53 - ...y_health_analytics_custom_modules_async.py | 53 - ...ty_health_analytics_custom_modules_sync.py | 53 - ...t_threat_detection_custom_modules_async.py | 53 - ...nt_threat_detection_custom_modules_sync.py | 53 - ...y_health_analytics_custom_modules_async.py | 53 - ...ty_health_analytics_custom_modules_sync.py | 53 - ...ty_health_analytics_custom_module_async.py | 56 - ...ity_health_analytics_custom_module_sync.py | 56 - ...nt_threat_detection_custom_module_async.py | 51 - ...ent_threat_detection_custom_module_sync.py | 51 - ...ty_health_analytics_custom_module_async.py | 51 - ...ity_health_analytics_custom_module_sync.py | 51 - ...nt_threat_detection_custom_module_async.py | 54 - ...ent_threat_detection_custom_module_sync.py | 54 - ...gle.cloud.securitycentermanagement.v1.json | 2941 ---- ...up_securitycentermanagement_v1_keywords.py | 193 - .../v1/setup.py | 91 - .../v1/testing/constraints-3.10.txt | 7 - .../v1/testing/constraints-3.11.txt | 7 - .../v1/testing/constraints-3.12.txt | 7 - .../v1/testing/constraints-3.7.txt | 10 - .../v1/testing/constraints-3.8.txt | 7 - .../v1/testing/constraints-3.9.txt | 7 - .../v1/tests/__init__.py | 16 - .../v1/tests/unit/__init__.py | 16 - .../v1/tests/unit/gapic/__init__.py | 16 - .../securitycentermanagement_v1/__init__.py | 16 - .../test_security_center_management.py | 12019 ---------------- .../securitycentermanagement/gapic_version.py | 2 +- .../gapic_version.py | 2 +- .../async_client.py | 67 +- .../security_center_management/client.py | 67 +- .../transports/grpc.py | 67 +- .../transports/grpc_asyncio.py | 67 +- .../types/security_center_management.py | 35 +- ...gle.cloud.securitycentermanagement.v1.json | 2 +- 89 files changed, 139 insertions(+), 31187 deletions(-) delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/.coveragerc delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/.flake8 delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/MANIFEST.in delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/README.rst delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/docs/_static/custom.css delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/docs/conf.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/docs/index.rst delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/docs/securitycentermanagement_v1/security_center_management.rst delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/docs/securitycentermanagement_v1/services_.rst delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/docs/securitycentermanagement_v1/types_.rst delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement/__init__.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement/gapic_version.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement/py.typed delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/__init__.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/gapic_metadata.json delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/gapic_version.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/py.typed delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/__init__.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/__init__.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/async_client.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/client.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/pagers.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/__init__.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/base.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/grpc.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/grpc_asyncio.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/rest.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/types/__init__.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/types/security_center_management.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/mypy.ini delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/noxfile.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_create_event_threat_detection_custom_module_async.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_create_event_threat_detection_custom_module_sync.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_create_security_health_analytics_custom_module_async.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_create_security_health_analytics_custom_module_sync.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_delete_event_threat_detection_custom_module_async.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_delete_event_threat_detection_custom_module_sync.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_delete_security_health_analytics_custom_module_async.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_delete_security_health_analytics_custom_module_sync.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_effective_event_threat_detection_custom_module_async.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_effective_event_threat_detection_custom_module_sync.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_effective_security_health_analytics_custom_module_async.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_effective_security_health_analytics_custom_module_sync.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_event_threat_detection_custom_module_async.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_event_threat_detection_custom_module_sync.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_security_health_analytics_custom_module_async.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_security_health_analytics_custom_module_sync.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_descendant_event_threat_detection_custom_modules_async.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_descendant_event_threat_detection_custom_modules_sync.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_descendant_security_health_analytics_custom_modules_async.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_descendant_security_health_analytics_custom_modules_sync.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_effective_event_threat_detection_custom_modules_async.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_effective_event_threat_detection_custom_modules_sync.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_effective_security_health_analytics_custom_modules_async.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_effective_security_health_analytics_custom_modules_sync.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_event_threat_detection_custom_modules_async.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_event_threat_detection_custom_modules_sync.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_security_health_analytics_custom_modules_async.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_security_health_analytics_custom_modules_sync.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_simulate_security_health_analytics_custom_module_async.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_simulate_security_health_analytics_custom_module_sync.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_update_event_threat_detection_custom_module_async.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_update_event_threat_detection_custom_module_sync.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_update_security_health_analytics_custom_module_async.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_update_security_health_analytics_custom_module_sync.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_validate_event_threat_detection_custom_module_async.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_validate_event_threat_detection_custom_module_sync.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/snippet_metadata_google.cloud.securitycentermanagement.v1.json delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/scripts/fixup_securitycentermanagement_v1_keywords.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/setup.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/testing/constraints-3.10.txt delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/testing/constraints-3.11.txt delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/testing/constraints-3.12.txt delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/testing/constraints-3.7.txt delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/testing/constraints-3.8.txt delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/testing/constraints-3.9.txt delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/tests/__init__.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/tests/unit/__init__.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/tests/unit/gapic/__init__.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/tests/unit/gapic/securitycentermanagement_v1/__init__.py delete mode 100644 owl-bot-staging/google-cloud-securitycentermanagement/v1/tests/unit/gapic/securitycentermanagement_v1/test_security_center_management.py diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/.coveragerc b/owl-bot-staging/google-cloud-securitycentermanagement/v1/.coveragerc deleted file mode 100644 index 866d4d24017c..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/.coveragerc +++ /dev/null @@ -1,13 +0,0 @@ -[run] -branch = True - -[report] -show_missing = True -omit = - google/cloud/securitycentermanagement/__init__.py - google/cloud/securitycentermanagement/gapic_version.py -exclude_lines = - # Re-enable the standard pragma - pragma: NO COVER - # Ignore debug-only repr - def __repr__ diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/.flake8 b/owl-bot-staging/google-cloud-securitycentermanagement/v1/.flake8 deleted file mode 100644 index 29227d4cf419..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/.flake8 +++ /dev/null @@ -1,33 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright 2020 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 -# -# https://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 by synthtool. DO NOT EDIT! -[flake8] -ignore = E203, E266, E501, W503 -exclude = - # Exclude generated code. - **/proto/** - **/gapic/** - **/services/** - **/types/** - *_pb2.py - - # Standard linting exemptions. - **/.nox/** - __pycache__, - .git, - *.pyc, - conf.py diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/MANIFEST.in b/owl-bot-staging/google-cloud-securitycentermanagement/v1/MANIFEST.in deleted file mode 100644 index c0ed60a0af08..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/MANIFEST.in +++ /dev/null @@ -1,2 +0,0 @@ -recursive-include google/cloud/securitycentermanagement *.py -recursive-include google/cloud/securitycentermanagement_v1 *.py diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/README.rst b/owl-bot-staging/google-cloud-securitycentermanagement/v1/README.rst deleted file mode 100644 index 152c83ba9bf7..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/README.rst +++ /dev/null @@ -1,49 +0,0 @@ -Python Client for Google Cloud Securitycentermanagement API -================================================= - -Quick Start ------------ - -In order to use this library, you first need to go through the following steps: - -1. `Select or create a Cloud Platform project.`_ -2. `Enable billing for your project.`_ -3. Enable the Google Cloud Securitycentermanagement API. -4. `Setup Authentication.`_ - -.. _Select or create a Cloud Platform project.: https://console.cloud.google.com/project -.. _Enable billing for your project.: https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project -.. _Setup Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html - -Installation -~~~~~~~~~~~~ - -Install this library in a `virtualenv`_ using pip. `virtualenv`_ is a tool to -create isolated Python environments. The basic problem it addresses is one of -dependencies and versions, and indirectly permissions. - -With `virtualenv`_, it's possible to install this library without needing system -install permissions, and without clashing with the installed system -dependencies. - -.. _`virtualenv`: https://virtualenv.pypa.io/en/latest/ - - -Mac/Linux -^^^^^^^^^ - -.. code-block:: console - - python3 -m venv - source /bin/activate - /bin/pip install /path/to/library - - -Windows -^^^^^^^ - -.. code-block:: console - - python3 -m venv - \Scripts\activate - \Scripts\pip.exe install \path\to\library diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/docs/_static/custom.css b/owl-bot-staging/google-cloud-securitycentermanagement/v1/docs/_static/custom.css deleted file mode 100644 index 06423be0b592..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/docs/_static/custom.css +++ /dev/null @@ -1,3 +0,0 @@ -dl.field-list > dt { - min-width: 100px -} diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/docs/conf.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/docs/conf.py deleted file mode 100644 index 0eb0d885ae4b..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/docs/conf.py +++ /dev/null @@ -1,376 +0,0 @@ -# -*- 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. -# -# -# google-cloud-securitycentermanagement documentation build configuration file -# -# This file is execfile()d with the current directory set to its -# containing dir. -# -# Note that not all possible configuration values are present in this -# autogenerated file. -# -# All configuration values have a default; values that are commented out -# serve to show the default. - -import sys -import os -import shlex - -# If extensions (or modules to document with autodoc) are in another directory, -# add these directories to sys.path here. If the directory is relative to the -# documentation root, use os.path.abspath to make it absolute, like shown here. -sys.path.insert(0, os.path.abspath("..")) - -__version__ = "0.1.0" - -# -- General configuration ------------------------------------------------ - -# If your documentation needs a minimal Sphinx version, state it here. -needs_sphinx = "4.0.1" - -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. -extensions = [ - "sphinx.ext.autodoc", - "sphinx.ext.autosummary", - "sphinx.ext.intersphinx", - "sphinx.ext.coverage", - "sphinx.ext.napoleon", - "sphinx.ext.todo", - "sphinx.ext.viewcode", -] - -# autodoc/autosummary flags -autoclass_content = "both" -autodoc_default_flags = ["members"] -autosummary_generate = True - - -# Add any paths that contain templates here, relative to this directory. -templates_path = ["_templates"] - -# Allow markdown includes (so releases.md can include CHANGLEOG.md) -# http://www.sphinx-doc.org/en/master/markdown.html -source_parsers = {".md": "recommonmark.parser.CommonMarkParser"} - -# The suffix(es) of source filenames. -# You can specify multiple suffix as a list of string: -source_suffix = [".rst", ".md"] - -# The encoding of source files. -# source_encoding = 'utf-8-sig' - -# The root toctree document. -root_doc = "index" - -# General information about the project. -project = u"google-cloud-securitycentermanagement" -copyright = u"2023, Google, LLC" -author = u"Google APIs" # TODO: autogenerate this bit - -# The version info for the project you're documenting, acts as replacement for -# |version| and |release|, also used in various other places throughout the -# built documents. -# -# The full version, including alpha/beta/rc tags. -release = __version__ -# The short X.Y version. -version = ".".join(release.split(".")[0:2]) - -# The language for content autogenerated by Sphinx. Refer to documentation -# for a list of supported languages. -# -# This is also used if you do content translation via gettext catalogs. -# Usually you set "language" from the command line for these cases. -language = 'en' - -# There are two options for replacing |today|: either, you set today to some -# non-false value, then it is used: -# today = '' -# Else, today_fmt is used as the format for a strftime call. -# today_fmt = '%B %d, %Y' - -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -exclude_patterns = ["_build"] - -# The reST default role (used for this markup: `text`) to use for all -# documents. -# default_role = None - -# If true, '()' will be appended to :func: etc. cross-reference text. -# add_function_parentheses = True - -# If true, the current module name will be prepended to all description -# unit titles (such as .. function::). -# add_module_names = True - -# If true, sectionauthor and moduleauthor directives will be shown in the -# output. They are ignored by default. -# show_authors = False - -# The name of the Pygments (syntax highlighting) style to use. -pygments_style = "sphinx" - -# A list of ignored prefixes for module index sorting. -# modindex_common_prefix = [] - -# If true, keep warnings as "system message" paragraphs in the built documents. -# keep_warnings = False - -# If true, `todo` and `todoList` produce output, else they produce nothing. -todo_include_todos = True - - -# -- Options for HTML output ---------------------------------------------- - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. -html_theme = "alabaster" - -# Theme options are theme-specific and customize the look and feel of a theme -# further. For a list of options available for each theme, see the -# documentation. -html_theme_options = { - "description": "Google Cloud Client Libraries for Python", - "github_user": "googleapis", - "github_repo": "google-cloud-python", - "github_banner": True, - "font_family": "'Roboto', Georgia, sans", - "head_font_family": "'Roboto', Georgia, serif", - "code_font_family": "'Roboto Mono', 'Consolas', monospace", -} - -# Add any paths that contain custom themes here, relative to this directory. -# html_theme_path = [] - -# The name for this set of Sphinx documents. If None, it defaults to -# " v documentation". -# html_title = None - -# A shorter title for the navigation bar. Default is the same as html_title. -# html_short_title = None - -# The name of an image file (relative to this directory) to place at the top -# of the sidebar. -# html_logo = None - -# The name of an image file (within the static path) to use as favicon of the -# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 -# pixels large. -# html_favicon = None - -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ["_static"] - -# Add any extra paths that contain custom files (such as robots.txt or -# .htaccess) here, relative to this directory. These files are copied -# directly to the root of the documentation. -# html_extra_path = [] - -# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, -# using the given strftime format. -# html_last_updated_fmt = '%b %d, %Y' - -# If true, SmartyPants will be used to convert quotes and dashes to -# typographically correct entities. -# html_use_smartypants = True - -# Custom sidebar templates, maps document names to template names. -# html_sidebars = {} - -# Additional templates that should be rendered to pages, maps page names to -# template names. -# html_additional_pages = {} - -# If false, no module index is generated. -# html_domain_indices = True - -# If false, no index is generated. -# html_use_index = True - -# If true, the index is split into individual pages for each letter. -# html_split_index = False - -# If true, links to the reST sources are added to the pages. -# html_show_sourcelink = True - -# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. -# html_show_sphinx = True - -# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. -# html_show_copyright = True - -# If true, an OpenSearch description file will be output, and all pages will -# contain a tag referring to it. The value of this option must be the -# base URL from which the finished HTML is served. -# html_use_opensearch = '' - -# This is the file name suffix for HTML files (e.g. ".xhtml"). -# html_file_suffix = None - -# Language to be used for generating the HTML full-text search index. -# Sphinx supports the following languages: -# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' -# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr' -# html_search_language = 'en' - -# A dictionary with options for the search language support, empty by default. -# Now only 'ja' uses this config value -# html_search_options = {'type': 'default'} - -# The name of a javascript file (relative to the configuration directory) that -# implements a search results scorer. If empty, the default will be used. -# html_search_scorer = 'scorer.js' - -# Output file base name for HTML help builder. -htmlhelp_basename = "google-cloud-securitycentermanagement-doc" - -# -- Options for warnings ------------------------------------------------------ - - -suppress_warnings = [ - # Temporarily suppress this to avoid "more than one target found for - # cross-reference" warning, which are intractable for us to avoid while in - # a mono-repo. - # See https://github.com/sphinx-doc/sphinx/blob - # /2a65ffeef5c107c19084fabdd706cdff3f52d93c/sphinx/domains/python.py#L843 - "ref.python" -] - -# -- Options for LaTeX output --------------------------------------------- - -latex_elements = { - # The paper size ('letterpaper' or 'a4paper'). - # 'papersize': 'letterpaper', - # The font size ('10pt', '11pt' or '12pt'). - # 'pointsize': '10pt', - # Additional stuff for the LaTeX preamble. - # 'preamble': '', - # Latex figure (float) alignment - # 'figure_align': 'htbp', -} - -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, -# author, documentclass [howto, manual, or own class]). -latex_documents = [ - ( - root_doc, - "google-cloud-securitycentermanagement.tex", - u"google-cloud-securitycentermanagement Documentation", - author, - "manual", - ) -] - -# The name of an image file (relative to this directory) to place at the top of -# the title page. -# latex_logo = None - -# For "manual" documents, if this is true, then toplevel headings are parts, -# not chapters. -# latex_use_parts = False - -# If true, show page references after internal links. -# latex_show_pagerefs = False - -# If true, show URL addresses after external links. -# latex_show_urls = False - -# Documents to append as an appendix to all manuals. -# latex_appendices = [] - -# If false, no module index is generated. -# latex_domain_indices = True - - -# -- Options for manual page output --------------------------------------- - -# One entry per manual page. List of tuples -# (source start file, name, description, authors, manual section). -man_pages = [ - ( - root_doc, - "google-cloud-securitycentermanagement", - u"Google Cloud Securitycentermanagement Documentation", - [author], - 1, - ) -] - -# If true, show URL addresses after external links. -# man_show_urls = False - - -# -- Options for Texinfo output ------------------------------------------- - -# Grouping the document tree into Texinfo files. List of tuples -# (source start file, target name, title, author, -# dir menu entry, description, category) -texinfo_documents = [ - ( - root_doc, - "google-cloud-securitycentermanagement", - u"google-cloud-securitycentermanagement Documentation", - author, - "google-cloud-securitycentermanagement", - "GAPIC library for Google Cloud Securitycentermanagement API", - "APIs", - ) -] - -# Documents to append as an appendix to all manuals. -# texinfo_appendices = [] - -# If false, no module index is generated. -# texinfo_domain_indices = True - -# How to display URL addresses: 'footnote', 'no', or 'inline'. -# texinfo_show_urls = 'footnote' - -# If true, do not generate a @detailmenu in the "Top" node's menu. -# texinfo_no_detailmenu = False - - -# Example configuration for intersphinx: refer to the Python standard library. -intersphinx_mapping = { - "python": ("http://python.readthedocs.org/en/latest/", None), - "gax": ("https://gax-python.readthedocs.org/en/latest/", None), - "google-auth": ("https://google-auth.readthedocs.io/en/stable", None), - "google-gax": ("https://gax-python.readthedocs.io/en/latest/", None), - "google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None), - "grpc": ("https://grpc.io/grpc/python/", None), - "requests": ("http://requests.kennethreitz.org/en/stable/", None), - "proto": ("https://proto-plus-python.readthedocs.io/en/stable", None), - "protobuf": ("https://googleapis.dev/python/protobuf/latest/", None), -} - - -# Napoleon settings -napoleon_google_docstring = True -napoleon_numpy_docstring = True -napoleon_include_private_with_doc = False -napoleon_include_special_with_doc = True -napoleon_use_admonition_for_examples = False -napoleon_use_admonition_for_notes = False -napoleon_use_admonition_for_references = False -napoleon_use_ivar = False -napoleon_use_param = True -napoleon_use_rtype = True diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/docs/index.rst b/owl-bot-staging/google-cloud-securitycentermanagement/v1/docs/index.rst deleted file mode 100644 index c6c66dbbf5f0..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/docs/index.rst +++ /dev/null @@ -1,7 +0,0 @@ -API Reference -------------- -.. toctree:: - :maxdepth: 2 - - securitycentermanagement_v1/services - securitycentermanagement_v1/types diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/docs/securitycentermanagement_v1/security_center_management.rst b/owl-bot-staging/google-cloud-securitycentermanagement/v1/docs/securitycentermanagement_v1/security_center_management.rst deleted file mode 100644 index b3c4450ffa9d..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/docs/securitycentermanagement_v1/security_center_management.rst +++ /dev/null @@ -1,10 +0,0 @@ -SecurityCenterManagement ------------------------------------------- - -.. automodule:: google.cloud.securitycentermanagement_v1.services.security_center_management - :members: - :inherited-members: - -.. automodule:: google.cloud.securitycentermanagement_v1.services.security_center_management.pagers - :members: - :inherited-members: diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/docs/securitycentermanagement_v1/services_.rst b/owl-bot-staging/google-cloud-securitycentermanagement/v1/docs/securitycentermanagement_v1/services_.rst deleted file mode 100644 index 6643c9eb98b0..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/docs/securitycentermanagement_v1/services_.rst +++ /dev/null @@ -1,6 +0,0 @@ -Services for Google Cloud Securitycentermanagement v1 API -========================================================= -.. toctree:: - :maxdepth: 2 - - security_center_management diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/docs/securitycentermanagement_v1/types_.rst b/owl-bot-staging/google-cloud-securitycentermanagement/v1/docs/securitycentermanagement_v1/types_.rst deleted file mode 100644 index 508e249b3abf..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/docs/securitycentermanagement_v1/types_.rst +++ /dev/null @@ -1,6 +0,0 @@ -Types for Google Cloud Securitycentermanagement v1 API -====================================================== - -.. automodule:: google.cloud.securitycentermanagement_v1.types - :members: - :show-inheritance: diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement/__init__.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement/__init__.py deleted file mode 100644 index 14e9ea1b1f5e..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement/__init__.py +++ /dev/null @@ -1,91 +0,0 @@ -# -*- 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. -# -from google.cloud.securitycentermanagement import gapic_version as package_version - -__version__ = package_version.__version__ - - -from google.cloud.securitycentermanagement_v1.services.security_center_management.client import SecurityCenterManagementClient -from google.cloud.securitycentermanagement_v1.services.security_center_management.async_client import SecurityCenterManagementAsyncClient - -from google.cloud.securitycentermanagement_v1.types.security_center_management import CreateEventThreatDetectionCustomModuleRequest -from google.cloud.securitycentermanagement_v1.types.security_center_management import CreateSecurityHealthAnalyticsCustomModuleRequest -from google.cloud.securitycentermanagement_v1.types.security_center_management import CustomConfig -from google.cloud.securitycentermanagement_v1.types.security_center_management import DeleteEventThreatDetectionCustomModuleRequest -from google.cloud.securitycentermanagement_v1.types.security_center_management import DeleteSecurityHealthAnalyticsCustomModuleRequest -from google.cloud.securitycentermanagement_v1.types.security_center_management import EffectiveEventThreatDetectionCustomModule -from google.cloud.securitycentermanagement_v1.types.security_center_management import EffectiveSecurityHealthAnalyticsCustomModule -from google.cloud.securitycentermanagement_v1.types.security_center_management import EventThreatDetectionCustomModule -from google.cloud.securitycentermanagement_v1.types.security_center_management import GetEffectiveEventThreatDetectionCustomModuleRequest -from google.cloud.securitycentermanagement_v1.types.security_center_management import GetEffectiveSecurityHealthAnalyticsCustomModuleRequest -from google.cloud.securitycentermanagement_v1.types.security_center_management import GetEventThreatDetectionCustomModuleRequest -from google.cloud.securitycentermanagement_v1.types.security_center_management import GetSecurityHealthAnalyticsCustomModuleRequest -from google.cloud.securitycentermanagement_v1.types.security_center_management import ListDescendantEventThreatDetectionCustomModulesRequest -from google.cloud.securitycentermanagement_v1.types.security_center_management import ListDescendantEventThreatDetectionCustomModulesResponse -from google.cloud.securitycentermanagement_v1.types.security_center_management import ListDescendantSecurityHealthAnalyticsCustomModulesRequest -from google.cloud.securitycentermanagement_v1.types.security_center_management import ListDescendantSecurityHealthAnalyticsCustomModulesResponse -from google.cloud.securitycentermanagement_v1.types.security_center_management import ListEffectiveEventThreatDetectionCustomModulesRequest -from google.cloud.securitycentermanagement_v1.types.security_center_management import ListEffectiveEventThreatDetectionCustomModulesResponse -from google.cloud.securitycentermanagement_v1.types.security_center_management import ListEffectiveSecurityHealthAnalyticsCustomModulesRequest -from google.cloud.securitycentermanagement_v1.types.security_center_management import ListEffectiveSecurityHealthAnalyticsCustomModulesResponse -from google.cloud.securitycentermanagement_v1.types.security_center_management import ListEventThreatDetectionCustomModulesRequest -from google.cloud.securitycentermanagement_v1.types.security_center_management import ListEventThreatDetectionCustomModulesResponse -from google.cloud.securitycentermanagement_v1.types.security_center_management import ListSecurityHealthAnalyticsCustomModulesRequest -from google.cloud.securitycentermanagement_v1.types.security_center_management import ListSecurityHealthAnalyticsCustomModulesResponse -from google.cloud.securitycentermanagement_v1.types.security_center_management import SecurityHealthAnalyticsCustomModule -from google.cloud.securitycentermanagement_v1.types.security_center_management import SimulatedFinding -from google.cloud.securitycentermanagement_v1.types.security_center_management import SimulateSecurityHealthAnalyticsCustomModuleRequest -from google.cloud.securitycentermanagement_v1.types.security_center_management import SimulateSecurityHealthAnalyticsCustomModuleResponse -from google.cloud.securitycentermanagement_v1.types.security_center_management import UpdateEventThreatDetectionCustomModuleRequest -from google.cloud.securitycentermanagement_v1.types.security_center_management import UpdateSecurityHealthAnalyticsCustomModuleRequest -from google.cloud.securitycentermanagement_v1.types.security_center_management import ValidateEventThreatDetectionCustomModuleRequest -from google.cloud.securitycentermanagement_v1.types.security_center_management import ValidateEventThreatDetectionCustomModuleResponse - -__all__ = ('SecurityCenterManagementClient', - 'SecurityCenterManagementAsyncClient', - 'CreateEventThreatDetectionCustomModuleRequest', - 'CreateSecurityHealthAnalyticsCustomModuleRequest', - 'CustomConfig', - 'DeleteEventThreatDetectionCustomModuleRequest', - 'DeleteSecurityHealthAnalyticsCustomModuleRequest', - 'EffectiveEventThreatDetectionCustomModule', - 'EffectiveSecurityHealthAnalyticsCustomModule', - 'EventThreatDetectionCustomModule', - 'GetEffectiveEventThreatDetectionCustomModuleRequest', - 'GetEffectiveSecurityHealthAnalyticsCustomModuleRequest', - 'GetEventThreatDetectionCustomModuleRequest', - 'GetSecurityHealthAnalyticsCustomModuleRequest', - 'ListDescendantEventThreatDetectionCustomModulesRequest', - 'ListDescendantEventThreatDetectionCustomModulesResponse', - 'ListDescendantSecurityHealthAnalyticsCustomModulesRequest', - 'ListDescendantSecurityHealthAnalyticsCustomModulesResponse', - 'ListEffectiveEventThreatDetectionCustomModulesRequest', - 'ListEffectiveEventThreatDetectionCustomModulesResponse', - 'ListEffectiveSecurityHealthAnalyticsCustomModulesRequest', - 'ListEffectiveSecurityHealthAnalyticsCustomModulesResponse', - 'ListEventThreatDetectionCustomModulesRequest', - 'ListEventThreatDetectionCustomModulesResponse', - 'ListSecurityHealthAnalyticsCustomModulesRequest', - 'ListSecurityHealthAnalyticsCustomModulesResponse', - 'SecurityHealthAnalyticsCustomModule', - 'SimulatedFinding', - 'SimulateSecurityHealthAnalyticsCustomModuleRequest', - 'SimulateSecurityHealthAnalyticsCustomModuleResponse', - 'UpdateEventThreatDetectionCustomModuleRequest', - 'UpdateSecurityHealthAnalyticsCustomModuleRequest', - 'ValidateEventThreatDetectionCustomModuleRequest', - 'ValidateEventThreatDetectionCustomModuleResponse', -) diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement/gapic_version.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement/gapic_version.py deleted file mode 100644 index 360a0d13ebdd..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement/gapic_version.py +++ /dev/null @@ -1,16 +0,0 @@ -# -*- 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. -# -__version__ = "0.0.0" # {x-release-please-version} diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement/py.typed b/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement/py.typed deleted file mode 100644 index 6303193f649f..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement/py.typed +++ /dev/null @@ -1,2 +0,0 @@ -# Marker file for PEP 561. -# The google-cloud-securitycentermanagement package uses inline types. diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/__init__.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/__init__.py deleted file mode 100644 index 8055dca9ed4c..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/__init__.py +++ /dev/null @@ -1,92 +0,0 @@ -# -*- 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. -# -from google.cloud.securitycentermanagement_v1 import gapic_version as package_version - -__version__ = package_version.__version__ - - -from .services.security_center_management import SecurityCenterManagementClient -from .services.security_center_management import SecurityCenterManagementAsyncClient - -from .types.security_center_management import CreateEventThreatDetectionCustomModuleRequest -from .types.security_center_management import CreateSecurityHealthAnalyticsCustomModuleRequest -from .types.security_center_management import CustomConfig -from .types.security_center_management import DeleteEventThreatDetectionCustomModuleRequest -from .types.security_center_management import DeleteSecurityHealthAnalyticsCustomModuleRequest -from .types.security_center_management import EffectiveEventThreatDetectionCustomModule -from .types.security_center_management import EffectiveSecurityHealthAnalyticsCustomModule -from .types.security_center_management import EventThreatDetectionCustomModule -from .types.security_center_management import GetEffectiveEventThreatDetectionCustomModuleRequest -from .types.security_center_management import GetEffectiveSecurityHealthAnalyticsCustomModuleRequest -from .types.security_center_management import GetEventThreatDetectionCustomModuleRequest -from .types.security_center_management import GetSecurityHealthAnalyticsCustomModuleRequest -from .types.security_center_management import ListDescendantEventThreatDetectionCustomModulesRequest -from .types.security_center_management import ListDescendantEventThreatDetectionCustomModulesResponse -from .types.security_center_management import ListDescendantSecurityHealthAnalyticsCustomModulesRequest -from .types.security_center_management import ListDescendantSecurityHealthAnalyticsCustomModulesResponse -from .types.security_center_management import ListEffectiveEventThreatDetectionCustomModulesRequest -from .types.security_center_management import ListEffectiveEventThreatDetectionCustomModulesResponse -from .types.security_center_management import ListEffectiveSecurityHealthAnalyticsCustomModulesRequest -from .types.security_center_management import ListEffectiveSecurityHealthAnalyticsCustomModulesResponse -from .types.security_center_management import ListEventThreatDetectionCustomModulesRequest -from .types.security_center_management import ListEventThreatDetectionCustomModulesResponse -from .types.security_center_management import ListSecurityHealthAnalyticsCustomModulesRequest -from .types.security_center_management import ListSecurityHealthAnalyticsCustomModulesResponse -from .types.security_center_management import SecurityHealthAnalyticsCustomModule -from .types.security_center_management import SimulatedFinding -from .types.security_center_management import SimulateSecurityHealthAnalyticsCustomModuleRequest -from .types.security_center_management import SimulateSecurityHealthAnalyticsCustomModuleResponse -from .types.security_center_management import UpdateEventThreatDetectionCustomModuleRequest -from .types.security_center_management import UpdateSecurityHealthAnalyticsCustomModuleRequest -from .types.security_center_management import ValidateEventThreatDetectionCustomModuleRequest -from .types.security_center_management import ValidateEventThreatDetectionCustomModuleResponse - -__all__ = ( - 'SecurityCenterManagementAsyncClient', -'CreateEventThreatDetectionCustomModuleRequest', -'CreateSecurityHealthAnalyticsCustomModuleRequest', -'CustomConfig', -'DeleteEventThreatDetectionCustomModuleRequest', -'DeleteSecurityHealthAnalyticsCustomModuleRequest', -'EffectiveEventThreatDetectionCustomModule', -'EffectiveSecurityHealthAnalyticsCustomModule', -'EventThreatDetectionCustomModule', -'GetEffectiveEventThreatDetectionCustomModuleRequest', -'GetEffectiveSecurityHealthAnalyticsCustomModuleRequest', -'GetEventThreatDetectionCustomModuleRequest', -'GetSecurityHealthAnalyticsCustomModuleRequest', -'ListDescendantEventThreatDetectionCustomModulesRequest', -'ListDescendantEventThreatDetectionCustomModulesResponse', -'ListDescendantSecurityHealthAnalyticsCustomModulesRequest', -'ListDescendantSecurityHealthAnalyticsCustomModulesResponse', -'ListEffectiveEventThreatDetectionCustomModulesRequest', -'ListEffectiveEventThreatDetectionCustomModulesResponse', -'ListEffectiveSecurityHealthAnalyticsCustomModulesRequest', -'ListEffectiveSecurityHealthAnalyticsCustomModulesResponse', -'ListEventThreatDetectionCustomModulesRequest', -'ListEventThreatDetectionCustomModulesResponse', -'ListSecurityHealthAnalyticsCustomModulesRequest', -'ListSecurityHealthAnalyticsCustomModulesResponse', -'SecurityCenterManagementClient', -'SecurityHealthAnalyticsCustomModule', -'SimulateSecurityHealthAnalyticsCustomModuleRequest', -'SimulateSecurityHealthAnalyticsCustomModuleResponse', -'SimulatedFinding', -'UpdateEventThreatDetectionCustomModuleRequest', -'UpdateSecurityHealthAnalyticsCustomModuleRequest', -'ValidateEventThreatDetectionCustomModuleRequest', -'ValidateEventThreatDetectionCustomModuleResponse', -) diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/gapic_metadata.json b/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/gapic_metadata.json deleted file mode 100644 index bc19f51f6a72..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/gapic_metadata.json +++ /dev/null @@ -1,298 +0,0 @@ - { - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "python", - "libraryPackage": "google.cloud.securitycentermanagement_v1", - "protoPackage": "google.cloud.securitycentermanagement.v1", - "schema": "1.0", - "services": { - "SecurityCenterManagement": { - "clients": { - "grpc": { - "libraryClient": "SecurityCenterManagementClient", - "rpcs": { - "CreateEventThreatDetectionCustomModule": { - "methods": [ - "create_event_threat_detection_custom_module" - ] - }, - "CreateSecurityHealthAnalyticsCustomModule": { - "methods": [ - "create_security_health_analytics_custom_module" - ] - }, - "DeleteEventThreatDetectionCustomModule": { - "methods": [ - "delete_event_threat_detection_custom_module" - ] - }, - "DeleteSecurityHealthAnalyticsCustomModule": { - "methods": [ - "delete_security_health_analytics_custom_module" - ] - }, - "GetEffectiveEventThreatDetectionCustomModule": { - "methods": [ - "get_effective_event_threat_detection_custom_module" - ] - }, - "GetEffectiveSecurityHealthAnalyticsCustomModule": { - "methods": [ - "get_effective_security_health_analytics_custom_module" - ] - }, - "GetEventThreatDetectionCustomModule": { - "methods": [ - "get_event_threat_detection_custom_module" - ] - }, - "GetSecurityHealthAnalyticsCustomModule": { - "methods": [ - "get_security_health_analytics_custom_module" - ] - }, - "ListDescendantEventThreatDetectionCustomModules": { - "methods": [ - "list_descendant_event_threat_detection_custom_modules" - ] - }, - "ListDescendantSecurityHealthAnalyticsCustomModules": { - "methods": [ - "list_descendant_security_health_analytics_custom_modules" - ] - }, - "ListEffectiveEventThreatDetectionCustomModules": { - "methods": [ - "list_effective_event_threat_detection_custom_modules" - ] - }, - "ListEffectiveSecurityHealthAnalyticsCustomModules": { - "methods": [ - "list_effective_security_health_analytics_custom_modules" - ] - }, - "ListEventThreatDetectionCustomModules": { - "methods": [ - "list_event_threat_detection_custom_modules" - ] - }, - "ListSecurityHealthAnalyticsCustomModules": { - "methods": [ - "list_security_health_analytics_custom_modules" - ] - }, - "SimulateSecurityHealthAnalyticsCustomModule": { - "methods": [ - "simulate_security_health_analytics_custom_module" - ] - }, - "UpdateEventThreatDetectionCustomModule": { - "methods": [ - "update_event_threat_detection_custom_module" - ] - }, - "UpdateSecurityHealthAnalyticsCustomModule": { - "methods": [ - "update_security_health_analytics_custom_module" - ] - }, - "ValidateEventThreatDetectionCustomModule": { - "methods": [ - "validate_event_threat_detection_custom_module" - ] - } - } - }, - "grpc-async": { - "libraryClient": "SecurityCenterManagementAsyncClient", - "rpcs": { - "CreateEventThreatDetectionCustomModule": { - "methods": [ - "create_event_threat_detection_custom_module" - ] - }, - "CreateSecurityHealthAnalyticsCustomModule": { - "methods": [ - "create_security_health_analytics_custom_module" - ] - }, - "DeleteEventThreatDetectionCustomModule": { - "methods": [ - "delete_event_threat_detection_custom_module" - ] - }, - "DeleteSecurityHealthAnalyticsCustomModule": { - "methods": [ - "delete_security_health_analytics_custom_module" - ] - }, - "GetEffectiveEventThreatDetectionCustomModule": { - "methods": [ - "get_effective_event_threat_detection_custom_module" - ] - }, - "GetEffectiveSecurityHealthAnalyticsCustomModule": { - "methods": [ - "get_effective_security_health_analytics_custom_module" - ] - }, - "GetEventThreatDetectionCustomModule": { - "methods": [ - "get_event_threat_detection_custom_module" - ] - }, - "GetSecurityHealthAnalyticsCustomModule": { - "methods": [ - "get_security_health_analytics_custom_module" - ] - }, - "ListDescendantEventThreatDetectionCustomModules": { - "methods": [ - "list_descendant_event_threat_detection_custom_modules" - ] - }, - "ListDescendantSecurityHealthAnalyticsCustomModules": { - "methods": [ - "list_descendant_security_health_analytics_custom_modules" - ] - }, - "ListEffectiveEventThreatDetectionCustomModules": { - "methods": [ - "list_effective_event_threat_detection_custom_modules" - ] - }, - "ListEffectiveSecurityHealthAnalyticsCustomModules": { - "methods": [ - "list_effective_security_health_analytics_custom_modules" - ] - }, - "ListEventThreatDetectionCustomModules": { - "methods": [ - "list_event_threat_detection_custom_modules" - ] - }, - "ListSecurityHealthAnalyticsCustomModules": { - "methods": [ - "list_security_health_analytics_custom_modules" - ] - }, - "SimulateSecurityHealthAnalyticsCustomModule": { - "methods": [ - "simulate_security_health_analytics_custom_module" - ] - }, - "UpdateEventThreatDetectionCustomModule": { - "methods": [ - "update_event_threat_detection_custom_module" - ] - }, - "UpdateSecurityHealthAnalyticsCustomModule": { - "methods": [ - "update_security_health_analytics_custom_module" - ] - }, - "ValidateEventThreatDetectionCustomModule": { - "methods": [ - "validate_event_threat_detection_custom_module" - ] - } - } - }, - "rest": { - "libraryClient": "SecurityCenterManagementClient", - "rpcs": { - "CreateEventThreatDetectionCustomModule": { - "methods": [ - "create_event_threat_detection_custom_module" - ] - }, - "CreateSecurityHealthAnalyticsCustomModule": { - "methods": [ - "create_security_health_analytics_custom_module" - ] - }, - "DeleteEventThreatDetectionCustomModule": { - "methods": [ - "delete_event_threat_detection_custom_module" - ] - }, - "DeleteSecurityHealthAnalyticsCustomModule": { - "methods": [ - "delete_security_health_analytics_custom_module" - ] - }, - "GetEffectiveEventThreatDetectionCustomModule": { - "methods": [ - "get_effective_event_threat_detection_custom_module" - ] - }, - "GetEffectiveSecurityHealthAnalyticsCustomModule": { - "methods": [ - "get_effective_security_health_analytics_custom_module" - ] - }, - "GetEventThreatDetectionCustomModule": { - "methods": [ - "get_event_threat_detection_custom_module" - ] - }, - "GetSecurityHealthAnalyticsCustomModule": { - "methods": [ - "get_security_health_analytics_custom_module" - ] - }, - "ListDescendantEventThreatDetectionCustomModules": { - "methods": [ - "list_descendant_event_threat_detection_custom_modules" - ] - }, - "ListDescendantSecurityHealthAnalyticsCustomModules": { - "methods": [ - "list_descendant_security_health_analytics_custom_modules" - ] - }, - "ListEffectiveEventThreatDetectionCustomModules": { - "methods": [ - "list_effective_event_threat_detection_custom_modules" - ] - }, - "ListEffectiveSecurityHealthAnalyticsCustomModules": { - "methods": [ - "list_effective_security_health_analytics_custom_modules" - ] - }, - "ListEventThreatDetectionCustomModules": { - "methods": [ - "list_event_threat_detection_custom_modules" - ] - }, - "ListSecurityHealthAnalyticsCustomModules": { - "methods": [ - "list_security_health_analytics_custom_modules" - ] - }, - "SimulateSecurityHealthAnalyticsCustomModule": { - "methods": [ - "simulate_security_health_analytics_custom_module" - ] - }, - "UpdateEventThreatDetectionCustomModule": { - "methods": [ - "update_event_threat_detection_custom_module" - ] - }, - "UpdateSecurityHealthAnalyticsCustomModule": { - "methods": [ - "update_security_health_analytics_custom_module" - ] - }, - "ValidateEventThreatDetectionCustomModule": { - "methods": [ - "validate_event_threat_detection_custom_module" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/gapic_version.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/gapic_version.py deleted file mode 100644 index 360a0d13ebdd..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/gapic_version.py +++ /dev/null @@ -1,16 +0,0 @@ -# -*- 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. -# -__version__ = "0.0.0" # {x-release-please-version} diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/py.typed b/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/py.typed deleted file mode 100644 index 6303193f649f..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/py.typed +++ /dev/null @@ -1,2 +0,0 @@ -# Marker file for PEP 561. -# The google-cloud-securitycentermanagement package uses inline types. diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/__init__.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/__init__.py deleted file mode 100644 index 89a37dc92c5a..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -# -*- 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. -# diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/__init__.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/__init__.py deleted file mode 100644 index 2e8ab1204d6a..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/__init__.py +++ /dev/null @@ -1,22 +0,0 @@ -# -*- 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. -# -from .client import SecurityCenterManagementClient -from .async_client import SecurityCenterManagementAsyncClient - -__all__ = ( - 'SecurityCenterManagementClient', - 'SecurityCenterManagementAsyncClient', -) diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/async_client.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/async_client.py deleted file mode 100644 index fcaade62cbd6..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/async_client.py +++ /dev/null @@ -1,2501 +0,0 @@ -# -*- 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. -# -from collections import OrderedDict -import functools -import re -from typing import Dict, Mapping, MutableMapping, MutableSequence, Optional, Sequence, Tuple, Type, Union - -from google.cloud.securitycentermanagement_v1 import gapic_version as package_version - -from google.api_core.client_options import ClientOptions -from google.api_core import exceptions as core_exceptions -from google.api_core import gapic_v1 -from google.api_core import retry_async as retries -from google.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore - -try: - OptionalRetry = Union[retries.AsyncRetry, gapic_v1.method._MethodDefault] -except AttributeError: # pragma: NO COVER - OptionalRetry = Union[retries.AsyncRetry, object] # type: ignore - -from google.cloud.location import locations_pb2 # type: ignore -from google.cloud.securitycentermanagement_v1.services.security_center_management import pagers -from google.cloud.securitycentermanagement_v1.types import security_center_management -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import struct_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore -from .transports.base import SecurityCenterManagementTransport, DEFAULT_CLIENT_INFO -from .transports.grpc_asyncio import SecurityCenterManagementGrpcAsyncIOTransport -from .client import SecurityCenterManagementClient - - -class SecurityCenterManagementAsyncClient: - """Service describing handlers for resources""" - - _client: SecurityCenterManagementClient - - DEFAULT_ENDPOINT = SecurityCenterManagementClient.DEFAULT_ENDPOINT - DEFAULT_MTLS_ENDPOINT = SecurityCenterManagementClient.DEFAULT_MTLS_ENDPOINT - - effective_event_threat_detection_custom_module_path = staticmethod(SecurityCenterManagementClient.effective_event_threat_detection_custom_module_path) - parse_effective_event_threat_detection_custom_module_path = staticmethod(SecurityCenterManagementClient.parse_effective_event_threat_detection_custom_module_path) - effective_security_health_analytics_custom_module_path = staticmethod(SecurityCenterManagementClient.effective_security_health_analytics_custom_module_path) - parse_effective_security_health_analytics_custom_module_path = staticmethod(SecurityCenterManagementClient.parse_effective_security_health_analytics_custom_module_path) - event_threat_detection_custom_module_path = staticmethod(SecurityCenterManagementClient.event_threat_detection_custom_module_path) - parse_event_threat_detection_custom_module_path = staticmethod(SecurityCenterManagementClient.parse_event_threat_detection_custom_module_path) - finding_path = staticmethod(SecurityCenterManagementClient.finding_path) - parse_finding_path = staticmethod(SecurityCenterManagementClient.parse_finding_path) - security_health_analytics_custom_module_path = staticmethod(SecurityCenterManagementClient.security_health_analytics_custom_module_path) - parse_security_health_analytics_custom_module_path = staticmethod(SecurityCenterManagementClient.parse_security_health_analytics_custom_module_path) - common_billing_account_path = staticmethod(SecurityCenterManagementClient.common_billing_account_path) - parse_common_billing_account_path = staticmethod(SecurityCenterManagementClient.parse_common_billing_account_path) - common_folder_path = staticmethod(SecurityCenterManagementClient.common_folder_path) - parse_common_folder_path = staticmethod(SecurityCenterManagementClient.parse_common_folder_path) - common_organization_path = staticmethod(SecurityCenterManagementClient.common_organization_path) - parse_common_organization_path = staticmethod(SecurityCenterManagementClient.parse_common_organization_path) - common_project_path = staticmethod(SecurityCenterManagementClient.common_project_path) - parse_common_project_path = staticmethod(SecurityCenterManagementClient.parse_common_project_path) - common_location_path = staticmethod(SecurityCenterManagementClient.common_location_path) - parse_common_location_path = staticmethod(SecurityCenterManagementClient.parse_common_location_path) - - @classmethod - def from_service_account_info(cls, info: dict, *args, **kwargs): - """Creates an instance of this client using the provided credentials - info. - - Args: - info (dict): The service account private key info. - args: Additional arguments to pass to the constructor. - kwargs: Additional arguments to pass to the constructor. - - Returns: - SecurityCenterManagementAsyncClient: The constructed client. - """ - return SecurityCenterManagementClient.from_service_account_info.__func__(SecurityCenterManagementAsyncClient, info, *args, **kwargs) # type: ignore - - @classmethod - def from_service_account_file(cls, filename: str, *args, **kwargs): - """Creates an instance of this client using the provided credentials - file. - - Args: - filename (str): The path to the service account private key json - file. - args: Additional arguments to pass to the constructor. - kwargs: Additional arguments to pass to the constructor. - - Returns: - SecurityCenterManagementAsyncClient: The constructed client. - """ - return SecurityCenterManagementClient.from_service_account_file.__func__(SecurityCenterManagementAsyncClient, filename, *args, **kwargs) # type: ignore - - from_service_account_json = from_service_account_file - - @classmethod - def get_mtls_endpoint_and_cert_source(cls, client_options: Optional[ClientOptions] = None): - """Return the API endpoint and client cert source for mutual TLS. - - The client cert source is determined in the following order: - (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the - client cert source is None. - (2) if `client_options.client_cert_source` is provided, use the provided one; if the - default client cert source exists, use the default one; otherwise the client cert - source is None. - - The API endpoint is determined in the following order: - (1) if `client_options.api_endpoint` if provided, use the provided one. - (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the - default mTLS endpoint; if the environment variable is "never", use the default API - endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise - use the default API endpoint. - - More details can be found at https://google.aip.dev/auth/4114. - - Args: - client_options (google.api_core.client_options.ClientOptions): Custom options for the - client. Only the `api_endpoint` and `client_cert_source` properties may be used - in this method. - - Returns: - Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the - client cert source to use. - - Raises: - google.auth.exceptions.MutualTLSChannelError: If any errors happen. - """ - return SecurityCenterManagementClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore - - @property - def transport(self) -> SecurityCenterManagementTransport: - """Returns the transport used by the client instance. - - Returns: - SecurityCenterManagementTransport: The transport used by the client instance. - """ - return self._client.transport - - get_transport_class = functools.partial(type(SecurityCenterManagementClient).get_transport_class, type(SecurityCenterManagementClient)) - - def __init__(self, *, - credentials: Optional[ga_credentials.Credentials] = None, - transport: Union[str, SecurityCenterManagementTransport] = "grpc_asyncio", - client_options: Optional[ClientOptions] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the security center management client. - - Args: - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - transport (Union[str, ~.SecurityCenterManagementTransport]): The - transport to use. If set to None, a transport is chosen - automatically. - client_options (ClientOptions): Custom options for the client. It - won't take effect if a ``transport`` instance is provided. - (1) The ``api_endpoint`` property can be used to override the - default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT - environment variable can also be used to override the endpoint: - "always" (always use the default mTLS endpoint), "never" (always - use the default regular endpoint) and "auto" (auto switch to the - default mTLS endpoint if client certificate is present, this is - the default value). However, the ``api_endpoint`` property takes - precedence if provided. - (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable - is "true", then the ``client_cert_source`` property can be used - to provide client certificate for mutual TLS transport. If - not provided, the default SSL client certificate will be used if - present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not - set, no client certificate will be used. - - Raises: - google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport - creation failed for any reason. - """ - self._client = SecurityCenterManagementClient( - credentials=credentials, - transport=transport, - client_options=client_options, - client_info=client_info, - - ) - - async def list_effective_security_health_analytics_custom_modules(self, - request: Optional[Union[security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest, 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.ListEffectiveSecurityHealthAnalyticsCustomModulesAsyncPager: - r"""Returns a list of all - EffectiveSecurityHealthAnalyticsCustomModules for the - given parent. This includes resident modules defined at - the scope of the parent, and inherited modules, - inherited from CRM ancestors (no descendants). - - .. 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 securitycentermanagement_v1 - - async def sample_list_effective_security_health_analytics_custom_modules(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_effective_security_health_analytics_custom_modules(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.securitycentermanagement_v1.types.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest, dict]]): - The request object. Request message for listing effective - Security Health Analytics custom - modules. - parent (:class:`str`): - Required. Name of parent to list - effective custom modules. Its format is - "organizations/{organization}/locations/{location}", - "folders/{folder}/locations/{location}", - or - "projects/{project}/locations/{location}" - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): 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.securitycentermanagement_v1.services.security_center_management.pagers.ListEffectiveSecurityHealthAnalyticsCustomModulesAsyncPager: - Response message for listing - effective Security Health Analytics - custom modules. - - 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 = security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest(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_effective_security_health_analytics_custom_modules, - default_retry=retries.AsyncRetry( -initial=0.1,maximum=60.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.DeadlineExceeded, - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - 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.ListEffectiveSecurityHealthAnalyticsCustomModulesAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_effective_security_health_analytics_custom_module(self, - request: Optional[Union[security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest, 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]] = (), - ) -> security_center_management.EffectiveSecurityHealthAnalyticsCustomModule: - r"""Gets details of a single - EffectiveSecurityHealthAnalyticsCustomModule. - - .. 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 securitycentermanagement_v1 - - async def sample_get_effective_security_health_analytics_custom_module(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest( - name="name_value", - ) - - # Make the request - response = await client.get_effective_security_health_analytics_custom_module(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.securitycentermanagement_v1.types.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest, dict]]): - The request object. Message for getting a - EffectiveSecurityHealthAnalyticsCustomModule - name (:class:`str`): - Required. The resource name of the SHA custom module. - - Its format is: - - - "organizations/{organization}/locations/{location}/effectiveSecurityHealthAnalyticsCustomModules/{module_id}". - - "folders/{folder}/locations/{location}/effectiveSecurityHealthAnalyticsCustomModules/{module_id}". - - "projects/{project}/locations/{location}/effectiveSecurityHealthAnalyticsCustomModules/{module_id}". - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): 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.securitycentermanagement_v1.types.EffectiveSecurityHealthAnalyticsCustomModule: - An EffectiveSecurityHealthAnalyticsCustomModule is the representation of - a Security Health Analytics custom module at a - specified level of the resource hierarchy: - organization, folder, or project. If a custom module - is inherited from a parent organization or folder, - the value of the enablementState property in - EffectiveSecurityHealthAnalyticsCustomModule is set - to the value that is effective in the parent, instead - of INHERITED. For example, if the module is enabled - in a parent organization or folder, the effective - enablement_state for the module in all child folders - or projects is also enabled. - EffectiveSecurityHealthAnalyticsCustomModule is - read-only. - - """ - # 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 = security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest(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_effective_security_health_analytics_custom_module, - default_retry=retries.AsyncRetry( -initial=0.1,maximum=60.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.DeadlineExceeded, - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - 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 list_security_health_analytics_custom_modules(self, - request: Optional[Union[security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest, 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.ListSecurityHealthAnalyticsCustomModulesAsyncPager: - r"""Returns a list of all - SecurityHealthAnalyticsCustomModules for the given - parent. This includes resident modules defined at the - scope of the parent, and inherited modules, inherited - from CRM ancestors (no descendants). - - .. 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 securitycentermanagement_v1 - - async def sample_list_security_health_analytics_custom_modules(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.ListSecurityHealthAnalyticsCustomModulesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_security_health_analytics_custom_modules(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.securitycentermanagement_v1.types.ListSecurityHealthAnalyticsCustomModulesRequest, dict]]): - The request object. Request message for listing Security - Health Analytics custom modules. - parent (:class:`str`): - Required. Name of parent to list - custom modules. Its format is - "organizations/{organization}/locations/{location}", - "folders/{folder}/locations/{location}", - or - "projects/{project}/locations/{location}" - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): 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.securitycentermanagement_v1.services.security_center_management.pagers.ListSecurityHealthAnalyticsCustomModulesAsyncPager: - Response message for listing Security - Health Analytics custom modules. - 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 = security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest(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_security_health_analytics_custom_modules, - default_retry=retries.AsyncRetry( -initial=0.1,maximum=60.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.DeadlineExceeded, - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - 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.ListSecurityHealthAnalyticsCustomModulesAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def list_descendant_security_health_analytics_custom_modules(self, - request: Optional[Union[security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest, 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.ListDescendantSecurityHealthAnalyticsCustomModulesAsyncPager: - r"""Returns a list of all resident - SecurityHealthAnalyticsCustomModules under the given CRM - parent and all of the parent’s CRM descendants. - - .. 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 securitycentermanagement_v1 - - async def sample_list_descendant_security_health_analytics_custom_modules(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.ListDescendantSecurityHealthAnalyticsCustomModulesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_descendant_security_health_analytics_custom_modules(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.securitycentermanagement_v1.types.ListDescendantSecurityHealthAnalyticsCustomModulesRequest, dict]]): - The request object. Request message for listing - descendant Security Health Analytics - custom modules. - parent (:class:`str`): - Required. Name of parent to list - custom modules. Its format is - "organizations/{organization}/locations/{location}", - "folders/{folder}/locations/{location}", - or - "projects/{project}/locations/{location}" - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): 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.securitycentermanagement_v1.services.security_center_management.pagers.ListDescendantSecurityHealthAnalyticsCustomModulesAsyncPager: - Response message for listing - descendant Security Health Analytics - custom modules. - - 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 = security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest(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_descendant_security_health_analytics_custom_modules, - default_retry=retries.AsyncRetry( -initial=0.1,maximum=60.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.DeadlineExceeded, - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - 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.ListDescendantSecurityHealthAnalyticsCustomModulesAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_security_health_analytics_custom_module(self, - request: Optional[Union[security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest, 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]] = (), - ) -> security_center_management.SecurityHealthAnalyticsCustomModule: - r"""Retrieves a SecurityHealthAnalyticsCustomModule. - - .. 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 securitycentermanagement_v1 - - async def sample_get_security_health_analytics_custom_module(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.GetSecurityHealthAnalyticsCustomModuleRequest( - name="name_value", - ) - - # Make the request - response = await client.get_security_health_analytics_custom_module(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.securitycentermanagement_v1.types.GetSecurityHealthAnalyticsCustomModuleRequest, dict]]): - The request object. Message for getting a - SecurityHealthAnalyticsCustomModule - name (:class:`str`): - Required. Name of the resource - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): 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.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule: - Represents an instance of a Security - Health Analytics custom module, - including its full module name, display - name, enablement state, and last updated - time. You can create a custom module at - the organization, folder, or project - level. Custom modules that you create at - the organization or folder level are - inherited by the child folders and - projects. - - """ - # 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 = security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest(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_security_health_analytics_custom_module, - default_retry=retries.AsyncRetry( -initial=0.1,maximum=60.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.DeadlineExceeded, - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - 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 create_security_health_analytics_custom_module(self, - request: Optional[Union[security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest, dict]] = None, - *, - parent: Optional[str] = None, - security_health_analytics_custom_module: Optional[security_center_management.SecurityHealthAnalyticsCustomModule] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> security_center_management.SecurityHealthAnalyticsCustomModule: - r"""Creates a resident - SecurityHealthAnalyticsCustomModule at the scope of the - given CRM parent, and also creates inherited - SecurityHealthAnalyticsCustomModules for all CRM - descendants of the given parent. These modules are - enabled by default. - - .. 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 securitycentermanagement_v1 - - async def sample_create_security_health_analytics_custom_module(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.CreateSecurityHealthAnalyticsCustomModuleRequest( - parent="parent_value", - ) - - # Make the request - response = await client.create_security_health_analytics_custom_module(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.securitycentermanagement_v1.types.CreateSecurityHealthAnalyticsCustomModuleRequest, dict]]): - The request object. Message for creating a - SecurityHealthAnalyticsCustomModule - parent (:class:`str`): - Required. Name of the parent for the - module. Its format is - "organizations/{organization}/locations/{location}", - "folders/{folder}/locations/{location}", - or - "projects/{project}/locations/{location}" - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - security_health_analytics_custom_module (:class:`google.cloud.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule`): - Required. The resource being created - This corresponds to the ``security_health_analytics_custom_module`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): 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.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule: - Represents an instance of a Security - Health Analytics custom module, - including its full module name, display - name, enablement state, and last updated - time. You can create a custom module at - the organization, folder, or project - level. Custom modules that you create at - the organization or folder level are - inherited by the child folders and - projects. - - """ - # 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, security_health_analytics_custom_module]) - 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 = security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if security_health_analytics_custom_module is not None: - request.security_health_analytics_custom_module = security_health_analytics_custom_module - - # 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_security_health_analytics_custom_module, - default_timeout=60.0, - 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 update_security_health_analytics_custom_module(self, - request: Optional[Union[security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest, dict]] = None, - *, - security_health_analytics_custom_module: Optional[security_center_management.SecurityHealthAnalyticsCustomModule] = 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]] = (), - ) -> security_center_management.SecurityHealthAnalyticsCustomModule: - r"""Updates the SecurityHealthAnalyticsCustomModule under - the given name based on the given update mask. Updating - the enablement state is supported on both resident and - inherited modules (though resident modules cannot have - an enablement state of "inherited"). Updating the - display name and custom config of a module is supported - on resident modules only. - - .. 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 securitycentermanagement_v1 - - async def sample_update_security_health_analytics_custom_module(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.UpdateSecurityHealthAnalyticsCustomModuleRequest( - ) - - # Make the request - response = await client.update_security_health_analytics_custom_module(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.securitycentermanagement_v1.types.UpdateSecurityHealthAnalyticsCustomModuleRequest, dict]]): - The request object. Message for updating a - SecurityHealthAnalyticsCustomModule - security_health_analytics_custom_module (:class:`google.cloud.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule`): - Required. The resource being updated - This corresponds to the ``security_health_analytics_custom_module`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - Required. Field mask is used to specify the fields to be - overwritten in the SecurityHealthAnalyticsCustomModule - resource by the update. The fields specified in the - update_mask are relative to the resource, not the full - request. A field will be overwritten if it is in the - mask. If the user does not provide a mask then all - fields will be overwritten. - - 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_async.AsyncRetry): 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.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule: - Represents an instance of a Security - Health Analytics custom module, - including its full module name, display - name, enablement state, and last updated - time. You can create a custom module at - the organization, folder, or project - level. Custom modules that you create at - the organization or folder level are - inherited by the child folders and - projects. - - """ - # 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([security_health_analytics_custom_module, 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 = security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if security_health_analytics_custom_module is not None: - request.security_health_analytics_custom_module = security_health_analytics_custom_module - 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_security_health_analytics_custom_module, - default_timeout=60.0, - 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(( - ("security_health_analytics_custom_module.name", request.security_health_analytics_custom_module.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def delete_security_health_analytics_custom_module(self, - request: Optional[Union[security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest, 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 - SecurityHealthAnalyticsCustomModule and all of its - descendants in the CRM hierarchy. This method is only - supported for resident custom modules. - - .. 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 securitycentermanagement_v1 - - async def sample_delete_security_health_analytics_custom_module(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.DeleteSecurityHealthAnalyticsCustomModuleRequest( - name="name_value", - ) - - # Make the request - await client.delete_security_health_analytics_custom_module(request=request) - - Args: - request (Optional[Union[google.cloud.securitycentermanagement_v1.types.DeleteSecurityHealthAnalyticsCustomModuleRequest, dict]]): - The request object. Message for deleting a - SecurityHealthAnalyticsCustomModule - name (:class:`str`): - Required. The resource name of the SHA custom module. - - Its format is: - - - "organizations/{organization}/locations/{location}/securityHealthAnalyticsCustomModules/{security_health_analytics_custom_module}". - - "folders/{folder}/locations/{location}/securityHealthAnalyticsCustomModules/{security_health_analytics_custom_module}". - - "projects/{project}/locations/{location}/securityHealthAnalyticsCustomModules/{security_health_analytics_custom_module}". - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): 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 = security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest(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_security_health_analytics_custom_module, - default_timeout=60.0, - 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 simulate_security_health_analytics_custom_module(self, - request: Optional[Union[security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest, dict]] = None, - *, - parent: Optional[str] = None, - custom_config: Optional[security_center_management.CustomConfig] = None, - resource: Optional[security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest.SimulatedResource] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse: - r"""Simulates a given SecurityHealthAnalyticsCustomModule - and Resource. - - .. 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 securitycentermanagement_v1 - - async def sample_simulate_security_health_analytics_custom_module(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() - - # Initialize request argument(s) - resource = securitycentermanagement_v1.SimulatedResource() - resource.resource_type = "resource_type_value" - - request = securitycentermanagement_v1.SimulateSecurityHealthAnalyticsCustomModuleRequest( - parent="parent_value", - resource=resource, - ) - - # Make the request - response = await client.simulate_security_health_analytics_custom_module(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.securitycentermanagement_v1.types.SimulateSecurityHealthAnalyticsCustomModuleRequest, dict]]): - The request object. Request message to simulate a - CustomConfig against a given test - resource. Maximum size of the request is - 4 MB by default. - parent (:class:`str`): - Required. The relative resource name of the - organization, project, or folder. For more information - about relative resource names, see `Relative Resource - Name `__ - Example: ``organizations/{organization_id}``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - custom_config (:class:`google.cloud.securitycentermanagement_v1.types.CustomConfig`): - Required. The custom configuration - that you need to test. - - This corresponds to the ``custom_config`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - resource (:class:`google.cloud.securitycentermanagement_v1.types.SimulateSecurityHealthAnalyticsCustomModuleRequest.SimulatedResource`): - Required. Resource data to simulate - custom module against. - - This corresponds to the ``resource`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): 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.securitycentermanagement_v1.types.SimulateSecurityHealthAnalyticsCustomModuleResponse: - Response message for simulating a SecurityHealthAnalyticsCustomModule - against a given resource. - - """ - # 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, custom_config, resource]) - 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 = security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if custom_config is not None: - request.custom_config = custom_config - if resource is not None: - request.resource = resource - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.simulate_security_health_analytics_custom_module, - default_retry=retries.AsyncRetry( -initial=0.1,maximum=60.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.DeadlineExceeded, - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - 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_effective_event_threat_detection_custom_modules(self, - request: Optional[Union[security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest, 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.ListEffectiveEventThreatDetectionCustomModulesAsyncPager: - r"""Lists all effective Event Threat Detection custom - modules for the given parent. This includes resident - modules defined at the scope of the parent along with - modules inherited from its ancestors. - - .. 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 securitycentermanagement_v1 - - async def sample_list_effective_event_threat_detection_custom_modules(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.ListEffectiveEventThreatDetectionCustomModulesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_effective_event_threat_detection_custom_modules(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.securitycentermanagement_v1.types.ListEffectiveEventThreatDetectionCustomModulesRequest, dict]]): - The request object. Request message for listing effective - Event Threat Detection custom modules. - parent (:class:`str`): - Required. Name of parent to list - effective custom modules. Its format is - "organizations/{organization}/locations/{location}", - "folders/{folder}/locations/{location}", - or - "projects/{project}/locations/{location}" - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): 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.securitycentermanagement_v1.services.security_center_management.pagers.ListEffectiveEventThreatDetectionCustomModulesAsyncPager: - Response message for listing - effective Event Threat Detection custom - modules. - - 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 = security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest(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_effective_event_threat_detection_custom_modules, - default_retry=retries.AsyncRetry( -initial=0.1,maximum=60.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.DeadlineExceeded, - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - 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.ListEffectiveEventThreatDetectionCustomModulesAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_effective_event_threat_detection_custom_module(self, - request: Optional[Union[security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest, 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]] = (), - ) -> security_center_management.EffectiveEventThreatDetectionCustomModule: - r"""Gets an effective ETD custom module. Retrieves the effective - module at the given level. The difference between an - EffectiveCustomModule and a CustomModule is that the fields for - an EffectiveCustomModule are computed from ancestors if needed. - For example, the enablement_state for a CustomModule can be - either ENABLED, DISABLED, or INHERITED. Where as the - enablement_state for an EffectiveCustomModule is always computed - to ENABLED or DISABLED (the effective enablement_state). - - .. 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 securitycentermanagement_v1 - - async def sample_get_effective_event_threat_detection_custom_module(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.GetEffectiveEventThreatDetectionCustomModuleRequest( - name="name_value", - ) - - # Make the request - response = await client.get_effective_event_threat_detection_custom_module(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.securitycentermanagement_v1.types.GetEffectiveEventThreatDetectionCustomModuleRequest, dict]]): - The request object. Message for getting a - EffectiveEventThreatDetectionCustomModule - name (:class:`str`): - Required. The resource name of the ETD custom module. - - Its format is: - - - "organizations/{organization}/locations/{location}/effectiveEventThreatDetectionCustomModules/{effective_event_threat_detection_custom_module}". - - "folders/{folder}/locations/{location}/effectiveEventThreatDetectionCustomModules/{effective_event_threat_detection_custom_module}". - - "projects/{project}/locations/{location}/effectiveEventThreatDetectionCustomModules/{effective_event_threat_detection_custom_module}". - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): 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.securitycentermanagement_v1.types.EffectiveEventThreatDetectionCustomModule: - An EffectiveEventThreatDetectionCustomModule is the representation of - EventThreatDetectionCustomModule at a given level - taking hierarchy into account and resolving various - fields accordingly. e.g. if the module is enabled at - the ancestor level, effective modules at all - descendant levels will have enablement_state set to - ENABLED. Similarly, if module.inherited is set, then - effective module's config will contain the ancestor's - config details. - EffectiveEventThreatDetectionCustomModule is - read-only. - - """ - # 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 = security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest(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_effective_event_threat_detection_custom_module, - default_retry=retries.AsyncRetry( -initial=0.1,maximum=60.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.DeadlineExceeded, - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - 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 list_event_threat_detection_custom_modules(self, - request: Optional[Union[security_center_management.ListEventThreatDetectionCustomModulesRequest, 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.ListEventThreatDetectionCustomModulesAsyncPager: - r"""Lists all Event Threat Detection custom modules for - the given Resource Manager parent. This includes - resident modules defined at the scope of the parent - along with modules inherited from ancestors. - - .. 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 securitycentermanagement_v1 - - async def sample_list_event_threat_detection_custom_modules(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.ListEventThreatDetectionCustomModulesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_event_threat_detection_custom_modules(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.securitycentermanagement_v1.types.ListEventThreatDetectionCustomModulesRequest, dict]]): - The request object. Request message for listing Event - Threat Detection custom modules. - parent (:class:`str`): - Required. Name of parent to list - custom modules. Its format is - "organizations/{organization}/locations/{location}", - "folders/{folder}/locations/{location}", - or - "projects/{project}/locations/{location}" - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): 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.securitycentermanagement_v1.services.security_center_management.pagers.ListEventThreatDetectionCustomModulesAsyncPager: - Response message for listing Event - Threat Detection custom modules. - 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 = security_center_management.ListEventThreatDetectionCustomModulesRequest(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_event_threat_detection_custom_modules, - default_retry=retries.AsyncRetry( -initial=0.1,maximum=60.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.DeadlineExceeded, - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - 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.ListEventThreatDetectionCustomModulesAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def list_descendant_event_threat_detection_custom_modules(self, - request: Optional[Union[security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest, 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.ListDescendantEventThreatDetectionCustomModulesAsyncPager: - r"""Lists all resident Event Threat Detection custom - modules under the given Resource Manager parent and its - descendants. - - .. 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 securitycentermanagement_v1 - - async def sample_list_descendant_event_threat_detection_custom_modules(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.ListDescendantEventThreatDetectionCustomModulesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_descendant_event_threat_detection_custom_modules(request=request) - - # Handle the response - async for response in page_result: - print(response) - - Args: - request (Optional[Union[google.cloud.securitycentermanagement_v1.types.ListDescendantEventThreatDetectionCustomModulesRequest, dict]]): - The request object. Request message for listing - descendant Event Threat Detection custom - modules. - parent (:class:`str`): - Required. Name of parent to list - custom modules. Its format is - "organizations/{organization}/locations/{location}", - "folders/{folder}/locations/{location}", - or - "projects/{project}/locations/{location}" - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): 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.securitycentermanagement_v1.services.security_center_management.pagers.ListDescendantEventThreatDetectionCustomModulesAsyncPager: - Response message for listing - descendant Event Threat Detection custom - modules. - - 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 = security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest(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_descendant_event_threat_detection_custom_modules, - default_retry=retries.AsyncRetry( -initial=0.1,maximum=60.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.DeadlineExceeded, - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - 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.ListDescendantEventThreatDetectionCustomModulesAsyncPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def get_event_threat_detection_custom_module(self, - request: Optional[Union[security_center_management.GetEventThreatDetectionCustomModuleRequest, 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]] = (), - ) -> security_center_management.EventThreatDetectionCustomModule: - r"""Gets an Event Threat Detection custom module. - - .. 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 securitycentermanagement_v1 - - async def sample_get_event_threat_detection_custom_module(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.GetEventThreatDetectionCustomModuleRequest( - name="name_value", - ) - - # Make the request - response = await client.get_event_threat_detection_custom_module(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.securitycentermanagement_v1.types.GetEventThreatDetectionCustomModuleRequest, dict]]): - The request object. Message for getting a - EventThreatDetectionCustomModule - name (:class:`str`): - Required. The resource name of the ETD custom module. - - Its format is: - - - "organizations/{organization}/locations/{location}/eventThreatDetectionCustomModules/{event_threat_detection_custom_module}". - - "folders/{folder}/locations/{location}/eventThreatDetectionCustomModules/{event_threat_detection_custom_module}". - - "projects/{project}/locations/{location}/eventThreatDetectionCustomModules/{event_threat_detection_custom_module}". - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): 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.securitycentermanagement_v1.types.EventThreatDetectionCustomModule: - An event threat detection custom - module is a Cloud SCC resource that - contains the configuration and - enablement state of a custom module, - which enables ETD to write certain - findings to Cloud SCC. - - """ - # 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 = security_center_management.GetEventThreatDetectionCustomModuleRequest(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_event_threat_detection_custom_module, - default_retry=retries.AsyncRetry( -initial=0.1,maximum=60.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.DeadlineExceeded, - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - 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 create_event_threat_detection_custom_module(self, - request: Optional[Union[security_center_management.CreateEventThreatDetectionCustomModuleRequest, dict]] = None, - *, - parent: Optional[str] = None, - event_threat_detection_custom_module: Optional[security_center_management.EventThreatDetectionCustomModule] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> security_center_management.EventThreatDetectionCustomModule: - r"""Creates a resident Event Threat Detection custom - module at the scope of the given Resource Manager - parent, and also creates inherited custom modules for - all descendants of the given parent. These modules are - enabled by default. - - .. 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 securitycentermanagement_v1 - - async def sample_create_event_threat_detection_custom_module(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.CreateEventThreatDetectionCustomModuleRequest( - parent="parent_value", - ) - - # Make the request - response = await client.create_event_threat_detection_custom_module(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.securitycentermanagement_v1.types.CreateEventThreatDetectionCustomModuleRequest, dict]]): - The request object. Message for creating a - EventThreatDetectionCustomModule - parent (:class:`str`): - Required. Name of parent for the - module. Its format is - "organizations/{organization}/locations/{location}", - "folders/{folder}/locations/{location}", - or - "projects/{project}/locations/{location}" - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - event_threat_detection_custom_module (:class:`google.cloud.securitycentermanagement_v1.types.EventThreatDetectionCustomModule`): - Required. The module to create. The - event_threat_detection_custom_module.name will be - ignored and server generated. - - This corresponds to the ``event_threat_detection_custom_module`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): 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.securitycentermanagement_v1.types.EventThreatDetectionCustomModule: - An event threat detection custom - module is a Cloud SCC resource that - contains the configuration and - enablement state of a custom module, - which enables ETD to write certain - findings to Cloud SCC. - - """ - # 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, event_threat_detection_custom_module]) - 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 = security_center_management.CreateEventThreatDetectionCustomModuleRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if event_threat_detection_custom_module is not None: - request.event_threat_detection_custom_module = event_threat_detection_custom_module - - # 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_event_threat_detection_custom_module, - default_timeout=60.0, - 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 update_event_threat_detection_custom_module(self, - request: Optional[Union[security_center_management.UpdateEventThreatDetectionCustomModuleRequest, dict]] = None, - *, - event_threat_detection_custom_module: Optional[security_center_management.EventThreatDetectionCustomModule] = 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]] = (), - ) -> security_center_management.EventThreatDetectionCustomModule: - r"""Updates the Event Threat Detection custom module with - the given name based on the given update mask. Updating - the enablement state is supported for both resident and - inherited modules (though resident modules cannot have - an enablement state of "inherited"). Updating the - display name or configuration of a module is supported - for resident modules only. The type of a module cannot - be changed. - - .. 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 securitycentermanagement_v1 - - async def sample_update_event_threat_detection_custom_module(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.UpdateEventThreatDetectionCustomModuleRequest( - ) - - # Make the request - response = await client.update_event_threat_detection_custom_module(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.securitycentermanagement_v1.types.UpdateEventThreatDetectionCustomModuleRequest, dict]]): - The request object. Message for updating a - EventThreatDetectionCustomModule - event_threat_detection_custom_module (:class:`google.cloud.securitycentermanagement_v1.types.EventThreatDetectionCustomModule`): - Required. The module being updated - This corresponds to the ``event_threat_detection_custom_module`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`): - Required. Field mask is used to specify the fields to be - overwritten in the EventThreatDetectionCustomModule - resource by the update. The fields specified in the - update_mask are relative to the resource, not the full - request. A field will be overwritten if it is in the - mask. If the user does not provide a mask then all - fields will be overwritten. - - 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_async.AsyncRetry): 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.securitycentermanagement_v1.types.EventThreatDetectionCustomModule: - An event threat detection custom - module is a Cloud SCC resource that - contains the configuration and - enablement state of a custom module, - which enables ETD to write certain - findings to Cloud SCC. - - """ - # 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([event_threat_detection_custom_module, 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 = security_center_management.UpdateEventThreatDetectionCustomModuleRequest(request) - - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if event_threat_detection_custom_module is not None: - request.event_threat_detection_custom_module = event_threat_detection_custom_module - 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_event_threat_detection_custom_module, - default_timeout=60.0, - 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(( - ("event_threat_detection_custom_module.name", request.event_threat_detection_custom_module.name), - )), - ) - - # Send the request. - response = await rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - async def delete_event_threat_detection_custom_module(self, - request: Optional[Union[security_center_management.DeleteEventThreatDetectionCustomModuleRequest, 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 Event Threat Detection custom - module and all of its descendants in the Resource - Manager hierarchy. This method is only supported for - resident custom modules. - - .. 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 securitycentermanagement_v1 - - async def sample_delete_event_threat_detection_custom_module(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.DeleteEventThreatDetectionCustomModuleRequest( - name="name_value", - ) - - # Make the request - await client.delete_event_threat_detection_custom_module(request=request) - - Args: - request (Optional[Union[google.cloud.securitycentermanagement_v1.types.DeleteEventThreatDetectionCustomModuleRequest, dict]]): - The request object. Message for deleting a - EventThreatDetectionCustomModule - name (:class:`str`): - Required. The resource name of the ETD custom module. - - Its format is: - - - "organizations/{organization}/locations/{location}/eventThreatDetectionCustomModules/{event_threat_detection_custom_module}". - - "folders/{folder}/locations/{location}/eventThreatDetectionCustomModules/{event_threat_detection_custom_module}". - - "projects/{project}/locations/{location}/eventThreatDetectionCustomModules/{event_threat_detection_custom_module}". - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry_async.AsyncRetry): 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 = security_center_management.DeleteEventThreatDetectionCustomModuleRequest(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_event_threat_detection_custom_module, - default_timeout=60.0, - 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 validate_event_threat_detection_custom_module(self, - request: Optional[Union[security_center_management.ValidateEventThreatDetectionCustomModuleRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> security_center_management.ValidateEventThreatDetectionCustomModuleResponse: - r"""Validates the given Event Threat Detection custom - module. - - .. 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 securitycentermanagement_v1 - - async def sample_validate_event_threat_detection_custom_module(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.ValidateEventThreatDetectionCustomModuleRequest( - parent="parent_value", - raw_text="raw_text_value", - type_="type__value", - ) - - # Make the request - response = await client.validate_event_threat_detection_custom_module(request=request) - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.securitycentermanagement_v1.types.ValidateEventThreatDetectionCustomModuleRequest, dict]]): - The request object. Request to validate an Event Threat - Detection custom module. - retry (google.api_core.retry_async.AsyncRetry): 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.securitycentermanagement_v1.types.ValidateEventThreatDetectionCustomModuleResponse: - Response to validating an Event - Threat Detection custom module. - - """ - # Create or coerce a protobuf request object. - request = security_center_management.ValidateEventThreatDetectionCustomModuleRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method_async.wrap_method( - self._client._transport.validate_event_threat_detection_custom_module, - default_retry=retries.AsyncRetry( -initial=0.1,maximum=60.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.DeadlineExceeded, - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - 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 get_location( - self, - request: Optional[locations_pb2.GetLocationRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.Location: - r"""Gets information about a location. - - Args: - request (:class:`~.location_pb2.GetLocationRequest`): - The request object. Request message for - `GetLocation` method. - retry (google.api_core.retry_async.AsyncRetry): 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: - ~.location_pb2.Location: - Location object. - """ - # Create or coerce a protobuf request object. - # The request isn't a proto-plus wrapped type, - # so it must be constructed via keyword expansion. - if isinstance(request, dict): - request = locations_pb2.GetLocationRequest(**request) - - # 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_location, - 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 list_locations( - self, - request: Optional[locations_pb2.ListLocationsRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.ListLocationsResponse: - r"""Lists information about the supported locations for this service. - - Args: - request (:class:`~.location_pb2.ListLocationsRequest`): - The request object. Request message for - `ListLocations` method. - retry (google.api_core.retry_async.AsyncRetry): 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: - ~.location_pb2.ListLocationsResponse: - Response message for ``ListLocations`` method. - """ - # Create or coerce a protobuf request object. - # The request isn't a proto-plus wrapped type, - # so it must be constructed via keyword expansion. - if isinstance(request, dict): - request = locations_pb2.ListLocationsRequest(**request) - - # 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_locations, - 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 __aenter__(self) -> "SecurityCenterManagementAsyncClient": - return self - - async def __aexit__(self, exc_type, exc, tb): - await self.transport.close() - -DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) - - -__all__ = ( - "SecurityCenterManagementAsyncClient", -) diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/client.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/client.py deleted file mode 100644 index 7031f8462341..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/client.py +++ /dev/null @@ -1,2653 +0,0 @@ -# -*- 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. -# -from collections import OrderedDict -import os -import re -from typing import Dict, Mapping, MutableMapping, MutableSequence, Optional, Sequence, Tuple, Type, Union, cast - -from google.cloud.securitycentermanagement_v1 import gapic_version as package_version - -from google.api_core import client_options as client_options_lib -from google.api_core import exceptions as core_exceptions -from google.api_core import gapic_v1 -from google.api_core import retry as retries -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport import mtls # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore -from google.auth.exceptions import MutualTLSChannelError # type: ignore -from google.oauth2 import service_account # type: ignore - -try: - OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] -except AttributeError: # pragma: NO COVER - OptionalRetry = Union[retries.Retry, object] # type: ignore - -from google.cloud.location import locations_pb2 # type: ignore -from google.cloud.securitycentermanagement_v1.services.security_center_management import pagers -from google.cloud.securitycentermanagement_v1.types import security_center_management -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import struct_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore -from .transports.base import SecurityCenterManagementTransport, DEFAULT_CLIENT_INFO -from .transports.grpc import SecurityCenterManagementGrpcTransport -from .transports.grpc_asyncio import SecurityCenterManagementGrpcAsyncIOTransport -from .transports.rest import SecurityCenterManagementRestTransport - - -class SecurityCenterManagementClientMeta(type): - """Metaclass for the SecurityCenterManagement client. - - This provides class-level methods for building and retrieving - support objects (e.g. transport) without polluting the client instance - objects. - """ - _transport_registry = OrderedDict() # type: Dict[str, Type[SecurityCenterManagementTransport]] - _transport_registry["grpc"] = SecurityCenterManagementGrpcTransport - _transport_registry["grpc_asyncio"] = SecurityCenterManagementGrpcAsyncIOTransport - _transport_registry["rest"] = SecurityCenterManagementRestTransport - - def get_transport_class(cls, - label: Optional[str] = None, - ) -> Type[SecurityCenterManagementTransport]: - """Returns an appropriate transport class. - - Args: - label: The name of the desired transport. If none is - provided, then the first transport in the registry is used. - - Returns: - The transport class to use. - """ - # If a specific transport is requested, return that one. - if label: - return cls._transport_registry[label] - - # No transport is requested; return the default (that is, the first one - # in the dictionary). - return next(iter(cls._transport_registry.values())) - - -class SecurityCenterManagementClient(metaclass=SecurityCenterManagementClientMeta): - """Service describing handlers for resources""" - - @staticmethod - def _get_default_mtls_endpoint(api_endpoint): - """Converts api endpoint to mTLS endpoint. - - Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to - "*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively. - Args: - api_endpoint (Optional[str]): the api endpoint to convert. - Returns: - str: converted mTLS api endpoint. - """ - if not api_endpoint: - return api_endpoint - - mtls_endpoint_re = re.compile( - r"(?P[^.]+)(?P\.mtls)?(?P\.sandbox)?(?P\.googleapis\.com)?" - ) - - m = mtls_endpoint_re.match(api_endpoint) - name, mtls, sandbox, googledomain = m.groups() - if mtls or not googledomain: - return api_endpoint - - if sandbox: - return api_endpoint.replace( - "sandbox.googleapis.com", "mtls.sandbox.googleapis.com" - ) - - return api_endpoint.replace(".googleapis.com", ".mtls.googleapis.com") - - DEFAULT_ENDPOINT = "securitycentermanagement.googleapis.com" - DEFAULT_MTLS_ENDPOINT = _get_default_mtls_endpoint.__func__( # type: ignore - DEFAULT_ENDPOINT - ) - - @classmethod - def from_service_account_info(cls, info: dict, *args, **kwargs): - """Creates an instance of this client using the provided credentials - info. - - Args: - info (dict): The service account private key info. - args: Additional arguments to pass to the constructor. - kwargs: Additional arguments to pass to the constructor. - - Returns: - SecurityCenterManagementClient: The constructed client. - """ - credentials = service_account.Credentials.from_service_account_info(info) - kwargs["credentials"] = credentials - return cls(*args, **kwargs) - - @classmethod - def from_service_account_file(cls, filename: str, *args, **kwargs): - """Creates an instance of this client using the provided credentials - file. - - Args: - filename (str): The path to the service account private key json - file. - args: Additional arguments to pass to the constructor. - kwargs: Additional arguments to pass to the constructor. - - Returns: - SecurityCenterManagementClient: The constructed client. - """ - credentials = service_account.Credentials.from_service_account_file( - filename) - kwargs["credentials"] = credentials - return cls(*args, **kwargs) - - from_service_account_json = from_service_account_file - - @property - def transport(self) -> SecurityCenterManagementTransport: - """Returns the transport used by the client instance. - - Returns: - SecurityCenterManagementTransport: The transport used by the client - instance. - """ - return self._transport - - @staticmethod - def effective_event_threat_detection_custom_module_path(organization: str,location: str,effective_event_threat_detection_custom_module: str,) -> str: - """Returns a fully-qualified effective_event_threat_detection_custom_module string.""" - return "organizations/{organization}/locations/{location}/effectiveEventThreatDetectionCustomModules/{effective_event_threat_detection_custom_module}".format(organization=organization, location=location, effective_event_threat_detection_custom_module=effective_event_threat_detection_custom_module, ) - - @staticmethod - def parse_effective_event_threat_detection_custom_module_path(path: str) -> Dict[str,str]: - """Parses a effective_event_threat_detection_custom_module path into its component segments.""" - m = re.match(r"^organizations/(?P.+?)/locations/(?P.+?)/effectiveEventThreatDetectionCustomModules/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def effective_security_health_analytics_custom_module_path(organization: str,location: str,effective_security_health_analytics_custom_module: str,) -> str: - """Returns a fully-qualified effective_security_health_analytics_custom_module string.""" - return "organizations/{organization}/locations/{location}/effectiveSecurityHealthAnalyticsCustomModules/{effective_security_health_analytics_custom_module}".format(organization=organization, location=location, effective_security_health_analytics_custom_module=effective_security_health_analytics_custom_module, ) - - @staticmethod - def parse_effective_security_health_analytics_custom_module_path(path: str) -> Dict[str,str]: - """Parses a effective_security_health_analytics_custom_module path into its component segments.""" - m = re.match(r"^organizations/(?P.+?)/locations/(?P.+?)/effectiveSecurityHealthAnalyticsCustomModules/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def event_threat_detection_custom_module_path(organization: str,location: str,event_threat_detection_custom_module: str,) -> str: - """Returns a fully-qualified event_threat_detection_custom_module string.""" - return "organizations/{organization}/locations/{location}/eventThreatDetectionCustomModules/{event_threat_detection_custom_module}".format(organization=organization, location=location, event_threat_detection_custom_module=event_threat_detection_custom_module, ) - - @staticmethod - def parse_event_threat_detection_custom_module_path(path: str) -> Dict[str,str]: - """Parses a event_threat_detection_custom_module path into its component segments.""" - m = re.match(r"^organizations/(?P.+?)/locations/(?P.+?)/eventThreatDetectionCustomModules/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def finding_path(organization: str,source: str,finding: str,) -> str: - """Returns a fully-qualified finding string.""" - return "organizations/{organization}/sources/{source}/findings/{finding}".format(organization=organization, source=source, finding=finding, ) - - @staticmethod - def parse_finding_path(path: str) -> Dict[str,str]: - """Parses a finding path into its component segments.""" - m = re.match(r"^organizations/(?P.+?)/sources/(?P.+?)/findings/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def security_health_analytics_custom_module_path(organization: str,location: str,security_health_analytics_custom_module: str,) -> str: - """Returns a fully-qualified security_health_analytics_custom_module string.""" - return "organizations/{organization}/locations/{location}/securityHealthAnalyticsCustomModules/{security_health_analytics_custom_module}".format(organization=organization, location=location, security_health_analytics_custom_module=security_health_analytics_custom_module, ) - - @staticmethod - def parse_security_health_analytics_custom_module_path(path: str) -> Dict[str,str]: - """Parses a security_health_analytics_custom_module path into its component segments.""" - m = re.match(r"^organizations/(?P.+?)/locations/(?P.+?)/securityHealthAnalyticsCustomModules/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def common_billing_account_path(billing_account: str, ) -> str: - """Returns a fully-qualified billing_account string.""" - return "billingAccounts/{billing_account}".format(billing_account=billing_account, ) - - @staticmethod - def parse_common_billing_account_path(path: str) -> Dict[str,str]: - """Parse a billing_account path into its component segments.""" - m = re.match(r"^billingAccounts/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def common_folder_path(folder: str, ) -> str: - """Returns a fully-qualified folder string.""" - return "folders/{folder}".format(folder=folder, ) - - @staticmethod - def parse_common_folder_path(path: str) -> Dict[str,str]: - """Parse a folder path into its component segments.""" - m = re.match(r"^folders/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def common_organization_path(organization: str, ) -> str: - """Returns a fully-qualified organization string.""" - return "organizations/{organization}".format(organization=organization, ) - - @staticmethod - def parse_common_organization_path(path: str) -> Dict[str,str]: - """Parse a organization path into its component segments.""" - m = re.match(r"^organizations/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def common_project_path(project: str, ) -> str: - """Returns a fully-qualified project string.""" - return "projects/{project}".format(project=project, ) - - @staticmethod - def parse_common_project_path(path: str) -> Dict[str,str]: - """Parse a project path into its component segments.""" - m = re.match(r"^projects/(?P.+?)$", path) - return m.groupdict() if m else {} - - @staticmethod - def common_location_path(project: str, location: str, ) -> str: - """Returns a fully-qualified location string.""" - return "projects/{project}/locations/{location}".format(project=project, location=location, ) - - @staticmethod - def parse_common_location_path(path: str) -> Dict[str,str]: - """Parse a location path into its component segments.""" - m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) - return m.groupdict() if m else {} - - @classmethod - def get_mtls_endpoint_and_cert_source(cls, client_options: Optional[client_options_lib.ClientOptions] = None): - """Return the API endpoint and client cert source for mutual TLS. - - The client cert source is determined in the following order: - (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the - client cert source is None. - (2) if `client_options.client_cert_source` is provided, use the provided one; if the - default client cert source exists, use the default one; otherwise the client cert - source is None. - - The API endpoint is determined in the following order: - (1) if `client_options.api_endpoint` if provided, use the provided one. - (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the - default mTLS endpoint; if the environment variable is "never", use the default API - endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise - use the default API endpoint. - - More details can be found at https://google.aip.dev/auth/4114. - - Args: - client_options (google.api_core.client_options.ClientOptions): Custom options for the - client. Only the `api_endpoint` and `client_cert_source` properties may be used - in this method. - - Returns: - Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the - client cert source to use. - - Raises: - google.auth.exceptions.MutualTLSChannelError: If any errors happen. - """ - if client_options is None: - client_options = client_options_lib.ClientOptions() - use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") - use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") - if use_client_cert not in ("true", "false"): - raise ValueError("Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`") - if use_mtls_endpoint not in ("auto", "never", "always"): - raise MutualTLSChannelError("Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`") - - # Figure out the client cert source to use. - client_cert_source = None - if use_client_cert == "true": - if client_options.client_cert_source: - client_cert_source = client_options.client_cert_source - elif mtls.has_default_client_cert_source(): - client_cert_source = mtls.default_client_cert_source() - - # Figure out which api endpoint to use. - if client_options.api_endpoint is not None: - api_endpoint = client_options.api_endpoint - elif use_mtls_endpoint == "always" or (use_mtls_endpoint == "auto" and client_cert_source): - api_endpoint = cls.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = cls.DEFAULT_ENDPOINT - - return api_endpoint, client_cert_source - - def __init__(self, *, - credentials: Optional[ga_credentials.Credentials] = None, - transport: Optional[Union[str, SecurityCenterManagementTransport]] = None, - client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - ) -> None: - """Instantiates the security center management client. - - Args: - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - transport (Union[str, SecurityCenterManagementTransport]): The - transport to use. If set to None, a transport is chosen - automatically. - client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]): Custom options for the - client. It won't take effect if a ``transport`` instance is provided. - (1) The ``api_endpoint`` property can be used to override the - default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT - environment variable can also be used to override the endpoint: - "always" (always use the default mTLS endpoint), "never" (always - use the default regular endpoint) and "auto" (auto switch to the - default mTLS endpoint if client certificate is present, this is - the default value). However, the ``api_endpoint`` property takes - precedence if provided. - (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable - is "true", then the ``client_cert_source`` property can be used - to provide client certificate for mutual TLS transport. If - not provided, the default SSL client certificate will be used if - present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not - set, no client certificate will be used. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing - your own client library. - - Raises: - google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport - creation failed for any reason. - """ - if isinstance(client_options, dict): - client_options = client_options_lib.from_dict(client_options) - if client_options is None: - client_options = client_options_lib.ClientOptions() - client_options = cast(client_options_lib.ClientOptions, client_options) - - api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source(client_options) - - api_key_value = getattr(client_options, "api_key", None) - if api_key_value and credentials: - raise ValueError("client_options.api_key and credentials are mutually exclusive") - - # Save or instantiate the transport. - # Ordinarily, we provide the transport, but allowing a custom transport - # instance provides an extensibility point for unusual situations. - if isinstance(transport, SecurityCenterManagementTransport): - # transport is a SecurityCenterManagementTransport instance. - if credentials or client_options.credentials_file or api_key_value: - raise ValueError("When providing a transport instance, " - "provide its credentials directly.") - if client_options.scopes: - raise ValueError( - "When providing a transport instance, provide its scopes " - "directly." - ) - self._transport = transport - else: - import google.auth._default # type: ignore - - if api_key_value and hasattr(google.auth._default, "get_api_key_credentials"): - credentials = google.auth._default.get_api_key_credentials(api_key_value) - - Transport = type(self).get_transport_class(transport) - self._transport = Transport( - credentials=credentials, - credentials_file=client_options.credentials_file, - host=api_endpoint, - scopes=client_options.scopes, - client_cert_source_for_mtls=client_cert_source_func, - quota_project_id=client_options.quota_project_id, - client_info=client_info, - always_use_jwt_access=True, - api_audience=client_options.api_audience, - ) - - def list_effective_security_health_analytics_custom_modules(self, - request: Optional[Union[security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest, 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.ListEffectiveSecurityHealthAnalyticsCustomModulesPager: - r"""Returns a list of all - EffectiveSecurityHealthAnalyticsCustomModules for the - given parent. This includes resident modules defined at - the scope of the parent, and inherited modules, - inherited from CRM ancestors (no descendants). - - .. 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 securitycentermanagement_v1 - - def sample_list_effective_security_health_analytics_custom_modules(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_effective_security_health_analytics_custom_modules(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.securitycentermanagement_v1.types.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest, dict]): - The request object. Request message for listing effective - Security Health Analytics custom - modules. - parent (str): - Required. Name of parent to list - effective custom modules. Its format is - "organizations/{organization}/locations/{location}", - "folders/{folder}/locations/{location}", - or - "projects/{project}/locations/{location}" - - 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.securitycentermanagement_v1.services.security_center_management.pagers.ListEffectiveSecurityHealthAnalyticsCustomModulesPager: - Response message for listing - effective Security Health Analytics - custom modules. - - 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 security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest): - request = security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest(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_effective_security_health_analytics_custom_modules] - - # 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.ListEffectiveSecurityHealthAnalyticsCustomModulesPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_effective_security_health_analytics_custom_module(self, - request: Optional[Union[security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest, 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]] = (), - ) -> security_center_management.EffectiveSecurityHealthAnalyticsCustomModule: - r"""Gets details of a single - EffectiveSecurityHealthAnalyticsCustomModule. - - .. 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 securitycentermanagement_v1 - - def sample_get_effective_security_health_analytics_custom_module(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest( - name="name_value", - ) - - # Make the request - response = client.get_effective_security_health_analytics_custom_module(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.securitycentermanagement_v1.types.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest, dict]): - The request object. Message for getting a - EffectiveSecurityHealthAnalyticsCustomModule - name (str): - Required. The resource name of the SHA custom module. - - Its format is: - - - "organizations/{organization}/locations/{location}/effectiveSecurityHealthAnalyticsCustomModules/{module_id}". - - "folders/{folder}/locations/{location}/effectiveSecurityHealthAnalyticsCustomModules/{module_id}". - - "projects/{project}/locations/{location}/effectiveSecurityHealthAnalyticsCustomModules/{module_id}". - - 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.securitycentermanagement_v1.types.EffectiveSecurityHealthAnalyticsCustomModule: - An EffectiveSecurityHealthAnalyticsCustomModule is the representation of - a Security Health Analytics custom module at a - specified level of the resource hierarchy: - organization, folder, or project. If a custom module - is inherited from a parent organization or folder, - the value of the enablementState property in - EffectiveSecurityHealthAnalyticsCustomModule is set - to the value that is effective in the parent, instead - of INHERITED. For example, if the module is enabled - in a parent organization or folder, the effective - enablement_state for the module in all child folders - or projects is also enabled. - EffectiveSecurityHealthAnalyticsCustomModule is - read-only. - - """ - # 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 security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest): - request = security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest(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_effective_security_health_analytics_custom_module] - - # 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 list_security_health_analytics_custom_modules(self, - request: Optional[Union[security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest, 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.ListSecurityHealthAnalyticsCustomModulesPager: - r"""Returns a list of all - SecurityHealthAnalyticsCustomModules for the given - parent. This includes resident modules defined at the - scope of the parent, and inherited modules, inherited - from CRM ancestors (no descendants). - - .. 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 securitycentermanagement_v1 - - def sample_list_security_health_analytics_custom_modules(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.ListSecurityHealthAnalyticsCustomModulesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_security_health_analytics_custom_modules(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.securitycentermanagement_v1.types.ListSecurityHealthAnalyticsCustomModulesRequest, dict]): - The request object. Request message for listing Security - Health Analytics custom modules. - parent (str): - Required. Name of parent to list - custom modules. Its format is - "organizations/{organization}/locations/{location}", - "folders/{folder}/locations/{location}", - or - "projects/{project}/locations/{location}" - - 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.securitycentermanagement_v1.services.security_center_management.pagers.ListSecurityHealthAnalyticsCustomModulesPager: - Response message for listing Security - Health Analytics custom modules. - 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 security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest): - request = security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest(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_security_health_analytics_custom_modules] - - # 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.ListSecurityHealthAnalyticsCustomModulesPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def list_descendant_security_health_analytics_custom_modules(self, - request: Optional[Union[security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest, 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.ListDescendantSecurityHealthAnalyticsCustomModulesPager: - r"""Returns a list of all resident - SecurityHealthAnalyticsCustomModules under the given CRM - parent and all of the parent’s CRM descendants. - - .. 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 securitycentermanagement_v1 - - def sample_list_descendant_security_health_analytics_custom_modules(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.ListDescendantSecurityHealthAnalyticsCustomModulesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_descendant_security_health_analytics_custom_modules(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.securitycentermanagement_v1.types.ListDescendantSecurityHealthAnalyticsCustomModulesRequest, dict]): - The request object. Request message for listing - descendant Security Health Analytics - custom modules. - parent (str): - Required. Name of parent to list - custom modules. Its format is - "organizations/{organization}/locations/{location}", - "folders/{folder}/locations/{location}", - or - "projects/{project}/locations/{location}" - - 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.securitycentermanagement_v1.services.security_center_management.pagers.ListDescendantSecurityHealthAnalyticsCustomModulesPager: - Response message for listing - descendant Security Health Analytics - custom modules. - - 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 security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest): - request = security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest(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_descendant_security_health_analytics_custom_modules] - - # 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.ListDescendantSecurityHealthAnalyticsCustomModulesPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_security_health_analytics_custom_module(self, - request: Optional[Union[security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest, 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]] = (), - ) -> security_center_management.SecurityHealthAnalyticsCustomModule: - r"""Retrieves a SecurityHealthAnalyticsCustomModule. - - .. 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 securitycentermanagement_v1 - - def sample_get_security_health_analytics_custom_module(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.GetSecurityHealthAnalyticsCustomModuleRequest( - name="name_value", - ) - - # Make the request - response = client.get_security_health_analytics_custom_module(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.securitycentermanagement_v1.types.GetSecurityHealthAnalyticsCustomModuleRequest, dict]): - The request object. Message for getting a - SecurityHealthAnalyticsCustomModule - name (str): - Required. Name of the resource - 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.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule: - Represents an instance of a Security - Health Analytics custom module, - including its full module name, display - name, enablement state, and last updated - time. You can create a custom module at - the organization, folder, or project - level. Custom modules that you create at - the organization or folder level are - inherited by the child folders and - projects. - - """ - # 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 security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest): - request = security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest(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_security_health_analytics_custom_module] - - # 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 create_security_health_analytics_custom_module(self, - request: Optional[Union[security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest, dict]] = None, - *, - parent: Optional[str] = None, - security_health_analytics_custom_module: Optional[security_center_management.SecurityHealthAnalyticsCustomModule] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> security_center_management.SecurityHealthAnalyticsCustomModule: - r"""Creates a resident - SecurityHealthAnalyticsCustomModule at the scope of the - given CRM parent, and also creates inherited - SecurityHealthAnalyticsCustomModules for all CRM - descendants of the given parent. These modules are - enabled by default. - - .. 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 securitycentermanagement_v1 - - def sample_create_security_health_analytics_custom_module(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.CreateSecurityHealthAnalyticsCustomModuleRequest( - parent="parent_value", - ) - - # Make the request - response = client.create_security_health_analytics_custom_module(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.securitycentermanagement_v1.types.CreateSecurityHealthAnalyticsCustomModuleRequest, dict]): - The request object. Message for creating a - SecurityHealthAnalyticsCustomModule - parent (str): - Required. Name of the parent for the - module. Its format is - "organizations/{organization}/locations/{location}", - "folders/{folder}/locations/{location}", - or - "projects/{project}/locations/{location}" - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - security_health_analytics_custom_module (google.cloud.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule): - Required. The resource being created - This corresponds to the ``security_health_analytics_custom_module`` 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.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule: - Represents an instance of a Security - Health Analytics custom module, - including its full module name, display - name, enablement state, and last updated - time. You can create a custom module at - the organization, folder, or project - level. Custom modules that you create at - the organization or folder level are - inherited by the child folders and - projects. - - """ - # 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, security_health_analytics_custom_module]) - 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 security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest): - request = security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if security_health_analytics_custom_module is not None: - request.security_health_analytics_custom_module = security_health_analytics_custom_module - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_security_health_analytics_custom_module] - - # 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 update_security_health_analytics_custom_module(self, - request: Optional[Union[security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest, dict]] = None, - *, - security_health_analytics_custom_module: Optional[security_center_management.SecurityHealthAnalyticsCustomModule] = 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]] = (), - ) -> security_center_management.SecurityHealthAnalyticsCustomModule: - r"""Updates the SecurityHealthAnalyticsCustomModule under - the given name based on the given update mask. Updating - the enablement state is supported on both resident and - inherited modules (though resident modules cannot have - an enablement state of "inherited"). Updating the - display name and custom config of a module is supported - on resident modules only. - - .. 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 securitycentermanagement_v1 - - def sample_update_security_health_analytics_custom_module(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.UpdateSecurityHealthAnalyticsCustomModuleRequest( - ) - - # Make the request - response = client.update_security_health_analytics_custom_module(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.securitycentermanagement_v1.types.UpdateSecurityHealthAnalyticsCustomModuleRequest, dict]): - The request object. Message for updating a - SecurityHealthAnalyticsCustomModule - security_health_analytics_custom_module (google.cloud.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule): - Required. The resource being updated - This corresponds to the ``security_health_analytics_custom_module`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. Field mask is used to specify the fields to be - overwritten in the SecurityHealthAnalyticsCustomModule - resource by the update. The fields specified in the - update_mask are relative to the resource, not the full - request. A field will be overwritten if it is in the - mask. If the user does not provide a mask then all - fields will be overwritten. - - 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.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule: - Represents an instance of a Security - Health Analytics custom module, - including its full module name, display - name, enablement state, and last updated - time. You can create a custom module at - the organization, folder, or project - level. Custom modules that you create at - the organization or folder level are - inherited by the child folders and - projects. - - """ - # 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([security_health_analytics_custom_module, 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 security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest): - request = security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if security_health_analytics_custom_module is not None: - request.security_health_analytics_custom_module = security_health_analytics_custom_module - 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_security_health_analytics_custom_module] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("security_health_analytics_custom_module.name", request.security_health_analytics_custom_module.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def delete_security_health_analytics_custom_module(self, - request: Optional[Union[security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest, 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 - SecurityHealthAnalyticsCustomModule and all of its - descendants in the CRM hierarchy. This method is only - supported for resident custom modules. - - .. 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 securitycentermanagement_v1 - - def sample_delete_security_health_analytics_custom_module(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.DeleteSecurityHealthAnalyticsCustomModuleRequest( - name="name_value", - ) - - # Make the request - client.delete_security_health_analytics_custom_module(request=request) - - Args: - request (Union[google.cloud.securitycentermanagement_v1.types.DeleteSecurityHealthAnalyticsCustomModuleRequest, dict]): - The request object. Message for deleting a - SecurityHealthAnalyticsCustomModule - name (str): - Required. The resource name of the SHA custom module. - - Its format is: - - - "organizations/{organization}/locations/{location}/securityHealthAnalyticsCustomModules/{security_health_analytics_custom_module}". - - "folders/{folder}/locations/{location}/securityHealthAnalyticsCustomModules/{security_health_analytics_custom_module}". - - "projects/{project}/locations/{location}/securityHealthAnalyticsCustomModules/{security_health_analytics_custom_module}". - - 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 security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest): - request = security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest(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_security_health_analytics_custom_module] - - # 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 simulate_security_health_analytics_custom_module(self, - request: Optional[Union[security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest, dict]] = None, - *, - parent: Optional[str] = None, - custom_config: Optional[security_center_management.CustomConfig] = None, - resource: Optional[security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest.SimulatedResource] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse: - r"""Simulates a given SecurityHealthAnalyticsCustomModule - and Resource. - - .. 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 securitycentermanagement_v1 - - def sample_simulate_security_health_analytics_custom_module(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementClient() - - # Initialize request argument(s) - resource = securitycentermanagement_v1.SimulatedResource() - resource.resource_type = "resource_type_value" - - request = securitycentermanagement_v1.SimulateSecurityHealthAnalyticsCustomModuleRequest( - parent="parent_value", - resource=resource, - ) - - # Make the request - response = client.simulate_security_health_analytics_custom_module(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.securitycentermanagement_v1.types.SimulateSecurityHealthAnalyticsCustomModuleRequest, dict]): - The request object. Request message to simulate a - CustomConfig against a given test - resource. Maximum size of the request is - 4 MB by default. - parent (str): - Required. The relative resource name of the - organization, project, or folder. For more information - about relative resource names, see `Relative Resource - Name `__ - Example: ``organizations/{organization_id}``. - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - custom_config (google.cloud.securitycentermanagement_v1.types.CustomConfig): - Required. The custom configuration - that you need to test. - - This corresponds to the ``custom_config`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - resource (google.cloud.securitycentermanagement_v1.types.SimulateSecurityHealthAnalyticsCustomModuleRequest.SimulatedResource): - Required. Resource data to simulate - custom module against. - - This corresponds to the ``resource`` 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.securitycentermanagement_v1.types.SimulateSecurityHealthAnalyticsCustomModuleResponse: - Response message for simulating a SecurityHealthAnalyticsCustomModule - against a given resource. - - """ - # 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, custom_config, resource]) - 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 security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest): - request = security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if custom_config is not None: - request.custom_config = custom_config - if resource is not None: - request.resource = resource - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.simulate_security_health_analytics_custom_module] - - # 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_effective_event_threat_detection_custom_modules(self, - request: Optional[Union[security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest, 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.ListEffectiveEventThreatDetectionCustomModulesPager: - r"""Lists all effective Event Threat Detection custom - modules for the given parent. This includes resident - modules defined at the scope of the parent along with - modules inherited from its ancestors. - - .. 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 securitycentermanagement_v1 - - def sample_list_effective_event_threat_detection_custom_modules(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.ListEffectiveEventThreatDetectionCustomModulesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_effective_event_threat_detection_custom_modules(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.securitycentermanagement_v1.types.ListEffectiveEventThreatDetectionCustomModulesRequest, dict]): - The request object. Request message for listing effective - Event Threat Detection custom modules. - parent (str): - Required. Name of parent to list - effective custom modules. Its format is - "organizations/{organization}/locations/{location}", - "folders/{folder}/locations/{location}", - or - "projects/{project}/locations/{location}" - - 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.securitycentermanagement_v1.services.security_center_management.pagers.ListEffectiveEventThreatDetectionCustomModulesPager: - Response message for listing - effective Event Threat Detection custom - modules. - - 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 security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest): - request = security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest(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_effective_event_threat_detection_custom_modules] - - # 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.ListEffectiveEventThreatDetectionCustomModulesPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_effective_event_threat_detection_custom_module(self, - request: Optional[Union[security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest, 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]] = (), - ) -> security_center_management.EffectiveEventThreatDetectionCustomModule: - r"""Gets an effective ETD custom module. Retrieves the effective - module at the given level. The difference between an - EffectiveCustomModule and a CustomModule is that the fields for - an EffectiveCustomModule are computed from ancestors if needed. - For example, the enablement_state for a CustomModule can be - either ENABLED, DISABLED, or INHERITED. Where as the - enablement_state for an EffectiveCustomModule is always computed - to ENABLED or DISABLED (the effective enablement_state). - - .. 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 securitycentermanagement_v1 - - def sample_get_effective_event_threat_detection_custom_module(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.GetEffectiveEventThreatDetectionCustomModuleRequest( - name="name_value", - ) - - # Make the request - response = client.get_effective_event_threat_detection_custom_module(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.securitycentermanagement_v1.types.GetEffectiveEventThreatDetectionCustomModuleRequest, dict]): - The request object. Message for getting a - EffectiveEventThreatDetectionCustomModule - name (str): - Required. The resource name of the ETD custom module. - - Its format is: - - - "organizations/{organization}/locations/{location}/effectiveEventThreatDetectionCustomModules/{effective_event_threat_detection_custom_module}". - - "folders/{folder}/locations/{location}/effectiveEventThreatDetectionCustomModules/{effective_event_threat_detection_custom_module}". - - "projects/{project}/locations/{location}/effectiveEventThreatDetectionCustomModules/{effective_event_threat_detection_custom_module}". - - 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.securitycentermanagement_v1.types.EffectiveEventThreatDetectionCustomModule: - An EffectiveEventThreatDetectionCustomModule is the representation of - EventThreatDetectionCustomModule at a given level - taking hierarchy into account and resolving various - fields accordingly. e.g. if the module is enabled at - the ancestor level, effective modules at all - descendant levels will have enablement_state set to - ENABLED. Similarly, if module.inherited is set, then - effective module's config will contain the ancestor's - config details. - EffectiveEventThreatDetectionCustomModule is - read-only. - - """ - # 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 security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest): - request = security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest(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_effective_event_threat_detection_custom_module] - - # 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 list_event_threat_detection_custom_modules(self, - request: Optional[Union[security_center_management.ListEventThreatDetectionCustomModulesRequest, 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.ListEventThreatDetectionCustomModulesPager: - r"""Lists all Event Threat Detection custom modules for - the given Resource Manager parent. This includes - resident modules defined at the scope of the parent - along with modules inherited from ancestors. - - .. 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 securitycentermanagement_v1 - - def sample_list_event_threat_detection_custom_modules(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.ListEventThreatDetectionCustomModulesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_event_threat_detection_custom_modules(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.securitycentermanagement_v1.types.ListEventThreatDetectionCustomModulesRequest, dict]): - The request object. Request message for listing Event - Threat Detection custom modules. - parent (str): - Required. Name of parent to list - custom modules. Its format is - "organizations/{organization}/locations/{location}", - "folders/{folder}/locations/{location}", - or - "projects/{project}/locations/{location}" - - 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.securitycentermanagement_v1.services.security_center_management.pagers.ListEventThreatDetectionCustomModulesPager: - Response message for listing Event - Threat Detection custom modules. - 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 security_center_management.ListEventThreatDetectionCustomModulesRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, security_center_management.ListEventThreatDetectionCustomModulesRequest): - request = security_center_management.ListEventThreatDetectionCustomModulesRequest(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_event_threat_detection_custom_modules] - - # 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.ListEventThreatDetectionCustomModulesPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def list_descendant_event_threat_detection_custom_modules(self, - request: Optional[Union[security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest, 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.ListDescendantEventThreatDetectionCustomModulesPager: - r"""Lists all resident Event Threat Detection custom - modules under the given Resource Manager parent and its - descendants. - - .. 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 securitycentermanagement_v1 - - def sample_list_descendant_event_threat_detection_custom_modules(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.ListDescendantEventThreatDetectionCustomModulesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_descendant_event_threat_detection_custom_modules(request=request) - - # Handle the response - for response in page_result: - print(response) - - Args: - request (Union[google.cloud.securitycentermanagement_v1.types.ListDescendantEventThreatDetectionCustomModulesRequest, dict]): - The request object. Request message for listing - descendant Event Threat Detection custom - modules. - parent (str): - Required. Name of parent to list - custom modules. Its format is - "organizations/{organization}/locations/{location}", - "folders/{folder}/locations/{location}", - or - "projects/{project}/locations/{location}" - - 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.securitycentermanagement_v1.services.security_center_management.pagers.ListDescendantEventThreatDetectionCustomModulesPager: - Response message for listing - descendant Event Threat Detection custom - modules. - - 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 security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest): - request = security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest(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_descendant_event_threat_detection_custom_modules] - - # 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.ListDescendantEventThreatDetectionCustomModulesPager( - method=rpc, - request=request, - response=response, - metadata=metadata, - ) - - # Done; return the response. - return response - - def get_event_threat_detection_custom_module(self, - request: Optional[Union[security_center_management.GetEventThreatDetectionCustomModuleRequest, 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]] = (), - ) -> security_center_management.EventThreatDetectionCustomModule: - r"""Gets an Event Threat Detection custom module. - - .. 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 securitycentermanagement_v1 - - def sample_get_event_threat_detection_custom_module(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.GetEventThreatDetectionCustomModuleRequest( - name="name_value", - ) - - # Make the request - response = client.get_event_threat_detection_custom_module(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.securitycentermanagement_v1.types.GetEventThreatDetectionCustomModuleRequest, dict]): - The request object. Message for getting a - EventThreatDetectionCustomModule - name (str): - Required. The resource name of the ETD custom module. - - Its format is: - - - "organizations/{organization}/locations/{location}/eventThreatDetectionCustomModules/{event_threat_detection_custom_module}". - - "folders/{folder}/locations/{location}/eventThreatDetectionCustomModules/{event_threat_detection_custom_module}". - - "projects/{project}/locations/{location}/eventThreatDetectionCustomModules/{event_threat_detection_custom_module}". - - 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.securitycentermanagement_v1.types.EventThreatDetectionCustomModule: - An event threat detection custom - module is a Cloud SCC resource that - contains the configuration and - enablement state of a custom module, - which enables ETD to write certain - findings to Cloud SCC. - - """ - # 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 security_center_management.GetEventThreatDetectionCustomModuleRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, security_center_management.GetEventThreatDetectionCustomModuleRequest): - request = security_center_management.GetEventThreatDetectionCustomModuleRequest(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_event_threat_detection_custom_module] - - # 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 create_event_threat_detection_custom_module(self, - request: Optional[Union[security_center_management.CreateEventThreatDetectionCustomModuleRequest, dict]] = None, - *, - parent: Optional[str] = None, - event_threat_detection_custom_module: Optional[security_center_management.EventThreatDetectionCustomModule] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> security_center_management.EventThreatDetectionCustomModule: - r"""Creates a resident Event Threat Detection custom - module at the scope of the given Resource Manager - parent, and also creates inherited custom modules for - all descendants of the given parent. These modules are - enabled by default. - - .. 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 securitycentermanagement_v1 - - def sample_create_event_threat_detection_custom_module(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.CreateEventThreatDetectionCustomModuleRequest( - parent="parent_value", - ) - - # Make the request - response = client.create_event_threat_detection_custom_module(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.securitycentermanagement_v1.types.CreateEventThreatDetectionCustomModuleRequest, dict]): - The request object. Message for creating a - EventThreatDetectionCustomModule - parent (str): - Required. Name of parent for the - module. Its format is - "organizations/{organization}/locations/{location}", - "folders/{folder}/locations/{location}", - or - "projects/{project}/locations/{location}" - - This corresponds to the ``parent`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - event_threat_detection_custom_module (google.cloud.securitycentermanagement_v1.types.EventThreatDetectionCustomModule): - Required. The module to create. The - event_threat_detection_custom_module.name will be - ignored and server generated. - - This corresponds to the ``event_threat_detection_custom_module`` 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.securitycentermanagement_v1.types.EventThreatDetectionCustomModule: - An event threat detection custom - module is a Cloud SCC resource that - contains the configuration and - enablement state of a custom module, - which enables ETD to write certain - findings to Cloud SCC. - - """ - # 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, event_threat_detection_custom_module]) - 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 security_center_management.CreateEventThreatDetectionCustomModuleRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, security_center_management.CreateEventThreatDetectionCustomModuleRequest): - request = security_center_management.CreateEventThreatDetectionCustomModuleRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if parent is not None: - request.parent = parent - if event_threat_detection_custom_module is not None: - request.event_threat_detection_custom_module = event_threat_detection_custom_module - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.create_event_threat_detection_custom_module] - - # 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 update_event_threat_detection_custom_module(self, - request: Optional[Union[security_center_management.UpdateEventThreatDetectionCustomModuleRequest, dict]] = None, - *, - event_threat_detection_custom_module: Optional[security_center_management.EventThreatDetectionCustomModule] = 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]] = (), - ) -> security_center_management.EventThreatDetectionCustomModule: - r"""Updates the Event Threat Detection custom module with - the given name based on the given update mask. Updating - the enablement state is supported for both resident and - inherited modules (though resident modules cannot have - an enablement state of "inherited"). Updating the - display name or configuration of a module is supported - for resident modules only. The type of a module cannot - be changed. - - .. 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 securitycentermanagement_v1 - - def sample_update_event_threat_detection_custom_module(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.UpdateEventThreatDetectionCustomModuleRequest( - ) - - # Make the request - response = client.update_event_threat_detection_custom_module(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.securitycentermanagement_v1.types.UpdateEventThreatDetectionCustomModuleRequest, dict]): - The request object. Message for updating a - EventThreatDetectionCustomModule - event_threat_detection_custom_module (google.cloud.securitycentermanagement_v1.types.EventThreatDetectionCustomModule): - Required. The module being updated - This corresponds to the ``event_threat_detection_custom_module`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. Field mask is used to specify the fields to be - overwritten in the EventThreatDetectionCustomModule - resource by the update. The fields specified in the - update_mask are relative to the resource, not the full - request. A field will be overwritten if it is in the - mask. If the user does not provide a mask then all - fields will be overwritten. - - 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.securitycentermanagement_v1.types.EventThreatDetectionCustomModule: - An event threat detection custom - module is a Cloud SCC resource that - contains the configuration and - enablement state of a custom module, - which enables ETD to write certain - findings to Cloud SCC. - - """ - # 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([event_threat_detection_custom_module, 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 security_center_management.UpdateEventThreatDetectionCustomModuleRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, security_center_management.UpdateEventThreatDetectionCustomModuleRequest): - request = security_center_management.UpdateEventThreatDetectionCustomModuleRequest(request) - # If we have keyword arguments corresponding to fields on the - # request, apply these. - if event_threat_detection_custom_module is not None: - request.event_threat_detection_custom_module = event_threat_detection_custom_module - 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_event_threat_detection_custom_module] - - # Certain fields should be provided within the metadata header; - # add these here. - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ("event_threat_detection_custom_module.name", request.event_threat_detection_custom_module.name), - )), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Done; return the response. - return response - - def delete_event_threat_detection_custom_module(self, - request: Optional[Union[security_center_management.DeleteEventThreatDetectionCustomModuleRequest, 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 Event Threat Detection custom - module and all of its descendants in the Resource - Manager hierarchy. This method is only supported for - resident custom modules. - - .. 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 securitycentermanagement_v1 - - def sample_delete_event_threat_detection_custom_module(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.DeleteEventThreatDetectionCustomModuleRequest( - name="name_value", - ) - - # Make the request - client.delete_event_threat_detection_custom_module(request=request) - - Args: - request (Union[google.cloud.securitycentermanagement_v1.types.DeleteEventThreatDetectionCustomModuleRequest, dict]): - The request object. Message for deleting a - EventThreatDetectionCustomModule - name (str): - Required. The resource name of the ETD custom module. - - Its format is: - - - "organizations/{organization}/locations/{location}/eventThreatDetectionCustomModules/{event_threat_detection_custom_module}". - - "folders/{folder}/locations/{location}/eventThreatDetectionCustomModules/{event_threat_detection_custom_module}". - - "projects/{project}/locations/{location}/eventThreatDetectionCustomModules/{event_threat_detection_custom_module}". - - 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 security_center_management.DeleteEventThreatDetectionCustomModuleRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, security_center_management.DeleteEventThreatDetectionCustomModuleRequest): - request = security_center_management.DeleteEventThreatDetectionCustomModuleRequest(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_event_threat_detection_custom_module] - - # 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 validate_event_threat_detection_custom_module(self, - request: Optional[Union[security_center_management.ValidateEventThreatDetectionCustomModuleRequest, dict]] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> security_center_management.ValidateEventThreatDetectionCustomModuleResponse: - r"""Validates the given Event Threat Detection custom - module. - - .. 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 securitycentermanagement_v1 - - def sample_validate_event_threat_detection_custom_module(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.ValidateEventThreatDetectionCustomModuleRequest( - parent="parent_value", - raw_text="raw_text_value", - type_="type__value", - ) - - # Make the request - response = client.validate_event_threat_detection_custom_module(request=request) - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.securitycentermanagement_v1.types.ValidateEventThreatDetectionCustomModuleRequest, dict]): - The request object. Request to validate an Event Threat - Detection custom module. - 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.securitycentermanagement_v1.types.ValidateEventThreatDetectionCustomModuleResponse: - Response to validating an Event - Threat Detection custom module. - - """ - # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes - # in a security_center_management.ValidateEventThreatDetectionCustomModuleRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, security_center_management.ValidateEventThreatDetectionCustomModuleRequest): - request = security_center_management.ValidateEventThreatDetectionCustomModuleRequest(request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = self._transport._wrapped_methods[self._transport.validate_event_threat_detection_custom_module] - - # 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 __enter__(self) -> "SecurityCenterManagementClient": - return self - - def __exit__(self, type, value, traceback): - """Releases underlying transport's resources. - - .. warning:: - ONLY use as a context manager if the transport is NOT shared - with other clients! Exiting the with block will CLOSE the transport - and may cause errors in other clients! - """ - self.transport.close() - - def get_location( - self, - request: Optional[locations_pb2.GetLocationRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.Location: - r"""Gets information about a location. - - Args: - request (:class:`~.location_pb2.GetLocationRequest`): - The request object. Request message for - `GetLocation` method. - 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: - ~.location_pb2.Location: - Location object. - """ - # Create or coerce a protobuf request object. - # The request isn't a proto-plus wrapped type, - # so it must be constructed via keyword expansion. - if isinstance(request, dict): - request = locations_pb2.GetLocationRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method.wrap_method( - self._transport.get_location, - 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 = rpc( - request, retry=retry, timeout=timeout, metadata=metadata,) - - # Done; return the response. - return response - - def list_locations( - self, - request: Optional[locations_pb2.ListLocationsRequest] = None, - *, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> locations_pb2.ListLocationsResponse: - r"""Lists information about the supported locations for this service. - - Args: - request (:class:`~.location_pb2.ListLocationsRequest`): - The request object. Request message for - `ListLocations` method. - 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: - ~.location_pb2.ListLocationsResponse: - Response message for ``ListLocations`` method. - """ - # Create or coerce a protobuf request object. - # The request isn't a proto-plus wrapped type, - # so it must be constructed via keyword expansion. - if isinstance(request, dict): - request = locations_pb2.ListLocationsRequest(**request) - - # Wrap the RPC method; this adds retry and timeout information, - # and friendly error handling. - rpc = gapic_v1.method.wrap_method( - self._transport.list_locations, - 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 = rpc( - request, retry=retry, timeout=timeout, metadata=metadata,) - - # Done; return the response. - return response - - -DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) - - -__all__ = ( - "SecurityCenterManagementClient", -) diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/pagers.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/pagers.py deleted file mode 100644 index 3caca15d9f13..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/pagers.py +++ /dev/null @@ -1,744 +0,0 @@ -# -*- 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. -# -from typing import Any, AsyncIterator, Awaitable, Callable, Sequence, Tuple, Optional, Iterator - -from google.cloud.securitycentermanagement_v1.types import security_center_management - - -class ListEffectiveSecurityHealthAnalyticsCustomModulesPager: - """A pager for iterating through ``list_effective_security_health_analytics_custom_modules`` requests. - - This class thinly wraps an initial - :class:`google.cloud.securitycentermanagement_v1.types.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse` object, and - provides an ``__iter__`` method to iterate through its - ``effective_security_health_analytics_custom_modules`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListEffectiveSecurityHealthAnalyticsCustomModules`` requests and continue to iterate - through the ``effective_security_health_analytics_custom_modules`` field on the - corresponding responses. - - All the usual :class:`google.cloud.securitycentermanagement_v1.types.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse` - 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[..., security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse], - request: security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest, - response: security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse, - *, - 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.securitycentermanagement_v1.types.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest): - The initial request object. - response (google.cloud.securitycentermanagement_v1.types.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse): - 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 = security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse]: - 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[security_center_management.EffectiveSecurityHealthAnalyticsCustomModule]: - for page in self.pages: - yield from page.effective_security_health_analytics_custom_modules - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListEffectiveSecurityHealthAnalyticsCustomModulesAsyncPager: - """A pager for iterating through ``list_effective_security_health_analytics_custom_modules`` requests. - - This class thinly wraps an initial - :class:`google.cloud.securitycentermanagement_v1.types.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``effective_security_health_analytics_custom_modules`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListEffectiveSecurityHealthAnalyticsCustomModules`` requests and continue to iterate - through the ``effective_security_health_analytics_custom_modules`` field on the - corresponding responses. - - All the usual :class:`google.cloud.securitycentermanagement_v1.types.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse` - 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[security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse]], - request: security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest, - response: security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse, - *, - 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.securitycentermanagement_v1.types.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest): - The initial request object. - response (google.cloud.securitycentermanagement_v1.types.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse): - 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 = security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse]: - 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[security_center_management.EffectiveSecurityHealthAnalyticsCustomModule]: - async def async_generator(): - async for page in self.pages: - for response in page.effective_security_health_analytics_custom_modules: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListSecurityHealthAnalyticsCustomModulesPager: - """A pager for iterating through ``list_security_health_analytics_custom_modules`` requests. - - This class thinly wraps an initial - :class:`google.cloud.securitycentermanagement_v1.types.ListSecurityHealthAnalyticsCustomModulesResponse` object, and - provides an ``__iter__`` method to iterate through its - ``security_health_analytics_custom_modules`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListSecurityHealthAnalyticsCustomModules`` requests and continue to iterate - through the ``security_health_analytics_custom_modules`` field on the - corresponding responses. - - All the usual :class:`google.cloud.securitycentermanagement_v1.types.ListSecurityHealthAnalyticsCustomModulesResponse` - 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[..., security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse], - request: security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest, - response: security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse, - *, - 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.securitycentermanagement_v1.types.ListSecurityHealthAnalyticsCustomModulesRequest): - The initial request object. - response (google.cloud.securitycentermanagement_v1.types.ListSecurityHealthAnalyticsCustomModulesResponse): - 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 = security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse]: - 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[security_center_management.SecurityHealthAnalyticsCustomModule]: - for page in self.pages: - yield from page.security_health_analytics_custom_modules - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListSecurityHealthAnalyticsCustomModulesAsyncPager: - """A pager for iterating through ``list_security_health_analytics_custom_modules`` requests. - - This class thinly wraps an initial - :class:`google.cloud.securitycentermanagement_v1.types.ListSecurityHealthAnalyticsCustomModulesResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``security_health_analytics_custom_modules`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListSecurityHealthAnalyticsCustomModules`` requests and continue to iterate - through the ``security_health_analytics_custom_modules`` field on the - corresponding responses. - - All the usual :class:`google.cloud.securitycentermanagement_v1.types.ListSecurityHealthAnalyticsCustomModulesResponse` - 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[security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse]], - request: security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest, - response: security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse, - *, - 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.securitycentermanagement_v1.types.ListSecurityHealthAnalyticsCustomModulesRequest): - The initial request object. - response (google.cloud.securitycentermanagement_v1.types.ListSecurityHealthAnalyticsCustomModulesResponse): - 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 = security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse]: - 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[security_center_management.SecurityHealthAnalyticsCustomModule]: - async def async_generator(): - async for page in self.pages: - for response in page.security_health_analytics_custom_modules: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListDescendantSecurityHealthAnalyticsCustomModulesPager: - """A pager for iterating through ``list_descendant_security_health_analytics_custom_modules`` requests. - - This class thinly wraps an initial - :class:`google.cloud.securitycentermanagement_v1.types.ListDescendantSecurityHealthAnalyticsCustomModulesResponse` object, and - provides an ``__iter__`` method to iterate through its - ``security_health_analytics_custom_modules`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListDescendantSecurityHealthAnalyticsCustomModules`` requests and continue to iterate - through the ``security_health_analytics_custom_modules`` field on the - corresponding responses. - - All the usual :class:`google.cloud.securitycentermanagement_v1.types.ListDescendantSecurityHealthAnalyticsCustomModulesResponse` - 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[..., security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse], - request: security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest, - response: security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse, - *, - 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.securitycentermanagement_v1.types.ListDescendantSecurityHealthAnalyticsCustomModulesRequest): - The initial request object. - response (google.cloud.securitycentermanagement_v1.types.ListDescendantSecurityHealthAnalyticsCustomModulesResponse): - 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 = security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse]: - 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[security_center_management.SecurityHealthAnalyticsCustomModule]: - for page in self.pages: - yield from page.security_health_analytics_custom_modules - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListDescendantSecurityHealthAnalyticsCustomModulesAsyncPager: - """A pager for iterating through ``list_descendant_security_health_analytics_custom_modules`` requests. - - This class thinly wraps an initial - :class:`google.cloud.securitycentermanagement_v1.types.ListDescendantSecurityHealthAnalyticsCustomModulesResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``security_health_analytics_custom_modules`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListDescendantSecurityHealthAnalyticsCustomModules`` requests and continue to iterate - through the ``security_health_analytics_custom_modules`` field on the - corresponding responses. - - All the usual :class:`google.cloud.securitycentermanagement_v1.types.ListDescendantSecurityHealthAnalyticsCustomModulesResponse` - 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[security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse]], - request: security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest, - response: security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse, - *, - 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.securitycentermanagement_v1.types.ListDescendantSecurityHealthAnalyticsCustomModulesRequest): - The initial request object. - response (google.cloud.securitycentermanagement_v1.types.ListDescendantSecurityHealthAnalyticsCustomModulesResponse): - 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 = security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse]: - 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[security_center_management.SecurityHealthAnalyticsCustomModule]: - async def async_generator(): - async for page in self.pages: - for response in page.security_health_analytics_custom_modules: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListEffectiveEventThreatDetectionCustomModulesPager: - """A pager for iterating through ``list_effective_event_threat_detection_custom_modules`` requests. - - This class thinly wraps an initial - :class:`google.cloud.securitycentermanagement_v1.types.ListEffectiveEventThreatDetectionCustomModulesResponse` object, and - provides an ``__iter__`` method to iterate through its - ``effective_event_threat_detection_custom_modules`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListEffectiveEventThreatDetectionCustomModules`` requests and continue to iterate - through the ``effective_event_threat_detection_custom_modules`` field on the - corresponding responses. - - All the usual :class:`google.cloud.securitycentermanagement_v1.types.ListEffectiveEventThreatDetectionCustomModulesResponse` - 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[..., security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse], - request: security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest, - response: security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse, - *, - 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.securitycentermanagement_v1.types.ListEffectiveEventThreatDetectionCustomModulesRequest): - The initial request object. - response (google.cloud.securitycentermanagement_v1.types.ListEffectiveEventThreatDetectionCustomModulesResponse): - 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 = security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse]: - 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[security_center_management.EffectiveEventThreatDetectionCustomModule]: - for page in self.pages: - yield from page.effective_event_threat_detection_custom_modules - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListEffectiveEventThreatDetectionCustomModulesAsyncPager: - """A pager for iterating through ``list_effective_event_threat_detection_custom_modules`` requests. - - This class thinly wraps an initial - :class:`google.cloud.securitycentermanagement_v1.types.ListEffectiveEventThreatDetectionCustomModulesResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``effective_event_threat_detection_custom_modules`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListEffectiveEventThreatDetectionCustomModules`` requests and continue to iterate - through the ``effective_event_threat_detection_custom_modules`` field on the - corresponding responses. - - All the usual :class:`google.cloud.securitycentermanagement_v1.types.ListEffectiveEventThreatDetectionCustomModulesResponse` - 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[security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse]], - request: security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest, - response: security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse, - *, - 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.securitycentermanagement_v1.types.ListEffectiveEventThreatDetectionCustomModulesRequest): - The initial request object. - response (google.cloud.securitycentermanagement_v1.types.ListEffectiveEventThreatDetectionCustomModulesResponse): - 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 = security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse]: - 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[security_center_management.EffectiveEventThreatDetectionCustomModule]: - async def async_generator(): - async for page in self.pages: - for response in page.effective_event_threat_detection_custom_modules: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListEventThreatDetectionCustomModulesPager: - """A pager for iterating through ``list_event_threat_detection_custom_modules`` requests. - - This class thinly wraps an initial - :class:`google.cloud.securitycentermanagement_v1.types.ListEventThreatDetectionCustomModulesResponse` object, and - provides an ``__iter__`` method to iterate through its - ``event_threat_detection_custom_modules`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListEventThreatDetectionCustomModules`` requests and continue to iterate - through the ``event_threat_detection_custom_modules`` field on the - corresponding responses. - - All the usual :class:`google.cloud.securitycentermanagement_v1.types.ListEventThreatDetectionCustomModulesResponse` - 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[..., security_center_management.ListEventThreatDetectionCustomModulesResponse], - request: security_center_management.ListEventThreatDetectionCustomModulesRequest, - response: security_center_management.ListEventThreatDetectionCustomModulesResponse, - *, - 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.securitycentermanagement_v1.types.ListEventThreatDetectionCustomModulesRequest): - The initial request object. - response (google.cloud.securitycentermanagement_v1.types.ListEventThreatDetectionCustomModulesResponse): - 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 = security_center_management.ListEventThreatDetectionCustomModulesRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[security_center_management.ListEventThreatDetectionCustomModulesResponse]: - 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[security_center_management.EventThreatDetectionCustomModule]: - for page in self.pages: - yield from page.event_threat_detection_custom_modules - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListEventThreatDetectionCustomModulesAsyncPager: - """A pager for iterating through ``list_event_threat_detection_custom_modules`` requests. - - This class thinly wraps an initial - :class:`google.cloud.securitycentermanagement_v1.types.ListEventThreatDetectionCustomModulesResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``event_threat_detection_custom_modules`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListEventThreatDetectionCustomModules`` requests and continue to iterate - through the ``event_threat_detection_custom_modules`` field on the - corresponding responses. - - All the usual :class:`google.cloud.securitycentermanagement_v1.types.ListEventThreatDetectionCustomModulesResponse` - 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[security_center_management.ListEventThreatDetectionCustomModulesResponse]], - request: security_center_management.ListEventThreatDetectionCustomModulesRequest, - response: security_center_management.ListEventThreatDetectionCustomModulesResponse, - *, - 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.securitycentermanagement_v1.types.ListEventThreatDetectionCustomModulesRequest): - The initial request object. - response (google.cloud.securitycentermanagement_v1.types.ListEventThreatDetectionCustomModulesResponse): - 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 = security_center_management.ListEventThreatDetectionCustomModulesRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[security_center_management.ListEventThreatDetectionCustomModulesResponse]: - 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[security_center_management.EventThreatDetectionCustomModule]: - async def async_generator(): - async for page in self.pages: - for response in page.event_threat_detection_custom_modules: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListDescendantEventThreatDetectionCustomModulesPager: - """A pager for iterating through ``list_descendant_event_threat_detection_custom_modules`` requests. - - This class thinly wraps an initial - :class:`google.cloud.securitycentermanagement_v1.types.ListDescendantEventThreatDetectionCustomModulesResponse` object, and - provides an ``__iter__`` method to iterate through its - ``event_threat_detection_custom_modules`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``ListDescendantEventThreatDetectionCustomModules`` requests and continue to iterate - through the ``event_threat_detection_custom_modules`` field on the - corresponding responses. - - All the usual :class:`google.cloud.securitycentermanagement_v1.types.ListDescendantEventThreatDetectionCustomModulesResponse` - 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[..., security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse], - request: security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest, - response: security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse, - *, - 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.securitycentermanagement_v1.types.ListDescendantEventThreatDetectionCustomModulesRequest): - The initial request object. - response (google.cloud.securitycentermanagement_v1.types.ListDescendantEventThreatDetectionCustomModulesResponse): - 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 = security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterator[security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse]: - 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[security_center_management.EventThreatDetectionCustomModule]: - for page in self.pages: - yield from page.event_threat_detection_custom_modules - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) - - -class ListDescendantEventThreatDetectionCustomModulesAsyncPager: - """A pager for iterating through ``list_descendant_event_threat_detection_custom_modules`` requests. - - This class thinly wraps an initial - :class:`google.cloud.securitycentermanagement_v1.types.ListDescendantEventThreatDetectionCustomModulesResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``event_threat_detection_custom_modules`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``ListDescendantEventThreatDetectionCustomModules`` requests and continue to iterate - through the ``event_threat_detection_custom_modules`` field on the - corresponding responses. - - All the usual :class:`google.cloud.securitycentermanagement_v1.types.ListDescendantEventThreatDetectionCustomModulesResponse` - 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[security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse]], - request: security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest, - response: security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse, - *, - 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.securitycentermanagement_v1.types.ListDescendantEventThreatDetectionCustomModulesRequest): - The initial request object. - response (google.cloud.securitycentermanagement_v1.types.ListDescendantEventThreatDetectionCustomModulesResponse): - 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 = security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterator[security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse]: - 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[security_center_management.EventThreatDetectionCustomModule]: - async def async_generator(): - async for page in self.pages: - for response in page.event_threat_detection_custom_modules: - yield response - - return async_generator() - - def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/__init__.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/__init__.py deleted file mode 100644 index 33264c4d84cf..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/__init__.py +++ /dev/null @@ -1,38 +0,0 @@ -# -*- 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. -# -from collections import OrderedDict -from typing import Dict, Type - -from .base import SecurityCenterManagementTransport -from .grpc import SecurityCenterManagementGrpcTransport -from .grpc_asyncio import SecurityCenterManagementGrpcAsyncIOTransport -from .rest import SecurityCenterManagementRestTransport -from .rest import SecurityCenterManagementRestInterceptor - - -# Compile a registry of transports. -_transport_registry = OrderedDict() # type: Dict[str, Type[SecurityCenterManagementTransport]] -_transport_registry['grpc'] = SecurityCenterManagementGrpcTransport -_transport_registry['grpc_asyncio'] = SecurityCenterManagementGrpcAsyncIOTransport -_transport_registry['rest'] = SecurityCenterManagementRestTransport - -__all__ = ( - 'SecurityCenterManagementTransport', - 'SecurityCenterManagementGrpcTransport', - 'SecurityCenterManagementGrpcAsyncIOTransport', - 'SecurityCenterManagementRestTransport', - 'SecurityCenterManagementRestInterceptor', -) diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/base.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/base.py deleted file mode 100644 index a7b4edfb139e..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/base.py +++ /dev/null @@ -1,488 +0,0 @@ -# -*- 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. -# -import abc -from typing import Awaitable, Callable, Dict, Optional, Sequence, Union - -from google.cloud.securitycentermanagement_v1 import gapic_version as package_version - -import google.auth # type: ignore -import google.api_core -from google.api_core import exceptions as core_exceptions -from google.api_core import gapic_v1 -from google.api_core import retry as retries -from google.auth import credentials as ga_credentials # type: ignore -from google.oauth2 import service_account # type: ignore - -from google.cloud.location import locations_pb2 # type: ignore -from google.cloud.securitycentermanagement_v1.types import security_center_management -from google.protobuf import empty_pb2 # type: ignore - -DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__) - - -class SecurityCenterManagementTransport(abc.ABC): - """Abstract transport class for SecurityCenterManagement.""" - - AUTH_SCOPES = ( - 'https://www.googleapis.com/auth/cloud-platform', - ) - - DEFAULT_HOST: str = 'securitycentermanagement.googleapis.com' - def __init__( - self, *, - host: str = DEFAULT_HOST, - credentials: Optional[ga_credentials.Credentials] = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - quota_project_id: Optional[str] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - always_use_jwt_access: Optional[bool] = False, - api_audience: Optional[str] = None, - **kwargs, - ) -> None: - """Instantiate the transport. - - Args: - host (Optional[str]): - The hostname to connect to. - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is mutually exclusive with credentials. - scopes (Optional[Sequence[str]]): A list of scopes. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing - your own client library. - always_use_jwt_access (Optional[bool]): Whether self signed JWT should - be used for service account credentials. - """ - - scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES} - - # Save the scopes. - self._scopes = scopes - - # If no credentials are provided, then determine the appropriate - # defaults. - if credentials and credentials_file: - raise core_exceptions.DuplicateCredentialArgs("'credentials_file' and 'credentials' are mutually exclusive") - - if credentials_file is not None: - credentials, _ = google.auth.load_credentials_from_file( - credentials_file, - **scopes_kwargs, - quota_project_id=quota_project_id - ) - elif credentials is None: - credentials, _ = google.auth.default(**scopes_kwargs, quota_project_id=quota_project_id) - # Don't apply audience if the credentials file passed from user. - if hasattr(credentials, "with_gdch_audience"): - credentials = credentials.with_gdch_audience(api_audience if api_audience else host) - - # If the credentials are service account credentials, then always try to use self signed JWT. - if always_use_jwt_access and isinstance(credentials, service_account.Credentials) and hasattr(service_account.Credentials, "with_always_use_jwt_access"): - credentials = credentials.with_always_use_jwt_access(True) - - # Save the credentials. - self._credentials = credentials - - # Save the hostname. Default to port 443 (HTTPS) if none is specified. - if ':' not in host: - host += ':443' - self._host = host - - def _prep_wrapped_messages(self, client_info): - # Precompute the wrapped methods. - self._wrapped_methods = { - self.list_effective_security_health_analytics_custom_modules: gapic_v1.method.wrap_method( - self.list_effective_security_health_analytics_custom_modules, - default_retry=retries.Retry( -initial=0.1,maximum=60.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.DeadlineExceeded, - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.get_effective_security_health_analytics_custom_module: gapic_v1.method.wrap_method( - self.get_effective_security_health_analytics_custom_module, - default_retry=retries.Retry( -initial=0.1,maximum=60.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.DeadlineExceeded, - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.list_security_health_analytics_custom_modules: gapic_v1.method.wrap_method( - self.list_security_health_analytics_custom_modules, - default_retry=retries.Retry( -initial=0.1,maximum=60.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.DeadlineExceeded, - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.list_descendant_security_health_analytics_custom_modules: gapic_v1.method.wrap_method( - self.list_descendant_security_health_analytics_custom_modules, - default_retry=retries.Retry( -initial=0.1,maximum=60.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.DeadlineExceeded, - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.get_security_health_analytics_custom_module: gapic_v1.method.wrap_method( - self.get_security_health_analytics_custom_module, - default_retry=retries.Retry( -initial=0.1,maximum=60.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.DeadlineExceeded, - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.create_security_health_analytics_custom_module: gapic_v1.method.wrap_method( - self.create_security_health_analytics_custom_module, - default_timeout=60.0, - client_info=client_info, - ), - self.update_security_health_analytics_custom_module: gapic_v1.method.wrap_method( - self.update_security_health_analytics_custom_module, - default_timeout=60.0, - client_info=client_info, - ), - self.delete_security_health_analytics_custom_module: gapic_v1.method.wrap_method( - self.delete_security_health_analytics_custom_module, - default_timeout=60.0, - client_info=client_info, - ), - self.simulate_security_health_analytics_custom_module: gapic_v1.method.wrap_method( - self.simulate_security_health_analytics_custom_module, - default_retry=retries.Retry( -initial=0.1,maximum=60.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.DeadlineExceeded, - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.list_effective_event_threat_detection_custom_modules: gapic_v1.method.wrap_method( - self.list_effective_event_threat_detection_custom_modules, - default_retry=retries.Retry( -initial=0.1,maximum=60.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.DeadlineExceeded, - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.get_effective_event_threat_detection_custom_module: gapic_v1.method.wrap_method( - self.get_effective_event_threat_detection_custom_module, - default_retry=retries.Retry( -initial=0.1,maximum=60.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.DeadlineExceeded, - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.list_event_threat_detection_custom_modules: gapic_v1.method.wrap_method( - self.list_event_threat_detection_custom_modules, - default_retry=retries.Retry( -initial=0.1,maximum=60.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.DeadlineExceeded, - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.list_descendant_event_threat_detection_custom_modules: gapic_v1.method.wrap_method( - self.list_descendant_event_threat_detection_custom_modules, - default_retry=retries.Retry( -initial=0.1,maximum=60.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.DeadlineExceeded, - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.get_event_threat_detection_custom_module: gapic_v1.method.wrap_method( - self.get_event_threat_detection_custom_module, - default_retry=retries.Retry( -initial=0.1,maximum=60.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.DeadlineExceeded, - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - self.create_event_threat_detection_custom_module: gapic_v1.method.wrap_method( - self.create_event_threat_detection_custom_module, - default_timeout=60.0, - client_info=client_info, - ), - self.update_event_threat_detection_custom_module: gapic_v1.method.wrap_method( - self.update_event_threat_detection_custom_module, - default_timeout=60.0, - client_info=client_info, - ), - self.delete_event_threat_detection_custom_module: gapic_v1.method.wrap_method( - self.delete_event_threat_detection_custom_module, - default_timeout=60.0, - client_info=client_info, - ), - self.validate_event_threat_detection_custom_module: gapic_v1.method.wrap_method( - self.validate_event_threat_detection_custom_module, - default_retry=retries.Retry( -initial=0.1,maximum=60.0,multiplier=1.3, predicate=retries.if_exception_type( - core_exceptions.DeadlineExceeded, - core_exceptions.ServiceUnavailable, - ), - deadline=60.0, - ), - default_timeout=60.0, - client_info=client_info, - ), - } - - def close(self): - """Closes resources associated with the transport. - - .. warning:: - Only call this method if the transport is NOT shared - with other clients - this may cause errors in other clients! - """ - raise NotImplementedError() - - @property - def list_effective_security_health_analytics_custom_modules(self) -> Callable[ - [security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest], - Union[ - security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse, - Awaitable[security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse] - ]]: - raise NotImplementedError() - - @property - def get_effective_security_health_analytics_custom_module(self) -> Callable[ - [security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest], - Union[ - security_center_management.EffectiveSecurityHealthAnalyticsCustomModule, - Awaitable[security_center_management.EffectiveSecurityHealthAnalyticsCustomModule] - ]]: - raise NotImplementedError() - - @property - def list_security_health_analytics_custom_modules(self) -> Callable[ - [security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest], - Union[ - security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse, - Awaitable[security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse] - ]]: - raise NotImplementedError() - - @property - def list_descendant_security_health_analytics_custom_modules(self) -> Callable[ - [security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest], - Union[ - security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse, - Awaitable[security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse] - ]]: - raise NotImplementedError() - - @property - def get_security_health_analytics_custom_module(self) -> Callable[ - [security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest], - Union[ - security_center_management.SecurityHealthAnalyticsCustomModule, - Awaitable[security_center_management.SecurityHealthAnalyticsCustomModule] - ]]: - raise NotImplementedError() - - @property - def create_security_health_analytics_custom_module(self) -> Callable[ - [security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest], - Union[ - security_center_management.SecurityHealthAnalyticsCustomModule, - Awaitable[security_center_management.SecurityHealthAnalyticsCustomModule] - ]]: - raise NotImplementedError() - - @property - def update_security_health_analytics_custom_module(self) -> Callable[ - [security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest], - Union[ - security_center_management.SecurityHealthAnalyticsCustomModule, - Awaitable[security_center_management.SecurityHealthAnalyticsCustomModule] - ]]: - raise NotImplementedError() - - @property - def delete_security_health_analytics_custom_module(self) -> Callable[ - [security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest], - Union[ - empty_pb2.Empty, - Awaitable[empty_pb2.Empty] - ]]: - raise NotImplementedError() - - @property - def simulate_security_health_analytics_custom_module(self) -> Callable[ - [security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest], - Union[ - security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse, - Awaitable[security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse] - ]]: - raise NotImplementedError() - - @property - def list_effective_event_threat_detection_custom_modules(self) -> Callable[ - [security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest], - Union[ - security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse, - Awaitable[security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse] - ]]: - raise NotImplementedError() - - @property - def get_effective_event_threat_detection_custom_module(self) -> Callable[ - [security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest], - Union[ - security_center_management.EffectiveEventThreatDetectionCustomModule, - Awaitable[security_center_management.EffectiveEventThreatDetectionCustomModule] - ]]: - raise NotImplementedError() - - @property - def list_event_threat_detection_custom_modules(self) -> Callable[ - [security_center_management.ListEventThreatDetectionCustomModulesRequest], - Union[ - security_center_management.ListEventThreatDetectionCustomModulesResponse, - Awaitable[security_center_management.ListEventThreatDetectionCustomModulesResponse] - ]]: - raise NotImplementedError() - - @property - def list_descendant_event_threat_detection_custom_modules(self) -> Callable[ - [security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest], - Union[ - security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse, - Awaitable[security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse] - ]]: - raise NotImplementedError() - - @property - def get_event_threat_detection_custom_module(self) -> Callable[ - [security_center_management.GetEventThreatDetectionCustomModuleRequest], - Union[ - security_center_management.EventThreatDetectionCustomModule, - Awaitable[security_center_management.EventThreatDetectionCustomModule] - ]]: - raise NotImplementedError() - - @property - def create_event_threat_detection_custom_module(self) -> Callable[ - [security_center_management.CreateEventThreatDetectionCustomModuleRequest], - Union[ - security_center_management.EventThreatDetectionCustomModule, - Awaitable[security_center_management.EventThreatDetectionCustomModule] - ]]: - raise NotImplementedError() - - @property - def update_event_threat_detection_custom_module(self) -> Callable[ - [security_center_management.UpdateEventThreatDetectionCustomModuleRequest], - Union[ - security_center_management.EventThreatDetectionCustomModule, - Awaitable[security_center_management.EventThreatDetectionCustomModule] - ]]: - raise NotImplementedError() - - @property - def delete_event_threat_detection_custom_module(self) -> Callable[ - [security_center_management.DeleteEventThreatDetectionCustomModuleRequest], - Union[ - empty_pb2.Empty, - Awaitable[empty_pb2.Empty] - ]]: - raise NotImplementedError() - - @property - def validate_event_threat_detection_custom_module(self) -> Callable[ - [security_center_management.ValidateEventThreatDetectionCustomModuleRequest], - Union[ - security_center_management.ValidateEventThreatDetectionCustomModuleResponse, - Awaitable[security_center_management.ValidateEventThreatDetectionCustomModuleResponse] - ]]: - raise NotImplementedError() - - @property - def get_location(self, - ) -> Callable[ - [locations_pb2.GetLocationRequest], - Union[locations_pb2.Location, Awaitable[locations_pb2.Location]], - ]: - raise NotImplementedError() - - @property - def list_locations(self, - ) -> Callable[ - [locations_pb2.ListLocationsRequest], - Union[locations_pb2.ListLocationsResponse, Awaitable[locations_pb2.ListLocationsResponse]], - ]: - raise NotImplementedError() - - @property - def kind(self) -> str: - raise NotImplementedError() - - -__all__ = ( - 'SecurityCenterManagementTransport', -) diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/grpc.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/grpc.py deleted file mode 100644 index 31d6cc96af89..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/grpc.py +++ /dev/null @@ -1,818 +0,0 @@ -# -*- 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. -# -import warnings -from typing import Callable, Dict, Optional, Sequence, Tuple, Union - -from google.api_core import grpc_helpers -from google.api_core import gapic_v1 -import google.auth # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore - -import grpc # type: ignore - -from google.cloud.location import locations_pb2 # type: ignore -from google.cloud.securitycentermanagement_v1.types import security_center_management -from google.protobuf import empty_pb2 # type: ignore -from .base import SecurityCenterManagementTransport, DEFAULT_CLIENT_INFO - - -class SecurityCenterManagementGrpcTransport(SecurityCenterManagementTransport): - """gRPC backend transport for SecurityCenterManagement. - - Service describing handlers for resources - - This class defines the same methods as the primary client, so the - primary client can load the underlying transport implementation - and call it. - - It sends protocol buffers over the wire using gRPC (which is built on - top of HTTP/2); the ``grpcio`` package must be installed. - """ - _stubs: Dict[str, Callable] - - def __init__(self, *, - host: str = 'securitycentermanagement.googleapis.com', - credentials: Optional[ga_credentials.Credentials] = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - channel: Optional[grpc.Channel] = None, - api_mtls_endpoint: Optional[str] = None, - client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None, - ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None, - client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None, - quota_project_id: Optional[str] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - always_use_jwt_access: Optional[bool] = False, - api_audience: Optional[str] = None, - ) -> None: - """Instantiate the transport. - - Args: - host (Optional[str]): - The hostname to connect to. - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - This argument is ignored if ``channel`` is provided. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is ignored if ``channel`` is provided. - scopes (Optional(Sequence[str])): A list of scopes. This argument is - ignored if ``channel`` is provided. - channel (Optional[grpc.Channel]): A ``Channel`` instance through - which to make calls. - api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. - If provided, it overrides the ``host`` argument and tries to create - a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or application default SSL credentials. - client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): - Deprecated. A callback to provide client SSL certificate bytes and - private key bytes, both in PEM format. It is ignored if - ``api_mtls_endpoint`` is None. - ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for the grpc channel. It is ignored if ``channel`` is provided. - client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): - A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure a mutual TLS channel. It is - ignored if ``channel`` or ``ssl_channel_credentials`` is provided. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing - your own client library. - always_use_jwt_access (Optional[bool]): Whether self signed JWT should - be used for service account credentials. - - Raises: - google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport - creation failed for any reason. - google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` - and ``credentials_file`` are passed. - """ - self._grpc_channel = None - self._ssl_channel_credentials = ssl_channel_credentials - self._stubs: Dict[str, Callable] = {} - - if api_mtls_endpoint: - warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) - if client_cert_source: - warnings.warn("client_cert_source is deprecated", DeprecationWarning) - - if channel: - # Ignore credentials if a channel was passed. - credentials = False - # If a channel was explicitly provided, set it. - self._grpc_channel = channel - self._ssl_channel_credentials = None - - else: - if api_mtls_endpoint: - host = api_mtls_endpoint - - # Create SSL credentials with client_cert_source or application - # default SSL credentials. - if client_cert_source: - cert, key = client_cert_source() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - else: - self._ssl_channel_credentials = SslCredentials().ssl_credentials - - else: - if client_cert_source_for_mtls and not ssl_channel_credentials: - cert, key = client_cert_source_for_mtls() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - - # The base transport sets the host, credentials and scopes - super().__init__( - host=host, - credentials=credentials, - credentials_file=credentials_file, - scopes=scopes, - quota_project_id=quota_project_id, - client_info=client_info, - always_use_jwt_access=always_use_jwt_access, - api_audience=api_audience, - ) - - if not self._grpc_channel: - self._grpc_channel = type(self).create_channel( - self._host, - # use the credentials which are saved - credentials=self._credentials, - # Set ``credentials_file`` to ``None`` here as - # the credentials that we saved earlier should be used. - credentials_file=None, - scopes=self._scopes, - ssl_credentials=self._ssl_channel_credentials, - quota_project_id=quota_project_id, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - # Wrap messages. This must be done after self._grpc_channel exists - self._prep_wrapped_messages(client_info) - - @classmethod - def create_channel(cls, - host: str = 'securitycentermanagement.googleapis.com', - credentials: Optional[ga_credentials.Credentials] = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - quota_project_id: Optional[str] = None, - **kwargs) -> grpc.Channel: - """Create and return a gRPC channel object. - Args: - host (Optional[str]): The host for the channel to use. - credentials (Optional[~.Credentials]): The - authorization credentials to attach to requests. These - credentials identify this application to the service. If - none are specified, the client will attempt to ascertain - the credentials from the environment. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is mutually exclusive with credentials. - scopes (Optional[Sequence[str]]): A optional list of scopes needed for this - service. These are only used when credentials are not specified and - are passed to :func:`google.auth.default`. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - kwargs (Optional[dict]): Keyword arguments, which are passed to the - channel creation. - Returns: - grpc.Channel: A gRPC channel object. - - Raises: - google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` - and ``credentials_file`` are passed. - """ - - return grpc_helpers.create_channel( - host, - credentials=credentials, - credentials_file=credentials_file, - quota_project_id=quota_project_id, - default_scopes=cls.AUTH_SCOPES, - scopes=scopes, - default_host=cls.DEFAULT_HOST, - **kwargs - ) - - @property - def grpc_channel(self) -> grpc.Channel: - """Return the channel designed to connect to this service. - """ - return self._grpc_channel - - @property - def list_effective_security_health_analytics_custom_modules(self) -> Callable[ - [security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest], - security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse]: - r"""Return a callable for the list effective security health - analytics custom modules method over gRPC. - - Returns a list of all - EffectiveSecurityHealthAnalyticsCustomModules for the - given parent. This includes resident modules defined at - the scope of the parent, and inherited modules, - inherited from CRM ancestors (no descendants). - - Returns: - Callable[[~.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest], - ~.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse]: - 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_effective_security_health_analytics_custom_modules' not in self._stubs: - self._stubs['list_effective_security_health_analytics_custom_modules'] = self.grpc_channel.unary_unary( - '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/ListEffectiveSecurityHealthAnalyticsCustomModules', - request_serializer=security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest.serialize, - response_deserializer=security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse.deserialize, - ) - return self._stubs['list_effective_security_health_analytics_custom_modules'] - - @property - def get_effective_security_health_analytics_custom_module(self) -> Callable[ - [security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest], - security_center_management.EffectiveSecurityHealthAnalyticsCustomModule]: - r"""Return a callable for the get effective security health - analytics custom module method over gRPC. - - Gets details of a single - EffectiveSecurityHealthAnalyticsCustomModule. - - Returns: - Callable[[~.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest], - ~.EffectiveSecurityHealthAnalyticsCustomModule]: - 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_effective_security_health_analytics_custom_module' not in self._stubs: - self._stubs['get_effective_security_health_analytics_custom_module'] = self.grpc_channel.unary_unary( - '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/GetEffectiveSecurityHealthAnalyticsCustomModule', - request_serializer=security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest.serialize, - response_deserializer=security_center_management.EffectiveSecurityHealthAnalyticsCustomModule.deserialize, - ) - return self._stubs['get_effective_security_health_analytics_custom_module'] - - @property - def list_security_health_analytics_custom_modules(self) -> Callable[ - [security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest], - security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse]: - r"""Return a callable for the list security health analytics - custom modules method over gRPC. - - Returns a list of all - SecurityHealthAnalyticsCustomModules for the given - parent. This includes resident modules defined at the - scope of the parent, and inherited modules, inherited - from CRM ancestors (no descendants). - - Returns: - Callable[[~.ListSecurityHealthAnalyticsCustomModulesRequest], - ~.ListSecurityHealthAnalyticsCustomModulesResponse]: - 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_security_health_analytics_custom_modules' not in self._stubs: - self._stubs['list_security_health_analytics_custom_modules'] = self.grpc_channel.unary_unary( - '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/ListSecurityHealthAnalyticsCustomModules', - request_serializer=security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest.serialize, - response_deserializer=security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse.deserialize, - ) - return self._stubs['list_security_health_analytics_custom_modules'] - - @property - def list_descendant_security_health_analytics_custom_modules(self) -> Callable[ - [security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest], - security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse]: - r"""Return a callable for the list descendant security - health analytics custom modules method over gRPC. - - Returns a list of all resident - SecurityHealthAnalyticsCustomModules under the given CRM - parent and all of the parent’s CRM descendants. - - Returns: - Callable[[~.ListDescendantSecurityHealthAnalyticsCustomModulesRequest], - ~.ListDescendantSecurityHealthAnalyticsCustomModulesResponse]: - 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_descendant_security_health_analytics_custom_modules' not in self._stubs: - self._stubs['list_descendant_security_health_analytics_custom_modules'] = self.grpc_channel.unary_unary( - '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/ListDescendantSecurityHealthAnalyticsCustomModules', - request_serializer=security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest.serialize, - response_deserializer=security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse.deserialize, - ) - return self._stubs['list_descendant_security_health_analytics_custom_modules'] - - @property - def get_security_health_analytics_custom_module(self) -> Callable[ - [security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest], - security_center_management.SecurityHealthAnalyticsCustomModule]: - r"""Return a callable for the get security health analytics - custom module method over gRPC. - - Retrieves a SecurityHealthAnalyticsCustomModule. - - Returns: - Callable[[~.GetSecurityHealthAnalyticsCustomModuleRequest], - ~.SecurityHealthAnalyticsCustomModule]: - 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_security_health_analytics_custom_module' not in self._stubs: - self._stubs['get_security_health_analytics_custom_module'] = self.grpc_channel.unary_unary( - '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/GetSecurityHealthAnalyticsCustomModule', - request_serializer=security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest.serialize, - response_deserializer=security_center_management.SecurityHealthAnalyticsCustomModule.deserialize, - ) - return self._stubs['get_security_health_analytics_custom_module'] - - @property - def create_security_health_analytics_custom_module(self) -> Callable[ - [security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest], - security_center_management.SecurityHealthAnalyticsCustomModule]: - r"""Return a callable for the create security health - analytics custom module method over gRPC. - - Creates a resident - SecurityHealthAnalyticsCustomModule at the scope of the - given CRM parent, and also creates inherited - SecurityHealthAnalyticsCustomModules for all CRM - descendants of the given parent. These modules are - enabled by default. - - Returns: - Callable[[~.CreateSecurityHealthAnalyticsCustomModuleRequest], - ~.SecurityHealthAnalyticsCustomModule]: - 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_security_health_analytics_custom_module' not in self._stubs: - self._stubs['create_security_health_analytics_custom_module'] = self.grpc_channel.unary_unary( - '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/CreateSecurityHealthAnalyticsCustomModule', - request_serializer=security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest.serialize, - response_deserializer=security_center_management.SecurityHealthAnalyticsCustomModule.deserialize, - ) - return self._stubs['create_security_health_analytics_custom_module'] - - @property - def update_security_health_analytics_custom_module(self) -> Callable[ - [security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest], - security_center_management.SecurityHealthAnalyticsCustomModule]: - r"""Return a callable for the update security health - analytics custom module method over gRPC. - - Updates the SecurityHealthAnalyticsCustomModule under - the given name based on the given update mask. Updating - the enablement state is supported on both resident and - inherited modules (though resident modules cannot have - an enablement state of "inherited"). Updating the - display name and custom config of a module is supported - on resident modules only. - - Returns: - Callable[[~.UpdateSecurityHealthAnalyticsCustomModuleRequest], - ~.SecurityHealthAnalyticsCustomModule]: - 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_security_health_analytics_custom_module' not in self._stubs: - self._stubs['update_security_health_analytics_custom_module'] = self.grpc_channel.unary_unary( - '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/UpdateSecurityHealthAnalyticsCustomModule', - request_serializer=security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest.serialize, - response_deserializer=security_center_management.SecurityHealthAnalyticsCustomModule.deserialize, - ) - return self._stubs['update_security_health_analytics_custom_module'] - - @property - def delete_security_health_analytics_custom_module(self) -> Callable[ - [security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest], - empty_pb2.Empty]: - r"""Return a callable for the delete security health - analytics custom module method over gRPC. - - Deletes the specified - SecurityHealthAnalyticsCustomModule and all of its - descendants in the CRM hierarchy. This method is only - supported for resident custom modules. - - Returns: - Callable[[~.DeleteSecurityHealthAnalyticsCustomModuleRequest], - ~.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_security_health_analytics_custom_module' not in self._stubs: - self._stubs['delete_security_health_analytics_custom_module'] = self.grpc_channel.unary_unary( - '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/DeleteSecurityHealthAnalyticsCustomModule', - request_serializer=security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_security_health_analytics_custom_module'] - - @property - def simulate_security_health_analytics_custom_module(self) -> Callable[ - [security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest], - security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse]: - r"""Return a callable for the simulate security health - analytics custom module method over gRPC. - - Simulates a given SecurityHealthAnalyticsCustomModule - and Resource. - - Returns: - Callable[[~.SimulateSecurityHealthAnalyticsCustomModuleRequest], - ~.SimulateSecurityHealthAnalyticsCustomModuleResponse]: - 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 'simulate_security_health_analytics_custom_module' not in self._stubs: - self._stubs['simulate_security_health_analytics_custom_module'] = self.grpc_channel.unary_unary( - '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/SimulateSecurityHealthAnalyticsCustomModule', - request_serializer=security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest.serialize, - response_deserializer=security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse.deserialize, - ) - return self._stubs['simulate_security_health_analytics_custom_module'] - - @property - def list_effective_event_threat_detection_custom_modules(self) -> Callable[ - [security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest], - security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse]: - r"""Return a callable for the list effective event threat - detection custom modules method over gRPC. - - Lists all effective Event Threat Detection custom - modules for the given parent. This includes resident - modules defined at the scope of the parent along with - modules inherited from its ancestors. - - Returns: - Callable[[~.ListEffectiveEventThreatDetectionCustomModulesRequest], - ~.ListEffectiveEventThreatDetectionCustomModulesResponse]: - 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_effective_event_threat_detection_custom_modules' not in self._stubs: - self._stubs['list_effective_event_threat_detection_custom_modules'] = self.grpc_channel.unary_unary( - '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/ListEffectiveEventThreatDetectionCustomModules', - request_serializer=security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest.serialize, - response_deserializer=security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse.deserialize, - ) - return self._stubs['list_effective_event_threat_detection_custom_modules'] - - @property - def get_effective_event_threat_detection_custom_module(self) -> Callable[ - [security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest], - security_center_management.EffectiveEventThreatDetectionCustomModule]: - r"""Return a callable for the get effective event threat - detection custom module method over gRPC. - - Gets an effective ETD custom module. Retrieves the effective - module at the given level. The difference between an - EffectiveCustomModule and a CustomModule is that the fields for - an EffectiveCustomModule are computed from ancestors if needed. - For example, the enablement_state for a CustomModule can be - either ENABLED, DISABLED, or INHERITED. Where as the - enablement_state for an EffectiveCustomModule is always computed - to ENABLED or DISABLED (the effective enablement_state). - - Returns: - Callable[[~.GetEffectiveEventThreatDetectionCustomModuleRequest], - ~.EffectiveEventThreatDetectionCustomModule]: - 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_effective_event_threat_detection_custom_module' not in self._stubs: - self._stubs['get_effective_event_threat_detection_custom_module'] = self.grpc_channel.unary_unary( - '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/GetEffectiveEventThreatDetectionCustomModule', - request_serializer=security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest.serialize, - response_deserializer=security_center_management.EffectiveEventThreatDetectionCustomModule.deserialize, - ) - return self._stubs['get_effective_event_threat_detection_custom_module'] - - @property - def list_event_threat_detection_custom_modules(self) -> Callable[ - [security_center_management.ListEventThreatDetectionCustomModulesRequest], - security_center_management.ListEventThreatDetectionCustomModulesResponse]: - r"""Return a callable for the list event threat detection - custom modules method over gRPC. - - Lists all Event Threat Detection custom modules for - the given Resource Manager parent. This includes - resident modules defined at the scope of the parent - along with modules inherited from ancestors. - - Returns: - Callable[[~.ListEventThreatDetectionCustomModulesRequest], - ~.ListEventThreatDetectionCustomModulesResponse]: - 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_event_threat_detection_custom_modules' not in self._stubs: - self._stubs['list_event_threat_detection_custom_modules'] = self.grpc_channel.unary_unary( - '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/ListEventThreatDetectionCustomModules', - request_serializer=security_center_management.ListEventThreatDetectionCustomModulesRequest.serialize, - response_deserializer=security_center_management.ListEventThreatDetectionCustomModulesResponse.deserialize, - ) - return self._stubs['list_event_threat_detection_custom_modules'] - - @property - def list_descendant_event_threat_detection_custom_modules(self) -> Callable[ - [security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest], - security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse]: - r"""Return a callable for the list descendant event threat - detection custom modules method over gRPC. - - Lists all resident Event Threat Detection custom - modules under the given Resource Manager parent and its - descendants. - - Returns: - Callable[[~.ListDescendantEventThreatDetectionCustomModulesRequest], - ~.ListDescendantEventThreatDetectionCustomModulesResponse]: - 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_descendant_event_threat_detection_custom_modules' not in self._stubs: - self._stubs['list_descendant_event_threat_detection_custom_modules'] = self.grpc_channel.unary_unary( - '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/ListDescendantEventThreatDetectionCustomModules', - request_serializer=security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest.serialize, - response_deserializer=security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse.deserialize, - ) - return self._stubs['list_descendant_event_threat_detection_custom_modules'] - - @property - def get_event_threat_detection_custom_module(self) -> Callable[ - [security_center_management.GetEventThreatDetectionCustomModuleRequest], - security_center_management.EventThreatDetectionCustomModule]: - r"""Return a callable for the get event threat detection - custom module method over gRPC. - - Gets an Event Threat Detection custom module. - - Returns: - Callable[[~.GetEventThreatDetectionCustomModuleRequest], - ~.EventThreatDetectionCustomModule]: - 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_event_threat_detection_custom_module' not in self._stubs: - self._stubs['get_event_threat_detection_custom_module'] = self.grpc_channel.unary_unary( - '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/GetEventThreatDetectionCustomModule', - request_serializer=security_center_management.GetEventThreatDetectionCustomModuleRequest.serialize, - response_deserializer=security_center_management.EventThreatDetectionCustomModule.deserialize, - ) - return self._stubs['get_event_threat_detection_custom_module'] - - @property - def create_event_threat_detection_custom_module(self) -> Callable[ - [security_center_management.CreateEventThreatDetectionCustomModuleRequest], - security_center_management.EventThreatDetectionCustomModule]: - r"""Return a callable for the create event threat detection - custom module method over gRPC. - - Creates a resident Event Threat Detection custom - module at the scope of the given Resource Manager - parent, and also creates inherited custom modules for - all descendants of the given parent. These modules are - enabled by default. - - Returns: - Callable[[~.CreateEventThreatDetectionCustomModuleRequest], - ~.EventThreatDetectionCustomModule]: - 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_event_threat_detection_custom_module' not in self._stubs: - self._stubs['create_event_threat_detection_custom_module'] = self.grpc_channel.unary_unary( - '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/CreateEventThreatDetectionCustomModule', - request_serializer=security_center_management.CreateEventThreatDetectionCustomModuleRequest.serialize, - response_deserializer=security_center_management.EventThreatDetectionCustomModule.deserialize, - ) - return self._stubs['create_event_threat_detection_custom_module'] - - @property - def update_event_threat_detection_custom_module(self) -> Callable[ - [security_center_management.UpdateEventThreatDetectionCustomModuleRequest], - security_center_management.EventThreatDetectionCustomModule]: - r"""Return a callable for the update event threat detection - custom module method over gRPC. - - Updates the Event Threat Detection custom module with - the given name based on the given update mask. Updating - the enablement state is supported for both resident and - inherited modules (though resident modules cannot have - an enablement state of "inherited"). Updating the - display name or configuration of a module is supported - for resident modules only. The type of a module cannot - be changed. - - Returns: - Callable[[~.UpdateEventThreatDetectionCustomModuleRequest], - ~.EventThreatDetectionCustomModule]: - 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_event_threat_detection_custom_module' not in self._stubs: - self._stubs['update_event_threat_detection_custom_module'] = self.grpc_channel.unary_unary( - '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/UpdateEventThreatDetectionCustomModule', - request_serializer=security_center_management.UpdateEventThreatDetectionCustomModuleRequest.serialize, - response_deserializer=security_center_management.EventThreatDetectionCustomModule.deserialize, - ) - return self._stubs['update_event_threat_detection_custom_module'] - - @property - def delete_event_threat_detection_custom_module(self) -> Callable[ - [security_center_management.DeleteEventThreatDetectionCustomModuleRequest], - empty_pb2.Empty]: - r"""Return a callable for the delete event threat detection - custom module method over gRPC. - - Deletes the specified Event Threat Detection custom - module and all of its descendants in the Resource - Manager hierarchy. This method is only supported for - resident custom modules. - - Returns: - Callable[[~.DeleteEventThreatDetectionCustomModuleRequest], - ~.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_event_threat_detection_custom_module' not in self._stubs: - self._stubs['delete_event_threat_detection_custom_module'] = self.grpc_channel.unary_unary( - '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/DeleteEventThreatDetectionCustomModule', - request_serializer=security_center_management.DeleteEventThreatDetectionCustomModuleRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_event_threat_detection_custom_module'] - - @property - def validate_event_threat_detection_custom_module(self) -> Callable[ - [security_center_management.ValidateEventThreatDetectionCustomModuleRequest], - security_center_management.ValidateEventThreatDetectionCustomModuleResponse]: - r"""Return a callable for the validate event threat - detection custom module method over gRPC. - - Validates the given Event Threat Detection custom - module. - - Returns: - Callable[[~.ValidateEventThreatDetectionCustomModuleRequest], - ~.ValidateEventThreatDetectionCustomModuleResponse]: - 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 'validate_event_threat_detection_custom_module' not in self._stubs: - self._stubs['validate_event_threat_detection_custom_module'] = self.grpc_channel.unary_unary( - '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/ValidateEventThreatDetectionCustomModule', - request_serializer=security_center_management.ValidateEventThreatDetectionCustomModuleRequest.serialize, - response_deserializer=security_center_management.ValidateEventThreatDetectionCustomModuleResponse.deserialize, - ) - return self._stubs['validate_event_threat_detection_custom_module'] - - def close(self): - self.grpc_channel.close() - - @property - def list_locations( - self, - ) -> Callable[[locations_pb2.ListLocationsRequest], locations_pb2.ListLocationsResponse]: - r"""Return a callable for the list locations method over gRPC. - """ - # 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_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/ListLocations", - request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, - response_deserializer=locations_pb2.ListLocationsResponse.FromString, - ) - return self._stubs["list_locations"] - - @property - def get_location( - self, - ) -> Callable[[locations_pb2.GetLocationRequest], locations_pb2.Location]: - r"""Return a callable for the list locations method over gRPC. - """ - # 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_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/GetLocation", - request_serializer=locations_pb2.GetLocationRequest.SerializeToString, - response_deserializer=locations_pb2.Location.FromString, - ) - return self._stubs["get_location"] - - @property - def kind(self) -> str: - return "grpc" - - -__all__ = ( - 'SecurityCenterManagementGrpcTransport', -) diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/grpc_asyncio.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/grpc_asyncio.py deleted file mode 100644 index 02d66be5c1a3..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/grpc_asyncio.py +++ /dev/null @@ -1,817 +0,0 @@ -# -*- 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. -# -import warnings -from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union - -from google.api_core import gapic_v1 -from google.api_core import grpc_helpers_async -from google.auth import credentials as ga_credentials # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore - -import grpc # type: ignore -from grpc.experimental import aio # type: ignore - -from google.cloud.location import locations_pb2 # type: ignore -from google.cloud.securitycentermanagement_v1.types import security_center_management -from google.protobuf import empty_pb2 # type: ignore -from .base import SecurityCenterManagementTransport, DEFAULT_CLIENT_INFO -from .grpc import SecurityCenterManagementGrpcTransport - - -class SecurityCenterManagementGrpcAsyncIOTransport(SecurityCenterManagementTransport): - """gRPC AsyncIO backend transport for SecurityCenterManagement. - - Service describing handlers for resources - - This class defines the same methods as the primary client, so the - primary client can load the underlying transport implementation - and call it. - - It sends protocol buffers over the wire using gRPC (which is built on - top of HTTP/2); the ``grpcio`` package must be installed. - """ - - _grpc_channel: aio.Channel - _stubs: Dict[str, Callable] = {} - - @classmethod - def create_channel(cls, - host: str = 'securitycentermanagement.googleapis.com', - credentials: Optional[ga_credentials.Credentials] = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - quota_project_id: Optional[str] = None, - **kwargs) -> aio.Channel: - """Create and return a gRPC AsyncIO channel object. - Args: - host (Optional[str]): The host for the channel to use. - credentials (Optional[~.Credentials]): The - authorization credentials to attach to requests. These - credentials identify this application to the service. If - none are specified, the client will attempt to ascertain - the credentials from the environment. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is ignored if ``channel`` is provided. - scopes (Optional[Sequence[str]]): A optional list of scopes needed for this - service. These are only used when credentials are not specified and - are passed to :func:`google.auth.default`. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - kwargs (Optional[dict]): Keyword arguments, which are passed to the - channel creation. - Returns: - aio.Channel: A gRPC AsyncIO channel object. - """ - - return grpc_helpers_async.create_channel( - host, - credentials=credentials, - credentials_file=credentials_file, - quota_project_id=quota_project_id, - default_scopes=cls.AUTH_SCOPES, - scopes=scopes, - default_host=cls.DEFAULT_HOST, - **kwargs - ) - - def __init__(self, *, - host: str = 'securitycentermanagement.googleapis.com', - credentials: Optional[ga_credentials.Credentials] = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - channel: Optional[aio.Channel] = None, - api_mtls_endpoint: Optional[str] = None, - client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None, - ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None, - client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None, - quota_project_id: Optional[str] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - always_use_jwt_access: Optional[bool] = False, - api_audience: Optional[str] = None, - ) -> None: - """Instantiate the transport. - - Args: - host (Optional[str]): - The hostname to connect to. - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - This argument is ignored if ``channel`` is provided. - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is ignored if ``channel`` is provided. - scopes (Optional[Sequence[str]]): A optional list of scopes needed for this - service. These are only used when credentials are not specified and - are passed to :func:`google.auth.default`. - channel (Optional[aio.Channel]): A ``Channel`` instance through - which to make calls. - api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint. - If provided, it overrides the ``host`` argument and tries to create - a mutual TLS channel with client SSL credentials from - ``client_cert_source`` or application default SSL credentials. - client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): - Deprecated. A callback to provide client SSL certificate bytes and - private key bytes, both in PEM format. It is ignored if - ``api_mtls_endpoint`` is None. - ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials - for the grpc channel. It is ignored if ``channel`` is provided. - client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): - A callback to provide client certificate bytes and private key bytes, - both in PEM format. It is used to configure a mutual TLS channel. It is - ignored if ``channel`` or ``ssl_channel_credentials`` is provided. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing - your own client library. - always_use_jwt_access (Optional[bool]): Whether self signed JWT should - be used for service account credentials. - - Raises: - google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport - creation failed for any reason. - google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` - and ``credentials_file`` are passed. - """ - self._grpc_channel = None - self._ssl_channel_credentials = ssl_channel_credentials - self._stubs: Dict[str, Callable] = {} - - if api_mtls_endpoint: - warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) - if client_cert_source: - warnings.warn("client_cert_source is deprecated", DeprecationWarning) - - if channel: - # Ignore credentials if a channel was passed. - credentials = False - # If a channel was explicitly provided, set it. - self._grpc_channel = channel - self._ssl_channel_credentials = None - else: - if api_mtls_endpoint: - host = api_mtls_endpoint - - # Create SSL credentials with client_cert_source or application - # default SSL credentials. - if client_cert_source: - cert, key = client_cert_source() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - else: - self._ssl_channel_credentials = SslCredentials().ssl_credentials - - else: - if client_cert_source_for_mtls and not ssl_channel_credentials: - cert, key = client_cert_source_for_mtls() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - - # The base transport sets the host, credentials and scopes - super().__init__( - host=host, - credentials=credentials, - credentials_file=credentials_file, - scopes=scopes, - quota_project_id=quota_project_id, - client_info=client_info, - always_use_jwt_access=always_use_jwt_access, - api_audience=api_audience, - ) - - if not self._grpc_channel: - self._grpc_channel = type(self).create_channel( - self._host, - # use the credentials which are saved - credentials=self._credentials, - # Set ``credentials_file`` to ``None`` here as - # the credentials that we saved earlier should be used. - credentials_file=None, - scopes=self._scopes, - ssl_credentials=self._ssl_channel_credentials, - quota_project_id=quota_project_id, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - # Wrap messages. This must be done after self._grpc_channel exists - self._prep_wrapped_messages(client_info) - - @property - def grpc_channel(self) -> aio.Channel: - """Create the channel designed to connect to this service. - - This property caches on the instance; repeated calls return - the same channel. - """ - # Return the channel from cache. - return self._grpc_channel - - @property - def list_effective_security_health_analytics_custom_modules(self) -> Callable[ - [security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest], - Awaitable[security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse]]: - r"""Return a callable for the list effective security health - analytics custom modules method over gRPC. - - Returns a list of all - EffectiveSecurityHealthAnalyticsCustomModules for the - given parent. This includes resident modules defined at - the scope of the parent, and inherited modules, - inherited from CRM ancestors (no descendants). - - Returns: - Callable[[~.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest], - Awaitable[~.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse]]: - 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_effective_security_health_analytics_custom_modules' not in self._stubs: - self._stubs['list_effective_security_health_analytics_custom_modules'] = self.grpc_channel.unary_unary( - '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/ListEffectiveSecurityHealthAnalyticsCustomModules', - request_serializer=security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest.serialize, - response_deserializer=security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse.deserialize, - ) - return self._stubs['list_effective_security_health_analytics_custom_modules'] - - @property - def get_effective_security_health_analytics_custom_module(self) -> Callable[ - [security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest], - Awaitable[security_center_management.EffectiveSecurityHealthAnalyticsCustomModule]]: - r"""Return a callable for the get effective security health - analytics custom module method over gRPC. - - Gets details of a single - EffectiveSecurityHealthAnalyticsCustomModule. - - Returns: - Callable[[~.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest], - Awaitable[~.EffectiveSecurityHealthAnalyticsCustomModule]]: - 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_effective_security_health_analytics_custom_module' not in self._stubs: - self._stubs['get_effective_security_health_analytics_custom_module'] = self.grpc_channel.unary_unary( - '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/GetEffectiveSecurityHealthAnalyticsCustomModule', - request_serializer=security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest.serialize, - response_deserializer=security_center_management.EffectiveSecurityHealthAnalyticsCustomModule.deserialize, - ) - return self._stubs['get_effective_security_health_analytics_custom_module'] - - @property - def list_security_health_analytics_custom_modules(self) -> Callable[ - [security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest], - Awaitable[security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse]]: - r"""Return a callable for the list security health analytics - custom modules method over gRPC. - - Returns a list of all - SecurityHealthAnalyticsCustomModules for the given - parent. This includes resident modules defined at the - scope of the parent, and inherited modules, inherited - from CRM ancestors (no descendants). - - Returns: - Callable[[~.ListSecurityHealthAnalyticsCustomModulesRequest], - Awaitable[~.ListSecurityHealthAnalyticsCustomModulesResponse]]: - 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_security_health_analytics_custom_modules' not in self._stubs: - self._stubs['list_security_health_analytics_custom_modules'] = self.grpc_channel.unary_unary( - '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/ListSecurityHealthAnalyticsCustomModules', - request_serializer=security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest.serialize, - response_deserializer=security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse.deserialize, - ) - return self._stubs['list_security_health_analytics_custom_modules'] - - @property - def list_descendant_security_health_analytics_custom_modules(self) -> Callable[ - [security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest], - Awaitable[security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse]]: - r"""Return a callable for the list descendant security - health analytics custom modules method over gRPC. - - Returns a list of all resident - SecurityHealthAnalyticsCustomModules under the given CRM - parent and all of the parent’s CRM descendants. - - Returns: - Callable[[~.ListDescendantSecurityHealthAnalyticsCustomModulesRequest], - Awaitable[~.ListDescendantSecurityHealthAnalyticsCustomModulesResponse]]: - 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_descendant_security_health_analytics_custom_modules' not in self._stubs: - self._stubs['list_descendant_security_health_analytics_custom_modules'] = self.grpc_channel.unary_unary( - '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/ListDescendantSecurityHealthAnalyticsCustomModules', - request_serializer=security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest.serialize, - response_deserializer=security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse.deserialize, - ) - return self._stubs['list_descendant_security_health_analytics_custom_modules'] - - @property - def get_security_health_analytics_custom_module(self) -> Callable[ - [security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest], - Awaitable[security_center_management.SecurityHealthAnalyticsCustomModule]]: - r"""Return a callable for the get security health analytics - custom module method over gRPC. - - Retrieves a SecurityHealthAnalyticsCustomModule. - - Returns: - Callable[[~.GetSecurityHealthAnalyticsCustomModuleRequest], - Awaitable[~.SecurityHealthAnalyticsCustomModule]]: - 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_security_health_analytics_custom_module' not in self._stubs: - self._stubs['get_security_health_analytics_custom_module'] = self.grpc_channel.unary_unary( - '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/GetSecurityHealthAnalyticsCustomModule', - request_serializer=security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest.serialize, - response_deserializer=security_center_management.SecurityHealthAnalyticsCustomModule.deserialize, - ) - return self._stubs['get_security_health_analytics_custom_module'] - - @property - def create_security_health_analytics_custom_module(self) -> Callable[ - [security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest], - Awaitable[security_center_management.SecurityHealthAnalyticsCustomModule]]: - r"""Return a callable for the create security health - analytics custom module method over gRPC. - - Creates a resident - SecurityHealthAnalyticsCustomModule at the scope of the - given CRM parent, and also creates inherited - SecurityHealthAnalyticsCustomModules for all CRM - descendants of the given parent. These modules are - enabled by default. - - Returns: - Callable[[~.CreateSecurityHealthAnalyticsCustomModuleRequest], - Awaitable[~.SecurityHealthAnalyticsCustomModule]]: - 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_security_health_analytics_custom_module' not in self._stubs: - self._stubs['create_security_health_analytics_custom_module'] = self.grpc_channel.unary_unary( - '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/CreateSecurityHealthAnalyticsCustomModule', - request_serializer=security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest.serialize, - response_deserializer=security_center_management.SecurityHealthAnalyticsCustomModule.deserialize, - ) - return self._stubs['create_security_health_analytics_custom_module'] - - @property - def update_security_health_analytics_custom_module(self) -> Callable[ - [security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest], - Awaitable[security_center_management.SecurityHealthAnalyticsCustomModule]]: - r"""Return a callable for the update security health - analytics custom module method over gRPC. - - Updates the SecurityHealthAnalyticsCustomModule under - the given name based on the given update mask. Updating - the enablement state is supported on both resident and - inherited modules (though resident modules cannot have - an enablement state of "inherited"). Updating the - display name and custom config of a module is supported - on resident modules only. - - Returns: - Callable[[~.UpdateSecurityHealthAnalyticsCustomModuleRequest], - Awaitable[~.SecurityHealthAnalyticsCustomModule]]: - 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_security_health_analytics_custom_module' not in self._stubs: - self._stubs['update_security_health_analytics_custom_module'] = self.grpc_channel.unary_unary( - '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/UpdateSecurityHealthAnalyticsCustomModule', - request_serializer=security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest.serialize, - response_deserializer=security_center_management.SecurityHealthAnalyticsCustomModule.deserialize, - ) - return self._stubs['update_security_health_analytics_custom_module'] - - @property - def delete_security_health_analytics_custom_module(self) -> Callable[ - [security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest], - Awaitable[empty_pb2.Empty]]: - r"""Return a callable for the delete security health - analytics custom module method over gRPC. - - Deletes the specified - SecurityHealthAnalyticsCustomModule and all of its - descendants in the CRM hierarchy. This method is only - supported for resident custom modules. - - Returns: - Callable[[~.DeleteSecurityHealthAnalyticsCustomModuleRequest], - 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_security_health_analytics_custom_module' not in self._stubs: - self._stubs['delete_security_health_analytics_custom_module'] = self.grpc_channel.unary_unary( - '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/DeleteSecurityHealthAnalyticsCustomModule', - request_serializer=security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_security_health_analytics_custom_module'] - - @property - def simulate_security_health_analytics_custom_module(self) -> Callable[ - [security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest], - Awaitable[security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse]]: - r"""Return a callable for the simulate security health - analytics custom module method over gRPC. - - Simulates a given SecurityHealthAnalyticsCustomModule - and Resource. - - Returns: - Callable[[~.SimulateSecurityHealthAnalyticsCustomModuleRequest], - Awaitable[~.SimulateSecurityHealthAnalyticsCustomModuleResponse]]: - 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 'simulate_security_health_analytics_custom_module' not in self._stubs: - self._stubs['simulate_security_health_analytics_custom_module'] = self.grpc_channel.unary_unary( - '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/SimulateSecurityHealthAnalyticsCustomModule', - request_serializer=security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest.serialize, - response_deserializer=security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse.deserialize, - ) - return self._stubs['simulate_security_health_analytics_custom_module'] - - @property - def list_effective_event_threat_detection_custom_modules(self) -> Callable[ - [security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest], - Awaitable[security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse]]: - r"""Return a callable for the list effective event threat - detection custom modules method over gRPC. - - Lists all effective Event Threat Detection custom - modules for the given parent. This includes resident - modules defined at the scope of the parent along with - modules inherited from its ancestors. - - Returns: - Callable[[~.ListEffectiveEventThreatDetectionCustomModulesRequest], - Awaitable[~.ListEffectiveEventThreatDetectionCustomModulesResponse]]: - 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_effective_event_threat_detection_custom_modules' not in self._stubs: - self._stubs['list_effective_event_threat_detection_custom_modules'] = self.grpc_channel.unary_unary( - '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/ListEffectiveEventThreatDetectionCustomModules', - request_serializer=security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest.serialize, - response_deserializer=security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse.deserialize, - ) - return self._stubs['list_effective_event_threat_detection_custom_modules'] - - @property - def get_effective_event_threat_detection_custom_module(self) -> Callable[ - [security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest], - Awaitable[security_center_management.EffectiveEventThreatDetectionCustomModule]]: - r"""Return a callable for the get effective event threat - detection custom module method over gRPC. - - Gets an effective ETD custom module. Retrieves the effective - module at the given level. The difference between an - EffectiveCustomModule and a CustomModule is that the fields for - an EffectiveCustomModule are computed from ancestors if needed. - For example, the enablement_state for a CustomModule can be - either ENABLED, DISABLED, or INHERITED. Where as the - enablement_state for an EffectiveCustomModule is always computed - to ENABLED or DISABLED (the effective enablement_state). - - Returns: - Callable[[~.GetEffectiveEventThreatDetectionCustomModuleRequest], - Awaitable[~.EffectiveEventThreatDetectionCustomModule]]: - 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_effective_event_threat_detection_custom_module' not in self._stubs: - self._stubs['get_effective_event_threat_detection_custom_module'] = self.grpc_channel.unary_unary( - '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/GetEffectiveEventThreatDetectionCustomModule', - request_serializer=security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest.serialize, - response_deserializer=security_center_management.EffectiveEventThreatDetectionCustomModule.deserialize, - ) - return self._stubs['get_effective_event_threat_detection_custom_module'] - - @property - def list_event_threat_detection_custom_modules(self) -> Callable[ - [security_center_management.ListEventThreatDetectionCustomModulesRequest], - Awaitable[security_center_management.ListEventThreatDetectionCustomModulesResponse]]: - r"""Return a callable for the list event threat detection - custom modules method over gRPC. - - Lists all Event Threat Detection custom modules for - the given Resource Manager parent. This includes - resident modules defined at the scope of the parent - along with modules inherited from ancestors. - - Returns: - Callable[[~.ListEventThreatDetectionCustomModulesRequest], - Awaitable[~.ListEventThreatDetectionCustomModulesResponse]]: - 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_event_threat_detection_custom_modules' not in self._stubs: - self._stubs['list_event_threat_detection_custom_modules'] = self.grpc_channel.unary_unary( - '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/ListEventThreatDetectionCustomModules', - request_serializer=security_center_management.ListEventThreatDetectionCustomModulesRequest.serialize, - response_deserializer=security_center_management.ListEventThreatDetectionCustomModulesResponse.deserialize, - ) - return self._stubs['list_event_threat_detection_custom_modules'] - - @property - def list_descendant_event_threat_detection_custom_modules(self) -> Callable[ - [security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest], - Awaitable[security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse]]: - r"""Return a callable for the list descendant event threat - detection custom modules method over gRPC. - - Lists all resident Event Threat Detection custom - modules under the given Resource Manager parent and its - descendants. - - Returns: - Callable[[~.ListDescendantEventThreatDetectionCustomModulesRequest], - Awaitable[~.ListDescendantEventThreatDetectionCustomModulesResponse]]: - 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_descendant_event_threat_detection_custom_modules' not in self._stubs: - self._stubs['list_descendant_event_threat_detection_custom_modules'] = self.grpc_channel.unary_unary( - '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/ListDescendantEventThreatDetectionCustomModules', - request_serializer=security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest.serialize, - response_deserializer=security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse.deserialize, - ) - return self._stubs['list_descendant_event_threat_detection_custom_modules'] - - @property - def get_event_threat_detection_custom_module(self) -> Callable[ - [security_center_management.GetEventThreatDetectionCustomModuleRequest], - Awaitable[security_center_management.EventThreatDetectionCustomModule]]: - r"""Return a callable for the get event threat detection - custom module method over gRPC. - - Gets an Event Threat Detection custom module. - - Returns: - Callable[[~.GetEventThreatDetectionCustomModuleRequest], - Awaitable[~.EventThreatDetectionCustomModule]]: - 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_event_threat_detection_custom_module' not in self._stubs: - self._stubs['get_event_threat_detection_custom_module'] = self.grpc_channel.unary_unary( - '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/GetEventThreatDetectionCustomModule', - request_serializer=security_center_management.GetEventThreatDetectionCustomModuleRequest.serialize, - response_deserializer=security_center_management.EventThreatDetectionCustomModule.deserialize, - ) - return self._stubs['get_event_threat_detection_custom_module'] - - @property - def create_event_threat_detection_custom_module(self) -> Callable[ - [security_center_management.CreateEventThreatDetectionCustomModuleRequest], - Awaitable[security_center_management.EventThreatDetectionCustomModule]]: - r"""Return a callable for the create event threat detection - custom module method over gRPC. - - Creates a resident Event Threat Detection custom - module at the scope of the given Resource Manager - parent, and also creates inherited custom modules for - all descendants of the given parent. These modules are - enabled by default. - - Returns: - Callable[[~.CreateEventThreatDetectionCustomModuleRequest], - Awaitable[~.EventThreatDetectionCustomModule]]: - 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_event_threat_detection_custom_module' not in self._stubs: - self._stubs['create_event_threat_detection_custom_module'] = self.grpc_channel.unary_unary( - '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/CreateEventThreatDetectionCustomModule', - request_serializer=security_center_management.CreateEventThreatDetectionCustomModuleRequest.serialize, - response_deserializer=security_center_management.EventThreatDetectionCustomModule.deserialize, - ) - return self._stubs['create_event_threat_detection_custom_module'] - - @property - def update_event_threat_detection_custom_module(self) -> Callable[ - [security_center_management.UpdateEventThreatDetectionCustomModuleRequest], - Awaitable[security_center_management.EventThreatDetectionCustomModule]]: - r"""Return a callable for the update event threat detection - custom module method over gRPC. - - Updates the Event Threat Detection custom module with - the given name based on the given update mask. Updating - the enablement state is supported for both resident and - inherited modules (though resident modules cannot have - an enablement state of "inherited"). Updating the - display name or configuration of a module is supported - for resident modules only. The type of a module cannot - be changed. - - Returns: - Callable[[~.UpdateEventThreatDetectionCustomModuleRequest], - Awaitable[~.EventThreatDetectionCustomModule]]: - 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_event_threat_detection_custom_module' not in self._stubs: - self._stubs['update_event_threat_detection_custom_module'] = self.grpc_channel.unary_unary( - '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/UpdateEventThreatDetectionCustomModule', - request_serializer=security_center_management.UpdateEventThreatDetectionCustomModuleRequest.serialize, - response_deserializer=security_center_management.EventThreatDetectionCustomModule.deserialize, - ) - return self._stubs['update_event_threat_detection_custom_module'] - - @property - def delete_event_threat_detection_custom_module(self) -> Callable[ - [security_center_management.DeleteEventThreatDetectionCustomModuleRequest], - Awaitable[empty_pb2.Empty]]: - r"""Return a callable for the delete event threat detection - custom module method over gRPC. - - Deletes the specified Event Threat Detection custom - module and all of its descendants in the Resource - Manager hierarchy. This method is only supported for - resident custom modules. - - Returns: - Callable[[~.DeleteEventThreatDetectionCustomModuleRequest], - 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_event_threat_detection_custom_module' not in self._stubs: - self._stubs['delete_event_threat_detection_custom_module'] = self.grpc_channel.unary_unary( - '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/DeleteEventThreatDetectionCustomModule', - request_serializer=security_center_management.DeleteEventThreatDetectionCustomModuleRequest.serialize, - response_deserializer=empty_pb2.Empty.FromString, - ) - return self._stubs['delete_event_threat_detection_custom_module'] - - @property - def validate_event_threat_detection_custom_module(self) -> Callable[ - [security_center_management.ValidateEventThreatDetectionCustomModuleRequest], - Awaitable[security_center_management.ValidateEventThreatDetectionCustomModuleResponse]]: - r"""Return a callable for the validate event threat - detection custom module method over gRPC. - - Validates the given Event Threat Detection custom - module. - - Returns: - Callable[[~.ValidateEventThreatDetectionCustomModuleRequest], - Awaitable[~.ValidateEventThreatDetectionCustomModuleResponse]]: - 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 'validate_event_threat_detection_custom_module' not in self._stubs: - self._stubs['validate_event_threat_detection_custom_module'] = self.grpc_channel.unary_unary( - '/google.cloud.securitycentermanagement.v1.SecurityCenterManagement/ValidateEventThreatDetectionCustomModule', - request_serializer=security_center_management.ValidateEventThreatDetectionCustomModuleRequest.serialize, - response_deserializer=security_center_management.ValidateEventThreatDetectionCustomModuleResponse.deserialize, - ) - return self._stubs['validate_event_threat_detection_custom_module'] - - def close(self): - return self.grpc_channel.close() - - @property - def list_locations( - self, - ) -> Callable[[locations_pb2.ListLocationsRequest], locations_pb2.ListLocationsResponse]: - r"""Return a callable for the list locations method over gRPC. - """ - # 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_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/ListLocations", - request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, - response_deserializer=locations_pb2.ListLocationsResponse.FromString, - ) - return self._stubs["list_locations"] - - @property - def get_location( - self, - ) -> Callable[[locations_pb2.GetLocationRequest], locations_pb2.Location]: - r"""Return a callable for the list locations method over gRPC. - """ - # 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_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( - "/google.cloud.location.Locations/GetLocation", - request_serializer=locations_pb2.GetLocationRequest.SerializeToString, - response_deserializer=locations_pb2.Location.FromString, - ) - return self._stubs["get_location"] - - -__all__ = ( - 'SecurityCenterManagementGrpcAsyncIOTransport', -) diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/rest.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/rest.py deleted file mode 100644 index 33dcd48632c8..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/rest.py +++ /dev/null @@ -1,2627 +0,0 @@ -# -*- 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. -# - -from google.auth.transport.requests import AuthorizedSession # type: ignore -import json # type: ignore -import grpc # type: ignore -from google.auth.transport.grpc import SslCredentials # type: ignore -from google.auth import credentials as ga_credentials # type: ignore -from google.api_core import exceptions as core_exceptions -from google.api_core import retry as retries -from google.api_core import rest_helpers -from google.api_core import rest_streaming -from google.api_core import path_template -from google.api_core import gapic_v1 - -from google.protobuf import json_format -from google.cloud.location import locations_pb2 # type: ignore -from requests import __version__ as requests_version -import dataclasses -import re -from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union -import warnings - -try: - OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] -except AttributeError: # pragma: NO COVER - OptionalRetry = Union[retries.Retry, object] # type: ignore - - -from google.cloud.securitycentermanagement_v1.types import security_center_management -from google.protobuf import empty_pb2 # type: ignore - -from .base import SecurityCenterManagementTransport, DEFAULT_CLIENT_INFO as BASE_DEFAULT_CLIENT_INFO - - -DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version, - grpc_version=None, - rest_version=requests_version, -) - - -class SecurityCenterManagementRestInterceptor: - """Interceptor for SecurityCenterManagement. - - Interceptors are used to manipulate requests, request metadata, and responses - in arbitrary ways. - Example use cases include: - * Logging - * Verifying requests according to service or custom semantics - * Stripping extraneous information from responses - - These use cases and more can be enabled by injecting an - instance of a custom subclass when constructing the SecurityCenterManagementRestTransport. - - .. code-block:: python - class MyCustomSecurityCenterManagementInterceptor(SecurityCenterManagementRestInterceptor): - def pre_create_event_threat_detection_custom_module(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_create_event_threat_detection_custom_module(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_create_security_health_analytics_custom_module(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_create_security_health_analytics_custom_module(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_delete_event_threat_detection_custom_module(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def pre_delete_security_health_analytics_custom_module(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def pre_get_effective_event_threat_detection_custom_module(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_effective_event_threat_detection_custom_module(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_get_effective_security_health_analytics_custom_module(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_effective_security_health_analytics_custom_module(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_get_event_threat_detection_custom_module(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_event_threat_detection_custom_module(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_get_security_health_analytics_custom_module(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_get_security_health_analytics_custom_module(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_descendant_event_threat_detection_custom_modules(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_descendant_event_threat_detection_custom_modules(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_descendant_security_health_analytics_custom_modules(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_descendant_security_health_analytics_custom_modules(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_effective_event_threat_detection_custom_modules(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_effective_event_threat_detection_custom_modules(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_effective_security_health_analytics_custom_modules(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_effective_security_health_analytics_custom_modules(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_event_threat_detection_custom_modules(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_event_threat_detection_custom_modules(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_list_security_health_analytics_custom_modules(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_list_security_health_analytics_custom_modules(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_simulate_security_health_analytics_custom_module(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_simulate_security_health_analytics_custom_module(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_update_event_threat_detection_custom_module(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_update_event_threat_detection_custom_module(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_update_security_health_analytics_custom_module(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_update_security_health_analytics_custom_module(self, response): - logging.log(f"Received response: {response}") - return response - - def pre_validate_event_threat_detection_custom_module(self, request, metadata): - logging.log(f"Received request: {request}") - return request, metadata - - def post_validate_event_threat_detection_custom_module(self, response): - logging.log(f"Received response: {response}") - return response - - transport = SecurityCenterManagementRestTransport(interceptor=MyCustomSecurityCenterManagementInterceptor()) - client = SecurityCenterManagementClient(transport=transport) - - - """ - def pre_create_event_threat_detection_custom_module(self, request: security_center_management.CreateEventThreatDetectionCustomModuleRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[security_center_management.CreateEventThreatDetectionCustomModuleRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for create_event_threat_detection_custom_module - - Override in a subclass to manipulate the request or metadata - before they are sent to the SecurityCenterManagement server. - """ - return request, metadata - - def post_create_event_threat_detection_custom_module(self, response: security_center_management.EventThreatDetectionCustomModule) -> security_center_management.EventThreatDetectionCustomModule: - """Post-rpc interceptor for create_event_threat_detection_custom_module - - Override in a subclass to manipulate the response - after it is returned by the SecurityCenterManagement server but before - it is returned to user code. - """ - return response - def pre_create_security_health_analytics_custom_module(self, request: security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for create_security_health_analytics_custom_module - - Override in a subclass to manipulate the request or metadata - before they are sent to the SecurityCenterManagement server. - """ - return request, metadata - - def post_create_security_health_analytics_custom_module(self, response: security_center_management.SecurityHealthAnalyticsCustomModule) -> security_center_management.SecurityHealthAnalyticsCustomModule: - """Post-rpc interceptor for create_security_health_analytics_custom_module - - Override in a subclass to manipulate the response - after it is returned by the SecurityCenterManagement server but before - it is returned to user code. - """ - return response - def pre_delete_event_threat_detection_custom_module(self, request: security_center_management.DeleteEventThreatDetectionCustomModuleRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[security_center_management.DeleteEventThreatDetectionCustomModuleRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for delete_event_threat_detection_custom_module - - Override in a subclass to manipulate the request or metadata - before they are sent to the SecurityCenterManagement server. - """ - return request, metadata - - def pre_delete_security_health_analytics_custom_module(self, request: security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for delete_security_health_analytics_custom_module - - Override in a subclass to manipulate the request or metadata - before they are sent to the SecurityCenterManagement server. - """ - return request, metadata - - def pre_get_effective_event_threat_detection_custom_module(self, request: security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_effective_event_threat_detection_custom_module - - Override in a subclass to manipulate the request or metadata - before they are sent to the SecurityCenterManagement server. - """ - return request, metadata - - def post_get_effective_event_threat_detection_custom_module(self, response: security_center_management.EffectiveEventThreatDetectionCustomModule) -> security_center_management.EffectiveEventThreatDetectionCustomModule: - """Post-rpc interceptor for get_effective_event_threat_detection_custom_module - - Override in a subclass to manipulate the response - after it is returned by the SecurityCenterManagement server but before - it is returned to user code. - """ - return response - def pre_get_effective_security_health_analytics_custom_module(self, request: security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_effective_security_health_analytics_custom_module - - Override in a subclass to manipulate the request or metadata - before they are sent to the SecurityCenterManagement server. - """ - return request, metadata - - def post_get_effective_security_health_analytics_custom_module(self, response: security_center_management.EffectiveSecurityHealthAnalyticsCustomModule) -> security_center_management.EffectiveSecurityHealthAnalyticsCustomModule: - """Post-rpc interceptor for get_effective_security_health_analytics_custom_module - - Override in a subclass to manipulate the response - after it is returned by the SecurityCenterManagement server but before - it is returned to user code. - """ - return response - def pre_get_event_threat_detection_custom_module(self, request: security_center_management.GetEventThreatDetectionCustomModuleRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[security_center_management.GetEventThreatDetectionCustomModuleRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_event_threat_detection_custom_module - - Override in a subclass to manipulate the request or metadata - before they are sent to the SecurityCenterManagement server. - """ - return request, metadata - - def post_get_event_threat_detection_custom_module(self, response: security_center_management.EventThreatDetectionCustomModule) -> security_center_management.EventThreatDetectionCustomModule: - """Post-rpc interceptor for get_event_threat_detection_custom_module - - Override in a subclass to manipulate the response - after it is returned by the SecurityCenterManagement server but before - it is returned to user code. - """ - return response - def pre_get_security_health_analytics_custom_module(self, request: security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_security_health_analytics_custom_module - - Override in a subclass to manipulate the request or metadata - before they are sent to the SecurityCenterManagement server. - """ - return request, metadata - - def post_get_security_health_analytics_custom_module(self, response: security_center_management.SecurityHealthAnalyticsCustomModule) -> security_center_management.SecurityHealthAnalyticsCustomModule: - """Post-rpc interceptor for get_security_health_analytics_custom_module - - Override in a subclass to manipulate the response - after it is returned by the SecurityCenterManagement server but before - it is returned to user code. - """ - return response - def pre_list_descendant_event_threat_detection_custom_modules(self, request: security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_descendant_event_threat_detection_custom_modules - - Override in a subclass to manipulate the request or metadata - before they are sent to the SecurityCenterManagement server. - """ - return request, metadata - - def post_list_descendant_event_threat_detection_custom_modules(self, response: security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse) -> security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse: - """Post-rpc interceptor for list_descendant_event_threat_detection_custom_modules - - Override in a subclass to manipulate the response - after it is returned by the SecurityCenterManagement server but before - it is returned to user code. - """ - return response - def pre_list_descendant_security_health_analytics_custom_modules(self, request: security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_descendant_security_health_analytics_custom_modules - - Override in a subclass to manipulate the request or metadata - before they are sent to the SecurityCenterManagement server. - """ - return request, metadata - - def post_list_descendant_security_health_analytics_custom_modules(self, response: security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse) -> security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse: - """Post-rpc interceptor for list_descendant_security_health_analytics_custom_modules - - Override in a subclass to manipulate the response - after it is returned by the SecurityCenterManagement server but before - it is returned to user code. - """ - return response - def pre_list_effective_event_threat_detection_custom_modules(self, request: security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_effective_event_threat_detection_custom_modules - - Override in a subclass to manipulate the request or metadata - before they are sent to the SecurityCenterManagement server. - """ - return request, metadata - - def post_list_effective_event_threat_detection_custom_modules(self, response: security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse) -> security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse: - """Post-rpc interceptor for list_effective_event_threat_detection_custom_modules - - Override in a subclass to manipulate the response - after it is returned by the SecurityCenterManagement server but before - it is returned to user code. - """ - return response - def pre_list_effective_security_health_analytics_custom_modules(self, request: security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_effective_security_health_analytics_custom_modules - - Override in a subclass to manipulate the request or metadata - before they are sent to the SecurityCenterManagement server. - """ - return request, metadata - - def post_list_effective_security_health_analytics_custom_modules(self, response: security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse) -> security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse: - """Post-rpc interceptor for list_effective_security_health_analytics_custom_modules - - Override in a subclass to manipulate the response - after it is returned by the SecurityCenterManagement server but before - it is returned to user code. - """ - return response - def pre_list_event_threat_detection_custom_modules(self, request: security_center_management.ListEventThreatDetectionCustomModulesRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[security_center_management.ListEventThreatDetectionCustomModulesRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_event_threat_detection_custom_modules - - Override in a subclass to manipulate the request or metadata - before they are sent to the SecurityCenterManagement server. - """ - return request, metadata - - def post_list_event_threat_detection_custom_modules(self, response: security_center_management.ListEventThreatDetectionCustomModulesResponse) -> security_center_management.ListEventThreatDetectionCustomModulesResponse: - """Post-rpc interceptor for list_event_threat_detection_custom_modules - - Override in a subclass to manipulate the response - after it is returned by the SecurityCenterManagement server but before - it is returned to user code. - """ - return response - def pre_list_security_health_analytics_custom_modules(self, request: security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_security_health_analytics_custom_modules - - Override in a subclass to manipulate the request or metadata - before they are sent to the SecurityCenterManagement server. - """ - return request, metadata - - def post_list_security_health_analytics_custom_modules(self, response: security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse) -> security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse: - """Post-rpc interceptor for list_security_health_analytics_custom_modules - - Override in a subclass to manipulate the response - after it is returned by the SecurityCenterManagement server but before - it is returned to user code. - """ - return response - def pre_simulate_security_health_analytics_custom_module(self, request: security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for simulate_security_health_analytics_custom_module - - Override in a subclass to manipulate the request or metadata - before they are sent to the SecurityCenterManagement server. - """ - return request, metadata - - def post_simulate_security_health_analytics_custom_module(self, response: security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse) -> security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse: - """Post-rpc interceptor for simulate_security_health_analytics_custom_module - - Override in a subclass to manipulate the response - after it is returned by the SecurityCenterManagement server but before - it is returned to user code. - """ - return response - def pre_update_event_threat_detection_custom_module(self, request: security_center_management.UpdateEventThreatDetectionCustomModuleRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[security_center_management.UpdateEventThreatDetectionCustomModuleRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for update_event_threat_detection_custom_module - - Override in a subclass to manipulate the request or metadata - before they are sent to the SecurityCenterManagement server. - """ - return request, metadata - - def post_update_event_threat_detection_custom_module(self, response: security_center_management.EventThreatDetectionCustomModule) -> security_center_management.EventThreatDetectionCustomModule: - """Post-rpc interceptor for update_event_threat_detection_custom_module - - Override in a subclass to manipulate the response - after it is returned by the SecurityCenterManagement server but before - it is returned to user code. - """ - return response - def pre_update_security_health_analytics_custom_module(self, request: security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for update_security_health_analytics_custom_module - - Override in a subclass to manipulate the request or metadata - before they are sent to the SecurityCenterManagement server. - """ - return request, metadata - - def post_update_security_health_analytics_custom_module(self, response: security_center_management.SecurityHealthAnalyticsCustomModule) -> security_center_management.SecurityHealthAnalyticsCustomModule: - """Post-rpc interceptor for update_security_health_analytics_custom_module - - Override in a subclass to manipulate the response - after it is returned by the SecurityCenterManagement server but before - it is returned to user code. - """ - return response - def pre_validate_event_threat_detection_custom_module(self, request: security_center_management.ValidateEventThreatDetectionCustomModuleRequest, metadata: Sequence[Tuple[str, str]]) -> Tuple[security_center_management.ValidateEventThreatDetectionCustomModuleRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for validate_event_threat_detection_custom_module - - Override in a subclass to manipulate the request or metadata - before they are sent to the SecurityCenterManagement server. - """ - return request, metadata - - def post_validate_event_threat_detection_custom_module(self, response: security_center_management.ValidateEventThreatDetectionCustomModuleResponse) -> security_center_management.ValidateEventThreatDetectionCustomModuleResponse: - """Post-rpc interceptor for validate_event_threat_detection_custom_module - - Override in a subclass to manipulate the response - after it is returned by the SecurityCenterManagement server but before - it is returned to user code. - """ - return response - - def pre_get_location( - self, request: locations_pb2.GetLocationRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[locations_pb2.GetLocationRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for get_location - - Override in a subclass to manipulate the request or metadata - before they are sent to the SecurityCenterManagement server. - """ - return request, metadata - - def post_get_location( - self, response: locations_pb2.Location - ) -> locations_pb2.Location: - """Post-rpc interceptor for get_location - - Override in a subclass to manipulate the response - after it is returned by the SecurityCenterManagement server but before - it is returned to user code. - """ - return response - def pre_list_locations( - self, request: locations_pb2.ListLocationsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, str]]]: - """Pre-rpc interceptor for list_locations - - Override in a subclass to manipulate the request or metadata - before they are sent to the SecurityCenterManagement server. - """ - return request, metadata - - def post_list_locations( - self, response: locations_pb2.ListLocationsResponse - ) -> locations_pb2.ListLocationsResponse: - """Post-rpc interceptor for list_locations - - Override in a subclass to manipulate the response - after it is returned by the SecurityCenterManagement server but before - it is returned to user code. - """ - return response - - -@dataclasses.dataclass -class SecurityCenterManagementRestStub: - _session: AuthorizedSession - _host: str - _interceptor: SecurityCenterManagementRestInterceptor - - -class SecurityCenterManagementRestTransport(SecurityCenterManagementTransport): - """REST backend transport for SecurityCenterManagement. - - Service describing handlers for resources - - This class defines the same methods as the primary client, so the - primary client can load the underlying transport implementation - and call it. - - It sends JSON representations of protocol buffers over HTTP/1.1 - - """ - - def __init__(self, *, - host: str = 'securitycentermanagement.googleapis.com', - credentials: Optional[ga_credentials.Credentials] = None, - credentials_file: Optional[str] = None, - scopes: Optional[Sequence[str]] = None, - client_cert_source_for_mtls: Optional[Callable[[ - ], Tuple[bytes, bytes]]] = None, - quota_project_id: Optional[str] = None, - client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, - always_use_jwt_access: Optional[bool] = False, - url_scheme: str = 'https', - interceptor: Optional[SecurityCenterManagementRestInterceptor] = None, - api_audience: Optional[str] = None, - ) -> None: - """Instantiate the transport. - - Args: - host (Optional[str]): - The hostname to connect to. - credentials (Optional[google.auth.credentials.Credentials]): The - authorization credentials to attach to requests. These - credentials identify the application to the service; if none - are specified, the client will attempt to ascertain the - credentials from the environment. - - credentials_file (Optional[str]): A file with credentials that can - be loaded with :func:`google.auth.load_credentials_from_file`. - This argument is ignored if ``channel`` is provided. - scopes (Optional(Sequence[str])): A list of scopes. This argument is - ignored if ``channel`` is provided. - client_cert_source_for_mtls (Callable[[], Tuple[bytes, bytes]]): Client - certificate to configure mutual TLS HTTP channel. It is ignored - if ``channel`` is provided. - quota_project_id (Optional[str]): An optional project to use for billing - and quota. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you are developing - your own client library. - always_use_jwt_access (Optional[bool]): Whether self signed JWT should - be used for service account credentials. - url_scheme: the protocol scheme for the API endpoint. Normally - "https", but for testing or local servers, - "http" can be specified. - """ - # Run the base constructor - # TODO(yon-mg): resolve other ctor params i.e. scopes, quota, etc. - # TODO: When custom host (api_endpoint) is set, `scopes` must *also* be set on the - # credentials object - maybe_url_match = re.match("^(?Phttp(?:s)?://)?(?P.*)$", host) - if maybe_url_match is None: - raise ValueError(f"Unexpected hostname structure: {host}") # pragma: NO COVER - - url_match_items = maybe_url_match.groupdict() - - host = f"{url_scheme}://{host}" if not url_match_items["scheme"] else host - - super().__init__( - host=host, - credentials=credentials, - client_info=client_info, - always_use_jwt_access=always_use_jwt_access, - api_audience=api_audience - ) - self._session = AuthorizedSession( - self._credentials, default_host=self.DEFAULT_HOST) - if client_cert_source_for_mtls: - self._session.configure_mtls_channel(client_cert_source_for_mtls) - self._interceptor = interceptor or SecurityCenterManagementRestInterceptor() - self._prep_wrapped_messages(client_info) - - class _CreateEventThreatDetectionCustomModule(SecurityCenterManagementRestStub): - def __hash__(self): - return hash("CreateEventThreatDetectionCustomModule") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: security_center_management.CreateEventThreatDetectionCustomModuleRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> security_center_management.EventThreatDetectionCustomModule: - r"""Call the create event threat - detection custom module method over HTTP. - - Args: - request (~.security_center_management.CreateEventThreatDetectionCustomModuleRequest): - The request object. Message for creating a - EventThreatDetectionCustomModule - 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: - ~.security_center_management.EventThreatDetectionCustomModule: - An event threat detection custom - module is a Cloud SCC resource that - contains the configuration and - enablement state of a custom module, - which enables ETD to write certain - findings to Cloud SCC. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v1/{parent=projects/*/locations/*}/eventThreatDetectionCustomModules', - 'body': 'event_threat_detection_custom_module', - }, -{ - 'method': 'post', - 'uri': '/v1/{parent=folders/*/locations/*}/eventThreatDetectionCustomModules', - 'body': 'event_threat_detection_custom_module', - }, -{ - 'method': 'post', - 'uri': '/v1/{parent=organizations/*/locations/*}/eventThreatDetectionCustomModules', - 'body': 'event_threat_detection_custom_module', - }, - ] - request, metadata = self._interceptor.pre_create_event_threat_detection_custom_module(request, metadata) - pb_request = security_center_management.CreateEventThreatDetectionCustomModuleRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request['body'], - including_default_value_fields=False, - use_integers_for_enums=True - ) - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) - query_params.update(self._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = security_center_management.EventThreatDetectionCustomModule() - pb_resp = security_center_management.EventThreatDetectionCustomModule.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_create_event_threat_detection_custom_module(resp) - return resp - - class _CreateSecurityHealthAnalyticsCustomModule(SecurityCenterManagementRestStub): - def __hash__(self): - return hash("CreateSecurityHealthAnalyticsCustomModule") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> security_center_management.SecurityHealthAnalyticsCustomModule: - r"""Call the create security health - analytics custom module method over HTTP. - - Args: - request (~.security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest): - The request object. Message for creating a - SecurityHealthAnalyticsCustomModule - 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: - ~.security_center_management.SecurityHealthAnalyticsCustomModule: - Represents an instance of a Security - Health Analytics custom module, - including its full module name, display - name, enablement state, and last updated - time. You can create a custom module at - the organization, folder, or project - level. Custom modules that you create at - the organization or folder level are - inherited by the child folders and - projects. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v1/{parent=projects/*/locations/*}/securityHealthAnalyticsCustomModules', - 'body': 'security_health_analytics_custom_module', - }, -{ - 'method': 'post', - 'uri': '/v1/{parent=folders/*/locations/*}/securityHealthAnalyticsCustomModules', - 'body': 'security_health_analytics_custom_module', - }, -{ - 'method': 'post', - 'uri': '/v1/{parent=organizations/*/locations/*}/securityHealthAnalyticsCustomModules', - 'body': 'security_health_analytics_custom_module', - }, - ] - request, metadata = self._interceptor.pre_create_security_health_analytics_custom_module(request, metadata) - pb_request = security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request['body'], - including_default_value_fields=False, - use_integers_for_enums=True - ) - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) - query_params.update(self._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = security_center_management.SecurityHealthAnalyticsCustomModule() - pb_resp = security_center_management.SecurityHealthAnalyticsCustomModule.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_create_security_health_analytics_custom_module(resp) - return resp - - class _DeleteEventThreatDetectionCustomModule(SecurityCenterManagementRestStub): - def __hash__(self): - return hash("DeleteEventThreatDetectionCustomModule") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: security_center_management.DeleteEventThreatDetectionCustomModuleRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ): - r"""Call the delete event threat - detection custom module method over HTTP. - - Args: - request (~.security_center_management.DeleteEventThreatDetectionCustomModuleRequest): - The request object. Message for deleting a - EventThreatDetectionCustomModule - 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. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'delete', - 'uri': '/v1/{name=projects/*/locations/*/eventThreatDetectionCustomModules/*}', - }, -{ - 'method': 'delete', - 'uri': '/v1/{name=folders/*/locations/*/eventThreatDetectionCustomModules/*}', - }, -{ - 'method': 'delete', - 'uri': '/v1/{name=organizations/*/locations/*/eventThreatDetectionCustomModules/*}', - }, - ] - request, metadata = self._interceptor.pre_delete_event_threat_detection_custom_module(request, metadata) - pb_request = security_center_management.DeleteEventThreatDetectionCustomModuleRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) - query_params.update(self._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - class _DeleteSecurityHealthAnalyticsCustomModule(SecurityCenterManagementRestStub): - def __hash__(self): - return hash("DeleteSecurityHealthAnalyticsCustomModule") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ): - r"""Call the delete security health - analytics custom module method over HTTP. - - Args: - request (~.security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest): - The request object. Message for deleting a - SecurityHealthAnalyticsCustomModule - 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. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'delete', - 'uri': '/v1/{name=projects/*/locations/*/securityHealthAnalyticsCustomModules/*}', - }, -{ - 'method': 'delete', - 'uri': '/v1/{name=folders/*/locations/*/securityHealthAnalyticsCustomModules/*}', - }, -{ - 'method': 'delete', - 'uri': '/v1/{name=organizations/*/locations/*/securityHealthAnalyticsCustomModules/*}', - }, - ] - request, metadata = self._interceptor.pre_delete_security_health_analytics_custom_module(request, metadata) - pb_request = security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) - query_params.update(self._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - class _GetEffectiveEventThreatDetectionCustomModule(SecurityCenterManagementRestStub): - def __hash__(self): - return hash("GetEffectiveEventThreatDetectionCustomModule") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> security_center_management.EffectiveEventThreatDetectionCustomModule: - r"""Call the get effective event - threat detection custom module method over HTTP. - - Args: - request (~.security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest): - The request object. Message for getting a - EffectiveEventThreatDetectionCustomModule - 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: - ~.security_center_management.EffectiveEventThreatDetectionCustomModule: - An EffectiveEventThreatDetectionCustomModule is the - representation of EventThreatDetectionCustomModule at a - given level taking hierarchy into account and resolving - various fields accordingly. e.g. if the module is - enabled at the ancestor level, effective modules at all - descendant levels will have enablement_state set to - ENABLED. Similarly, if module.inherited is set, then - effective module's config will contain the ancestor's - config details. - EffectiveEventThreatDetectionCustomModule is read-only. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{name=projects/*/locations/*/effectiveEventThreatDetectionCustomModules/*}', - }, -{ - 'method': 'get', - 'uri': '/v1/{name=folders/*/locations/*/effectiveEventThreatDetectionCustomModules/*}', - }, -{ - 'method': 'get', - 'uri': '/v1/{name=organizations/*/locations/*/effectiveEventThreatDetectionCustomModules/*}', - }, - ] - request, metadata = self._interceptor.pre_get_effective_event_threat_detection_custom_module(request, metadata) - pb_request = security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) - query_params.update(self._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = security_center_management.EffectiveEventThreatDetectionCustomModule() - pb_resp = security_center_management.EffectiveEventThreatDetectionCustomModule.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_effective_event_threat_detection_custom_module(resp) - return resp - - class _GetEffectiveSecurityHealthAnalyticsCustomModule(SecurityCenterManagementRestStub): - def __hash__(self): - return hash("GetEffectiveSecurityHealthAnalyticsCustomModule") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> security_center_management.EffectiveSecurityHealthAnalyticsCustomModule: - r"""Call the get effective security - health analytics custom module method over HTTP. - - Args: - request (~.security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest): - The request object. Message for getting a - EffectiveSecurityHealthAnalyticsCustomModule - 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: - ~.security_center_management.EffectiveSecurityHealthAnalyticsCustomModule: - An EffectiveSecurityHealthAnalyticsCustomModule is the - representation of a Security Health Analytics custom - module at a specified level of the resource hierarchy: - organization, folder, or project. If a custom module is - inherited from a parent organization or folder, the - value of the ``enablementState`` property in - EffectiveSecurityHealthAnalyticsCustomModule is set to - the value that is effective in the parent, instead of - ``INHERITED``. For example, if the module is enabled in - a parent organization or folder, the effective - enablement_state for the module in all child folders or - projects is also ``enabled``. - EffectiveSecurityHealthAnalyticsCustomModule is - read-only. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{name=projects/*/locations/*/effectiveSecurityHealthAnalyticsCustomModules/*}', - }, -{ - 'method': 'get', - 'uri': '/v1/{name=folders/*/locations/*/effectiveSecurityHealthAnalyticsCustomModules/*}', - }, -{ - 'method': 'get', - 'uri': '/v1/{name=organizations/*/locations/*/effectiveSecurityHealthAnalyticsCustomModules/*}', - }, - ] - request, metadata = self._interceptor.pre_get_effective_security_health_analytics_custom_module(request, metadata) - pb_request = security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) - query_params.update(self._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = security_center_management.EffectiveSecurityHealthAnalyticsCustomModule() - pb_resp = security_center_management.EffectiveSecurityHealthAnalyticsCustomModule.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_effective_security_health_analytics_custom_module(resp) - return resp - - class _GetEventThreatDetectionCustomModule(SecurityCenterManagementRestStub): - def __hash__(self): - return hash("GetEventThreatDetectionCustomModule") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: security_center_management.GetEventThreatDetectionCustomModuleRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> security_center_management.EventThreatDetectionCustomModule: - r"""Call the get event threat - detection custom module method over HTTP. - - Args: - request (~.security_center_management.GetEventThreatDetectionCustomModuleRequest): - The request object. Message for getting a - EventThreatDetectionCustomModule - 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: - ~.security_center_management.EventThreatDetectionCustomModule: - An event threat detection custom - module is a Cloud SCC resource that - contains the configuration and - enablement state of a custom module, - which enables ETD to write certain - findings to Cloud SCC. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{name=projects/*/locations/*/eventThreatDetectionCustomModules/*}', - }, -{ - 'method': 'get', - 'uri': '/v1/{name=folders/*/locations/*/eventThreatDetectionCustomModules/*}', - }, -{ - 'method': 'get', - 'uri': '/v1/{name=organizations/*/locations/*/eventThreatDetectionCustomModules/*}', - }, - ] - request, metadata = self._interceptor.pre_get_event_threat_detection_custom_module(request, metadata) - pb_request = security_center_management.GetEventThreatDetectionCustomModuleRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) - query_params.update(self._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = security_center_management.EventThreatDetectionCustomModule() - pb_resp = security_center_management.EventThreatDetectionCustomModule.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_event_threat_detection_custom_module(resp) - return resp - - class _GetSecurityHealthAnalyticsCustomModule(SecurityCenterManagementRestStub): - def __hash__(self): - return hash("GetSecurityHealthAnalyticsCustomModule") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> security_center_management.SecurityHealthAnalyticsCustomModule: - r"""Call the get security health - analytics custom module method over HTTP. - - Args: - request (~.security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest): - The request object. Message for getting a - SecurityHealthAnalyticsCustomModule - 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: - ~.security_center_management.SecurityHealthAnalyticsCustomModule: - Represents an instance of a Security - Health Analytics custom module, - including its full module name, display - name, enablement state, and last updated - time. You can create a custom module at - the organization, folder, or project - level. Custom modules that you create at - the organization or folder level are - inherited by the child folders and - projects. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{name=projects/*/locations/*/securityHealthAnalyticsCustomModules/*}', - }, -{ - 'method': 'get', - 'uri': '/v1/{name=folders/*/locations/*/securityHealthAnalyticsCustomModules/*}', - }, -{ - 'method': 'get', - 'uri': '/v1/{name=organizations/*/locations/*/securityHealthAnalyticsCustomModules/*}', - }, - ] - request, metadata = self._interceptor.pre_get_security_health_analytics_custom_module(request, metadata) - pb_request = security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) - query_params.update(self._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = security_center_management.SecurityHealthAnalyticsCustomModule() - pb_resp = security_center_management.SecurityHealthAnalyticsCustomModule.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_get_security_health_analytics_custom_module(resp) - return resp - - class _ListDescendantEventThreatDetectionCustomModules(SecurityCenterManagementRestStub): - def __hash__(self): - return hash("ListDescendantEventThreatDetectionCustomModules") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse: - r"""Call the list descendant event - threat detection custom modules method over HTTP. - - Args: - request (~.security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest): - The request object. Request message for listing - descendant Event Threat Detection custom - modules. - 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: - ~.security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse: - Response message for listing - descendant Event Threat Detection custom - modules. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{parent=projects/*/locations/*}/eventThreatDetectionCustomModules:listDescendant', - }, -{ - 'method': 'get', - 'uri': '/v1/{parent=folders/*/locations/*}/eventThreatDetectionCustomModules:listDescendant', - }, -{ - 'method': 'get', - 'uri': '/v1/{parent=organizations/*/locations/*}/eventThreatDetectionCustomModules:listDescendant', - }, - ] - request, metadata = self._interceptor.pre_list_descendant_event_threat_detection_custom_modules(request, metadata) - pb_request = security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) - query_params.update(self._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse() - pb_resp = security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_descendant_event_threat_detection_custom_modules(resp) - return resp - - class _ListDescendantSecurityHealthAnalyticsCustomModules(SecurityCenterManagementRestStub): - def __hash__(self): - return hash("ListDescendantSecurityHealthAnalyticsCustomModules") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse: - r"""Call the list descendant security - health analytics custom modules method over HTTP. - - Args: - request (~.security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest): - The request object. Request message for listing - descendant Security Health Analytics - custom modules. - 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: - ~.security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse: - Response message for listing - descendant Security Health Analytics - custom modules. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{parent=projects/*/locations/*}/securityHealthAnalyticsCustomModules:listDescendant', - }, -{ - 'method': 'get', - 'uri': '/v1/{parent=folders/*/locations/*}/securityHealthAnalyticsCustomModules:listDescendant', - }, -{ - 'method': 'get', - 'uri': '/v1/{parent=organizations/*/locations/*}/securityHealthAnalyticsCustomModules:listDescendant', - }, - ] - request, metadata = self._interceptor.pre_list_descendant_security_health_analytics_custom_modules(request, metadata) - pb_request = security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) - query_params.update(self._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse() - pb_resp = security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_descendant_security_health_analytics_custom_modules(resp) - return resp - - class _ListEffectiveEventThreatDetectionCustomModules(SecurityCenterManagementRestStub): - def __hash__(self): - return hash("ListEffectiveEventThreatDetectionCustomModules") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse: - r"""Call the list effective event - threat detection custom modules method over HTTP. - - Args: - request (~.security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest): - The request object. Request message for listing effective - Event Threat Detection custom modules. - 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: - ~.security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse: - Response message for listing - effective Event Threat Detection custom - modules. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{parent=projects/*/locations/*}/effectiveEventThreatDetectionCustomModules', - }, -{ - 'method': 'get', - 'uri': '/v1/{parent=folders/*/locations/*}/effectiveEventThreatDetectionCustomModules', - }, -{ - 'method': 'get', - 'uri': '/v1/{parent=organizations/*/locations/*}/effectiveEventThreatDetectionCustomModules', - }, - ] - request, metadata = self._interceptor.pre_list_effective_event_threat_detection_custom_modules(request, metadata) - pb_request = security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) - query_params.update(self._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse() - pb_resp = security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_effective_event_threat_detection_custom_modules(resp) - return resp - - class _ListEffectiveSecurityHealthAnalyticsCustomModules(SecurityCenterManagementRestStub): - def __hash__(self): - return hash("ListEffectiveSecurityHealthAnalyticsCustomModules") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse: - r"""Call the list effective security - health analytics custom modules method over HTTP. - - Args: - request (~.security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest): - The request object. Request message for listing effective - Security Health Analytics custom - modules. - 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: - ~.security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse: - Response message for listing - effective Security Health Analytics - custom modules. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{parent=projects/*/locations/*}/effectiveSecurityHealthAnalyticsCustomModules', - }, -{ - 'method': 'get', - 'uri': '/v1/{parent=folders/*/locations/*}/effectiveSecurityHealthAnalyticsCustomModules', - }, -{ - 'method': 'get', - 'uri': '/v1/{parent=organizations/*/locations/*}/effectiveSecurityHealthAnalyticsCustomModules', - }, - ] - request, metadata = self._interceptor.pre_list_effective_security_health_analytics_custom_modules(request, metadata) - pb_request = security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) - query_params.update(self._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse() - pb_resp = security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_effective_security_health_analytics_custom_modules(resp) - return resp - - class _ListEventThreatDetectionCustomModules(SecurityCenterManagementRestStub): - def __hash__(self): - return hash("ListEventThreatDetectionCustomModules") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: security_center_management.ListEventThreatDetectionCustomModulesRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> security_center_management.ListEventThreatDetectionCustomModulesResponse: - r"""Call the list event threat - detection custom modules method over HTTP. - - Args: - request (~.security_center_management.ListEventThreatDetectionCustomModulesRequest): - The request object. Request message for listing Event - Threat Detection custom modules. - 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: - ~.security_center_management.ListEventThreatDetectionCustomModulesResponse: - Response message for listing Event - Threat Detection custom modules. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{parent=projects/*/locations/*}/eventThreatDetectionCustomModules', - }, -{ - 'method': 'get', - 'uri': '/v1/{parent=folders/*/locations/*}/eventThreatDetectionCustomModules', - }, -{ - 'method': 'get', - 'uri': '/v1/{parent=organizations/*/locations/*}/eventThreatDetectionCustomModules', - }, - ] - request, metadata = self._interceptor.pre_list_event_threat_detection_custom_modules(request, metadata) - pb_request = security_center_management.ListEventThreatDetectionCustomModulesRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) - query_params.update(self._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = security_center_management.ListEventThreatDetectionCustomModulesResponse() - pb_resp = security_center_management.ListEventThreatDetectionCustomModulesResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_event_threat_detection_custom_modules(resp) - return resp - - class _ListSecurityHealthAnalyticsCustomModules(SecurityCenterManagementRestStub): - def __hash__(self): - return hash("ListSecurityHealthAnalyticsCustomModules") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse: - r"""Call the list security health - analytics custom modules method over HTTP. - - Args: - request (~.security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest): - The request object. Request message for listing Security - Health Analytics custom modules. - 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: - ~.security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse: - Response message for listing Security - Health Analytics custom modules. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{parent=projects/*/locations/*}/securityHealthAnalyticsCustomModules', - }, -{ - 'method': 'get', - 'uri': '/v1/{parent=folders/*/locations/*}/securityHealthAnalyticsCustomModules', - }, -{ - 'method': 'get', - 'uri': '/v1/{parent=organizations/*/locations/*}/securityHealthAnalyticsCustomModules', - }, - ] - request, metadata = self._interceptor.pre_list_security_health_analytics_custom_modules(request, metadata) - pb_request = security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) - query_params.update(self._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse() - pb_resp = security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_list_security_health_analytics_custom_modules(resp) - return resp - - class _SimulateSecurityHealthAnalyticsCustomModule(SecurityCenterManagementRestStub): - def __hash__(self): - return hash("SimulateSecurityHealthAnalyticsCustomModule") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse: - r"""Call the simulate security health - analytics custom module method over HTTP. - - Args: - request (~.security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest): - The request object. Request message to simulate a - CustomConfig against a given test - resource. Maximum size of the request is - 4 MB by default. - 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: - ~.security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse: - Response message for simulating a - ``SecurityHealthAnalyticsCustomModule`` against a given - resource. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v1/{parent=projects/*/locations/*}/securityHealthAnalyticsCustomModules:simulate', - 'body': '*', - }, -{ - 'method': 'post', - 'uri': '/v1/{parent=folders/*/locations/*}/securityHealthAnalyticsCustomModules:simulate', - 'body': '*', - }, -{ - 'method': 'post', - 'uri': '/v1/{parent=organizations/*/locations/*}/securityHealthAnalyticsCustomModules:simulate', - 'body': '*', - }, - ] - request, metadata = self._interceptor.pre_simulate_security_health_analytics_custom_module(request, metadata) - pb_request = security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request['body'], - including_default_value_fields=False, - use_integers_for_enums=True - ) - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) - query_params.update(self._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse() - pb_resp = security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_simulate_security_health_analytics_custom_module(resp) - return resp - - class _UpdateEventThreatDetectionCustomModule(SecurityCenterManagementRestStub): - def __hash__(self): - return hash("UpdateEventThreatDetectionCustomModule") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - "updateMask" : {}, } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: security_center_management.UpdateEventThreatDetectionCustomModuleRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> security_center_management.EventThreatDetectionCustomModule: - r"""Call the update event threat - detection custom module method over HTTP. - - Args: - request (~.security_center_management.UpdateEventThreatDetectionCustomModuleRequest): - The request object. Message for updating a - EventThreatDetectionCustomModule - 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: - ~.security_center_management.EventThreatDetectionCustomModule: - An event threat detection custom - module is a Cloud SCC resource that - contains the configuration and - enablement state of a custom module, - which enables ETD to write certain - findings to Cloud SCC. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'patch', - 'uri': '/v1/{event_threat_detection_custom_module.name=projects/*/locations/*/eventThreatDetectionCustomModules/*}', - 'body': 'event_threat_detection_custom_module', - }, -{ - 'method': 'patch', - 'uri': '/v1/{event_threat_detection_custom_module.name=folders/*/locations/*/eventThreatDetectionCustomModules/*}', - 'body': 'event_threat_detection_custom_module', - }, -{ - 'method': 'patch', - 'uri': '/v1/{event_threat_detection_custom_module.name=organizations/*/locations/*/eventThreatDetectionCustomModules/*}', - 'body': 'event_threat_detection_custom_module', - }, - ] - request, metadata = self._interceptor.pre_update_event_threat_detection_custom_module(request, metadata) - pb_request = security_center_management.UpdateEventThreatDetectionCustomModuleRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request['body'], - including_default_value_fields=False, - use_integers_for_enums=True - ) - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) - query_params.update(self._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = security_center_management.EventThreatDetectionCustomModule() - pb_resp = security_center_management.EventThreatDetectionCustomModule.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_update_event_threat_detection_custom_module(resp) - return resp - - class _UpdateSecurityHealthAnalyticsCustomModule(SecurityCenterManagementRestStub): - def __hash__(self): - return hash("UpdateSecurityHealthAnalyticsCustomModule") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - "updateMask" : {}, } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> security_center_management.SecurityHealthAnalyticsCustomModule: - r"""Call the update security health - analytics custom module method over HTTP. - - Args: - request (~.security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest): - The request object. Message for updating a - SecurityHealthAnalyticsCustomModule - 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: - ~.security_center_management.SecurityHealthAnalyticsCustomModule: - Represents an instance of a Security - Health Analytics custom module, - including its full module name, display - name, enablement state, and last updated - time. You can create a custom module at - the organization, folder, or project - level. Custom modules that you create at - the organization or folder level are - inherited by the child folders and - projects. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'patch', - 'uri': '/v1/{security_health_analytics_custom_module.name=projects/*/locations/*/securityHealthAnalyticsCustomModules/*}', - 'body': 'security_health_analytics_custom_module', - }, -{ - 'method': 'patch', - 'uri': '/v1/{security_health_analytics_custom_module.name=folders/*/locations/*/securityHealthAnalyticsCustomModules/*}', - 'body': 'security_health_analytics_custom_module', - }, -{ - 'method': 'patch', - 'uri': '/v1/{security_health_analytics_custom_module.name=organizations/*/locations/*/securityHealthAnalyticsCustomModules/*}', - 'body': 'security_health_analytics_custom_module', - }, - ] - request, metadata = self._interceptor.pre_update_security_health_analytics_custom_module(request, metadata) - pb_request = security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request['body'], - including_default_value_fields=False, - use_integers_for_enums=True - ) - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) - query_params.update(self._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = security_center_management.SecurityHealthAnalyticsCustomModule() - pb_resp = security_center_management.SecurityHealthAnalyticsCustomModule.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_update_security_health_analytics_custom_module(resp) - return resp - - class _ValidateEventThreatDetectionCustomModule(SecurityCenterManagementRestStub): - def __hash__(self): - return hash("ValidateEventThreatDetectionCustomModule") - - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = { - } - - @classmethod - def _get_unset_required_fields(cls, message_dict): - return {k: v for k, v in cls.__REQUIRED_FIELDS_DEFAULT_VALUES.items() if k not in message_dict} - - def __call__(self, - request: security_center_management.ValidateEventThreatDetectionCustomModuleRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> security_center_management.ValidateEventThreatDetectionCustomModuleResponse: - r"""Call the validate event threat - detection custom module method over HTTP. - - Args: - request (~.security_center_management.ValidateEventThreatDetectionCustomModuleRequest): - The request object. Request to validate an Event Threat - Detection custom module. - 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: - ~.security_center_management.ValidateEventThreatDetectionCustomModuleResponse: - Response to validating an Event - Threat Detection custom module. - - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'post', - 'uri': '/v1/{parent=projects/*/locations/*}/eventThreatDetectionCustomModules:validate', - 'body': '*', - }, -{ - 'method': 'post', - 'uri': '/v1/{parent=folders/*/locations/*}/eventThreatDetectionCustomModules:validate', - 'body': '*', - }, -{ - 'method': 'post', - 'uri': '/v1/{parent=organizations/*/locations/*}/eventThreatDetectionCustomModules:validate', - 'body': '*', - }, - ] - request, metadata = self._interceptor.pre_validate_event_threat_detection_custom_module(request, metadata) - pb_request = security_center_management.ValidateEventThreatDetectionCustomModuleRequest.pb(request) - transcoded_request = path_template.transcode(http_options, pb_request) - - # Jsonify the request body - - body = json_format.MessageToJson( - transcoded_request['body'], - including_default_value_fields=False, - use_integers_for_enums=True - ) - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json_format.MessageToJson( - transcoded_request['query_params'], - including_default_value_fields=False, - use_integers_for_enums=True, - )) - query_params.update(self._get_unset_required_fields(query_params)) - - query_params["$alt"] = "json;enum-encoding=int" - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params, strict=True), - data=body, - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - # Return the response - resp = security_center_management.ValidateEventThreatDetectionCustomModuleResponse() - pb_resp = security_center_management.ValidateEventThreatDetectionCustomModuleResponse.pb(resp) - - json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) - resp = self._interceptor.post_validate_event_threat_detection_custom_module(resp) - return resp - - @property - def create_event_threat_detection_custom_module(self) -> Callable[ - [security_center_management.CreateEventThreatDetectionCustomModuleRequest], - security_center_management.EventThreatDetectionCustomModule]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._CreateEventThreatDetectionCustomModule(self._session, self._host, self._interceptor) # type: ignore - - @property - def create_security_health_analytics_custom_module(self) -> Callable[ - [security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest], - security_center_management.SecurityHealthAnalyticsCustomModule]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._CreateSecurityHealthAnalyticsCustomModule(self._session, self._host, self._interceptor) # type: ignore - - @property - def delete_event_threat_detection_custom_module(self) -> Callable[ - [security_center_management.DeleteEventThreatDetectionCustomModuleRequest], - empty_pb2.Empty]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._DeleteEventThreatDetectionCustomModule(self._session, self._host, self._interceptor) # type: ignore - - @property - def delete_security_health_analytics_custom_module(self) -> Callable[ - [security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest], - empty_pb2.Empty]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._DeleteSecurityHealthAnalyticsCustomModule(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_effective_event_threat_detection_custom_module(self) -> Callable[ - [security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest], - security_center_management.EffectiveEventThreatDetectionCustomModule]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._GetEffectiveEventThreatDetectionCustomModule(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_effective_security_health_analytics_custom_module(self) -> Callable[ - [security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest], - security_center_management.EffectiveSecurityHealthAnalyticsCustomModule]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._GetEffectiveSecurityHealthAnalyticsCustomModule(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_event_threat_detection_custom_module(self) -> Callable[ - [security_center_management.GetEventThreatDetectionCustomModuleRequest], - security_center_management.EventThreatDetectionCustomModule]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._GetEventThreatDetectionCustomModule(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_security_health_analytics_custom_module(self) -> Callable[ - [security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest], - security_center_management.SecurityHealthAnalyticsCustomModule]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._GetSecurityHealthAnalyticsCustomModule(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_descendant_event_threat_detection_custom_modules(self) -> Callable[ - [security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest], - security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._ListDescendantEventThreatDetectionCustomModules(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_descendant_security_health_analytics_custom_modules(self) -> Callable[ - [security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest], - security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._ListDescendantSecurityHealthAnalyticsCustomModules(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_effective_event_threat_detection_custom_modules(self) -> Callable[ - [security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest], - security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._ListEffectiveEventThreatDetectionCustomModules(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_effective_security_health_analytics_custom_modules(self) -> Callable[ - [security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest], - security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._ListEffectiveSecurityHealthAnalyticsCustomModules(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_event_threat_detection_custom_modules(self) -> Callable[ - [security_center_management.ListEventThreatDetectionCustomModulesRequest], - security_center_management.ListEventThreatDetectionCustomModulesResponse]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._ListEventThreatDetectionCustomModules(self._session, self._host, self._interceptor) # type: ignore - - @property - def list_security_health_analytics_custom_modules(self) -> Callable[ - [security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest], - security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._ListSecurityHealthAnalyticsCustomModules(self._session, self._host, self._interceptor) # type: ignore - - @property - def simulate_security_health_analytics_custom_module(self) -> Callable[ - [security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest], - security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._SimulateSecurityHealthAnalyticsCustomModule(self._session, self._host, self._interceptor) # type: ignore - - @property - def update_event_threat_detection_custom_module(self) -> Callable[ - [security_center_management.UpdateEventThreatDetectionCustomModuleRequest], - security_center_management.EventThreatDetectionCustomModule]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._UpdateEventThreatDetectionCustomModule(self._session, self._host, self._interceptor) # type: ignore - - @property - def update_security_health_analytics_custom_module(self) -> Callable[ - [security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest], - security_center_management.SecurityHealthAnalyticsCustomModule]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._UpdateSecurityHealthAnalyticsCustomModule(self._session, self._host, self._interceptor) # type: ignore - - @property - def validate_event_threat_detection_custom_module(self) -> Callable[ - [security_center_management.ValidateEventThreatDetectionCustomModuleRequest], - security_center_management.ValidateEventThreatDetectionCustomModuleResponse]: - # The return type is fine, but mypy isn't sophisticated enough to determine what's going on here. - # In C++ this would require a dynamic_cast - return self._ValidateEventThreatDetectionCustomModule(self._session, self._host, self._interceptor) # type: ignore - - @property - def get_location(self): - return self._GetLocation(self._session, self._host, self._interceptor) # type: ignore - - class _GetLocation(SecurityCenterManagementRestStub): - def __call__(self, - request: locations_pb2.GetLocationRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> locations_pb2.Location: - - r"""Call the get location method over HTTP. - - Args: - request (locations_pb2.GetLocationRequest): - The request object for GetLocation method. - 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: - locations_pb2.Location: Response from GetLocation method. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{name=projects/*/locations/*}', - }, - ] - - request, metadata = self._interceptor.pre_get_location(request, metadata) - request_kwargs = json_format.MessageToDict(request) - transcoded_request = path_template.transcode( - http_options, **request_kwargs) - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json.dumps(transcoded_request['query_params'])) - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params), - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - resp = locations_pb2.Location() - resp = json_format.Parse(response.content.decode("utf-8"), resp) - resp = self._interceptor.post_get_location(resp) - return resp - - @property - def list_locations(self): - return self._ListLocations(self._session, self._host, self._interceptor) # type: ignore - - class _ListLocations(SecurityCenterManagementRestStub): - def __call__(self, - request: locations_pb2.ListLocationsRequest, *, - retry: OptionalRetry=gapic_v1.method.DEFAULT, - timeout: Optional[float]=None, - metadata: Sequence[Tuple[str, str]]=(), - ) -> locations_pb2.ListLocationsResponse: - - r"""Call the list locations method over HTTP. - - Args: - request (locations_pb2.ListLocationsRequest): - The request object for ListLocations method. - 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: - locations_pb2.ListLocationsResponse: Response from ListLocations method. - """ - - http_options: List[Dict[str, str]] = [{ - 'method': 'get', - 'uri': '/v1/{name=projects/*}/locations', - }, - ] - - request, metadata = self._interceptor.pre_list_locations(request, metadata) - request_kwargs = json_format.MessageToDict(request) - transcoded_request = path_template.transcode( - http_options, **request_kwargs) - - uri = transcoded_request['uri'] - method = transcoded_request['method'] - - # Jsonify the query params - query_params = json.loads(json.dumps(transcoded_request['query_params'])) - - # Send the request - headers = dict(metadata) - headers['Content-Type'] = 'application/json' - - response = getattr(self._session, method)( - "{host}{uri}".format(host=self._host, uri=uri), - timeout=timeout, - headers=headers, - params=rest_helpers.flatten_query_params(query_params), - ) - - # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception - # subclass. - if response.status_code >= 400: - raise core_exceptions.from_http_response(response) - - resp = locations_pb2.ListLocationsResponse() - resp = json_format.Parse(response.content.decode("utf-8"), resp) - resp = self._interceptor.post_list_locations(resp) - return resp - - @property - def kind(self) -> str: - return "rest" - - def close(self): - self._session.close() - - -__all__=( - 'SecurityCenterManagementRestTransport', -) diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/types/__init__.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/types/__init__.py deleted file mode 100644 index f04c46589738..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/types/__init__.py +++ /dev/null @@ -1,84 +0,0 @@ -# -*- 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. -# -from .security_center_management import ( - CreateEventThreatDetectionCustomModuleRequest, - CreateSecurityHealthAnalyticsCustomModuleRequest, - CustomConfig, - DeleteEventThreatDetectionCustomModuleRequest, - DeleteSecurityHealthAnalyticsCustomModuleRequest, - EffectiveEventThreatDetectionCustomModule, - EffectiveSecurityHealthAnalyticsCustomModule, - EventThreatDetectionCustomModule, - GetEffectiveEventThreatDetectionCustomModuleRequest, - GetEffectiveSecurityHealthAnalyticsCustomModuleRequest, - GetEventThreatDetectionCustomModuleRequest, - GetSecurityHealthAnalyticsCustomModuleRequest, - ListDescendantEventThreatDetectionCustomModulesRequest, - ListDescendantEventThreatDetectionCustomModulesResponse, - ListDescendantSecurityHealthAnalyticsCustomModulesRequest, - ListDescendantSecurityHealthAnalyticsCustomModulesResponse, - ListEffectiveEventThreatDetectionCustomModulesRequest, - ListEffectiveEventThreatDetectionCustomModulesResponse, - ListEffectiveSecurityHealthAnalyticsCustomModulesRequest, - ListEffectiveSecurityHealthAnalyticsCustomModulesResponse, - ListEventThreatDetectionCustomModulesRequest, - ListEventThreatDetectionCustomModulesResponse, - ListSecurityHealthAnalyticsCustomModulesRequest, - ListSecurityHealthAnalyticsCustomModulesResponse, - SecurityHealthAnalyticsCustomModule, - SimulatedFinding, - SimulateSecurityHealthAnalyticsCustomModuleRequest, - SimulateSecurityHealthAnalyticsCustomModuleResponse, - UpdateEventThreatDetectionCustomModuleRequest, - UpdateSecurityHealthAnalyticsCustomModuleRequest, - ValidateEventThreatDetectionCustomModuleRequest, - ValidateEventThreatDetectionCustomModuleResponse, -) - -__all__ = ( - 'CreateEventThreatDetectionCustomModuleRequest', - 'CreateSecurityHealthAnalyticsCustomModuleRequest', - 'CustomConfig', - 'DeleteEventThreatDetectionCustomModuleRequest', - 'DeleteSecurityHealthAnalyticsCustomModuleRequest', - 'EffectiveEventThreatDetectionCustomModule', - 'EffectiveSecurityHealthAnalyticsCustomModule', - 'EventThreatDetectionCustomModule', - 'GetEffectiveEventThreatDetectionCustomModuleRequest', - 'GetEffectiveSecurityHealthAnalyticsCustomModuleRequest', - 'GetEventThreatDetectionCustomModuleRequest', - 'GetSecurityHealthAnalyticsCustomModuleRequest', - 'ListDescendantEventThreatDetectionCustomModulesRequest', - 'ListDescendantEventThreatDetectionCustomModulesResponse', - 'ListDescendantSecurityHealthAnalyticsCustomModulesRequest', - 'ListDescendantSecurityHealthAnalyticsCustomModulesResponse', - 'ListEffectiveEventThreatDetectionCustomModulesRequest', - 'ListEffectiveEventThreatDetectionCustomModulesResponse', - 'ListEffectiveSecurityHealthAnalyticsCustomModulesRequest', - 'ListEffectiveSecurityHealthAnalyticsCustomModulesResponse', - 'ListEventThreatDetectionCustomModulesRequest', - 'ListEventThreatDetectionCustomModulesResponse', - 'ListSecurityHealthAnalyticsCustomModulesRequest', - 'ListSecurityHealthAnalyticsCustomModulesResponse', - 'SecurityHealthAnalyticsCustomModule', - 'SimulatedFinding', - 'SimulateSecurityHealthAnalyticsCustomModuleRequest', - 'SimulateSecurityHealthAnalyticsCustomModuleResponse', - 'UpdateEventThreatDetectionCustomModuleRequest', - 'UpdateSecurityHealthAnalyticsCustomModuleRequest', - 'ValidateEventThreatDetectionCustomModuleRequest', - 'ValidateEventThreatDetectionCustomModuleResponse', -) diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/types/security_center_management.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/types/security_center_management.py deleted file mode 100644 index 9fc59ef014c3..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/google/cloud/securitycentermanagement_v1/types/security_center_management.py +++ /dev/null @@ -1,1771 +0,0 @@ -# -*- 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. -# -from __future__ import annotations - -from typing import MutableMapping, MutableSequence - -import proto # type: ignore - -from google.iam.v1 import policy_pb2 # type: ignore -from google.protobuf import empty_pb2 # type: ignore -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import struct_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore -from google.rpc import status_pb2 # type: ignore -from google.type import expr_pb2 # type: ignore - - -__protobuf__ = proto.module( - package='google.cloud.securitycentermanagement.v1', - manifest={ - 'EffectiveSecurityHealthAnalyticsCustomModule', - 'ListEffectiveSecurityHealthAnalyticsCustomModulesRequest', - 'ListEffectiveSecurityHealthAnalyticsCustomModulesResponse', - 'GetEffectiveSecurityHealthAnalyticsCustomModuleRequest', - 'SecurityHealthAnalyticsCustomModule', - 'CustomConfig', - 'ListSecurityHealthAnalyticsCustomModulesRequest', - 'ListSecurityHealthAnalyticsCustomModulesResponse', - 'ListDescendantSecurityHealthAnalyticsCustomModulesRequest', - 'ListDescendantSecurityHealthAnalyticsCustomModulesResponse', - 'GetSecurityHealthAnalyticsCustomModuleRequest', - 'CreateSecurityHealthAnalyticsCustomModuleRequest', - 'UpdateSecurityHealthAnalyticsCustomModuleRequest', - 'DeleteSecurityHealthAnalyticsCustomModuleRequest', - 'SimulateSecurityHealthAnalyticsCustomModuleRequest', - 'SimulatedFinding', - 'SimulateSecurityHealthAnalyticsCustomModuleResponse', - 'EffectiveEventThreatDetectionCustomModule', - 'ListEffectiveEventThreatDetectionCustomModulesRequest', - 'ListEffectiveEventThreatDetectionCustomModulesResponse', - 'GetEffectiveEventThreatDetectionCustomModuleRequest', - 'EventThreatDetectionCustomModule', - 'ListEventThreatDetectionCustomModulesRequest', - 'ListEventThreatDetectionCustomModulesResponse', - 'ListDescendantEventThreatDetectionCustomModulesRequest', - 'ListDescendantEventThreatDetectionCustomModulesResponse', - 'GetEventThreatDetectionCustomModuleRequest', - 'CreateEventThreatDetectionCustomModuleRequest', - 'UpdateEventThreatDetectionCustomModuleRequest', - 'DeleteEventThreatDetectionCustomModuleRequest', - 'ValidateEventThreatDetectionCustomModuleRequest', - 'ValidateEventThreatDetectionCustomModuleResponse', - }, -) - - -class EffectiveSecurityHealthAnalyticsCustomModule(proto.Message): - r"""An EffectiveSecurityHealthAnalyticsCustomModule is the - representation of a Security Health Analytics custom module at a - specified level of the resource hierarchy: organization, folder, or - project. If a custom module is inherited from a parent organization - or folder, the value of the ``enablementState`` property in - EffectiveSecurityHealthAnalyticsCustomModule is set to the value - that is effective in the parent, instead of ``INHERITED``. For - example, if the module is enabled in a parent organization or - folder, the effective enablement_state for the module in all child - folders or projects is also ``enabled``. - EffectiveSecurityHealthAnalyticsCustomModule is read-only. - - Attributes: - name (str): - Output only. The resource name of the custom module. Its - format is - "organizations/{organization}/locations/{location}/effectiveSecurityHealthAnalyticsCustomModules/{effective_security_health_analytics_custom_module}", - or - "folders/{folder}/locations/{location}/effectiveSecurityHealthAnalyticsCustomModules/{effective_security_health_analytics_custom_module}", - or - "projects/{project}/locations/{location}/effectiveSecurityHealthAnalyticsCustomModules/{effective_security_health_analytics_custom_module}". - custom_config (google.cloud.securitycentermanagement_v1.types.CustomConfig): - Output only. The user-specified configuration - for the module. - enablement_state (google.cloud.securitycentermanagement_v1.types.EffectiveSecurityHealthAnalyticsCustomModule.EnablementState): - Output only. The effective state of - enablement for the module at the given level of - the hierarchy. - display_name (str): - Output only. The display name for the custom - module. The name must be between 1 and 128 - characters, start with a lowercase letter, and - contain alphanumeric characters or underscores - only. - """ - class EnablementState(proto.Enum): - r"""The enablement state of the module. - - Values: - ENABLEMENT_STATE_UNSPECIFIED (0): - Unspecified enablement state. - ENABLED (1): - The module is enabled at the given level. - DISABLED (2): - The module is disabled at the given level. - """ - ENABLEMENT_STATE_UNSPECIFIED = 0 - ENABLED = 1 - DISABLED = 2 - - name: str = proto.Field( - proto.STRING, - number=1, - ) - custom_config: 'CustomConfig' = proto.Field( - proto.MESSAGE, - number=2, - message='CustomConfig', - ) - enablement_state: EnablementState = proto.Field( - proto.ENUM, - number=3, - enum=EnablementState, - ) - display_name: str = proto.Field( - proto.STRING, - number=4, - ) - - -class ListEffectiveSecurityHealthAnalyticsCustomModulesRequest(proto.Message): - r"""Request message for listing effective Security Health - Analytics custom modules. - - Attributes: - parent (str): - Required. Name of parent to list effective - custom modules. Its format is - "organizations/{organization}/locations/{location}", - "folders/{folder}/locations/{location}", - or - "projects/{project}/locations/{location}". - page_size (int): - Optional. The maximum number of results to - return in a single response. Default is 10, - minimum is 1, maximum is 1000. - page_token (str): - Optional. The value returned by the last call - indicating a continuation - """ - - 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 ListEffectiveSecurityHealthAnalyticsCustomModulesResponse(proto.Message): - r"""Response message for listing effective Security Health - Analytics custom modules. - - Attributes: - effective_security_health_analytics_custom_modules (MutableSequence[google.cloud.securitycentermanagement_v1.types.EffectiveSecurityHealthAnalyticsCustomModule]): - The list of - EffectiveSecurityHealthAnalyticsCustomModule - next_page_token (str): - A token identifying a page of results the - server should return. - """ - - @property - def raw_page(self): - return self - - effective_security_health_analytics_custom_modules: MutableSequence['EffectiveSecurityHealthAnalyticsCustomModule'] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='EffectiveSecurityHealthAnalyticsCustomModule', - ) - next_page_token: str = proto.Field( - proto.STRING, - number=2, - ) - - -class GetEffectiveSecurityHealthAnalyticsCustomModuleRequest(proto.Message): - r"""Message for getting a - EffectiveSecurityHealthAnalyticsCustomModule - - Attributes: - name (str): - Required. The resource name of the SHA custom module. - - Its format is: - - - "organizations/{organization}/locations/{location}/effectiveSecurityHealthAnalyticsCustomModules/{module_id}". - - "folders/{folder}/locations/{location}/effectiveSecurityHealthAnalyticsCustomModules/{module_id}". - - "projects/{project}/locations/{location}/effectiveSecurityHealthAnalyticsCustomModules/{module_id}". - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class SecurityHealthAnalyticsCustomModule(proto.Message): - r"""Represents an instance of a Security Health Analytics custom - module, including its full module name, display name, enablement - state, and last updated time. You can create a custom module at - the organization, folder, or project level. Custom modules that - you create at the organization or folder level are inherited by - the child folders and projects. - - Attributes: - name (str): - Immutable. The resource name of the custom module. Its - format is - "organizations/{organization}/locations/{location}/securityHealthAnalyticsCustomModules/{security_health_analytics_custom_module}", - or - "folders/{folder}/locations/{location}/securityHealthAnalyticsCustomModules/{security_health_analytics_custom_module}", - or - "projects/{project}/locations/{location}/securityHealthAnalyticsCustomModules/{security_health_analytics_custom_module}" - - The id {customModule} is server-generated and is not user - settable. It will be a numeric id containing 1-20 digits. - display_name (str): - Optional. The display name of the Security - Health Analytics custom module. This display - name becomes the finding category for all - findings that are returned by this custom - module. The display name must be between 1 and - 128 characters, start with a lowercase letter, - and contain alphanumeric characters or - underscores only. - enablement_state (google.cloud.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule.EnablementState): - Optional. The enablement state of the custom - module. - update_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time at which the custom - module was last updated. - last_editor (str): - Output only. The editor that last updated the - custom module. - ancestor_module (str): - Output only. Specifies the organization or - folder from which the custom module is - inherited. If empty, indicates that the custom - module was created in the organization, folder, - or project in which you are viewing the custom - module. - custom_config (google.cloud.securitycentermanagement_v1.types.CustomConfig): - Optional. The user specified custom - configuration for the module. - """ - class EnablementState(proto.Enum): - r"""Possible enablement states of a custom module. - - Values: - ENABLEMENT_STATE_UNSPECIFIED (0): - Unspecified enablement state. - ENABLED (1): - The module is enabled at the given CRM - resource. - DISABLED (2): - The module is disabled at the given CRM - resource. - INHERITED (3): - State is inherited from an ancestor module. The module will - either be effectively ENABLED or DISABLED based on its - closest non-inherited ancestor module in the CRM hierarchy. - Attempting to set a top level module (module with no parent) - to the INHERITED state will result in an INVALID_ARGUMENT - error. - """ - ENABLEMENT_STATE_UNSPECIFIED = 0 - ENABLED = 1 - DISABLED = 2 - INHERITED = 3 - - name: str = proto.Field( - proto.STRING, - number=1, - ) - display_name: str = proto.Field( - proto.STRING, - number=2, - ) - enablement_state: EnablementState = proto.Field( - proto.ENUM, - number=3, - enum=EnablementState, - ) - update_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=4, - message=timestamp_pb2.Timestamp, - ) - last_editor: str = proto.Field( - proto.STRING, - number=5, - ) - ancestor_module: str = proto.Field( - proto.STRING, - number=6, - ) - custom_config: 'CustomConfig' = proto.Field( - proto.MESSAGE, - number=7, - message='CustomConfig', - ) - - -class CustomConfig(proto.Message): - r"""Defines the properties in a custom module configuration for - Security Health Analytics. Use the custom module configuration - to create custom detectors that generate custom findings for - resources that you specify. - - Attributes: - predicate (google.type.expr_pb2.Expr): - Optional. The CEL expression to evaluate to - produce findings. When the expression evaluates - to true against a resource, a finding is - generated. - custom_output (google.cloud.securitycentermanagement_v1.types.CustomConfig.CustomOutputSpec): - Optional. Custom output properties. - resource_selector (google.cloud.securitycentermanagement_v1.types.CustomConfig.ResourceSelector): - Optional. The CAI resource types that the - custom module operates on (see - go/gcp-cai-doc/supported-asset-types). Each - custom module can specify up to 5 resource - types. - severity (google.cloud.securitycentermanagement_v1.types.CustomConfig.Severity): - Optional. The severity to assign to findings - generated by the module. - description (str): - Optional. Text that describes the - vulnerability or misconfiguration that the - custom module detects. This explanation is - returned with each finding instance to help - investigators understand the detected issue. The - text must be enclosed in quotation marks. - recommendation (str): - Optional. An explanation of the recommended steps that - security teams can take to resolve the detected issue. This - explanation is returned with each finding generated by this - module in the ``nextSteps`` property of the finding JSON. - """ - class Severity(proto.Enum): - r"""Defines the valid value options for the severity of a - finding. - - Values: - SEVERITY_UNSPECIFIED (0): - Unspecified severity. - CRITICAL (1): - Critical severity. - HIGH (2): - High severity. - MEDIUM (3): - Medium severity. - LOW (4): - Low severity. - """ - SEVERITY_UNSPECIFIED = 0 - CRITICAL = 1 - HIGH = 2 - MEDIUM = 3 - LOW = 4 - - class CustomOutputSpec(proto.Message): - r"""A set of optional name-value pairs that define custom source - properties to return with each finding that is generated by the - custom module. The custom source properties that are defined here - are included in the finding JSON under ``sourceProperties``. - - Attributes: - properties (MutableSequence[google.cloud.securitycentermanagement_v1.types.CustomConfig.CustomOutputSpec.Property]): - Optional. A list of custom output properties - to add to the finding. - """ - - class Property(proto.Message): - r"""An individual name-value pair that defines a custom source - property. - - Attributes: - name (str): - Optional. Name of the property for the custom - output. - value_expression (google.type.expr_pb2.Expr): - Optional. The CEL expression for the custom - output. A resource property can be specified to - return the value of the property or a text - string enclosed in quotation marks. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - value_expression: expr_pb2.Expr = proto.Field( - proto.MESSAGE, - number=2, - message=expr_pb2.Expr, - ) - - properties: MutableSequence['CustomConfig.CustomOutputSpec.Property'] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='CustomConfig.CustomOutputSpec.Property', - ) - - class ResourceSelector(proto.Message): - r"""Resource for selecting resource type. - - Attributes: - resource_types (MutableSequence[str]): - Optional. The resource types to run the - detector on. - """ - - resource_types: MutableSequence[str] = proto.RepeatedField( - proto.STRING, - number=1, - ) - - predicate: expr_pb2.Expr = proto.Field( - proto.MESSAGE, - number=1, - message=expr_pb2.Expr, - ) - custom_output: CustomOutputSpec = proto.Field( - proto.MESSAGE, - number=2, - message=CustomOutputSpec, - ) - resource_selector: ResourceSelector = proto.Field( - proto.MESSAGE, - number=3, - message=ResourceSelector, - ) - severity: Severity = proto.Field( - proto.ENUM, - number=4, - enum=Severity, - ) - description: str = proto.Field( - proto.STRING, - number=5, - ) - recommendation: str = proto.Field( - proto.STRING, - number=6, - ) - - -class ListSecurityHealthAnalyticsCustomModulesRequest(proto.Message): - r"""Request message for listing Security Health Analytics custom - modules. - - Attributes: - parent (str): - Required. Name of parent to list custom - modules. Its format is - "organizations/{organization}/locations/{location}", - "folders/{folder}/locations/{location}", - or - "projects/{project}/locations/{location}". - page_size (int): - Optional. The maximum number of results to - return in a single response. Default is 10, - minimum is 1, maximum is 1000. - page_token (str): - Optional. A token identifying a page of - results the server should return. - """ - - 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 ListSecurityHealthAnalyticsCustomModulesResponse(proto.Message): - r"""Response message for listing Security Health Analytics custom - modules. - - Attributes: - security_health_analytics_custom_modules (MutableSequence[google.cloud.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule]): - The list of - SecurityHealthAnalyticsCustomModules - next_page_token (str): - A token identifying a page of results the - server should return. - """ - - @property - def raw_page(self): - return self - - security_health_analytics_custom_modules: MutableSequence['SecurityHealthAnalyticsCustomModule'] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='SecurityHealthAnalyticsCustomModule', - ) - next_page_token: str = proto.Field( - proto.STRING, - number=2, - ) - - -class ListDescendantSecurityHealthAnalyticsCustomModulesRequest(proto.Message): - r"""Request message for listing descendant Security Health - Analytics custom modules. - - Attributes: - parent (str): - Required. Name of parent to list custom - modules. Its format is - "organizations/{organization}/locations/{location}", - "folders/{folder}/locations/{location}", - or - "projects/{project}/locations/{location}". - page_size (int): - Optional. The maximum number of results to - return in a single response. Default is 10, - minimum is 1, maximum is 1000. - page_token (str): - Optional. A token identifying a page of - results the server should return. - """ - - 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 ListDescendantSecurityHealthAnalyticsCustomModulesResponse(proto.Message): - r"""Response message for listing descendant Security Health - Analytics custom modules. - - Attributes: - security_health_analytics_custom_modules (MutableSequence[google.cloud.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule]): - The list of - SecurityHealthAnalyticsCustomModules - next_page_token (str): - A token identifying a page of results the - server should return. - """ - - @property - def raw_page(self): - return self - - security_health_analytics_custom_modules: MutableSequence['SecurityHealthAnalyticsCustomModule'] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='SecurityHealthAnalyticsCustomModule', - ) - next_page_token: str = proto.Field( - proto.STRING, - number=2, - ) - - -class GetSecurityHealthAnalyticsCustomModuleRequest(proto.Message): - r"""Message for getting a SecurityHealthAnalyticsCustomModule - - Attributes: - name (str): - Required. Name of the resource - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class CreateSecurityHealthAnalyticsCustomModuleRequest(proto.Message): - r"""Message for creating a SecurityHealthAnalyticsCustomModule - - Attributes: - parent (str): - Required. Name of the parent for the module. - Its format is - "organizations/{organization}/locations/{location}", - "folders/{folder}/locations/{location}", - or - "projects/{project}/locations/{location}". - security_health_analytics_custom_module (google.cloud.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule): - Required. The resource being created - validate_only (bool): - Optional. When set to true, only validations - (including IAM checks) will done for the request - (no module will be created). An OK response - indicates the request is valid while an error - response indicates the request is invalid. Note - that a subsequent request to actually create the - module could still fail because: - - 1. the state could have changed (e.g. IAM - permission lost) or - 2. A failure occurred during creation of the - module. Defaults to false. - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - security_health_analytics_custom_module: 'SecurityHealthAnalyticsCustomModule' = proto.Field( - proto.MESSAGE, - number=2, - message='SecurityHealthAnalyticsCustomModule', - ) - validate_only: bool = proto.Field( - proto.BOOL, - number=3, - ) - - -class UpdateSecurityHealthAnalyticsCustomModuleRequest(proto.Message): - r"""Message for updating a SecurityHealthAnalyticsCustomModule - - Attributes: - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. Field mask is used to specify the fields to be - overwritten in the SecurityHealthAnalyticsCustomModule - resource by the update. The fields specified in the - update_mask are relative to the resource, not the full - request. A field will be overwritten if it is in the mask. - If the user does not provide a mask then all fields will be - overwritten. - security_health_analytics_custom_module (google.cloud.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule): - Required. The resource being updated - validate_only (bool): - Optional. When set to true, only validations - (including IAM checks) will done for the request - (module will not be updated). An OK response - indicates the request is valid while an error - response indicates the request is invalid. Note - that a subsequent request to actually update the - module could still fail because 1. the state - could have changed (e.g. IAM permission lost) or - 2. A failure occurred while trying to update the - module. - """ - - update_mask: field_mask_pb2.FieldMask = proto.Field( - proto.MESSAGE, - number=1, - message=field_mask_pb2.FieldMask, - ) - security_health_analytics_custom_module: 'SecurityHealthAnalyticsCustomModule' = proto.Field( - proto.MESSAGE, - number=2, - message='SecurityHealthAnalyticsCustomModule', - ) - validate_only: bool = proto.Field( - proto.BOOL, - number=3, - ) - - -class DeleteSecurityHealthAnalyticsCustomModuleRequest(proto.Message): - r"""Message for deleting a SecurityHealthAnalyticsCustomModule - - Attributes: - name (str): - Required. The resource name of the SHA custom module. - - Its format is: - - - "organizations/{organization}/locations/{location}/securityHealthAnalyticsCustomModules/{security_health_analytics_custom_module}". - - "folders/{folder}/locations/{location}/securityHealthAnalyticsCustomModules/{security_health_analytics_custom_module}". - - "projects/{project}/locations/{location}/securityHealthAnalyticsCustomModules/{security_health_analytics_custom_module}". - validate_only (bool): - Optional. When set to true, only validations - (including IAM checks) will done for the request - (module will not be deleted). An OK response - indicates the request is valid while an error - response indicates the request is invalid. Note - that a subsequent request to actually delete the - module could still fail because 1. the state - could have changed (e.g. IAM permission lost) or - 2. A failure occurred while trying to delete the - module. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - validate_only: bool = proto.Field( - proto.BOOL, - number=2, - ) - - -class SimulateSecurityHealthAnalyticsCustomModuleRequest(proto.Message): - r"""Request message to simulate a CustomConfig against a given - test resource. Maximum size of the request is 4 MB by default. - - Attributes: - parent (str): - Required. The relative resource name of the organization, - project, or folder. For more information about relative - resource names, see `Relative Resource - Name `__ - Example: ``organizations/{organization_id}``. - custom_config (google.cloud.securitycentermanagement_v1.types.CustomConfig): - Required. The custom configuration that you - need to test. - resource (google.cloud.securitycentermanagement_v1.types.SimulateSecurityHealthAnalyticsCustomModuleRequest.SimulatedResource): - Required. Resource data to simulate custom - module against. - """ - - class SimulatedResource(proto.Message): - r"""Manually constructed resource name. If the custom module evaluates - against only the resource data, you can omit the ``iam_policy_data`` - field. If it evaluates only the ``iam_policy_data`` field, you can - omit the resource data. - - Attributes: - resource_type (str): - Required. The type of the resource, for example, - ``compute.googleapis.com/Disk``. - resource_data (google.protobuf.struct_pb2.Struct): - Optional. A representation of the Google - Cloud resource. Should match the Google Cloud - resource JSON format. - iam_policy_data (google.iam.v1.policy_pb2.Policy): - Optional. A representation of the IAM policy. - """ - - resource_type: str = proto.Field( - proto.STRING, - number=1, - ) - resource_data: struct_pb2.Struct = proto.Field( - proto.MESSAGE, - number=2, - message=struct_pb2.Struct, - ) - iam_policy_data: policy_pb2.Policy = proto.Field( - proto.MESSAGE, - number=3, - message=policy_pb2.Policy, - ) - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - custom_config: 'CustomConfig' = proto.Field( - proto.MESSAGE, - number=2, - message='CustomConfig', - ) - resource: SimulatedResource = proto.Field( - proto.MESSAGE, - number=3, - message=SimulatedResource, - ) - - -class SimulatedFinding(proto.Message): - r"""A subset of the fields of the Security Center Finding proto. - The minimum set of fields needed to represent a simulated - finding from a SHA custom module. - - Attributes: - name (str): - Identifier. The `relative resource - name `__ - of the finding. Example: - "organizations/{organization_id}/sources/{source_id}/findings/{finding_id}", - "folders/{folder_id}/sources/{source_id}/findings/{finding_id}", - "projects/{project_id}/sources/{source_id}/findings/{finding_id}". - parent (str): - The relative resource name of the source the finding belongs - to. See: - https://cloud.google.com/apis/design/resource_names#relative_resource_name - This field is immutable after creation time. For example: - "organizations/{organization_id}/sources/{source_id}". - resource_name (str): - For findings on Google Cloud resources, the full resource - name of the Google Cloud resource this finding is for. See: - https://cloud.google.com/apis/design/resource_names#full_resource_name - When the finding is for a non-Google Cloud resource, the - resourceName can be a customer or partner defined string. - This field is immutable after creation time. - category (str): - The additional taxonomy group within findings from a given - source. This field is immutable after creation time. - Example: "XSS_FLASH_INJECTION". - state (google.cloud.securitycentermanagement_v1.types.SimulatedFinding.State): - Output only. The state of the finding. - source_properties (MutableMapping[str, google.protobuf.struct_pb2.Value]): - Source specific properties. These properties are managed by - the source that writes the finding. The key names in the - source_properties map must be between 1 and 255 characters, - and must start with a letter and contain alphanumeric - characters or underscores only. - event_time (google.protobuf.timestamp_pb2.Timestamp): - The time the finding was first detected. If - an existing finding is updated, then this is the - time the update occurred. For example, if the - finding represents an open firewall, this - property captures the time the detector believes - the firewall became open. The accuracy is - determined by the detector. If the finding is - later resolved, then this time reflects when the - finding was resolved. This must not be set to a - value greater than the current timestamp. - severity (google.cloud.securitycentermanagement_v1.types.SimulatedFinding.Severity): - The severity of the finding. This field is - managed by the source that writes the finding. - finding_class (google.cloud.securitycentermanagement_v1.types.SimulatedFinding.FindingClass): - The class of the finding. - """ - class State(proto.Enum): - r"""The state of the finding. - - Values: - STATE_UNSPECIFIED (0): - Unspecified state. - ACTIVE (1): - The finding requires attention and has not - been addressed yet. - INACTIVE (2): - The finding has been fixed, triaged as a - non-issue or otherwise addressed and is no - longer active. - """ - STATE_UNSPECIFIED = 0 - ACTIVE = 1 - INACTIVE = 2 - - class Severity(proto.Enum): - r"""The severity of the finding. - - Values: - SEVERITY_UNSPECIFIED (0): - This value is used for findings when a source - doesn't write a severity value. - CRITICAL (1): - Vulnerability: - - A critical vulnerability is easily discoverable - by an external actor, exploitable, and results - in the direct ability to execute arbitrary code, - exfiltrate data, and otherwise gain additional - access and privileges to cloud resources and - workloads. Examples include publicly accessible - unprotected user data and public SSH access with - weak or no passwords. - - Threat: - - Indicates a threat that is able to access, - modify, or delete data or execute unauthorized - code within existing resources. - HIGH (2): - Vulnerability: - - A high risk vulnerability can be easily - discovered and exploited in combination with - other vulnerabilities in order to gain direct - access and the ability to execute arbitrary - code, exfiltrate data, and otherwise gain - additional access and privileges to cloud - resources and workloads. An example is a - database with weak or no passwords that is only - accessible internally. This database could - easily be compromised by an actor that had - access to the internal network. - - Threat: - - Indicates a threat that is able to create new - computational resources in an environment but - not able to access data or execute code in - existing resources. - MEDIUM (3): - Vulnerability: - - A medium risk vulnerability could be used by an - actor to gain access to resources or privileges - that enable them to eventually (through multiple - steps or a complex exploit) gain access and the - ability to execute arbitrary code or exfiltrate - data. An example is a service account with - access to more projects than it should have. If - an actor gains access to the service account, - they could potentially use that access to - manipulate a project the service account was not - intended to. - - Threat: - - Indicates a threat that is able to cause - operational impact but may not access data or - execute unauthorized code. - LOW (4): - Vulnerability: - - A low risk vulnerability hampers a security - organization's ability to detect vulnerabilities - or active threats in their deployment, or - prevents the root cause investigation of - security issues. An example is monitoring and - logs being disabled for resource configurations - and access. - - Threat: - - Indicates a threat that has obtained minimal - access to an environment but is not able to - access data, execute code, or create resources. - """ - SEVERITY_UNSPECIFIED = 0 - CRITICAL = 1 - HIGH = 2 - MEDIUM = 3 - LOW = 4 - - class FindingClass(proto.Enum): - r"""Represents what kind of Finding it is. - - Values: - FINDING_CLASS_UNSPECIFIED (0): - Unspecified finding class. - THREAT (1): - Describes unwanted or malicious activity. - VULNERABILITY (2): - Describes a potential weakness in software - that increases risk to Confidentiality & - Integrity & Availability. - MISCONFIGURATION (3): - Describes a potential weakness in cloud - resource/asset configuration that increases - risk. - OBSERVATION (4): - Describes a security observation that is for - informational purposes. - SCC_ERROR (5): - Describes an error that prevents some SCC - functionality. - POSTURE_VIOLATION (6): - Describes a potential security risk due to a - change in the security posture. - """ - FINDING_CLASS_UNSPECIFIED = 0 - THREAT = 1 - VULNERABILITY = 2 - MISCONFIGURATION = 3 - OBSERVATION = 4 - SCC_ERROR = 5 - POSTURE_VIOLATION = 6 - - name: str = proto.Field( - proto.STRING, - number=1, - ) - parent: str = proto.Field( - proto.STRING, - number=2, - ) - resource_name: str = proto.Field( - proto.STRING, - number=3, - ) - category: str = proto.Field( - proto.STRING, - number=4, - ) - state: State = proto.Field( - proto.ENUM, - number=5, - enum=State, - ) - source_properties: MutableMapping[str, struct_pb2.Value] = proto.MapField( - proto.STRING, - proto.MESSAGE, - number=6, - message=struct_pb2.Value, - ) - event_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=7, - message=timestamp_pb2.Timestamp, - ) - severity: Severity = proto.Field( - proto.ENUM, - number=8, - enum=Severity, - ) - finding_class: FindingClass = proto.Field( - proto.ENUM, - number=9, - enum=FindingClass, - ) - - -class SimulateSecurityHealthAnalyticsCustomModuleResponse(proto.Message): - r"""Response message for simulating a - ``SecurityHealthAnalyticsCustomModule`` against a given resource. - - Attributes: - result (google.cloud.securitycentermanagement_v1.types.SimulateSecurityHealthAnalyticsCustomModuleResponse.SimulatedResult): - Result for test case in the corresponding - request. - """ - - class SimulatedResult(proto.Message): - r"""Possible test result. - - 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: - finding (google.cloud.securitycentermanagement_v1.types.SimulatedFinding): - Finding that would be published for the test - case, if a violation is detected. - - This field is a member of `oneof`_ ``result``. - no_violation (google.protobuf.empty_pb2.Empty): - Indicates that the test case does not trigger - any violation. - - This field is a member of `oneof`_ ``result``. - error (google.rpc.status_pb2.Status): - Error encountered during the test. - - This field is a member of `oneof`_ ``result``. - """ - - finding: 'SimulatedFinding' = proto.Field( - proto.MESSAGE, - number=1, - oneof='result', - message='SimulatedFinding', - ) - no_violation: empty_pb2.Empty = proto.Field( - proto.MESSAGE, - number=2, - oneof='result', - message=empty_pb2.Empty, - ) - error: status_pb2.Status = proto.Field( - proto.MESSAGE, - number=3, - oneof='result', - message=status_pb2.Status, - ) - - result: SimulatedResult = proto.Field( - proto.MESSAGE, - number=1, - message=SimulatedResult, - ) - - -class EffectiveEventThreatDetectionCustomModule(proto.Message): - r"""An EffectiveEventThreatDetectionCustomModule is the representation - of EventThreatDetectionCustomModule at a given level taking - hierarchy into account and resolving various fields accordingly. - e.g. if the module is enabled at the ancestor level, effective - modules at all descendant levels will have enablement_state set to - ENABLED. Similarly, if module.inherited is set, then effective - module's config will contain the ancestor's config details. - EffectiveEventThreatDetectionCustomModule is read-only. - - Attributes: - name (str): - Immutable. The resource name of the ETD custom module. - - Its format is: - - - "organizations/{organization}/locations/{location}/effectiveEventThreatDetectionCustomModules/{effective_event_threat_detection_custom_module}". - - "folders/{folder}/locations/{location}/effectiveEventThreatDetectionCustomModules/{effective_event_threat_detection_custom_module}". - - "projects/{project}/locations/{location}/effectiveEventThreatDetectionCustomModules/{effective_event_threat_detection_custom_module}". - config (google.protobuf.struct_pb2.Struct): - Output only. Config for the effective module. - enablement_state (google.cloud.securitycentermanagement_v1.types.EffectiveEventThreatDetectionCustomModule.EnablementState): - Output only. The effective state of - enablement for the module at the given level of - the hierarchy. - type_ (str): - Output only. Type for the module. e.g. CONFIGURABLE_BAD_IP. - display_name (str): - Output only. The human readable name to be - displayed for the module. - description (str): - Output only. The description for the module. - """ - class EnablementState(proto.Enum): - r"""The enablement state of the module. - - Values: - ENABLEMENT_STATE_UNSPECIFIED (0): - Unspecified enablement state. - ENABLED (1): - The module is enabled at the given level. - DISABLED (2): - The module is disabled at the given level. - """ - ENABLEMENT_STATE_UNSPECIFIED = 0 - ENABLED = 1 - DISABLED = 2 - - name: str = proto.Field( - proto.STRING, - number=1, - ) - config: struct_pb2.Struct = proto.Field( - proto.MESSAGE, - number=2, - message=struct_pb2.Struct, - ) - enablement_state: EnablementState = proto.Field( - proto.ENUM, - number=3, - enum=EnablementState, - ) - type_: str = proto.Field( - proto.STRING, - number=4, - ) - display_name: str = proto.Field( - proto.STRING, - number=5, - ) - description: str = proto.Field( - proto.STRING, - number=6, - ) - - -class ListEffectiveEventThreatDetectionCustomModulesRequest(proto.Message): - r"""Request message for listing effective Event Threat Detection - custom modules. - - Attributes: - parent (str): - Required. Name of parent to list effective - custom modules. Its format is - "organizations/{organization}/locations/{location}", - "folders/{folder}/locations/{location}", - or - "projects/{project}/locations/{location}". - page_size (int): - Optional. The maximum number of results to - return in a single response. Default is 10, - minimum is 1, maximum is 1000. - page_token (str): - Optional. The value returned by the last call - indicating a continuation - """ - - 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 ListEffectiveEventThreatDetectionCustomModulesResponse(proto.Message): - r"""Response message for listing effective Event Threat Detection - custom modules. - - Attributes: - effective_event_threat_detection_custom_modules (MutableSequence[google.cloud.securitycentermanagement_v1.types.EffectiveEventThreatDetectionCustomModule]): - The list of - EffectiveEventThreatDetectionCustomModules - next_page_token (str): - A token identifying a page of results the - server should return. - """ - - @property - def raw_page(self): - return self - - effective_event_threat_detection_custom_modules: MutableSequence['EffectiveEventThreatDetectionCustomModule'] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='EffectiveEventThreatDetectionCustomModule', - ) - next_page_token: str = proto.Field( - proto.STRING, - number=2, - ) - - -class GetEffectiveEventThreatDetectionCustomModuleRequest(proto.Message): - r"""Message for getting a - EffectiveEventThreatDetectionCustomModule - - Attributes: - name (str): - Required. The resource name of the ETD custom module. - - Its format is: - - - "organizations/{organization}/locations/{location}/effectiveEventThreatDetectionCustomModules/{effective_event_threat_detection_custom_module}". - - "folders/{folder}/locations/{location}/effectiveEventThreatDetectionCustomModules/{effective_event_threat_detection_custom_module}". - - "projects/{project}/locations/{location}/effectiveEventThreatDetectionCustomModules/{effective_event_threat_detection_custom_module}". - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class EventThreatDetectionCustomModule(proto.Message): - r"""An event threat detection custom module is a Cloud SCC - resource that contains the configuration and enablement state of - a custom module, which enables ETD to write certain findings to - Cloud SCC. - - Attributes: - name (str): - Immutable. The resource name of the ETD custom module. - - Its format is: - - - "organizations/{organization}/locations/{location}/eventThreatDetectionCustomModules/{event_threat_detection_custom_module}". - - "folders/{folder}/locations/{location}/eventThreatDetectionCustomModules/{event_threat_detection_custom_module}". - - "projects/{project}/locations/{location}/eventThreatDetectionCustomModules/{event_threat_detection_custom_module}". - config (google.protobuf.struct_pb2.Struct): - Optional. Config for the module. For the - resident module, its config value is defined at - this level. For the inherited module, its config - value is inherited from the ancestor module. - ancestor_module (str): - Output only. The closest ancestor module that - this module inherits the enablement state from. - If empty, indicates that the custom module was - created in the requesting parent organization, - folder, or project. The format is the same as - the EventThreatDetectionCustomModule resource - name. - enablement_state (google.cloud.securitycentermanagement_v1.types.EventThreatDetectionCustomModule.EnablementState): - Optional. The state of enablement for the - module at the given level of the hierarchy. - type_ (str): - Optional. Type for the module. e.g. CONFIGURABLE_BAD_IP. - display_name (str): - Optional. The human readable name to be - displayed for the module. - description (str): - Optional. The description for the module. - update_time (google.protobuf.timestamp_pb2.Timestamp): - Output only. The time the module was last - updated. - last_editor (str): - Output only. The editor the module was last - updated by. - """ - class EnablementState(proto.Enum): - r"""The enablement state of the module. - - Values: - ENABLEMENT_STATE_UNSPECIFIED (0): - Unspecified enablement state. - ENABLED (1): - The module is enabled at the given level. - DISABLED (2): - The module is disabled at the given level. - INHERITED (3): - State is inherited from an ancestor module. - The module will either be effectively ENABLED or - DISABLED based on its closest non-inherited - ancestor module in the CRM hierarchy. Attempting - to set a top level module (module with no - parent) to the INHERITED state will result in an - error. - """ - ENABLEMENT_STATE_UNSPECIFIED = 0 - ENABLED = 1 - DISABLED = 2 - INHERITED = 3 - - name: str = proto.Field( - proto.STRING, - number=1, - ) - config: struct_pb2.Struct = proto.Field( - proto.MESSAGE, - number=2, - message=struct_pb2.Struct, - ) - ancestor_module: str = proto.Field( - proto.STRING, - number=3, - ) - enablement_state: EnablementState = proto.Field( - proto.ENUM, - number=4, - enum=EnablementState, - ) - type_: str = proto.Field( - proto.STRING, - number=5, - ) - display_name: str = proto.Field( - proto.STRING, - number=6, - ) - description: str = proto.Field( - proto.STRING, - number=7, - ) - update_time: timestamp_pb2.Timestamp = proto.Field( - proto.MESSAGE, - number=8, - message=timestamp_pb2.Timestamp, - ) - last_editor: str = proto.Field( - proto.STRING, - number=9, - ) - - -class ListEventThreatDetectionCustomModulesRequest(proto.Message): - r"""Request message for listing Event Threat Detection custom - modules. - - Attributes: - parent (str): - Required. Name of parent to list custom - modules. Its format is - "organizations/{organization}/locations/{location}", - "folders/{folder}/locations/{location}", - or - "projects/{project}/locations/{location}". - page_size (int): - Optional. The maximum number of modules to - return. The service may return fewer than this - value. If unspecified, at most 10 configs will - be returned. The maximum value is 1000; values - above 1000 will be coerced to 1000. - page_token (str): - Optional. A page token, received from a previous - ``ListEventThreatDetectionCustomModules`` call. Provide this - to retrieve the subsequent page. - - When paginating, all other parameters provided to - ``ListEventThreatDetectionCustomModules`` must match the - call that provided the page token. - """ - - 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 ListEventThreatDetectionCustomModulesResponse(proto.Message): - r"""Response message for listing Event Threat Detection custom - modules. - - Attributes: - event_threat_detection_custom_modules (MutableSequence[google.cloud.securitycentermanagement_v1.types.EventThreatDetectionCustomModule]): - The list of EventThreatDetectionCustomModules - next_page_token (str): - A token identifying a page of results the - server should return. - """ - - @property - def raw_page(self): - return self - - event_threat_detection_custom_modules: MutableSequence['EventThreatDetectionCustomModule'] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='EventThreatDetectionCustomModule', - ) - next_page_token: str = proto.Field( - proto.STRING, - number=2, - ) - - -class ListDescendantEventThreatDetectionCustomModulesRequest(proto.Message): - r"""Request message for listing descendant Event Threat Detection - custom modules. - - Attributes: - parent (str): - Required. Name of parent to list custom - modules. Its format is - "organizations/{organization}/locations/{location}", - "folders/{folder}/locations/{location}", - or - "projects/{project}/locations/{location}". - page_size (int): - Optional. The maximum number of modules to - return. The service may return fewer than this - value. If unspecified, at most 10 configs will - be returned. The maximum value is 1000; values - above 1000 will be coerced to 1000. - page_token (str): - Optional. A token identifying a page of - results the server should return. - """ - - 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 ListDescendantEventThreatDetectionCustomModulesResponse(proto.Message): - r"""Response message for listing descendant Event Threat - Detection custom modules. - - Attributes: - event_threat_detection_custom_modules (MutableSequence[google.cloud.securitycentermanagement_v1.types.EventThreatDetectionCustomModule]): - The list of EventThreatDetectionCustomModules - next_page_token (str): - A token identifying a page of results the - server should return. - """ - - @property - def raw_page(self): - return self - - event_threat_detection_custom_modules: MutableSequence['EventThreatDetectionCustomModule'] = proto.RepeatedField( - proto.MESSAGE, - number=1, - message='EventThreatDetectionCustomModule', - ) - next_page_token: str = proto.Field( - proto.STRING, - number=2, - ) - - -class GetEventThreatDetectionCustomModuleRequest(proto.Message): - r"""Message for getting a EventThreatDetectionCustomModule - - Attributes: - name (str): - Required. The resource name of the ETD custom module. - - Its format is: - - - "organizations/{organization}/locations/{location}/eventThreatDetectionCustomModules/{event_threat_detection_custom_module}". - - "folders/{folder}/locations/{location}/eventThreatDetectionCustomModules/{event_threat_detection_custom_module}". - - "projects/{project}/locations/{location}/eventThreatDetectionCustomModules/{event_threat_detection_custom_module}". - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - -class CreateEventThreatDetectionCustomModuleRequest(proto.Message): - r"""Message for creating a EventThreatDetectionCustomModule - - Attributes: - parent (str): - Required. Name of parent for the module. Its - format is - "organizations/{organization}/locations/{location}", - "folders/{folder}/locations/{location}", - or - "projects/{project}/locations/{location}". - event_threat_detection_custom_module (google.cloud.securitycentermanagement_v1.types.EventThreatDetectionCustomModule): - Required. The module to create. The - event_threat_detection_custom_module.name will be ignored - and server generated. - validate_only (bool): - Optional. When set to true, only validations - (including IAM checks) will done for the request - (no module will be created). An OK response - indicates the request is valid while an error - response indicates the request is invalid. Note - that a subsequent request to actually create the - module could still fail because 1. the state - could have changed (e.g. IAM permission lost) or - 2. A failure occurred during creation of the - module. - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - event_threat_detection_custom_module: 'EventThreatDetectionCustomModule' = proto.Field( - proto.MESSAGE, - number=3, - message='EventThreatDetectionCustomModule', - ) - validate_only: bool = proto.Field( - proto.BOOL, - number=4, - ) - - -class UpdateEventThreatDetectionCustomModuleRequest(proto.Message): - r"""Message for updating a EventThreatDetectionCustomModule - - Attributes: - update_mask (google.protobuf.field_mask_pb2.FieldMask): - Required. Field mask is used to specify the fields to be - overwritten in the EventThreatDetectionCustomModule resource - by the update. The fields specified in the update_mask are - relative to the resource, not the full request. A field will - be overwritten if it is in the mask. If the user does not - provide a mask then all fields will be overwritten. - event_threat_detection_custom_module (google.cloud.securitycentermanagement_v1.types.EventThreatDetectionCustomModule): - Required. The module being updated - validate_only (bool): - Optional. When set to true, only validations - (including IAM checks) will done for the request - (module will not be updated). An OK response - indicates the request is valid while an error - response indicates the request is invalid. Note - that a subsequent request to actually update the - module could still fail because 1. the state - could have changed (e.g. IAM permission lost) or - 2. A failure occurred while trying to update the - module. - """ - - update_mask: field_mask_pb2.FieldMask = proto.Field( - proto.MESSAGE, - number=1, - message=field_mask_pb2.FieldMask, - ) - event_threat_detection_custom_module: 'EventThreatDetectionCustomModule' = proto.Field( - proto.MESSAGE, - number=2, - message='EventThreatDetectionCustomModule', - ) - validate_only: bool = proto.Field( - proto.BOOL, - number=3, - ) - - -class DeleteEventThreatDetectionCustomModuleRequest(proto.Message): - r"""Message for deleting a EventThreatDetectionCustomModule - - Attributes: - name (str): - Required. The resource name of the ETD custom module. - - Its format is: - - - "organizations/{organization}/locations/{location}/eventThreatDetectionCustomModules/{event_threat_detection_custom_module}". - - "folders/{folder}/locations/{location}/eventThreatDetectionCustomModules/{event_threat_detection_custom_module}". - - "projects/{project}/locations/{location}/eventThreatDetectionCustomModules/{event_threat_detection_custom_module}". - validate_only (bool): - Optional. When set to true, only validations - (including IAM checks) will done for the request - (module will not be deleted). An OK response - indicates the request is valid while an error - response indicates the request is invalid. Note - that a subsequent request to actually delete the - module could still fail because 1. the state - could have changed (e.g. IAM permission lost) or - 2. A failure occurred while trying to delete the - module. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - validate_only: bool = proto.Field( - proto.BOOL, - number=2, - ) - - -class ValidateEventThreatDetectionCustomModuleRequest(proto.Message): - r"""Request to validate an Event Threat Detection custom module. - - Attributes: - parent (str): - Required. Resource name of the parent to validate the Custom - Module under. - - Its format is: - - - "organizations/{organization}/locations/{location}". - raw_text (str): - Required. The raw text of the module's - contents. Used to generate error messages. - type_ (str): - Required. The type of the module (e.g. CONFIGURABLE_BAD_IP). - """ - - parent: str = proto.Field( - proto.STRING, - number=1, - ) - raw_text: str = proto.Field( - proto.STRING, - number=2, - ) - type_: str = proto.Field( - proto.STRING, - number=3, - ) - - -class ValidateEventThreatDetectionCustomModuleResponse(proto.Message): - r"""Response to validating an Event Threat Detection custom - module. - - Attributes: - errors (MutableSequence[google.cloud.securitycentermanagement_v1.types.ValidateEventThreatDetectionCustomModuleResponse.CustomModuleValidationError]): - A list of errors returned by the validator. - If the list is empty, there were no errors. - """ - - class CustomModuleValidationError(proto.Message): - r"""An error encountered while validating the uploaded - configuration of an Event Threat Detection Custom Module. - - - .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields - - Attributes: - description (str): - A description of the error, suitable for - human consumption. Required. - field_path (str): - The path, in RFC 8901 JSON Pointer format, to - the field that failed validation. This may be - left empty if no specific field is affected. - start (google.cloud.securitycentermanagement_v1.types.ValidateEventThreatDetectionCustomModuleResponse.Position): - The initial position of the error in the - uploaded text version of the module. This field - may be omitted if no specific position applies, - or if one could not be computed. - - This field is a member of `oneof`_ ``_start``. - end (google.cloud.securitycentermanagement_v1.types.ValidateEventThreatDetectionCustomModuleResponse.Position): - The end position of the error in the uploaded - text version of the module. This field may be - omitted if no specific position applies, or if - one could not be computed.. - - This field is a member of `oneof`_ ``_end``. - """ - - description: str = proto.Field( - proto.STRING, - number=1, - ) - field_path: str = proto.Field( - proto.STRING, - number=2, - ) - start: 'ValidateEventThreatDetectionCustomModuleResponse.Position' = proto.Field( - proto.MESSAGE, - number=3, - optional=True, - message='ValidateEventThreatDetectionCustomModuleResponse.Position', - ) - end: 'ValidateEventThreatDetectionCustomModuleResponse.Position' = proto.Field( - proto.MESSAGE, - number=4, - optional=True, - message='ValidateEventThreatDetectionCustomModuleResponse.Position', - ) - - class Position(proto.Message): - r"""A position in the uploaded text version of a module. - - Attributes: - line_number (int): - The line position in the text - column_number (int): - The column position in the line - """ - - line_number: int = proto.Field( - proto.INT32, - number=1, - ) - column_number: int = proto.Field( - proto.INT32, - number=2, - ) - - errors: MutableSequence[CustomModuleValidationError] = proto.RepeatedField( - proto.MESSAGE, - number=2, - message=CustomModuleValidationError, - ) - - -__all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/mypy.ini b/owl-bot-staging/google-cloud-securitycentermanagement/v1/mypy.ini deleted file mode 100644 index 574c5aed394b..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/mypy.ini +++ /dev/null @@ -1,3 +0,0 @@ -[mypy] -python_version = 3.7 -namespace_packages = True diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/noxfile.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/noxfile.py deleted file mode 100644 index 295627896224..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/noxfile.py +++ /dev/null @@ -1,177 +0,0 @@ -# -*- 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. -# -import os -import pathlib -import shutil -import subprocess -import sys - - -import nox # type: ignore - -ALL_PYTHON = [ - "3.7", - "3.8", - "3.9", - "3.10", - "3.11", - "3.12" -] - -CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() - -LOWER_BOUND_CONSTRAINTS_FILE = CURRENT_DIRECTORY / "constraints.txt" -PACKAGE_NAME = 'google-cloud-securitycentermanagement' - -BLACK_VERSION = "black==22.3.0" -BLACK_PATHS = ["docs", "google", "tests", "samples", "noxfile.py", "setup.py"] -DEFAULT_PYTHON_VERSION = "3.12" - -nox.sessions = [ - "unit", - "cover", - "mypy", - "check_lower_bounds" - # exclude update_lower_bounds from default - "docs", - "blacken", - "lint", -] - -@nox.session(python=ALL_PYTHON) -def unit(session): - """Run the unit test suite.""" - - session.install('coverage', 'pytest', 'pytest-cov', 'pytest-asyncio', 'asyncmock; python_version < "3.8"') - session.install('-e', '.') - - session.run( - 'py.test', - '--quiet', - '--cov=google/cloud/securitycentermanagement_v1/', - '--cov=tests/', - '--cov-config=.coveragerc', - '--cov-report=term', - '--cov-report=html', - os.path.join('tests', 'unit', ''.join(session.posargs)) - ) - - -@nox.session(python=DEFAULT_PYTHON_VERSION) -def cover(session): - """Run the final coverage report. - This outputs the coverage report aggregating coverage from the unit - test runs (not system test runs), and then erases coverage data. - """ - session.install("coverage", "pytest-cov") - session.run("coverage", "report", "--show-missing", "--fail-under=100") - - session.run("coverage", "erase") - - -@nox.session(python=ALL_PYTHON) -def mypy(session): - """Run the type checker.""" - session.install( - 'mypy', - 'types-requests', - 'types-protobuf' - ) - session.install('.') - session.run( - 'mypy', - '-p', - 'google', - ) - - -@nox.session -def update_lower_bounds(session): - """Update lower bounds in constraints.txt to match setup.py""" - session.install('google-cloud-testutils') - session.install('.') - - session.run( - 'lower-bound-checker', - 'update', - '--package-name', - PACKAGE_NAME, - '--constraints-file', - str(LOWER_BOUND_CONSTRAINTS_FILE), - ) - - -@nox.session -def check_lower_bounds(session): - """Check lower bounds in setup.py are reflected in constraints file""" - session.install('google-cloud-testutils') - session.install('.') - - session.run( - 'lower-bound-checker', - 'check', - '--package-name', - PACKAGE_NAME, - '--constraints-file', - str(LOWER_BOUND_CONSTRAINTS_FILE), - ) - -@nox.session(python=DEFAULT_PYTHON_VERSION) -def docs(session): - """Build the docs for this library.""" - - session.install("-e", ".") - session.install("sphinx==7.0.1", "alabaster", "recommonmark") - - shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True) - session.run( - "sphinx-build", - "-W", # warnings as errors - "-T", # show full traceback on exception - "-N", # no colors - "-b", - "html", - "-d", - os.path.join("docs", "_build", "doctrees", ""), - os.path.join("docs", ""), - os.path.join("docs", "_build", "html", ""), - ) - - -@nox.session(python=DEFAULT_PYTHON_VERSION) -def lint(session): - """Run linters. - - Returns a failure if the linters find linting errors or sufficiently - serious code quality issues. - """ - session.install("flake8", BLACK_VERSION) - session.run( - "black", - "--check", - *BLACK_PATHS, - ) - session.run("flake8", "google", "tests", "samples") - - -@nox.session(python=DEFAULT_PYTHON_VERSION) -def blacken(session): - """Run black. Format code to uniform standard.""" - session.install(BLACK_VERSION) - session.run( - "black", - *BLACK_PATHS, - ) diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_create_event_threat_detection_custom_module_async.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_create_event_threat_detection_custom_module_async.py deleted file mode 100644 index c967fe467d57..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_create_event_threat_detection_custom_module_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- 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 CreateEventThreatDetectionCustomModule -# 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-securitycentermanagement - - -# [START securitycentermanagement_v1_generated_SecurityCenterManagement_CreateEventThreatDetectionCustomModule_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 securitycentermanagement_v1 - - -async def sample_create_event_threat_detection_custom_module(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.CreateEventThreatDetectionCustomModuleRequest( - parent="parent_value", - ) - - # Make the request - response = await client.create_event_threat_detection_custom_module(request=request) - - # Handle the response - print(response) - -# [END securitycentermanagement_v1_generated_SecurityCenterManagement_CreateEventThreatDetectionCustomModule_async] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_create_event_threat_detection_custom_module_sync.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_create_event_threat_detection_custom_module_sync.py deleted file mode 100644 index be59c3f2a0c6..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_create_event_threat_detection_custom_module_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- 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 CreateEventThreatDetectionCustomModule -# 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-securitycentermanagement - - -# [START securitycentermanagement_v1_generated_SecurityCenterManagement_CreateEventThreatDetectionCustomModule_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 securitycentermanagement_v1 - - -def sample_create_event_threat_detection_custom_module(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.CreateEventThreatDetectionCustomModuleRequest( - parent="parent_value", - ) - - # Make the request - response = client.create_event_threat_detection_custom_module(request=request) - - # Handle the response - print(response) - -# [END securitycentermanagement_v1_generated_SecurityCenterManagement_CreateEventThreatDetectionCustomModule_sync] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_create_security_health_analytics_custom_module_async.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_create_security_health_analytics_custom_module_async.py deleted file mode 100644 index 42e6609609ef..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_create_security_health_analytics_custom_module_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- 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 CreateSecurityHealthAnalyticsCustomModule -# 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-securitycentermanagement - - -# [START securitycentermanagement_v1_generated_SecurityCenterManagement_CreateSecurityHealthAnalyticsCustomModule_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 securitycentermanagement_v1 - - -async def sample_create_security_health_analytics_custom_module(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.CreateSecurityHealthAnalyticsCustomModuleRequest( - parent="parent_value", - ) - - # Make the request - response = await client.create_security_health_analytics_custom_module(request=request) - - # Handle the response - print(response) - -# [END securitycentermanagement_v1_generated_SecurityCenterManagement_CreateSecurityHealthAnalyticsCustomModule_async] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_create_security_health_analytics_custom_module_sync.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_create_security_health_analytics_custom_module_sync.py deleted file mode 100644 index 9bed1b55abf8..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_create_security_health_analytics_custom_module_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- 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 CreateSecurityHealthAnalyticsCustomModule -# 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-securitycentermanagement - - -# [START securitycentermanagement_v1_generated_SecurityCenterManagement_CreateSecurityHealthAnalyticsCustomModule_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 securitycentermanagement_v1 - - -def sample_create_security_health_analytics_custom_module(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.CreateSecurityHealthAnalyticsCustomModuleRequest( - parent="parent_value", - ) - - # Make the request - response = client.create_security_health_analytics_custom_module(request=request) - - # Handle the response - print(response) - -# [END securitycentermanagement_v1_generated_SecurityCenterManagement_CreateSecurityHealthAnalyticsCustomModule_sync] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_delete_event_threat_detection_custom_module_async.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_delete_event_threat_detection_custom_module_async.py deleted file mode 100644 index e628c0c2a012..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_delete_event_threat_detection_custom_module_async.py +++ /dev/null @@ -1,50 +0,0 @@ -# -*- 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 DeleteEventThreatDetectionCustomModule -# 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-securitycentermanagement - - -# [START securitycentermanagement_v1_generated_SecurityCenterManagement_DeleteEventThreatDetectionCustomModule_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 securitycentermanagement_v1 - - -async def sample_delete_event_threat_detection_custom_module(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.DeleteEventThreatDetectionCustomModuleRequest( - name="name_value", - ) - - # Make the request - await client.delete_event_threat_detection_custom_module(request=request) - - -# [END securitycentermanagement_v1_generated_SecurityCenterManagement_DeleteEventThreatDetectionCustomModule_async] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_delete_event_threat_detection_custom_module_sync.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_delete_event_threat_detection_custom_module_sync.py deleted file mode 100644 index 24d967206eda..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_delete_event_threat_detection_custom_module_sync.py +++ /dev/null @@ -1,50 +0,0 @@ -# -*- 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 DeleteEventThreatDetectionCustomModule -# 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-securitycentermanagement - - -# [START securitycentermanagement_v1_generated_SecurityCenterManagement_DeleteEventThreatDetectionCustomModule_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 securitycentermanagement_v1 - - -def sample_delete_event_threat_detection_custom_module(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.DeleteEventThreatDetectionCustomModuleRequest( - name="name_value", - ) - - # Make the request - client.delete_event_threat_detection_custom_module(request=request) - - -# [END securitycentermanagement_v1_generated_SecurityCenterManagement_DeleteEventThreatDetectionCustomModule_sync] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_delete_security_health_analytics_custom_module_async.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_delete_security_health_analytics_custom_module_async.py deleted file mode 100644 index 1ebe5c7aaabe..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_delete_security_health_analytics_custom_module_async.py +++ /dev/null @@ -1,50 +0,0 @@ -# -*- 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 DeleteSecurityHealthAnalyticsCustomModule -# 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-securitycentermanagement - - -# [START securitycentermanagement_v1_generated_SecurityCenterManagement_DeleteSecurityHealthAnalyticsCustomModule_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 securitycentermanagement_v1 - - -async def sample_delete_security_health_analytics_custom_module(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.DeleteSecurityHealthAnalyticsCustomModuleRequest( - name="name_value", - ) - - # Make the request - await client.delete_security_health_analytics_custom_module(request=request) - - -# [END securitycentermanagement_v1_generated_SecurityCenterManagement_DeleteSecurityHealthAnalyticsCustomModule_async] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_delete_security_health_analytics_custom_module_sync.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_delete_security_health_analytics_custom_module_sync.py deleted file mode 100644 index 7c6293d24466..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_delete_security_health_analytics_custom_module_sync.py +++ /dev/null @@ -1,50 +0,0 @@ -# -*- 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 DeleteSecurityHealthAnalyticsCustomModule -# 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-securitycentermanagement - - -# [START securitycentermanagement_v1_generated_SecurityCenterManagement_DeleteSecurityHealthAnalyticsCustomModule_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 securitycentermanagement_v1 - - -def sample_delete_security_health_analytics_custom_module(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.DeleteSecurityHealthAnalyticsCustomModuleRequest( - name="name_value", - ) - - # Make the request - client.delete_security_health_analytics_custom_module(request=request) - - -# [END securitycentermanagement_v1_generated_SecurityCenterManagement_DeleteSecurityHealthAnalyticsCustomModule_sync] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_effective_event_threat_detection_custom_module_async.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_effective_event_threat_detection_custom_module_async.py deleted file mode 100644 index 9ce55980d0ff..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_effective_event_threat_detection_custom_module_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- 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 GetEffectiveEventThreatDetectionCustomModule -# 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-securitycentermanagement - - -# [START securitycentermanagement_v1_generated_SecurityCenterManagement_GetEffectiveEventThreatDetectionCustomModule_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 securitycentermanagement_v1 - - -async def sample_get_effective_event_threat_detection_custom_module(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.GetEffectiveEventThreatDetectionCustomModuleRequest( - name="name_value", - ) - - # Make the request - response = await client.get_effective_event_threat_detection_custom_module(request=request) - - # Handle the response - print(response) - -# [END securitycentermanagement_v1_generated_SecurityCenterManagement_GetEffectiveEventThreatDetectionCustomModule_async] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_effective_event_threat_detection_custom_module_sync.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_effective_event_threat_detection_custom_module_sync.py deleted file mode 100644 index 9ff55729a3cf..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_effective_event_threat_detection_custom_module_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- 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 GetEffectiveEventThreatDetectionCustomModule -# 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-securitycentermanagement - - -# [START securitycentermanagement_v1_generated_SecurityCenterManagement_GetEffectiveEventThreatDetectionCustomModule_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 securitycentermanagement_v1 - - -def sample_get_effective_event_threat_detection_custom_module(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.GetEffectiveEventThreatDetectionCustomModuleRequest( - name="name_value", - ) - - # Make the request - response = client.get_effective_event_threat_detection_custom_module(request=request) - - # Handle the response - print(response) - -# [END securitycentermanagement_v1_generated_SecurityCenterManagement_GetEffectiveEventThreatDetectionCustomModule_sync] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_effective_security_health_analytics_custom_module_async.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_effective_security_health_analytics_custom_module_async.py deleted file mode 100644 index 2058072391fe..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_effective_security_health_analytics_custom_module_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- 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 GetEffectiveSecurityHealthAnalyticsCustomModule -# 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-securitycentermanagement - - -# [START securitycentermanagement_v1_generated_SecurityCenterManagement_GetEffectiveSecurityHealthAnalyticsCustomModule_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 securitycentermanagement_v1 - - -async def sample_get_effective_security_health_analytics_custom_module(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest( - name="name_value", - ) - - # Make the request - response = await client.get_effective_security_health_analytics_custom_module(request=request) - - # Handle the response - print(response) - -# [END securitycentermanagement_v1_generated_SecurityCenterManagement_GetEffectiveSecurityHealthAnalyticsCustomModule_async] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_effective_security_health_analytics_custom_module_sync.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_effective_security_health_analytics_custom_module_sync.py deleted file mode 100644 index bf8826b475a1..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_effective_security_health_analytics_custom_module_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- 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 GetEffectiveSecurityHealthAnalyticsCustomModule -# 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-securitycentermanagement - - -# [START securitycentermanagement_v1_generated_SecurityCenterManagement_GetEffectiveSecurityHealthAnalyticsCustomModule_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 securitycentermanagement_v1 - - -def sample_get_effective_security_health_analytics_custom_module(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest( - name="name_value", - ) - - # Make the request - response = client.get_effective_security_health_analytics_custom_module(request=request) - - # Handle the response - print(response) - -# [END securitycentermanagement_v1_generated_SecurityCenterManagement_GetEffectiveSecurityHealthAnalyticsCustomModule_sync] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_event_threat_detection_custom_module_async.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_event_threat_detection_custom_module_async.py deleted file mode 100644 index 7f85605372e2..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_event_threat_detection_custom_module_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- 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 GetEventThreatDetectionCustomModule -# 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-securitycentermanagement - - -# [START securitycentermanagement_v1_generated_SecurityCenterManagement_GetEventThreatDetectionCustomModule_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 securitycentermanagement_v1 - - -async def sample_get_event_threat_detection_custom_module(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.GetEventThreatDetectionCustomModuleRequest( - name="name_value", - ) - - # Make the request - response = await client.get_event_threat_detection_custom_module(request=request) - - # Handle the response - print(response) - -# [END securitycentermanagement_v1_generated_SecurityCenterManagement_GetEventThreatDetectionCustomModule_async] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_event_threat_detection_custom_module_sync.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_event_threat_detection_custom_module_sync.py deleted file mode 100644 index dec845db1712..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_event_threat_detection_custom_module_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- 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 GetEventThreatDetectionCustomModule -# 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-securitycentermanagement - - -# [START securitycentermanagement_v1_generated_SecurityCenterManagement_GetEventThreatDetectionCustomModule_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 securitycentermanagement_v1 - - -def sample_get_event_threat_detection_custom_module(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.GetEventThreatDetectionCustomModuleRequest( - name="name_value", - ) - - # Make the request - response = client.get_event_threat_detection_custom_module(request=request) - - # Handle the response - print(response) - -# [END securitycentermanagement_v1_generated_SecurityCenterManagement_GetEventThreatDetectionCustomModule_sync] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_security_health_analytics_custom_module_async.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_security_health_analytics_custom_module_async.py deleted file mode 100644 index 768dd7bb766a..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_security_health_analytics_custom_module_async.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- 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 GetSecurityHealthAnalyticsCustomModule -# 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-securitycentermanagement - - -# [START securitycentermanagement_v1_generated_SecurityCenterManagement_GetSecurityHealthAnalyticsCustomModule_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 securitycentermanagement_v1 - - -async def sample_get_security_health_analytics_custom_module(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.GetSecurityHealthAnalyticsCustomModuleRequest( - name="name_value", - ) - - # Make the request - response = await client.get_security_health_analytics_custom_module(request=request) - - # Handle the response - print(response) - -# [END securitycentermanagement_v1_generated_SecurityCenterManagement_GetSecurityHealthAnalyticsCustomModule_async] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_security_health_analytics_custom_module_sync.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_security_health_analytics_custom_module_sync.py deleted file mode 100644 index eae37c7729ab..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_get_security_health_analytics_custom_module_sync.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- 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 GetSecurityHealthAnalyticsCustomModule -# 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-securitycentermanagement - - -# [START securitycentermanagement_v1_generated_SecurityCenterManagement_GetSecurityHealthAnalyticsCustomModule_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 securitycentermanagement_v1 - - -def sample_get_security_health_analytics_custom_module(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.GetSecurityHealthAnalyticsCustomModuleRequest( - name="name_value", - ) - - # Make the request - response = client.get_security_health_analytics_custom_module(request=request) - - # Handle the response - print(response) - -# [END securitycentermanagement_v1_generated_SecurityCenterManagement_GetSecurityHealthAnalyticsCustomModule_sync] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_descendant_event_threat_detection_custom_modules_async.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_descendant_event_threat_detection_custom_modules_async.py deleted file mode 100644 index dcd0684a187e..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_descendant_event_threat_detection_custom_modules_async.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- 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 ListDescendantEventThreatDetectionCustomModules -# 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-securitycentermanagement - - -# [START securitycentermanagement_v1_generated_SecurityCenterManagement_ListDescendantEventThreatDetectionCustomModules_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 securitycentermanagement_v1 - - -async def sample_list_descendant_event_threat_detection_custom_modules(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.ListDescendantEventThreatDetectionCustomModulesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_descendant_event_threat_detection_custom_modules(request=request) - - # Handle the response - async for response in page_result: - print(response) - -# [END securitycentermanagement_v1_generated_SecurityCenterManagement_ListDescendantEventThreatDetectionCustomModules_async] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_descendant_event_threat_detection_custom_modules_sync.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_descendant_event_threat_detection_custom_modules_sync.py deleted file mode 100644 index 0eca9fd0adb3..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_descendant_event_threat_detection_custom_modules_sync.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- 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 ListDescendantEventThreatDetectionCustomModules -# 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-securitycentermanagement - - -# [START securitycentermanagement_v1_generated_SecurityCenterManagement_ListDescendantEventThreatDetectionCustomModules_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 securitycentermanagement_v1 - - -def sample_list_descendant_event_threat_detection_custom_modules(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.ListDescendantEventThreatDetectionCustomModulesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_descendant_event_threat_detection_custom_modules(request=request) - - # Handle the response - for response in page_result: - print(response) - -# [END securitycentermanagement_v1_generated_SecurityCenterManagement_ListDescendantEventThreatDetectionCustomModules_sync] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_descendant_security_health_analytics_custom_modules_async.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_descendant_security_health_analytics_custom_modules_async.py deleted file mode 100644 index 1366af79fae3..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_descendant_security_health_analytics_custom_modules_async.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- 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 ListDescendantSecurityHealthAnalyticsCustomModules -# 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-securitycentermanagement - - -# [START securitycentermanagement_v1_generated_SecurityCenterManagement_ListDescendantSecurityHealthAnalyticsCustomModules_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 securitycentermanagement_v1 - - -async def sample_list_descendant_security_health_analytics_custom_modules(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.ListDescendantSecurityHealthAnalyticsCustomModulesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_descendant_security_health_analytics_custom_modules(request=request) - - # Handle the response - async for response in page_result: - print(response) - -# [END securitycentermanagement_v1_generated_SecurityCenterManagement_ListDescendantSecurityHealthAnalyticsCustomModules_async] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_descendant_security_health_analytics_custom_modules_sync.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_descendant_security_health_analytics_custom_modules_sync.py deleted file mode 100644 index e153a54a40cf..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_descendant_security_health_analytics_custom_modules_sync.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- 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 ListDescendantSecurityHealthAnalyticsCustomModules -# 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-securitycentermanagement - - -# [START securitycentermanagement_v1_generated_SecurityCenterManagement_ListDescendantSecurityHealthAnalyticsCustomModules_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 securitycentermanagement_v1 - - -def sample_list_descendant_security_health_analytics_custom_modules(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.ListDescendantSecurityHealthAnalyticsCustomModulesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_descendant_security_health_analytics_custom_modules(request=request) - - # Handle the response - for response in page_result: - print(response) - -# [END securitycentermanagement_v1_generated_SecurityCenterManagement_ListDescendantSecurityHealthAnalyticsCustomModules_sync] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_effective_event_threat_detection_custom_modules_async.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_effective_event_threat_detection_custom_modules_async.py deleted file mode 100644 index 1e36fc7b4be8..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_effective_event_threat_detection_custom_modules_async.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- 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 ListEffectiveEventThreatDetectionCustomModules -# 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-securitycentermanagement - - -# [START securitycentermanagement_v1_generated_SecurityCenterManagement_ListEffectiveEventThreatDetectionCustomModules_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 securitycentermanagement_v1 - - -async def sample_list_effective_event_threat_detection_custom_modules(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.ListEffectiveEventThreatDetectionCustomModulesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_effective_event_threat_detection_custom_modules(request=request) - - # Handle the response - async for response in page_result: - print(response) - -# [END securitycentermanagement_v1_generated_SecurityCenterManagement_ListEffectiveEventThreatDetectionCustomModules_async] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_effective_event_threat_detection_custom_modules_sync.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_effective_event_threat_detection_custom_modules_sync.py deleted file mode 100644 index 1b4514d693dc..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_effective_event_threat_detection_custom_modules_sync.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- 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 ListEffectiveEventThreatDetectionCustomModules -# 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-securitycentermanagement - - -# [START securitycentermanagement_v1_generated_SecurityCenterManagement_ListEffectiveEventThreatDetectionCustomModules_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 securitycentermanagement_v1 - - -def sample_list_effective_event_threat_detection_custom_modules(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.ListEffectiveEventThreatDetectionCustomModulesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_effective_event_threat_detection_custom_modules(request=request) - - # Handle the response - for response in page_result: - print(response) - -# [END securitycentermanagement_v1_generated_SecurityCenterManagement_ListEffectiveEventThreatDetectionCustomModules_sync] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_effective_security_health_analytics_custom_modules_async.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_effective_security_health_analytics_custom_modules_async.py deleted file mode 100644 index 99890cad5845..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_effective_security_health_analytics_custom_modules_async.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- 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 ListEffectiveSecurityHealthAnalyticsCustomModules -# 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-securitycentermanagement - - -# [START securitycentermanagement_v1_generated_SecurityCenterManagement_ListEffectiveSecurityHealthAnalyticsCustomModules_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 securitycentermanagement_v1 - - -async def sample_list_effective_security_health_analytics_custom_modules(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_effective_security_health_analytics_custom_modules(request=request) - - # Handle the response - async for response in page_result: - print(response) - -# [END securitycentermanagement_v1_generated_SecurityCenterManagement_ListEffectiveSecurityHealthAnalyticsCustomModules_async] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_effective_security_health_analytics_custom_modules_sync.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_effective_security_health_analytics_custom_modules_sync.py deleted file mode 100644 index 360bf12b0349..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_effective_security_health_analytics_custom_modules_sync.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- 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 ListEffectiveSecurityHealthAnalyticsCustomModules -# 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-securitycentermanagement - - -# [START securitycentermanagement_v1_generated_SecurityCenterManagement_ListEffectiveSecurityHealthAnalyticsCustomModules_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 securitycentermanagement_v1 - - -def sample_list_effective_security_health_analytics_custom_modules(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_effective_security_health_analytics_custom_modules(request=request) - - # Handle the response - for response in page_result: - print(response) - -# [END securitycentermanagement_v1_generated_SecurityCenterManagement_ListEffectiveSecurityHealthAnalyticsCustomModules_sync] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_event_threat_detection_custom_modules_async.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_event_threat_detection_custom_modules_async.py deleted file mode 100644 index 342770053297..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_event_threat_detection_custom_modules_async.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- 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 ListEventThreatDetectionCustomModules -# 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-securitycentermanagement - - -# [START securitycentermanagement_v1_generated_SecurityCenterManagement_ListEventThreatDetectionCustomModules_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 securitycentermanagement_v1 - - -async def sample_list_event_threat_detection_custom_modules(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.ListEventThreatDetectionCustomModulesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_event_threat_detection_custom_modules(request=request) - - # Handle the response - async for response in page_result: - print(response) - -# [END securitycentermanagement_v1_generated_SecurityCenterManagement_ListEventThreatDetectionCustomModules_async] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_event_threat_detection_custom_modules_sync.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_event_threat_detection_custom_modules_sync.py deleted file mode 100644 index 930926c99d3e..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_event_threat_detection_custom_modules_sync.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- 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 ListEventThreatDetectionCustomModules -# 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-securitycentermanagement - - -# [START securitycentermanagement_v1_generated_SecurityCenterManagement_ListEventThreatDetectionCustomModules_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 securitycentermanagement_v1 - - -def sample_list_event_threat_detection_custom_modules(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.ListEventThreatDetectionCustomModulesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_event_threat_detection_custom_modules(request=request) - - # Handle the response - for response in page_result: - print(response) - -# [END securitycentermanagement_v1_generated_SecurityCenterManagement_ListEventThreatDetectionCustomModules_sync] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_security_health_analytics_custom_modules_async.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_security_health_analytics_custom_modules_async.py deleted file mode 100644 index 5e670b94cd08..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_security_health_analytics_custom_modules_async.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- 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 ListSecurityHealthAnalyticsCustomModules -# 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-securitycentermanagement - - -# [START securitycentermanagement_v1_generated_SecurityCenterManagement_ListSecurityHealthAnalyticsCustomModules_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 securitycentermanagement_v1 - - -async def sample_list_security_health_analytics_custom_modules(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.ListSecurityHealthAnalyticsCustomModulesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_security_health_analytics_custom_modules(request=request) - - # Handle the response - async for response in page_result: - print(response) - -# [END securitycentermanagement_v1_generated_SecurityCenterManagement_ListSecurityHealthAnalyticsCustomModules_async] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_security_health_analytics_custom_modules_sync.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_security_health_analytics_custom_modules_sync.py deleted file mode 100644 index ee54a8250216..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_list_security_health_analytics_custom_modules_sync.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- 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 ListSecurityHealthAnalyticsCustomModules -# 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-securitycentermanagement - - -# [START securitycentermanagement_v1_generated_SecurityCenterManagement_ListSecurityHealthAnalyticsCustomModules_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 securitycentermanagement_v1 - - -def sample_list_security_health_analytics_custom_modules(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.ListSecurityHealthAnalyticsCustomModulesRequest( - parent="parent_value", - ) - - # Make the request - page_result = client.list_security_health_analytics_custom_modules(request=request) - - # Handle the response - for response in page_result: - print(response) - -# [END securitycentermanagement_v1_generated_SecurityCenterManagement_ListSecurityHealthAnalyticsCustomModules_sync] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_simulate_security_health_analytics_custom_module_async.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_simulate_security_health_analytics_custom_module_async.py deleted file mode 100644 index a6331f7231ec..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_simulate_security_health_analytics_custom_module_async.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- 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 SimulateSecurityHealthAnalyticsCustomModule -# 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-securitycentermanagement - - -# [START securitycentermanagement_v1_generated_SecurityCenterManagement_SimulateSecurityHealthAnalyticsCustomModule_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 securitycentermanagement_v1 - - -async def sample_simulate_security_health_analytics_custom_module(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() - - # Initialize request argument(s) - resource = securitycentermanagement_v1.SimulatedResource() - resource.resource_type = "resource_type_value" - - request = securitycentermanagement_v1.SimulateSecurityHealthAnalyticsCustomModuleRequest( - parent="parent_value", - resource=resource, - ) - - # Make the request - response = await client.simulate_security_health_analytics_custom_module(request=request) - - # Handle the response - print(response) - -# [END securitycentermanagement_v1_generated_SecurityCenterManagement_SimulateSecurityHealthAnalyticsCustomModule_async] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_simulate_security_health_analytics_custom_module_sync.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_simulate_security_health_analytics_custom_module_sync.py deleted file mode 100644 index ae16b2ed67a1..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_simulate_security_health_analytics_custom_module_sync.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- 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 SimulateSecurityHealthAnalyticsCustomModule -# 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-securitycentermanagement - - -# [START securitycentermanagement_v1_generated_SecurityCenterManagement_SimulateSecurityHealthAnalyticsCustomModule_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 securitycentermanagement_v1 - - -def sample_simulate_security_health_analytics_custom_module(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementClient() - - # Initialize request argument(s) - resource = securitycentermanagement_v1.SimulatedResource() - resource.resource_type = "resource_type_value" - - request = securitycentermanagement_v1.SimulateSecurityHealthAnalyticsCustomModuleRequest( - parent="parent_value", - resource=resource, - ) - - # Make the request - response = client.simulate_security_health_analytics_custom_module(request=request) - - # Handle the response - print(response) - -# [END securitycentermanagement_v1_generated_SecurityCenterManagement_SimulateSecurityHealthAnalyticsCustomModule_sync] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_update_event_threat_detection_custom_module_async.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_update_event_threat_detection_custom_module_async.py deleted file mode 100644 index a7f9a8c8f88b..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_update_event_threat_detection_custom_module_async.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- 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 UpdateEventThreatDetectionCustomModule -# 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-securitycentermanagement - - -# [START securitycentermanagement_v1_generated_SecurityCenterManagement_UpdateEventThreatDetectionCustomModule_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 securitycentermanagement_v1 - - -async def sample_update_event_threat_detection_custom_module(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.UpdateEventThreatDetectionCustomModuleRequest( - ) - - # Make the request - response = await client.update_event_threat_detection_custom_module(request=request) - - # Handle the response - print(response) - -# [END securitycentermanagement_v1_generated_SecurityCenterManagement_UpdateEventThreatDetectionCustomModule_async] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_update_event_threat_detection_custom_module_sync.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_update_event_threat_detection_custom_module_sync.py deleted file mode 100644 index 36c12eebff9e..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_update_event_threat_detection_custom_module_sync.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- 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 UpdateEventThreatDetectionCustomModule -# 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-securitycentermanagement - - -# [START securitycentermanagement_v1_generated_SecurityCenterManagement_UpdateEventThreatDetectionCustomModule_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 securitycentermanagement_v1 - - -def sample_update_event_threat_detection_custom_module(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.UpdateEventThreatDetectionCustomModuleRequest( - ) - - # Make the request - response = client.update_event_threat_detection_custom_module(request=request) - - # Handle the response - print(response) - -# [END securitycentermanagement_v1_generated_SecurityCenterManagement_UpdateEventThreatDetectionCustomModule_sync] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_update_security_health_analytics_custom_module_async.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_update_security_health_analytics_custom_module_async.py deleted file mode 100644 index 1ccf3db9d4fb..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_update_security_health_analytics_custom_module_async.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- 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 UpdateSecurityHealthAnalyticsCustomModule -# 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-securitycentermanagement - - -# [START securitycentermanagement_v1_generated_SecurityCenterManagement_UpdateSecurityHealthAnalyticsCustomModule_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 securitycentermanagement_v1 - - -async def sample_update_security_health_analytics_custom_module(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.UpdateSecurityHealthAnalyticsCustomModuleRequest( - ) - - # Make the request - response = await client.update_security_health_analytics_custom_module(request=request) - - # Handle the response - print(response) - -# [END securitycentermanagement_v1_generated_SecurityCenterManagement_UpdateSecurityHealthAnalyticsCustomModule_async] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_update_security_health_analytics_custom_module_sync.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_update_security_health_analytics_custom_module_sync.py deleted file mode 100644 index f9b0a0c5509f..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_update_security_health_analytics_custom_module_sync.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- 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 UpdateSecurityHealthAnalyticsCustomModule -# 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-securitycentermanagement - - -# [START securitycentermanagement_v1_generated_SecurityCenterManagement_UpdateSecurityHealthAnalyticsCustomModule_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 securitycentermanagement_v1 - - -def sample_update_security_health_analytics_custom_module(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.UpdateSecurityHealthAnalyticsCustomModuleRequest( - ) - - # Make the request - response = client.update_security_health_analytics_custom_module(request=request) - - # Handle the response - print(response) - -# [END securitycentermanagement_v1_generated_SecurityCenterManagement_UpdateSecurityHealthAnalyticsCustomModule_sync] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_validate_event_threat_detection_custom_module_async.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_validate_event_threat_detection_custom_module_async.py deleted file mode 100644 index 006c9e451079..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_validate_event_threat_detection_custom_module_async.py +++ /dev/null @@ -1,54 +0,0 @@ -# -*- 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 ValidateEventThreatDetectionCustomModule -# 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-securitycentermanagement - - -# [START securitycentermanagement_v1_generated_SecurityCenterManagement_ValidateEventThreatDetectionCustomModule_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 securitycentermanagement_v1 - - -async def sample_validate_event_threat_detection_custom_module(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementAsyncClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.ValidateEventThreatDetectionCustomModuleRequest( - parent="parent_value", - raw_text="raw_text_value", - type_="type__value", - ) - - # Make the request - response = await client.validate_event_threat_detection_custom_module(request=request) - - # Handle the response - print(response) - -# [END securitycentermanagement_v1_generated_SecurityCenterManagement_ValidateEventThreatDetectionCustomModule_async] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_validate_event_threat_detection_custom_module_sync.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_validate_event_threat_detection_custom_module_sync.py deleted file mode 100644 index 9236fc49ec08..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/securitycentermanagement_v1_generated_security_center_management_validate_event_threat_detection_custom_module_sync.py +++ /dev/null @@ -1,54 +0,0 @@ -# -*- 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 ValidateEventThreatDetectionCustomModule -# 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-securitycentermanagement - - -# [START securitycentermanagement_v1_generated_SecurityCenterManagement_ValidateEventThreatDetectionCustomModule_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 securitycentermanagement_v1 - - -def sample_validate_event_threat_detection_custom_module(): - # Create a client - client = securitycentermanagement_v1.SecurityCenterManagementClient() - - # Initialize request argument(s) - request = securitycentermanagement_v1.ValidateEventThreatDetectionCustomModuleRequest( - parent="parent_value", - raw_text="raw_text_value", - type_="type__value", - ) - - # Make the request - response = client.validate_event_threat_detection_custom_module(request=request) - - # Handle the response - print(response) - -# [END securitycentermanagement_v1_generated_SecurityCenterManagement_ValidateEventThreatDetectionCustomModule_sync] diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/snippet_metadata_google.cloud.securitycentermanagement.v1.json b/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/snippet_metadata_google.cloud.securitycentermanagement.v1.json deleted file mode 100644 index 8e50d8fef945..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/samples/generated_samples/snippet_metadata_google.cloud.securitycentermanagement.v1.json +++ /dev/null @@ -1,2941 +0,0 @@ -{ - "clientLibrary": { - "apis": [ - { - "id": "google.cloud.securitycentermanagement.v1", - "version": "v1" - } - ], - "language": "PYTHON", - "name": "google-cloud-securitycentermanagement", - "version": "0.1.0" - }, - "snippets": [ - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient", - "shortName": "SecurityCenterManagementAsyncClient" - }, - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient.create_event_threat_detection_custom_module", - "method": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.CreateEventThreatDetectionCustomModule", - "service": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", - "shortName": "SecurityCenterManagement" - }, - "shortName": "CreateEventThreatDetectionCustomModule" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.securitycentermanagement_v1.types.CreateEventThreatDetectionCustomModuleRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "event_threat_detection_custom_module", - "type": "google.cloud.securitycentermanagement_v1.types.EventThreatDetectionCustomModule" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.securitycentermanagement_v1.types.EventThreatDetectionCustomModule", - "shortName": "create_event_threat_detection_custom_module" - }, - "description": "Sample for CreateEventThreatDetectionCustomModule", - "file": "securitycentermanagement_v1_generated_security_center_management_create_event_threat_detection_custom_module_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_CreateEventThreatDetectionCustomModule_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": "securitycentermanagement_v1_generated_security_center_management_create_event_threat_detection_custom_module_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient", - "shortName": "SecurityCenterManagementClient" - }, - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient.create_event_threat_detection_custom_module", - "method": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.CreateEventThreatDetectionCustomModule", - "service": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", - "shortName": "SecurityCenterManagement" - }, - "shortName": "CreateEventThreatDetectionCustomModule" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.securitycentermanagement_v1.types.CreateEventThreatDetectionCustomModuleRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "event_threat_detection_custom_module", - "type": "google.cloud.securitycentermanagement_v1.types.EventThreatDetectionCustomModule" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.securitycentermanagement_v1.types.EventThreatDetectionCustomModule", - "shortName": "create_event_threat_detection_custom_module" - }, - "description": "Sample for CreateEventThreatDetectionCustomModule", - "file": "securitycentermanagement_v1_generated_security_center_management_create_event_threat_detection_custom_module_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_CreateEventThreatDetectionCustomModule_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": "securitycentermanagement_v1_generated_security_center_management_create_event_threat_detection_custom_module_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient", - "shortName": "SecurityCenterManagementAsyncClient" - }, - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient.create_security_health_analytics_custom_module", - "method": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.CreateSecurityHealthAnalyticsCustomModule", - "service": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", - "shortName": "SecurityCenterManagement" - }, - "shortName": "CreateSecurityHealthAnalyticsCustomModule" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.securitycentermanagement_v1.types.CreateSecurityHealthAnalyticsCustomModuleRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "security_health_analytics_custom_module", - "type": "google.cloud.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule", - "shortName": "create_security_health_analytics_custom_module" - }, - "description": "Sample for CreateSecurityHealthAnalyticsCustomModule", - "file": "securitycentermanagement_v1_generated_security_center_management_create_security_health_analytics_custom_module_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_CreateSecurityHealthAnalyticsCustomModule_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": "securitycentermanagement_v1_generated_security_center_management_create_security_health_analytics_custom_module_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient", - "shortName": "SecurityCenterManagementClient" - }, - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient.create_security_health_analytics_custom_module", - "method": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.CreateSecurityHealthAnalyticsCustomModule", - "service": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", - "shortName": "SecurityCenterManagement" - }, - "shortName": "CreateSecurityHealthAnalyticsCustomModule" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.securitycentermanagement_v1.types.CreateSecurityHealthAnalyticsCustomModuleRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "security_health_analytics_custom_module", - "type": "google.cloud.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule", - "shortName": "create_security_health_analytics_custom_module" - }, - "description": "Sample for CreateSecurityHealthAnalyticsCustomModule", - "file": "securitycentermanagement_v1_generated_security_center_management_create_security_health_analytics_custom_module_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_CreateSecurityHealthAnalyticsCustomModule_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": "securitycentermanagement_v1_generated_security_center_management_create_security_health_analytics_custom_module_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient", - "shortName": "SecurityCenterManagementAsyncClient" - }, - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient.delete_event_threat_detection_custom_module", - "method": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.DeleteEventThreatDetectionCustomModule", - "service": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", - "shortName": "SecurityCenterManagement" - }, - "shortName": "DeleteEventThreatDetectionCustomModule" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.securitycentermanagement_v1.types.DeleteEventThreatDetectionCustomModuleRequest" - }, - { - "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_event_threat_detection_custom_module" - }, - "description": "Sample for DeleteEventThreatDetectionCustomModule", - "file": "securitycentermanagement_v1_generated_security_center_management_delete_event_threat_detection_custom_module_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_DeleteEventThreatDetectionCustomModule_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": "securitycentermanagement_v1_generated_security_center_management_delete_event_threat_detection_custom_module_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient", - "shortName": "SecurityCenterManagementClient" - }, - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient.delete_event_threat_detection_custom_module", - "method": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.DeleteEventThreatDetectionCustomModule", - "service": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", - "shortName": "SecurityCenterManagement" - }, - "shortName": "DeleteEventThreatDetectionCustomModule" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.securitycentermanagement_v1.types.DeleteEventThreatDetectionCustomModuleRequest" - }, - { - "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_event_threat_detection_custom_module" - }, - "description": "Sample for DeleteEventThreatDetectionCustomModule", - "file": "securitycentermanagement_v1_generated_security_center_management_delete_event_threat_detection_custom_module_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_DeleteEventThreatDetectionCustomModule_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": "securitycentermanagement_v1_generated_security_center_management_delete_event_threat_detection_custom_module_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient", - "shortName": "SecurityCenterManagementAsyncClient" - }, - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient.delete_security_health_analytics_custom_module", - "method": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.DeleteSecurityHealthAnalyticsCustomModule", - "service": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", - "shortName": "SecurityCenterManagement" - }, - "shortName": "DeleteSecurityHealthAnalyticsCustomModule" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.securitycentermanagement_v1.types.DeleteSecurityHealthAnalyticsCustomModuleRequest" - }, - { - "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_security_health_analytics_custom_module" - }, - "description": "Sample for DeleteSecurityHealthAnalyticsCustomModule", - "file": "securitycentermanagement_v1_generated_security_center_management_delete_security_health_analytics_custom_module_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_DeleteSecurityHealthAnalyticsCustomModule_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": "securitycentermanagement_v1_generated_security_center_management_delete_security_health_analytics_custom_module_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient", - "shortName": "SecurityCenterManagementClient" - }, - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient.delete_security_health_analytics_custom_module", - "method": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.DeleteSecurityHealthAnalyticsCustomModule", - "service": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", - "shortName": "SecurityCenterManagement" - }, - "shortName": "DeleteSecurityHealthAnalyticsCustomModule" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.securitycentermanagement_v1.types.DeleteSecurityHealthAnalyticsCustomModuleRequest" - }, - { - "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_security_health_analytics_custom_module" - }, - "description": "Sample for DeleteSecurityHealthAnalyticsCustomModule", - "file": "securitycentermanagement_v1_generated_security_center_management_delete_security_health_analytics_custom_module_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_DeleteSecurityHealthAnalyticsCustomModule_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": "securitycentermanagement_v1_generated_security_center_management_delete_security_health_analytics_custom_module_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient", - "shortName": "SecurityCenterManagementAsyncClient" - }, - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient.get_effective_event_threat_detection_custom_module", - "method": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.GetEffectiveEventThreatDetectionCustomModule", - "service": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", - "shortName": "SecurityCenterManagement" - }, - "shortName": "GetEffectiveEventThreatDetectionCustomModule" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.securitycentermanagement_v1.types.GetEffectiveEventThreatDetectionCustomModuleRequest" - }, - { - "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.securitycentermanagement_v1.types.EffectiveEventThreatDetectionCustomModule", - "shortName": "get_effective_event_threat_detection_custom_module" - }, - "description": "Sample for GetEffectiveEventThreatDetectionCustomModule", - "file": "securitycentermanagement_v1_generated_security_center_management_get_effective_event_threat_detection_custom_module_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_GetEffectiveEventThreatDetectionCustomModule_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": "securitycentermanagement_v1_generated_security_center_management_get_effective_event_threat_detection_custom_module_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient", - "shortName": "SecurityCenterManagementClient" - }, - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient.get_effective_event_threat_detection_custom_module", - "method": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.GetEffectiveEventThreatDetectionCustomModule", - "service": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", - "shortName": "SecurityCenterManagement" - }, - "shortName": "GetEffectiveEventThreatDetectionCustomModule" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.securitycentermanagement_v1.types.GetEffectiveEventThreatDetectionCustomModuleRequest" - }, - { - "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.securitycentermanagement_v1.types.EffectiveEventThreatDetectionCustomModule", - "shortName": "get_effective_event_threat_detection_custom_module" - }, - "description": "Sample for GetEffectiveEventThreatDetectionCustomModule", - "file": "securitycentermanagement_v1_generated_security_center_management_get_effective_event_threat_detection_custom_module_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_GetEffectiveEventThreatDetectionCustomModule_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": "securitycentermanagement_v1_generated_security_center_management_get_effective_event_threat_detection_custom_module_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient", - "shortName": "SecurityCenterManagementAsyncClient" - }, - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient.get_effective_security_health_analytics_custom_module", - "method": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.GetEffectiveSecurityHealthAnalyticsCustomModule", - "service": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", - "shortName": "SecurityCenterManagement" - }, - "shortName": "GetEffectiveSecurityHealthAnalyticsCustomModule" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.securitycentermanagement_v1.types.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest" - }, - { - "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.securitycentermanagement_v1.types.EffectiveSecurityHealthAnalyticsCustomModule", - "shortName": "get_effective_security_health_analytics_custom_module" - }, - "description": "Sample for GetEffectiveSecurityHealthAnalyticsCustomModule", - "file": "securitycentermanagement_v1_generated_security_center_management_get_effective_security_health_analytics_custom_module_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_GetEffectiveSecurityHealthAnalyticsCustomModule_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": "securitycentermanagement_v1_generated_security_center_management_get_effective_security_health_analytics_custom_module_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient", - "shortName": "SecurityCenterManagementClient" - }, - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient.get_effective_security_health_analytics_custom_module", - "method": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.GetEffectiveSecurityHealthAnalyticsCustomModule", - "service": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", - "shortName": "SecurityCenterManagement" - }, - "shortName": "GetEffectiveSecurityHealthAnalyticsCustomModule" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.securitycentermanagement_v1.types.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest" - }, - { - "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.securitycentermanagement_v1.types.EffectiveSecurityHealthAnalyticsCustomModule", - "shortName": "get_effective_security_health_analytics_custom_module" - }, - "description": "Sample for GetEffectiveSecurityHealthAnalyticsCustomModule", - "file": "securitycentermanagement_v1_generated_security_center_management_get_effective_security_health_analytics_custom_module_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_GetEffectiveSecurityHealthAnalyticsCustomModule_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": "securitycentermanagement_v1_generated_security_center_management_get_effective_security_health_analytics_custom_module_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient", - "shortName": "SecurityCenterManagementAsyncClient" - }, - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient.get_event_threat_detection_custom_module", - "method": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.GetEventThreatDetectionCustomModule", - "service": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", - "shortName": "SecurityCenterManagement" - }, - "shortName": "GetEventThreatDetectionCustomModule" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.securitycentermanagement_v1.types.GetEventThreatDetectionCustomModuleRequest" - }, - { - "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.securitycentermanagement_v1.types.EventThreatDetectionCustomModule", - "shortName": "get_event_threat_detection_custom_module" - }, - "description": "Sample for GetEventThreatDetectionCustomModule", - "file": "securitycentermanagement_v1_generated_security_center_management_get_event_threat_detection_custom_module_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_GetEventThreatDetectionCustomModule_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": "securitycentermanagement_v1_generated_security_center_management_get_event_threat_detection_custom_module_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient", - "shortName": "SecurityCenterManagementClient" - }, - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient.get_event_threat_detection_custom_module", - "method": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.GetEventThreatDetectionCustomModule", - "service": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", - "shortName": "SecurityCenterManagement" - }, - "shortName": "GetEventThreatDetectionCustomModule" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.securitycentermanagement_v1.types.GetEventThreatDetectionCustomModuleRequest" - }, - { - "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.securitycentermanagement_v1.types.EventThreatDetectionCustomModule", - "shortName": "get_event_threat_detection_custom_module" - }, - "description": "Sample for GetEventThreatDetectionCustomModule", - "file": "securitycentermanagement_v1_generated_security_center_management_get_event_threat_detection_custom_module_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_GetEventThreatDetectionCustomModule_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": "securitycentermanagement_v1_generated_security_center_management_get_event_threat_detection_custom_module_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient", - "shortName": "SecurityCenterManagementAsyncClient" - }, - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient.get_security_health_analytics_custom_module", - "method": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.GetSecurityHealthAnalyticsCustomModule", - "service": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", - "shortName": "SecurityCenterManagement" - }, - "shortName": "GetSecurityHealthAnalyticsCustomModule" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.securitycentermanagement_v1.types.GetSecurityHealthAnalyticsCustomModuleRequest" - }, - { - "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.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule", - "shortName": "get_security_health_analytics_custom_module" - }, - "description": "Sample for GetSecurityHealthAnalyticsCustomModule", - "file": "securitycentermanagement_v1_generated_security_center_management_get_security_health_analytics_custom_module_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_GetSecurityHealthAnalyticsCustomModule_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": "securitycentermanagement_v1_generated_security_center_management_get_security_health_analytics_custom_module_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient", - "shortName": "SecurityCenterManagementClient" - }, - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient.get_security_health_analytics_custom_module", - "method": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.GetSecurityHealthAnalyticsCustomModule", - "service": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", - "shortName": "SecurityCenterManagement" - }, - "shortName": "GetSecurityHealthAnalyticsCustomModule" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.securitycentermanagement_v1.types.GetSecurityHealthAnalyticsCustomModuleRequest" - }, - { - "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.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule", - "shortName": "get_security_health_analytics_custom_module" - }, - "description": "Sample for GetSecurityHealthAnalyticsCustomModule", - "file": "securitycentermanagement_v1_generated_security_center_management_get_security_health_analytics_custom_module_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_GetSecurityHealthAnalyticsCustomModule_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": "securitycentermanagement_v1_generated_security_center_management_get_security_health_analytics_custom_module_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient", - "shortName": "SecurityCenterManagementAsyncClient" - }, - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient.list_descendant_event_threat_detection_custom_modules", - "method": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.ListDescendantEventThreatDetectionCustomModules", - "service": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", - "shortName": "SecurityCenterManagement" - }, - "shortName": "ListDescendantEventThreatDetectionCustomModules" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.securitycentermanagement_v1.types.ListDescendantEventThreatDetectionCustomModulesRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.securitycentermanagement_v1.services.security_center_management.pagers.ListDescendantEventThreatDetectionCustomModulesAsyncPager", - "shortName": "list_descendant_event_threat_detection_custom_modules" - }, - "description": "Sample for ListDescendantEventThreatDetectionCustomModules", - "file": "securitycentermanagement_v1_generated_security_center_management_list_descendant_event_threat_detection_custom_modules_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_ListDescendantEventThreatDetectionCustomModules_async", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "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": 53, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "securitycentermanagement_v1_generated_security_center_management_list_descendant_event_threat_detection_custom_modules_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient", - "shortName": "SecurityCenterManagementClient" - }, - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient.list_descendant_event_threat_detection_custom_modules", - "method": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.ListDescendantEventThreatDetectionCustomModules", - "service": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", - "shortName": "SecurityCenterManagement" - }, - "shortName": "ListDescendantEventThreatDetectionCustomModules" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.securitycentermanagement_v1.types.ListDescendantEventThreatDetectionCustomModulesRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.securitycentermanagement_v1.services.security_center_management.pagers.ListDescendantEventThreatDetectionCustomModulesPager", - "shortName": "list_descendant_event_threat_detection_custom_modules" - }, - "description": "Sample for ListDescendantEventThreatDetectionCustomModules", - "file": "securitycentermanagement_v1_generated_security_center_management_list_descendant_event_threat_detection_custom_modules_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_ListDescendantEventThreatDetectionCustomModules_sync", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "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": 53, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "securitycentermanagement_v1_generated_security_center_management_list_descendant_event_threat_detection_custom_modules_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient", - "shortName": "SecurityCenterManagementAsyncClient" - }, - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient.list_descendant_security_health_analytics_custom_modules", - "method": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.ListDescendantSecurityHealthAnalyticsCustomModules", - "service": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", - "shortName": "SecurityCenterManagement" - }, - "shortName": "ListDescendantSecurityHealthAnalyticsCustomModules" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.securitycentermanagement_v1.types.ListDescendantSecurityHealthAnalyticsCustomModulesRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.securitycentermanagement_v1.services.security_center_management.pagers.ListDescendantSecurityHealthAnalyticsCustomModulesAsyncPager", - "shortName": "list_descendant_security_health_analytics_custom_modules" - }, - "description": "Sample for ListDescendantSecurityHealthAnalyticsCustomModules", - "file": "securitycentermanagement_v1_generated_security_center_management_list_descendant_security_health_analytics_custom_modules_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_ListDescendantSecurityHealthAnalyticsCustomModules_async", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "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": 53, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "securitycentermanagement_v1_generated_security_center_management_list_descendant_security_health_analytics_custom_modules_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient", - "shortName": "SecurityCenterManagementClient" - }, - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient.list_descendant_security_health_analytics_custom_modules", - "method": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.ListDescendantSecurityHealthAnalyticsCustomModules", - "service": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", - "shortName": "SecurityCenterManagement" - }, - "shortName": "ListDescendantSecurityHealthAnalyticsCustomModules" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.securitycentermanagement_v1.types.ListDescendantSecurityHealthAnalyticsCustomModulesRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.securitycentermanagement_v1.services.security_center_management.pagers.ListDescendantSecurityHealthAnalyticsCustomModulesPager", - "shortName": "list_descendant_security_health_analytics_custom_modules" - }, - "description": "Sample for ListDescendantSecurityHealthAnalyticsCustomModules", - "file": "securitycentermanagement_v1_generated_security_center_management_list_descendant_security_health_analytics_custom_modules_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_ListDescendantSecurityHealthAnalyticsCustomModules_sync", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "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": 53, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "securitycentermanagement_v1_generated_security_center_management_list_descendant_security_health_analytics_custom_modules_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient", - "shortName": "SecurityCenterManagementAsyncClient" - }, - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient.list_effective_event_threat_detection_custom_modules", - "method": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.ListEffectiveEventThreatDetectionCustomModules", - "service": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", - "shortName": "SecurityCenterManagement" - }, - "shortName": "ListEffectiveEventThreatDetectionCustomModules" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.securitycentermanagement_v1.types.ListEffectiveEventThreatDetectionCustomModulesRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.securitycentermanagement_v1.services.security_center_management.pagers.ListEffectiveEventThreatDetectionCustomModulesAsyncPager", - "shortName": "list_effective_event_threat_detection_custom_modules" - }, - "description": "Sample for ListEffectiveEventThreatDetectionCustomModules", - "file": "securitycentermanagement_v1_generated_security_center_management_list_effective_event_threat_detection_custom_modules_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_ListEffectiveEventThreatDetectionCustomModules_async", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "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": 53, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "securitycentermanagement_v1_generated_security_center_management_list_effective_event_threat_detection_custom_modules_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient", - "shortName": "SecurityCenterManagementClient" - }, - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient.list_effective_event_threat_detection_custom_modules", - "method": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.ListEffectiveEventThreatDetectionCustomModules", - "service": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", - "shortName": "SecurityCenterManagement" - }, - "shortName": "ListEffectiveEventThreatDetectionCustomModules" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.securitycentermanagement_v1.types.ListEffectiveEventThreatDetectionCustomModulesRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.securitycentermanagement_v1.services.security_center_management.pagers.ListEffectiveEventThreatDetectionCustomModulesPager", - "shortName": "list_effective_event_threat_detection_custom_modules" - }, - "description": "Sample for ListEffectiveEventThreatDetectionCustomModules", - "file": "securitycentermanagement_v1_generated_security_center_management_list_effective_event_threat_detection_custom_modules_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_ListEffectiveEventThreatDetectionCustomModules_sync", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "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": 53, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "securitycentermanagement_v1_generated_security_center_management_list_effective_event_threat_detection_custom_modules_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient", - "shortName": "SecurityCenterManagementAsyncClient" - }, - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient.list_effective_security_health_analytics_custom_modules", - "method": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.ListEffectiveSecurityHealthAnalyticsCustomModules", - "service": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", - "shortName": "SecurityCenterManagement" - }, - "shortName": "ListEffectiveSecurityHealthAnalyticsCustomModules" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.securitycentermanagement_v1.types.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.securitycentermanagement_v1.services.security_center_management.pagers.ListEffectiveSecurityHealthAnalyticsCustomModulesAsyncPager", - "shortName": "list_effective_security_health_analytics_custom_modules" - }, - "description": "Sample for ListEffectiveSecurityHealthAnalyticsCustomModules", - "file": "securitycentermanagement_v1_generated_security_center_management_list_effective_security_health_analytics_custom_modules_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_ListEffectiveSecurityHealthAnalyticsCustomModules_async", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "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": 53, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "securitycentermanagement_v1_generated_security_center_management_list_effective_security_health_analytics_custom_modules_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient", - "shortName": "SecurityCenterManagementClient" - }, - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient.list_effective_security_health_analytics_custom_modules", - "method": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.ListEffectiveSecurityHealthAnalyticsCustomModules", - "service": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", - "shortName": "SecurityCenterManagement" - }, - "shortName": "ListEffectiveSecurityHealthAnalyticsCustomModules" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.securitycentermanagement_v1.types.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.securitycentermanagement_v1.services.security_center_management.pagers.ListEffectiveSecurityHealthAnalyticsCustomModulesPager", - "shortName": "list_effective_security_health_analytics_custom_modules" - }, - "description": "Sample for ListEffectiveSecurityHealthAnalyticsCustomModules", - "file": "securitycentermanagement_v1_generated_security_center_management_list_effective_security_health_analytics_custom_modules_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_ListEffectiveSecurityHealthAnalyticsCustomModules_sync", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "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": 53, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "securitycentermanagement_v1_generated_security_center_management_list_effective_security_health_analytics_custom_modules_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient", - "shortName": "SecurityCenterManagementAsyncClient" - }, - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient.list_event_threat_detection_custom_modules", - "method": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.ListEventThreatDetectionCustomModules", - "service": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", - "shortName": "SecurityCenterManagement" - }, - "shortName": "ListEventThreatDetectionCustomModules" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.securitycentermanagement_v1.types.ListEventThreatDetectionCustomModulesRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.securitycentermanagement_v1.services.security_center_management.pagers.ListEventThreatDetectionCustomModulesAsyncPager", - "shortName": "list_event_threat_detection_custom_modules" - }, - "description": "Sample for ListEventThreatDetectionCustomModules", - "file": "securitycentermanagement_v1_generated_security_center_management_list_event_threat_detection_custom_modules_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_ListEventThreatDetectionCustomModules_async", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "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": 53, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "securitycentermanagement_v1_generated_security_center_management_list_event_threat_detection_custom_modules_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient", - "shortName": "SecurityCenterManagementClient" - }, - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient.list_event_threat_detection_custom_modules", - "method": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.ListEventThreatDetectionCustomModules", - "service": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", - "shortName": "SecurityCenterManagement" - }, - "shortName": "ListEventThreatDetectionCustomModules" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.securitycentermanagement_v1.types.ListEventThreatDetectionCustomModulesRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.securitycentermanagement_v1.services.security_center_management.pagers.ListEventThreatDetectionCustomModulesPager", - "shortName": "list_event_threat_detection_custom_modules" - }, - "description": "Sample for ListEventThreatDetectionCustomModules", - "file": "securitycentermanagement_v1_generated_security_center_management_list_event_threat_detection_custom_modules_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_ListEventThreatDetectionCustomModules_sync", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "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": 53, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "securitycentermanagement_v1_generated_security_center_management_list_event_threat_detection_custom_modules_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient", - "shortName": "SecurityCenterManagementAsyncClient" - }, - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient.list_security_health_analytics_custom_modules", - "method": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.ListSecurityHealthAnalyticsCustomModules", - "service": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", - "shortName": "SecurityCenterManagement" - }, - "shortName": "ListSecurityHealthAnalyticsCustomModules" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.securitycentermanagement_v1.types.ListSecurityHealthAnalyticsCustomModulesRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.securitycentermanagement_v1.services.security_center_management.pagers.ListSecurityHealthAnalyticsCustomModulesAsyncPager", - "shortName": "list_security_health_analytics_custom_modules" - }, - "description": "Sample for ListSecurityHealthAnalyticsCustomModules", - "file": "securitycentermanagement_v1_generated_security_center_management_list_security_health_analytics_custom_modules_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_ListSecurityHealthAnalyticsCustomModules_async", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "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": 53, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "securitycentermanagement_v1_generated_security_center_management_list_security_health_analytics_custom_modules_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient", - "shortName": "SecurityCenterManagementClient" - }, - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient.list_security_health_analytics_custom_modules", - "method": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.ListSecurityHealthAnalyticsCustomModules", - "service": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", - "shortName": "SecurityCenterManagement" - }, - "shortName": "ListSecurityHealthAnalyticsCustomModules" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.securitycentermanagement_v1.types.ListSecurityHealthAnalyticsCustomModulesRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.securitycentermanagement_v1.services.security_center_management.pagers.ListSecurityHealthAnalyticsCustomModulesPager", - "shortName": "list_security_health_analytics_custom_modules" - }, - "description": "Sample for ListSecurityHealthAnalyticsCustomModules", - "file": "securitycentermanagement_v1_generated_security_center_management_list_security_health_analytics_custom_modules_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_ListSecurityHealthAnalyticsCustomModules_sync", - "segments": [ - { - "end": 52, - "start": 27, - "type": "FULL" - }, - { - "end": 52, - "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": 53, - "start": 49, - "type": "RESPONSE_HANDLING" - } - ], - "title": "securitycentermanagement_v1_generated_security_center_management_list_security_health_analytics_custom_modules_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient", - "shortName": "SecurityCenterManagementAsyncClient" - }, - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient.simulate_security_health_analytics_custom_module", - "method": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.SimulateSecurityHealthAnalyticsCustomModule", - "service": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", - "shortName": "SecurityCenterManagement" - }, - "shortName": "SimulateSecurityHealthAnalyticsCustomModule" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.securitycentermanagement_v1.types.SimulateSecurityHealthAnalyticsCustomModuleRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "custom_config", - "type": "google.cloud.securitycentermanagement_v1.types.CustomConfig" - }, - { - "name": "resource", - "type": "google.cloud.securitycentermanagement_v1.types.SimulateSecurityHealthAnalyticsCustomModuleRequest.SimulatedResource" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.securitycentermanagement_v1.types.SimulateSecurityHealthAnalyticsCustomModuleResponse", - "shortName": "simulate_security_health_analytics_custom_module" - }, - "description": "Sample for SimulateSecurityHealthAnalyticsCustomModule", - "file": "securitycentermanagement_v1_generated_security_center_management_simulate_security_health_analytics_custom_module_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_SimulateSecurityHealthAnalyticsCustomModule_async", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 49, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 50, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "securitycentermanagement_v1_generated_security_center_management_simulate_security_health_analytics_custom_module_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient", - "shortName": "SecurityCenterManagementClient" - }, - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient.simulate_security_health_analytics_custom_module", - "method": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.SimulateSecurityHealthAnalyticsCustomModule", - "service": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", - "shortName": "SecurityCenterManagement" - }, - "shortName": "SimulateSecurityHealthAnalyticsCustomModule" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.securitycentermanagement_v1.types.SimulateSecurityHealthAnalyticsCustomModuleRequest" - }, - { - "name": "parent", - "type": "str" - }, - { - "name": "custom_config", - "type": "google.cloud.securitycentermanagement_v1.types.CustomConfig" - }, - { - "name": "resource", - "type": "google.cloud.securitycentermanagement_v1.types.SimulateSecurityHealthAnalyticsCustomModuleRequest.SimulatedResource" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.securitycentermanagement_v1.types.SimulateSecurityHealthAnalyticsCustomModuleResponse", - "shortName": "simulate_security_health_analytics_custom_module" - }, - "description": "Sample for SimulateSecurityHealthAnalyticsCustomModule", - "file": "securitycentermanagement_v1_generated_security_center_management_simulate_security_health_analytics_custom_module_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_SimulateSecurityHealthAnalyticsCustomModule_sync", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 49, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 50, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "securitycentermanagement_v1_generated_security_center_management_simulate_security_health_analytics_custom_module_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient", - "shortName": "SecurityCenterManagementAsyncClient" - }, - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient.update_event_threat_detection_custom_module", - "method": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.UpdateEventThreatDetectionCustomModule", - "service": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", - "shortName": "SecurityCenterManagement" - }, - "shortName": "UpdateEventThreatDetectionCustomModule" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.securitycentermanagement_v1.types.UpdateEventThreatDetectionCustomModuleRequest" - }, - { - "name": "event_threat_detection_custom_module", - "type": "google.cloud.securitycentermanagement_v1.types.EventThreatDetectionCustomModule" - }, - { - "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.securitycentermanagement_v1.types.EventThreatDetectionCustomModule", - "shortName": "update_event_threat_detection_custom_module" - }, - "description": "Sample for UpdateEventThreatDetectionCustomModule", - "file": "securitycentermanagement_v1_generated_security_center_management_update_event_threat_detection_custom_module_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_UpdateEventThreatDetectionCustomModule_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": "securitycentermanagement_v1_generated_security_center_management_update_event_threat_detection_custom_module_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient", - "shortName": "SecurityCenterManagementClient" - }, - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient.update_event_threat_detection_custom_module", - "method": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.UpdateEventThreatDetectionCustomModule", - "service": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", - "shortName": "SecurityCenterManagement" - }, - "shortName": "UpdateEventThreatDetectionCustomModule" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.securitycentermanagement_v1.types.UpdateEventThreatDetectionCustomModuleRequest" - }, - { - "name": "event_threat_detection_custom_module", - "type": "google.cloud.securitycentermanagement_v1.types.EventThreatDetectionCustomModule" - }, - { - "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.securitycentermanagement_v1.types.EventThreatDetectionCustomModule", - "shortName": "update_event_threat_detection_custom_module" - }, - "description": "Sample for UpdateEventThreatDetectionCustomModule", - "file": "securitycentermanagement_v1_generated_security_center_management_update_event_threat_detection_custom_module_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_UpdateEventThreatDetectionCustomModule_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": "securitycentermanagement_v1_generated_security_center_management_update_event_threat_detection_custom_module_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient", - "shortName": "SecurityCenterManagementAsyncClient" - }, - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient.update_security_health_analytics_custom_module", - "method": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.UpdateSecurityHealthAnalyticsCustomModule", - "service": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", - "shortName": "SecurityCenterManagement" - }, - "shortName": "UpdateSecurityHealthAnalyticsCustomModule" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.securitycentermanagement_v1.types.UpdateSecurityHealthAnalyticsCustomModuleRequest" - }, - { - "name": "security_health_analytics_custom_module", - "type": "google.cloud.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule" - }, - { - "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.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule", - "shortName": "update_security_health_analytics_custom_module" - }, - "description": "Sample for UpdateSecurityHealthAnalyticsCustomModule", - "file": "securitycentermanagement_v1_generated_security_center_management_update_security_health_analytics_custom_module_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_UpdateSecurityHealthAnalyticsCustomModule_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": "securitycentermanagement_v1_generated_security_center_management_update_security_health_analytics_custom_module_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient", - "shortName": "SecurityCenterManagementClient" - }, - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient.update_security_health_analytics_custom_module", - "method": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.UpdateSecurityHealthAnalyticsCustomModule", - "service": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", - "shortName": "SecurityCenterManagement" - }, - "shortName": "UpdateSecurityHealthAnalyticsCustomModule" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.securitycentermanagement_v1.types.UpdateSecurityHealthAnalyticsCustomModuleRequest" - }, - { - "name": "security_health_analytics_custom_module", - "type": "google.cloud.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule" - }, - { - "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.securitycentermanagement_v1.types.SecurityHealthAnalyticsCustomModule", - "shortName": "update_security_health_analytics_custom_module" - }, - "description": "Sample for UpdateSecurityHealthAnalyticsCustomModule", - "file": "securitycentermanagement_v1_generated_security_center_management_update_security_health_analytics_custom_module_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_UpdateSecurityHealthAnalyticsCustomModule_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": "securitycentermanagement_v1_generated_security_center_management_update_security_health_analytics_custom_module_sync.py" - }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient", - "shortName": "SecurityCenterManagementAsyncClient" - }, - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementAsyncClient.validate_event_threat_detection_custom_module", - "method": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.ValidateEventThreatDetectionCustomModule", - "service": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", - "shortName": "SecurityCenterManagement" - }, - "shortName": "ValidateEventThreatDetectionCustomModule" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.securitycentermanagement_v1.types.ValidateEventThreatDetectionCustomModuleRequest" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.securitycentermanagement_v1.types.ValidateEventThreatDetectionCustomModuleResponse", - "shortName": "validate_event_threat_detection_custom_module" - }, - "description": "Sample for ValidateEventThreatDetectionCustomModule", - "file": "securitycentermanagement_v1_generated_security_center_management_validate_event_threat_detection_custom_module_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_ValidateEventThreatDetectionCustomModule_async", - "segments": [ - { - "end": 53, - "start": 27, - "type": "FULL" - }, - { - "end": 53, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 47, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 50, - "start": 48, - "type": "REQUEST_EXECUTION" - }, - { - "end": 54, - "start": 51, - "type": "RESPONSE_HANDLING" - } - ], - "title": "securitycentermanagement_v1_generated_security_center_management_validate_event_threat_detection_custom_module_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient", - "shortName": "SecurityCenterManagementClient" - }, - "fullName": "google.cloud.securitycentermanagement_v1.SecurityCenterManagementClient.validate_event_threat_detection_custom_module", - "method": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement.ValidateEventThreatDetectionCustomModule", - "service": { - "fullName": "google.cloud.securitycentermanagement.v1.SecurityCenterManagement", - "shortName": "SecurityCenterManagement" - }, - "shortName": "ValidateEventThreatDetectionCustomModule" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.securitycentermanagement_v1.types.ValidateEventThreatDetectionCustomModuleRequest" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.cloud.securitycentermanagement_v1.types.ValidateEventThreatDetectionCustomModuleResponse", - "shortName": "validate_event_threat_detection_custom_module" - }, - "description": "Sample for ValidateEventThreatDetectionCustomModule", - "file": "securitycentermanagement_v1_generated_security_center_management_validate_event_threat_detection_custom_module_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "securitycentermanagement_v1_generated_SecurityCenterManagement_ValidateEventThreatDetectionCustomModule_sync", - "segments": [ - { - "end": 53, - "start": 27, - "type": "FULL" - }, - { - "end": 53, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 47, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 50, - "start": 48, - "type": "REQUEST_EXECUTION" - }, - { - "end": 54, - "start": 51, - "type": "RESPONSE_HANDLING" - } - ], - "title": "securitycentermanagement_v1_generated_security_center_management_validate_event_threat_detection_custom_module_sync.py" - } - ] -} diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/scripts/fixup_securitycentermanagement_v1_keywords.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/scripts/fixup_securitycentermanagement_v1_keywords.py deleted file mode 100644 index 778802ae9931..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/scripts/fixup_securitycentermanagement_v1_keywords.py +++ /dev/null @@ -1,193 +0,0 @@ -#! /usr/bin/env python3 -# -*- 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. -# -import argparse -import os -import libcst as cst -import pathlib -import sys -from typing import (Any, Callable, Dict, List, Sequence, Tuple) - - -def partition( - predicate: Callable[[Any], bool], - iterator: Sequence[Any] -) -> Tuple[List[Any], List[Any]]: - """A stable, out-of-place partition.""" - results = ([], []) - - for i in iterator: - results[int(predicate(i))].append(i) - - # Returns trueList, falseList - return results[1], results[0] - - -class securitycentermanagementCallTransformer(cst.CSTTransformer): - CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') - METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { - 'create_event_threat_detection_custom_module': ('parent', 'event_threat_detection_custom_module', 'validate_only', ), - 'create_security_health_analytics_custom_module': ('parent', 'security_health_analytics_custom_module', 'validate_only', ), - 'delete_event_threat_detection_custom_module': ('name', 'validate_only', ), - 'delete_security_health_analytics_custom_module': ('name', 'validate_only', ), - 'get_effective_event_threat_detection_custom_module': ('name', ), - 'get_effective_security_health_analytics_custom_module': ('name', ), - 'get_event_threat_detection_custom_module': ('name', ), - 'get_security_health_analytics_custom_module': ('name', ), - 'list_descendant_event_threat_detection_custom_modules': ('parent', 'page_size', 'page_token', ), - 'list_descendant_security_health_analytics_custom_modules': ('parent', 'page_size', 'page_token', ), - 'list_effective_event_threat_detection_custom_modules': ('parent', 'page_size', 'page_token', ), - 'list_effective_security_health_analytics_custom_modules': ('parent', 'page_size', 'page_token', ), - 'list_event_threat_detection_custom_modules': ('parent', 'page_size', 'page_token', ), - 'list_security_health_analytics_custom_modules': ('parent', 'page_size', 'page_token', ), - 'simulate_security_health_analytics_custom_module': ('parent', 'custom_config', 'resource', ), - 'update_event_threat_detection_custom_module': ('update_mask', 'event_threat_detection_custom_module', 'validate_only', ), - 'update_security_health_analytics_custom_module': ('update_mask', 'security_health_analytics_custom_module', 'validate_only', ), - 'validate_event_threat_detection_custom_module': ('parent', 'raw_text', 'type_', ), - } - - def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: - try: - key = original.func.attr.value - kword_params = self.METHOD_TO_PARAMS[key] - except (AttributeError, KeyError): - # Either not a method from the API or too convoluted to be sure. - return updated - - # If the existing code is valid, keyword args come after positional args. - # Therefore, all positional args must map to the first parameters. - args, kwargs = partition(lambda a: not bool(a.keyword), updated.args) - if any(k.keyword.value == "request" for k in kwargs): - # We've already fixed this file, don't fix it again. - return updated - - kwargs, ctrl_kwargs = partition( - lambda a: a.keyword.value not in self.CTRL_PARAMS, - kwargs - ) - - args, ctrl_args = args[:len(kword_params)], args[len(kword_params):] - ctrl_kwargs.extend(cst.Arg(value=a.value, keyword=cst.Name(value=ctrl)) - for a, ctrl in zip(ctrl_args, self.CTRL_PARAMS)) - - request_arg = cst.Arg( - value=cst.Dict([ - cst.DictElement( - cst.SimpleString("'{}'".format(name)), -cst.Element(value=arg.value) - ) - # Note: the args + kwargs looks silly, but keep in mind that - # the control parameters had to be stripped out, and that - # those could have been passed positionally or by keyword. - for name, arg in zip(kword_params, args + kwargs)]), - keyword=cst.Name("request") - ) - - return updated.with_changes( - args=[request_arg] + ctrl_kwargs - ) - - -def fix_files( - in_dir: pathlib.Path, - out_dir: pathlib.Path, - *, - transformer=securitycentermanagementCallTransformer(), -): - """Duplicate the input dir to the output dir, fixing file method calls. - - Preconditions: - * in_dir is a real directory - * out_dir is a real, empty directory - """ - pyfile_gen = ( - pathlib.Path(os.path.join(root, f)) - for root, _, files in os.walk(in_dir) - for f in files if os.path.splitext(f)[1] == ".py" - ) - - for fpath in pyfile_gen: - with open(fpath, 'r') as f: - src = f.read() - - # Parse the code and insert method call fixes. - tree = cst.parse_module(src) - updated = tree.visit(transformer) - - # Create the path and directory structure for the new file. - updated_path = out_dir.joinpath(fpath.relative_to(in_dir)) - updated_path.parent.mkdir(parents=True, exist_ok=True) - - # Generate the updated source file at the corresponding path. - with open(updated_path, 'w') as f: - f.write(updated.code) - - -if __name__ == '__main__': - parser = argparse.ArgumentParser( - description="""Fix up source that uses the securitycentermanagement client library. - -The existing sources are NOT overwritten but are copied to output_dir with changes made. - -Note: This tool operates at a best-effort level at converting positional - parameters in client method calls to keyword based parameters. - Cases where it WILL FAIL include - A) * or ** expansion in a method call. - B) Calls via function or method alias (includes free function calls) - C) Indirect or dispatched calls (e.g. the method is looked up dynamically) - - These all constitute false negatives. The tool will also detect false - positives when an API method shares a name with another method. -""") - parser.add_argument( - '-d', - '--input-directory', - required=True, - dest='input_dir', - help='the input directory to walk for python files to fix up', - ) - parser.add_argument( - '-o', - '--output-directory', - required=True, - dest='output_dir', - help='the directory to output files fixed via un-flattening', - ) - args = parser.parse_args() - input_dir = pathlib.Path(args.input_dir) - output_dir = pathlib.Path(args.output_dir) - if not input_dir.is_dir(): - print( - f"input directory '{input_dir}' does not exist or is not a directory", - file=sys.stderr, - ) - sys.exit(-1) - - if not output_dir.is_dir(): - print( - f"output directory '{output_dir}' does not exist or is not a directory", - file=sys.stderr, - ) - sys.exit(-1) - - if os.listdir(output_dir): - print( - f"output directory '{output_dir}' is not empty", - file=sys.stderr, - ) - sys.exit(-1) - - fix_files(input_dir, output_dir) diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/setup.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/setup.py deleted file mode 100644 index 47e47326cd9a..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/setup.py +++ /dev/null @@ -1,91 +0,0 @@ -# -*- 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. -# -import io -import os -import re - -import setuptools # type: ignore - -package_root = os.path.abspath(os.path.dirname(__file__)) - -name = 'google-cloud-securitycentermanagement' - - -description = "Google Cloud Securitycentermanagement API client library" - -version = None - -with open(os.path.join(package_root, 'google/cloud/securitycentermanagement/gapic_version.py')) as fp: - version_candidates = re.findall(r"(?<=\")\d+.\d+.\d+(?=\")", fp.read()) - assert (len(version_candidates) == 1) - version = version_candidates[0] - -if version[0] == "0": - release_status = "Development Status :: 4 - Beta" -else: - release_status = "Development Status :: 5 - Production/Stable" - -dependencies = [ - "google-api-core[grpc] >= 1.34.0, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,!=2.8.*,!=2.9.*,!=2.10.*", - "proto-plus >= 1.22.3, <2.0.0dev", - "protobuf>=3.19.5,<5.0.0dev,!=3.20.0,!=3.20.1,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5", - "grpc-google-iam-v1 >= 0.12.4, <1.0.0dev", -] -url = "https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-securitycentermanagement" - -package_root = os.path.abspath(os.path.dirname(__file__)) - -readme_filename = os.path.join(package_root, "README.rst") -with io.open(readme_filename, encoding="utf-8") as readme_file: - readme = readme_file.read() - -packages = [ - package - for package in setuptools.find_namespace_packages() - if package.startswith("google") -] - -setuptools.setup( - name=name, - version=version, - description=description, - long_description=readme, - author="Google LLC", - author_email="googleapis-packages@google.com", - license="Apache 2.0", - url=url, - classifiers=[ - release_status, - "Intended Audience :: Developers", - "License :: OSI Approved :: Apache Software License", - "Programming Language :: Python", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "Operating System :: OS Independent", - "Topic :: Internet", - ], - platforms="Posix; MacOS X; Windows", - packages=packages, - python_requires=">=3.7", - install_requires=dependencies, - include_package_data=True, - zip_safe=False, -) diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/testing/constraints-3.10.txt b/owl-bot-staging/google-cloud-securitycentermanagement/v1/testing/constraints-3.10.txt deleted file mode 100644 index ad3f0fa58e2d..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/testing/constraints-3.10.txt +++ /dev/null @@ -1,7 +0,0 @@ -# -*- coding: utf-8 -*- -# This constraints file is required for unit tests. -# List all library dependencies and extras in this file. -google-api-core -proto-plus -protobuf -grpc-google-iam-v1 diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/testing/constraints-3.11.txt b/owl-bot-staging/google-cloud-securitycentermanagement/v1/testing/constraints-3.11.txt deleted file mode 100644 index ad3f0fa58e2d..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/testing/constraints-3.11.txt +++ /dev/null @@ -1,7 +0,0 @@ -# -*- coding: utf-8 -*- -# This constraints file is required for unit tests. -# List all library dependencies and extras in this file. -google-api-core -proto-plus -protobuf -grpc-google-iam-v1 diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/testing/constraints-3.12.txt b/owl-bot-staging/google-cloud-securitycentermanagement/v1/testing/constraints-3.12.txt deleted file mode 100644 index ad3f0fa58e2d..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/testing/constraints-3.12.txt +++ /dev/null @@ -1,7 +0,0 @@ -# -*- coding: utf-8 -*- -# This constraints file is required for unit tests. -# List all library dependencies and extras in this file. -google-api-core -proto-plus -protobuf -grpc-google-iam-v1 diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/testing/constraints-3.7.txt b/owl-bot-staging/google-cloud-securitycentermanagement/v1/testing/constraints-3.7.txt deleted file mode 100644 index 44ffd04543a8..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/testing/constraints-3.7.txt +++ /dev/null @@ -1,10 +0,0 @@ -# This constraints file is used to check that lower bounds -# are correct in setup.py -# List all library dependencies and extras in this file. -# Pin the version to the lower bound. -# e.g., if setup.py has "google-cloud-foo >= 1.14.0, < 2.0.0dev", -# Then this file should have google-cloud-foo==1.14.0 -google-api-core==1.34.0 -proto-plus==1.22.3 -protobuf==3.19.5 -grpc-google-iam-v1==0.12.4 diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/testing/constraints-3.8.txt b/owl-bot-staging/google-cloud-securitycentermanagement/v1/testing/constraints-3.8.txt deleted file mode 100644 index ad3f0fa58e2d..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/testing/constraints-3.8.txt +++ /dev/null @@ -1,7 +0,0 @@ -# -*- coding: utf-8 -*- -# This constraints file is required for unit tests. -# List all library dependencies and extras in this file. -google-api-core -proto-plus -protobuf -grpc-google-iam-v1 diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/testing/constraints-3.9.txt b/owl-bot-staging/google-cloud-securitycentermanagement/v1/testing/constraints-3.9.txt deleted file mode 100644 index ad3f0fa58e2d..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/testing/constraints-3.9.txt +++ /dev/null @@ -1,7 +0,0 @@ -# -*- coding: utf-8 -*- -# This constraints file is required for unit tests. -# List all library dependencies and extras in this file. -google-api-core -proto-plus -protobuf -grpc-google-iam-v1 diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/tests/__init__.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/tests/__init__.py deleted file mode 100644 index 1b4db446eb8d..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/tests/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- 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. -# diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/tests/unit/__init__.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/tests/unit/__init__.py deleted file mode 100644 index 1b4db446eb8d..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/tests/unit/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- 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. -# diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/tests/unit/gapic/__init__.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/tests/unit/gapic/__init__.py deleted file mode 100644 index 1b4db446eb8d..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/tests/unit/gapic/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- 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. -# diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/tests/unit/gapic/securitycentermanagement_v1/__init__.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/tests/unit/gapic/securitycentermanagement_v1/__init__.py deleted file mode 100644 index 1b4db446eb8d..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/tests/unit/gapic/securitycentermanagement_v1/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ - -# -*- 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. -# diff --git a/owl-bot-staging/google-cloud-securitycentermanagement/v1/tests/unit/gapic/securitycentermanagement_v1/test_security_center_management.py b/owl-bot-staging/google-cloud-securitycentermanagement/v1/tests/unit/gapic/securitycentermanagement_v1/test_security_center_management.py deleted file mode 100644 index 442d1b229d30..000000000000 --- a/owl-bot-staging/google-cloud-securitycentermanagement/v1/tests/unit/gapic/securitycentermanagement_v1/test_security_center_management.py +++ /dev/null @@ -1,12019 +0,0 @@ -# -*- 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. -# -import os -# try/except added for compatibility with python < 3.8 -try: - from unittest import mock - from unittest.mock import AsyncMock # pragma: NO COVER -except ImportError: # pragma: NO COVER - import mock - -import grpc -from grpc.experimental import aio -from collections.abc import Iterable -from google.protobuf import json_format -import json -import math -import pytest -from proto.marshal.rules.dates import DurationRule, TimestampRule -from proto.marshal.rules import wrappers -from requests import Response -from requests import Request, PreparedRequest -from requests.sessions import Session -from google.protobuf import json_format - -from google.api_core import client_options -from google.api_core import exceptions as core_exceptions -from google.api_core import gapic_v1 -from google.api_core import grpc_helpers -from google.api_core import grpc_helpers_async -from google.api_core import path_template -from google.auth import credentials as ga_credentials -from google.auth.exceptions import MutualTLSChannelError -from google.cloud.location import locations_pb2 -from google.cloud.securitycentermanagement_v1.services.security_center_management import SecurityCenterManagementAsyncClient -from google.cloud.securitycentermanagement_v1.services.security_center_management import SecurityCenterManagementClient -from google.cloud.securitycentermanagement_v1.services.security_center_management import pagers -from google.cloud.securitycentermanagement_v1.services.security_center_management import transports -from google.cloud.securitycentermanagement_v1.types import security_center_management -from google.iam.v1 import policy_pb2 # type: ignore -from google.oauth2 import service_account -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import struct_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore -from google.type import expr_pb2 # type: ignore -import google.auth - - -def client_cert_source_callback(): - return b"cert bytes", b"key bytes" - - -# If default endpoint is localhost, then default mtls endpoint will be the same. -# This method modifies the default endpoint so the client can produce a different -# mtls endpoint for endpoint testing purposes. -def modify_default_endpoint(client): - return "foo.googleapis.com" if ("localhost" in client.DEFAULT_ENDPOINT) else client.DEFAULT_ENDPOINT - - -def test__get_default_mtls_endpoint(): - api_endpoint = "example.googleapis.com" - api_mtls_endpoint = "example.mtls.googleapis.com" - sandbox_endpoint = "example.sandbox.googleapis.com" - sandbox_mtls_endpoint = "example.mtls.sandbox.googleapis.com" - non_googleapi = "api.example.com" - - assert SecurityCenterManagementClient._get_default_mtls_endpoint(None) is None - assert SecurityCenterManagementClient._get_default_mtls_endpoint(api_endpoint) == api_mtls_endpoint - assert SecurityCenterManagementClient._get_default_mtls_endpoint(api_mtls_endpoint) == api_mtls_endpoint - assert SecurityCenterManagementClient._get_default_mtls_endpoint(sandbox_endpoint) == sandbox_mtls_endpoint - assert SecurityCenterManagementClient._get_default_mtls_endpoint(sandbox_mtls_endpoint) == sandbox_mtls_endpoint - assert SecurityCenterManagementClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi - - -@pytest.mark.parametrize("client_class,transport_name", [ - (SecurityCenterManagementClient, "grpc"), - (SecurityCenterManagementAsyncClient, "grpc_asyncio"), - (SecurityCenterManagementClient, "rest"), -]) -def test_security_center_management_client_from_service_account_info(client_class, transport_name): - creds = ga_credentials.AnonymousCredentials() - with mock.patch.object(service_account.Credentials, 'from_service_account_info') as factory: - factory.return_value = creds - info = {"valid": True} - client = client_class.from_service_account_info(info, transport=transport_name) - assert client.transport._credentials == creds - assert isinstance(client, client_class) - - assert client.transport._host == ( - 'securitycentermanagement.googleapis.com:443' - if transport_name in ['grpc', 'grpc_asyncio'] - else - 'https://securitycentermanagement.googleapis.com' - ) - - -@pytest.mark.parametrize("transport_class,transport_name", [ - (transports.SecurityCenterManagementGrpcTransport, "grpc"), - (transports.SecurityCenterManagementGrpcAsyncIOTransport, "grpc_asyncio"), - (transports.SecurityCenterManagementRestTransport, "rest"), -]) -def test_security_center_management_client_service_account_always_use_jwt(transport_class, transport_name): - with mock.patch.object(service_account.Credentials, 'with_always_use_jwt_access', create=True) as use_jwt: - creds = service_account.Credentials(None, None, None) - transport = transport_class(credentials=creds, always_use_jwt_access=True) - use_jwt.assert_called_once_with(True) - - with mock.patch.object(service_account.Credentials, 'with_always_use_jwt_access', create=True) as use_jwt: - creds = service_account.Credentials(None, None, None) - transport = transport_class(credentials=creds, always_use_jwt_access=False) - use_jwt.assert_not_called() - - -@pytest.mark.parametrize("client_class,transport_name", [ - (SecurityCenterManagementClient, "grpc"), - (SecurityCenterManagementAsyncClient, "grpc_asyncio"), - (SecurityCenterManagementClient, "rest"), -]) -def test_security_center_management_client_from_service_account_file(client_class, transport_name): - creds = ga_credentials.AnonymousCredentials() - with mock.patch.object(service_account.Credentials, 'from_service_account_file') as factory: - factory.return_value = creds - client = client_class.from_service_account_file("dummy/file/path.json", transport=transport_name) - assert client.transport._credentials == creds - assert isinstance(client, client_class) - - client = client_class.from_service_account_json("dummy/file/path.json", transport=transport_name) - assert client.transport._credentials == creds - assert isinstance(client, client_class) - - assert client.transport._host == ( - 'securitycentermanagement.googleapis.com:443' - if transport_name in ['grpc', 'grpc_asyncio'] - else - 'https://securitycentermanagement.googleapis.com' - ) - - -def test_security_center_management_client_get_transport_class(): - transport = SecurityCenterManagementClient.get_transport_class() - available_transports = [ - transports.SecurityCenterManagementGrpcTransport, - transports.SecurityCenterManagementRestTransport, - ] - assert transport in available_transports - - transport = SecurityCenterManagementClient.get_transport_class("grpc") - assert transport == transports.SecurityCenterManagementGrpcTransport - - -@pytest.mark.parametrize("client_class,transport_class,transport_name", [ - (SecurityCenterManagementClient, transports.SecurityCenterManagementGrpcTransport, "grpc"), - (SecurityCenterManagementAsyncClient, transports.SecurityCenterManagementGrpcAsyncIOTransport, "grpc_asyncio"), - (SecurityCenterManagementClient, transports.SecurityCenterManagementRestTransport, "rest"), -]) -@mock.patch.object(SecurityCenterManagementClient, "DEFAULT_ENDPOINT", modify_default_endpoint(SecurityCenterManagementClient)) -@mock.patch.object(SecurityCenterManagementAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(SecurityCenterManagementAsyncClient)) -def test_security_center_management_client_client_options(client_class, transport_class, transport_name): - # Check that if channel is provided we won't create a new one. - with mock.patch.object(SecurityCenterManagementClient, 'get_transport_class') as gtc: - transport = transport_class( - credentials=ga_credentials.AnonymousCredentials() - ) - client = client_class(transport=transport) - gtc.assert_not_called() - - # Check that if channel is provided via str we will create a new one. - with mock.patch.object(SecurityCenterManagementClient, 'get_transport_class') as gtc: - client = client_class(transport=transport_name) - gtc.assert_called() - - # Check the case api_endpoint is provided. - options = client_options.ClientOptions(api_endpoint="squid.clam.whelk") - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(transport=transport_name, client_options=options) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host="squid.clam.whelk", - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) - - # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is - # "never". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) - - # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT is - # "always". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_MTLS_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) - - # Check the case api_endpoint is not provided and GOOGLE_API_USE_MTLS_ENDPOINT has - # unsupported value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): - with pytest.raises(MutualTLSChannelError): - client = client_class(transport=transport_name) - - # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}): - with pytest.raises(ValueError): - client = client_class(transport=transport_name) - - # Check the case quota_project_id is provided - options = client_options.ClientOptions(quota_project_id="octopus") - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(client_options=options, transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id="octopus", - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) - # Check the case api_endpoint is provided - options = client_options.ClientOptions(api_audience="https://language.googleapis.com") - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(client_options=options, transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience="https://language.googleapis.com" - ) - -@pytest.mark.parametrize("client_class,transport_class,transport_name,use_client_cert_env", [ - (SecurityCenterManagementClient, transports.SecurityCenterManagementGrpcTransport, "grpc", "true"), - (SecurityCenterManagementAsyncClient, transports.SecurityCenterManagementGrpcAsyncIOTransport, "grpc_asyncio", "true"), - (SecurityCenterManagementClient, transports.SecurityCenterManagementGrpcTransport, "grpc", "false"), - (SecurityCenterManagementAsyncClient, transports.SecurityCenterManagementGrpcAsyncIOTransport, "grpc_asyncio", "false"), - (SecurityCenterManagementClient, transports.SecurityCenterManagementRestTransport, "rest", "true"), - (SecurityCenterManagementClient, transports.SecurityCenterManagementRestTransport, "rest", "false"), -]) -@mock.patch.object(SecurityCenterManagementClient, "DEFAULT_ENDPOINT", modify_default_endpoint(SecurityCenterManagementClient)) -@mock.patch.object(SecurityCenterManagementAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(SecurityCenterManagementAsyncClient)) -@mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "auto"}) -def test_security_center_management_client_mtls_env_auto(client_class, transport_class, transport_name, use_client_cert_env): - # This tests the endpoint autoswitch behavior. Endpoint is autoswitched to the default - # mtls endpoint, if GOOGLE_API_USE_CLIENT_CERTIFICATE is "true" and client cert exists. - - # Check the case client_cert_source is provided. Whether client cert is used depends on - # GOOGLE_API_USE_CLIENT_CERTIFICATE value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): - options = client_options.ClientOptions(client_cert_source=client_cert_source_callback) - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(client_options=options, transport=transport_name) - - if use_client_cert_env == "false": - expected_client_cert_source = None - expected_host = client.DEFAULT_ENDPOINT - else: - expected_client_cert_source = client_cert_source_callback - expected_host = client.DEFAULT_MTLS_ENDPOINT - - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=expected_host, - scopes=None, - client_cert_source_for_mtls=expected_client_cert_source, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) - - # Check the case ADC client cert is provided. Whether client cert is used depends on - # GOOGLE_API_USE_CLIENT_CERTIFICATE value. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): - with mock.patch.object(transport_class, '__init__') as patched: - with mock.patch('google.auth.transport.mtls.has_default_client_cert_source', return_value=True): - with mock.patch('google.auth.transport.mtls.default_client_cert_source', return_value=client_cert_source_callback): - if use_client_cert_env == "false": - expected_host = client.DEFAULT_ENDPOINT - expected_client_cert_source = None - else: - expected_host = client.DEFAULT_MTLS_ENDPOINT - expected_client_cert_source = client_cert_source_callback - - patched.return_value = None - client = client_class(transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=expected_host, - scopes=None, - client_cert_source_for_mtls=expected_client_cert_source, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) - - # Check the case client_cert_source and ADC client cert are not provided. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env}): - with mock.patch.object(transport_class, '__init__') as patched: - with mock.patch("google.auth.transport.mtls.has_default_client_cert_source", return_value=False): - patched.return_value = None - client = client_class(transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) - - -@pytest.mark.parametrize("client_class", [ - SecurityCenterManagementClient, SecurityCenterManagementAsyncClient -]) -@mock.patch.object(SecurityCenterManagementClient, "DEFAULT_ENDPOINT", modify_default_endpoint(SecurityCenterManagementClient)) -@mock.patch.object(SecurityCenterManagementAsyncClient, "DEFAULT_ENDPOINT", modify_default_endpoint(SecurityCenterManagementAsyncClient)) -def test_security_center_management_client_get_mtls_endpoint_and_cert_source(client_class): - mock_client_cert_source = mock.Mock() - - # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): - mock_api_endpoint = "foo" - options = client_options.ClientOptions(client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint) - api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source(options) - assert api_endpoint == mock_api_endpoint - assert cert_source == mock_client_cert_source - - # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): - mock_client_cert_source = mock.Mock() - mock_api_endpoint = "foo" - options = client_options.ClientOptions(client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint) - api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source(options) - assert api_endpoint == mock_api_endpoint - assert cert_source is None - - # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): - api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() - assert api_endpoint == client_class.DEFAULT_ENDPOINT - assert cert_source is None - - # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always". - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): - api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() - assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT - assert cert_source is None - - # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): - with mock.patch('google.auth.transport.mtls.has_default_client_cert_source', return_value=False): - api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() - assert api_endpoint == client_class.DEFAULT_ENDPOINT - assert cert_source is None - - # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists. - with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): - with mock.patch('google.auth.transport.mtls.has_default_client_cert_source', return_value=True): - with mock.patch('google.auth.transport.mtls.default_client_cert_source', return_value=mock_client_cert_source): - api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() - assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT - assert cert_source == mock_client_cert_source - - -@pytest.mark.parametrize("client_class,transport_class,transport_name", [ - (SecurityCenterManagementClient, transports.SecurityCenterManagementGrpcTransport, "grpc"), - (SecurityCenterManagementAsyncClient, transports.SecurityCenterManagementGrpcAsyncIOTransport, "grpc_asyncio"), - (SecurityCenterManagementClient, transports.SecurityCenterManagementRestTransport, "rest"), -]) -def test_security_center_management_client_client_options_scopes(client_class, transport_class, transport_name): - # Check the case scopes are provided. - options = client_options.ClientOptions( - scopes=["1", "2"], - ) - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(client_options=options, transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=client.DEFAULT_ENDPOINT, - scopes=["1", "2"], - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) - -@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ - (SecurityCenterManagementClient, transports.SecurityCenterManagementGrpcTransport, "grpc", grpc_helpers), - (SecurityCenterManagementAsyncClient, transports.SecurityCenterManagementGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), - (SecurityCenterManagementClient, transports.SecurityCenterManagementRestTransport, "rest", None), -]) -def test_security_center_management_client_client_options_credentials_file(client_class, transport_class, transport_name, grpc_helpers): - # Check the case credentials file is provided. - options = client_options.ClientOptions( - credentials_file="credentials.json" - ) - - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(client_options=options, transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file="credentials.json", - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) - -def test_security_center_management_client_client_options_from_dict(): - with mock.patch('google.cloud.securitycentermanagement_v1.services.security_center_management.transports.SecurityCenterManagementGrpcTransport.__init__') as grpc_transport: - grpc_transport.return_value = None - client = SecurityCenterManagementClient( - client_options={'api_endpoint': 'squid.clam.whelk'} - ) - grpc_transport.assert_called_once_with( - credentials=None, - credentials_file=None, - host="squid.clam.whelk", - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) - - -@pytest.mark.parametrize("client_class,transport_class,transport_name,grpc_helpers", [ - (SecurityCenterManagementClient, transports.SecurityCenterManagementGrpcTransport, "grpc", grpc_helpers), - (SecurityCenterManagementAsyncClient, transports.SecurityCenterManagementGrpcAsyncIOTransport, "grpc_asyncio", grpc_helpers_async), -]) -def test_security_center_management_client_create_channel_credentials_file(client_class, transport_class, transport_name, grpc_helpers): - # Check the case credentials file is provided. - options = client_options.ClientOptions( - credentials_file="credentials.json" - ) - - with mock.patch.object(transport_class, '__init__') as patched: - patched.return_value = None - client = client_class(client_options=options, transport=transport_name) - patched.assert_called_once_with( - credentials=None, - credentials_file="credentials.json", - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) - - # test that the credentials from file are saved and used as the credentials. - with mock.patch.object( - google.auth, "load_credentials_from_file", autospec=True - ) as load_creds, mock.patch.object( - google.auth, "default", autospec=True - ) as adc, mock.patch.object( - grpc_helpers, "create_channel" - ) as create_channel: - creds = ga_credentials.AnonymousCredentials() - file_creds = ga_credentials.AnonymousCredentials() - load_creds.return_value = (file_creds, None) - adc.return_value = (creds, None) - client = client_class(client_options=options, transport=transport_name) - create_channel.assert_called_with( - "securitycentermanagement.googleapis.com:443", - credentials=file_creds, - credentials_file=None, - quota_project_id=None, - default_scopes=( - 'https://www.googleapis.com/auth/cloud-platform', -), - scopes=None, - default_host="securitycentermanagement.googleapis.com", - ssl_credentials=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - -@pytest.mark.parametrize("request_type", [ - security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest, - dict, -]) -def test_list_effective_security_health_analytics_custom_modules(request_type, transport: str = 'grpc'): - client = SecurityCenterManagementClient( - 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_effective_security_health_analytics_custom_modules), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse( - next_page_token='next_page_token_value', - ) - response = client.list_effective_security_health_analytics_custom_modules(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListEffectiveSecurityHealthAnalyticsCustomModulesPager) - assert response.next_page_token == 'next_page_token_value' - - -def test_list_effective_security_health_analytics_custom_modules_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 = SecurityCenterManagementClient( - 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_effective_security_health_analytics_custom_modules), - '__call__') as call: - client.list_effective_security_health_analytics_custom_modules() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest() - -@pytest.mark.asyncio -async def test_list_effective_security_health_analytics_custom_modules_async(transport: str = 'grpc_asyncio', request_type=security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest): - client = SecurityCenterManagementAsyncClient( - 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_effective_security_health_analytics_custom_modules), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse( - next_page_token='next_page_token_value', - )) - response = await client.list_effective_security_health_analytics_custom_modules(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListEffectiveSecurityHealthAnalyticsCustomModulesAsyncPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.asyncio -async def test_list_effective_security_health_analytics_custom_modules_async_from_dict(): - await test_list_effective_security_health_analytics_custom_modules_async(request_type=dict) - - -def test_list_effective_security_health_analytics_custom_modules_field_headers(): - client = SecurityCenterManagementClient( - 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 = security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_effective_security_health_analytics_custom_modules), - '__call__') as call: - call.return_value = security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse() - client.list_effective_security_health_analytics_custom_modules(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_effective_security_health_analytics_custom_modules_field_headers_async(): - client = SecurityCenterManagementAsyncClient( - 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 = security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_effective_security_health_analytics_custom_modules), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse()) - await client.list_effective_security_health_analytics_custom_modules(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_effective_security_health_analytics_custom_modules_flattened(): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_effective_security_health_analytics_custom_modules), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_effective_security_health_analytics_custom_modules( - 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_effective_security_health_analytics_custom_modules_flattened_error(): - client = SecurityCenterManagementClient( - 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_effective_security_health_analytics_custom_modules( - security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest(), - parent='parent_value', - ) - -@pytest.mark.asyncio -async def test_list_effective_security_health_analytics_custom_modules_flattened_async(): - client = SecurityCenterManagementAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_effective_security_health_analytics_custom_modules), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_effective_security_health_analytics_custom_modules( - 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_effective_security_health_analytics_custom_modules_flattened_error_async(): - client = SecurityCenterManagementAsyncClient( - 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_effective_security_health_analytics_custom_modules( - security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest(), - parent='parent_value', - ) - - -def test_list_effective_security_health_analytics_custom_modules_pager(transport_name: str = "grpc"): - client = SecurityCenterManagementClient( - 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_effective_security_health_analytics_custom_modules), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse( - effective_security_health_analytics_custom_modules=[ - security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), - security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), - security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), - ], - next_page_token='abc', - ), - security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse( - effective_security_health_analytics_custom_modules=[], - next_page_token='def', - ), - security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse( - effective_security_health_analytics_custom_modules=[ - security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), - ], - next_page_token='ghi', - ), - security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse( - effective_security_health_analytics_custom_modules=[ - security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), - security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_effective_security_health_analytics_custom_modules(request={}) - - assert pager._metadata == metadata - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, security_center_management.EffectiveSecurityHealthAnalyticsCustomModule) - for i in results) -def test_list_effective_security_health_analytics_custom_modules_pages(transport_name: str = "grpc"): - client = SecurityCenterManagementClient( - 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_effective_security_health_analytics_custom_modules), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse( - effective_security_health_analytics_custom_modules=[ - security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), - security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), - security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), - ], - next_page_token='abc', - ), - security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse( - effective_security_health_analytics_custom_modules=[], - next_page_token='def', - ), - security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse( - effective_security_health_analytics_custom_modules=[ - security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), - ], - next_page_token='ghi', - ), - security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse( - effective_security_health_analytics_custom_modules=[ - security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), - security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), - ], - ), - RuntimeError, - ) - pages = list(client.list_effective_security_health_analytics_custom_modules(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_effective_security_health_analytics_custom_modules_async_pager(): - client = SecurityCenterManagementAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_effective_security_health_analytics_custom_modules), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse( - effective_security_health_analytics_custom_modules=[ - security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), - security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), - security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), - ], - next_page_token='abc', - ), - security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse( - effective_security_health_analytics_custom_modules=[], - next_page_token='def', - ), - security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse( - effective_security_health_analytics_custom_modules=[ - security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), - ], - next_page_token='ghi', - ), - security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse( - effective_security_health_analytics_custom_modules=[ - security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), - security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_effective_security_health_analytics_custom_modules(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, security_center_management.EffectiveSecurityHealthAnalyticsCustomModule) - for i in responses) - - -@pytest.mark.asyncio -async def test_list_effective_security_health_analytics_custom_modules_async_pages(): - client = SecurityCenterManagementAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_effective_security_health_analytics_custom_modules), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse( - effective_security_health_analytics_custom_modules=[ - security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), - security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), - security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), - ], - next_page_token='abc', - ), - security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse( - effective_security_health_analytics_custom_modules=[], - next_page_token='def', - ), - security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse( - effective_security_health_analytics_custom_modules=[ - security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), - ], - next_page_token='ghi', - ), - security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse( - effective_security_health_analytics_custom_modules=[ - security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), - security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), - ], - ), - 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_effective_security_health_analytics_custom_modules(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", [ - security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest, - dict, -]) -def test_get_effective_security_health_analytics_custom_module(request_type, transport: str = 'grpc'): - client = SecurityCenterManagementClient( - 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_effective_security_health_analytics_custom_module), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = security_center_management.EffectiveSecurityHealthAnalyticsCustomModule( - name='name_value', - enablement_state=security_center_management.EffectiveSecurityHealthAnalyticsCustomModule.EnablementState.ENABLED, - display_name='display_name_value', - ) - response = client.get_effective_security_health_analytics_custom_module(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, security_center_management.EffectiveSecurityHealthAnalyticsCustomModule) - assert response.name == 'name_value' - assert response.enablement_state == security_center_management.EffectiveSecurityHealthAnalyticsCustomModule.EnablementState.ENABLED - assert response.display_name == 'display_name_value' - - -def test_get_effective_security_health_analytics_custom_module_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 = SecurityCenterManagementClient( - 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_effective_security_health_analytics_custom_module), - '__call__') as call: - client.get_effective_security_health_analytics_custom_module() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest() - -@pytest.mark.asyncio -async def test_get_effective_security_health_analytics_custom_module_async(transport: str = 'grpc_asyncio', request_type=security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest): - client = SecurityCenterManagementAsyncClient( - 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_effective_security_health_analytics_custom_module), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.EffectiveSecurityHealthAnalyticsCustomModule( - name='name_value', - enablement_state=security_center_management.EffectiveSecurityHealthAnalyticsCustomModule.EnablementState.ENABLED, - display_name='display_name_value', - )) - response = await client.get_effective_security_health_analytics_custom_module(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, security_center_management.EffectiveSecurityHealthAnalyticsCustomModule) - assert response.name == 'name_value' - assert response.enablement_state == security_center_management.EffectiveSecurityHealthAnalyticsCustomModule.EnablementState.ENABLED - assert response.display_name == 'display_name_value' - - -@pytest.mark.asyncio -async def test_get_effective_security_health_analytics_custom_module_async_from_dict(): - await test_get_effective_security_health_analytics_custom_module_async(request_type=dict) - - -def test_get_effective_security_health_analytics_custom_module_field_headers(): - client = SecurityCenterManagementClient( - 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 = security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_effective_security_health_analytics_custom_module), - '__call__') as call: - call.return_value = security_center_management.EffectiveSecurityHealthAnalyticsCustomModule() - client.get_effective_security_health_analytics_custom_module(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_effective_security_health_analytics_custom_module_field_headers_async(): - client = SecurityCenterManagementAsyncClient( - 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 = security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_effective_security_health_analytics_custom_module), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.EffectiveSecurityHealthAnalyticsCustomModule()) - await client.get_effective_security_health_analytics_custom_module(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_effective_security_health_analytics_custom_module_flattened(): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_effective_security_health_analytics_custom_module), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = security_center_management.EffectiveSecurityHealthAnalyticsCustomModule() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_effective_security_health_analytics_custom_module( - 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_effective_security_health_analytics_custom_module_flattened_error(): - client = SecurityCenterManagementClient( - 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_effective_security_health_analytics_custom_module( - security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_get_effective_security_health_analytics_custom_module_flattened_async(): - client = SecurityCenterManagementAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_effective_security_health_analytics_custom_module), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = security_center_management.EffectiveSecurityHealthAnalyticsCustomModule() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.EffectiveSecurityHealthAnalyticsCustomModule()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_effective_security_health_analytics_custom_module( - 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_effective_security_health_analytics_custom_module_flattened_error_async(): - client = SecurityCenterManagementAsyncClient( - 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_effective_security_health_analytics_custom_module( - security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest, - dict, -]) -def test_list_security_health_analytics_custom_modules(request_type, transport: str = 'grpc'): - client = SecurityCenterManagementClient( - 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_security_health_analytics_custom_modules), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse( - next_page_token='next_page_token_value', - ) - response = client.list_security_health_analytics_custom_modules(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListSecurityHealthAnalyticsCustomModulesPager) - assert response.next_page_token == 'next_page_token_value' - - -def test_list_security_health_analytics_custom_modules_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 = SecurityCenterManagementClient( - 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_security_health_analytics_custom_modules), - '__call__') as call: - client.list_security_health_analytics_custom_modules() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest() - -@pytest.mark.asyncio -async def test_list_security_health_analytics_custom_modules_async(transport: str = 'grpc_asyncio', request_type=security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest): - client = SecurityCenterManagementAsyncClient( - 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_security_health_analytics_custom_modules), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse( - next_page_token='next_page_token_value', - )) - response = await client.list_security_health_analytics_custom_modules(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListSecurityHealthAnalyticsCustomModulesAsyncPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.asyncio -async def test_list_security_health_analytics_custom_modules_async_from_dict(): - await test_list_security_health_analytics_custom_modules_async(request_type=dict) - - -def test_list_security_health_analytics_custom_modules_field_headers(): - client = SecurityCenterManagementClient( - 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 = security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_security_health_analytics_custom_modules), - '__call__') as call: - call.return_value = security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse() - client.list_security_health_analytics_custom_modules(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_security_health_analytics_custom_modules_field_headers_async(): - client = SecurityCenterManagementAsyncClient( - 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 = security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_security_health_analytics_custom_modules), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse()) - await client.list_security_health_analytics_custom_modules(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_security_health_analytics_custom_modules_flattened(): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_security_health_analytics_custom_modules), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_security_health_analytics_custom_modules( - 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_security_health_analytics_custom_modules_flattened_error(): - client = SecurityCenterManagementClient( - 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_security_health_analytics_custom_modules( - security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest(), - parent='parent_value', - ) - -@pytest.mark.asyncio -async def test_list_security_health_analytics_custom_modules_flattened_async(): - client = SecurityCenterManagementAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_security_health_analytics_custom_modules), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_security_health_analytics_custom_modules( - 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_security_health_analytics_custom_modules_flattened_error_async(): - client = SecurityCenterManagementAsyncClient( - 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_security_health_analytics_custom_modules( - security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest(), - parent='parent_value', - ) - - -def test_list_security_health_analytics_custom_modules_pager(transport_name: str = "grpc"): - client = SecurityCenterManagementClient( - 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_security_health_analytics_custom_modules), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse( - security_health_analytics_custom_modules=[ - security_center_management.SecurityHealthAnalyticsCustomModule(), - security_center_management.SecurityHealthAnalyticsCustomModule(), - security_center_management.SecurityHealthAnalyticsCustomModule(), - ], - next_page_token='abc', - ), - security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse( - security_health_analytics_custom_modules=[], - next_page_token='def', - ), - security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse( - security_health_analytics_custom_modules=[ - security_center_management.SecurityHealthAnalyticsCustomModule(), - ], - next_page_token='ghi', - ), - security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse( - security_health_analytics_custom_modules=[ - security_center_management.SecurityHealthAnalyticsCustomModule(), - security_center_management.SecurityHealthAnalyticsCustomModule(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_security_health_analytics_custom_modules(request={}) - - assert pager._metadata == metadata - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, security_center_management.SecurityHealthAnalyticsCustomModule) - for i in results) -def test_list_security_health_analytics_custom_modules_pages(transport_name: str = "grpc"): - client = SecurityCenterManagementClient( - 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_security_health_analytics_custom_modules), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse( - security_health_analytics_custom_modules=[ - security_center_management.SecurityHealthAnalyticsCustomModule(), - security_center_management.SecurityHealthAnalyticsCustomModule(), - security_center_management.SecurityHealthAnalyticsCustomModule(), - ], - next_page_token='abc', - ), - security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse( - security_health_analytics_custom_modules=[], - next_page_token='def', - ), - security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse( - security_health_analytics_custom_modules=[ - security_center_management.SecurityHealthAnalyticsCustomModule(), - ], - next_page_token='ghi', - ), - security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse( - security_health_analytics_custom_modules=[ - security_center_management.SecurityHealthAnalyticsCustomModule(), - security_center_management.SecurityHealthAnalyticsCustomModule(), - ], - ), - RuntimeError, - ) - pages = list(client.list_security_health_analytics_custom_modules(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_security_health_analytics_custom_modules_async_pager(): - client = SecurityCenterManagementAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_security_health_analytics_custom_modules), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse( - security_health_analytics_custom_modules=[ - security_center_management.SecurityHealthAnalyticsCustomModule(), - security_center_management.SecurityHealthAnalyticsCustomModule(), - security_center_management.SecurityHealthAnalyticsCustomModule(), - ], - next_page_token='abc', - ), - security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse( - security_health_analytics_custom_modules=[], - next_page_token='def', - ), - security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse( - security_health_analytics_custom_modules=[ - security_center_management.SecurityHealthAnalyticsCustomModule(), - ], - next_page_token='ghi', - ), - security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse( - security_health_analytics_custom_modules=[ - security_center_management.SecurityHealthAnalyticsCustomModule(), - security_center_management.SecurityHealthAnalyticsCustomModule(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_security_health_analytics_custom_modules(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, security_center_management.SecurityHealthAnalyticsCustomModule) - for i in responses) - - -@pytest.mark.asyncio -async def test_list_security_health_analytics_custom_modules_async_pages(): - client = SecurityCenterManagementAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_security_health_analytics_custom_modules), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse( - security_health_analytics_custom_modules=[ - security_center_management.SecurityHealthAnalyticsCustomModule(), - security_center_management.SecurityHealthAnalyticsCustomModule(), - security_center_management.SecurityHealthAnalyticsCustomModule(), - ], - next_page_token='abc', - ), - security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse( - security_health_analytics_custom_modules=[], - next_page_token='def', - ), - security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse( - security_health_analytics_custom_modules=[ - security_center_management.SecurityHealthAnalyticsCustomModule(), - ], - next_page_token='ghi', - ), - security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse( - security_health_analytics_custom_modules=[ - security_center_management.SecurityHealthAnalyticsCustomModule(), - security_center_management.SecurityHealthAnalyticsCustomModule(), - ], - ), - 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_security_health_analytics_custom_modules(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", [ - security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest, - dict, -]) -def test_list_descendant_security_health_analytics_custom_modules(request_type, transport: str = 'grpc'): - client = SecurityCenterManagementClient( - 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_descendant_security_health_analytics_custom_modules), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse( - next_page_token='next_page_token_value', - ) - response = client.list_descendant_security_health_analytics_custom_modules(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListDescendantSecurityHealthAnalyticsCustomModulesPager) - assert response.next_page_token == 'next_page_token_value' - - -def test_list_descendant_security_health_analytics_custom_modules_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 = SecurityCenterManagementClient( - 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_descendant_security_health_analytics_custom_modules), - '__call__') as call: - client.list_descendant_security_health_analytics_custom_modules() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest() - -@pytest.mark.asyncio -async def test_list_descendant_security_health_analytics_custom_modules_async(transport: str = 'grpc_asyncio', request_type=security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest): - client = SecurityCenterManagementAsyncClient( - 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_descendant_security_health_analytics_custom_modules), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse( - next_page_token='next_page_token_value', - )) - response = await client.list_descendant_security_health_analytics_custom_modules(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListDescendantSecurityHealthAnalyticsCustomModulesAsyncPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.asyncio -async def test_list_descendant_security_health_analytics_custom_modules_async_from_dict(): - await test_list_descendant_security_health_analytics_custom_modules_async(request_type=dict) - - -def test_list_descendant_security_health_analytics_custom_modules_field_headers(): - client = SecurityCenterManagementClient( - 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 = security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_descendant_security_health_analytics_custom_modules), - '__call__') as call: - call.return_value = security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse() - client.list_descendant_security_health_analytics_custom_modules(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_descendant_security_health_analytics_custom_modules_field_headers_async(): - client = SecurityCenterManagementAsyncClient( - 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 = security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_descendant_security_health_analytics_custom_modules), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse()) - await client.list_descendant_security_health_analytics_custom_modules(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_descendant_security_health_analytics_custom_modules_flattened(): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_descendant_security_health_analytics_custom_modules), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_descendant_security_health_analytics_custom_modules( - 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_descendant_security_health_analytics_custom_modules_flattened_error(): - client = SecurityCenterManagementClient( - 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_descendant_security_health_analytics_custom_modules( - security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest(), - parent='parent_value', - ) - -@pytest.mark.asyncio -async def test_list_descendant_security_health_analytics_custom_modules_flattened_async(): - client = SecurityCenterManagementAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_descendant_security_health_analytics_custom_modules), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_descendant_security_health_analytics_custom_modules( - 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_descendant_security_health_analytics_custom_modules_flattened_error_async(): - client = SecurityCenterManagementAsyncClient( - 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_descendant_security_health_analytics_custom_modules( - security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest(), - parent='parent_value', - ) - - -def test_list_descendant_security_health_analytics_custom_modules_pager(transport_name: str = "grpc"): - client = SecurityCenterManagementClient( - 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_descendant_security_health_analytics_custom_modules), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse( - security_health_analytics_custom_modules=[ - security_center_management.SecurityHealthAnalyticsCustomModule(), - security_center_management.SecurityHealthAnalyticsCustomModule(), - security_center_management.SecurityHealthAnalyticsCustomModule(), - ], - next_page_token='abc', - ), - security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse( - security_health_analytics_custom_modules=[], - next_page_token='def', - ), - security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse( - security_health_analytics_custom_modules=[ - security_center_management.SecurityHealthAnalyticsCustomModule(), - ], - next_page_token='ghi', - ), - security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse( - security_health_analytics_custom_modules=[ - security_center_management.SecurityHealthAnalyticsCustomModule(), - security_center_management.SecurityHealthAnalyticsCustomModule(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_descendant_security_health_analytics_custom_modules(request={}) - - assert pager._metadata == metadata - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, security_center_management.SecurityHealthAnalyticsCustomModule) - for i in results) -def test_list_descendant_security_health_analytics_custom_modules_pages(transport_name: str = "grpc"): - client = SecurityCenterManagementClient( - 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_descendant_security_health_analytics_custom_modules), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse( - security_health_analytics_custom_modules=[ - security_center_management.SecurityHealthAnalyticsCustomModule(), - security_center_management.SecurityHealthAnalyticsCustomModule(), - security_center_management.SecurityHealthAnalyticsCustomModule(), - ], - next_page_token='abc', - ), - security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse( - security_health_analytics_custom_modules=[], - next_page_token='def', - ), - security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse( - security_health_analytics_custom_modules=[ - security_center_management.SecurityHealthAnalyticsCustomModule(), - ], - next_page_token='ghi', - ), - security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse( - security_health_analytics_custom_modules=[ - security_center_management.SecurityHealthAnalyticsCustomModule(), - security_center_management.SecurityHealthAnalyticsCustomModule(), - ], - ), - RuntimeError, - ) - pages = list(client.list_descendant_security_health_analytics_custom_modules(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_descendant_security_health_analytics_custom_modules_async_pager(): - client = SecurityCenterManagementAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_descendant_security_health_analytics_custom_modules), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse( - security_health_analytics_custom_modules=[ - security_center_management.SecurityHealthAnalyticsCustomModule(), - security_center_management.SecurityHealthAnalyticsCustomModule(), - security_center_management.SecurityHealthAnalyticsCustomModule(), - ], - next_page_token='abc', - ), - security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse( - security_health_analytics_custom_modules=[], - next_page_token='def', - ), - security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse( - security_health_analytics_custom_modules=[ - security_center_management.SecurityHealthAnalyticsCustomModule(), - ], - next_page_token='ghi', - ), - security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse( - security_health_analytics_custom_modules=[ - security_center_management.SecurityHealthAnalyticsCustomModule(), - security_center_management.SecurityHealthAnalyticsCustomModule(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_descendant_security_health_analytics_custom_modules(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, security_center_management.SecurityHealthAnalyticsCustomModule) - for i in responses) - - -@pytest.mark.asyncio -async def test_list_descendant_security_health_analytics_custom_modules_async_pages(): - client = SecurityCenterManagementAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_descendant_security_health_analytics_custom_modules), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse( - security_health_analytics_custom_modules=[ - security_center_management.SecurityHealthAnalyticsCustomModule(), - security_center_management.SecurityHealthAnalyticsCustomModule(), - security_center_management.SecurityHealthAnalyticsCustomModule(), - ], - next_page_token='abc', - ), - security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse( - security_health_analytics_custom_modules=[], - next_page_token='def', - ), - security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse( - security_health_analytics_custom_modules=[ - security_center_management.SecurityHealthAnalyticsCustomModule(), - ], - next_page_token='ghi', - ), - security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse( - security_health_analytics_custom_modules=[ - security_center_management.SecurityHealthAnalyticsCustomModule(), - security_center_management.SecurityHealthAnalyticsCustomModule(), - ], - ), - 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_descendant_security_health_analytics_custom_modules(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", [ - security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest, - dict, -]) -def test_get_security_health_analytics_custom_module(request_type, transport: str = 'grpc'): - client = SecurityCenterManagementClient( - 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_security_health_analytics_custom_module), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = security_center_management.SecurityHealthAnalyticsCustomModule( - name='name_value', - display_name='display_name_value', - enablement_state=security_center_management.SecurityHealthAnalyticsCustomModule.EnablementState.ENABLED, - last_editor='last_editor_value', - ancestor_module='ancestor_module_value', - ) - response = client.get_security_health_analytics_custom_module(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, security_center_management.SecurityHealthAnalyticsCustomModule) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - assert response.enablement_state == security_center_management.SecurityHealthAnalyticsCustomModule.EnablementState.ENABLED - assert response.last_editor == 'last_editor_value' - assert response.ancestor_module == 'ancestor_module_value' - - -def test_get_security_health_analytics_custom_module_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 = SecurityCenterManagementClient( - 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_security_health_analytics_custom_module), - '__call__') as call: - client.get_security_health_analytics_custom_module() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest() - -@pytest.mark.asyncio -async def test_get_security_health_analytics_custom_module_async(transport: str = 'grpc_asyncio', request_type=security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest): - client = SecurityCenterManagementAsyncClient( - 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_security_health_analytics_custom_module), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.SecurityHealthAnalyticsCustomModule( - name='name_value', - display_name='display_name_value', - enablement_state=security_center_management.SecurityHealthAnalyticsCustomModule.EnablementState.ENABLED, - last_editor='last_editor_value', - ancestor_module='ancestor_module_value', - )) - response = await client.get_security_health_analytics_custom_module(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, security_center_management.SecurityHealthAnalyticsCustomModule) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - assert response.enablement_state == security_center_management.SecurityHealthAnalyticsCustomModule.EnablementState.ENABLED - assert response.last_editor == 'last_editor_value' - assert response.ancestor_module == 'ancestor_module_value' - - -@pytest.mark.asyncio -async def test_get_security_health_analytics_custom_module_async_from_dict(): - await test_get_security_health_analytics_custom_module_async(request_type=dict) - - -def test_get_security_health_analytics_custom_module_field_headers(): - client = SecurityCenterManagementClient( - 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 = security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_security_health_analytics_custom_module), - '__call__') as call: - call.return_value = security_center_management.SecurityHealthAnalyticsCustomModule() - client.get_security_health_analytics_custom_module(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_security_health_analytics_custom_module_field_headers_async(): - client = SecurityCenterManagementAsyncClient( - 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 = security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_security_health_analytics_custom_module), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.SecurityHealthAnalyticsCustomModule()) - await client.get_security_health_analytics_custom_module(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_security_health_analytics_custom_module_flattened(): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_security_health_analytics_custom_module), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = security_center_management.SecurityHealthAnalyticsCustomModule() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_security_health_analytics_custom_module( - 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_security_health_analytics_custom_module_flattened_error(): - client = SecurityCenterManagementClient( - 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_security_health_analytics_custom_module( - security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_get_security_health_analytics_custom_module_flattened_async(): - client = SecurityCenterManagementAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_security_health_analytics_custom_module), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = security_center_management.SecurityHealthAnalyticsCustomModule() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.SecurityHealthAnalyticsCustomModule()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_security_health_analytics_custom_module( - 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_security_health_analytics_custom_module_flattened_error_async(): - client = SecurityCenterManagementAsyncClient( - 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_security_health_analytics_custom_module( - security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest, - dict, -]) -def test_create_security_health_analytics_custom_module(request_type, transport: str = 'grpc'): - client = SecurityCenterManagementClient( - 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_security_health_analytics_custom_module), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = security_center_management.SecurityHealthAnalyticsCustomModule( - name='name_value', - display_name='display_name_value', - enablement_state=security_center_management.SecurityHealthAnalyticsCustomModule.EnablementState.ENABLED, - last_editor='last_editor_value', - ancestor_module='ancestor_module_value', - ) - response = client.create_security_health_analytics_custom_module(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, security_center_management.SecurityHealthAnalyticsCustomModule) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - assert response.enablement_state == security_center_management.SecurityHealthAnalyticsCustomModule.EnablementState.ENABLED - assert response.last_editor == 'last_editor_value' - assert response.ancestor_module == 'ancestor_module_value' - - -def test_create_security_health_analytics_custom_module_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 = SecurityCenterManagementClient( - 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_security_health_analytics_custom_module), - '__call__') as call: - client.create_security_health_analytics_custom_module() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest() - -@pytest.mark.asyncio -async def test_create_security_health_analytics_custom_module_async(transport: str = 'grpc_asyncio', request_type=security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest): - client = SecurityCenterManagementAsyncClient( - 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_security_health_analytics_custom_module), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.SecurityHealthAnalyticsCustomModule( - name='name_value', - display_name='display_name_value', - enablement_state=security_center_management.SecurityHealthAnalyticsCustomModule.EnablementState.ENABLED, - last_editor='last_editor_value', - ancestor_module='ancestor_module_value', - )) - response = await client.create_security_health_analytics_custom_module(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, security_center_management.SecurityHealthAnalyticsCustomModule) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - assert response.enablement_state == security_center_management.SecurityHealthAnalyticsCustomModule.EnablementState.ENABLED - assert response.last_editor == 'last_editor_value' - assert response.ancestor_module == 'ancestor_module_value' - - -@pytest.mark.asyncio -async def test_create_security_health_analytics_custom_module_async_from_dict(): - await test_create_security_health_analytics_custom_module_async(request_type=dict) - - -def test_create_security_health_analytics_custom_module_field_headers(): - client = SecurityCenterManagementClient( - 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 = security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_security_health_analytics_custom_module), - '__call__') as call: - call.return_value = security_center_management.SecurityHealthAnalyticsCustomModule() - client.create_security_health_analytics_custom_module(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_security_health_analytics_custom_module_field_headers_async(): - client = SecurityCenterManagementAsyncClient( - 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 = security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_security_health_analytics_custom_module), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.SecurityHealthAnalyticsCustomModule()) - await client.create_security_health_analytics_custom_module(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_security_health_analytics_custom_module_flattened(): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_security_health_analytics_custom_module), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = security_center_management.SecurityHealthAnalyticsCustomModule() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.create_security_health_analytics_custom_module( - parent='parent_value', - security_health_analytics_custom_module=security_center_management.SecurityHealthAnalyticsCustomModule(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].security_health_analytics_custom_module - mock_val = security_center_management.SecurityHealthAnalyticsCustomModule(name='name_value') - assert arg == mock_val - - -def test_create_security_health_analytics_custom_module_flattened_error(): - client = SecurityCenterManagementClient( - 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_security_health_analytics_custom_module( - security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest(), - parent='parent_value', - security_health_analytics_custom_module=security_center_management.SecurityHealthAnalyticsCustomModule(name='name_value'), - ) - -@pytest.mark.asyncio -async def test_create_security_health_analytics_custom_module_flattened_async(): - client = SecurityCenterManagementAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_security_health_analytics_custom_module), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = security_center_management.SecurityHealthAnalyticsCustomModule() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.SecurityHealthAnalyticsCustomModule()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.create_security_health_analytics_custom_module( - parent='parent_value', - security_health_analytics_custom_module=security_center_management.SecurityHealthAnalyticsCustomModule(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].security_health_analytics_custom_module - mock_val = security_center_management.SecurityHealthAnalyticsCustomModule(name='name_value') - assert arg == mock_val - -@pytest.mark.asyncio -async def test_create_security_health_analytics_custom_module_flattened_error_async(): - client = SecurityCenterManagementAsyncClient( - 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_security_health_analytics_custom_module( - security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest(), - parent='parent_value', - security_health_analytics_custom_module=security_center_management.SecurityHealthAnalyticsCustomModule(name='name_value'), - ) - - -@pytest.mark.parametrize("request_type", [ - security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest, - dict, -]) -def test_update_security_health_analytics_custom_module(request_type, transport: str = 'grpc'): - client = SecurityCenterManagementClient( - 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_security_health_analytics_custom_module), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = security_center_management.SecurityHealthAnalyticsCustomModule( - name='name_value', - display_name='display_name_value', - enablement_state=security_center_management.SecurityHealthAnalyticsCustomModule.EnablementState.ENABLED, - last_editor='last_editor_value', - ancestor_module='ancestor_module_value', - ) - response = client.update_security_health_analytics_custom_module(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, security_center_management.SecurityHealthAnalyticsCustomModule) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - assert response.enablement_state == security_center_management.SecurityHealthAnalyticsCustomModule.EnablementState.ENABLED - assert response.last_editor == 'last_editor_value' - assert response.ancestor_module == 'ancestor_module_value' - - -def test_update_security_health_analytics_custom_module_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 = SecurityCenterManagementClient( - 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_security_health_analytics_custom_module), - '__call__') as call: - client.update_security_health_analytics_custom_module() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest() - -@pytest.mark.asyncio -async def test_update_security_health_analytics_custom_module_async(transport: str = 'grpc_asyncio', request_type=security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest): - client = SecurityCenterManagementAsyncClient( - 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_security_health_analytics_custom_module), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.SecurityHealthAnalyticsCustomModule( - name='name_value', - display_name='display_name_value', - enablement_state=security_center_management.SecurityHealthAnalyticsCustomModule.EnablementState.ENABLED, - last_editor='last_editor_value', - ancestor_module='ancestor_module_value', - )) - response = await client.update_security_health_analytics_custom_module(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, security_center_management.SecurityHealthAnalyticsCustomModule) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - assert response.enablement_state == security_center_management.SecurityHealthAnalyticsCustomModule.EnablementState.ENABLED - assert response.last_editor == 'last_editor_value' - assert response.ancestor_module == 'ancestor_module_value' - - -@pytest.mark.asyncio -async def test_update_security_health_analytics_custom_module_async_from_dict(): - await test_update_security_health_analytics_custom_module_async(request_type=dict) - - -def test_update_security_health_analytics_custom_module_field_headers(): - client = SecurityCenterManagementClient( - 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 = security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest() - - request.security_health_analytics_custom_module.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_security_health_analytics_custom_module), - '__call__') as call: - call.return_value = security_center_management.SecurityHealthAnalyticsCustomModule() - client.update_security_health_analytics_custom_module(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', - 'security_health_analytics_custom_module.name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_security_health_analytics_custom_module_field_headers_async(): - client = SecurityCenterManagementAsyncClient( - 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 = security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest() - - request.security_health_analytics_custom_module.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_security_health_analytics_custom_module), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.SecurityHealthAnalyticsCustomModule()) - await client.update_security_health_analytics_custom_module(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', - 'security_health_analytics_custom_module.name=name_value', - ) in kw['metadata'] - - -def test_update_security_health_analytics_custom_module_flattened(): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_security_health_analytics_custom_module), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = security_center_management.SecurityHealthAnalyticsCustomModule() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.update_security_health_analytics_custom_module( - security_health_analytics_custom_module=security_center_management.SecurityHealthAnalyticsCustomModule(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].security_health_analytics_custom_module - mock_val = security_center_management.SecurityHealthAnalyticsCustomModule(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_security_health_analytics_custom_module_flattened_error(): - client = SecurityCenterManagementClient( - 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_security_health_analytics_custom_module( - security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest(), - security_health_analytics_custom_module=security_center_management.SecurityHealthAnalyticsCustomModule(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - -@pytest.mark.asyncio -async def test_update_security_health_analytics_custom_module_flattened_async(): - client = SecurityCenterManagementAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_security_health_analytics_custom_module), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = security_center_management.SecurityHealthAnalyticsCustomModule() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.SecurityHealthAnalyticsCustomModule()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.update_security_health_analytics_custom_module( - security_health_analytics_custom_module=security_center_management.SecurityHealthAnalyticsCustomModule(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].security_health_analytics_custom_module - mock_val = security_center_management.SecurityHealthAnalyticsCustomModule(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_security_health_analytics_custom_module_flattened_error_async(): - client = SecurityCenterManagementAsyncClient( - 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_security_health_analytics_custom_module( - security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest(), - security_health_analytics_custom_module=security_center_management.SecurityHealthAnalyticsCustomModule(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.parametrize("request_type", [ - security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest, - dict, -]) -def test_delete_security_health_analytics_custom_module(request_type, transport: str = 'grpc'): - client = SecurityCenterManagementClient( - 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_security_health_analytics_custom_module), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - response = client.delete_security_health_analytics_custom_module(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -def test_delete_security_health_analytics_custom_module_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 = SecurityCenterManagementClient( - 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_security_health_analytics_custom_module), - '__call__') as call: - client.delete_security_health_analytics_custom_module() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest() - -@pytest.mark.asyncio -async def test_delete_security_health_analytics_custom_module_async(transport: str = 'grpc_asyncio', request_type=security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest): - client = SecurityCenterManagementAsyncClient( - 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_security_health_analytics_custom_module), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - response = await client.delete_security_health_analytics_custom_module(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -@pytest.mark.asyncio -async def test_delete_security_health_analytics_custom_module_async_from_dict(): - await test_delete_security_health_analytics_custom_module_async(request_type=dict) - - -def test_delete_security_health_analytics_custom_module_field_headers(): - client = SecurityCenterManagementClient( - 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 = security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_security_health_analytics_custom_module), - '__call__') as call: - call.return_value = None - client.delete_security_health_analytics_custom_module(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_security_health_analytics_custom_module_field_headers_async(): - client = SecurityCenterManagementAsyncClient( - 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 = security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_security_health_analytics_custom_module), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.delete_security_health_analytics_custom_module(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_security_health_analytics_custom_module_flattened(): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_security_health_analytics_custom_module), - '__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_security_health_analytics_custom_module( - 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_security_health_analytics_custom_module_flattened_error(): - client = SecurityCenterManagementClient( - 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_security_health_analytics_custom_module( - security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_delete_security_health_analytics_custom_module_flattened_async(): - client = SecurityCenterManagementAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_security_health_analytics_custom_module), - '__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_security_health_analytics_custom_module( - 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_security_health_analytics_custom_module_flattened_error_async(): - client = SecurityCenterManagementAsyncClient( - 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_security_health_analytics_custom_module( - security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest, - dict, -]) -def test_simulate_security_health_analytics_custom_module(request_type, transport: str = 'grpc'): - client = SecurityCenterManagementClient( - 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.simulate_security_health_analytics_custom_module), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse( - ) - response = client.simulate_security_health_analytics_custom_module(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse) - - -def test_simulate_security_health_analytics_custom_module_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 = SecurityCenterManagementClient( - 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.simulate_security_health_analytics_custom_module), - '__call__') as call: - client.simulate_security_health_analytics_custom_module() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest() - -@pytest.mark.asyncio -async def test_simulate_security_health_analytics_custom_module_async(transport: str = 'grpc_asyncio', request_type=security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest): - client = SecurityCenterManagementAsyncClient( - 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.simulate_security_health_analytics_custom_module), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse( - )) - response = await client.simulate_security_health_analytics_custom_module(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse) - - -@pytest.mark.asyncio -async def test_simulate_security_health_analytics_custom_module_async_from_dict(): - await test_simulate_security_health_analytics_custom_module_async(request_type=dict) - - -def test_simulate_security_health_analytics_custom_module_field_headers(): - client = SecurityCenterManagementClient( - 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 = security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.simulate_security_health_analytics_custom_module), - '__call__') as call: - call.return_value = security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse() - client.simulate_security_health_analytics_custom_module(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_simulate_security_health_analytics_custom_module_field_headers_async(): - client = SecurityCenterManagementAsyncClient( - 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 = security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.simulate_security_health_analytics_custom_module), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse()) - await client.simulate_security_health_analytics_custom_module(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_simulate_security_health_analytics_custom_module_flattened(): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.simulate_security_health_analytics_custom_module), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.simulate_security_health_analytics_custom_module( - parent='parent_value', - custom_config=security_center_management.CustomConfig(predicate=expr_pb2.Expr(expression='expression_value')), - resource=security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest.SimulatedResource(resource_type='resource_type_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].custom_config - mock_val = security_center_management.CustomConfig(predicate=expr_pb2.Expr(expression='expression_value')) - assert arg == mock_val - arg = args[0].resource - mock_val = security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest.SimulatedResource(resource_type='resource_type_value') - assert arg == mock_val - - -def test_simulate_security_health_analytics_custom_module_flattened_error(): - client = SecurityCenterManagementClient( - 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.simulate_security_health_analytics_custom_module( - security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest(), - parent='parent_value', - custom_config=security_center_management.CustomConfig(predicate=expr_pb2.Expr(expression='expression_value')), - resource=security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest.SimulatedResource(resource_type='resource_type_value'), - ) - -@pytest.mark.asyncio -async def test_simulate_security_health_analytics_custom_module_flattened_async(): - client = SecurityCenterManagementAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.simulate_security_health_analytics_custom_module), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.simulate_security_health_analytics_custom_module( - parent='parent_value', - custom_config=security_center_management.CustomConfig(predicate=expr_pb2.Expr(expression='expression_value')), - resource=security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest.SimulatedResource(resource_type='resource_type_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].custom_config - mock_val = security_center_management.CustomConfig(predicate=expr_pb2.Expr(expression='expression_value')) - assert arg == mock_val - arg = args[0].resource - mock_val = security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest.SimulatedResource(resource_type='resource_type_value') - assert arg == mock_val - -@pytest.mark.asyncio -async def test_simulate_security_health_analytics_custom_module_flattened_error_async(): - client = SecurityCenterManagementAsyncClient( - 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.simulate_security_health_analytics_custom_module( - security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest(), - parent='parent_value', - custom_config=security_center_management.CustomConfig(predicate=expr_pb2.Expr(expression='expression_value')), - resource=security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest.SimulatedResource(resource_type='resource_type_value'), - ) - - -@pytest.mark.parametrize("request_type", [ - security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest, - dict, -]) -def test_list_effective_event_threat_detection_custom_modules(request_type, transport: str = 'grpc'): - client = SecurityCenterManagementClient( - 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_effective_event_threat_detection_custom_modules), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse( - next_page_token='next_page_token_value', - ) - response = client.list_effective_event_threat_detection_custom_modules(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListEffectiveEventThreatDetectionCustomModulesPager) - assert response.next_page_token == 'next_page_token_value' - - -def test_list_effective_event_threat_detection_custom_modules_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 = SecurityCenterManagementClient( - 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_effective_event_threat_detection_custom_modules), - '__call__') as call: - client.list_effective_event_threat_detection_custom_modules() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest() - -@pytest.mark.asyncio -async def test_list_effective_event_threat_detection_custom_modules_async(transport: str = 'grpc_asyncio', request_type=security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest): - client = SecurityCenterManagementAsyncClient( - 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_effective_event_threat_detection_custom_modules), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse( - next_page_token='next_page_token_value', - )) - response = await client.list_effective_event_threat_detection_custom_modules(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListEffectiveEventThreatDetectionCustomModulesAsyncPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.asyncio -async def test_list_effective_event_threat_detection_custom_modules_async_from_dict(): - await test_list_effective_event_threat_detection_custom_modules_async(request_type=dict) - - -def test_list_effective_event_threat_detection_custom_modules_field_headers(): - client = SecurityCenterManagementClient( - 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 = security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_effective_event_threat_detection_custom_modules), - '__call__') as call: - call.return_value = security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse() - client.list_effective_event_threat_detection_custom_modules(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_effective_event_threat_detection_custom_modules_field_headers_async(): - client = SecurityCenterManagementAsyncClient( - 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 = security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_effective_event_threat_detection_custom_modules), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse()) - await client.list_effective_event_threat_detection_custom_modules(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_effective_event_threat_detection_custom_modules_flattened(): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_effective_event_threat_detection_custom_modules), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_effective_event_threat_detection_custom_modules( - 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_effective_event_threat_detection_custom_modules_flattened_error(): - client = SecurityCenterManagementClient( - 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_effective_event_threat_detection_custom_modules( - security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest(), - parent='parent_value', - ) - -@pytest.mark.asyncio -async def test_list_effective_event_threat_detection_custom_modules_flattened_async(): - client = SecurityCenterManagementAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_effective_event_threat_detection_custom_modules), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_effective_event_threat_detection_custom_modules( - 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_effective_event_threat_detection_custom_modules_flattened_error_async(): - client = SecurityCenterManagementAsyncClient( - 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_effective_event_threat_detection_custom_modules( - security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest(), - parent='parent_value', - ) - - -def test_list_effective_event_threat_detection_custom_modules_pager(transport_name: str = "grpc"): - client = SecurityCenterManagementClient( - 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_effective_event_threat_detection_custom_modules), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse( - effective_event_threat_detection_custom_modules=[ - security_center_management.EffectiveEventThreatDetectionCustomModule(), - security_center_management.EffectiveEventThreatDetectionCustomModule(), - security_center_management.EffectiveEventThreatDetectionCustomModule(), - ], - next_page_token='abc', - ), - security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse( - effective_event_threat_detection_custom_modules=[], - next_page_token='def', - ), - security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse( - effective_event_threat_detection_custom_modules=[ - security_center_management.EffectiveEventThreatDetectionCustomModule(), - ], - next_page_token='ghi', - ), - security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse( - effective_event_threat_detection_custom_modules=[ - security_center_management.EffectiveEventThreatDetectionCustomModule(), - security_center_management.EffectiveEventThreatDetectionCustomModule(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_effective_event_threat_detection_custom_modules(request={}) - - assert pager._metadata == metadata - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, security_center_management.EffectiveEventThreatDetectionCustomModule) - for i in results) -def test_list_effective_event_threat_detection_custom_modules_pages(transport_name: str = "grpc"): - client = SecurityCenterManagementClient( - 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_effective_event_threat_detection_custom_modules), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse( - effective_event_threat_detection_custom_modules=[ - security_center_management.EffectiveEventThreatDetectionCustomModule(), - security_center_management.EffectiveEventThreatDetectionCustomModule(), - security_center_management.EffectiveEventThreatDetectionCustomModule(), - ], - next_page_token='abc', - ), - security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse( - effective_event_threat_detection_custom_modules=[], - next_page_token='def', - ), - security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse( - effective_event_threat_detection_custom_modules=[ - security_center_management.EffectiveEventThreatDetectionCustomModule(), - ], - next_page_token='ghi', - ), - security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse( - effective_event_threat_detection_custom_modules=[ - security_center_management.EffectiveEventThreatDetectionCustomModule(), - security_center_management.EffectiveEventThreatDetectionCustomModule(), - ], - ), - RuntimeError, - ) - pages = list(client.list_effective_event_threat_detection_custom_modules(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_effective_event_threat_detection_custom_modules_async_pager(): - client = SecurityCenterManagementAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_effective_event_threat_detection_custom_modules), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse( - effective_event_threat_detection_custom_modules=[ - security_center_management.EffectiveEventThreatDetectionCustomModule(), - security_center_management.EffectiveEventThreatDetectionCustomModule(), - security_center_management.EffectiveEventThreatDetectionCustomModule(), - ], - next_page_token='abc', - ), - security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse( - effective_event_threat_detection_custom_modules=[], - next_page_token='def', - ), - security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse( - effective_event_threat_detection_custom_modules=[ - security_center_management.EffectiveEventThreatDetectionCustomModule(), - ], - next_page_token='ghi', - ), - security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse( - effective_event_threat_detection_custom_modules=[ - security_center_management.EffectiveEventThreatDetectionCustomModule(), - security_center_management.EffectiveEventThreatDetectionCustomModule(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_effective_event_threat_detection_custom_modules(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, security_center_management.EffectiveEventThreatDetectionCustomModule) - for i in responses) - - -@pytest.mark.asyncio -async def test_list_effective_event_threat_detection_custom_modules_async_pages(): - client = SecurityCenterManagementAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_effective_event_threat_detection_custom_modules), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse( - effective_event_threat_detection_custom_modules=[ - security_center_management.EffectiveEventThreatDetectionCustomModule(), - security_center_management.EffectiveEventThreatDetectionCustomModule(), - security_center_management.EffectiveEventThreatDetectionCustomModule(), - ], - next_page_token='abc', - ), - security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse( - effective_event_threat_detection_custom_modules=[], - next_page_token='def', - ), - security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse( - effective_event_threat_detection_custom_modules=[ - security_center_management.EffectiveEventThreatDetectionCustomModule(), - ], - next_page_token='ghi', - ), - security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse( - effective_event_threat_detection_custom_modules=[ - security_center_management.EffectiveEventThreatDetectionCustomModule(), - security_center_management.EffectiveEventThreatDetectionCustomModule(), - ], - ), - 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_effective_event_threat_detection_custom_modules(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", [ - security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest, - dict, -]) -def test_get_effective_event_threat_detection_custom_module(request_type, transport: str = 'grpc'): - client = SecurityCenterManagementClient( - 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_effective_event_threat_detection_custom_module), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = security_center_management.EffectiveEventThreatDetectionCustomModule( - name='name_value', - enablement_state=security_center_management.EffectiveEventThreatDetectionCustomModule.EnablementState.ENABLED, - type_='type__value', - display_name='display_name_value', - description='description_value', - ) - response = client.get_effective_event_threat_detection_custom_module(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, security_center_management.EffectiveEventThreatDetectionCustomModule) - assert response.name == 'name_value' - assert response.enablement_state == security_center_management.EffectiveEventThreatDetectionCustomModule.EnablementState.ENABLED - assert response.type_ == 'type__value' - assert response.display_name == 'display_name_value' - assert response.description == 'description_value' - - -def test_get_effective_event_threat_detection_custom_module_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 = SecurityCenterManagementClient( - 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_effective_event_threat_detection_custom_module), - '__call__') as call: - client.get_effective_event_threat_detection_custom_module() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest() - -@pytest.mark.asyncio -async def test_get_effective_event_threat_detection_custom_module_async(transport: str = 'grpc_asyncio', request_type=security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest): - client = SecurityCenterManagementAsyncClient( - 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_effective_event_threat_detection_custom_module), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.EffectiveEventThreatDetectionCustomModule( - name='name_value', - enablement_state=security_center_management.EffectiveEventThreatDetectionCustomModule.EnablementState.ENABLED, - type_='type__value', - display_name='display_name_value', - description='description_value', - )) - response = await client.get_effective_event_threat_detection_custom_module(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, security_center_management.EffectiveEventThreatDetectionCustomModule) - assert response.name == 'name_value' - assert response.enablement_state == security_center_management.EffectiveEventThreatDetectionCustomModule.EnablementState.ENABLED - assert response.type_ == 'type__value' - assert response.display_name == 'display_name_value' - assert response.description == 'description_value' - - -@pytest.mark.asyncio -async def test_get_effective_event_threat_detection_custom_module_async_from_dict(): - await test_get_effective_event_threat_detection_custom_module_async(request_type=dict) - - -def test_get_effective_event_threat_detection_custom_module_field_headers(): - client = SecurityCenterManagementClient( - 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 = security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_effective_event_threat_detection_custom_module), - '__call__') as call: - call.return_value = security_center_management.EffectiveEventThreatDetectionCustomModule() - client.get_effective_event_threat_detection_custom_module(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_effective_event_threat_detection_custom_module_field_headers_async(): - client = SecurityCenterManagementAsyncClient( - 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 = security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_effective_event_threat_detection_custom_module), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.EffectiveEventThreatDetectionCustomModule()) - await client.get_effective_event_threat_detection_custom_module(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_effective_event_threat_detection_custom_module_flattened(): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_effective_event_threat_detection_custom_module), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = security_center_management.EffectiveEventThreatDetectionCustomModule() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_effective_event_threat_detection_custom_module( - 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_effective_event_threat_detection_custom_module_flattened_error(): - client = SecurityCenterManagementClient( - 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_effective_event_threat_detection_custom_module( - security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_get_effective_event_threat_detection_custom_module_flattened_async(): - client = SecurityCenterManagementAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_effective_event_threat_detection_custom_module), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = security_center_management.EffectiveEventThreatDetectionCustomModule() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.EffectiveEventThreatDetectionCustomModule()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_effective_event_threat_detection_custom_module( - 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_effective_event_threat_detection_custom_module_flattened_error_async(): - client = SecurityCenterManagementAsyncClient( - 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_effective_event_threat_detection_custom_module( - security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - security_center_management.ListEventThreatDetectionCustomModulesRequest, - dict, -]) -def test_list_event_threat_detection_custom_modules(request_type, transport: str = 'grpc'): - client = SecurityCenterManagementClient( - 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_event_threat_detection_custom_modules), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = security_center_management.ListEventThreatDetectionCustomModulesResponse( - next_page_token='next_page_token_value', - ) - response = client.list_event_threat_detection_custom_modules(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == security_center_management.ListEventThreatDetectionCustomModulesRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListEventThreatDetectionCustomModulesPager) - assert response.next_page_token == 'next_page_token_value' - - -def test_list_event_threat_detection_custom_modules_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 = SecurityCenterManagementClient( - 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_event_threat_detection_custom_modules), - '__call__') as call: - client.list_event_threat_detection_custom_modules() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == security_center_management.ListEventThreatDetectionCustomModulesRequest() - -@pytest.mark.asyncio -async def test_list_event_threat_detection_custom_modules_async(transport: str = 'grpc_asyncio', request_type=security_center_management.ListEventThreatDetectionCustomModulesRequest): - client = SecurityCenterManagementAsyncClient( - 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_event_threat_detection_custom_modules), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.ListEventThreatDetectionCustomModulesResponse( - next_page_token='next_page_token_value', - )) - response = await client.list_event_threat_detection_custom_modules(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == security_center_management.ListEventThreatDetectionCustomModulesRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListEventThreatDetectionCustomModulesAsyncPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.asyncio -async def test_list_event_threat_detection_custom_modules_async_from_dict(): - await test_list_event_threat_detection_custom_modules_async(request_type=dict) - - -def test_list_event_threat_detection_custom_modules_field_headers(): - client = SecurityCenterManagementClient( - 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 = security_center_management.ListEventThreatDetectionCustomModulesRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_event_threat_detection_custom_modules), - '__call__') as call: - call.return_value = security_center_management.ListEventThreatDetectionCustomModulesResponse() - client.list_event_threat_detection_custom_modules(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_event_threat_detection_custom_modules_field_headers_async(): - client = SecurityCenterManagementAsyncClient( - 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 = security_center_management.ListEventThreatDetectionCustomModulesRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_event_threat_detection_custom_modules), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.ListEventThreatDetectionCustomModulesResponse()) - await client.list_event_threat_detection_custom_modules(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_event_threat_detection_custom_modules_flattened(): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_event_threat_detection_custom_modules), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = security_center_management.ListEventThreatDetectionCustomModulesResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_event_threat_detection_custom_modules( - 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_event_threat_detection_custom_modules_flattened_error(): - client = SecurityCenterManagementClient( - 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_event_threat_detection_custom_modules( - security_center_management.ListEventThreatDetectionCustomModulesRequest(), - parent='parent_value', - ) - -@pytest.mark.asyncio -async def test_list_event_threat_detection_custom_modules_flattened_async(): - client = SecurityCenterManagementAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_event_threat_detection_custom_modules), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = security_center_management.ListEventThreatDetectionCustomModulesResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.ListEventThreatDetectionCustomModulesResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_event_threat_detection_custom_modules( - 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_event_threat_detection_custom_modules_flattened_error_async(): - client = SecurityCenterManagementAsyncClient( - 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_event_threat_detection_custom_modules( - security_center_management.ListEventThreatDetectionCustomModulesRequest(), - parent='parent_value', - ) - - -def test_list_event_threat_detection_custom_modules_pager(transport_name: str = "grpc"): - client = SecurityCenterManagementClient( - 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_event_threat_detection_custom_modules), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - security_center_management.ListEventThreatDetectionCustomModulesResponse( - event_threat_detection_custom_modules=[ - security_center_management.EventThreatDetectionCustomModule(), - security_center_management.EventThreatDetectionCustomModule(), - security_center_management.EventThreatDetectionCustomModule(), - ], - next_page_token='abc', - ), - security_center_management.ListEventThreatDetectionCustomModulesResponse( - event_threat_detection_custom_modules=[], - next_page_token='def', - ), - security_center_management.ListEventThreatDetectionCustomModulesResponse( - event_threat_detection_custom_modules=[ - security_center_management.EventThreatDetectionCustomModule(), - ], - next_page_token='ghi', - ), - security_center_management.ListEventThreatDetectionCustomModulesResponse( - event_threat_detection_custom_modules=[ - security_center_management.EventThreatDetectionCustomModule(), - security_center_management.EventThreatDetectionCustomModule(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_event_threat_detection_custom_modules(request={}) - - assert pager._metadata == metadata - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, security_center_management.EventThreatDetectionCustomModule) - for i in results) -def test_list_event_threat_detection_custom_modules_pages(transport_name: str = "grpc"): - client = SecurityCenterManagementClient( - 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_event_threat_detection_custom_modules), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - security_center_management.ListEventThreatDetectionCustomModulesResponse( - event_threat_detection_custom_modules=[ - security_center_management.EventThreatDetectionCustomModule(), - security_center_management.EventThreatDetectionCustomModule(), - security_center_management.EventThreatDetectionCustomModule(), - ], - next_page_token='abc', - ), - security_center_management.ListEventThreatDetectionCustomModulesResponse( - event_threat_detection_custom_modules=[], - next_page_token='def', - ), - security_center_management.ListEventThreatDetectionCustomModulesResponse( - event_threat_detection_custom_modules=[ - security_center_management.EventThreatDetectionCustomModule(), - ], - next_page_token='ghi', - ), - security_center_management.ListEventThreatDetectionCustomModulesResponse( - event_threat_detection_custom_modules=[ - security_center_management.EventThreatDetectionCustomModule(), - security_center_management.EventThreatDetectionCustomModule(), - ], - ), - RuntimeError, - ) - pages = list(client.list_event_threat_detection_custom_modules(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_event_threat_detection_custom_modules_async_pager(): - client = SecurityCenterManagementAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_event_threat_detection_custom_modules), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - security_center_management.ListEventThreatDetectionCustomModulesResponse( - event_threat_detection_custom_modules=[ - security_center_management.EventThreatDetectionCustomModule(), - security_center_management.EventThreatDetectionCustomModule(), - security_center_management.EventThreatDetectionCustomModule(), - ], - next_page_token='abc', - ), - security_center_management.ListEventThreatDetectionCustomModulesResponse( - event_threat_detection_custom_modules=[], - next_page_token='def', - ), - security_center_management.ListEventThreatDetectionCustomModulesResponse( - event_threat_detection_custom_modules=[ - security_center_management.EventThreatDetectionCustomModule(), - ], - next_page_token='ghi', - ), - security_center_management.ListEventThreatDetectionCustomModulesResponse( - event_threat_detection_custom_modules=[ - security_center_management.EventThreatDetectionCustomModule(), - security_center_management.EventThreatDetectionCustomModule(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_event_threat_detection_custom_modules(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, security_center_management.EventThreatDetectionCustomModule) - for i in responses) - - -@pytest.mark.asyncio -async def test_list_event_threat_detection_custom_modules_async_pages(): - client = SecurityCenterManagementAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_event_threat_detection_custom_modules), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - security_center_management.ListEventThreatDetectionCustomModulesResponse( - event_threat_detection_custom_modules=[ - security_center_management.EventThreatDetectionCustomModule(), - security_center_management.EventThreatDetectionCustomModule(), - security_center_management.EventThreatDetectionCustomModule(), - ], - next_page_token='abc', - ), - security_center_management.ListEventThreatDetectionCustomModulesResponse( - event_threat_detection_custom_modules=[], - next_page_token='def', - ), - security_center_management.ListEventThreatDetectionCustomModulesResponse( - event_threat_detection_custom_modules=[ - security_center_management.EventThreatDetectionCustomModule(), - ], - next_page_token='ghi', - ), - security_center_management.ListEventThreatDetectionCustomModulesResponse( - event_threat_detection_custom_modules=[ - security_center_management.EventThreatDetectionCustomModule(), - security_center_management.EventThreatDetectionCustomModule(), - ], - ), - 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_event_threat_detection_custom_modules(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", [ - security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest, - dict, -]) -def test_list_descendant_event_threat_detection_custom_modules(request_type, transport: str = 'grpc'): - client = SecurityCenterManagementClient( - 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_descendant_event_threat_detection_custom_modules), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse( - next_page_token='next_page_token_value', - ) - response = client.list_descendant_event_threat_detection_custom_modules(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListDescendantEventThreatDetectionCustomModulesPager) - assert response.next_page_token == 'next_page_token_value' - - -def test_list_descendant_event_threat_detection_custom_modules_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 = SecurityCenterManagementClient( - 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_descendant_event_threat_detection_custom_modules), - '__call__') as call: - client.list_descendant_event_threat_detection_custom_modules() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest() - -@pytest.mark.asyncio -async def test_list_descendant_event_threat_detection_custom_modules_async(transport: str = 'grpc_asyncio', request_type=security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest): - client = SecurityCenterManagementAsyncClient( - 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_descendant_event_threat_detection_custom_modules), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse( - next_page_token='next_page_token_value', - )) - response = await client.list_descendant_event_threat_detection_custom_modules(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListDescendantEventThreatDetectionCustomModulesAsyncPager) - assert response.next_page_token == 'next_page_token_value' - - -@pytest.mark.asyncio -async def test_list_descendant_event_threat_detection_custom_modules_async_from_dict(): - await test_list_descendant_event_threat_detection_custom_modules_async(request_type=dict) - - -def test_list_descendant_event_threat_detection_custom_modules_field_headers(): - client = SecurityCenterManagementClient( - 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 = security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_descendant_event_threat_detection_custom_modules), - '__call__') as call: - call.return_value = security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse() - client.list_descendant_event_threat_detection_custom_modules(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_descendant_event_threat_detection_custom_modules_field_headers_async(): - client = SecurityCenterManagementAsyncClient( - 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 = security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_descendant_event_threat_detection_custom_modules), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse()) - await client.list_descendant_event_threat_detection_custom_modules(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_descendant_event_threat_detection_custom_modules_flattened(): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_descendant_event_threat_detection_custom_modules), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.list_descendant_event_threat_detection_custom_modules( - 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_descendant_event_threat_detection_custom_modules_flattened_error(): - client = SecurityCenterManagementClient( - 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_descendant_event_threat_detection_custom_modules( - security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest(), - parent='parent_value', - ) - -@pytest.mark.asyncio -async def test_list_descendant_event_threat_detection_custom_modules_flattened_async(): - client = SecurityCenterManagementAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_descendant_event_threat_detection_custom_modules), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.list_descendant_event_threat_detection_custom_modules( - 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_descendant_event_threat_detection_custom_modules_flattened_error_async(): - client = SecurityCenterManagementAsyncClient( - 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_descendant_event_threat_detection_custom_modules( - security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest(), - parent='parent_value', - ) - - -def test_list_descendant_event_threat_detection_custom_modules_pager(transport_name: str = "grpc"): - client = SecurityCenterManagementClient( - 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_descendant_event_threat_detection_custom_modules), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse( - event_threat_detection_custom_modules=[ - security_center_management.EventThreatDetectionCustomModule(), - security_center_management.EventThreatDetectionCustomModule(), - security_center_management.EventThreatDetectionCustomModule(), - ], - next_page_token='abc', - ), - security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse( - event_threat_detection_custom_modules=[], - next_page_token='def', - ), - security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse( - event_threat_detection_custom_modules=[ - security_center_management.EventThreatDetectionCustomModule(), - ], - next_page_token='ghi', - ), - security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse( - event_threat_detection_custom_modules=[ - security_center_management.EventThreatDetectionCustomModule(), - security_center_management.EventThreatDetectionCustomModule(), - ], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata(( - ('parent', ''), - )), - ) - pager = client.list_descendant_event_threat_detection_custom_modules(request={}) - - assert pager._metadata == metadata - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, security_center_management.EventThreatDetectionCustomModule) - for i in results) -def test_list_descendant_event_threat_detection_custom_modules_pages(transport_name: str = "grpc"): - client = SecurityCenterManagementClient( - 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_descendant_event_threat_detection_custom_modules), - '__call__') as call: - # Set the response to a series of pages. - call.side_effect = ( - security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse( - event_threat_detection_custom_modules=[ - security_center_management.EventThreatDetectionCustomModule(), - security_center_management.EventThreatDetectionCustomModule(), - security_center_management.EventThreatDetectionCustomModule(), - ], - next_page_token='abc', - ), - security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse( - event_threat_detection_custom_modules=[], - next_page_token='def', - ), - security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse( - event_threat_detection_custom_modules=[ - security_center_management.EventThreatDetectionCustomModule(), - ], - next_page_token='ghi', - ), - security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse( - event_threat_detection_custom_modules=[ - security_center_management.EventThreatDetectionCustomModule(), - security_center_management.EventThreatDetectionCustomModule(), - ], - ), - RuntimeError, - ) - pages = list(client.list_descendant_event_threat_detection_custom_modules(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_descendant_event_threat_detection_custom_modules_async_pager(): - client = SecurityCenterManagementAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_descendant_event_threat_detection_custom_modules), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse( - event_threat_detection_custom_modules=[ - security_center_management.EventThreatDetectionCustomModule(), - security_center_management.EventThreatDetectionCustomModule(), - security_center_management.EventThreatDetectionCustomModule(), - ], - next_page_token='abc', - ), - security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse( - event_threat_detection_custom_modules=[], - next_page_token='def', - ), - security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse( - event_threat_detection_custom_modules=[ - security_center_management.EventThreatDetectionCustomModule(), - ], - next_page_token='ghi', - ), - security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse( - event_threat_detection_custom_modules=[ - security_center_management.EventThreatDetectionCustomModule(), - security_center_management.EventThreatDetectionCustomModule(), - ], - ), - RuntimeError, - ) - async_pager = await client.list_descendant_event_threat_detection_custom_modules(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, security_center_management.EventThreatDetectionCustomModule) - for i in responses) - - -@pytest.mark.asyncio -async def test_list_descendant_event_threat_detection_custom_modules_async_pages(): - client = SecurityCenterManagementAsyncClient( - credentials=ga_credentials.AnonymousCredentials, - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.list_descendant_event_threat_detection_custom_modules), - '__call__', new_callable=mock.AsyncMock) as call: - # Set the response to a series of pages. - call.side_effect = ( - security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse( - event_threat_detection_custom_modules=[ - security_center_management.EventThreatDetectionCustomModule(), - security_center_management.EventThreatDetectionCustomModule(), - security_center_management.EventThreatDetectionCustomModule(), - ], - next_page_token='abc', - ), - security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse( - event_threat_detection_custom_modules=[], - next_page_token='def', - ), - security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse( - event_threat_detection_custom_modules=[ - security_center_management.EventThreatDetectionCustomModule(), - ], - next_page_token='ghi', - ), - security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse( - event_threat_detection_custom_modules=[ - security_center_management.EventThreatDetectionCustomModule(), - security_center_management.EventThreatDetectionCustomModule(), - ], - ), - 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_descendant_event_threat_detection_custom_modules(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", [ - security_center_management.GetEventThreatDetectionCustomModuleRequest, - dict, -]) -def test_get_event_threat_detection_custom_module(request_type, transport: str = 'grpc'): - client = SecurityCenterManagementClient( - 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_event_threat_detection_custom_module), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = security_center_management.EventThreatDetectionCustomModule( - name='name_value', - ancestor_module='ancestor_module_value', - enablement_state=security_center_management.EventThreatDetectionCustomModule.EnablementState.ENABLED, - type_='type__value', - display_name='display_name_value', - description='description_value', - last_editor='last_editor_value', - ) - response = client.get_event_threat_detection_custom_module(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == security_center_management.GetEventThreatDetectionCustomModuleRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, security_center_management.EventThreatDetectionCustomModule) - assert response.name == 'name_value' - assert response.ancestor_module == 'ancestor_module_value' - assert response.enablement_state == security_center_management.EventThreatDetectionCustomModule.EnablementState.ENABLED - assert response.type_ == 'type__value' - assert response.display_name == 'display_name_value' - assert response.description == 'description_value' - assert response.last_editor == 'last_editor_value' - - -def test_get_event_threat_detection_custom_module_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 = SecurityCenterManagementClient( - 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_event_threat_detection_custom_module), - '__call__') as call: - client.get_event_threat_detection_custom_module() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == security_center_management.GetEventThreatDetectionCustomModuleRequest() - -@pytest.mark.asyncio -async def test_get_event_threat_detection_custom_module_async(transport: str = 'grpc_asyncio', request_type=security_center_management.GetEventThreatDetectionCustomModuleRequest): - client = SecurityCenterManagementAsyncClient( - 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_event_threat_detection_custom_module), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.EventThreatDetectionCustomModule( - name='name_value', - ancestor_module='ancestor_module_value', - enablement_state=security_center_management.EventThreatDetectionCustomModule.EnablementState.ENABLED, - type_='type__value', - display_name='display_name_value', - description='description_value', - last_editor='last_editor_value', - )) - response = await client.get_event_threat_detection_custom_module(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == security_center_management.GetEventThreatDetectionCustomModuleRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, security_center_management.EventThreatDetectionCustomModule) - assert response.name == 'name_value' - assert response.ancestor_module == 'ancestor_module_value' - assert response.enablement_state == security_center_management.EventThreatDetectionCustomModule.EnablementState.ENABLED - assert response.type_ == 'type__value' - assert response.display_name == 'display_name_value' - assert response.description == 'description_value' - assert response.last_editor == 'last_editor_value' - - -@pytest.mark.asyncio -async def test_get_event_threat_detection_custom_module_async_from_dict(): - await test_get_event_threat_detection_custom_module_async(request_type=dict) - - -def test_get_event_threat_detection_custom_module_field_headers(): - client = SecurityCenterManagementClient( - 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 = security_center_management.GetEventThreatDetectionCustomModuleRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_event_threat_detection_custom_module), - '__call__') as call: - call.return_value = security_center_management.EventThreatDetectionCustomModule() - client.get_event_threat_detection_custom_module(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_event_threat_detection_custom_module_field_headers_async(): - client = SecurityCenterManagementAsyncClient( - 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 = security_center_management.GetEventThreatDetectionCustomModuleRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_event_threat_detection_custom_module), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.EventThreatDetectionCustomModule()) - await client.get_event_threat_detection_custom_module(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_event_threat_detection_custom_module_flattened(): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_event_threat_detection_custom_module), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = security_center_management.EventThreatDetectionCustomModule() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.get_event_threat_detection_custom_module( - 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_event_threat_detection_custom_module_flattened_error(): - client = SecurityCenterManagementClient( - 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_event_threat_detection_custom_module( - security_center_management.GetEventThreatDetectionCustomModuleRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_get_event_threat_detection_custom_module_flattened_async(): - client = SecurityCenterManagementAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.get_event_threat_detection_custom_module), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = security_center_management.EventThreatDetectionCustomModule() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.EventThreatDetectionCustomModule()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.get_event_threat_detection_custom_module( - 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_event_threat_detection_custom_module_flattened_error_async(): - client = SecurityCenterManagementAsyncClient( - 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_event_threat_detection_custom_module( - security_center_management.GetEventThreatDetectionCustomModuleRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - security_center_management.CreateEventThreatDetectionCustomModuleRequest, - dict, -]) -def test_create_event_threat_detection_custom_module(request_type, transport: str = 'grpc'): - client = SecurityCenterManagementClient( - 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_event_threat_detection_custom_module), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = security_center_management.EventThreatDetectionCustomModule( - name='name_value', - ancestor_module='ancestor_module_value', - enablement_state=security_center_management.EventThreatDetectionCustomModule.EnablementState.ENABLED, - type_='type__value', - display_name='display_name_value', - description='description_value', - last_editor='last_editor_value', - ) - response = client.create_event_threat_detection_custom_module(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == security_center_management.CreateEventThreatDetectionCustomModuleRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, security_center_management.EventThreatDetectionCustomModule) - assert response.name == 'name_value' - assert response.ancestor_module == 'ancestor_module_value' - assert response.enablement_state == security_center_management.EventThreatDetectionCustomModule.EnablementState.ENABLED - assert response.type_ == 'type__value' - assert response.display_name == 'display_name_value' - assert response.description == 'description_value' - assert response.last_editor == 'last_editor_value' - - -def test_create_event_threat_detection_custom_module_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 = SecurityCenterManagementClient( - 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_event_threat_detection_custom_module), - '__call__') as call: - client.create_event_threat_detection_custom_module() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == security_center_management.CreateEventThreatDetectionCustomModuleRequest() - -@pytest.mark.asyncio -async def test_create_event_threat_detection_custom_module_async(transport: str = 'grpc_asyncio', request_type=security_center_management.CreateEventThreatDetectionCustomModuleRequest): - client = SecurityCenterManagementAsyncClient( - 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_event_threat_detection_custom_module), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.EventThreatDetectionCustomModule( - name='name_value', - ancestor_module='ancestor_module_value', - enablement_state=security_center_management.EventThreatDetectionCustomModule.EnablementState.ENABLED, - type_='type__value', - display_name='display_name_value', - description='description_value', - last_editor='last_editor_value', - )) - response = await client.create_event_threat_detection_custom_module(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == security_center_management.CreateEventThreatDetectionCustomModuleRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, security_center_management.EventThreatDetectionCustomModule) - assert response.name == 'name_value' - assert response.ancestor_module == 'ancestor_module_value' - assert response.enablement_state == security_center_management.EventThreatDetectionCustomModule.EnablementState.ENABLED - assert response.type_ == 'type__value' - assert response.display_name == 'display_name_value' - assert response.description == 'description_value' - assert response.last_editor == 'last_editor_value' - - -@pytest.mark.asyncio -async def test_create_event_threat_detection_custom_module_async_from_dict(): - await test_create_event_threat_detection_custom_module_async(request_type=dict) - - -def test_create_event_threat_detection_custom_module_field_headers(): - client = SecurityCenterManagementClient( - 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 = security_center_management.CreateEventThreatDetectionCustomModuleRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_event_threat_detection_custom_module), - '__call__') as call: - call.return_value = security_center_management.EventThreatDetectionCustomModule() - client.create_event_threat_detection_custom_module(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_event_threat_detection_custom_module_field_headers_async(): - client = SecurityCenterManagementAsyncClient( - 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 = security_center_management.CreateEventThreatDetectionCustomModuleRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_event_threat_detection_custom_module), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.EventThreatDetectionCustomModule()) - await client.create_event_threat_detection_custom_module(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_event_threat_detection_custom_module_flattened(): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_event_threat_detection_custom_module), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = security_center_management.EventThreatDetectionCustomModule() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.create_event_threat_detection_custom_module( - parent='parent_value', - event_threat_detection_custom_module=security_center_management.EventThreatDetectionCustomModule(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].event_threat_detection_custom_module - mock_val = security_center_management.EventThreatDetectionCustomModule(name='name_value') - assert arg == mock_val - - -def test_create_event_threat_detection_custom_module_flattened_error(): - client = SecurityCenterManagementClient( - 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_event_threat_detection_custom_module( - security_center_management.CreateEventThreatDetectionCustomModuleRequest(), - parent='parent_value', - event_threat_detection_custom_module=security_center_management.EventThreatDetectionCustomModule(name='name_value'), - ) - -@pytest.mark.asyncio -async def test_create_event_threat_detection_custom_module_flattened_async(): - client = SecurityCenterManagementAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.create_event_threat_detection_custom_module), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = security_center_management.EventThreatDetectionCustomModule() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.EventThreatDetectionCustomModule()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.create_event_threat_detection_custom_module( - parent='parent_value', - event_threat_detection_custom_module=security_center_management.EventThreatDetectionCustomModule(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].event_threat_detection_custom_module - mock_val = security_center_management.EventThreatDetectionCustomModule(name='name_value') - assert arg == mock_val - -@pytest.mark.asyncio -async def test_create_event_threat_detection_custom_module_flattened_error_async(): - client = SecurityCenterManagementAsyncClient( - 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_event_threat_detection_custom_module( - security_center_management.CreateEventThreatDetectionCustomModuleRequest(), - parent='parent_value', - event_threat_detection_custom_module=security_center_management.EventThreatDetectionCustomModule(name='name_value'), - ) - - -@pytest.mark.parametrize("request_type", [ - security_center_management.UpdateEventThreatDetectionCustomModuleRequest, - dict, -]) -def test_update_event_threat_detection_custom_module(request_type, transport: str = 'grpc'): - client = SecurityCenterManagementClient( - 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_event_threat_detection_custom_module), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = security_center_management.EventThreatDetectionCustomModule( - name='name_value', - ancestor_module='ancestor_module_value', - enablement_state=security_center_management.EventThreatDetectionCustomModule.EnablementState.ENABLED, - type_='type__value', - display_name='display_name_value', - description='description_value', - last_editor='last_editor_value', - ) - response = client.update_event_threat_detection_custom_module(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == security_center_management.UpdateEventThreatDetectionCustomModuleRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, security_center_management.EventThreatDetectionCustomModule) - assert response.name == 'name_value' - assert response.ancestor_module == 'ancestor_module_value' - assert response.enablement_state == security_center_management.EventThreatDetectionCustomModule.EnablementState.ENABLED - assert response.type_ == 'type__value' - assert response.display_name == 'display_name_value' - assert response.description == 'description_value' - assert response.last_editor == 'last_editor_value' - - -def test_update_event_threat_detection_custom_module_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 = SecurityCenterManagementClient( - 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_event_threat_detection_custom_module), - '__call__') as call: - client.update_event_threat_detection_custom_module() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == security_center_management.UpdateEventThreatDetectionCustomModuleRequest() - -@pytest.mark.asyncio -async def test_update_event_threat_detection_custom_module_async(transport: str = 'grpc_asyncio', request_type=security_center_management.UpdateEventThreatDetectionCustomModuleRequest): - client = SecurityCenterManagementAsyncClient( - 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_event_threat_detection_custom_module), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.EventThreatDetectionCustomModule( - name='name_value', - ancestor_module='ancestor_module_value', - enablement_state=security_center_management.EventThreatDetectionCustomModule.EnablementState.ENABLED, - type_='type__value', - display_name='display_name_value', - description='description_value', - last_editor='last_editor_value', - )) - response = await client.update_event_threat_detection_custom_module(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == security_center_management.UpdateEventThreatDetectionCustomModuleRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, security_center_management.EventThreatDetectionCustomModule) - assert response.name == 'name_value' - assert response.ancestor_module == 'ancestor_module_value' - assert response.enablement_state == security_center_management.EventThreatDetectionCustomModule.EnablementState.ENABLED - assert response.type_ == 'type__value' - assert response.display_name == 'display_name_value' - assert response.description == 'description_value' - assert response.last_editor == 'last_editor_value' - - -@pytest.mark.asyncio -async def test_update_event_threat_detection_custom_module_async_from_dict(): - await test_update_event_threat_detection_custom_module_async(request_type=dict) - - -def test_update_event_threat_detection_custom_module_field_headers(): - client = SecurityCenterManagementClient( - 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 = security_center_management.UpdateEventThreatDetectionCustomModuleRequest() - - request.event_threat_detection_custom_module.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_event_threat_detection_custom_module), - '__call__') as call: - call.return_value = security_center_management.EventThreatDetectionCustomModule() - client.update_event_threat_detection_custom_module(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', - 'event_threat_detection_custom_module.name=name_value', - ) in kw['metadata'] - - -@pytest.mark.asyncio -async def test_update_event_threat_detection_custom_module_field_headers_async(): - client = SecurityCenterManagementAsyncClient( - 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 = security_center_management.UpdateEventThreatDetectionCustomModuleRequest() - - request.event_threat_detection_custom_module.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_event_threat_detection_custom_module), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.EventThreatDetectionCustomModule()) - await client.update_event_threat_detection_custom_module(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', - 'event_threat_detection_custom_module.name=name_value', - ) in kw['metadata'] - - -def test_update_event_threat_detection_custom_module_flattened(): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_event_threat_detection_custom_module), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = security_center_management.EventThreatDetectionCustomModule() - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.update_event_threat_detection_custom_module( - event_threat_detection_custom_module=security_center_management.EventThreatDetectionCustomModule(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].event_threat_detection_custom_module - mock_val = security_center_management.EventThreatDetectionCustomModule(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_event_threat_detection_custom_module_flattened_error(): - client = SecurityCenterManagementClient( - 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_event_threat_detection_custom_module( - security_center_management.UpdateEventThreatDetectionCustomModuleRequest(), - event_threat_detection_custom_module=security_center_management.EventThreatDetectionCustomModule(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - -@pytest.mark.asyncio -async def test_update_event_threat_detection_custom_module_flattened_async(): - client = SecurityCenterManagementAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.update_event_threat_detection_custom_module), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = security_center_management.EventThreatDetectionCustomModule() - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.EventThreatDetectionCustomModule()) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.update_event_threat_detection_custom_module( - event_threat_detection_custom_module=security_center_management.EventThreatDetectionCustomModule(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].event_threat_detection_custom_module - mock_val = security_center_management.EventThreatDetectionCustomModule(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_event_threat_detection_custom_module_flattened_error_async(): - client = SecurityCenterManagementAsyncClient( - 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_event_threat_detection_custom_module( - security_center_management.UpdateEventThreatDetectionCustomModuleRequest(), - event_threat_detection_custom_module=security_center_management.EventThreatDetectionCustomModule(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -@pytest.mark.parametrize("request_type", [ - security_center_management.DeleteEventThreatDetectionCustomModuleRequest, - dict, -]) -def test_delete_event_threat_detection_custom_module(request_type, transport: str = 'grpc'): - client = SecurityCenterManagementClient( - 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_event_threat_detection_custom_module), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = None - response = client.delete_event_threat_detection_custom_module(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == security_center_management.DeleteEventThreatDetectionCustomModuleRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -def test_delete_event_threat_detection_custom_module_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 = SecurityCenterManagementClient( - 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_event_threat_detection_custom_module), - '__call__') as call: - client.delete_event_threat_detection_custom_module() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == security_center_management.DeleteEventThreatDetectionCustomModuleRequest() - -@pytest.mark.asyncio -async def test_delete_event_threat_detection_custom_module_async(transport: str = 'grpc_asyncio', request_type=security_center_management.DeleteEventThreatDetectionCustomModuleRequest): - client = SecurityCenterManagementAsyncClient( - 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_event_threat_detection_custom_module), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - response = await client.delete_event_threat_detection_custom_module(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == security_center_management.DeleteEventThreatDetectionCustomModuleRequest() - - # Establish that the response is the type that we expect. - assert response is None - - -@pytest.mark.asyncio -async def test_delete_event_threat_detection_custom_module_async_from_dict(): - await test_delete_event_threat_detection_custom_module_async(request_type=dict) - - -def test_delete_event_threat_detection_custom_module_field_headers(): - client = SecurityCenterManagementClient( - 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 = security_center_management.DeleteEventThreatDetectionCustomModuleRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_event_threat_detection_custom_module), - '__call__') as call: - call.return_value = None - client.delete_event_threat_detection_custom_module(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_event_threat_detection_custom_module_field_headers_async(): - client = SecurityCenterManagementAsyncClient( - 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 = security_center_management.DeleteEventThreatDetectionCustomModuleRequest() - - request.name = 'name_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_event_threat_detection_custom_module), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - await client.delete_event_threat_detection_custom_module(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_event_threat_detection_custom_module_flattened(): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_event_threat_detection_custom_module), - '__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_event_threat_detection_custom_module( - 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_event_threat_detection_custom_module_flattened_error(): - client = SecurityCenterManagementClient( - 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_event_threat_detection_custom_module( - security_center_management.DeleteEventThreatDetectionCustomModuleRequest(), - name='name_value', - ) - -@pytest.mark.asyncio -async def test_delete_event_threat_detection_custom_module_flattened_async(): - client = SecurityCenterManagementAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.delete_event_threat_detection_custom_module), - '__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_event_threat_detection_custom_module( - 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_event_threat_detection_custom_module_flattened_error_async(): - client = SecurityCenterManagementAsyncClient( - 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_event_threat_detection_custom_module( - security_center_management.DeleteEventThreatDetectionCustomModuleRequest(), - name='name_value', - ) - - -@pytest.mark.parametrize("request_type", [ - security_center_management.ValidateEventThreatDetectionCustomModuleRequest, - dict, -]) -def test_validate_event_threat_detection_custom_module(request_type, transport: str = 'grpc'): - client = SecurityCenterManagementClient( - 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.validate_event_threat_detection_custom_module), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value = security_center_management.ValidateEventThreatDetectionCustomModuleResponse( - ) - response = client.validate_event_threat_detection_custom_module(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == security_center_management.ValidateEventThreatDetectionCustomModuleRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, security_center_management.ValidateEventThreatDetectionCustomModuleResponse) - - -def test_validate_event_threat_detection_custom_module_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 = SecurityCenterManagementClient( - 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.validate_event_threat_detection_custom_module), - '__call__') as call: - client.validate_event_threat_detection_custom_module() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == security_center_management.ValidateEventThreatDetectionCustomModuleRequest() - -@pytest.mark.asyncio -async def test_validate_event_threat_detection_custom_module_async(transport: str = 'grpc_asyncio', request_type=security_center_management.ValidateEventThreatDetectionCustomModuleRequest): - client = SecurityCenterManagementAsyncClient( - 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.validate_event_threat_detection_custom_module), - '__call__') as call: - # Designate an appropriate return value for the call. - call.return_value =grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.ValidateEventThreatDetectionCustomModuleResponse( - )) - response = await client.validate_event_threat_detection_custom_module(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == security_center_management.ValidateEventThreatDetectionCustomModuleRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, security_center_management.ValidateEventThreatDetectionCustomModuleResponse) - - -@pytest.mark.asyncio -async def test_validate_event_threat_detection_custom_module_async_from_dict(): - await test_validate_event_threat_detection_custom_module_async(request_type=dict) - - -def test_validate_event_threat_detection_custom_module_field_headers(): - client = SecurityCenterManagementClient( - 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 = security_center_management.ValidateEventThreatDetectionCustomModuleRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.validate_event_threat_detection_custom_module), - '__call__') as call: - call.return_value = security_center_management.ValidateEventThreatDetectionCustomModuleResponse() - client.validate_event_threat_detection_custom_module(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_validate_event_threat_detection_custom_module_field_headers_async(): - client = SecurityCenterManagementAsyncClient( - 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 = security_center_management.ValidateEventThreatDetectionCustomModuleRequest() - - request.parent = 'parent_value' - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.validate_event_threat_detection_custom_module), - '__call__') as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(security_center_management.ValidateEventThreatDetectionCustomModuleResponse()) - await client.validate_event_threat_detection_custom_module(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'] - - -@pytest.mark.parametrize("request_type", [ - security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest, - dict, -]) -def test_list_effective_security_health_analytics_custom_modules_rest(request_type): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse( - next_page_token='next_page_token_value', - ) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.list_effective_security_health_analytics_custom_modules(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListEffectiveSecurityHealthAnalyticsCustomModulesPager) - assert response.next_page_token == 'next_page_token_value' - - -def test_list_effective_security_health_analytics_custom_modules_rest_required_fields(request_type=security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest): - transport_class = transports.SecurityCenterManagementRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_effective_security_health_analytics_custom_modules._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = 'parent_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_effective_security_health_analytics_custom_modules._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("page_size", "page_token", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.list_effective_security_health_analytics_custom_modules(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_list_effective_security_health_analytics_custom_modules_rest_unset_required_fields(): - transport = transports.SecurityCenterManagementRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.list_effective_security_health_analytics_custom_modules._get_unset_required_fields({}) - assert set(unset_fields) == (set(("pageSize", "pageToken", )) & set(("parent", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_effective_security_health_analytics_custom_modules_rest_interceptors(null_interceptor): - transport = transports.SecurityCenterManagementRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.SecurityCenterManagementRestInterceptor(), - ) - client = SecurityCenterManagementClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "post_list_effective_security_health_analytics_custom_modules") as post, \ - mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "pre_list_effective_security_health_analytics_custom_modules") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest.pb(security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse.to_json(security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse()) - - request = security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse() - - client.list_effective_security_health_analytics_custom_modules(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_list_effective_security_health_analytics_custom_modules_rest_bad_request(transport: str = 'rest', request_type=security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.list_effective_security_health_analytics_custom_modules(request) - - -def test_list_effective_security_health_analytics_custom_modules_rest_flattened(): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.list_effective_security_health_analytics_custom_modules(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/effectiveSecurityHealthAnalyticsCustomModules" % client.transport._host, args[1]) - - -def test_list_effective_security_health_analytics_custom_modules_rest_flattened_error(transport: str = 'rest'): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_effective_security_health_analytics_custom_modules( - security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesRequest(), - parent='parent_value', - ) - - -def test_list_effective_security_health_analytics_custom_modules_rest_pager(transport: str = 'rest'): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - #with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse( - effective_security_health_analytics_custom_modules=[ - security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), - security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), - security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), - ], - next_page_token='abc', - ), - security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse( - effective_security_health_analytics_custom_modules=[], - next_page_token='def', - ), - security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse( - effective_security_health_analytics_custom_modules=[ - security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), - ], - next_page_token='ghi', - ), - security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse( - effective_security_health_analytics_custom_modules=[ - security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), - security_center_management.EffectiveSecurityHealthAnalyticsCustomModule(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple(security_center_management.ListEffectiveSecurityHealthAnalyticsCustomModulesResponse.to_json(x) for x in response) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode('UTF-8') - return_val.status_code = 200 - req.side_effect = return_values - - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - pager = client.list_effective_security_health_analytics_custom_modules(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, security_center_management.EffectiveSecurityHealthAnalyticsCustomModule) - for i in results) - - pages = list(client.list_effective_security_health_analytics_custom_modules(request=sample_request).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - - -@pytest.mark.parametrize("request_type", [ - security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest, - dict, -]) -def test_get_effective_security_health_analytics_custom_module_rest(request_type): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/effectiveSecurityHealthAnalyticsCustomModules/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = security_center_management.EffectiveSecurityHealthAnalyticsCustomModule( - name='name_value', - enablement_state=security_center_management.EffectiveSecurityHealthAnalyticsCustomModule.EnablementState.ENABLED, - display_name='display_name_value', - ) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = security_center_management.EffectiveSecurityHealthAnalyticsCustomModule.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.get_effective_security_health_analytics_custom_module(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, security_center_management.EffectiveSecurityHealthAnalyticsCustomModule) - assert response.name == 'name_value' - assert response.enablement_state == security_center_management.EffectiveSecurityHealthAnalyticsCustomModule.EnablementState.ENABLED - assert response.display_name == 'display_name_value' - - -def test_get_effective_security_health_analytics_custom_module_rest_required_fields(request_type=security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest): - transport_class = transports.SecurityCenterManagementRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_effective_security_health_analytics_custom_module._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_effective_security_health_analytics_custom_module._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = security_center_management.EffectiveSecurityHealthAnalyticsCustomModule() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = security_center_management.EffectiveSecurityHealthAnalyticsCustomModule.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.get_effective_security_health_analytics_custom_module(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_get_effective_security_health_analytics_custom_module_rest_unset_required_fields(): - transport = transports.SecurityCenterManagementRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.get_effective_security_health_analytics_custom_module._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_effective_security_health_analytics_custom_module_rest_interceptors(null_interceptor): - transport = transports.SecurityCenterManagementRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.SecurityCenterManagementRestInterceptor(), - ) - client = SecurityCenterManagementClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "post_get_effective_security_health_analytics_custom_module") as post, \ - mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "pre_get_effective_security_health_analytics_custom_module") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest.pb(security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = security_center_management.EffectiveSecurityHealthAnalyticsCustomModule.to_json(security_center_management.EffectiveSecurityHealthAnalyticsCustomModule()) - - request = security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = security_center_management.EffectiveSecurityHealthAnalyticsCustomModule() - - client.get_effective_security_health_analytics_custom_module(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_get_effective_security_health_analytics_custom_module_rest_bad_request(transport: str = 'rest', request_type=security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/effectiveSecurityHealthAnalyticsCustomModules/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.get_effective_security_health_analytics_custom_module(request) - - -def test_get_effective_security_health_analytics_custom_module_rest_flattened(): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = security_center_management.EffectiveSecurityHealthAnalyticsCustomModule() - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/effectiveSecurityHealthAnalyticsCustomModules/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = security_center_management.EffectiveSecurityHealthAnalyticsCustomModule.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.get_effective_security_health_analytics_custom_module(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/effectiveSecurityHealthAnalyticsCustomModules/*}" % client.transport._host, args[1]) - - -def test_get_effective_security_health_analytics_custom_module_rest_flattened_error(transport: str = 'rest'): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_effective_security_health_analytics_custom_module( - security_center_management.GetEffectiveSecurityHealthAnalyticsCustomModuleRequest(), - name='name_value', - ) - - -def test_get_effective_security_health_analytics_custom_module_rest_error(): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest, - dict, -]) -def test_list_security_health_analytics_custom_modules_rest(request_type): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse( - next_page_token='next_page_token_value', - ) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.list_security_health_analytics_custom_modules(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListSecurityHealthAnalyticsCustomModulesPager) - assert response.next_page_token == 'next_page_token_value' - - -def test_list_security_health_analytics_custom_modules_rest_required_fields(request_type=security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest): - transport_class = transports.SecurityCenterManagementRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_security_health_analytics_custom_modules._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = 'parent_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_security_health_analytics_custom_modules._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("page_size", "page_token", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.list_security_health_analytics_custom_modules(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_list_security_health_analytics_custom_modules_rest_unset_required_fields(): - transport = transports.SecurityCenterManagementRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.list_security_health_analytics_custom_modules._get_unset_required_fields({}) - assert set(unset_fields) == (set(("pageSize", "pageToken", )) & set(("parent", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_security_health_analytics_custom_modules_rest_interceptors(null_interceptor): - transport = transports.SecurityCenterManagementRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.SecurityCenterManagementRestInterceptor(), - ) - client = SecurityCenterManagementClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "post_list_security_health_analytics_custom_modules") as post, \ - mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "pre_list_security_health_analytics_custom_modules") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest.pb(security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse.to_json(security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse()) - - request = security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse() - - client.list_security_health_analytics_custom_modules(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_list_security_health_analytics_custom_modules_rest_bad_request(transport: str = 'rest', request_type=security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.list_security_health_analytics_custom_modules(request) - - -def test_list_security_health_analytics_custom_modules_rest_flattened(): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.list_security_health_analytics_custom_modules(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/securityHealthAnalyticsCustomModules" % client.transport._host, args[1]) - - -def test_list_security_health_analytics_custom_modules_rest_flattened_error(transport: str = 'rest'): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_security_health_analytics_custom_modules( - security_center_management.ListSecurityHealthAnalyticsCustomModulesRequest(), - parent='parent_value', - ) - - -def test_list_security_health_analytics_custom_modules_rest_pager(transport: str = 'rest'): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - #with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse( - security_health_analytics_custom_modules=[ - security_center_management.SecurityHealthAnalyticsCustomModule(), - security_center_management.SecurityHealthAnalyticsCustomModule(), - security_center_management.SecurityHealthAnalyticsCustomModule(), - ], - next_page_token='abc', - ), - security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse( - security_health_analytics_custom_modules=[], - next_page_token='def', - ), - security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse( - security_health_analytics_custom_modules=[ - security_center_management.SecurityHealthAnalyticsCustomModule(), - ], - next_page_token='ghi', - ), - security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse( - security_health_analytics_custom_modules=[ - security_center_management.SecurityHealthAnalyticsCustomModule(), - security_center_management.SecurityHealthAnalyticsCustomModule(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple(security_center_management.ListSecurityHealthAnalyticsCustomModulesResponse.to_json(x) for x in response) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode('UTF-8') - return_val.status_code = 200 - req.side_effect = return_values - - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - pager = client.list_security_health_analytics_custom_modules(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, security_center_management.SecurityHealthAnalyticsCustomModule) - for i in results) - - pages = list(client.list_security_health_analytics_custom_modules(request=sample_request).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - - -@pytest.mark.parametrize("request_type", [ - security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest, - dict, -]) -def test_list_descendant_security_health_analytics_custom_modules_rest(request_type): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse( - next_page_token='next_page_token_value', - ) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.list_descendant_security_health_analytics_custom_modules(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListDescendantSecurityHealthAnalyticsCustomModulesPager) - assert response.next_page_token == 'next_page_token_value' - - -def test_list_descendant_security_health_analytics_custom_modules_rest_required_fields(request_type=security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest): - transport_class = transports.SecurityCenterManagementRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_descendant_security_health_analytics_custom_modules._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = 'parent_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_descendant_security_health_analytics_custom_modules._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("page_size", "page_token", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.list_descendant_security_health_analytics_custom_modules(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_list_descendant_security_health_analytics_custom_modules_rest_unset_required_fields(): - transport = transports.SecurityCenterManagementRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.list_descendant_security_health_analytics_custom_modules._get_unset_required_fields({}) - assert set(unset_fields) == (set(("pageSize", "pageToken", )) & set(("parent", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_descendant_security_health_analytics_custom_modules_rest_interceptors(null_interceptor): - transport = transports.SecurityCenterManagementRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.SecurityCenterManagementRestInterceptor(), - ) - client = SecurityCenterManagementClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "post_list_descendant_security_health_analytics_custom_modules") as post, \ - mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "pre_list_descendant_security_health_analytics_custom_modules") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest.pb(security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse.to_json(security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse()) - - request = security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse() - - client.list_descendant_security_health_analytics_custom_modules(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_list_descendant_security_health_analytics_custom_modules_rest_bad_request(transport: str = 'rest', request_type=security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.list_descendant_security_health_analytics_custom_modules(request) - - -def test_list_descendant_security_health_analytics_custom_modules_rest_flattened(): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.list_descendant_security_health_analytics_custom_modules(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/securityHealthAnalyticsCustomModules:listDescendant" % client.transport._host, args[1]) - - -def test_list_descendant_security_health_analytics_custom_modules_rest_flattened_error(transport: str = 'rest'): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_descendant_security_health_analytics_custom_modules( - security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesRequest(), - parent='parent_value', - ) - - -def test_list_descendant_security_health_analytics_custom_modules_rest_pager(transport: str = 'rest'): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - #with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse( - security_health_analytics_custom_modules=[ - security_center_management.SecurityHealthAnalyticsCustomModule(), - security_center_management.SecurityHealthAnalyticsCustomModule(), - security_center_management.SecurityHealthAnalyticsCustomModule(), - ], - next_page_token='abc', - ), - security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse( - security_health_analytics_custom_modules=[], - next_page_token='def', - ), - security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse( - security_health_analytics_custom_modules=[ - security_center_management.SecurityHealthAnalyticsCustomModule(), - ], - next_page_token='ghi', - ), - security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse( - security_health_analytics_custom_modules=[ - security_center_management.SecurityHealthAnalyticsCustomModule(), - security_center_management.SecurityHealthAnalyticsCustomModule(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple(security_center_management.ListDescendantSecurityHealthAnalyticsCustomModulesResponse.to_json(x) for x in response) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode('UTF-8') - return_val.status_code = 200 - req.side_effect = return_values - - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - pager = client.list_descendant_security_health_analytics_custom_modules(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, security_center_management.SecurityHealthAnalyticsCustomModule) - for i in results) - - pages = list(client.list_descendant_security_health_analytics_custom_modules(request=sample_request).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - - -@pytest.mark.parametrize("request_type", [ - security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest, - dict, -]) -def test_get_security_health_analytics_custom_module_rest(request_type): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/securityHealthAnalyticsCustomModules/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = security_center_management.SecurityHealthAnalyticsCustomModule( - name='name_value', - display_name='display_name_value', - enablement_state=security_center_management.SecurityHealthAnalyticsCustomModule.EnablementState.ENABLED, - last_editor='last_editor_value', - ancestor_module='ancestor_module_value', - ) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = security_center_management.SecurityHealthAnalyticsCustomModule.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.get_security_health_analytics_custom_module(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, security_center_management.SecurityHealthAnalyticsCustomModule) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - assert response.enablement_state == security_center_management.SecurityHealthAnalyticsCustomModule.EnablementState.ENABLED - assert response.last_editor == 'last_editor_value' - assert response.ancestor_module == 'ancestor_module_value' - - -def test_get_security_health_analytics_custom_module_rest_required_fields(request_type=security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest): - transport_class = transports.SecurityCenterManagementRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_security_health_analytics_custom_module._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_security_health_analytics_custom_module._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = security_center_management.SecurityHealthAnalyticsCustomModule() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = security_center_management.SecurityHealthAnalyticsCustomModule.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.get_security_health_analytics_custom_module(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_get_security_health_analytics_custom_module_rest_unset_required_fields(): - transport = transports.SecurityCenterManagementRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.get_security_health_analytics_custom_module._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_security_health_analytics_custom_module_rest_interceptors(null_interceptor): - transport = transports.SecurityCenterManagementRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.SecurityCenterManagementRestInterceptor(), - ) - client = SecurityCenterManagementClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "post_get_security_health_analytics_custom_module") as post, \ - mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "pre_get_security_health_analytics_custom_module") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest.pb(security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = security_center_management.SecurityHealthAnalyticsCustomModule.to_json(security_center_management.SecurityHealthAnalyticsCustomModule()) - - request = security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = security_center_management.SecurityHealthAnalyticsCustomModule() - - client.get_security_health_analytics_custom_module(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_get_security_health_analytics_custom_module_rest_bad_request(transport: str = 'rest', request_type=security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/securityHealthAnalyticsCustomModules/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.get_security_health_analytics_custom_module(request) - - -def test_get_security_health_analytics_custom_module_rest_flattened(): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = security_center_management.SecurityHealthAnalyticsCustomModule() - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/securityHealthAnalyticsCustomModules/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = security_center_management.SecurityHealthAnalyticsCustomModule.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.get_security_health_analytics_custom_module(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/securityHealthAnalyticsCustomModules/*}" % client.transport._host, args[1]) - - -def test_get_security_health_analytics_custom_module_rest_flattened_error(transport: str = 'rest'): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_security_health_analytics_custom_module( - security_center_management.GetSecurityHealthAnalyticsCustomModuleRequest(), - name='name_value', - ) - - -def test_get_security_health_analytics_custom_module_rest_error(): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest, - dict, -]) -def test_create_security_health_analytics_custom_module_rest(request_type): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request_init["security_health_analytics_custom_module"] = {'name': 'name_value', 'display_name': 'display_name_value', 'enablement_state': 1, 'update_time': {'seconds': 751, 'nanos': 543}, 'last_editor': 'last_editor_value', 'ancestor_module': 'ancestor_module_value', 'custom_config': {'predicate': {'expression': 'expression_value', 'title': 'title_value', 'description': 'description_value', 'location': 'location_value'}, 'custom_output': {'properties': [{'name': 'name_value', 'value_expression': {}}]}, 'resource_selector': {'resource_types': ['resource_types_value1', 'resource_types_value2']}, 'severity': 1, 'description': 'description_value', 'recommendation': 'recommendation_value'}} - # The version of a generated dependency at test runtime may differ from the version used during generation. - # Delete any fields which are not present in the current runtime dependency - # See https://github.com/googleapis/gapic-generator-python/issues/1748 - - # Determine if the message type is proto-plus or protobuf - test_field = security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest.meta.fields["security_health_analytics_custom_module"] - - def get_message_fields(field): - # Given a field which is a message (composite type), return a list with - # all the fields of the message. - # If the field is not a composite type, return an empty list. - message_fields = [] - - if hasattr(field, "message") and field.message: - is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") - - if is_field_type_proto_plus_type: - message_fields = field.message.meta.fields.values() - # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types - else: # pragma: NO COVER - message_fields = field.message.DESCRIPTOR.fields - return message_fields - - runtime_nested_fields = [ - (field.name, nested_field.name) - for field in get_message_fields(test_field) - for nested_field in get_message_fields(field) - ] - - subfields_not_in_runtime = [] - - # For each item in the sample request, create a list of sub fields which are not present at runtime - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["security_health_analytics_custom_module"].items(): # pragma: NO COVER - result = None - is_repeated = False - # For repeated fields - if isinstance(value, list) and len(value): - is_repeated = True - result = value[0] - # For fields where the type is another message - if isinstance(value, dict): - result = value - - if result and hasattr(result, "keys"): - for subfield in result.keys(): - if (field, subfield) not in runtime_nested_fields: - subfields_not_in_runtime.append( - {"field": field, "subfield": subfield, "is_repeated": is_repeated} - ) - - # Remove fields from the sample request which are not present in the runtime version of the dependency - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER - field = subfield_to_delete.get("field") - field_repeated = subfield_to_delete.get("is_repeated") - subfield = subfield_to_delete.get("subfield") - if subfield: - if field_repeated: - for i in range(0, len(request_init["security_health_analytics_custom_module"][field])): - del request_init["security_health_analytics_custom_module"][field][i][subfield] - else: - del request_init["security_health_analytics_custom_module"][field][subfield] - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = security_center_management.SecurityHealthAnalyticsCustomModule( - name='name_value', - display_name='display_name_value', - enablement_state=security_center_management.SecurityHealthAnalyticsCustomModule.EnablementState.ENABLED, - last_editor='last_editor_value', - ancestor_module='ancestor_module_value', - ) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = security_center_management.SecurityHealthAnalyticsCustomModule.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.create_security_health_analytics_custom_module(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, security_center_management.SecurityHealthAnalyticsCustomModule) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - assert response.enablement_state == security_center_management.SecurityHealthAnalyticsCustomModule.EnablementState.ENABLED - assert response.last_editor == 'last_editor_value' - assert response.ancestor_module == 'ancestor_module_value' - - -def test_create_security_health_analytics_custom_module_rest_required_fields(request_type=security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest): - transport_class = transports.SecurityCenterManagementRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_security_health_analytics_custom_module._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = 'parent_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_security_health_analytics_custom_module._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("validate_only", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = security_center_management.SecurityHealthAnalyticsCustomModule() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "post", - 'query_params': pb_request, - } - transcode_result['body'] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = security_center_management.SecurityHealthAnalyticsCustomModule.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.create_security_health_analytics_custom_module(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_create_security_health_analytics_custom_module_rest_unset_required_fields(): - transport = transports.SecurityCenterManagementRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.create_security_health_analytics_custom_module._get_unset_required_fields({}) - assert set(unset_fields) == (set(("validateOnly", )) & set(("parent", "securityHealthAnalyticsCustomModule", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_create_security_health_analytics_custom_module_rest_interceptors(null_interceptor): - transport = transports.SecurityCenterManagementRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.SecurityCenterManagementRestInterceptor(), - ) - client = SecurityCenterManagementClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "post_create_security_health_analytics_custom_module") as post, \ - mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "pre_create_security_health_analytics_custom_module") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest.pb(security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = security_center_management.SecurityHealthAnalyticsCustomModule.to_json(security_center_management.SecurityHealthAnalyticsCustomModule()) - - request = security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = security_center_management.SecurityHealthAnalyticsCustomModule() - - client.create_security_health_analytics_custom_module(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_create_security_health_analytics_custom_module_rest_bad_request(transport: str = 'rest', request_type=security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.create_security_health_analytics_custom_module(request) - - -def test_create_security_health_analytics_custom_module_rest_flattened(): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = security_center_management.SecurityHealthAnalyticsCustomModule() - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - security_health_analytics_custom_module=security_center_management.SecurityHealthAnalyticsCustomModule(name='name_value'), - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = security_center_management.SecurityHealthAnalyticsCustomModule.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.create_security_health_analytics_custom_module(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/securityHealthAnalyticsCustomModules" % client.transport._host, args[1]) - - -def test_create_security_health_analytics_custom_module_rest_flattened_error(transport: str = 'rest'): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_security_health_analytics_custom_module( - security_center_management.CreateSecurityHealthAnalyticsCustomModuleRequest(), - parent='parent_value', - security_health_analytics_custom_module=security_center_management.SecurityHealthAnalyticsCustomModule(name='name_value'), - ) - - -def test_create_security_health_analytics_custom_module_rest_error(): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest, - dict, -]) -def test_update_security_health_analytics_custom_module_rest(request_type): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'security_health_analytics_custom_module': {'name': 'projects/sample1/locations/sample2/securityHealthAnalyticsCustomModules/sample3'}} - request_init["security_health_analytics_custom_module"] = {'name': 'projects/sample1/locations/sample2/securityHealthAnalyticsCustomModules/sample3', 'display_name': 'display_name_value', 'enablement_state': 1, 'update_time': {'seconds': 751, 'nanos': 543}, 'last_editor': 'last_editor_value', 'ancestor_module': 'ancestor_module_value', 'custom_config': {'predicate': {'expression': 'expression_value', 'title': 'title_value', 'description': 'description_value', 'location': 'location_value'}, 'custom_output': {'properties': [{'name': 'name_value', 'value_expression': {}}]}, 'resource_selector': {'resource_types': ['resource_types_value1', 'resource_types_value2']}, 'severity': 1, 'description': 'description_value', 'recommendation': 'recommendation_value'}} - # The version of a generated dependency at test runtime may differ from the version used during generation. - # Delete any fields which are not present in the current runtime dependency - # See https://github.com/googleapis/gapic-generator-python/issues/1748 - - # Determine if the message type is proto-plus or protobuf - test_field = security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest.meta.fields["security_health_analytics_custom_module"] - - def get_message_fields(field): - # Given a field which is a message (composite type), return a list with - # all the fields of the message. - # If the field is not a composite type, return an empty list. - message_fields = [] - - if hasattr(field, "message") and field.message: - is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") - - if is_field_type_proto_plus_type: - message_fields = field.message.meta.fields.values() - # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types - else: # pragma: NO COVER - message_fields = field.message.DESCRIPTOR.fields - return message_fields - - runtime_nested_fields = [ - (field.name, nested_field.name) - for field in get_message_fields(test_field) - for nested_field in get_message_fields(field) - ] - - subfields_not_in_runtime = [] - - # For each item in the sample request, create a list of sub fields which are not present at runtime - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["security_health_analytics_custom_module"].items(): # pragma: NO COVER - result = None - is_repeated = False - # For repeated fields - if isinstance(value, list) and len(value): - is_repeated = True - result = value[0] - # For fields where the type is another message - if isinstance(value, dict): - result = value - - if result and hasattr(result, "keys"): - for subfield in result.keys(): - if (field, subfield) not in runtime_nested_fields: - subfields_not_in_runtime.append( - {"field": field, "subfield": subfield, "is_repeated": is_repeated} - ) - - # Remove fields from the sample request which are not present in the runtime version of the dependency - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER - field = subfield_to_delete.get("field") - field_repeated = subfield_to_delete.get("is_repeated") - subfield = subfield_to_delete.get("subfield") - if subfield: - if field_repeated: - for i in range(0, len(request_init["security_health_analytics_custom_module"][field])): - del request_init["security_health_analytics_custom_module"][field][i][subfield] - else: - del request_init["security_health_analytics_custom_module"][field][subfield] - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = security_center_management.SecurityHealthAnalyticsCustomModule( - name='name_value', - display_name='display_name_value', - enablement_state=security_center_management.SecurityHealthAnalyticsCustomModule.EnablementState.ENABLED, - last_editor='last_editor_value', - ancestor_module='ancestor_module_value', - ) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = security_center_management.SecurityHealthAnalyticsCustomModule.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.update_security_health_analytics_custom_module(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, security_center_management.SecurityHealthAnalyticsCustomModule) - assert response.name == 'name_value' - assert response.display_name == 'display_name_value' - assert response.enablement_state == security_center_management.SecurityHealthAnalyticsCustomModule.EnablementState.ENABLED - assert response.last_editor == 'last_editor_value' - assert response.ancestor_module == 'ancestor_module_value' - - -def test_update_security_health_analytics_custom_module_rest_required_fields(request_type=security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest): - transport_class = transports.SecurityCenterManagementRestTransport - - request_init = {} - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_security_health_analytics_custom_module._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_security_health_analytics_custom_module._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("update_mask", "validate_only", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = security_center_management.SecurityHealthAnalyticsCustomModule() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "patch", - 'query_params': pb_request, - } - transcode_result['body'] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = security_center_management.SecurityHealthAnalyticsCustomModule.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.update_security_health_analytics_custom_module(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_update_security_health_analytics_custom_module_rest_unset_required_fields(): - transport = transports.SecurityCenterManagementRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.update_security_health_analytics_custom_module._get_unset_required_fields({}) - assert set(unset_fields) == (set(("updateMask", "validateOnly", )) & set(("updateMask", "securityHealthAnalyticsCustomModule", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_security_health_analytics_custom_module_rest_interceptors(null_interceptor): - transport = transports.SecurityCenterManagementRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.SecurityCenterManagementRestInterceptor(), - ) - client = SecurityCenterManagementClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "post_update_security_health_analytics_custom_module") as post, \ - mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "pre_update_security_health_analytics_custom_module") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest.pb(security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = security_center_management.SecurityHealthAnalyticsCustomModule.to_json(security_center_management.SecurityHealthAnalyticsCustomModule()) - - request = security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = security_center_management.SecurityHealthAnalyticsCustomModule() - - client.update_security_health_analytics_custom_module(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_update_security_health_analytics_custom_module_rest_bad_request(transport: str = 'rest', request_type=security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'security_health_analytics_custom_module': {'name': 'projects/sample1/locations/sample2/securityHealthAnalyticsCustomModules/sample3'}} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.update_security_health_analytics_custom_module(request) - - -def test_update_security_health_analytics_custom_module_rest_flattened(): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = security_center_management.SecurityHealthAnalyticsCustomModule() - - # get arguments that satisfy an http rule for this method - sample_request = {'security_health_analytics_custom_module': {'name': 'projects/sample1/locations/sample2/securityHealthAnalyticsCustomModules/sample3'}} - - # get truthy value for each flattened field - mock_args = dict( - security_health_analytics_custom_module=security_center_management.SecurityHealthAnalyticsCustomModule(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = security_center_management.SecurityHealthAnalyticsCustomModule.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.update_security_health_analytics_custom_module(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{security_health_analytics_custom_module.name=projects/*/locations/*/securityHealthAnalyticsCustomModules/*}" % client.transport._host, args[1]) - - -def test_update_security_health_analytics_custom_module_rest_flattened_error(transport: str = 'rest'): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_security_health_analytics_custom_module( - security_center_management.UpdateSecurityHealthAnalyticsCustomModuleRequest(), - security_health_analytics_custom_module=security_center_management.SecurityHealthAnalyticsCustomModule(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -def test_update_security_health_analytics_custom_module_rest_error(): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest, - dict, -]) -def test_delete_security_health_analytics_custom_module_rest(request_type): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/securityHealthAnalyticsCustomModules/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = None - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = '' - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.delete_security_health_analytics_custom_module(request) - - # Establish that the response is the type that we expect. - assert response is None - - -def test_delete_security_health_analytics_custom_module_rest_required_fields(request_type=security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest): - transport_class = transports.SecurityCenterManagementRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_security_health_analytics_custom_module._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_security_health_analytics_custom_module._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("validate_only", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = None - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "delete", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - json_return_value = '' - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.delete_security_health_analytics_custom_module(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_delete_security_health_analytics_custom_module_rest_unset_required_fields(): - transport = transports.SecurityCenterManagementRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.delete_security_health_analytics_custom_module._get_unset_required_fields({}) - assert set(unset_fields) == (set(("validateOnly", )) & set(("name", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_security_health_analytics_custom_module_rest_interceptors(null_interceptor): - transport = transports.SecurityCenterManagementRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.SecurityCenterManagementRestInterceptor(), - ) - client = SecurityCenterManagementClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "pre_delete_security_health_analytics_custom_module") as pre: - pre.assert_not_called() - pb_message = security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest.pb(security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - - request = security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - - client.delete_security_health_analytics_custom_module(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - - -def test_delete_security_health_analytics_custom_module_rest_bad_request(transport: str = 'rest', request_type=security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/securityHealthAnalyticsCustomModules/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.delete_security_health_analytics_custom_module(request) - - -def test_delete_security_health_analytics_custom_module_rest_flattened(): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = None - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/securityHealthAnalyticsCustomModules/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = '' - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.delete_security_health_analytics_custom_module(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/securityHealthAnalyticsCustomModules/*}" % client.transport._host, args[1]) - - -def test_delete_security_health_analytics_custom_module_rest_flattened_error(transport: str = 'rest'): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.delete_security_health_analytics_custom_module( - security_center_management.DeleteSecurityHealthAnalyticsCustomModuleRequest(), - name='name_value', - ) - - -def test_delete_security_health_analytics_custom_module_rest_error(): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest, - dict, -]) -def test_simulate_security_health_analytics_custom_module_rest(request_type): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse( - ) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.simulate_security_health_analytics_custom_module(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse) - - -def test_simulate_security_health_analytics_custom_module_rest_required_fields(request_type=security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest): - transport_class = transports.SecurityCenterManagementRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).simulate_security_health_analytics_custom_module._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = 'parent_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).simulate_security_health_analytics_custom_module._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "post", - 'query_params': pb_request, - } - transcode_result['body'] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.simulate_security_health_analytics_custom_module(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_simulate_security_health_analytics_custom_module_rest_unset_required_fields(): - transport = transports.SecurityCenterManagementRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.simulate_security_health_analytics_custom_module._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("parent", "customConfig", "resource", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_simulate_security_health_analytics_custom_module_rest_interceptors(null_interceptor): - transport = transports.SecurityCenterManagementRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.SecurityCenterManagementRestInterceptor(), - ) - client = SecurityCenterManagementClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "post_simulate_security_health_analytics_custom_module") as post, \ - mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "pre_simulate_security_health_analytics_custom_module") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest.pb(security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse.to_json(security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse()) - - request = security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse() - - client.simulate_security_health_analytics_custom_module(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_simulate_security_health_analytics_custom_module_rest_bad_request(transport: str = 'rest', request_type=security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.simulate_security_health_analytics_custom_module(request) - - -def test_simulate_security_health_analytics_custom_module_rest_flattened(): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - custom_config=security_center_management.CustomConfig(predicate=expr_pb2.Expr(expression='expression_value')), - resource=security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest.SimulatedResource(resource_type='resource_type_value'), - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = security_center_management.SimulateSecurityHealthAnalyticsCustomModuleResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.simulate_security_health_analytics_custom_module(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/securityHealthAnalyticsCustomModules:simulate" % client.transport._host, args[1]) - - -def test_simulate_security_health_analytics_custom_module_rest_flattened_error(transport: str = 'rest'): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.simulate_security_health_analytics_custom_module( - security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest(), - parent='parent_value', - custom_config=security_center_management.CustomConfig(predicate=expr_pb2.Expr(expression='expression_value')), - resource=security_center_management.SimulateSecurityHealthAnalyticsCustomModuleRequest.SimulatedResource(resource_type='resource_type_value'), - ) - - -def test_simulate_security_health_analytics_custom_module_rest_error(): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest, - dict, -]) -def test_list_effective_event_threat_detection_custom_modules_rest(request_type): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse( - next_page_token='next_page_token_value', - ) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.list_effective_event_threat_detection_custom_modules(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListEffectiveEventThreatDetectionCustomModulesPager) - assert response.next_page_token == 'next_page_token_value' - - -def test_list_effective_event_threat_detection_custom_modules_rest_required_fields(request_type=security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest): - transport_class = transports.SecurityCenterManagementRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_effective_event_threat_detection_custom_modules._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = 'parent_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_effective_event_threat_detection_custom_modules._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("page_size", "page_token", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.list_effective_event_threat_detection_custom_modules(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_list_effective_event_threat_detection_custom_modules_rest_unset_required_fields(): - transport = transports.SecurityCenterManagementRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.list_effective_event_threat_detection_custom_modules._get_unset_required_fields({}) - assert set(unset_fields) == (set(("pageSize", "pageToken", )) & set(("parent", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_effective_event_threat_detection_custom_modules_rest_interceptors(null_interceptor): - transport = transports.SecurityCenterManagementRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.SecurityCenterManagementRestInterceptor(), - ) - client = SecurityCenterManagementClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "post_list_effective_event_threat_detection_custom_modules") as post, \ - mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "pre_list_effective_event_threat_detection_custom_modules") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest.pb(security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse.to_json(security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse()) - - request = security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse() - - client.list_effective_event_threat_detection_custom_modules(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_list_effective_event_threat_detection_custom_modules_rest_bad_request(transport: str = 'rest', request_type=security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.list_effective_event_threat_detection_custom_modules(request) - - -def test_list_effective_event_threat_detection_custom_modules_rest_flattened(): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.list_effective_event_threat_detection_custom_modules(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/effectiveEventThreatDetectionCustomModules" % client.transport._host, args[1]) - - -def test_list_effective_event_threat_detection_custom_modules_rest_flattened_error(transport: str = 'rest'): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_effective_event_threat_detection_custom_modules( - security_center_management.ListEffectiveEventThreatDetectionCustomModulesRequest(), - parent='parent_value', - ) - - -def test_list_effective_event_threat_detection_custom_modules_rest_pager(transport: str = 'rest'): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - #with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse( - effective_event_threat_detection_custom_modules=[ - security_center_management.EffectiveEventThreatDetectionCustomModule(), - security_center_management.EffectiveEventThreatDetectionCustomModule(), - security_center_management.EffectiveEventThreatDetectionCustomModule(), - ], - next_page_token='abc', - ), - security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse( - effective_event_threat_detection_custom_modules=[], - next_page_token='def', - ), - security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse( - effective_event_threat_detection_custom_modules=[ - security_center_management.EffectiveEventThreatDetectionCustomModule(), - ], - next_page_token='ghi', - ), - security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse( - effective_event_threat_detection_custom_modules=[ - security_center_management.EffectiveEventThreatDetectionCustomModule(), - security_center_management.EffectiveEventThreatDetectionCustomModule(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple(security_center_management.ListEffectiveEventThreatDetectionCustomModulesResponse.to_json(x) for x in response) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode('UTF-8') - return_val.status_code = 200 - req.side_effect = return_values - - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - pager = client.list_effective_event_threat_detection_custom_modules(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, security_center_management.EffectiveEventThreatDetectionCustomModule) - for i in results) - - pages = list(client.list_effective_event_threat_detection_custom_modules(request=sample_request).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - - -@pytest.mark.parametrize("request_type", [ - security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest, - dict, -]) -def test_get_effective_event_threat_detection_custom_module_rest(request_type): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/effectiveEventThreatDetectionCustomModules/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = security_center_management.EffectiveEventThreatDetectionCustomModule( - name='name_value', - enablement_state=security_center_management.EffectiveEventThreatDetectionCustomModule.EnablementState.ENABLED, - type_='type__value', - display_name='display_name_value', - description='description_value', - ) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = security_center_management.EffectiveEventThreatDetectionCustomModule.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.get_effective_event_threat_detection_custom_module(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, security_center_management.EffectiveEventThreatDetectionCustomModule) - assert response.name == 'name_value' - assert response.enablement_state == security_center_management.EffectiveEventThreatDetectionCustomModule.EnablementState.ENABLED - assert response.type_ == 'type__value' - assert response.display_name == 'display_name_value' - assert response.description == 'description_value' - - -def test_get_effective_event_threat_detection_custom_module_rest_required_fields(request_type=security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest): - transport_class = transports.SecurityCenterManagementRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_effective_event_threat_detection_custom_module._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_effective_event_threat_detection_custom_module._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = security_center_management.EffectiveEventThreatDetectionCustomModule() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = security_center_management.EffectiveEventThreatDetectionCustomModule.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.get_effective_event_threat_detection_custom_module(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_get_effective_event_threat_detection_custom_module_rest_unset_required_fields(): - transport = transports.SecurityCenterManagementRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.get_effective_event_threat_detection_custom_module._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_effective_event_threat_detection_custom_module_rest_interceptors(null_interceptor): - transport = transports.SecurityCenterManagementRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.SecurityCenterManagementRestInterceptor(), - ) - client = SecurityCenterManagementClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "post_get_effective_event_threat_detection_custom_module") as post, \ - mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "pre_get_effective_event_threat_detection_custom_module") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest.pb(security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = security_center_management.EffectiveEventThreatDetectionCustomModule.to_json(security_center_management.EffectiveEventThreatDetectionCustomModule()) - - request = security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = security_center_management.EffectiveEventThreatDetectionCustomModule() - - client.get_effective_event_threat_detection_custom_module(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_get_effective_event_threat_detection_custom_module_rest_bad_request(transport: str = 'rest', request_type=security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/effectiveEventThreatDetectionCustomModules/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.get_effective_event_threat_detection_custom_module(request) - - -def test_get_effective_event_threat_detection_custom_module_rest_flattened(): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = security_center_management.EffectiveEventThreatDetectionCustomModule() - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/effectiveEventThreatDetectionCustomModules/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = security_center_management.EffectiveEventThreatDetectionCustomModule.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.get_effective_event_threat_detection_custom_module(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/effectiveEventThreatDetectionCustomModules/*}" % client.transport._host, args[1]) - - -def test_get_effective_event_threat_detection_custom_module_rest_flattened_error(transport: str = 'rest'): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_effective_event_threat_detection_custom_module( - security_center_management.GetEffectiveEventThreatDetectionCustomModuleRequest(), - name='name_value', - ) - - -def test_get_effective_event_threat_detection_custom_module_rest_error(): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - security_center_management.ListEventThreatDetectionCustomModulesRequest, - dict, -]) -def test_list_event_threat_detection_custom_modules_rest(request_type): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = security_center_management.ListEventThreatDetectionCustomModulesResponse( - next_page_token='next_page_token_value', - ) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = security_center_management.ListEventThreatDetectionCustomModulesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.list_event_threat_detection_custom_modules(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListEventThreatDetectionCustomModulesPager) - assert response.next_page_token == 'next_page_token_value' - - -def test_list_event_threat_detection_custom_modules_rest_required_fields(request_type=security_center_management.ListEventThreatDetectionCustomModulesRequest): - transport_class = transports.SecurityCenterManagementRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_event_threat_detection_custom_modules._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = 'parent_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_event_threat_detection_custom_modules._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("page_size", "page_token", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = security_center_management.ListEventThreatDetectionCustomModulesResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = security_center_management.ListEventThreatDetectionCustomModulesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.list_event_threat_detection_custom_modules(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_list_event_threat_detection_custom_modules_rest_unset_required_fields(): - transport = transports.SecurityCenterManagementRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.list_event_threat_detection_custom_modules._get_unset_required_fields({}) - assert set(unset_fields) == (set(("pageSize", "pageToken", )) & set(("parent", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_event_threat_detection_custom_modules_rest_interceptors(null_interceptor): - transport = transports.SecurityCenterManagementRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.SecurityCenterManagementRestInterceptor(), - ) - client = SecurityCenterManagementClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "post_list_event_threat_detection_custom_modules") as post, \ - mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "pre_list_event_threat_detection_custom_modules") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = security_center_management.ListEventThreatDetectionCustomModulesRequest.pb(security_center_management.ListEventThreatDetectionCustomModulesRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = security_center_management.ListEventThreatDetectionCustomModulesResponse.to_json(security_center_management.ListEventThreatDetectionCustomModulesResponse()) - - request = security_center_management.ListEventThreatDetectionCustomModulesRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = security_center_management.ListEventThreatDetectionCustomModulesResponse() - - client.list_event_threat_detection_custom_modules(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_list_event_threat_detection_custom_modules_rest_bad_request(transport: str = 'rest', request_type=security_center_management.ListEventThreatDetectionCustomModulesRequest): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.list_event_threat_detection_custom_modules(request) - - -def test_list_event_threat_detection_custom_modules_rest_flattened(): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = security_center_management.ListEventThreatDetectionCustomModulesResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = security_center_management.ListEventThreatDetectionCustomModulesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.list_event_threat_detection_custom_modules(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/eventThreatDetectionCustomModules" % client.transport._host, args[1]) - - -def test_list_event_threat_detection_custom_modules_rest_flattened_error(transport: str = 'rest'): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_event_threat_detection_custom_modules( - security_center_management.ListEventThreatDetectionCustomModulesRequest(), - parent='parent_value', - ) - - -def test_list_event_threat_detection_custom_modules_rest_pager(transport: str = 'rest'): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - #with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - security_center_management.ListEventThreatDetectionCustomModulesResponse( - event_threat_detection_custom_modules=[ - security_center_management.EventThreatDetectionCustomModule(), - security_center_management.EventThreatDetectionCustomModule(), - security_center_management.EventThreatDetectionCustomModule(), - ], - next_page_token='abc', - ), - security_center_management.ListEventThreatDetectionCustomModulesResponse( - event_threat_detection_custom_modules=[], - next_page_token='def', - ), - security_center_management.ListEventThreatDetectionCustomModulesResponse( - event_threat_detection_custom_modules=[ - security_center_management.EventThreatDetectionCustomModule(), - ], - next_page_token='ghi', - ), - security_center_management.ListEventThreatDetectionCustomModulesResponse( - event_threat_detection_custom_modules=[ - security_center_management.EventThreatDetectionCustomModule(), - security_center_management.EventThreatDetectionCustomModule(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple(security_center_management.ListEventThreatDetectionCustomModulesResponse.to_json(x) for x in response) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode('UTF-8') - return_val.status_code = 200 - req.side_effect = return_values - - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - pager = client.list_event_threat_detection_custom_modules(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, security_center_management.EventThreatDetectionCustomModule) - for i in results) - - pages = list(client.list_event_threat_detection_custom_modules(request=sample_request).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - - -@pytest.mark.parametrize("request_type", [ - security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest, - dict, -]) -def test_list_descendant_event_threat_detection_custom_modules_rest(request_type): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse( - next_page_token='next_page_token_value', - ) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.list_descendant_event_threat_detection_custom_modules(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListDescendantEventThreatDetectionCustomModulesPager) - assert response.next_page_token == 'next_page_token_value' - - -def test_list_descendant_event_threat_detection_custom_modules_rest_required_fields(request_type=security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest): - transport_class = transports.SecurityCenterManagementRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_descendant_event_threat_detection_custom_modules._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = 'parent_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).list_descendant_event_threat_detection_custom_modules._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("page_size", "page_token", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.list_descendant_event_threat_detection_custom_modules(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_list_descendant_event_threat_detection_custom_modules_rest_unset_required_fields(): - transport = transports.SecurityCenterManagementRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.list_descendant_event_threat_detection_custom_modules._get_unset_required_fields({}) - assert set(unset_fields) == (set(("pageSize", "pageToken", )) & set(("parent", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_list_descendant_event_threat_detection_custom_modules_rest_interceptors(null_interceptor): - transport = transports.SecurityCenterManagementRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.SecurityCenterManagementRestInterceptor(), - ) - client = SecurityCenterManagementClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "post_list_descendant_event_threat_detection_custom_modules") as post, \ - mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "pre_list_descendant_event_threat_detection_custom_modules") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest.pb(security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse.to_json(security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse()) - - request = security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse() - - client.list_descendant_event_threat_detection_custom_modules(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_list_descendant_event_threat_detection_custom_modules_rest_bad_request(transport: str = 'rest', request_type=security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.list_descendant_event_threat_detection_custom_modules(request) - - -def test_list_descendant_event_threat_detection_custom_modules_rest_flattened(): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse() - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.list_descendant_event_threat_detection_custom_modules(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/eventThreatDetectionCustomModules:listDescendant" % client.transport._host, args[1]) - - -def test_list_descendant_event_threat_detection_custom_modules_rest_flattened_error(transport: str = 'rest'): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.list_descendant_event_threat_detection_custom_modules( - security_center_management.ListDescendantEventThreatDetectionCustomModulesRequest(), - parent='parent_value', - ) - - -def test_list_descendant_event_threat_detection_custom_modules_rest_pager(transport: str = 'rest'): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # TODO(kbandes): remove this mock unless there's a good reason for it. - #with mock.patch.object(path_template, 'transcode') as transcode: - # Set the response as a series of pages - response = ( - security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse( - event_threat_detection_custom_modules=[ - security_center_management.EventThreatDetectionCustomModule(), - security_center_management.EventThreatDetectionCustomModule(), - security_center_management.EventThreatDetectionCustomModule(), - ], - next_page_token='abc', - ), - security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse( - event_threat_detection_custom_modules=[], - next_page_token='def', - ), - security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse( - event_threat_detection_custom_modules=[ - security_center_management.EventThreatDetectionCustomModule(), - ], - next_page_token='ghi', - ), - security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse( - event_threat_detection_custom_modules=[ - security_center_management.EventThreatDetectionCustomModule(), - security_center_management.EventThreatDetectionCustomModule(), - ], - ), - ) - # Two responses for two calls - response = response + response - - # Wrap the values into proper Response objs - response = tuple(security_center_management.ListDescendantEventThreatDetectionCustomModulesResponse.to_json(x) for x in response) - return_values = tuple(Response() for i in response) - for return_val, response_val in zip(return_values, response): - return_val._content = response_val.encode('UTF-8') - return_val.status_code = 200 - req.side_effect = return_values - - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - pager = client.list_descendant_event_threat_detection_custom_modules(request=sample_request) - - results = list(pager) - assert len(results) == 6 - assert all(isinstance(i, security_center_management.EventThreatDetectionCustomModule) - for i in results) - - pages = list(client.list_descendant_event_threat_detection_custom_modules(request=sample_request).pages) - for page_, token in zip(pages, ['abc','def','ghi', '']): - assert page_.raw_page.next_page_token == token - - -@pytest.mark.parametrize("request_type", [ - security_center_management.GetEventThreatDetectionCustomModuleRequest, - dict, -]) -def test_get_event_threat_detection_custom_module_rest(request_type): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/eventThreatDetectionCustomModules/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = security_center_management.EventThreatDetectionCustomModule( - name='name_value', - ancestor_module='ancestor_module_value', - enablement_state=security_center_management.EventThreatDetectionCustomModule.EnablementState.ENABLED, - type_='type__value', - display_name='display_name_value', - description='description_value', - last_editor='last_editor_value', - ) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = security_center_management.EventThreatDetectionCustomModule.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.get_event_threat_detection_custom_module(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, security_center_management.EventThreatDetectionCustomModule) - assert response.name == 'name_value' - assert response.ancestor_module == 'ancestor_module_value' - assert response.enablement_state == security_center_management.EventThreatDetectionCustomModule.EnablementState.ENABLED - assert response.type_ == 'type__value' - assert response.display_name == 'display_name_value' - assert response.description == 'description_value' - assert response.last_editor == 'last_editor_value' - - -def test_get_event_threat_detection_custom_module_rest_required_fields(request_type=security_center_management.GetEventThreatDetectionCustomModuleRequest): - transport_class = transports.SecurityCenterManagementRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_event_threat_detection_custom_module._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).get_event_threat_detection_custom_module._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = security_center_management.EventThreatDetectionCustomModule() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "get", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = security_center_management.EventThreatDetectionCustomModule.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.get_event_threat_detection_custom_module(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_get_event_threat_detection_custom_module_rest_unset_required_fields(): - transport = transports.SecurityCenterManagementRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.get_event_threat_detection_custom_module._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("name", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_get_event_threat_detection_custom_module_rest_interceptors(null_interceptor): - transport = transports.SecurityCenterManagementRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.SecurityCenterManagementRestInterceptor(), - ) - client = SecurityCenterManagementClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "post_get_event_threat_detection_custom_module") as post, \ - mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "pre_get_event_threat_detection_custom_module") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = security_center_management.GetEventThreatDetectionCustomModuleRequest.pb(security_center_management.GetEventThreatDetectionCustomModuleRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = security_center_management.EventThreatDetectionCustomModule.to_json(security_center_management.EventThreatDetectionCustomModule()) - - request = security_center_management.GetEventThreatDetectionCustomModuleRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = security_center_management.EventThreatDetectionCustomModule() - - client.get_event_threat_detection_custom_module(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_get_event_threat_detection_custom_module_rest_bad_request(transport: str = 'rest', request_type=security_center_management.GetEventThreatDetectionCustomModuleRequest): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/eventThreatDetectionCustomModules/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.get_event_threat_detection_custom_module(request) - - -def test_get_event_threat_detection_custom_module_rest_flattened(): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = security_center_management.EventThreatDetectionCustomModule() - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/eventThreatDetectionCustomModules/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = security_center_management.EventThreatDetectionCustomModule.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.get_event_threat_detection_custom_module(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/eventThreatDetectionCustomModules/*}" % client.transport._host, args[1]) - - -def test_get_event_threat_detection_custom_module_rest_flattened_error(transport: str = 'rest'): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.get_event_threat_detection_custom_module( - security_center_management.GetEventThreatDetectionCustomModuleRequest(), - name='name_value', - ) - - -def test_get_event_threat_detection_custom_module_rest_error(): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - security_center_management.CreateEventThreatDetectionCustomModuleRequest, - dict, -]) -def test_create_event_threat_detection_custom_module_rest(request_type): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request_init["event_threat_detection_custom_module"] = {'name': 'name_value', 'config': {'fields': {}}, 'ancestor_module': 'ancestor_module_value', 'enablement_state': 1, 'type_': 'type__value', 'display_name': 'display_name_value', 'description': 'description_value', 'update_time': {'seconds': 751, 'nanos': 543}, 'last_editor': 'last_editor_value'} - # The version of a generated dependency at test runtime may differ from the version used during generation. - # Delete any fields which are not present in the current runtime dependency - # See https://github.com/googleapis/gapic-generator-python/issues/1748 - - # Determine if the message type is proto-plus or protobuf - test_field = security_center_management.CreateEventThreatDetectionCustomModuleRequest.meta.fields["event_threat_detection_custom_module"] - - def get_message_fields(field): - # Given a field which is a message (composite type), return a list with - # all the fields of the message. - # If the field is not a composite type, return an empty list. - message_fields = [] - - if hasattr(field, "message") and field.message: - is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") - - if is_field_type_proto_plus_type: - message_fields = field.message.meta.fields.values() - # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types - else: # pragma: NO COVER - message_fields = field.message.DESCRIPTOR.fields - return message_fields - - runtime_nested_fields = [ - (field.name, nested_field.name) - for field in get_message_fields(test_field) - for nested_field in get_message_fields(field) - ] - - subfields_not_in_runtime = [] - - # For each item in the sample request, create a list of sub fields which are not present at runtime - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["event_threat_detection_custom_module"].items(): # pragma: NO COVER - result = None - is_repeated = False - # For repeated fields - if isinstance(value, list) and len(value): - is_repeated = True - result = value[0] - # For fields where the type is another message - if isinstance(value, dict): - result = value - - if result and hasattr(result, "keys"): - for subfield in result.keys(): - if (field, subfield) not in runtime_nested_fields: - subfields_not_in_runtime.append( - {"field": field, "subfield": subfield, "is_repeated": is_repeated} - ) - - # Remove fields from the sample request which are not present in the runtime version of the dependency - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER - field = subfield_to_delete.get("field") - field_repeated = subfield_to_delete.get("is_repeated") - subfield = subfield_to_delete.get("subfield") - if subfield: - if field_repeated: - for i in range(0, len(request_init["event_threat_detection_custom_module"][field])): - del request_init["event_threat_detection_custom_module"][field][i][subfield] - else: - del request_init["event_threat_detection_custom_module"][field][subfield] - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = security_center_management.EventThreatDetectionCustomModule( - name='name_value', - ancestor_module='ancestor_module_value', - enablement_state=security_center_management.EventThreatDetectionCustomModule.EnablementState.ENABLED, - type_='type__value', - display_name='display_name_value', - description='description_value', - last_editor='last_editor_value', - ) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = security_center_management.EventThreatDetectionCustomModule.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.create_event_threat_detection_custom_module(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, security_center_management.EventThreatDetectionCustomModule) - assert response.name == 'name_value' - assert response.ancestor_module == 'ancestor_module_value' - assert response.enablement_state == security_center_management.EventThreatDetectionCustomModule.EnablementState.ENABLED - assert response.type_ == 'type__value' - assert response.display_name == 'display_name_value' - assert response.description == 'description_value' - assert response.last_editor == 'last_editor_value' - - -def test_create_event_threat_detection_custom_module_rest_required_fields(request_type=security_center_management.CreateEventThreatDetectionCustomModuleRequest): - transport_class = transports.SecurityCenterManagementRestTransport - - request_init = {} - request_init["parent"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_event_threat_detection_custom_module._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = 'parent_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).create_event_threat_detection_custom_module._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("validate_only", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = security_center_management.EventThreatDetectionCustomModule() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "post", - 'query_params': pb_request, - } - transcode_result['body'] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = security_center_management.EventThreatDetectionCustomModule.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.create_event_threat_detection_custom_module(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_create_event_threat_detection_custom_module_rest_unset_required_fields(): - transport = transports.SecurityCenterManagementRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.create_event_threat_detection_custom_module._get_unset_required_fields({}) - assert set(unset_fields) == (set(("validateOnly", )) & set(("parent", "eventThreatDetectionCustomModule", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_create_event_threat_detection_custom_module_rest_interceptors(null_interceptor): - transport = transports.SecurityCenterManagementRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.SecurityCenterManagementRestInterceptor(), - ) - client = SecurityCenterManagementClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "post_create_event_threat_detection_custom_module") as post, \ - mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "pre_create_event_threat_detection_custom_module") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = security_center_management.CreateEventThreatDetectionCustomModuleRequest.pb(security_center_management.CreateEventThreatDetectionCustomModuleRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = security_center_management.EventThreatDetectionCustomModule.to_json(security_center_management.EventThreatDetectionCustomModule()) - - request = security_center_management.CreateEventThreatDetectionCustomModuleRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = security_center_management.EventThreatDetectionCustomModule() - - client.create_event_threat_detection_custom_module(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_create_event_threat_detection_custom_module_rest_bad_request(transport: str = 'rest', request_type=security_center_management.CreateEventThreatDetectionCustomModuleRequest): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.create_event_threat_detection_custom_module(request) - - -def test_create_event_threat_detection_custom_module_rest_flattened(): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = security_center_management.EventThreatDetectionCustomModule() - - # get arguments that satisfy an http rule for this method - sample_request = {'parent': 'projects/sample1/locations/sample2'} - - # get truthy value for each flattened field - mock_args = dict( - parent='parent_value', - event_threat_detection_custom_module=security_center_management.EventThreatDetectionCustomModule(name='name_value'), - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = security_center_management.EventThreatDetectionCustomModule.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.create_event_threat_detection_custom_module(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{parent=projects/*/locations/*}/eventThreatDetectionCustomModules" % client.transport._host, args[1]) - - -def test_create_event_threat_detection_custom_module_rest_flattened_error(transport: str = 'rest'): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.create_event_threat_detection_custom_module( - security_center_management.CreateEventThreatDetectionCustomModuleRequest(), - parent='parent_value', - event_threat_detection_custom_module=security_center_management.EventThreatDetectionCustomModule(name='name_value'), - ) - - -def test_create_event_threat_detection_custom_module_rest_error(): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - security_center_management.UpdateEventThreatDetectionCustomModuleRequest, - dict, -]) -def test_update_event_threat_detection_custom_module_rest(request_type): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'event_threat_detection_custom_module': {'name': 'projects/sample1/locations/sample2/eventThreatDetectionCustomModules/sample3'}} - request_init["event_threat_detection_custom_module"] = {'name': 'projects/sample1/locations/sample2/eventThreatDetectionCustomModules/sample3', 'config': {'fields': {}}, 'ancestor_module': 'ancestor_module_value', 'enablement_state': 1, 'type_': 'type__value', 'display_name': 'display_name_value', 'description': 'description_value', 'update_time': {'seconds': 751, 'nanos': 543}, 'last_editor': 'last_editor_value'} - # The version of a generated dependency at test runtime may differ from the version used during generation. - # Delete any fields which are not present in the current runtime dependency - # See https://github.com/googleapis/gapic-generator-python/issues/1748 - - # Determine if the message type is proto-plus or protobuf - test_field = security_center_management.UpdateEventThreatDetectionCustomModuleRequest.meta.fields["event_threat_detection_custom_module"] - - def get_message_fields(field): - # Given a field which is a message (composite type), return a list with - # all the fields of the message. - # If the field is not a composite type, return an empty list. - message_fields = [] - - if hasattr(field, "message") and field.message: - is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR") - - if is_field_type_proto_plus_type: - message_fields = field.message.meta.fields.values() - # Add `# pragma: NO COVER` because there may not be any `*_pb2` field types - else: # pragma: NO COVER - message_fields = field.message.DESCRIPTOR.fields - return message_fields - - runtime_nested_fields = [ - (field.name, nested_field.name) - for field in get_message_fields(test_field) - for nested_field in get_message_fields(field) - ] - - subfields_not_in_runtime = [] - - # For each item in the sample request, create a list of sub fields which are not present at runtime - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for field, value in request_init["event_threat_detection_custom_module"].items(): # pragma: NO COVER - result = None - is_repeated = False - # For repeated fields - if isinstance(value, list) and len(value): - is_repeated = True - result = value[0] - # For fields where the type is another message - if isinstance(value, dict): - result = value - - if result and hasattr(result, "keys"): - for subfield in result.keys(): - if (field, subfield) not in runtime_nested_fields: - subfields_not_in_runtime.append( - {"field": field, "subfield": subfield, "is_repeated": is_repeated} - ) - - # Remove fields from the sample request which are not present in the runtime version of the dependency - # Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime - for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER - field = subfield_to_delete.get("field") - field_repeated = subfield_to_delete.get("is_repeated") - subfield = subfield_to_delete.get("subfield") - if subfield: - if field_repeated: - for i in range(0, len(request_init["event_threat_detection_custom_module"][field])): - del request_init["event_threat_detection_custom_module"][field][i][subfield] - else: - del request_init["event_threat_detection_custom_module"][field][subfield] - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = security_center_management.EventThreatDetectionCustomModule( - name='name_value', - ancestor_module='ancestor_module_value', - enablement_state=security_center_management.EventThreatDetectionCustomModule.EnablementState.ENABLED, - type_='type__value', - display_name='display_name_value', - description='description_value', - last_editor='last_editor_value', - ) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = security_center_management.EventThreatDetectionCustomModule.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.update_event_threat_detection_custom_module(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, security_center_management.EventThreatDetectionCustomModule) - assert response.name == 'name_value' - assert response.ancestor_module == 'ancestor_module_value' - assert response.enablement_state == security_center_management.EventThreatDetectionCustomModule.EnablementState.ENABLED - assert response.type_ == 'type__value' - assert response.display_name == 'display_name_value' - assert response.description == 'description_value' - assert response.last_editor == 'last_editor_value' - - -def test_update_event_threat_detection_custom_module_rest_required_fields(request_type=security_center_management.UpdateEventThreatDetectionCustomModuleRequest): - transport_class = transports.SecurityCenterManagementRestTransport - - request_init = {} - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_event_threat_detection_custom_module._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).update_event_threat_detection_custom_module._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("update_mask", "validate_only", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = security_center_management.EventThreatDetectionCustomModule() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "patch", - 'query_params': pb_request, - } - transcode_result['body'] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = security_center_management.EventThreatDetectionCustomModule.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.update_event_threat_detection_custom_module(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_update_event_threat_detection_custom_module_rest_unset_required_fields(): - transport = transports.SecurityCenterManagementRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.update_event_threat_detection_custom_module._get_unset_required_fields({}) - assert set(unset_fields) == (set(("updateMask", "validateOnly", )) & set(("updateMask", "eventThreatDetectionCustomModule", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_update_event_threat_detection_custom_module_rest_interceptors(null_interceptor): - transport = transports.SecurityCenterManagementRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.SecurityCenterManagementRestInterceptor(), - ) - client = SecurityCenterManagementClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "post_update_event_threat_detection_custom_module") as post, \ - mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "pre_update_event_threat_detection_custom_module") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = security_center_management.UpdateEventThreatDetectionCustomModuleRequest.pb(security_center_management.UpdateEventThreatDetectionCustomModuleRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = security_center_management.EventThreatDetectionCustomModule.to_json(security_center_management.EventThreatDetectionCustomModule()) - - request = security_center_management.UpdateEventThreatDetectionCustomModuleRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = security_center_management.EventThreatDetectionCustomModule() - - client.update_event_threat_detection_custom_module(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_update_event_threat_detection_custom_module_rest_bad_request(transport: str = 'rest', request_type=security_center_management.UpdateEventThreatDetectionCustomModuleRequest): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'event_threat_detection_custom_module': {'name': 'projects/sample1/locations/sample2/eventThreatDetectionCustomModules/sample3'}} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.update_event_threat_detection_custom_module(request) - - -def test_update_event_threat_detection_custom_module_rest_flattened(): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = security_center_management.EventThreatDetectionCustomModule() - - # get arguments that satisfy an http rule for this method - sample_request = {'event_threat_detection_custom_module': {'name': 'projects/sample1/locations/sample2/eventThreatDetectionCustomModules/sample3'}} - - # get truthy value for each flattened field - mock_args = dict( - event_threat_detection_custom_module=security_center_management.EventThreatDetectionCustomModule(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = security_center_management.EventThreatDetectionCustomModule.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.update_event_threat_detection_custom_module(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{event_threat_detection_custom_module.name=projects/*/locations/*/eventThreatDetectionCustomModules/*}" % client.transport._host, args[1]) - - -def test_update_event_threat_detection_custom_module_rest_flattened_error(transport: str = 'rest'): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.update_event_threat_detection_custom_module( - security_center_management.UpdateEventThreatDetectionCustomModuleRequest(), - event_threat_detection_custom_module=security_center_management.EventThreatDetectionCustomModule(name='name_value'), - update_mask=field_mask_pb2.FieldMask(paths=['paths_value']), - ) - - -def test_update_event_threat_detection_custom_module_rest_error(): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - security_center_management.DeleteEventThreatDetectionCustomModuleRequest, - dict, -]) -def test_delete_event_threat_detection_custom_module_rest(request_type): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/eventThreatDetectionCustomModules/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = None - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = '' - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.delete_event_threat_detection_custom_module(request) - - # Establish that the response is the type that we expect. - assert response is None - - -def test_delete_event_threat_detection_custom_module_rest_required_fields(request_type=security_center_management.DeleteEventThreatDetectionCustomModuleRequest): - transport_class = transports.SecurityCenterManagementRestTransport - - request_init = {} - request_init["name"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_event_threat_detection_custom_module._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["name"] = 'name_value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).delete_event_threat_detection_custom_module._get_unset_required_fields(jsonified_request) - # Check that path parameters and body parameters are not mixing in. - assert not set(unset_fields) - set(("validate_only", )) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "name" in jsonified_request - assert jsonified_request["name"] == 'name_value' - - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = None - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "delete", - 'query_params': pb_request, - } - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - json_return_value = '' - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.delete_event_threat_detection_custom_module(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_delete_event_threat_detection_custom_module_rest_unset_required_fields(): - transport = transports.SecurityCenterManagementRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.delete_event_threat_detection_custom_module._get_unset_required_fields({}) - assert set(unset_fields) == (set(("validateOnly", )) & set(("name", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_delete_event_threat_detection_custom_module_rest_interceptors(null_interceptor): - transport = transports.SecurityCenterManagementRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.SecurityCenterManagementRestInterceptor(), - ) - client = SecurityCenterManagementClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "pre_delete_event_threat_detection_custom_module") as pre: - pre.assert_not_called() - pb_message = security_center_management.DeleteEventThreatDetectionCustomModuleRequest.pb(security_center_management.DeleteEventThreatDetectionCustomModuleRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - - request = security_center_management.DeleteEventThreatDetectionCustomModuleRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - - client.delete_event_threat_detection_custom_module(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - - -def test_delete_event_threat_detection_custom_module_rest_bad_request(transport: str = 'rest', request_type=security_center_management.DeleteEventThreatDetectionCustomModuleRequest): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'name': 'projects/sample1/locations/sample2/eventThreatDetectionCustomModules/sample3'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.delete_event_threat_detection_custom_module(request) - - -def test_delete_event_threat_detection_custom_module_rest_flattened(): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = None - - # get arguments that satisfy an http rule for this method - sample_request = {'name': 'projects/sample1/locations/sample2/eventThreatDetectionCustomModules/sample3'} - - # get truthy value for each flattened field - mock_args = dict( - name='name_value', - ) - mock_args.update(sample_request) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = '' - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - client.delete_event_threat_detection_custom_module(**mock_args) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(req.mock_calls) == 1 - _, args, _ = req.mock_calls[0] - assert path_template.validate("%s/v1/{name=projects/*/locations/*/eventThreatDetectionCustomModules/*}" % client.transport._host, args[1]) - - -def test_delete_event_threat_detection_custom_module_rest_flattened_error(transport: str = 'rest'): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.delete_event_threat_detection_custom_module( - security_center_management.DeleteEventThreatDetectionCustomModuleRequest(), - name='name_value', - ) - - -def test_delete_event_threat_detection_custom_module_rest_error(): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -@pytest.mark.parametrize("request_type", [ - security_center_management.ValidateEventThreatDetectionCustomModuleRequest, - dict, -]) -def test_validate_event_threat_detection_custom_module_rest(request_type): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = security_center_management.ValidateEventThreatDetectionCustomModuleResponse( - ) - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - # Convert return value to protobuf type - return_value = security_center_management.ValidateEventThreatDetectionCustomModuleResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - response = client.validate_event_threat_detection_custom_module(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, security_center_management.ValidateEventThreatDetectionCustomModuleResponse) - - -def test_validate_event_threat_detection_custom_module_rest_required_fields(request_type=security_center_management.ValidateEventThreatDetectionCustomModuleRequest): - transport_class = transports.SecurityCenterManagementRestTransport - - request_init = {} - request_init["parent"] = "" - request_init["raw_text"] = "" - request_init["type_"] = "" - request = request_type(**request_init) - pb_request = request_type.pb(request) - jsonified_request = json.loads(json_format.MessageToJson( - pb_request, - including_default_value_fields=False, - use_integers_for_enums=False - )) - - # verify fields with default values are dropped - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).validate_event_threat_detection_custom_module._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with default values are now present - - jsonified_request["parent"] = 'parent_value' - jsonified_request["rawText"] = 'raw_text_value' - jsonified_request["type"] = 'type__value' - - unset_fields = transport_class(credentials=ga_credentials.AnonymousCredentials()).validate_event_threat_detection_custom_module._get_unset_required_fields(jsonified_request) - jsonified_request.update(unset_fields) - - # verify required fields with non-default values are left alone - assert "parent" in jsonified_request - assert jsonified_request["parent"] == 'parent_value' - assert "rawText" in jsonified_request - assert jsonified_request["rawText"] == 'raw_text_value' - assert "type" in jsonified_request - assert jsonified_request["type"] == 'type__value' - - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest', - ) - request = request_type(**request_init) - - # Designate an appropriate value for the returned response. - return_value = security_center_management.ValidateEventThreatDetectionCustomModuleResponse() - # Mock the http request call within the method and fake a response. - with mock.patch.object(Session, 'request') as req: - # We need to mock transcode() because providing default values - # for required fields will fail the real version if the http_options - # expect actual values for those fields. - with mock.patch.object(path_template, 'transcode') as transcode: - # A uri without fields and an empty body will force all the - # request fields to show up in the query_params. - pb_request = request_type.pb(request) - transcode_result = { - 'uri': 'v1/sample_method', - 'method': "post", - 'query_params': pb_request, - } - transcode_result['body'] = pb_request - transcode.return_value = transcode_result - - response_value = Response() - response_value.status_code = 200 - - # Convert return value to protobuf type - return_value = security_center_management.ValidateEventThreatDetectionCustomModuleResponse.pb(return_value) - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.validate_event_threat_detection_custom_module(request) - - expected_params = [ - ('$alt', 'json;enum-encoding=int') - ] - actual_params = req.call_args.kwargs['params'] - assert expected_params == actual_params - - -def test_validate_event_threat_detection_custom_module_rest_unset_required_fields(): - transport = transports.SecurityCenterManagementRestTransport(credentials=ga_credentials.AnonymousCredentials) - - unset_fields = transport.validate_event_threat_detection_custom_module._get_unset_required_fields({}) - assert set(unset_fields) == (set(()) & set(("parent", "rawText", "type", ))) - - -@pytest.mark.parametrize("null_interceptor", [True, False]) -def test_validate_event_threat_detection_custom_module_rest_interceptors(null_interceptor): - transport = transports.SecurityCenterManagementRestTransport( - credentials=ga_credentials.AnonymousCredentials(), - interceptor=None if null_interceptor else transports.SecurityCenterManagementRestInterceptor(), - ) - client = SecurityCenterManagementClient(transport=transport) - with mock.patch.object(type(client.transport._session), "request") as req, \ - mock.patch.object(path_template, "transcode") as transcode, \ - mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "post_validate_event_threat_detection_custom_module") as post, \ - mock.patch.object(transports.SecurityCenterManagementRestInterceptor, "pre_validate_event_threat_detection_custom_module") as pre: - pre.assert_not_called() - post.assert_not_called() - pb_message = security_center_management.ValidateEventThreatDetectionCustomModuleRequest.pb(security_center_management.ValidateEventThreatDetectionCustomModuleRequest()) - transcode.return_value = { - "method": "post", - "uri": "my_uri", - "body": pb_message, - "query_params": pb_message, - } - - req.return_value = Response() - req.return_value.status_code = 200 - req.return_value.request = PreparedRequest() - req.return_value._content = security_center_management.ValidateEventThreatDetectionCustomModuleResponse.to_json(security_center_management.ValidateEventThreatDetectionCustomModuleResponse()) - - request = security_center_management.ValidateEventThreatDetectionCustomModuleRequest() - metadata =[ - ("key", "val"), - ("cephalopod", "squid"), - ] - pre.return_value = request, metadata - post.return_value = security_center_management.ValidateEventThreatDetectionCustomModuleResponse() - - client.validate_event_threat_detection_custom_module(request, metadata=[("key", "val"), ("cephalopod", "squid"),]) - - pre.assert_called_once() - post.assert_called_once() - - -def test_validate_event_threat_detection_custom_module_rest_bad_request(transport: str = 'rest', request_type=security_center_management.ValidateEventThreatDetectionCustomModuleRequest): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # send a request that will satisfy transcoding - request_init = {'parent': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.validate_event_threat_detection_custom_module(request) - - -def test_validate_event_threat_detection_custom_module_rest_error(): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport='rest' - ) - - -def test_credentials_transport_error(): - # It is an error to provide credentials and a transport instance. - transport = transports.SecurityCenterManagementGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # It is an error to provide a credentials file and a transport instance. - transport = transports.SecurityCenterManagementGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = SecurityCenterManagementClient( - client_options={"credentials_file": "credentials.json"}, - transport=transport, - ) - - # It is an error to provide an api_key and a transport instance. - transport = transports.SecurityCenterManagementGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - options = client_options.ClientOptions() - options.api_key = "api_key" - with pytest.raises(ValueError): - client = SecurityCenterManagementClient( - client_options=options, - transport=transport, - ) - - # It is an error to provide an api_key and a credential. - options = mock.Mock() - options.api_key = "api_key" - with pytest.raises(ValueError): - client = SecurityCenterManagementClient( - client_options=options, - credentials=ga_credentials.AnonymousCredentials() - ) - - # It is an error to provide scopes and a transport instance. - transport = transports.SecurityCenterManagementGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - with pytest.raises(ValueError): - client = SecurityCenterManagementClient( - client_options={"scopes": ["1", "2"]}, - transport=transport, - ) - - -def test_transport_instance(): - # A client may be instantiated with a custom transport instance. - transport = transports.SecurityCenterManagementGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - client = SecurityCenterManagementClient(transport=transport) - assert client.transport is transport - -def test_transport_get_channel(): - # A client may be instantiated with a custom transport instance. - transport = transports.SecurityCenterManagementGrpcTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - - transport = transports.SecurityCenterManagementGrpcAsyncIOTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - channel = transport.grpc_channel - assert channel - -@pytest.mark.parametrize("transport_class", [ - transports.SecurityCenterManagementGrpcTransport, - transports.SecurityCenterManagementGrpcAsyncIOTransport, - transports.SecurityCenterManagementRestTransport, -]) -def test_transport_adc(transport_class): - # Test default credentials are used if not provided. - with mock.patch.object(google.auth, 'default') as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class() - adc.assert_called_once() - -@pytest.mark.parametrize("transport_name", [ - "grpc", - "rest", -]) -def test_transport_kind(transport_name): - transport = SecurityCenterManagementClient.get_transport_class(transport_name)( - credentials=ga_credentials.AnonymousCredentials(), - ) - assert transport.kind == transport_name - -def test_transport_grpc_default(): - # A client should use the gRPC transport by default. - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - assert isinstance( - client.transport, - transports.SecurityCenterManagementGrpcTransport, - ) - -def test_security_center_management_base_transport_error(): - # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(core_exceptions.DuplicateCredentialArgs): - transport = transports.SecurityCenterManagementTransport( - credentials=ga_credentials.AnonymousCredentials(), - credentials_file="credentials.json" - ) - - -def test_security_center_management_base_transport(): - # Instantiate the base transport. - with mock.patch('google.cloud.securitycentermanagement_v1.services.security_center_management.transports.SecurityCenterManagementTransport.__init__') as Transport: - Transport.return_value = None - transport = transports.SecurityCenterManagementTransport( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Every method on the transport should just blindly - # raise NotImplementedError. - methods = ( - 'list_effective_security_health_analytics_custom_modules', - 'get_effective_security_health_analytics_custom_module', - 'list_security_health_analytics_custom_modules', - 'list_descendant_security_health_analytics_custom_modules', - 'get_security_health_analytics_custom_module', - 'create_security_health_analytics_custom_module', - 'update_security_health_analytics_custom_module', - 'delete_security_health_analytics_custom_module', - 'simulate_security_health_analytics_custom_module', - 'list_effective_event_threat_detection_custom_modules', - 'get_effective_event_threat_detection_custom_module', - 'list_event_threat_detection_custom_modules', - 'list_descendant_event_threat_detection_custom_modules', - 'get_event_threat_detection_custom_module', - 'create_event_threat_detection_custom_module', - 'update_event_threat_detection_custom_module', - 'delete_event_threat_detection_custom_module', - 'validate_event_threat_detection_custom_module', - 'get_location', - 'list_locations', - ) - for method in methods: - with pytest.raises(NotImplementedError): - getattr(transport, method)(request=object()) - - with pytest.raises(NotImplementedError): - transport.close() - - # Catch all for all remaining methods and properties - remainder = [ - 'kind', - ] - for r in remainder: - with pytest.raises(NotImplementedError): - getattr(transport, r)() - - -def test_security_center_management_base_transport_with_credentials_file(): - # Instantiate the base transport with a credentials file - with mock.patch.object(google.auth, 'load_credentials_from_file', autospec=True) as load_creds, mock.patch('google.cloud.securitycentermanagement_v1.services.security_center_management.transports.SecurityCenterManagementTransport._prep_wrapped_messages') as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.SecurityCenterManagementTransport( - credentials_file="credentials.json", - quota_project_id="octopus", - ) - load_creds.assert_called_once_with("credentials.json", - scopes=None, - default_scopes=( - 'https://www.googleapis.com/auth/cloud-platform', -), - quota_project_id="octopus", - ) - - -def test_security_center_management_base_transport_with_adc(): - # Test the default credentials are used if credentials and credentials_file are None. - with mock.patch.object(google.auth, 'default', autospec=True) as adc, mock.patch('google.cloud.securitycentermanagement_v1.services.security_center_management.transports.SecurityCenterManagementTransport._prep_wrapped_messages') as Transport: - Transport.return_value = None - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.SecurityCenterManagementTransport() - adc.assert_called_once() - - -def test_security_center_management_auth_adc(): - # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(google.auth, 'default', autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - SecurityCenterManagementClient() - adc.assert_called_once_with( - scopes=None, - default_scopes=( - 'https://www.googleapis.com/auth/cloud-platform', -), - quota_project_id=None, - ) - - -@pytest.mark.parametrize( - "transport_class", - [ - transports.SecurityCenterManagementGrpcTransport, - transports.SecurityCenterManagementGrpcAsyncIOTransport, - ], -) -def test_security_center_management_transport_auth_adc(transport_class): - # If credentials and host are not provided, the transport class should use - # ADC credentials. - with mock.patch.object(google.auth, 'default', autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class(quota_project_id="octopus", scopes=["1", "2"]) - adc.assert_called_once_with( - scopes=["1", "2"], - default_scopes=( 'https://www.googleapis.com/auth/cloud-platform',), - quota_project_id="octopus", - ) - - -@pytest.mark.parametrize( - "transport_class", - [ - transports.SecurityCenterManagementGrpcTransport, - transports.SecurityCenterManagementGrpcAsyncIOTransport, - transports.SecurityCenterManagementRestTransport, - ], -) -def test_security_center_management_transport_auth_gdch_credentials(transport_class): - host = 'https://language.com' - api_audience_tests = [None, 'https://language2.com'] - api_audience_expect = [host, 'https://language2.com'] - for t, e in zip(api_audience_tests, api_audience_expect): - with mock.patch.object(google.auth, 'default', autospec=True) as adc: - gdch_mock = mock.MagicMock() - type(gdch_mock).with_gdch_audience = mock.PropertyMock(return_value=gdch_mock) - adc.return_value = (gdch_mock, None) - transport_class(host=host, api_audience=t) - gdch_mock.with_gdch_audience.assert_called_once_with( - e - ) - - -@pytest.mark.parametrize( - "transport_class,grpc_helpers", - [ - (transports.SecurityCenterManagementGrpcTransport, grpc_helpers), - (transports.SecurityCenterManagementGrpcAsyncIOTransport, grpc_helpers_async) - ], -) -def test_security_center_management_transport_create_channel(transport_class, grpc_helpers): - # If credentials and host are not provided, the transport class should use - # ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch.object( - grpc_helpers, "create_channel", autospec=True - ) as create_channel: - creds = ga_credentials.AnonymousCredentials() - adc.return_value = (creds, None) - transport_class( - quota_project_id="octopus", - scopes=["1", "2"] - ) - - create_channel.assert_called_with( - "securitycentermanagement.googleapis.com:443", - credentials=creds, - credentials_file=None, - quota_project_id="octopus", - default_scopes=( - 'https://www.googleapis.com/auth/cloud-platform', -), - scopes=["1", "2"], - default_host="securitycentermanagement.googleapis.com", - ssl_credentials=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - -@pytest.mark.parametrize("transport_class", [transports.SecurityCenterManagementGrpcTransport, transports.SecurityCenterManagementGrpcAsyncIOTransport]) -def test_security_center_management_grpc_transport_client_cert_source_for_mtls( - transport_class -): - cred = ga_credentials.AnonymousCredentials() - - # Check ssl_channel_credentials is used if provided. - with mock.patch.object(transport_class, "create_channel") as mock_create_channel: - mock_ssl_channel_creds = mock.Mock() - transport_class( - host="squid.clam.whelk", - credentials=cred, - ssl_channel_credentials=mock_ssl_channel_creds - ) - mock_create_channel.assert_called_once_with( - "squid.clam.whelk:443", - credentials=cred, - credentials_file=None, - scopes=None, - ssl_credentials=mock_ssl_channel_creds, - quota_project_id=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - # Check if ssl_channel_credentials is not provided, then client_cert_source_for_mtls - # is used. - with mock.patch.object(transport_class, "create_channel", return_value=mock.Mock()): - with mock.patch("grpc.ssl_channel_credentials") as mock_ssl_cred: - transport_class( - credentials=cred, - client_cert_source_for_mtls=client_cert_source_callback - ) - expected_cert, expected_key = client_cert_source_callback() - mock_ssl_cred.assert_called_once_with( - certificate_chain=expected_cert, - private_key=expected_key - ) - -def test_security_center_management_http_transport_client_cert_source_for_mtls(): - cred = ga_credentials.AnonymousCredentials() - with mock.patch("google.auth.transport.requests.AuthorizedSession.configure_mtls_channel") as mock_configure_mtls_channel: - transports.SecurityCenterManagementRestTransport ( - credentials=cred, - client_cert_source_for_mtls=client_cert_source_callback - ) - mock_configure_mtls_channel.assert_called_once_with(client_cert_source_callback) - - -@pytest.mark.parametrize("transport_name", [ - "grpc", - "grpc_asyncio", - "rest", -]) -def test_security_center_management_host_no_port(transport_name): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - client_options=client_options.ClientOptions(api_endpoint='securitycentermanagement.googleapis.com'), - transport=transport_name, - ) - assert client.transport._host == ( - 'securitycentermanagement.googleapis.com:443' - if transport_name in ['grpc', 'grpc_asyncio'] - else 'https://securitycentermanagement.googleapis.com' - ) - -@pytest.mark.parametrize("transport_name", [ - "grpc", - "grpc_asyncio", - "rest", -]) -def test_security_center_management_host_with_port(transport_name): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - client_options=client_options.ClientOptions(api_endpoint='securitycentermanagement.googleapis.com:8000'), - transport=transport_name, - ) - assert client.transport._host == ( - 'securitycentermanagement.googleapis.com:8000' - if transport_name in ['grpc', 'grpc_asyncio'] - else 'https://securitycentermanagement.googleapis.com:8000' - ) - -@pytest.mark.parametrize("transport_name", [ - "rest", -]) -def test_security_center_management_client_transport_session_collision(transport_name): - creds1 = ga_credentials.AnonymousCredentials() - creds2 = ga_credentials.AnonymousCredentials() - client1 = SecurityCenterManagementClient( - credentials=creds1, - transport=transport_name, - ) - client2 = SecurityCenterManagementClient( - credentials=creds2, - transport=transport_name, - ) - session1 = client1.transport.list_effective_security_health_analytics_custom_modules._session - session2 = client2.transport.list_effective_security_health_analytics_custom_modules._session - assert session1 != session2 - session1 = client1.transport.get_effective_security_health_analytics_custom_module._session - session2 = client2.transport.get_effective_security_health_analytics_custom_module._session - assert session1 != session2 - session1 = client1.transport.list_security_health_analytics_custom_modules._session - session2 = client2.transport.list_security_health_analytics_custom_modules._session - assert session1 != session2 - session1 = client1.transport.list_descendant_security_health_analytics_custom_modules._session - session2 = client2.transport.list_descendant_security_health_analytics_custom_modules._session - assert session1 != session2 - session1 = client1.transport.get_security_health_analytics_custom_module._session - session2 = client2.transport.get_security_health_analytics_custom_module._session - assert session1 != session2 - session1 = client1.transport.create_security_health_analytics_custom_module._session - session2 = client2.transport.create_security_health_analytics_custom_module._session - assert session1 != session2 - session1 = client1.transport.update_security_health_analytics_custom_module._session - session2 = client2.transport.update_security_health_analytics_custom_module._session - assert session1 != session2 - session1 = client1.transport.delete_security_health_analytics_custom_module._session - session2 = client2.transport.delete_security_health_analytics_custom_module._session - assert session1 != session2 - session1 = client1.transport.simulate_security_health_analytics_custom_module._session - session2 = client2.transport.simulate_security_health_analytics_custom_module._session - assert session1 != session2 - session1 = client1.transport.list_effective_event_threat_detection_custom_modules._session - session2 = client2.transport.list_effective_event_threat_detection_custom_modules._session - assert session1 != session2 - session1 = client1.transport.get_effective_event_threat_detection_custom_module._session - session2 = client2.transport.get_effective_event_threat_detection_custom_module._session - assert session1 != session2 - session1 = client1.transport.list_event_threat_detection_custom_modules._session - session2 = client2.transport.list_event_threat_detection_custom_modules._session - assert session1 != session2 - session1 = client1.transport.list_descendant_event_threat_detection_custom_modules._session - session2 = client2.transport.list_descendant_event_threat_detection_custom_modules._session - assert session1 != session2 - session1 = client1.transport.get_event_threat_detection_custom_module._session - session2 = client2.transport.get_event_threat_detection_custom_module._session - assert session1 != session2 - session1 = client1.transport.create_event_threat_detection_custom_module._session - session2 = client2.transport.create_event_threat_detection_custom_module._session - assert session1 != session2 - session1 = client1.transport.update_event_threat_detection_custom_module._session - session2 = client2.transport.update_event_threat_detection_custom_module._session - assert session1 != session2 - session1 = client1.transport.delete_event_threat_detection_custom_module._session - session2 = client2.transport.delete_event_threat_detection_custom_module._session - assert session1 != session2 - session1 = client1.transport.validate_event_threat_detection_custom_module._session - session2 = client2.transport.validate_event_threat_detection_custom_module._session - assert session1 != session2 -def test_security_center_management_grpc_transport_channel(): - channel = grpc.secure_channel('http://localhost/', grpc.local_channel_credentials()) - - # Check that channel is used if provided. - transport = transports.SecurityCenterManagementGrpcTransport( - host="squid.clam.whelk", - channel=channel, - ) - assert transport.grpc_channel == channel - assert transport._host == "squid.clam.whelk:443" - assert transport._ssl_channel_credentials == None - - -def test_security_center_management_grpc_asyncio_transport_channel(): - channel = aio.secure_channel('http://localhost/', grpc.local_channel_credentials()) - - # Check that channel is used if provided. - transport = transports.SecurityCenterManagementGrpcAsyncIOTransport( - host="squid.clam.whelk", - channel=channel, - ) - assert transport.grpc_channel == channel - assert transport._host == "squid.clam.whelk:443" - assert transport._ssl_channel_credentials == None - - -# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are -# removed from grpc/grpc_asyncio transport constructor. -@pytest.mark.parametrize("transport_class", [transports.SecurityCenterManagementGrpcTransport, transports.SecurityCenterManagementGrpcAsyncIOTransport]) -def test_security_center_management_transport_channel_mtls_with_client_cert_source( - transport_class -): - with mock.patch("grpc.ssl_channel_credentials", autospec=True) as grpc_ssl_channel_cred: - with mock.patch.object(transport_class, "create_channel") as grpc_create_channel: - mock_ssl_cred = mock.Mock() - grpc_ssl_channel_cred.return_value = mock_ssl_cred - - mock_grpc_channel = mock.Mock() - grpc_create_channel.return_value = mock_grpc_channel - - cred = ga_credentials.AnonymousCredentials() - with pytest.warns(DeprecationWarning): - with mock.patch.object(google.auth, 'default') as adc: - adc.return_value = (cred, None) - transport = transport_class( - host="squid.clam.whelk", - api_mtls_endpoint="mtls.squid.clam.whelk", - client_cert_source=client_cert_source_callback, - ) - adc.assert_called_once() - - grpc_ssl_channel_cred.assert_called_once_with( - certificate_chain=b"cert bytes", private_key=b"key bytes" - ) - grpc_create_channel.assert_called_once_with( - "mtls.squid.clam.whelk:443", - credentials=cred, - credentials_file=None, - scopes=None, - ssl_credentials=mock_ssl_cred, - quota_project_id=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - assert transport.grpc_channel == mock_grpc_channel - assert transport._ssl_channel_credentials == mock_ssl_cred - - -# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are -# removed from grpc/grpc_asyncio transport constructor. -@pytest.mark.parametrize("transport_class", [transports.SecurityCenterManagementGrpcTransport, transports.SecurityCenterManagementGrpcAsyncIOTransport]) -def test_security_center_management_transport_channel_mtls_with_adc( - transport_class -): - mock_ssl_cred = mock.Mock() - with mock.patch.multiple( - "google.auth.transport.grpc.SslCredentials", - __init__=mock.Mock(return_value=None), - ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred), - ): - with mock.patch.object(transport_class, "create_channel") as grpc_create_channel: - mock_grpc_channel = mock.Mock() - grpc_create_channel.return_value = mock_grpc_channel - mock_cred = mock.Mock() - - with pytest.warns(DeprecationWarning): - transport = transport_class( - host="squid.clam.whelk", - credentials=mock_cred, - api_mtls_endpoint="mtls.squid.clam.whelk", - client_cert_source=None, - ) - - grpc_create_channel.assert_called_once_with( - "mtls.squid.clam.whelk:443", - credentials=mock_cred, - credentials_file=None, - scopes=None, - ssl_credentials=mock_ssl_cred, - quota_project_id=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - assert transport.grpc_channel == mock_grpc_channel - - -def test_effective_event_threat_detection_custom_module_path(): - organization = "squid" - location = "clam" - effective_event_threat_detection_custom_module = "whelk" - expected = "organizations/{organization}/locations/{location}/effectiveEventThreatDetectionCustomModules/{effective_event_threat_detection_custom_module}".format(organization=organization, location=location, effective_event_threat_detection_custom_module=effective_event_threat_detection_custom_module, ) - actual = SecurityCenterManagementClient.effective_event_threat_detection_custom_module_path(organization, location, effective_event_threat_detection_custom_module) - assert expected == actual - - -def test_parse_effective_event_threat_detection_custom_module_path(): - expected = { - "organization": "octopus", - "location": "oyster", - "effective_event_threat_detection_custom_module": "nudibranch", - } - path = SecurityCenterManagementClient.effective_event_threat_detection_custom_module_path(**expected) - - # Check that the path construction is reversible. - actual = SecurityCenterManagementClient.parse_effective_event_threat_detection_custom_module_path(path) - assert expected == actual - -def test_effective_security_health_analytics_custom_module_path(): - organization = "cuttlefish" - location = "mussel" - effective_security_health_analytics_custom_module = "winkle" - expected = "organizations/{organization}/locations/{location}/effectiveSecurityHealthAnalyticsCustomModules/{effective_security_health_analytics_custom_module}".format(organization=organization, location=location, effective_security_health_analytics_custom_module=effective_security_health_analytics_custom_module, ) - actual = SecurityCenterManagementClient.effective_security_health_analytics_custom_module_path(organization, location, effective_security_health_analytics_custom_module) - assert expected == actual - - -def test_parse_effective_security_health_analytics_custom_module_path(): - expected = { - "organization": "nautilus", - "location": "scallop", - "effective_security_health_analytics_custom_module": "abalone", - } - path = SecurityCenterManagementClient.effective_security_health_analytics_custom_module_path(**expected) - - # Check that the path construction is reversible. - actual = SecurityCenterManagementClient.parse_effective_security_health_analytics_custom_module_path(path) - assert expected == actual - -def test_event_threat_detection_custom_module_path(): - organization = "squid" - location = "clam" - event_threat_detection_custom_module = "whelk" - expected = "organizations/{organization}/locations/{location}/eventThreatDetectionCustomModules/{event_threat_detection_custom_module}".format(organization=organization, location=location, event_threat_detection_custom_module=event_threat_detection_custom_module, ) - actual = SecurityCenterManagementClient.event_threat_detection_custom_module_path(organization, location, event_threat_detection_custom_module) - assert expected == actual - - -def test_parse_event_threat_detection_custom_module_path(): - expected = { - "organization": "octopus", - "location": "oyster", - "event_threat_detection_custom_module": "nudibranch", - } - path = SecurityCenterManagementClient.event_threat_detection_custom_module_path(**expected) - - # Check that the path construction is reversible. - actual = SecurityCenterManagementClient.parse_event_threat_detection_custom_module_path(path) - assert expected == actual - -def test_finding_path(): - organization = "cuttlefish" - source = "mussel" - finding = "winkle" - expected = "organizations/{organization}/sources/{source}/findings/{finding}".format(organization=organization, source=source, finding=finding, ) - actual = SecurityCenterManagementClient.finding_path(organization, source, finding) - assert expected == actual - - -def test_parse_finding_path(): - expected = { - "organization": "nautilus", - "source": "scallop", - "finding": "abalone", - } - path = SecurityCenterManagementClient.finding_path(**expected) - - # Check that the path construction is reversible. - actual = SecurityCenterManagementClient.parse_finding_path(path) - assert expected == actual - -def test_security_health_analytics_custom_module_path(): - organization = "squid" - location = "clam" - security_health_analytics_custom_module = "whelk" - expected = "organizations/{organization}/locations/{location}/securityHealthAnalyticsCustomModules/{security_health_analytics_custom_module}".format(organization=organization, location=location, security_health_analytics_custom_module=security_health_analytics_custom_module, ) - actual = SecurityCenterManagementClient.security_health_analytics_custom_module_path(organization, location, security_health_analytics_custom_module) - assert expected == actual - - -def test_parse_security_health_analytics_custom_module_path(): - expected = { - "organization": "octopus", - "location": "oyster", - "security_health_analytics_custom_module": "nudibranch", - } - path = SecurityCenterManagementClient.security_health_analytics_custom_module_path(**expected) - - # Check that the path construction is reversible. - actual = SecurityCenterManagementClient.parse_security_health_analytics_custom_module_path(path) - assert expected == actual - -def test_common_billing_account_path(): - billing_account = "cuttlefish" - expected = "billingAccounts/{billing_account}".format(billing_account=billing_account, ) - actual = SecurityCenterManagementClient.common_billing_account_path(billing_account) - assert expected == actual - - -def test_parse_common_billing_account_path(): - expected = { - "billing_account": "mussel", - } - path = SecurityCenterManagementClient.common_billing_account_path(**expected) - - # Check that the path construction is reversible. - actual = SecurityCenterManagementClient.parse_common_billing_account_path(path) - assert expected == actual - -def test_common_folder_path(): - folder = "winkle" - expected = "folders/{folder}".format(folder=folder, ) - actual = SecurityCenterManagementClient.common_folder_path(folder) - assert expected == actual - - -def test_parse_common_folder_path(): - expected = { - "folder": "nautilus", - } - path = SecurityCenterManagementClient.common_folder_path(**expected) - - # Check that the path construction is reversible. - actual = SecurityCenterManagementClient.parse_common_folder_path(path) - assert expected == actual - -def test_common_organization_path(): - organization = "scallop" - expected = "organizations/{organization}".format(organization=organization, ) - actual = SecurityCenterManagementClient.common_organization_path(organization) - assert expected == actual - - -def test_parse_common_organization_path(): - expected = { - "organization": "abalone", - } - path = SecurityCenterManagementClient.common_organization_path(**expected) - - # Check that the path construction is reversible. - actual = SecurityCenterManagementClient.parse_common_organization_path(path) - assert expected == actual - -def test_common_project_path(): - project = "squid" - expected = "projects/{project}".format(project=project, ) - actual = SecurityCenterManagementClient.common_project_path(project) - assert expected == actual - - -def test_parse_common_project_path(): - expected = { - "project": "clam", - } - path = SecurityCenterManagementClient.common_project_path(**expected) - - # Check that the path construction is reversible. - actual = SecurityCenterManagementClient.parse_common_project_path(path) - assert expected == actual - -def test_common_location_path(): - project = "whelk" - location = "octopus" - expected = "projects/{project}/locations/{location}".format(project=project, location=location, ) - actual = SecurityCenterManagementClient.common_location_path(project, location) - assert expected == actual - - -def test_parse_common_location_path(): - expected = { - "project": "oyster", - "location": "nudibranch", - } - path = SecurityCenterManagementClient.common_location_path(**expected) - - # Check that the path construction is reversible. - actual = SecurityCenterManagementClient.parse_common_location_path(path) - assert expected == actual - - -def test_client_with_default_client_info(): - client_info = gapic_v1.client_info.ClientInfo() - - with mock.patch.object(transports.SecurityCenterManagementTransport, '_prep_wrapped_messages') as prep: - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - client_info=client_info, - ) - prep.assert_called_once_with(client_info) - - with mock.patch.object(transports.SecurityCenterManagementTransport, '_prep_wrapped_messages') as prep: - transport_class = SecurityCenterManagementClient.get_transport_class() - transport = transport_class( - credentials=ga_credentials.AnonymousCredentials(), - client_info=client_info, - ) - prep.assert_called_once_with(client_info) - -@pytest.mark.asyncio -async def test_transport_close_async(): - client = SecurityCenterManagementAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc_asyncio", - ) - with mock.patch.object(type(getattr(client.transport, "grpc_channel")), "close") as close: - async with client: - close.assert_not_called() - close.assert_called_once() - - -def test_get_location_rest_bad_request(transport: str = 'rest', request_type=locations_pb2.GetLocationRequest): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - request = request_type() - request = json_format.ParseDict({'name': 'projects/sample1/locations/sample2'}, request) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.get_location(request) - -@pytest.mark.parametrize("request_type", [ - locations_pb2.GetLocationRequest, - dict, -]) -def test_get_location_rest(request_type): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - request_init = {'name': 'projects/sample1/locations/sample2'} - request = request_type(**request_init) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = locations_pb2.Location() - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.get_location(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, locations_pb2.Location) - -def test_list_locations_rest_bad_request(transport: str = 'rest', request_type=locations_pb2.ListLocationsRequest): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - request = request_type() - request = json_format.ParseDict({'name': 'projects/sample1'}, request) - - # Mock the http request call within the method and fake a BadRequest error. - with mock.patch.object(Session, 'request') as req, pytest.raises(core_exceptions.BadRequest): - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 400 - response_value.request = Request() - req.return_value = response_value - client.list_locations(request) - -@pytest.mark.parametrize("request_type", [ - locations_pb2.ListLocationsRequest, - dict, -]) -def test_list_locations_rest(request_type): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="rest", - ) - request_init = {'name': 'projects/sample1'} - request = request_type(**request_init) - # Mock the http request call within the method and fake a response. - with mock.patch.object(type(client.transport._session), 'request') as req: - # Designate an appropriate value for the returned response. - return_value = locations_pb2.ListLocationsResponse() - - # Wrap the value into a proper Response obj - response_value = Response() - response_value.status_code = 200 - json_return_value = json_format.MessageToJson(return_value) - - response_value._content = json_return_value.encode('UTF-8') - req.return_value = response_value - - response = client.list_locations(request) - - # Establish that the response is the type that we expect. - assert isinstance(response, locations_pb2.ListLocationsResponse) - - -def test_list_locations(transport: str = "grpc"): - client = SecurityCenterManagementClient( - 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 = locations_pb2.ListLocationsRequest() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_locations), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = locations_pb2.ListLocationsResponse() - response = client.list_locations(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 response is the type that we expect. - assert isinstance(response, locations_pb2.ListLocationsResponse) -@pytest.mark.asyncio -async def test_list_locations_async(transport: str = "grpc_asyncio"): - client = SecurityCenterManagementAsyncClient( - 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 = locations_pb2.ListLocationsRequest() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_locations), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - locations_pb2.ListLocationsResponse() - ) - response = await client.list_locations(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 response is the type that we expect. - assert isinstance(response, locations_pb2.ListLocationsResponse) - -def test_list_locations_field_headers(): - client = SecurityCenterManagementClient( - 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 = locations_pb2.ListLocationsRequest() - request.name = "locations" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_locations), "__call__") as call: - call.return_value = locations_pb2.ListLocationsResponse() - - client.list_locations(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=locations",) in kw["metadata"] -@pytest.mark.asyncio -async def test_list_locations_field_headers_async(): - client = SecurityCenterManagementAsyncClient( - 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 = locations_pb2.ListLocationsRequest() - request.name = "locations" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_locations), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - locations_pb2.ListLocationsResponse() - ) - await client.list_locations(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=locations",) in kw["metadata"] - -def test_list_locations_from_dict(): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_locations), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = locations_pb2.ListLocationsResponse() - - response = client.list_locations( - request={ - "name": "locations", - } - ) - call.assert_called() -@pytest.mark.asyncio -async def test_list_locations_from_dict_async(): - client = SecurityCenterManagementAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_locations), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - locations_pb2.ListLocationsResponse() - ) - response = await client.list_locations( - request={ - "name": "locations", - } - ) - call.assert_called() - - -def test_get_location(transport: str = "grpc"): - client = SecurityCenterManagementClient( - 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 = locations_pb2.GetLocationRequest() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_location), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = locations_pb2.Location() - response = client.get_location(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 response is the type that we expect. - assert isinstance(response, locations_pb2.Location) -@pytest.mark.asyncio -async def test_get_location_async(transport: str = "grpc_asyncio"): - client = SecurityCenterManagementAsyncClient( - 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 = locations_pb2.GetLocationRequest() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_location), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - locations_pb2.Location() - ) - response = await client.get_location(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 response is the type that we expect. - assert isinstance(response, locations_pb2.Location) - -def test_get_location_field_headers(): - client = SecurityCenterManagementClient( - 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 = locations_pb2.GetLocationRequest() - request.name = "locations/abc" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_location), "__call__") as call: - call.return_value = locations_pb2.Location() - - client.get_location(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=locations/abc",) in kw["metadata"] -@pytest.mark.asyncio -async def test_get_location_field_headers_async(): - client = SecurityCenterManagementAsyncClient( - 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 = locations_pb2.GetLocationRequest() - request.name = "locations/abc" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.get_location), "__call__") as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - locations_pb2.Location() - ) - await client.get_location(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=locations/abc",) in kw["metadata"] - -def test_get_location_from_dict(): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_locations), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = locations_pb2.Location() - - response = client.get_location( - request={ - "name": "locations/abc", - } - ) - call.assert_called() -@pytest.mark.asyncio -async def test_get_location_from_dict_async(): - client = SecurityCenterManagementAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.list_locations), "__call__") as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - locations_pb2.Location() - ) - response = await client.get_location( - request={ - "name": "locations", - } - ) - call.assert_called() - - -def test_transport_close(): - transports = { - "rest": "_session", - "grpc": "_grpc_channel", - } - - for transport, close_name in transports.items(): - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport - ) - with mock.patch.object(type(getattr(client.transport, close_name)), "close") as close: - with client: - close.assert_not_called() - close.assert_called_once() - -def test_client_ctx(): - transports = [ - 'rest', - 'grpc', - ] - for transport in transports: - client = SecurityCenterManagementClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport - ) - # Test client calls underlying transport. - with mock.patch.object(type(client.transport), "close") as close: - close.assert_not_called() - with client: - pass - close.assert_called() - -@pytest.mark.parametrize("client_class,transport_class", [ - (SecurityCenterManagementClient, transports.SecurityCenterManagementGrpcTransport), - (SecurityCenterManagementAsyncClient, transports.SecurityCenterManagementGrpcAsyncIOTransport), -]) -def test_api_key_credentials(client_class, transport_class): - with mock.patch.object( - google.auth._default, "get_api_key_credentials", create=True - ) as get_api_key_credentials: - mock_cred = mock.Mock() - get_api_key_credentials.return_value = mock_cred - options = client_options.ClientOptions() - options.api_key = "api_key" - with mock.patch.object(transport_class, "__init__") as patched: - patched.return_value = None - client = client_class(client_options=options) - patched.assert_called_once_with( - credentials=mock_cred, - credentials_file=None, - host=client.DEFAULT_ENDPOINT, - scopes=None, - client_cert_source_for_mtls=None, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - always_use_jwt_access=True, - api_audience=None, - ) diff --git a/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement/gapic_version.py b/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement/gapic_version.py index 123d60293175..360a0d13ebdd 100644 --- a/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement/gapic_version.py +++ b/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.1.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement_v1/gapic_version.py b/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement_v1/gapic_version.py index 123d60293175..360a0d13ebdd 100644 --- a/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement_v1/gapic_version.py +++ b/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.1.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement_v1/services/security_center_management/async_client.py b/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement_v1/services/security_center_management/async_client.py index e98a7165c9a0..1b8751f438b4 100644 --- a/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement_v1/services/security_center_management/async_client.py +++ b/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement_v1/services/security_center_management/async_client.py @@ -1502,16 +1502,10 @@ async def list_effective_event_threat_detection_custom_modules( timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListEffectiveEventThreatDetectionCustomModulesAsyncPager: - r"""Returns a list of all EffectiveEventThreatDetectionCustomModules - for the given parent. This includes resident modules defined at - the scope of the parent, and inherited modules, inherited from - CRM ancestors (no descendants). The difference between an - EffectiveCustomModule and a CustomModule is that the fields for - an EffectiveCustomModule are computed from ancestors if needed. - For example, the enablement_state for a CustomModule can be - either ENABLED, DISABLED, or INHERITED. Where as the - enablement_state for an EffectiveCustomModule is always computed - to ENABLED or DISABLED (the effective enablement_state). + r"""Lists all effective Event Threat Detection custom + modules for the given parent. This includes resident + modules defined at the scope of the parent along with + modules inherited from its ancestors. .. code-block:: python @@ -1789,11 +1783,10 @@ async def list_event_threat_detection_custom_modules( timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListEventThreatDetectionCustomModulesAsyncPager: - r"""Returns a list of all - EventThreatDetectionCustomModules for the given parent. - This includes resident modules defined at the scope of - the parent, and inherited modules, inherited from CRM - ancestors (no descendants). + r"""Lists all Event Threat Detection custom modules for + the given Resource Manager parent. This includes + resident modules defined at the scope of the parent + along with modules inherited from ancestors. .. code-block:: python @@ -1931,9 +1924,9 @@ async def list_descendant_event_threat_detection_custom_modules( timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListDescendantEventThreatDetectionCustomModulesAsyncPager: - r"""Returns a list of all resident - EventThreatDetectionCustomModules under the given CRM - parent and all of the parent’s CRM descendants. + r"""Lists all resident Event Threat Detection custom + modules under the given Resource Manager parent and its + descendants. .. code-block:: python @@ -2072,14 +2065,7 @@ async def get_event_threat_detection_custom_module( timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> security_center_management.EventThreatDetectionCustomModule: - r"""Gets an ETD custom module. Retrieves the module at the given - level. The difference between an EffectiveCustomModule and a - CustomModule is that the fields for an EffectiveCustomModule are - computed from ancestors if needed. For example, the - enablement_state for a CustomModule can be either ENABLED, - DISABLED, or INHERITED. Where as the enablement_state for an - EffectiveCustomModule is always computed to ENABLED or DISABLED - (the effective enablement_state). + r"""Gets an Event Threat Detection custom module. .. code-block:: python @@ -2210,9 +2196,11 @@ async def create_event_threat_detection_custom_module( timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> security_center_management.EventThreatDetectionCustomModule: - r"""Creates an ETD custom module at the given level. - Creating a module has a side-effect of creating modules - at all descendants. + r"""Creates a resident Event Threat Detection custom + module at the scope of the given Resource Manager + parent, and also creates inherited custom modules for + all descendants of the given parent. These modules are + enabled by default. .. code-block:: python @@ -2346,12 +2334,14 @@ async def update_event_threat_detection_custom_module( timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> security_center_management.EventThreatDetectionCustomModule: - r"""Updates an ETD custom module at the given level. All - config fields can be updated when updating the module at - resident level. Only enablement state can be updated - when updating the module at inherited levels. Updating - the module has a side-effect that it updates all - descendants that are inherited from this module. + r"""Updates the Event Threat Detection custom module with + the given name based on the given update mask. Updating + the enablement state is supported for both resident and + inherited modules (though resident modules cannot have + an enablement state of "inherited"). Updating the + display name or configuration of a module is supported + for resident modules only. The type of a module cannot + be changed. .. code-block:: python @@ -2486,9 +2476,10 @@ async def delete_event_threat_detection_custom_module( timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> None: - r"""Deletes an ETD custom module. Deletion at resident - level also deletes modules at all descendants. Deletion - at any other level is not supported. + r"""Deletes the specified Event Threat Detection custom + module and all of its descendants in the Resource + Manager hierarchy. This method is only supported for + resident custom modules. .. code-block:: python diff --git a/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement_v1/services/security_center_management/client.py b/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement_v1/services/security_center_management/client.py index c5d7c9a8ae28..a2bdb1391fa4 100644 --- a/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement_v1/services/security_center_management/client.py +++ b/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement_v1/services/security_center_management/client.py @@ -1771,16 +1771,10 @@ def list_effective_event_threat_detection_custom_modules( timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListEffectiveEventThreatDetectionCustomModulesPager: - r"""Returns a list of all EffectiveEventThreatDetectionCustomModules - for the given parent. This includes resident modules defined at - the scope of the parent, and inherited modules, inherited from - CRM ancestors (no descendants). The difference between an - EffectiveCustomModule and a CustomModule is that the fields for - an EffectiveCustomModule are computed from ancestors if needed. - For example, the enablement_state for a CustomModule can be - either ENABLED, DISABLED, or INHERITED. Where as the - enablement_state for an EffectiveCustomModule is always computed - to ENABLED or DISABLED (the effective enablement_state). + r"""Lists all effective Event Threat Detection custom + modules for the given parent. This includes resident + modules defined at the scope of the parent along with + modules inherited from its ancestors. .. code-block:: python @@ -2048,11 +2042,10 @@ def list_event_threat_detection_custom_modules( timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListEventThreatDetectionCustomModulesPager: - r"""Returns a list of all - EventThreatDetectionCustomModules for the given parent. - This includes resident modules defined at the scope of - the parent, and inherited modules, inherited from CRM - ancestors (no descendants). + r"""Lists all Event Threat Detection custom modules for + the given Resource Manager parent. This includes + resident modules defined at the scope of the parent + along with modules inherited from ancestors. .. code-block:: python @@ -2185,9 +2178,9 @@ def list_descendant_event_threat_detection_custom_modules( timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListDescendantEventThreatDetectionCustomModulesPager: - r"""Returns a list of all resident - EventThreatDetectionCustomModules under the given CRM - parent and all of the parent’s CRM descendants. + r"""Lists all resident Event Threat Detection custom + modules under the given Resource Manager parent and its + descendants. .. code-block:: python @@ -2321,14 +2314,7 @@ def get_event_threat_detection_custom_module( timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> security_center_management.EventThreatDetectionCustomModule: - r"""Gets an ETD custom module. Retrieves the module at the given - level. The difference between an EffectiveCustomModule and a - CustomModule is that the fields for an EffectiveCustomModule are - computed from ancestors if needed. For example, the - enablement_state for a CustomModule can be either ENABLED, - DISABLED, or INHERITED. Where as the enablement_state for an - EffectiveCustomModule is always computed to ENABLED or DISABLED - (the effective enablement_state). + r"""Gets an Event Threat Detection custom module. .. code-block:: python @@ -2456,9 +2442,11 @@ def create_event_threat_detection_custom_module( timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> security_center_management.EventThreatDetectionCustomModule: - r"""Creates an ETD custom module at the given level. - Creating a module has a side-effect of creating modules - at all descendants. + r"""Creates a resident Event Threat Detection custom + module at the scope of the given Resource Manager + parent, and also creates inherited custom modules for + all descendants of the given parent. These modules are + enabled by default. .. code-block:: python @@ -2595,12 +2583,14 @@ def update_event_threat_detection_custom_module( timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> security_center_management.EventThreatDetectionCustomModule: - r"""Updates an ETD custom module at the given level. All - config fields can be updated when updating the module at - resident level. Only enablement state can be updated - when updating the module at inherited levels. Updating - the module has a side-effect that it updates all - descendants that are inherited from this module. + r"""Updates the Event Threat Detection custom module with + the given name based on the given update mask. Updating + the enablement state is supported for both resident and + inherited modules (though resident modules cannot have + an enablement state of "inherited"). Updating the + display name or configuration of a module is supported + for resident modules only. The type of a module cannot + be changed. .. code-block:: python @@ -2738,9 +2728,10 @@ def delete_event_threat_detection_custom_module( timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> None: - r"""Deletes an ETD custom module. Deletion at resident - level also deletes modules at all descendants. Deletion - at any other level is not supported. + r"""Deletes the specified Event Threat Detection custom + module and all of its descendants in the Resource + Manager hierarchy. This method is only supported for + resident custom modules. .. code-block:: python diff --git a/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/grpc.py b/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/grpc.py index 2e1a63be9cb8..a7bdb5c28299 100644 --- a/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/grpc.py +++ b/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/grpc.py @@ -565,16 +565,10 @@ def list_effective_event_threat_detection_custom_modules( r"""Return a callable for the list effective event threat detection custom modules method over gRPC. - Returns a list of all EffectiveEventThreatDetectionCustomModules - for the given parent. This includes resident modules defined at - the scope of the parent, and inherited modules, inherited from - CRM ancestors (no descendants). The difference between an - EffectiveCustomModule and a CustomModule is that the fields for - an EffectiveCustomModule are computed from ancestors if needed. - For example, the enablement_state for a CustomModule can be - either ENABLED, DISABLED, or INHERITED. Where as the - enablement_state for an EffectiveCustomModule is always computed - to ENABLED or DISABLED (the effective enablement_state). + Lists all effective Event Threat Detection custom + modules for the given parent. This includes resident + modules defined at the scope of the parent along with + modules inherited from its ancestors. Returns: Callable[[~.ListEffectiveEventThreatDetectionCustomModulesRequest], @@ -647,11 +641,10 @@ def list_event_threat_detection_custom_modules( r"""Return a callable for the list event threat detection custom modules method over gRPC. - Returns a list of all - EventThreatDetectionCustomModules for the given parent. - This includes resident modules defined at the scope of - the parent, and inherited modules, inherited from CRM - ancestors (no descendants). + Lists all Event Threat Detection custom modules for + the given Resource Manager parent. This includes + resident modules defined at the scope of the parent + along with modules inherited from ancestors. Returns: Callable[[~.ListEventThreatDetectionCustomModulesRequest], @@ -685,9 +678,9 @@ def list_descendant_event_threat_detection_custom_modules( r"""Return a callable for the list descendant event threat detection custom modules method over gRPC. - Returns a list of all resident - EventThreatDetectionCustomModules under the given CRM - parent and all of the parent’s CRM descendants. + Lists all resident Event Threat Detection custom + modules under the given Resource Manager parent and its + descendants. Returns: Callable[[~.ListDescendantEventThreatDetectionCustomModulesRequest], @@ -719,14 +712,7 @@ def get_event_threat_detection_custom_module( r"""Return a callable for the get event threat detection custom module method over gRPC. - Gets an ETD custom module. Retrieves the module at the given - level. The difference between an EffectiveCustomModule and a - CustomModule is that the fields for an EffectiveCustomModule are - computed from ancestors if needed. For example, the - enablement_state for a CustomModule can be either ENABLED, - DISABLED, or INHERITED. Where as the enablement_state for an - EffectiveCustomModule is always computed to ENABLED or DISABLED - (the effective enablement_state). + Gets an Event Threat Detection custom module. Returns: Callable[[~.GetEventThreatDetectionCustomModuleRequest], @@ -758,9 +744,11 @@ def create_event_threat_detection_custom_module( r"""Return a callable for the create event threat detection custom module method over gRPC. - Creates an ETD custom module at the given level. - Creating a module has a side-effect of creating modules - at all descendants. + Creates a resident Event Threat Detection custom + module at the scope of the given Resource Manager + parent, and also creates inherited custom modules for + all descendants of the given parent. These modules are + enabled by default. Returns: Callable[[~.CreateEventThreatDetectionCustomModuleRequest], @@ -792,12 +780,14 @@ def update_event_threat_detection_custom_module( r"""Return a callable for the update event threat detection custom module method over gRPC. - Updates an ETD custom module at the given level. All - config fields can be updated when updating the module at - resident level. Only enablement state can be updated - when updating the module at inherited levels. Updating - the module has a side-effect that it updates all - descendants that are inherited from this module. + Updates the Event Threat Detection custom module with + the given name based on the given update mask. Updating + the enablement state is supported for both resident and + inherited modules (though resident modules cannot have + an enablement state of "inherited"). Updating the + display name or configuration of a module is supported + for resident modules only. The type of a module cannot + be changed. Returns: Callable[[~.UpdateEventThreatDetectionCustomModuleRequest], @@ -829,9 +819,10 @@ def delete_event_threat_detection_custom_module( r"""Return a callable for the delete event threat detection custom module method over gRPC. - Deletes an ETD custom module. Deletion at resident - level also deletes modules at all descendants. Deletion - at any other level is not supported. + Deletes the specified Event Threat Detection custom + module and all of its descendants in the Resource + Manager hierarchy. This method is only supported for + resident custom modules. Returns: Callable[[~.DeleteEventThreatDetectionCustomModuleRequest], diff --git a/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/grpc_asyncio.py b/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/grpc_asyncio.py index bfee6adb5aa2..c2c1e991d521 100644 --- a/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/grpc_asyncio.py +++ b/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement_v1/services/security_center_management/transports/grpc_asyncio.py @@ -580,16 +580,10 @@ def list_effective_event_threat_detection_custom_modules( r"""Return a callable for the list effective event threat detection custom modules method over gRPC. - Returns a list of all EffectiveEventThreatDetectionCustomModules - for the given parent. This includes resident modules defined at - the scope of the parent, and inherited modules, inherited from - CRM ancestors (no descendants). The difference between an - EffectiveCustomModule and a CustomModule is that the fields for - an EffectiveCustomModule are computed from ancestors if needed. - For example, the enablement_state for a CustomModule can be - either ENABLED, DISABLED, or INHERITED. Where as the - enablement_state for an EffectiveCustomModule is always computed - to ENABLED or DISABLED (the effective enablement_state). + Lists all effective Event Threat Detection custom + modules for the given parent. This includes resident + modules defined at the scope of the parent along with + modules inherited from its ancestors. Returns: Callable[[~.ListEffectiveEventThreatDetectionCustomModulesRequest], @@ -664,11 +658,10 @@ def list_event_threat_detection_custom_modules( r"""Return a callable for the list event threat detection custom modules method over gRPC. - Returns a list of all - EventThreatDetectionCustomModules for the given parent. - This includes resident modules defined at the scope of - the parent, and inherited modules, inherited from CRM - ancestors (no descendants). + Lists all Event Threat Detection custom modules for + the given Resource Manager parent. This includes + resident modules defined at the scope of the parent + along with modules inherited from ancestors. Returns: Callable[[~.ListEventThreatDetectionCustomModulesRequest], @@ -704,9 +697,9 @@ def list_descendant_event_threat_detection_custom_modules( r"""Return a callable for the list descendant event threat detection custom modules method over gRPC. - Returns a list of all resident - EventThreatDetectionCustomModules under the given CRM - parent and all of the parent’s CRM descendants. + Lists all resident Event Threat Detection custom + modules under the given Resource Manager parent and its + descendants. Returns: Callable[[~.ListDescendantEventThreatDetectionCustomModulesRequest], @@ -738,14 +731,7 @@ def get_event_threat_detection_custom_module( r"""Return a callable for the get event threat detection custom module method over gRPC. - Gets an ETD custom module. Retrieves the module at the given - level. The difference between an EffectiveCustomModule and a - CustomModule is that the fields for an EffectiveCustomModule are - computed from ancestors if needed. For example, the - enablement_state for a CustomModule can be either ENABLED, - DISABLED, or INHERITED. Where as the enablement_state for an - EffectiveCustomModule is always computed to ENABLED or DISABLED - (the effective enablement_state). + Gets an Event Threat Detection custom module. Returns: Callable[[~.GetEventThreatDetectionCustomModuleRequest], @@ -777,9 +763,11 @@ def create_event_threat_detection_custom_module( r"""Return a callable for the create event threat detection custom module method over gRPC. - Creates an ETD custom module at the given level. - Creating a module has a side-effect of creating modules - at all descendants. + Creates a resident Event Threat Detection custom + module at the scope of the given Resource Manager + parent, and also creates inherited custom modules for + all descendants of the given parent. These modules are + enabled by default. Returns: Callable[[~.CreateEventThreatDetectionCustomModuleRequest], @@ -811,12 +799,14 @@ def update_event_threat_detection_custom_module( r"""Return a callable for the update event threat detection custom module method over gRPC. - Updates an ETD custom module at the given level. All - config fields can be updated when updating the module at - resident level. Only enablement state can be updated - when updating the module at inherited levels. Updating - the module has a side-effect that it updates all - descendants that are inherited from this module. + Updates the Event Threat Detection custom module with + the given name based on the given update mask. Updating + the enablement state is supported for both resident and + inherited modules (though resident modules cannot have + an enablement state of "inherited"). Updating the + display name or configuration of a module is supported + for resident modules only. The type of a module cannot + be changed. Returns: Callable[[~.UpdateEventThreatDetectionCustomModuleRequest], @@ -848,9 +838,10 @@ def delete_event_threat_detection_custom_module( r"""Return a callable for the delete event threat detection custom module method over gRPC. - Deletes an ETD custom module. Deletion at resident - level also deletes modules at all descendants. Deletion - at any other level is not supported. + Deletes the specified Event Threat Detection custom + module and all of its descendants in the Resource + Manager hierarchy. This method is only supported for + resident custom modules. Returns: Callable[[~.DeleteEventThreatDetectionCustomModuleRequest], diff --git a/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement_v1/types/security_center_management.py b/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement_v1/types/security_center_management.py index d748fa095475..1e023348626a 100644 --- a/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement_v1/types/security_center_management.py +++ b/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement_v1/types/security_center_management.py @@ -689,9 +689,10 @@ class UpdateSecurityHealthAnalyticsCustomModuleRequest(proto.Message): indicates the request is valid while an error response indicates the request is invalid. Note that a subsequent request to actually update the - module could still fail because: - 1. the state could have changed (e.g. IAM permission lost) or - 2. A failure occurred while trying to update the module. + module could still fail because 1. the state + could have changed (e.g. IAM permission lost) or + 2. A failure occurred while trying to update the + module. """ update_mask: field_mask_pb2.FieldMask = proto.Field( @@ -731,9 +732,10 @@ class DeleteSecurityHealthAnalyticsCustomModuleRequest(proto.Message): indicates the request is valid while an error response indicates the request is invalid. Note that a subsequent request to actually delete the - module could still fail because: - 1. the state could have changed (e.g. IAM permission lost) or - 2. A failure occurred while trying to delete the module. + module could still fail because 1. the state + could have changed (e.g. IAM permission lost) or + 2. A failure occurred while trying to delete the + module. """ name: str = proto.Field( @@ -1570,9 +1572,10 @@ class CreateEventThreatDetectionCustomModuleRequest(proto.Message): indicates the request is valid while an error response indicates the request is invalid. Note that a subsequent request to actually create the - module could still fail because: - 1. the state could have changed (e.g. IAM permission lost) or - 2. A failure occurred during creation of the module. + module could still fail because 1. the state + could have changed (e.g. IAM permission lost) or + 2. A failure occurred during creation of the + module. """ parent: str = proto.Field( @@ -1612,9 +1615,10 @@ class UpdateEventThreatDetectionCustomModuleRequest(proto.Message): indicates the request is valid while an error response indicates the request is invalid. Note that a subsequent request to actually update the - module could still fail because: - 1. the state could have changed (e.g. IAM permission lost) or - 2. A failure occurred while trying to update the module. + module could still fail because 1. the state + could have changed (e.g. IAM permission lost) or + 2. A failure occurred while trying to update the + module. """ update_mask: field_mask_pb2.FieldMask = proto.Field( @@ -1654,9 +1658,10 @@ class DeleteEventThreatDetectionCustomModuleRequest(proto.Message): indicates the request is valid while an error response indicates the request is invalid. Note that a subsequent request to actually delete the - module could still fail because: - 1. the state could have changed (e.g. IAM permission lost) or - 2. A failure occurred while trying to delete the module. + module could still fail because 1. the state + could have changed (e.g. IAM permission lost) or + 2. A failure occurred while trying to delete the + module. """ name: str = proto.Field( diff --git a/packages/google-cloud-securitycentermanagement/samples/generated_samples/snippet_metadata_google.cloud.securitycentermanagement.v1.json b/packages/google-cloud-securitycentermanagement/samples/generated_samples/snippet_metadata_google.cloud.securitycentermanagement.v1.json index 970ffb255ded..8e50d8fef945 100644 --- a/packages/google-cloud-securitycentermanagement/samples/generated_samples/snippet_metadata_google.cloud.securitycentermanagement.v1.json +++ b/packages/google-cloud-securitycentermanagement/samples/generated_samples/snippet_metadata_google.cloud.securitycentermanagement.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-securitycentermanagement", - "version": "0.1.1" + "version": "0.1.0" }, "snippets": [ { From 9d1e513f11c4404010a2656b9901372e44717562 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Fri, 5 Jan 2024 09:07:23 -0500 Subject: [PATCH 3/3] revert --- .../types/security_center_management.py | 35 ++++++++----------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement_v1/types/security_center_management.py b/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement_v1/types/security_center_management.py index 1e023348626a..d748fa095475 100644 --- a/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement_v1/types/security_center_management.py +++ b/packages/google-cloud-securitycentermanagement/google/cloud/securitycentermanagement_v1/types/security_center_management.py @@ -689,10 +689,9 @@ class UpdateSecurityHealthAnalyticsCustomModuleRequest(proto.Message): indicates the request is valid while an error response indicates the request is invalid. Note that a subsequent request to actually update the - module could still fail because 1. the state - could have changed (e.g. IAM permission lost) or - 2. A failure occurred while trying to update the - module. + module could still fail because: + 1. the state could have changed (e.g. IAM permission lost) or + 2. A failure occurred while trying to update the module. """ update_mask: field_mask_pb2.FieldMask = proto.Field( @@ -732,10 +731,9 @@ class DeleteSecurityHealthAnalyticsCustomModuleRequest(proto.Message): indicates the request is valid while an error response indicates the request is invalid. Note that a subsequent request to actually delete the - module could still fail because 1. the state - could have changed (e.g. IAM permission lost) or - 2. A failure occurred while trying to delete the - module. + module could still fail because: + 1. the state could have changed (e.g. IAM permission lost) or + 2. A failure occurred while trying to delete the module. """ name: str = proto.Field( @@ -1572,10 +1570,9 @@ class CreateEventThreatDetectionCustomModuleRequest(proto.Message): indicates the request is valid while an error response indicates the request is invalid. Note that a subsequent request to actually create the - module could still fail because 1. the state - could have changed (e.g. IAM permission lost) or - 2. A failure occurred during creation of the - module. + module could still fail because: + 1. the state could have changed (e.g. IAM permission lost) or + 2. A failure occurred during creation of the module. """ parent: str = proto.Field( @@ -1615,10 +1612,9 @@ class UpdateEventThreatDetectionCustomModuleRequest(proto.Message): indicates the request is valid while an error response indicates the request is invalid. Note that a subsequent request to actually update the - module could still fail because 1. the state - could have changed (e.g. IAM permission lost) or - 2. A failure occurred while trying to update the - module. + module could still fail because: + 1. the state could have changed (e.g. IAM permission lost) or + 2. A failure occurred while trying to update the module. """ update_mask: field_mask_pb2.FieldMask = proto.Field( @@ -1658,10 +1654,9 @@ class DeleteEventThreatDetectionCustomModuleRequest(proto.Message): indicates the request is valid while an error response indicates the request is invalid. Note that a subsequent request to actually delete the - module could still fail because 1. the state - could have changed (e.g. IAM permission lost) or - 2. A failure occurred while trying to delete the - module. + module could still fail because: + 1. the state could have changed (e.g. IAM permission lost) or + 2. A failure occurred while trying to delete the module. """ name: str = proto.Field(