From 260c2d7c86bfd1a1a3c42bc176bfc270e95a939b Mon Sep 17 00:00:00 2001 From: yoshi-automation Date: Sat, 6 Mar 2021 08:13:10 -0800 Subject: [PATCH 01/25] fix: remove client recv msg limit fix: add enums to `types/__init__.py` PiperOrigin-RevId: 347055288 Source-Author: Google APIs Source-Date: Fri Dec 11 12:44:37 2020 -0800 Source-Repo: googleapis/googleapis Source-Sha: dd372aa22ded7a8ba6f0e03a80e06358a3fa0907 Source-Link: https://github.com/googleapis/googleapis/commit/dd372aa22ded7a8ba6f0e03a80e06358a3fa0907 --- google/cloud/errorreporting_v1beta1/__init__.py | 4 ++-- synth.metadata | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/google/cloud/errorreporting_v1beta1/__init__.py b/google/cloud/errorreporting_v1beta1/__init__.py index 8db40bd7..b6f762a3 100644 --- a/google/cloud/errorreporting_v1beta1/__init__.py +++ b/google/cloud/errorreporting_v1beta1/__init__.py @@ -51,8 +51,8 @@ "ErrorEvent", "ErrorGroup", "ErrorGroupOrder", + "ErrorGroupServiceClient", "ErrorGroupStats", - "ErrorStatsServiceClient", "GetGroupRequest", "HttpRequestContext", "ListEventsRequest", @@ -71,5 +71,5 @@ "TimedCountAlignment", "TrackingIssue", "UpdateGroupRequest", - "ErrorGroupServiceClient", + "ErrorStatsServiceClient", ) diff --git a/synth.metadata b/synth.metadata index 330ea88c..99396870 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,7 +4,7 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/python-error-reporting.git", - "sha": "b6887650c28d9fce253ed5894bb2d64a4fedae19" + "sha": "c4b168d1f4e045d72487abba88e118a15b1c99ef" } }, { From c5c9d14d1b98fde93eecf2ff3871014b70241a4c Mon Sep 17 00:00:00 2001 From: yoshi-automation Date: Sat, 6 Mar 2021 08:14:47 -0800 Subject: [PATCH 02/25] docs: put FPS table in code block PiperOrigin-RevId: 348857882 Source-Author: Google APIs Source-Date: Wed Dec 23 15:47:05 2020 -0800 Source-Repo: googleapis/googleapis Source-Sha: 2ccf8f460800e98884d1aa4ba61e344ad4cd5d04 Source-Link: https://github.com/googleapis/googleapis/commit/2ccf8f460800e98884d1aa4ba61e344ad4cd5d04 --- google/cloud/errorreporting_v1beta1/__init__.py | 4 ++-- synth.metadata | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/google/cloud/errorreporting_v1beta1/__init__.py b/google/cloud/errorreporting_v1beta1/__init__.py index b6f762a3..43fc283f 100644 --- a/google/cloud/errorreporting_v1beta1/__init__.py +++ b/google/cloud/errorreporting_v1beta1/__init__.py @@ -53,6 +53,7 @@ "ErrorGroupOrder", "ErrorGroupServiceClient", "ErrorGroupStats", + "ErrorStatsServiceClient", "GetGroupRequest", "HttpRequestContext", "ListEventsRequest", @@ -62,7 +63,6 @@ "QueryTimeRange", "ReportErrorEventRequest", "ReportErrorEventResponse", - "ReportErrorsServiceClient", "ReportedErrorEvent", "ServiceContext", "ServiceContextFilter", @@ -71,5 +71,5 @@ "TimedCountAlignment", "TrackingIssue", "UpdateGroupRequest", - "ErrorStatsServiceClient", + "ReportErrorsServiceClient", ) diff --git a/synth.metadata b/synth.metadata index 99396870..6e480a01 100644 --- a/synth.metadata +++ b/synth.metadata @@ -11,8 +11,8 @@ "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "dd372aa22ded7a8ba6f0e03a80e06358a3fa0907", - "internalRef": "347055288" + "sha": "2ccf8f460800e98884d1aa4ba61e344ad4cd5d04", + "internalRef": "348857882" } }, { From 75ea339958f084c23c63acfa2261246d9187509c Mon Sep 17 00:00:00 2001 From: yoshi-automation Date: Sat, 6 Mar 2021 08:15:51 -0800 Subject: [PATCH 03/25] chore: upgrade gapic-generator-python to 0.39.1 feat: add 'from_service_account_info' factory to clients fix: fix sphinx identifiers PiperOrigin-RevId: 350246057 Source-Author: Google APIs Source-Date: Tue Jan 5 16:44:11 2021 -0800 Source-Repo: googleapis/googleapis Source-Sha: 520682435235d9c503983a360a2090025aa47cd1 Source-Link: https://github.com/googleapis/googleapis/commit/520682435235d9c503983a360a2090025aa47cd1 --- .coveragerc | 22 ++------- .../error_group_service.rst | 6 +++ .../error_stats_service.rst | 11 +++++ .../report_errors_service.rst | 6 +++ docs/errorreporting_v1beta1/services.rst | 14 ++---- docs/errorreporting_v1beta1/types.rst | 1 + .../cloud/errorreporting_v1beta1/__init__.py | 4 +- .../error_group_service/async_client.py | 13 +++-- .../services/error_group_service/client.py | 36 ++++++++++---- .../error_stats_service/async_client.py | 20 +++++--- .../services/error_stats_service/client.py | 49 +++++++++++++------ .../services/error_stats_service/pagers.py | 32 ++++++------ .../report_errors_service/async_client.py | 9 ++-- .../services/report_errors_service/client.py | 32 +++++++++--- .../errorreporting_v1beta1/types/common.py | 12 ++--- .../types/error_group_service.py | 2 +- .../types/error_stats_service.py | 42 ++++++++-------- .../types/report_errors_service.py | 8 +-- synth.metadata | 8 ++- .../test_error_group_service.py | 28 ++++++++--- .../test_error_stats_service.py | 28 ++++++++--- .../test_report_errors_service.py | 28 ++++++++--- 22 files changed, 268 insertions(+), 143 deletions(-) create mode 100644 docs/errorreporting_v1beta1/error_group_service.rst create mode 100644 docs/errorreporting_v1beta1/error_stats_service.rst create mode 100644 docs/errorreporting_v1beta1/report_errors_service.rst diff --git a/.coveragerc b/.coveragerc index 10cb72e8..9a9b9f3e 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,27 +1,11 @@ -# -*- 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! [run] branch = True [report] fail_under = 100 show_missing = True -omit = google/cloud/errorreporting/__init__.py, .nox/* +omit = + google/cloud/errorreporting/__init__.py exclude_lines = # Re-enable the standard pragma pragma: NO COVER @@ -31,4 +15,4 @@ exclude_lines = # This is added at the module level as a safeguard for if someone # generates the code and tries to run it without pip installing. This # makes it virtually impossible to test properly. - except pkg_resources.DistributionNotFound \ No newline at end of file + except pkg_resources.DistributionNotFound diff --git a/docs/errorreporting_v1beta1/error_group_service.rst b/docs/errorreporting_v1beta1/error_group_service.rst new file mode 100644 index 00000000..dd213525 --- /dev/null +++ b/docs/errorreporting_v1beta1/error_group_service.rst @@ -0,0 +1,6 @@ +ErrorGroupService +----------------------------------- + +.. automodule:: google.cloud.errorreporting_v1beta1.services.error_group_service + :members: + :inherited-members: diff --git a/docs/errorreporting_v1beta1/error_stats_service.rst b/docs/errorreporting_v1beta1/error_stats_service.rst new file mode 100644 index 00000000..30d29e69 --- /dev/null +++ b/docs/errorreporting_v1beta1/error_stats_service.rst @@ -0,0 +1,11 @@ +ErrorStatsService +----------------------------------- + +.. automodule:: google.cloud.errorreporting_v1beta1.services.error_stats_service + :members: + :inherited-members: + + +.. automodule:: google.cloud.errorreporting_v1beta1.services.error_stats_service.pagers + :members: + :inherited-members: diff --git a/docs/errorreporting_v1beta1/report_errors_service.rst b/docs/errorreporting_v1beta1/report_errors_service.rst new file mode 100644 index 00000000..ccddb8b0 --- /dev/null +++ b/docs/errorreporting_v1beta1/report_errors_service.rst @@ -0,0 +1,6 @@ +ReportErrorsService +------------------------------------- + +.. automodule:: google.cloud.errorreporting_v1beta1.services.report_errors_service + :members: + :inherited-members: diff --git a/docs/errorreporting_v1beta1/services.rst b/docs/errorreporting_v1beta1/services.rst index a5ec3b92..e888027f 100644 --- a/docs/errorreporting_v1beta1/services.rst +++ b/docs/errorreporting_v1beta1/services.rst @@ -1,12 +1,8 @@ Services for Google Cloud Errorreporting v1beta1 API ==================================================== +.. toctree:: + :maxdepth: 2 -.. automodule:: google.cloud.errorreporting_v1beta1.services.error_group_service - :members: - :inherited-members: -.. automodule:: google.cloud.errorreporting_v1beta1.services.error_stats_service - :members: - :inherited-members: -.. automodule:: google.cloud.errorreporting_v1beta1.services.report_errors_service - :members: - :inherited-members: + error_group_service + error_stats_service + report_errors_service diff --git a/docs/errorreporting_v1beta1/types.rst b/docs/errorreporting_v1beta1/types.rst index 08851dbe..179256c7 100644 --- a/docs/errorreporting_v1beta1/types.rst +++ b/docs/errorreporting_v1beta1/types.rst @@ -3,4 +3,5 @@ Types for Google Cloud Errorreporting v1beta1 API .. automodule:: google.cloud.errorreporting_v1beta1.types :members: + :undoc-members: :show-inheritance: diff --git a/google/cloud/errorreporting_v1beta1/__init__.py b/google/cloud/errorreporting_v1beta1/__init__.py index 43fc283f..b6f762a3 100644 --- a/google/cloud/errorreporting_v1beta1/__init__.py +++ b/google/cloud/errorreporting_v1beta1/__init__.py @@ -53,7 +53,6 @@ "ErrorGroupOrder", "ErrorGroupServiceClient", "ErrorGroupStats", - "ErrorStatsServiceClient", "GetGroupRequest", "HttpRequestContext", "ListEventsRequest", @@ -63,6 +62,7 @@ "QueryTimeRange", "ReportErrorEventRequest", "ReportErrorEventResponse", + "ReportErrorsServiceClient", "ReportedErrorEvent", "ServiceContext", "ServiceContextFilter", @@ -71,5 +71,5 @@ "TimedCountAlignment", "TrackingIssue", "UpdateGroupRequest", - "ReportErrorsServiceClient", + "ErrorStatsServiceClient", ) diff --git a/google/cloud/errorreporting_v1beta1/services/error_group_service/async_client.py b/google/cloud/errorreporting_v1beta1/services/error_group_service/async_client.py index 26c03996..c44df685 100644 --- a/google/cloud/errorreporting_v1beta1/services/error_group_service/async_client.py +++ b/google/cloud/errorreporting_v1beta1/services/error_group_service/async_client.py @@ -78,6 +78,7 @@ class ErrorGroupServiceAsyncClient: ErrorGroupServiceClient.parse_common_location_path ) + from_service_account_info = ErrorGroupServiceClient.from_service_account_info from_service_account_file = ErrorGroupServiceClient.from_service_account_file from_service_account_json = from_service_account_file @@ -154,7 +155,7 @@ async def get_group( r"""Get the specified group. Args: - request (:class:`~.error_group_service.GetGroupRequest`): + request (:class:`google.cloud.errorreporting_v1beta1.types.GetGroupRequest`): The request object. A request to return an individual group. group_name (:class:`str`): @@ -164,6 +165,7 @@ async def get_group( to return a list of groups belonging to this project. Example: ``projects/my-project-123/groups/my-group`` + This corresponds to the ``group_name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -175,7 +177,7 @@ async def get_group( sent along with the request as metadata. Returns: - ~.common.ErrorGroup: + google.cloud.errorreporting_v1beta1.types.ErrorGroup: Description of a group of similar error events. @@ -233,12 +235,13 @@ async def update_group( Fails if the group does not exist. Args: - request (:class:`~.error_group_service.UpdateGroupRequest`): + request (:class:`google.cloud.errorreporting_v1beta1.types.UpdateGroupRequest`): The request object. A request to replace the existing data for the given group. - group (:class:`~.common.ErrorGroup`): + group (:class:`google.cloud.errorreporting_v1beta1.types.ErrorGroup`): Required. The group which replaces the resource on the server. + This corresponds to the ``group`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -250,7 +253,7 @@ async def update_group( sent along with the request as metadata. Returns: - ~.common.ErrorGroup: + google.cloud.errorreporting_v1beta1.types.ErrorGroup: Description of a group of similar error events. diff --git a/google/cloud/errorreporting_v1beta1/services/error_group_service/client.py b/google/cloud/errorreporting_v1beta1/services/error_group_service/client.py index d1656df2..868b2bcb 100644 --- a/google/cloud/errorreporting_v1beta1/services/error_group_service/client.py +++ b/google/cloud/errorreporting_v1beta1/services/error_group_service/client.py @@ -112,6 +112,22 @@ def _get_default_mtls_endpoint(api_endpoint): 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: + ErrorGroupServiceClient: 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 @@ -124,7 +140,7 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): kwargs: Additional arguments to pass to the constructor. Returns: - {@api.name}: The constructed client. + ErrorGroupServiceClient: The constructed client. """ credentials = service_account.Credentials.from_service_account_file(filename) kwargs["credentials"] = credentials @@ -227,10 +243,10 @@ def __init__( 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, ~.ErrorGroupServiceTransport]): The + transport (Union[str, ErrorGroupServiceTransport]): The transport to use. If set to None, a transport is chosen automatically. - client_options (client_options_lib.ClientOptions): Custom options for the + client_options (google.api_core.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 @@ -340,16 +356,17 @@ def get_group( r"""Get the specified group. Args: - request (:class:`~.error_group_service.GetGroupRequest`): + request (google.cloud.errorreporting_v1beta1.types.GetGroupRequest): The request object. A request to return an individual group. - group_name (:class:`str`): + group_name (str): The group resource name. Written as ``projects/{projectID}/groups/{group_name}``. Call ```groupStats.list`` `__ to return a list of groups belonging to this project. Example: ``projects/my-project-123/groups/my-group`` + This corresponds to the ``group_name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -361,7 +378,7 @@ def get_group( sent along with the request as metadata. Returns: - ~.common.ErrorGroup: + google.cloud.errorreporting_v1beta1.types.ErrorGroup: Description of a group of similar error events. @@ -420,12 +437,13 @@ def update_group( Fails if the group does not exist. Args: - request (:class:`~.error_group_service.UpdateGroupRequest`): + request (google.cloud.errorreporting_v1beta1.types.UpdateGroupRequest): The request object. A request to replace the existing data for the given group. - group (:class:`~.common.ErrorGroup`): + group (google.cloud.errorreporting_v1beta1.types.ErrorGroup): Required. The group which replaces the resource on the server. + This corresponds to the ``group`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -437,7 +455,7 @@ def update_group( sent along with the request as metadata. Returns: - ~.common.ErrorGroup: + google.cloud.errorreporting_v1beta1.types.ErrorGroup: Description of a group of similar error events. diff --git a/google/cloud/errorreporting_v1beta1/services/error_stats_service/async_client.py b/google/cloud/errorreporting_v1beta1/services/error_stats_service/async_client.py index 20e91256..15cb7577 100644 --- a/google/cloud/errorreporting_v1beta1/services/error_stats_service/async_client.py +++ b/google/cloud/errorreporting_v1beta1/services/error_stats_service/async_client.py @@ -81,6 +81,7 @@ class ErrorStatsServiceAsyncClient: ErrorStatsServiceClient.parse_common_location_path ) + from_service_account_info = ErrorStatsServiceClient.from_service_account_info from_service_account_file = ErrorStatsServiceClient.from_service_account_file from_service_account_json = from_service_account_file @@ -158,7 +159,7 @@ async def list_group_stats( r"""Lists the specified groups. Args: - request (:class:`~.error_stats_service.ListGroupStatsRequest`): + request (:class:`google.cloud.errorreporting_v1beta1.types.ListGroupStatsRequest`): The request object. Specifies a set of `ErrorGroupStats` to return. project_name (:class:`str`): @@ -170,10 +171,11 @@ async def list_group_stats( Example: projects/my- project-123. + This corresponds to the ``project_name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - time_range (:class:`~.error_stats_service.QueryTimeRange`): + time_range (:class:`google.cloud.errorreporting_v1beta1.types.QueryTimeRange`): Optional. List data for the given time range. If not set, a default time range is used. The field time_range_begin in the response will specify the @@ -182,6 +184,7 @@ async def list_group_stats( unless the request contains an explicit group_id list. If a group_id list is given, also ErrorGroupStats with zero occurrences are returned. + This corresponds to the ``time_range`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -193,7 +196,7 @@ async def list_group_stats( sent along with the request as metadata. Returns: - ~.pagers.ListGroupStatsAsyncPager: + google.cloud.errorreporting_v1beta1.services.error_stats_service.pagers.ListGroupStatsAsyncPager: Contains a set of requested error group stats. Iterating over this object will yield @@ -262,7 +265,7 @@ async def list_events( r"""Lists the specified events. Args: - request (:class:`~.error_stats_service.ListEventsRequest`): + request (:class:`google.cloud.errorreporting_v1beta1.types.ListEventsRequest`): The request object. Specifies a set of error events to return. project_name (:class:`str`): @@ -271,12 +274,14 @@ async def list_events( Platform project ID `__. Example: ``projects/my-project-123``. + This corresponds to the ``project_name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. group_id (:class:`str`): Required. The group for which events shall be returned. + This corresponds to the ``group_id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -288,7 +293,7 @@ async def list_events( sent along with the request as metadata. Returns: - ~.pagers.ListEventsAsyncPager: + google.cloud.errorreporting_v1beta1.services.error_stats_service.pagers.ListEventsAsyncPager: Contains a set of requested error events. Iterating over this object will yield @@ -356,7 +361,7 @@ async def delete_events( r"""Deletes all error events of a given project. Args: - request (:class:`~.error_stats_service.DeleteEventsRequest`): + request (:class:`google.cloud.errorreporting_v1beta1.types.DeleteEventsRequest`): The request object. Deletes all events in the project. project_name (:class:`str`): Required. The resource name of the Google Cloud Platform @@ -364,6 +369,7 @@ async def delete_events( Platform project ID `__. Example: ``projects/my-project-123``. + This corresponds to the ``project_name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -375,7 +381,7 @@ async def delete_events( sent along with the request as metadata. Returns: - ~.error_stats_service.DeleteEventsResponse: + google.cloud.errorreporting_v1beta1.types.DeleteEventsResponse: Response message for deleting error events. diff --git a/google/cloud/errorreporting_v1beta1/services/error_stats_service/client.py b/google/cloud/errorreporting_v1beta1/services/error_stats_service/client.py index f04fbfef..edc91a65 100644 --- a/google/cloud/errorreporting_v1beta1/services/error_stats_service/client.py +++ b/google/cloud/errorreporting_v1beta1/services/error_stats_service/client.py @@ -115,6 +115,22 @@ def _get_default_mtls_endpoint(api_endpoint): 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: + ErrorStatsServiceClient: 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 @@ -127,7 +143,7 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): kwargs: Additional arguments to pass to the constructor. Returns: - {@api.name}: The constructed client. + ErrorStatsServiceClient: The constructed client. """ credentials = service_account.Credentials.from_service_account_file(filename) kwargs["credentials"] = credentials @@ -230,10 +246,10 @@ def __init__( 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, ~.ErrorStatsServiceTransport]): The + transport (Union[str, ErrorStatsServiceTransport]): The transport to use. If set to None, a transport is chosen automatically. - client_options (client_options_lib.ClientOptions): Custom options for the + client_options (google.api_core.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 @@ -344,10 +360,10 @@ def list_group_stats( r"""Lists the specified groups. Args: - request (:class:`~.error_stats_service.ListGroupStatsRequest`): + request (google.cloud.errorreporting_v1beta1.types.ListGroupStatsRequest): The request object. Specifies a set of `ErrorGroupStats` to return. - project_name (:class:`str`): + project_name (str): Required. The resource name of the Google Cloud Platform project. Written as projects/ plus the projects/my- project-123. + This corresponds to the ``project_name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - time_range (:class:`~.error_stats_service.QueryTimeRange`): + time_range (google.cloud.errorreporting_v1beta1.types.QueryTimeRange): Optional. List data for the given time range. If not set, a default time range is used. The field time_range_begin in the response will specify the @@ -368,6 +385,7 @@ def list_group_stats( unless the request contains an explicit group_id list. If a group_id list is given, also ErrorGroupStats with zero occurrences are returned. + This corresponds to the ``time_range`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -379,7 +397,7 @@ def list_group_stats( sent along with the request as metadata. Returns: - ~.pagers.ListGroupStatsPager: + google.cloud.errorreporting_v1beta1.services.error_stats_service.pagers.ListGroupStatsPager: Contains a set of requested error group stats. Iterating over this object will yield @@ -449,21 +467,23 @@ def list_events( r"""Lists the specified events. Args: - request (:class:`~.error_stats_service.ListEventsRequest`): + request (google.cloud.errorreporting_v1beta1.types.ListEventsRequest): The request object. Specifies a set of error events to return. - project_name (:class:`str`): + project_name (str): Required. The resource name of the Google Cloud Platform project. Written as ``projects/`` plus the `Google Cloud Platform project ID `__. Example: ``projects/my-project-123``. + This corresponds to the ``project_name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - group_id (:class:`str`): + group_id (str): Required. The group for which events shall be returned. + This corresponds to the ``group_id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -475,7 +495,7 @@ def list_events( sent along with the request as metadata. Returns: - ~.pagers.ListEventsPager: + google.cloud.errorreporting_v1beta1.services.error_stats_service.pagers.ListEventsPager: Contains a set of requested error events. Iterating over this object will yield @@ -544,14 +564,15 @@ def delete_events( r"""Deletes all error events of a given project. Args: - request (:class:`~.error_stats_service.DeleteEventsRequest`): + request (google.cloud.errorreporting_v1beta1.types.DeleteEventsRequest): The request object. Deletes all events in the project. - project_name (:class:`str`): + project_name (str): Required. The resource name of the Google Cloud Platform project. Written as ``projects/`` plus the `Google Cloud Platform project ID `__. Example: ``projects/my-project-123``. + This corresponds to the ``project_name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -563,7 +584,7 @@ def delete_events( sent along with the request as metadata. Returns: - ~.error_stats_service.DeleteEventsResponse: + google.cloud.errorreporting_v1beta1.types.DeleteEventsResponse: Response message for deleting error events. diff --git a/google/cloud/errorreporting_v1beta1/services/error_stats_service/pagers.py b/google/cloud/errorreporting_v1beta1/services/error_stats_service/pagers.py index 02a4faa4..63bb8413 100644 --- a/google/cloud/errorreporting_v1beta1/services/error_stats_service/pagers.py +++ b/google/cloud/errorreporting_v1beta1/services/error_stats_service/pagers.py @@ -25,7 +25,7 @@ class ListGroupStatsPager: """A pager for iterating through ``list_group_stats`` requests. This class thinly wraps an initial - :class:`~.error_stats_service.ListGroupStatsResponse` object, and + :class:`google.cloud.errorreporting_v1beta1.types.ListGroupStatsResponse` object, and provides an ``__iter__`` method to iterate through its ``error_group_stats`` field. @@ -34,7 +34,7 @@ class ListGroupStatsPager: through the ``error_group_stats`` field on the corresponding responses. - All the usual :class:`~.error_stats_service.ListGroupStatsResponse` + All the usual :class:`google.cloud.errorreporting_v1beta1.types.ListGroupStatsResponse` attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup. """ @@ -52,9 +52,9 @@ def __init__( Args: method (Callable): The method that was originally called, and which instantiated this pager. - request (:class:`~.error_stats_service.ListGroupStatsRequest`): + request (google.cloud.errorreporting_v1beta1.types.ListGroupStatsRequest): The initial request object. - response (:class:`~.error_stats_service.ListGroupStatsResponse`): + response (google.cloud.errorreporting_v1beta1.types.ListGroupStatsResponse): The initial response object. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. @@ -87,7 +87,7 @@ class ListGroupStatsAsyncPager: """A pager for iterating through ``list_group_stats`` requests. This class thinly wraps an initial - :class:`~.error_stats_service.ListGroupStatsResponse` object, and + :class:`google.cloud.errorreporting_v1beta1.types.ListGroupStatsResponse` object, and provides an ``__aiter__`` method to iterate through its ``error_group_stats`` field. @@ -96,7 +96,7 @@ class ListGroupStatsAsyncPager: through the ``error_group_stats`` field on the corresponding responses. - All the usual :class:`~.error_stats_service.ListGroupStatsResponse` + All the usual :class:`google.cloud.errorreporting_v1beta1.types.ListGroupStatsResponse` attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup. """ @@ -114,9 +114,9 @@ def __init__( Args: method (Callable): The method that was originally called, and which instantiated this pager. - request (:class:`~.error_stats_service.ListGroupStatsRequest`): + request (google.cloud.errorreporting_v1beta1.types.ListGroupStatsRequest): The initial request object. - response (:class:`~.error_stats_service.ListGroupStatsResponse`): + response (google.cloud.errorreporting_v1beta1.types.ListGroupStatsResponse): The initial response object. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. @@ -153,7 +153,7 @@ class ListEventsPager: """A pager for iterating through ``list_events`` requests. This class thinly wraps an initial - :class:`~.error_stats_service.ListEventsResponse` object, and + :class:`google.cloud.errorreporting_v1beta1.types.ListEventsResponse` object, and provides an ``__iter__`` method to iterate through its ``error_events`` field. @@ -162,7 +162,7 @@ class ListEventsPager: through the ``error_events`` field on the corresponding responses. - All the usual :class:`~.error_stats_service.ListEventsResponse` + All the usual :class:`google.cloud.errorreporting_v1beta1.types.ListEventsResponse` attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup. """ @@ -180,9 +180,9 @@ def __init__( Args: method (Callable): The method that was originally called, and which instantiated this pager. - request (:class:`~.error_stats_service.ListEventsRequest`): + request (google.cloud.errorreporting_v1beta1.types.ListEventsRequest): The initial request object. - response (:class:`~.error_stats_service.ListEventsResponse`): + response (google.cloud.errorreporting_v1beta1.types.ListEventsResponse): The initial response object. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. @@ -215,7 +215,7 @@ class ListEventsAsyncPager: """A pager for iterating through ``list_events`` requests. This class thinly wraps an initial - :class:`~.error_stats_service.ListEventsResponse` object, and + :class:`google.cloud.errorreporting_v1beta1.types.ListEventsResponse` object, and provides an ``__aiter__`` method to iterate through its ``error_events`` field. @@ -224,7 +224,7 @@ class ListEventsAsyncPager: through the ``error_events`` field on the corresponding responses. - All the usual :class:`~.error_stats_service.ListEventsResponse` + All the usual :class:`google.cloud.errorreporting_v1beta1.types.ListEventsResponse` attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup. """ @@ -242,9 +242,9 @@ def __init__( Args: method (Callable): The method that was originally called, and which instantiated this pager. - request (:class:`~.error_stats_service.ListEventsRequest`): + request (google.cloud.errorreporting_v1beta1.types.ListEventsRequest): The initial request object. - response (:class:`~.error_stats_service.ListEventsResponse`): + response (google.cloud.errorreporting_v1beta1.types.ListEventsResponse): The initial response object. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. diff --git a/google/cloud/errorreporting_v1beta1/services/report_errors_service/async_client.py b/google/cloud/errorreporting_v1beta1/services/report_errors_service/async_client.py index 3b7c6fcf..9562776f 100644 --- a/google/cloud/errorreporting_v1beta1/services/report_errors_service/async_client.py +++ b/google/cloud/errorreporting_v1beta1/services/report_errors_service/async_client.py @@ -72,6 +72,7 @@ class ReportErrorsServiceAsyncClient: ReportErrorsServiceClient.parse_common_location_path ) + from_service_account_info = ReportErrorsServiceClient.from_service_account_info from_service_account_file = ReportErrorsServiceClient.from_service_account_file from_service_account_json = from_service_account_file @@ -157,7 +158,7 @@ async def report_error_event( ``POST https://clouderrorreporting.googleapis.com/v1beta1/projects/example-project/events:report?key=123ABC456`` Args: - request (:class:`~.report_errors_service.ReportErrorEventRequest`): + request (:class:`google.cloud.errorreporting_v1beta1.types.ReportErrorEventRequest`): The request object. A request for reporting an individual error event. project_name (:class:`str`): @@ -166,12 +167,14 @@ async def report_error_event( Platform project ID `__. Example: ``projects/my-project-123``. + This corresponds to the ``project_name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - event (:class:`~.report_errors_service.ReportedErrorEvent`): + event (:class:`google.cloud.errorreporting_v1beta1.types.ReportedErrorEvent`): Required. The error event to be reported. + This corresponds to the ``event`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -183,7 +186,7 @@ async def report_error_event( sent along with the request as metadata. Returns: - ~.report_errors_service.ReportErrorEventResponse: + google.cloud.errorreporting_v1beta1.types.ReportErrorEventResponse: Response for reporting an individual error event. Data may be added to this message in the future. diff --git a/google/cloud/errorreporting_v1beta1/services/report_errors_service/client.py b/google/cloud/errorreporting_v1beta1/services/report_errors_service/client.py index b10ecca4..1510c7d6 100644 --- a/google/cloud/errorreporting_v1beta1/services/report_errors_service/client.py +++ b/google/cloud/errorreporting_v1beta1/services/report_errors_service/client.py @@ -111,6 +111,22 @@ def _get_default_mtls_endpoint(api_endpoint): 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: + ReportErrorsServiceClient: 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 @@ -123,7 +139,7 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): kwargs: Additional arguments to pass to the constructor. Returns: - {@api.name}: The constructed client. + ReportErrorsServiceClient: The constructed client. """ credentials = service_account.Credentials.from_service_account_file(filename) kwargs["credentials"] = credentials @@ -215,10 +231,10 @@ def __init__( 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, ~.ReportErrorsServiceTransport]): The + transport (Union[str, ReportErrorsServiceTransport]): The transport to use. If set to None, a transport is chosen automatically. - client_options (client_options_lib.ClientOptions): Custom options for the + client_options (google.api_core.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 @@ -336,21 +352,23 @@ def report_error_event( ``POST https://clouderrorreporting.googleapis.com/v1beta1/projects/example-project/events:report?key=123ABC456`` Args: - request (:class:`~.report_errors_service.ReportErrorEventRequest`): + request (google.cloud.errorreporting_v1beta1.types.ReportErrorEventRequest): The request object. A request for reporting an individual error event. - project_name (:class:`str`): + project_name (str): Required. The resource name of the Google Cloud Platform project. Written as ``projects/`` plus the `Google Cloud Platform project ID `__. Example: ``projects/my-project-123``. + This corresponds to the ``project_name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - event (:class:`~.report_errors_service.ReportedErrorEvent`): + event (google.cloud.errorreporting_v1beta1.types.ReportedErrorEvent): Required. The error event to be reported. + This corresponds to the ``event`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -362,7 +380,7 @@ def report_error_event( sent along with the request as metadata. Returns: - ~.report_errors_service.ReportErrorEventResponse: + google.cloud.errorreporting_v1beta1.types.ReportErrorEventResponse: Response for reporting an individual error event. Data may be added to this message in the future. diff --git a/google/cloud/errorreporting_v1beta1/types/common.py b/google/cloud/errorreporting_v1beta1/types/common.py index 779aa453..e8371063 100644 --- a/google/cloud/errorreporting_v1beta1/types/common.py +++ b/google/cloud/errorreporting_v1beta1/types/common.py @@ -48,7 +48,7 @@ class ErrorGroup(proto.Message): the same kind of error occurs in different service contexts, it will receive the same group ID. - tracking_issues (Sequence[~.common.TrackingIssue]): + tracking_issues (Sequence[google.cloud.errorreporting_v1beta1.types.TrackingIssue]): Associated tracking issues. """ @@ -80,17 +80,17 @@ class ErrorEvent(proto.Message): system. Attributes: - event_time (~.timestamp.Timestamp): + event_time (google.protobuf.timestamp_pb2.Timestamp): Time when the event occurred as provided in the error report. If the report did not contain a timestamp, the time the error was received by the Error Reporting system is used. - service_context (~.common.ServiceContext): + service_context (google.cloud.errorreporting_v1beta1.types.ServiceContext): The ``ServiceContext`` for which this error was reported. message (str): The stack trace that was reported or logged by the service. - context (~.common.ErrorContext): + context (google.cloud.errorreporting_v1beta1.types.ErrorContext): Data about the context in which the error occurred. """ @@ -149,7 +149,7 @@ class ErrorContext(proto.Message): Engine logs. Attributes: - http_request (~.common.HttpRequestContext): + http_request (google.cloud.errorreporting_v1beta1.types.HttpRequestContext): The HTTP request which was processed when the error was triggered. user (str): @@ -160,7 +160,7 @@ class ErrorContext(proto.Message): this case the Error Reporting system will use other data, such as remote IP address, to distinguish affected users. See ``affected_users_count`` in ``ErrorGroupStats``. - report_location (~.common.SourceLocation): + report_location (google.cloud.errorreporting_v1beta1.types.SourceLocation): The location in the source code where the decision was made to report the error, usually the place where it was logged. For a logged diff --git a/google/cloud/errorreporting_v1beta1/types/error_group_service.py b/google/cloud/errorreporting_v1beta1/types/error_group_service.py index 70aa92a8..632e072f 100644 --- a/google/cloud/errorreporting_v1beta1/types/error_group_service.py +++ b/google/cloud/errorreporting_v1beta1/types/error_group_service.py @@ -47,7 +47,7 @@ class UpdateGroupRequest(proto.Message): r"""A request to replace the existing data for the given group. Attributes: - group (~.common.ErrorGroup): + group (google.cloud.errorreporting_v1beta1.types.ErrorGroup): Required. The group which replaces the resource on the server. """ diff --git a/google/cloud/errorreporting_v1beta1/types/error_stats_service.py b/google/cloud/errorreporting_v1beta1/types/error_stats_service.py index 51a14e89..dfd08020 100644 --- a/google/cloud/errorreporting_v1beta1/types/error_stats_service.py +++ b/google/cloud/errorreporting_v1beta1/types/error_stats_service.py @@ -75,13 +75,13 @@ class ListGroupStatsRequest(proto.Message): group_id (Sequence[str]): Optional. List all ErrorGroupStats with these IDs. - service_filter (~.error_stats_service.ServiceContextFilter): + service_filter (google.cloud.errorreporting_v1beta1.types.ServiceContextFilter): Optional. List only ErrorGroupStats which belong to a service context that matches the filter. Data for all service contexts is returned if this field is not specified. - time_range (~.error_stats_service.QueryTimeRange): + time_range (google.cloud.errorreporting_v1beta1.types.QueryTimeRange): Optional. List data for the given time range. If not set, a default time range is used. The field time_range_begin in the response will specify the beginning of this time range. @@ -89,17 +89,17 @@ class ListGroupStatsRequest(proto.Message): range are returned, unless the request contains an explicit group_id list. If a group_id list is given, also ErrorGroupStats with zero occurrences are returned. - timed_count_duration (~.duration.Duration): + timed_count_duration (google.protobuf.duration_pb2.Duration): Optional. The preferred duration for a single returned ``TimedCount``. If not set, no timed counts are returned. - alignment (~.error_stats_service.TimedCountAlignment): + alignment (google.cloud.errorreporting_v1beta1.types.TimedCountAlignment): Optional. The alignment of the timed counts to be returned. Default is ``ALIGNMENT_EQUAL_AT_END``. - alignment_time (~.timestamp.Timestamp): + alignment_time (google.protobuf.timestamp_pb2.Timestamp): Optional. Time where the timed counts shall be aligned if rounded alignment is chosen. Default is 00:00 UTC. - order (~.error_stats_service.ErrorGroupOrder): + order (google.cloud.errorreporting_v1beta1.types.ErrorGroupOrder): Optional. The sort order in which the results are returned. Default is ``COUNT_DESC``. page_size (int): @@ -140,7 +140,7 @@ class ListGroupStatsResponse(proto.Message): r"""Contains a set of requested error group stats. Attributes: - error_group_stats (Sequence[~.error_stats_service.ErrorGroupStats]): + error_group_stats (Sequence[google.cloud.errorreporting_v1beta1.types.ErrorGroupStats]): The error group stats which match the given request. next_page_token (str): @@ -148,7 +148,7 @@ class ListGroupStatsResponse(proto.Message): Pass this token, along with the same query parameters as the first request, to view the next page of results. - time_range_begin (~.timestamp.Timestamp): + time_range_begin (google.protobuf.timestamp_pb2.Timestamp): The timestamp specifies the start time to which the request was restricted. The start time is set based on the requested time range. It may @@ -177,7 +177,7 @@ class ErrorGroupStats(proto.Message): criteria, such as a given time period and/or service filter. Attributes: - group (~.common.ErrorGroup): + group (google.cloud.errorreporting_v1beta1.types.ErrorGroup): Group data that is independent of the filter criteria. count (int): @@ -195,22 +195,22 @@ class ErrorGroupStats(proto.Message): provided in the error report. If more users are implicitly affected, such as due to a crash of the whole service, this is not reflected here. - timed_counts (Sequence[~.error_stats_service.TimedCount]): + timed_counts (Sequence[google.cloud.errorreporting_v1beta1.types.TimedCount]): Approximate number of occurrences over time. Timed counts returned by ListGroups are guaranteed to be: - Inside the requested time interval - Non-overlapping, and - Ordered by ascending time. - first_seen_time (~.timestamp.Timestamp): + first_seen_time (google.protobuf.timestamp_pb2.Timestamp): Approximate first occurrence that was ever seen for this group and which matches the given filter criteria, ignoring the time_range that was specified in the request. - last_seen_time (~.timestamp.Timestamp): + last_seen_time (google.protobuf.timestamp_pb2.Timestamp): Approximate last occurrence that was ever seen for this group and which matches the given filter criteria, ignoring the time_range that was specified in the request. - affected_services (Sequence[~.common.ServiceContext]): + affected_services (Sequence[google.cloud.errorreporting_v1beta1.types.ServiceContext]): Service contexts with a non-zero error count for the given filter criteria. This list can be truncated if multiple services are affected. Refer to ``num_affected_services`` @@ -218,7 +218,7 @@ class ErrorGroupStats(proto.Message): num_affected_services (int): The total number of services with a non-zero error count for the given filter criteria. - representative (~.common.ErrorEvent): + representative (google.cloud.errorreporting_v1beta1.types.ErrorEvent): An arbitrary event that is chosen as representative for the whole group. The representative event is intended to be used as a @@ -259,10 +259,10 @@ class TimedCount(proto.Message): count (int): Approximate number of occurrences in the given time period. - start_time (~.timestamp.Timestamp): + start_time (google.protobuf.timestamp_pb2.Timestamp): Start of the time period to which ``count`` refers (included). - end_time (~.timestamp.Timestamp): + end_time (google.protobuf.timestamp_pb2.Timestamp): End of the time period to which ``count`` refers (excluded). """ @@ -286,12 +286,12 @@ class ListEventsRequest(proto.Message): group_id (str): Required. The group for which events shall be returned. - service_filter (~.error_stats_service.ServiceContextFilter): + service_filter (google.cloud.errorreporting_v1beta1.types.ServiceContextFilter): Optional. List only ErrorGroups which belong to a service context that matches the filter. Data for all service contexts is returned if this field is not specified. - time_range (~.error_stats_service.QueryTimeRange): + time_range (google.cloud.errorreporting_v1beta1.types.QueryTimeRange): Optional. List only data for the given time range. If not set a default time range is used. The field time_range_begin in the response will specify the beginning of this time @@ -323,7 +323,7 @@ class ListEventsResponse(proto.Message): r"""Contains a set of requested error events. Attributes: - error_events (Sequence[~.common.ErrorEvent]): + error_events (Sequence[google.cloud.errorreporting_v1beta1.types.ErrorEvent]): The error events which match the given request. next_page_token (str): @@ -331,7 +331,7 @@ class ListEventsResponse(proto.Message): Pass this token, along with the same query parameters as the first request, to view the next page of results. - time_range_begin (~.timestamp.Timestamp): + time_range_begin (google.protobuf.timestamp_pb2.Timestamp): The timestamp specifies the start time to which the request was restricted. """ @@ -356,7 +356,7 @@ class QueryTimeRange(proto.Message): durations might be adjusted for lower durations. Attributes: - period (~.error_stats_service.QueryTimeRange.Period): + period (google.cloud.errorreporting_v1beta1.types.QueryTimeRange.Period): Restricts the query to the specified time range. """ diff --git a/google/cloud/errorreporting_v1beta1/types/report_errors_service.py b/google/cloud/errorreporting_v1beta1/types/report_errors_service.py index 1a66727b..e53fa5e5 100644 --- a/google/cloud/errorreporting_v1beta1/types/report_errors_service.py +++ b/google/cloud/errorreporting_v1beta1/types/report_errors_service.py @@ -42,7 +42,7 @@ class ReportErrorEventRequest(proto.Message): Platform project ID `__. Example: ``projects/my-project-123``. - event (~.report_errors_service.ReportedErrorEvent): + event (google.cloud.errorreporting_v1beta1.types.ReportedErrorEvent): Required. The error event to be reported. """ @@ -62,12 +62,12 @@ class ReportedErrorEvent(proto.Message): system. Attributes: - event_time (~.timestamp.Timestamp): + event_time (google.protobuf.timestamp_pb2.Timestamp): Optional. Time when the event occurred. If not provided, the time when the event was received by the Error Reporting system will be used. - service_context (~.common.ServiceContext): + service_context (google.cloud.errorreporting_v1beta1.types.ServiceContext): Required. The service context in which this error has occurred. message (str): @@ -96,7 +96,7 @@ class ReportedErrorEvent(proto.Message): ```(string)$exception`` `__. - **Go**: Must be the return value of ```runtime.Stack()`` `__. - context (~.common.ErrorContext): + context (google.cloud.errorreporting_v1beta1.types.ErrorContext): Optional. A description of the context in which the error occurred. """ diff --git a/synth.metadata b/synth.metadata index 6e480a01..02713c29 100644 --- a/synth.metadata +++ b/synth.metadata @@ -11,8 +11,8 @@ "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "2ccf8f460800e98884d1aa4ba61e344ad4cd5d04", - "internalRef": "348857882" + "sha": "520682435235d9c503983a360a2090025aa47cd1", + "internalRef": "350246057" } }, { @@ -42,6 +42,7 @@ } ], "generatedFiles": [ + ".coveragerc", ".flake8", ".github/CONTRIBUTING.md", ".github/ISSUE_TEMPLATE/bug_report.md", @@ -95,6 +96,9 @@ "docs/_static/custom.css", "docs/_templates/layout.html", "docs/conf.py", + "docs/errorreporting_v1beta1/error_group_service.rst", + "docs/errorreporting_v1beta1/error_stats_service.rst", + "docs/errorreporting_v1beta1/report_errors_service.rst", "docs/errorreporting_v1beta1/services.rst", "docs/errorreporting_v1beta1/types.rst", "docs/multiprocessing.rst", diff --git a/tests/unit/gapic/errorreporting_v1beta1/test_error_group_service.py b/tests/unit/gapic/errorreporting_v1beta1/test_error_group_service.py index da93c3df..8c82e2db 100644 --- a/tests/unit/gapic/errorreporting_v1beta1/test_error_group_service.py +++ b/tests/unit/gapic/errorreporting_v1beta1/test_error_group_service.py @@ -89,8 +89,21 @@ def test__get_default_mtls_endpoint(): ) +def test_error_group_service_client_from_service_account_info(): + creds = credentials.AnonymousCredentials() + with mock.patch.object( + service_account.Credentials, "from_service_account_info" + ) as factory: + factory.return_value = creds + info = {"valid": True} + client = ErrorGroupServiceClient.from_service_account_info(info) + assert client.transport._credentials == creds + + assert client.transport._host == "clouderrorreporting.googleapis.com:443" + + @pytest.mark.parametrize( - "client_class", [ErrorGroupServiceClient, ErrorGroupServiceAsyncClient] + "client_class", [ErrorGroupServiceClient, ErrorGroupServiceAsyncClient,] ) def test_error_group_service_client_from_service_account_file(client_class): creds = credentials.AnonymousCredentials() @@ -109,7 +122,10 @@ def test_error_group_service_client_from_service_account_file(client_class): def test_error_group_service_client_get_transport_class(): transport = ErrorGroupServiceClient.get_transport_class() - assert transport == transports.ErrorGroupServiceGrpcTransport + available_transports = [ + transports.ErrorGroupServiceGrpcTransport, + ] + assert transport in available_transports transport = ErrorGroupServiceClient.get_transport_class("grpc") assert transport == transports.ErrorGroupServiceGrpcTransport @@ -1035,7 +1051,7 @@ def test_error_group_service_host_with_port(): def test_error_group_service_grpc_transport_channel(): - channel = grpc.insecure_channel("http://localhost/") + channel = grpc.secure_channel("http://localhost/", grpc.local_channel_credentials()) # Check that channel is used if provided. transport = transports.ErrorGroupServiceGrpcTransport( @@ -1047,7 +1063,7 @@ def test_error_group_service_grpc_transport_channel(): def test_error_group_service_grpc_asyncio_transport_channel(): - channel = aio.insecure_channel("http://localhost/") + channel = aio.secure_channel("http://localhost/", grpc.local_channel_credentials()) # Check that channel is used if provided. transport = transports.ErrorGroupServiceGrpcAsyncIOTransport( @@ -1072,7 +1088,7 @@ def test_error_group_service_transport_channel_mtls_with_client_cert_source( "grpc.ssl_channel_credentials", autospec=True ) as grpc_ssl_channel_cred: with mock.patch.object( - transport_class, "create_channel", autospec=True + transport_class, "create_channel" ) as grpc_create_channel: mock_ssl_cred = mock.Mock() grpc_ssl_channel_cred.return_value = mock_ssl_cred @@ -1125,7 +1141,7 @@ def test_error_group_service_transport_channel_mtls_with_adc(transport_class): ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred), ): with mock.patch.object( - transport_class, "create_channel", autospec=True + transport_class, "create_channel" ) as grpc_create_channel: mock_grpc_channel = mock.Mock() grpc_create_channel.return_value = mock_grpc_channel diff --git a/tests/unit/gapic/errorreporting_v1beta1/test_error_stats_service.py b/tests/unit/gapic/errorreporting_v1beta1/test_error_stats_service.py index 2ea69420..672c74c9 100644 --- a/tests/unit/gapic/errorreporting_v1beta1/test_error_stats_service.py +++ b/tests/unit/gapic/errorreporting_v1beta1/test_error_stats_service.py @@ -92,8 +92,21 @@ def test__get_default_mtls_endpoint(): ) +def test_error_stats_service_client_from_service_account_info(): + creds = credentials.AnonymousCredentials() + with mock.patch.object( + service_account.Credentials, "from_service_account_info" + ) as factory: + factory.return_value = creds + info = {"valid": True} + client = ErrorStatsServiceClient.from_service_account_info(info) + assert client.transport._credentials == creds + + assert client.transport._host == "clouderrorreporting.googleapis.com:443" + + @pytest.mark.parametrize( - "client_class", [ErrorStatsServiceClient, ErrorStatsServiceAsyncClient] + "client_class", [ErrorStatsServiceClient, ErrorStatsServiceAsyncClient,] ) def test_error_stats_service_client_from_service_account_file(client_class): creds = credentials.AnonymousCredentials() @@ -112,7 +125,10 @@ def test_error_stats_service_client_from_service_account_file(client_class): def test_error_stats_service_client_get_transport_class(): transport = ErrorStatsServiceClient.get_transport_class() - assert transport == transports.ErrorStatsServiceGrpcTransport + available_transports = [ + transports.ErrorStatsServiceGrpcTransport, + ] + assert transport in available_transports transport = ErrorStatsServiceClient.get_transport_class("grpc") assert transport == transports.ErrorStatsServiceGrpcTransport @@ -1596,7 +1612,7 @@ def test_error_stats_service_host_with_port(): def test_error_stats_service_grpc_transport_channel(): - channel = grpc.insecure_channel("http://localhost/") + channel = grpc.secure_channel("http://localhost/", grpc.local_channel_credentials()) # Check that channel is used if provided. transport = transports.ErrorStatsServiceGrpcTransport( @@ -1608,7 +1624,7 @@ def test_error_stats_service_grpc_transport_channel(): def test_error_stats_service_grpc_asyncio_transport_channel(): - channel = aio.insecure_channel("http://localhost/") + channel = aio.secure_channel("http://localhost/", grpc.local_channel_credentials()) # Check that channel is used if provided. transport = transports.ErrorStatsServiceGrpcAsyncIOTransport( @@ -1633,7 +1649,7 @@ def test_error_stats_service_transport_channel_mtls_with_client_cert_source( "grpc.ssl_channel_credentials", autospec=True ) as grpc_ssl_channel_cred: with mock.patch.object( - transport_class, "create_channel", autospec=True + transport_class, "create_channel" ) as grpc_create_channel: mock_ssl_cred = mock.Mock() grpc_ssl_channel_cred.return_value = mock_ssl_cred @@ -1686,7 +1702,7 @@ def test_error_stats_service_transport_channel_mtls_with_adc(transport_class): ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred), ): with mock.patch.object( - transport_class, "create_channel", autospec=True + transport_class, "create_channel" ) as grpc_create_channel: mock_grpc_channel = mock.Mock() grpc_create_channel.return_value = mock_grpc_channel diff --git a/tests/unit/gapic/errorreporting_v1beta1/test_report_errors_service.py b/tests/unit/gapic/errorreporting_v1beta1/test_report_errors_service.py index f84d267f..04b6850f 100644 --- a/tests/unit/gapic/errorreporting_v1beta1/test_report_errors_service.py +++ b/tests/unit/gapic/errorreporting_v1beta1/test_report_errors_service.py @@ -92,8 +92,21 @@ def test__get_default_mtls_endpoint(): ) +def test_report_errors_service_client_from_service_account_info(): + creds = credentials.AnonymousCredentials() + with mock.patch.object( + service_account.Credentials, "from_service_account_info" + ) as factory: + factory.return_value = creds + info = {"valid": True} + client = ReportErrorsServiceClient.from_service_account_info(info) + assert client.transport._credentials == creds + + assert client.transport._host == "clouderrorreporting.googleapis.com:443" + + @pytest.mark.parametrize( - "client_class", [ReportErrorsServiceClient, ReportErrorsServiceAsyncClient] + "client_class", [ReportErrorsServiceClient, ReportErrorsServiceAsyncClient,] ) def test_report_errors_service_client_from_service_account_file(client_class): creds = credentials.AnonymousCredentials() @@ -112,7 +125,10 @@ def test_report_errors_service_client_from_service_account_file(client_class): def test_report_errors_service_client_get_transport_class(): transport = ReportErrorsServiceClient.get_transport_class() - assert transport == transports.ReportErrorsServiceGrpcTransport + available_transports = [ + transports.ReportErrorsServiceGrpcTransport, + ] + assert transport in available_transports transport = ReportErrorsServiceClient.get_transport_class("grpc") assert transport == transports.ReportErrorsServiceGrpcTransport @@ -881,7 +897,7 @@ def test_report_errors_service_host_with_port(): def test_report_errors_service_grpc_transport_channel(): - channel = grpc.insecure_channel("http://localhost/") + channel = grpc.secure_channel("http://localhost/", grpc.local_channel_credentials()) # Check that channel is used if provided. transport = transports.ReportErrorsServiceGrpcTransport( @@ -893,7 +909,7 @@ def test_report_errors_service_grpc_transport_channel(): def test_report_errors_service_grpc_asyncio_transport_channel(): - channel = aio.insecure_channel("http://localhost/") + channel = aio.secure_channel("http://localhost/", grpc.local_channel_credentials()) # Check that channel is used if provided. transport = transports.ReportErrorsServiceGrpcAsyncIOTransport( @@ -918,7 +934,7 @@ def test_report_errors_service_transport_channel_mtls_with_client_cert_source( "grpc.ssl_channel_credentials", autospec=True ) as grpc_ssl_channel_cred: with mock.patch.object( - transport_class, "create_channel", autospec=True + transport_class, "create_channel" ) as grpc_create_channel: mock_ssl_cred = mock.Mock() grpc_ssl_channel_cred.return_value = mock_ssl_cred @@ -971,7 +987,7 @@ def test_report_errors_service_transport_channel_mtls_with_adc(transport_class): ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred), ): with mock.patch.object( - transport_class, "create_channel", autospec=True + transport_class, "create_channel" ) as grpc_create_channel: mock_grpc_channel = mock.Mock() grpc_create_channel.return_value = mock_grpc_channel From e745c543069f14c348ba28df62a3fee54570eed5 Mon Sep 17 00:00:00 2001 From: yoshi-automation Date: Sat, 6 Mar 2021 08:16:21 -0800 Subject: [PATCH 04/25] chore: Update C# namespace This is a breaking change, but *only* for C#. Google has not yet published a package for this API, so it would only break users who have generated the code themselves. PiperOrigin-RevId: 350388717 Source-Author: Google APIs Source-Date: Wed Jan 6 11:04:54 2021 -0800 Source-Repo: googleapis/googleapis Source-Sha: dd1d2325b189d3bb69c4a6a802185cefbd8e592e Source-Link: https://github.com/googleapis/googleapis/commit/dd1d2325b189d3bb69c4a6a802185cefbd8e592e --- google/cloud/errorreporting_v1beta1/__init__.py | 4 ++-- synth.metadata | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/google/cloud/errorreporting_v1beta1/__init__.py b/google/cloud/errorreporting_v1beta1/__init__.py index b6f762a3..8db40bd7 100644 --- a/google/cloud/errorreporting_v1beta1/__init__.py +++ b/google/cloud/errorreporting_v1beta1/__init__.py @@ -51,8 +51,8 @@ "ErrorEvent", "ErrorGroup", "ErrorGroupOrder", - "ErrorGroupServiceClient", "ErrorGroupStats", + "ErrorStatsServiceClient", "GetGroupRequest", "HttpRequestContext", "ListEventsRequest", @@ -71,5 +71,5 @@ "TimedCountAlignment", "TrackingIssue", "UpdateGroupRequest", - "ErrorStatsServiceClient", + "ErrorGroupServiceClient", ) diff --git a/synth.metadata b/synth.metadata index 02713c29..8fea90a4 100644 --- a/synth.metadata +++ b/synth.metadata @@ -11,8 +11,8 @@ "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "520682435235d9c503983a360a2090025aa47cd1", - "internalRef": "350246057" + "sha": "dd1d2325b189d3bb69c4a6a802185cefbd8e592e", + "internalRef": "350388717" } }, { From 4bfcc048ca5780636091cfde79d8d29a672c7d0d Mon Sep 17 00:00:00 2001 From: yoshi-automation Date: Sat, 6 Mar 2021 08:16:21 -0800 Subject: [PATCH 05/25] chore: put markdown table in a codeblock PiperOrigin-RevId: 350414815 Source-Author: Google APIs Source-Date: Wed Jan 6 13:18:46 2021 -0800 Source-Repo: googleapis/googleapis Source-Sha: 700afd1f0bafc2155bc5e891504c53d4ac9166f5 Source-Link: https://github.com/googleapis/googleapis/commit/700afd1f0bafc2155bc5e891504c53d4ac9166f5 --- google/cloud/errorreporting_v1beta1/__init__.py | 4 ++-- synth.metadata | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/google/cloud/errorreporting_v1beta1/__init__.py b/google/cloud/errorreporting_v1beta1/__init__.py index 8db40bd7..43fc283f 100644 --- a/google/cloud/errorreporting_v1beta1/__init__.py +++ b/google/cloud/errorreporting_v1beta1/__init__.py @@ -51,6 +51,7 @@ "ErrorEvent", "ErrorGroup", "ErrorGroupOrder", + "ErrorGroupServiceClient", "ErrorGroupStats", "ErrorStatsServiceClient", "GetGroupRequest", @@ -62,7 +63,6 @@ "QueryTimeRange", "ReportErrorEventRequest", "ReportErrorEventResponse", - "ReportErrorsServiceClient", "ReportedErrorEvent", "ServiceContext", "ServiceContextFilter", @@ -71,5 +71,5 @@ "TimedCountAlignment", "TrackingIssue", "UpdateGroupRequest", - "ErrorGroupServiceClient", + "ReportErrorsServiceClient", ) diff --git a/synth.metadata b/synth.metadata index 8fea90a4..a7bd3f83 100644 --- a/synth.metadata +++ b/synth.metadata @@ -11,8 +11,8 @@ "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "dd1d2325b189d3bb69c4a6a802185cefbd8e592e", - "internalRef": "350388717" + "sha": "700afd1f0bafc2155bc5e891504c53d4ac9166f5", + "internalRef": "350414815" } }, { From f556b273fd92edc7efa0dbb5038b18b89fa408bf Mon Sep 17 00:00:00 2001 From: yoshi-automation Date: Sat, 6 Mar 2021 08:17:01 -0800 Subject: [PATCH 06/25] chore: use name google.cloud.bigquery_storage namespace to avoid conflicts with google.cloud.bigquery PiperOrigin-RevId: 351218127 Source-Author: Google APIs Source-Date: Mon Jan 11 13:04:39 2021 -0800 Source-Repo: googleapis/googleapis Source-Sha: c8bfd324b41ad1f6f65fed124572f92fe116517b Source-Link: https://github.com/googleapis/googleapis/commit/c8bfd324b41ad1f6f65fed124572f92fe116517b --- google/cloud/errorreporting_v1beta1/__init__.py | 4 ++-- synth.metadata | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/google/cloud/errorreporting_v1beta1/__init__.py b/google/cloud/errorreporting_v1beta1/__init__.py index 43fc283f..8db40bd7 100644 --- a/google/cloud/errorreporting_v1beta1/__init__.py +++ b/google/cloud/errorreporting_v1beta1/__init__.py @@ -51,7 +51,6 @@ "ErrorEvent", "ErrorGroup", "ErrorGroupOrder", - "ErrorGroupServiceClient", "ErrorGroupStats", "ErrorStatsServiceClient", "GetGroupRequest", @@ -63,6 +62,7 @@ "QueryTimeRange", "ReportErrorEventRequest", "ReportErrorEventResponse", + "ReportErrorsServiceClient", "ReportedErrorEvent", "ServiceContext", "ServiceContextFilter", @@ -71,5 +71,5 @@ "TimedCountAlignment", "TrackingIssue", "UpdateGroupRequest", - "ReportErrorsServiceClient", + "ErrorGroupServiceClient", ) diff --git a/synth.metadata b/synth.metadata index a7bd3f83..a97da051 100644 --- a/synth.metadata +++ b/synth.metadata @@ -11,8 +11,8 @@ "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "700afd1f0bafc2155bc5e891504c53d4ac9166f5", - "internalRef": "350414815" + "sha": "c8bfd324b41ad1f6f65fed124572f92fe116517b", + "internalRef": "351218127" } }, { From d68e2cf38094c3121e2414f4c2b9ea761a3a824f Mon Sep 17 00:00:00 2001 From: yoshi-automation Date: Sat, 6 Mar 2021 08:17:38 -0800 Subject: [PATCH 07/25] feat: add C++ targets for DialogFlow PiperOrigin-RevId: 351615861 Source-Author: Google APIs Source-Date: Wed Jan 13 10:31:46 2021 -0800 Source-Repo: googleapis/googleapis Source-Sha: a515fa4183cb95089af55020ab547081714c5a7b Source-Link: https://github.com/googleapis/googleapis/commit/a515fa4183cb95089af55020ab547081714c5a7b --- devtools-clouderrorreporting-v1beta1-py.tar.gz | 0 google/cloud/errorreporting_v1beta1/__init__.py | 4 ++-- synth.metadata | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) create mode 100644 devtools-clouderrorreporting-v1beta1-py.tar.gz diff --git a/devtools-clouderrorreporting-v1beta1-py.tar.gz b/devtools-clouderrorreporting-v1beta1-py.tar.gz new file mode 100644 index 00000000..e69de29b diff --git a/google/cloud/errorreporting_v1beta1/__init__.py b/google/cloud/errorreporting_v1beta1/__init__.py index 8db40bd7..b6f762a3 100644 --- a/google/cloud/errorreporting_v1beta1/__init__.py +++ b/google/cloud/errorreporting_v1beta1/__init__.py @@ -51,8 +51,8 @@ "ErrorEvent", "ErrorGroup", "ErrorGroupOrder", + "ErrorGroupServiceClient", "ErrorGroupStats", - "ErrorStatsServiceClient", "GetGroupRequest", "HttpRequestContext", "ListEventsRequest", @@ -71,5 +71,5 @@ "TimedCountAlignment", "TrackingIssue", "UpdateGroupRequest", - "ErrorGroupServiceClient", + "ErrorStatsServiceClient", ) diff --git a/synth.metadata b/synth.metadata index a97da051..6c3da552 100644 --- a/synth.metadata +++ b/synth.metadata @@ -11,8 +11,8 @@ "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "c8bfd324b41ad1f6f65fed124572f92fe116517b", - "internalRef": "351218127" + "sha": "a515fa4183cb95089af55020ab547081714c5a7b", + "internalRef": "351615861" } }, { @@ -93,6 +93,7 @@ "CONTRIBUTING.rst", "LICENSE", "MANIFEST.in", + "devtools-clouderrorreporting-v1beta1-py.tar.gz", "docs/_static/custom.css", "docs/_templates/layout.html", "docs/conf.py", From 50f5703ce18a317768bf5650f0733830253e2e8a Mon Sep 17 00:00:00 2001 From: yoshi-automation Date: Sat, 6 Mar 2021 08:22:59 -0800 Subject: [PATCH 08/25] feat: added client library for Workflows Executions V1 API PiperOrigin-RevId: 351618705 Source-Author: Google APIs Source-Date: Wed Jan 13 10:45:45 2021 -0800 Source-Repo: googleapis/googleapis Source-Sha: 98911d3e77f3d541eaa841252a44905ea4a430ab Source-Link: https://github.com/googleapis/googleapis/commit/98911d3e77f3d541eaa841252a44905ea4a430ab --- devtools-clouderrorreporting-v1beta1-py.tar.gz | 0 synth.metadata | 5 ++--- 2 files changed, 2 insertions(+), 3 deletions(-) delete mode 100644 devtools-clouderrorreporting-v1beta1-py.tar.gz diff --git a/devtools-clouderrorreporting-v1beta1-py.tar.gz b/devtools-clouderrorreporting-v1beta1-py.tar.gz deleted file mode 100644 index e69de29b..00000000 diff --git a/synth.metadata b/synth.metadata index 6c3da552..dd2a7a17 100644 --- a/synth.metadata +++ b/synth.metadata @@ -11,8 +11,8 @@ "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "a515fa4183cb95089af55020ab547081714c5a7b", - "internalRef": "351615861" + "sha": "98911d3e77f3d541eaa841252a44905ea4a430ab", + "internalRef": "351618705" } }, { @@ -93,7 +93,6 @@ "CONTRIBUTING.rst", "LICENSE", "MANIFEST.in", - "devtools-clouderrorreporting-v1beta1-py.tar.gz", "docs/_static/custom.css", "docs/_templates/layout.html", "docs/conf.py", From ce70b91e6067523b3d8ecc314c0853f3c7a61eb5 Mon Sep 17 00:00:00 2001 From: yoshi-automation Date: Sat, 6 Mar 2021 08:27:50 -0800 Subject: [PATCH 09/25] chore: migrate texttospeech v1beta1 to python microgenerator PiperOrigin-RevId: 352645446 Source-Author: Google APIs Source-Date: Tue Jan 19 13:45:56 2021 -0800 Source-Repo: googleapis/googleapis Source-Sha: 4d19fc01775b142dd392f4bd82bdf8810202d061 Source-Link: https://github.com/googleapis/googleapis/commit/4d19fc01775b142dd392f4bd82bdf8810202d061 --- google/cloud/errorreporting_v1beta1/__init__.py | 4 ++-- synth.metadata | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/google/cloud/errorreporting_v1beta1/__init__.py b/google/cloud/errorreporting_v1beta1/__init__.py index b6f762a3..43fc283f 100644 --- a/google/cloud/errorreporting_v1beta1/__init__.py +++ b/google/cloud/errorreporting_v1beta1/__init__.py @@ -53,6 +53,7 @@ "ErrorGroupOrder", "ErrorGroupServiceClient", "ErrorGroupStats", + "ErrorStatsServiceClient", "GetGroupRequest", "HttpRequestContext", "ListEventsRequest", @@ -62,7 +63,6 @@ "QueryTimeRange", "ReportErrorEventRequest", "ReportErrorEventResponse", - "ReportErrorsServiceClient", "ReportedErrorEvent", "ServiceContext", "ServiceContextFilter", @@ -71,5 +71,5 @@ "TimedCountAlignment", "TrackingIssue", "UpdateGroupRequest", - "ErrorStatsServiceClient", + "ReportErrorsServiceClient", ) diff --git a/synth.metadata b/synth.metadata index dd2a7a17..feb5fa55 100644 --- a/synth.metadata +++ b/synth.metadata @@ -11,8 +11,8 @@ "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "98911d3e77f3d541eaa841252a44905ea4a430ab", - "internalRef": "351618705" + "sha": "4d19fc01775b142dd392f4bd82bdf8810202d061", + "internalRef": "352645446" } }, { From f126f0b41935c85ab8e72d86b9b8b696f3ffe46d Mon Sep 17 00:00:00 2001 From: yoshi-automation Date: Sat, 6 Mar 2021 08:32:33 -0800 Subject: [PATCH 10/25] chore: update Go generator, rules_go, and protobuf PiperOrigin-RevId: 352816749 Source-Author: Google APIs Source-Date: Wed Jan 20 10:06:23 2021 -0800 Source-Repo: googleapis/googleapis Source-Sha: ceaaf31b3d13badab7cf9d3b570f5639db5593d9 Source-Link: https://github.com/googleapis/googleapis/commit/ceaaf31b3d13badab7cf9d3b570f5639db5593d9 --- .coveragerc | 22 +++++++-- .../error_group_service.rst | 6 --- .../error_stats_service.rst | 11 ----- .../report_errors_service.rst | 6 --- docs/errorreporting_v1beta1/services.rst | 14 ++++-- docs/errorreporting_v1beta1/types.rst | 1 - .../cloud/errorreporting_v1beta1/__init__.py | 4 +- .../error_group_service/async_client.py | 13 ++--- .../services/error_group_service/client.py | 36 ++++---------- .../error_stats_service/async_client.py | 20 +++----- .../services/error_stats_service/client.py | 49 ++++++------------- .../services/error_stats_service/pagers.py | 32 ++++++------ .../report_errors_service/async_client.py | 9 ++-- .../services/report_errors_service/client.py | 32 +++--------- .../errorreporting_v1beta1/types/common.py | 12 ++--- .../types/error_group_service.py | 2 +- .../types/error_stats_service.py | 42 ++++++++-------- .../types/report_errors_service.py | 8 +-- synth.metadata | 10 ++-- .../test_error_group_service.py | 28 +++-------- .../test_error_stats_service.py | 28 +++-------- .../test_report_errors_service.py | 28 +++-------- 22 files changed, 144 insertions(+), 269 deletions(-) delete mode 100644 docs/errorreporting_v1beta1/error_group_service.rst delete mode 100644 docs/errorreporting_v1beta1/error_stats_service.rst delete mode 100644 docs/errorreporting_v1beta1/report_errors_service.rst diff --git a/.coveragerc b/.coveragerc index 9a9b9f3e..10cb72e8 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,11 +1,27 @@ +# -*- 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! [run] branch = True [report] fail_under = 100 show_missing = True -omit = - google/cloud/errorreporting/__init__.py +omit = google/cloud/errorreporting/__init__.py, .nox/* exclude_lines = # Re-enable the standard pragma pragma: NO COVER @@ -15,4 +31,4 @@ exclude_lines = # This is added at the module level as a safeguard for if someone # generates the code and tries to run it without pip installing. This # makes it virtually impossible to test properly. - except pkg_resources.DistributionNotFound + except pkg_resources.DistributionNotFound \ No newline at end of file diff --git a/docs/errorreporting_v1beta1/error_group_service.rst b/docs/errorreporting_v1beta1/error_group_service.rst deleted file mode 100644 index dd213525..00000000 --- a/docs/errorreporting_v1beta1/error_group_service.rst +++ /dev/null @@ -1,6 +0,0 @@ -ErrorGroupService ------------------------------------ - -.. automodule:: google.cloud.errorreporting_v1beta1.services.error_group_service - :members: - :inherited-members: diff --git a/docs/errorreporting_v1beta1/error_stats_service.rst b/docs/errorreporting_v1beta1/error_stats_service.rst deleted file mode 100644 index 30d29e69..00000000 --- a/docs/errorreporting_v1beta1/error_stats_service.rst +++ /dev/null @@ -1,11 +0,0 @@ -ErrorStatsService ------------------------------------ - -.. automodule:: google.cloud.errorreporting_v1beta1.services.error_stats_service - :members: - :inherited-members: - - -.. automodule:: google.cloud.errorreporting_v1beta1.services.error_stats_service.pagers - :members: - :inherited-members: diff --git a/docs/errorreporting_v1beta1/report_errors_service.rst b/docs/errorreporting_v1beta1/report_errors_service.rst deleted file mode 100644 index ccddb8b0..00000000 --- a/docs/errorreporting_v1beta1/report_errors_service.rst +++ /dev/null @@ -1,6 +0,0 @@ -ReportErrorsService -------------------------------------- - -.. automodule:: google.cloud.errorreporting_v1beta1.services.report_errors_service - :members: - :inherited-members: diff --git a/docs/errorreporting_v1beta1/services.rst b/docs/errorreporting_v1beta1/services.rst index e888027f..a5ec3b92 100644 --- a/docs/errorreporting_v1beta1/services.rst +++ b/docs/errorreporting_v1beta1/services.rst @@ -1,8 +1,12 @@ Services for Google Cloud Errorreporting v1beta1 API ==================================================== -.. toctree:: - :maxdepth: 2 - error_group_service - error_stats_service - report_errors_service +.. automodule:: google.cloud.errorreporting_v1beta1.services.error_group_service + :members: + :inherited-members: +.. automodule:: google.cloud.errorreporting_v1beta1.services.error_stats_service + :members: + :inherited-members: +.. automodule:: google.cloud.errorreporting_v1beta1.services.report_errors_service + :members: + :inherited-members: diff --git a/docs/errorreporting_v1beta1/types.rst b/docs/errorreporting_v1beta1/types.rst index 179256c7..08851dbe 100644 --- a/docs/errorreporting_v1beta1/types.rst +++ b/docs/errorreporting_v1beta1/types.rst @@ -3,5 +3,4 @@ Types for Google Cloud Errorreporting v1beta1 API .. automodule:: google.cloud.errorreporting_v1beta1.types :members: - :undoc-members: :show-inheritance: diff --git a/google/cloud/errorreporting_v1beta1/__init__.py b/google/cloud/errorreporting_v1beta1/__init__.py index 43fc283f..8db40bd7 100644 --- a/google/cloud/errorreporting_v1beta1/__init__.py +++ b/google/cloud/errorreporting_v1beta1/__init__.py @@ -51,7 +51,6 @@ "ErrorEvent", "ErrorGroup", "ErrorGroupOrder", - "ErrorGroupServiceClient", "ErrorGroupStats", "ErrorStatsServiceClient", "GetGroupRequest", @@ -63,6 +62,7 @@ "QueryTimeRange", "ReportErrorEventRequest", "ReportErrorEventResponse", + "ReportErrorsServiceClient", "ReportedErrorEvent", "ServiceContext", "ServiceContextFilter", @@ -71,5 +71,5 @@ "TimedCountAlignment", "TrackingIssue", "UpdateGroupRequest", - "ReportErrorsServiceClient", + "ErrorGroupServiceClient", ) diff --git a/google/cloud/errorreporting_v1beta1/services/error_group_service/async_client.py b/google/cloud/errorreporting_v1beta1/services/error_group_service/async_client.py index c44df685..26c03996 100644 --- a/google/cloud/errorreporting_v1beta1/services/error_group_service/async_client.py +++ b/google/cloud/errorreporting_v1beta1/services/error_group_service/async_client.py @@ -78,7 +78,6 @@ class ErrorGroupServiceAsyncClient: ErrorGroupServiceClient.parse_common_location_path ) - from_service_account_info = ErrorGroupServiceClient.from_service_account_info from_service_account_file = ErrorGroupServiceClient.from_service_account_file from_service_account_json = from_service_account_file @@ -155,7 +154,7 @@ async def get_group( r"""Get the specified group. Args: - request (:class:`google.cloud.errorreporting_v1beta1.types.GetGroupRequest`): + request (:class:`~.error_group_service.GetGroupRequest`): The request object. A request to return an individual group. group_name (:class:`str`): @@ -165,7 +164,6 @@ async def get_group( to return a list of groups belonging to this project. Example: ``projects/my-project-123/groups/my-group`` - This corresponds to the ``group_name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -177,7 +175,7 @@ async def get_group( sent along with the request as metadata. Returns: - google.cloud.errorreporting_v1beta1.types.ErrorGroup: + ~.common.ErrorGroup: Description of a group of similar error events. @@ -235,13 +233,12 @@ async def update_group( Fails if the group does not exist. Args: - request (:class:`google.cloud.errorreporting_v1beta1.types.UpdateGroupRequest`): + request (:class:`~.error_group_service.UpdateGroupRequest`): The request object. A request to replace the existing data for the given group. - group (:class:`google.cloud.errorreporting_v1beta1.types.ErrorGroup`): + group (:class:`~.common.ErrorGroup`): Required. The group which replaces the resource on the server. - This corresponds to the ``group`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -253,7 +250,7 @@ async def update_group( sent along with the request as metadata. Returns: - google.cloud.errorreporting_v1beta1.types.ErrorGroup: + ~.common.ErrorGroup: Description of a group of similar error events. diff --git a/google/cloud/errorreporting_v1beta1/services/error_group_service/client.py b/google/cloud/errorreporting_v1beta1/services/error_group_service/client.py index 868b2bcb..d1656df2 100644 --- a/google/cloud/errorreporting_v1beta1/services/error_group_service/client.py +++ b/google/cloud/errorreporting_v1beta1/services/error_group_service/client.py @@ -112,22 +112,6 @@ def _get_default_mtls_endpoint(api_endpoint): 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: - ErrorGroupServiceClient: 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 @@ -140,7 +124,7 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): kwargs: Additional arguments to pass to the constructor. Returns: - ErrorGroupServiceClient: The constructed client. + {@api.name}: The constructed client. """ credentials = service_account.Credentials.from_service_account_file(filename) kwargs["credentials"] = credentials @@ -243,10 +227,10 @@ def __init__( 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, ErrorGroupServiceTransport]): The + transport (Union[str, ~.ErrorGroupServiceTransport]): The transport to use. If set to None, a transport is chosen automatically. - client_options (google.api_core.client_options.ClientOptions): Custom options for the + client_options (client_options_lib.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 @@ -356,17 +340,16 @@ def get_group( r"""Get the specified group. Args: - request (google.cloud.errorreporting_v1beta1.types.GetGroupRequest): + request (:class:`~.error_group_service.GetGroupRequest`): The request object. A request to return an individual group. - group_name (str): + group_name (:class:`str`): The group resource name. Written as ``projects/{projectID}/groups/{group_name}``. Call ```groupStats.list`` `__ to return a list of groups belonging to this project. Example: ``projects/my-project-123/groups/my-group`` - This corresponds to the ``group_name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -378,7 +361,7 @@ def get_group( sent along with the request as metadata. Returns: - google.cloud.errorreporting_v1beta1.types.ErrorGroup: + ~.common.ErrorGroup: Description of a group of similar error events. @@ -437,13 +420,12 @@ def update_group( Fails if the group does not exist. Args: - request (google.cloud.errorreporting_v1beta1.types.UpdateGroupRequest): + request (:class:`~.error_group_service.UpdateGroupRequest`): The request object. A request to replace the existing data for the given group. - group (google.cloud.errorreporting_v1beta1.types.ErrorGroup): + group (:class:`~.common.ErrorGroup`): Required. The group which replaces the resource on the server. - This corresponds to the ``group`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -455,7 +437,7 @@ def update_group( sent along with the request as metadata. Returns: - google.cloud.errorreporting_v1beta1.types.ErrorGroup: + ~.common.ErrorGroup: Description of a group of similar error events. diff --git a/google/cloud/errorreporting_v1beta1/services/error_stats_service/async_client.py b/google/cloud/errorreporting_v1beta1/services/error_stats_service/async_client.py index 15cb7577..20e91256 100644 --- a/google/cloud/errorreporting_v1beta1/services/error_stats_service/async_client.py +++ b/google/cloud/errorreporting_v1beta1/services/error_stats_service/async_client.py @@ -81,7 +81,6 @@ class ErrorStatsServiceAsyncClient: ErrorStatsServiceClient.parse_common_location_path ) - from_service_account_info = ErrorStatsServiceClient.from_service_account_info from_service_account_file = ErrorStatsServiceClient.from_service_account_file from_service_account_json = from_service_account_file @@ -159,7 +158,7 @@ async def list_group_stats( r"""Lists the specified groups. Args: - request (:class:`google.cloud.errorreporting_v1beta1.types.ListGroupStatsRequest`): + request (:class:`~.error_stats_service.ListGroupStatsRequest`): The request object. Specifies a set of `ErrorGroupStats` to return. project_name (:class:`str`): @@ -171,11 +170,10 @@ async def list_group_stats( Example: projects/my- project-123. - This corresponds to the ``project_name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - time_range (:class:`google.cloud.errorreporting_v1beta1.types.QueryTimeRange`): + time_range (:class:`~.error_stats_service.QueryTimeRange`): Optional. List data for the given time range. If not set, a default time range is used. The field time_range_begin in the response will specify the @@ -184,7 +182,6 @@ async def list_group_stats( unless the request contains an explicit group_id list. If a group_id list is given, also ErrorGroupStats with zero occurrences are returned. - This corresponds to the ``time_range`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -196,7 +193,7 @@ async def list_group_stats( sent along with the request as metadata. Returns: - google.cloud.errorreporting_v1beta1.services.error_stats_service.pagers.ListGroupStatsAsyncPager: + ~.pagers.ListGroupStatsAsyncPager: Contains a set of requested error group stats. Iterating over this object will yield @@ -265,7 +262,7 @@ async def list_events( r"""Lists the specified events. Args: - request (:class:`google.cloud.errorreporting_v1beta1.types.ListEventsRequest`): + request (:class:`~.error_stats_service.ListEventsRequest`): The request object. Specifies a set of error events to return. project_name (:class:`str`): @@ -274,14 +271,12 @@ async def list_events( Platform project ID `__. Example: ``projects/my-project-123``. - This corresponds to the ``project_name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. group_id (:class:`str`): Required. The group for which events shall be returned. - This corresponds to the ``group_id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -293,7 +288,7 @@ async def list_events( sent along with the request as metadata. Returns: - google.cloud.errorreporting_v1beta1.services.error_stats_service.pagers.ListEventsAsyncPager: + ~.pagers.ListEventsAsyncPager: Contains a set of requested error events. Iterating over this object will yield @@ -361,7 +356,7 @@ async def delete_events( r"""Deletes all error events of a given project. Args: - request (:class:`google.cloud.errorreporting_v1beta1.types.DeleteEventsRequest`): + request (:class:`~.error_stats_service.DeleteEventsRequest`): The request object. Deletes all events in the project. project_name (:class:`str`): Required. The resource name of the Google Cloud Platform @@ -369,7 +364,6 @@ async def delete_events( Platform project ID `__. Example: ``projects/my-project-123``. - This corresponds to the ``project_name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -381,7 +375,7 @@ async def delete_events( sent along with the request as metadata. Returns: - google.cloud.errorreporting_v1beta1.types.DeleteEventsResponse: + ~.error_stats_service.DeleteEventsResponse: Response message for deleting error events. diff --git a/google/cloud/errorreporting_v1beta1/services/error_stats_service/client.py b/google/cloud/errorreporting_v1beta1/services/error_stats_service/client.py index edc91a65..f04fbfef 100644 --- a/google/cloud/errorreporting_v1beta1/services/error_stats_service/client.py +++ b/google/cloud/errorreporting_v1beta1/services/error_stats_service/client.py @@ -115,22 +115,6 @@ def _get_default_mtls_endpoint(api_endpoint): 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: - ErrorStatsServiceClient: 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 @@ -143,7 +127,7 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): kwargs: Additional arguments to pass to the constructor. Returns: - ErrorStatsServiceClient: The constructed client. + {@api.name}: The constructed client. """ credentials = service_account.Credentials.from_service_account_file(filename) kwargs["credentials"] = credentials @@ -246,10 +230,10 @@ def __init__( 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, ErrorStatsServiceTransport]): The + transport (Union[str, ~.ErrorStatsServiceTransport]): The transport to use. If set to None, a transport is chosen automatically. - client_options (google.api_core.client_options.ClientOptions): Custom options for the + client_options (client_options_lib.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 @@ -360,10 +344,10 @@ def list_group_stats( r"""Lists the specified groups. Args: - request (google.cloud.errorreporting_v1beta1.types.ListGroupStatsRequest): + request (:class:`~.error_stats_service.ListGroupStatsRequest`): The request object. Specifies a set of `ErrorGroupStats` to return. - project_name (str): + project_name (:class:`str`): Required. The resource name of the Google Cloud Platform project. Written as projects/ plus the projects/my- project-123. - This corresponds to the ``project_name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - time_range (google.cloud.errorreporting_v1beta1.types.QueryTimeRange): + time_range (:class:`~.error_stats_service.QueryTimeRange`): Optional. List data for the given time range. If not set, a default time range is used. The field time_range_begin in the response will specify the @@ -385,7 +368,6 @@ def list_group_stats( unless the request contains an explicit group_id list. If a group_id list is given, also ErrorGroupStats with zero occurrences are returned. - This corresponds to the ``time_range`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -397,7 +379,7 @@ def list_group_stats( sent along with the request as metadata. Returns: - google.cloud.errorreporting_v1beta1.services.error_stats_service.pagers.ListGroupStatsPager: + ~.pagers.ListGroupStatsPager: Contains a set of requested error group stats. Iterating over this object will yield @@ -467,23 +449,21 @@ def list_events( r"""Lists the specified events. Args: - request (google.cloud.errorreporting_v1beta1.types.ListEventsRequest): + request (:class:`~.error_stats_service.ListEventsRequest`): The request object. Specifies a set of error events to return. - project_name (str): + project_name (:class:`str`): Required. The resource name of the Google Cloud Platform project. Written as ``projects/`` plus the `Google Cloud Platform project ID `__. Example: ``projects/my-project-123``. - This corresponds to the ``project_name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - group_id (str): + group_id (:class:`str`): Required. The group for which events shall be returned. - This corresponds to the ``group_id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -495,7 +475,7 @@ def list_events( sent along with the request as metadata. Returns: - google.cloud.errorreporting_v1beta1.services.error_stats_service.pagers.ListEventsPager: + ~.pagers.ListEventsPager: Contains a set of requested error events. Iterating over this object will yield @@ -564,15 +544,14 @@ def delete_events( r"""Deletes all error events of a given project. Args: - request (google.cloud.errorreporting_v1beta1.types.DeleteEventsRequest): + request (:class:`~.error_stats_service.DeleteEventsRequest`): The request object. Deletes all events in the project. - project_name (str): + project_name (:class:`str`): Required. The resource name of the Google Cloud Platform project. Written as ``projects/`` plus the `Google Cloud Platform project ID `__. Example: ``projects/my-project-123``. - This corresponds to the ``project_name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -584,7 +563,7 @@ def delete_events( sent along with the request as metadata. Returns: - google.cloud.errorreporting_v1beta1.types.DeleteEventsResponse: + ~.error_stats_service.DeleteEventsResponse: Response message for deleting error events. diff --git a/google/cloud/errorreporting_v1beta1/services/error_stats_service/pagers.py b/google/cloud/errorreporting_v1beta1/services/error_stats_service/pagers.py index 63bb8413..02a4faa4 100644 --- a/google/cloud/errorreporting_v1beta1/services/error_stats_service/pagers.py +++ b/google/cloud/errorreporting_v1beta1/services/error_stats_service/pagers.py @@ -25,7 +25,7 @@ class ListGroupStatsPager: """A pager for iterating through ``list_group_stats`` requests. This class thinly wraps an initial - :class:`google.cloud.errorreporting_v1beta1.types.ListGroupStatsResponse` object, and + :class:`~.error_stats_service.ListGroupStatsResponse` object, and provides an ``__iter__`` method to iterate through its ``error_group_stats`` field. @@ -34,7 +34,7 @@ class ListGroupStatsPager: through the ``error_group_stats`` field on the corresponding responses. - All the usual :class:`google.cloud.errorreporting_v1beta1.types.ListGroupStatsResponse` + All the usual :class:`~.error_stats_service.ListGroupStatsResponse` attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup. """ @@ -52,9 +52,9 @@ def __init__( Args: method (Callable): The method that was originally called, and which instantiated this pager. - request (google.cloud.errorreporting_v1beta1.types.ListGroupStatsRequest): + request (:class:`~.error_stats_service.ListGroupStatsRequest`): The initial request object. - response (google.cloud.errorreporting_v1beta1.types.ListGroupStatsResponse): + response (:class:`~.error_stats_service.ListGroupStatsResponse`): The initial response object. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. @@ -87,7 +87,7 @@ class ListGroupStatsAsyncPager: """A pager for iterating through ``list_group_stats`` requests. This class thinly wraps an initial - :class:`google.cloud.errorreporting_v1beta1.types.ListGroupStatsResponse` object, and + :class:`~.error_stats_service.ListGroupStatsResponse` object, and provides an ``__aiter__`` method to iterate through its ``error_group_stats`` field. @@ -96,7 +96,7 @@ class ListGroupStatsAsyncPager: through the ``error_group_stats`` field on the corresponding responses. - All the usual :class:`google.cloud.errorreporting_v1beta1.types.ListGroupStatsResponse` + All the usual :class:`~.error_stats_service.ListGroupStatsResponse` attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup. """ @@ -114,9 +114,9 @@ def __init__( Args: method (Callable): The method that was originally called, and which instantiated this pager. - request (google.cloud.errorreporting_v1beta1.types.ListGroupStatsRequest): + request (:class:`~.error_stats_service.ListGroupStatsRequest`): The initial request object. - response (google.cloud.errorreporting_v1beta1.types.ListGroupStatsResponse): + response (:class:`~.error_stats_service.ListGroupStatsResponse`): The initial response object. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. @@ -153,7 +153,7 @@ class ListEventsPager: """A pager for iterating through ``list_events`` requests. This class thinly wraps an initial - :class:`google.cloud.errorreporting_v1beta1.types.ListEventsResponse` object, and + :class:`~.error_stats_service.ListEventsResponse` object, and provides an ``__iter__`` method to iterate through its ``error_events`` field. @@ -162,7 +162,7 @@ class ListEventsPager: through the ``error_events`` field on the corresponding responses. - All the usual :class:`google.cloud.errorreporting_v1beta1.types.ListEventsResponse` + All the usual :class:`~.error_stats_service.ListEventsResponse` attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup. """ @@ -180,9 +180,9 @@ def __init__( Args: method (Callable): The method that was originally called, and which instantiated this pager. - request (google.cloud.errorreporting_v1beta1.types.ListEventsRequest): + request (:class:`~.error_stats_service.ListEventsRequest`): The initial request object. - response (google.cloud.errorreporting_v1beta1.types.ListEventsResponse): + response (:class:`~.error_stats_service.ListEventsResponse`): The initial response object. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. @@ -215,7 +215,7 @@ class ListEventsAsyncPager: """A pager for iterating through ``list_events`` requests. This class thinly wraps an initial - :class:`google.cloud.errorreporting_v1beta1.types.ListEventsResponse` object, and + :class:`~.error_stats_service.ListEventsResponse` object, and provides an ``__aiter__`` method to iterate through its ``error_events`` field. @@ -224,7 +224,7 @@ class ListEventsAsyncPager: through the ``error_events`` field on the corresponding responses. - All the usual :class:`google.cloud.errorreporting_v1beta1.types.ListEventsResponse` + All the usual :class:`~.error_stats_service.ListEventsResponse` attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup. """ @@ -242,9 +242,9 @@ def __init__( Args: method (Callable): The method that was originally called, and which instantiated this pager. - request (google.cloud.errorreporting_v1beta1.types.ListEventsRequest): + request (:class:`~.error_stats_service.ListEventsRequest`): The initial request object. - response (google.cloud.errorreporting_v1beta1.types.ListEventsResponse): + response (:class:`~.error_stats_service.ListEventsResponse`): The initial response object. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. diff --git a/google/cloud/errorreporting_v1beta1/services/report_errors_service/async_client.py b/google/cloud/errorreporting_v1beta1/services/report_errors_service/async_client.py index 9562776f..3b7c6fcf 100644 --- a/google/cloud/errorreporting_v1beta1/services/report_errors_service/async_client.py +++ b/google/cloud/errorreporting_v1beta1/services/report_errors_service/async_client.py @@ -72,7 +72,6 @@ class ReportErrorsServiceAsyncClient: ReportErrorsServiceClient.parse_common_location_path ) - from_service_account_info = ReportErrorsServiceClient.from_service_account_info from_service_account_file = ReportErrorsServiceClient.from_service_account_file from_service_account_json = from_service_account_file @@ -158,7 +157,7 @@ async def report_error_event( ``POST https://clouderrorreporting.googleapis.com/v1beta1/projects/example-project/events:report?key=123ABC456`` Args: - request (:class:`google.cloud.errorreporting_v1beta1.types.ReportErrorEventRequest`): + request (:class:`~.report_errors_service.ReportErrorEventRequest`): The request object. A request for reporting an individual error event. project_name (:class:`str`): @@ -167,14 +166,12 @@ async def report_error_event( Platform project ID `__. Example: ``projects/my-project-123``. - This corresponds to the ``project_name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - event (:class:`google.cloud.errorreporting_v1beta1.types.ReportedErrorEvent`): + event (:class:`~.report_errors_service.ReportedErrorEvent`): Required. The error event to be reported. - This corresponds to the ``event`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -186,7 +183,7 @@ async def report_error_event( sent along with the request as metadata. Returns: - google.cloud.errorreporting_v1beta1.types.ReportErrorEventResponse: + ~.report_errors_service.ReportErrorEventResponse: Response for reporting an individual error event. Data may be added to this message in the future. diff --git a/google/cloud/errorreporting_v1beta1/services/report_errors_service/client.py b/google/cloud/errorreporting_v1beta1/services/report_errors_service/client.py index 1510c7d6..b10ecca4 100644 --- a/google/cloud/errorreporting_v1beta1/services/report_errors_service/client.py +++ b/google/cloud/errorreporting_v1beta1/services/report_errors_service/client.py @@ -111,22 +111,6 @@ def _get_default_mtls_endpoint(api_endpoint): 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: - ReportErrorsServiceClient: 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 @@ -139,7 +123,7 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): kwargs: Additional arguments to pass to the constructor. Returns: - ReportErrorsServiceClient: The constructed client. + {@api.name}: The constructed client. """ credentials = service_account.Credentials.from_service_account_file(filename) kwargs["credentials"] = credentials @@ -231,10 +215,10 @@ def __init__( 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, ReportErrorsServiceTransport]): The + transport (Union[str, ~.ReportErrorsServiceTransport]): The transport to use. If set to None, a transport is chosen automatically. - client_options (google.api_core.client_options.ClientOptions): Custom options for the + client_options (client_options_lib.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 @@ -352,23 +336,21 @@ def report_error_event( ``POST https://clouderrorreporting.googleapis.com/v1beta1/projects/example-project/events:report?key=123ABC456`` Args: - request (google.cloud.errorreporting_v1beta1.types.ReportErrorEventRequest): + request (:class:`~.report_errors_service.ReportErrorEventRequest`): The request object. A request for reporting an individual error event. - project_name (str): + project_name (:class:`str`): Required. The resource name of the Google Cloud Platform project. Written as ``projects/`` plus the `Google Cloud Platform project ID `__. Example: ``projects/my-project-123``. - This corresponds to the ``project_name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - event (google.cloud.errorreporting_v1beta1.types.ReportedErrorEvent): + event (:class:`~.report_errors_service.ReportedErrorEvent`): Required. The error event to be reported. - This corresponds to the ``event`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -380,7 +362,7 @@ def report_error_event( sent along with the request as metadata. Returns: - google.cloud.errorreporting_v1beta1.types.ReportErrorEventResponse: + ~.report_errors_service.ReportErrorEventResponse: Response for reporting an individual error event. Data may be added to this message in the future. diff --git a/google/cloud/errorreporting_v1beta1/types/common.py b/google/cloud/errorreporting_v1beta1/types/common.py index e8371063..779aa453 100644 --- a/google/cloud/errorreporting_v1beta1/types/common.py +++ b/google/cloud/errorreporting_v1beta1/types/common.py @@ -48,7 +48,7 @@ class ErrorGroup(proto.Message): the same kind of error occurs in different service contexts, it will receive the same group ID. - tracking_issues (Sequence[google.cloud.errorreporting_v1beta1.types.TrackingIssue]): + tracking_issues (Sequence[~.common.TrackingIssue]): Associated tracking issues. """ @@ -80,17 +80,17 @@ class ErrorEvent(proto.Message): system. Attributes: - event_time (google.protobuf.timestamp_pb2.Timestamp): + event_time (~.timestamp.Timestamp): Time when the event occurred as provided in the error report. If the report did not contain a timestamp, the time the error was received by the Error Reporting system is used. - service_context (google.cloud.errorreporting_v1beta1.types.ServiceContext): + service_context (~.common.ServiceContext): The ``ServiceContext`` for which this error was reported. message (str): The stack trace that was reported or logged by the service. - context (google.cloud.errorreporting_v1beta1.types.ErrorContext): + context (~.common.ErrorContext): Data about the context in which the error occurred. """ @@ -149,7 +149,7 @@ class ErrorContext(proto.Message): Engine logs. Attributes: - http_request (google.cloud.errorreporting_v1beta1.types.HttpRequestContext): + http_request (~.common.HttpRequestContext): The HTTP request which was processed when the error was triggered. user (str): @@ -160,7 +160,7 @@ class ErrorContext(proto.Message): this case the Error Reporting system will use other data, such as remote IP address, to distinguish affected users. See ``affected_users_count`` in ``ErrorGroupStats``. - report_location (google.cloud.errorreporting_v1beta1.types.SourceLocation): + report_location (~.common.SourceLocation): The location in the source code where the decision was made to report the error, usually the place where it was logged. For a logged diff --git a/google/cloud/errorreporting_v1beta1/types/error_group_service.py b/google/cloud/errorreporting_v1beta1/types/error_group_service.py index 632e072f..70aa92a8 100644 --- a/google/cloud/errorreporting_v1beta1/types/error_group_service.py +++ b/google/cloud/errorreporting_v1beta1/types/error_group_service.py @@ -47,7 +47,7 @@ class UpdateGroupRequest(proto.Message): r"""A request to replace the existing data for the given group. Attributes: - group (google.cloud.errorreporting_v1beta1.types.ErrorGroup): + group (~.common.ErrorGroup): Required. The group which replaces the resource on the server. """ diff --git a/google/cloud/errorreporting_v1beta1/types/error_stats_service.py b/google/cloud/errorreporting_v1beta1/types/error_stats_service.py index dfd08020..51a14e89 100644 --- a/google/cloud/errorreporting_v1beta1/types/error_stats_service.py +++ b/google/cloud/errorreporting_v1beta1/types/error_stats_service.py @@ -75,13 +75,13 @@ class ListGroupStatsRequest(proto.Message): group_id (Sequence[str]): Optional. List all ErrorGroupStats with these IDs. - service_filter (google.cloud.errorreporting_v1beta1.types.ServiceContextFilter): + service_filter (~.error_stats_service.ServiceContextFilter): Optional. List only ErrorGroupStats which belong to a service context that matches the filter. Data for all service contexts is returned if this field is not specified. - time_range (google.cloud.errorreporting_v1beta1.types.QueryTimeRange): + time_range (~.error_stats_service.QueryTimeRange): Optional. List data for the given time range. If not set, a default time range is used. The field time_range_begin in the response will specify the beginning of this time range. @@ -89,17 +89,17 @@ class ListGroupStatsRequest(proto.Message): range are returned, unless the request contains an explicit group_id list. If a group_id list is given, also ErrorGroupStats with zero occurrences are returned. - timed_count_duration (google.protobuf.duration_pb2.Duration): + timed_count_duration (~.duration.Duration): Optional. The preferred duration for a single returned ``TimedCount``. If not set, no timed counts are returned. - alignment (google.cloud.errorreporting_v1beta1.types.TimedCountAlignment): + alignment (~.error_stats_service.TimedCountAlignment): Optional. The alignment of the timed counts to be returned. Default is ``ALIGNMENT_EQUAL_AT_END``. - alignment_time (google.protobuf.timestamp_pb2.Timestamp): + alignment_time (~.timestamp.Timestamp): Optional. Time where the timed counts shall be aligned if rounded alignment is chosen. Default is 00:00 UTC. - order (google.cloud.errorreporting_v1beta1.types.ErrorGroupOrder): + order (~.error_stats_service.ErrorGroupOrder): Optional. The sort order in which the results are returned. Default is ``COUNT_DESC``. page_size (int): @@ -140,7 +140,7 @@ class ListGroupStatsResponse(proto.Message): r"""Contains a set of requested error group stats. Attributes: - error_group_stats (Sequence[google.cloud.errorreporting_v1beta1.types.ErrorGroupStats]): + error_group_stats (Sequence[~.error_stats_service.ErrorGroupStats]): The error group stats which match the given request. next_page_token (str): @@ -148,7 +148,7 @@ class ListGroupStatsResponse(proto.Message): Pass this token, along with the same query parameters as the first request, to view the next page of results. - time_range_begin (google.protobuf.timestamp_pb2.Timestamp): + time_range_begin (~.timestamp.Timestamp): The timestamp specifies the start time to which the request was restricted. The start time is set based on the requested time range. It may @@ -177,7 +177,7 @@ class ErrorGroupStats(proto.Message): criteria, such as a given time period and/or service filter. Attributes: - group (google.cloud.errorreporting_v1beta1.types.ErrorGroup): + group (~.common.ErrorGroup): Group data that is independent of the filter criteria. count (int): @@ -195,22 +195,22 @@ class ErrorGroupStats(proto.Message): provided in the error report. If more users are implicitly affected, such as due to a crash of the whole service, this is not reflected here. - timed_counts (Sequence[google.cloud.errorreporting_v1beta1.types.TimedCount]): + timed_counts (Sequence[~.error_stats_service.TimedCount]): Approximate number of occurrences over time. Timed counts returned by ListGroups are guaranteed to be: - Inside the requested time interval - Non-overlapping, and - Ordered by ascending time. - first_seen_time (google.protobuf.timestamp_pb2.Timestamp): + first_seen_time (~.timestamp.Timestamp): Approximate first occurrence that was ever seen for this group and which matches the given filter criteria, ignoring the time_range that was specified in the request. - last_seen_time (google.protobuf.timestamp_pb2.Timestamp): + last_seen_time (~.timestamp.Timestamp): Approximate last occurrence that was ever seen for this group and which matches the given filter criteria, ignoring the time_range that was specified in the request. - affected_services (Sequence[google.cloud.errorreporting_v1beta1.types.ServiceContext]): + affected_services (Sequence[~.common.ServiceContext]): Service contexts with a non-zero error count for the given filter criteria. This list can be truncated if multiple services are affected. Refer to ``num_affected_services`` @@ -218,7 +218,7 @@ class ErrorGroupStats(proto.Message): num_affected_services (int): The total number of services with a non-zero error count for the given filter criteria. - representative (google.cloud.errorreporting_v1beta1.types.ErrorEvent): + representative (~.common.ErrorEvent): An arbitrary event that is chosen as representative for the whole group. The representative event is intended to be used as a @@ -259,10 +259,10 @@ class TimedCount(proto.Message): count (int): Approximate number of occurrences in the given time period. - start_time (google.protobuf.timestamp_pb2.Timestamp): + start_time (~.timestamp.Timestamp): Start of the time period to which ``count`` refers (included). - end_time (google.protobuf.timestamp_pb2.Timestamp): + end_time (~.timestamp.Timestamp): End of the time period to which ``count`` refers (excluded). """ @@ -286,12 +286,12 @@ class ListEventsRequest(proto.Message): group_id (str): Required. The group for which events shall be returned. - service_filter (google.cloud.errorreporting_v1beta1.types.ServiceContextFilter): + service_filter (~.error_stats_service.ServiceContextFilter): Optional. List only ErrorGroups which belong to a service context that matches the filter. Data for all service contexts is returned if this field is not specified. - time_range (google.cloud.errorreporting_v1beta1.types.QueryTimeRange): + time_range (~.error_stats_service.QueryTimeRange): Optional. List only data for the given time range. If not set a default time range is used. The field time_range_begin in the response will specify the beginning of this time @@ -323,7 +323,7 @@ class ListEventsResponse(proto.Message): r"""Contains a set of requested error events. Attributes: - error_events (Sequence[google.cloud.errorreporting_v1beta1.types.ErrorEvent]): + error_events (Sequence[~.common.ErrorEvent]): The error events which match the given request. next_page_token (str): @@ -331,7 +331,7 @@ class ListEventsResponse(proto.Message): Pass this token, along with the same query parameters as the first request, to view the next page of results. - time_range_begin (google.protobuf.timestamp_pb2.Timestamp): + time_range_begin (~.timestamp.Timestamp): The timestamp specifies the start time to which the request was restricted. """ @@ -356,7 +356,7 @@ class QueryTimeRange(proto.Message): durations might be adjusted for lower durations. Attributes: - period (google.cloud.errorreporting_v1beta1.types.QueryTimeRange.Period): + period (~.error_stats_service.QueryTimeRange.Period): Restricts the query to the specified time range. """ diff --git a/google/cloud/errorreporting_v1beta1/types/report_errors_service.py b/google/cloud/errorreporting_v1beta1/types/report_errors_service.py index e53fa5e5..1a66727b 100644 --- a/google/cloud/errorreporting_v1beta1/types/report_errors_service.py +++ b/google/cloud/errorreporting_v1beta1/types/report_errors_service.py @@ -42,7 +42,7 @@ class ReportErrorEventRequest(proto.Message): Platform project ID `__. Example: ``projects/my-project-123``. - event (google.cloud.errorreporting_v1beta1.types.ReportedErrorEvent): + event (~.report_errors_service.ReportedErrorEvent): Required. The error event to be reported. """ @@ -62,12 +62,12 @@ class ReportedErrorEvent(proto.Message): system. Attributes: - event_time (google.protobuf.timestamp_pb2.Timestamp): + event_time (~.timestamp.Timestamp): Optional. Time when the event occurred. If not provided, the time when the event was received by the Error Reporting system will be used. - service_context (google.cloud.errorreporting_v1beta1.types.ServiceContext): + service_context (~.common.ServiceContext): Required. The service context in which this error has occurred. message (str): @@ -96,7 +96,7 @@ class ReportedErrorEvent(proto.Message): ```(string)$exception`` `__. - **Go**: Must be the return value of ```runtime.Stack()`` `__. - context (google.cloud.errorreporting_v1beta1.types.ErrorContext): + context (~.common.ErrorContext): Optional. A description of the context in which the error occurred. """ diff --git a/synth.metadata b/synth.metadata index feb5fa55..330ea88c 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,15 +4,15 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/python-error-reporting.git", - "sha": "c4b168d1f4e045d72487abba88e118a15b1c99ef" + "sha": "b6887650c28d9fce253ed5894bb2d64a4fedae19" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "4d19fc01775b142dd392f4bd82bdf8810202d061", - "internalRef": "352645446" + "sha": "dd372aa22ded7a8ba6f0e03a80e06358a3fa0907", + "internalRef": "347055288" } }, { @@ -42,7 +42,6 @@ } ], "generatedFiles": [ - ".coveragerc", ".flake8", ".github/CONTRIBUTING.md", ".github/ISSUE_TEMPLATE/bug_report.md", @@ -96,9 +95,6 @@ "docs/_static/custom.css", "docs/_templates/layout.html", "docs/conf.py", - "docs/errorreporting_v1beta1/error_group_service.rst", - "docs/errorreporting_v1beta1/error_stats_service.rst", - "docs/errorreporting_v1beta1/report_errors_service.rst", "docs/errorreporting_v1beta1/services.rst", "docs/errorreporting_v1beta1/types.rst", "docs/multiprocessing.rst", diff --git a/tests/unit/gapic/errorreporting_v1beta1/test_error_group_service.py b/tests/unit/gapic/errorreporting_v1beta1/test_error_group_service.py index 8c82e2db..da93c3df 100644 --- a/tests/unit/gapic/errorreporting_v1beta1/test_error_group_service.py +++ b/tests/unit/gapic/errorreporting_v1beta1/test_error_group_service.py @@ -89,21 +89,8 @@ def test__get_default_mtls_endpoint(): ) -def test_error_group_service_client_from_service_account_info(): - creds = credentials.AnonymousCredentials() - with mock.patch.object( - service_account.Credentials, "from_service_account_info" - ) as factory: - factory.return_value = creds - info = {"valid": True} - client = ErrorGroupServiceClient.from_service_account_info(info) - assert client.transport._credentials == creds - - assert client.transport._host == "clouderrorreporting.googleapis.com:443" - - @pytest.mark.parametrize( - "client_class", [ErrorGroupServiceClient, ErrorGroupServiceAsyncClient,] + "client_class", [ErrorGroupServiceClient, ErrorGroupServiceAsyncClient] ) def test_error_group_service_client_from_service_account_file(client_class): creds = credentials.AnonymousCredentials() @@ -122,10 +109,7 @@ def test_error_group_service_client_from_service_account_file(client_class): def test_error_group_service_client_get_transport_class(): transport = ErrorGroupServiceClient.get_transport_class() - available_transports = [ - transports.ErrorGroupServiceGrpcTransport, - ] - assert transport in available_transports + assert transport == transports.ErrorGroupServiceGrpcTransport transport = ErrorGroupServiceClient.get_transport_class("grpc") assert transport == transports.ErrorGroupServiceGrpcTransport @@ -1051,7 +1035,7 @@ def test_error_group_service_host_with_port(): def test_error_group_service_grpc_transport_channel(): - channel = grpc.secure_channel("http://localhost/", grpc.local_channel_credentials()) + channel = grpc.insecure_channel("http://localhost/") # Check that channel is used if provided. transport = transports.ErrorGroupServiceGrpcTransport( @@ -1063,7 +1047,7 @@ def test_error_group_service_grpc_transport_channel(): def test_error_group_service_grpc_asyncio_transport_channel(): - channel = aio.secure_channel("http://localhost/", grpc.local_channel_credentials()) + channel = aio.insecure_channel("http://localhost/") # Check that channel is used if provided. transport = transports.ErrorGroupServiceGrpcAsyncIOTransport( @@ -1088,7 +1072,7 @@ def test_error_group_service_transport_channel_mtls_with_client_cert_source( "grpc.ssl_channel_credentials", autospec=True ) as grpc_ssl_channel_cred: with mock.patch.object( - transport_class, "create_channel" + transport_class, "create_channel", autospec=True ) as grpc_create_channel: mock_ssl_cred = mock.Mock() grpc_ssl_channel_cred.return_value = mock_ssl_cred @@ -1141,7 +1125,7 @@ def test_error_group_service_transport_channel_mtls_with_adc(transport_class): ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred), ): with mock.patch.object( - transport_class, "create_channel" + transport_class, "create_channel", autospec=True ) as grpc_create_channel: mock_grpc_channel = mock.Mock() grpc_create_channel.return_value = mock_grpc_channel diff --git a/tests/unit/gapic/errorreporting_v1beta1/test_error_stats_service.py b/tests/unit/gapic/errorreporting_v1beta1/test_error_stats_service.py index 672c74c9..2ea69420 100644 --- a/tests/unit/gapic/errorreporting_v1beta1/test_error_stats_service.py +++ b/tests/unit/gapic/errorreporting_v1beta1/test_error_stats_service.py @@ -92,21 +92,8 @@ def test__get_default_mtls_endpoint(): ) -def test_error_stats_service_client_from_service_account_info(): - creds = credentials.AnonymousCredentials() - with mock.patch.object( - service_account.Credentials, "from_service_account_info" - ) as factory: - factory.return_value = creds - info = {"valid": True} - client = ErrorStatsServiceClient.from_service_account_info(info) - assert client.transport._credentials == creds - - assert client.transport._host == "clouderrorreporting.googleapis.com:443" - - @pytest.mark.parametrize( - "client_class", [ErrorStatsServiceClient, ErrorStatsServiceAsyncClient,] + "client_class", [ErrorStatsServiceClient, ErrorStatsServiceAsyncClient] ) def test_error_stats_service_client_from_service_account_file(client_class): creds = credentials.AnonymousCredentials() @@ -125,10 +112,7 @@ def test_error_stats_service_client_from_service_account_file(client_class): def test_error_stats_service_client_get_transport_class(): transport = ErrorStatsServiceClient.get_transport_class() - available_transports = [ - transports.ErrorStatsServiceGrpcTransport, - ] - assert transport in available_transports + assert transport == transports.ErrorStatsServiceGrpcTransport transport = ErrorStatsServiceClient.get_transport_class("grpc") assert transport == transports.ErrorStatsServiceGrpcTransport @@ -1612,7 +1596,7 @@ def test_error_stats_service_host_with_port(): def test_error_stats_service_grpc_transport_channel(): - channel = grpc.secure_channel("http://localhost/", grpc.local_channel_credentials()) + channel = grpc.insecure_channel("http://localhost/") # Check that channel is used if provided. transport = transports.ErrorStatsServiceGrpcTransport( @@ -1624,7 +1608,7 @@ def test_error_stats_service_grpc_transport_channel(): def test_error_stats_service_grpc_asyncio_transport_channel(): - channel = aio.secure_channel("http://localhost/", grpc.local_channel_credentials()) + channel = aio.insecure_channel("http://localhost/") # Check that channel is used if provided. transport = transports.ErrorStatsServiceGrpcAsyncIOTransport( @@ -1649,7 +1633,7 @@ def test_error_stats_service_transport_channel_mtls_with_client_cert_source( "grpc.ssl_channel_credentials", autospec=True ) as grpc_ssl_channel_cred: with mock.patch.object( - transport_class, "create_channel" + transport_class, "create_channel", autospec=True ) as grpc_create_channel: mock_ssl_cred = mock.Mock() grpc_ssl_channel_cred.return_value = mock_ssl_cred @@ -1702,7 +1686,7 @@ def test_error_stats_service_transport_channel_mtls_with_adc(transport_class): ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred), ): with mock.patch.object( - transport_class, "create_channel" + transport_class, "create_channel", autospec=True ) as grpc_create_channel: mock_grpc_channel = mock.Mock() grpc_create_channel.return_value = mock_grpc_channel diff --git a/tests/unit/gapic/errorreporting_v1beta1/test_report_errors_service.py b/tests/unit/gapic/errorreporting_v1beta1/test_report_errors_service.py index 04b6850f..f84d267f 100644 --- a/tests/unit/gapic/errorreporting_v1beta1/test_report_errors_service.py +++ b/tests/unit/gapic/errorreporting_v1beta1/test_report_errors_service.py @@ -92,21 +92,8 @@ def test__get_default_mtls_endpoint(): ) -def test_report_errors_service_client_from_service_account_info(): - creds = credentials.AnonymousCredentials() - with mock.patch.object( - service_account.Credentials, "from_service_account_info" - ) as factory: - factory.return_value = creds - info = {"valid": True} - client = ReportErrorsServiceClient.from_service_account_info(info) - assert client.transport._credentials == creds - - assert client.transport._host == "clouderrorreporting.googleapis.com:443" - - @pytest.mark.parametrize( - "client_class", [ReportErrorsServiceClient, ReportErrorsServiceAsyncClient,] + "client_class", [ReportErrorsServiceClient, ReportErrorsServiceAsyncClient] ) def test_report_errors_service_client_from_service_account_file(client_class): creds = credentials.AnonymousCredentials() @@ -125,10 +112,7 @@ def test_report_errors_service_client_from_service_account_file(client_class): def test_report_errors_service_client_get_transport_class(): transport = ReportErrorsServiceClient.get_transport_class() - available_transports = [ - transports.ReportErrorsServiceGrpcTransport, - ] - assert transport in available_transports + assert transport == transports.ReportErrorsServiceGrpcTransport transport = ReportErrorsServiceClient.get_transport_class("grpc") assert transport == transports.ReportErrorsServiceGrpcTransport @@ -897,7 +881,7 @@ def test_report_errors_service_host_with_port(): def test_report_errors_service_grpc_transport_channel(): - channel = grpc.secure_channel("http://localhost/", grpc.local_channel_credentials()) + channel = grpc.insecure_channel("http://localhost/") # Check that channel is used if provided. transport = transports.ReportErrorsServiceGrpcTransport( @@ -909,7 +893,7 @@ def test_report_errors_service_grpc_transport_channel(): def test_report_errors_service_grpc_asyncio_transport_channel(): - channel = aio.secure_channel("http://localhost/", grpc.local_channel_credentials()) + channel = aio.insecure_channel("http://localhost/") # Check that channel is used if provided. transport = transports.ReportErrorsServiceGrpcAsyncIOTransport( @@ -934,7 +918,7 @@ def test_report_errors_service_transport_channel_mtls_with_client_cert_source( "grpc.ssl_channel_credentials", autospec=True ) as grpc_ssl_channel_cred: with mock.patch.object( - transport_class, "create_channel" + transport_class, "create_channel", autospec=True ) as grpc_create_channel: mock_ssl_cred = mock.Mock() grpc_ssl_channel_cred.return_value = mock_ssl_cred @@ -987,7 +971,7 @@ def test_report_errors_service_transport_channel_mtls_with_adc(transport_class): ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred), ): with mock.patch.object( - transport_class, "create_channel" + transport_class, "create_channel", autospec=True ) as grpc_create_channel: mock_grpc_channel = mock.Mock() grpc_create_channel.return_value = mock_grpc_channel From 5c7a8d27d43b953cf9116423199bc59994406b5a Mon Sep 17 00:00:00 2001 From: yoshi-automation Date: Sat, 6 Mar 2021 08:35:53 -0800 Subject: [PATCH 11/25] chore: upgrade gapic-generator-python to 0.40.5 PiperOrigin-RevId: 354996675 Source-Author: Google APIs Source-Date: Mon Feb 1 12:11:49 2021 -0800 Source-Repo: googleapis/googleapis Source-Sha: 20712b8fe95001b312f62c6c5f33e3e3ec92cfaf Source-Link: https://github.com/googleapis/googleapis/commit/20712b8fe95001b312f62c6c5f33e3e3ec92cfaf --- .coveragerc | 22 +- .../error_group_service.rst | 6 + .../error_stats_service.rst | 11 + .../report_errors_service.rst | 6 + docs/errorreporting_v1beta1/services.rst | 14 +- docs/errorreporting_v1beta1/types.rst | 1 + .../cloud/errorreporting_v1beta1/__init__.py | 4 +- .../error_group_service/async_client.py | 13 +- .../services/error_group_service/client.py | 54 +++-- .../error_group_service/transports/grpc.py | 23 +- .../transports/grpc_asyncio.py | 23 +- .../error_stats_service/async_client.py | 20 +- .../services/error_stats_service/client.py | 67 +++--- .../services/error_stats_service/pagers.py | 32 +-- .../error_stats_service/transports/grpc.py | 23 +- .../transports/grpc_asyncio.py | 23 +- .../report_errors_service/async_client.py | 9 +- .../services/report_errors_service/client.py | 50 +++-- .../report_errors_service/transports/grpc.py | 23 +- .../transports/grpc_asyncio.py | 23 +- .../errorreporting_v1beta1/types/common.py | 12 +- .../types/error_group_service.py | 2 +- .../types/error_stats_service.py | 42 ++-- .../types/report_errors_service.py | 8 +- synth.metadata | 10 +- .../test_error_group_service.py | 212 +++++++++++------- .../test_error_stats_service.py | 212 +++++++++++------- .../test_report_errors_service.py | 212 +++++++++++------- 28 files changed, 719 insertions(+), 438 deletions(-) create mode 100644 docs/errorreporting_v1beta1/error_group_service.rst create mode 100644 docs/errorreporting_v1beta1/error_stats_service.rst create mode 100644 docs/errorreporting_v1beta1/report_errors_service.rst diff --git a/.coveragerc b/.coveragerc index 10cb72e8..9a9b9f3e 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,27 +1,11 @@ -# -*- 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! [run] branch = True [report] fail_under = 100 show_missing = True -omit = google/cloud/errorreporting/__init__.py, .nox/* +omit = + google/cloud/errorreporting/__init__.py exclude_lines = # Re-enable the standard pragma pragma: NO COVER @@ -31,4 +15,4 @@ exclude_lines = # This is added at the module level as a safeguard for if someone # generates the code and tries to run it without pip installing. This # makes it virtually impossible to test properly. - except pkg_resources.DistributionNotFound \ No newline at end of file + except pkg_resources.DistributionNotFound diff --git a/docs/errorreporting_v1beta1/error_group_service.rst b/docs/errorreporting_v1beta1/error_group_service.rst new file mode 100644 index 00000000..dd213525 --- /dev/null +++ b/docs/errorreporting_v1beta1/error_group_service.rst @@ -0,0 +1,6 @@ +ErrorGroupService +----------------------------------- + +.. automodule:: google.cloud.errorreporting_v1beta1.services.error_group_service + :members: + :inherited-members: diff --git a/docs/errorreporting_v1beta1/error_stats_service.rst b/docs/errorreporting_v1beta1/error_stats_service.rst new file mode 100644 index 00000000..30d29e69 --- /dev/null +++ b/docs/errorreporting_v1beta1/error_stats_service.rst @@ -0,0 +1,11 @@ +ErrorStatsService +----------------------------------- + +.. automodule:: google.cloud.errorreporting_v1beta1.services.error_stats_service + :members: + :inherited-members: + + +.. automodule:: google.cloud.errorreporting_v1beta1.services.error_stats_service.pagers + :members: + :inherited-members: diff --git a/docs/errorreporting_v1beta1/report_errors_service.rst b/docs/errorreporting_v1beta1/report_errors_service.rst new file mode 100644 index 00000000..ccddb8b0 --- /dev/null +++ b/docs/errorreporting_v1beta1/report_errors_service.rst @@ -0,0 +1,6 @@ +ReportErrorsService +------------------------------------- + +.. automodule:: google.cloud.errorreporting_v1beta1.services.report_errors_service + :members: + :inherited-members: diff --git a/docs/errorreporting_v1beta1/services.rst b/docs/errorreporting_v1beta1/services.rst index a5ec3b92..e888027f 100644 --- a/docs/errorreporting_v1beta1/services.rst +++ b/docs/errorreporting_v1beta1/services.rst @@ -1,12 +1,8 @@ Services for Google Cloud Errorreporting v1beta1 API ==================================================== +.. toctree:: + :maxdepth: 2 -.. automodule:: google.cloud.errorreporting_v1beta1.services.error_group_service - :members: - :inherited-members: -.. automodule:: google.cloud.errorreporting_v1beta1.services.error_stats_service - :members: - :inherited-members: -.. automodule:: google.cloud.errorreporting_v1beta1.services.report_errors_service - :members: - :inherited-members: + error_group_service + error_stats_service + report_errors_service diff --git a/docs/errorreporting_v1beta1/types.rst b/docs/errorreporting_v1beta1/types.rst index 08851dbe..179256c7 100644 --- a/docs/errorreporting_v1beta1/types.rst +++ b/docs/errorreporting_v1beta1/types.rst @@ -3,4 +3,5 @@ Types for Google Cloud Errorreporting v1beta1 API .. automodule:: google.cloud.errorreporting_v1beta1.types :members: + :undoc-members: :show-inheritance: diff --git a/google/cloud/errorreporting_v1beta1/__init__.py b/google/cloud/errorreporting_v1beta1/__init__.py index 8db40bd7..b6f762a3 100644 --- a/google/cloud/errorreporting_v1beta1/__init__.py +++ b/google/cloud/errorreporting_v1beta1/__init__.py @@ -51,8 +51,8 @@ "ErrorEvent", "ErrorGroup", "ErrorGroupOrder", + "ErrorGroupServiceClient", "ErrorGroupStats", - "ErrorStatsServiceClient", "GetGroupRequest", "HttpRequestContext", "ListEventsRequest", @@ -71,5 +71,5 @@ "TimedCountAlignment", "TrackingIssue", "UpdateGroupRequest", - "ErrorGroupServiceClient", + "ErrorStatsServiceClient", ) diff --git a/google/cloud/errorreporting_v1beta1/services/error_group_service/async_client.py b/google/cloud/errorreporting_v1beta1/services/error_group_service/async_client.py index 26c03996..c44df685 100644 --- a/google/cloud/errorreporting_v1beta1/services/error_group_service/async_client.py +++ b/google/cloud/errorreporting_v1beta1/services/error_group_service/async_client.py @@ -78,6 +78,7 @@ class ErrorGroupServiceAsyncClient: ErrorGroupServiceClient.parse_common_location_path ) + from_service_account_info = ErrorGroupServiceClient.from_service_account_info from_service_account_file = ErrorGroupServiceClient.from_service_account_file from_service_account_json = from_service_account_file @@ -154,7 +155,7 @@ async def get_group( r"""Get the specified group. Args: - request (:class:`~.error_group_service.GetGroupRequest`): + request (:class:`google.cloud.errorreporting_v1beta1.types.GetGroupRequest`): The request object. A request to return an individual group. group_name (:class:`str`): @@ -164,6 +165,7 @@ async def get_group( to return a list of groups belonging to this project. Example: ``projects/my-project-123/groups/my-group`` + This corresponds to the ``group_name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -175,7 +177,7 @@ async def get_group( sent along with the request as metadata. Returns: - ~.common.ErrorGroup: + google.cloud.errorreporting_v1beta1.types.ErrorGroup: Description of a group of similar error events. @@ -233,12 +235,13 @@ async def update_group( Fails if the group does not exist. Args: - request (:class:`~.error_group_service.UpdateGroupRequest`): + request (:class:`google.cloud.errorreporting_v1beta1.types.UpdateGroupRequest`): The request object. A request to replace the existing data for the given group. - group (:class:`~.common.ErrorGroup`): + group (:class:`google.cloud.errorreporting_v1beta1.types.ErrorGroup`): Required. The group which replaces the resource on the server. + This corresponds to the ``group`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -250,7 +253,7 @@ async def update_group( sent along with the request as metadata. Returns: - ~.common.ErrorGroup: + google.cloud.errorreporting_v1beta1.types.ErrorGroup: Description of a group of similar error events. diff --git a/google/cloud/errorreporting_v1beta1/services/error_group_service/client.py b/google/cloud/errorreporting_v1beta1/services/error_group_service/client.py index d1656df2..2c00658d 100644 --- a/google/cloud/errorreporting_v1beta1/services/error_group_service/client.py +++ b/google/cloud/errorreporting_v1beta1/services/error_group_service/client.py @@ -112,6 +112,22 @@ def _get_default_mtls_endpoint(api_endpoint): 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: + ErrorGroupServiceClient: 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 @@ -124,7 +140,7 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): kwargs: Additional arguments to pass to the constructor. Returns: - {@api.name}: The constructed client. + ErrorGroupServiceClient: The constructed client. """ credentials = service_account.Credentials.from_service_account_file(filename) kwargs["credentials"] = credentials @@ -227,10 +243,10 @@ def __init__( 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, ~.ErrorGroupServiceTransport]): The + transport (Union[str, ErrorGroupServiceTransport]): The transport to use. If set to None, a transport is chosen automatically. - client_options (client_options_lib.ClientOptions): Custom options for the + client_options (google.api_core.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 @@ -266,21 +282,17 @@ def __init__( util.strtobool(os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false")) ) - ssl_credentials = None + client_cert_source_func = None is_mtls = False if use_client_cert: if client_options.client_cert_source: - import grpc # type: ignore - - cert, key = client_options.client_cert_source() - ssl_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) is_mtls = True + client_cert_source_func = client_options.client_cert_source else: - creds = SslCredentials() - is_mtls = creds.is_mtls - ssl_credentials = creds.ssl_credentials if is_mtls else None + is_mtls = mtls.has_default_client_cert_source() + client_cert_source_func = ( + mtls.default_client_cert_source() if is_mtls else None + ) # Figure out which api endpoint to use. if client_options.api_endpoint is not None: @@ -323,7 +335,7 @@ def __init__( credentials_file=client_options.credentials_file, host=api_endpoint, scopes=client_options.scopes, - ssl_channel_credentials=ssl_credentials, + client_cert_source_for_mtls=client_cert_source_func, quota_project_id=client_options.quota_project_id, client_info=client_info, ) @@ -340,16 +352,17 @@ def get_group( r"""Get the specified group. Args: - request (:class:`~.error_group_service.GetGroupRequest`): + request (google.cloud.errorreporting_v1beta1.types.GetGroupRequest): The request object. A request to return an individual group. - group_name (:class:`str`): + group_name (str): The group resource name. Written as ``projects/{projectID}/groups/{group_name}``. Call ```groupStats.list`` `__ to return a list of groups belonging to this project. Example: ``projects/my-project-123/groups/my-group`` + This corresponds to the ``group_name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -361,7 +374,7 @@ def get_group( sent along with the request as metadata. Returns: - ~.common.ErrorGroup: + google.cloud.errorreporting_v1beta1.types.ErrorGroup: Description of a group of similar error events. @@ -420,12 +433,13 @@ def update_group( Fails if the group does not exist. Args: - request (:class:`~.error_group_service.UpdateGroupRequest`): + request (google.cloud.errorreporting_v1beta1.types.UpdateGroupRequest): The request object. A request to replace the existing data for the given group. - group (:class:`~.common.ErrorGroup`): + group (google.cloud.errorreporting_v1beta1.types.ErrorGroup): Required. The group which replaces the resource on the server. + This corresponds to the ``group`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -437,7 +451,7 @@ def update_group( sent along with the request as metadata. Returns: - ~.common.ErrorGroup: + google.cloud.errorreporting_v1beta1.types.ErrorGroup: Description of a group of similar error events. diff --git a/google/cloud/errorreporting_v1beta1/services/error_group_service/transports/grpc.py b/google/cloud/errorreporting_v1beta1/services/error_group_service/transports/grpc.py index 102cdd39..b6a71e1f 100644 --- a/google/cloud/errorreporting_v1beta1/services/error_group_service/transports/grpc.py +++ b/google/cloud/errorreporting_v1beta1/services/error_group_service/transports/grpc.py @@ -58,6 +58,7 @@ def __init__( api_mtls_endpoint: str = None, client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, ssl_channel_credentials: grpc.ChannelCredentials = None, + client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: @@ -88,6 +89,10 @@ def __init__( ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials for 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 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): @@ -104,6 +109,11 @@ def __init__( """ self._ssl_channel_credentials = ssl_channel_credentials + 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: # Sanity check: Ensure that channel and credentials are not both # provided. @@ -113,11 +123,6 @@ def __init__( self._grpc_channel = channel self._ssl_channel_credentials = None elif api_mtls_endpoint: - warnings.warn( - "api_mtls_endpoint and client_cert_source are deprecated", - DeprecationWarning, - ) - host = ( api_mtls_endpoint if ":" in api_mtls_endpoint @@ -161,12 +166,18 @@ def __init__( scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id ) + 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 + ) + # create a new channel. The provided one is ignored. self._grpc_channel = type(self).create_channel( host, credentials=credentials, credentials_file=credentials_file, - ssl_credentials=ssl_channel_credentials, + ssl_credentials=self._ssl_channel_credentials, scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, options=[ diff --git a/google/cloud/errorreporting_v1beta1/services/error_group_service/transports/grpc_asyncio.py b/google/cloud/errorreporting_v1beta1/services/error_group_service/transports/grpc_asyncio.py index f6ed3855..6fd73663 100644 --- a/google/cloud/errorreporting_v1beta1/services/error_group_service/transports/grpc_asyncio.py +++ b/google/cloud/errorreporting_v1beta1/services/error_group_service/transports/grpc_asyncio.py @@ -102,6 +102,7 @@ def __init__( api_mtls_endpoint: str = None, client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, ssl_channel_credentials: grpc.ChannelCredentials = None, + client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, quota_project_id=None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: @@ -133,6 +134,10 @@ def __init__( ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials for 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 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): @@ -149,6 +154,11 @@ def __init__( """ self._ssl_channel_credentials = ssl_channel_credentials + 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: # Sanity check: Ensure that channel and credentials are not both # provided. @@ -158,11 +168,6 @@ def __init__( self._grpc_channel = channel self._ssl_channel_credentials = None elif api_mtls_endpoint: - warnings.warn( - "api_mtls_endpoint and client_cert_source are deprecated", - DeprecationWarning, - ) - host = ( api_mtls_endpoint if ":" in api_mtls_endpoint @@ -206,12 +211,18 @@ def __init__( scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id ) + 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 + ) + # create a new channel. The provided one is ignored. self._grpc_channel = type(self).create_channel( host, credentials=credentials, credentials_file=credentials_file, - ssl_credentials=ssl_channel_credentials, + ssl_credentials=self._ssl_channel_credentials, scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, options=[ diff --git a/google/cloud/errorreporting_v1beta1/services/error_stats_service/async_client.py b/google/cloud/errorreporting_v1beta1/services/error_stats_service/async_client.py index 20e91256..15cb7577 100644 --- a/google/cloud/errorreporting_v1beta1/services/error_stats_service/async_client.py +++ b/google/cloud/errorreporting_v1beta1/services/error_stats_service/async_client.py @@ -81,6 +81,7 @@ class ErrorStatsServiceAsyncClient: ErrorStatsServiceClient.parse_common_location_path ) + from_service_account_info = ErrorStatsServiceClient.from_service_account_info from_service_account_file = ErrorStatsServiceClient.from_service_account_file from_service_account_json = from_service_account_file @@ -158,7 +159,7 @@ async def list_group_stats( r"""Lists the specified groups. Args: - request (:class:`~.error_stats_service.ListGroupStatsRequest`): + request (:class:`google.cloud.errorreporting_v1beta1.types.ListGroupStatsRequest`): The request object. Specifies a set of `ErrorGroupStats` to return. project_name (:class:`str`): @@ -170,10 +171,11 @@ async def list_group_stats( Example: projects/my- project-123. + This corresponds to the ``project_name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - time_range (:class:`~.error_stats_service.QueryTimeRange`): + time_range (:class:`google.cloud.errorreporting_v1beta1.types.QueryTimeRange`): Optional. List data for the given time range. If not set, a default time range is used. The field time_range_begin in the response will specify the @@ -182,6 +184,7 @@ async def list_group_stats( unless the request contains an explicit group_id list. If a group_id list is given, also ErrorGroupStats with zero occurrences are returned. + This corresponds to the ``time_range`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -193,7 +196,7 @@ async def list_group_stats( sent along with the request as metadata. Returns: - ~.pagers.ListGroupStatsAsyncPager: + google.cloud.errorreporting_v1beta1.services.error_stats_service.pagers.ListGroupStatsAsyncPager: Contains a set of requested error group stats. Iterating over this object will yield @@ -262,7 +265,7 @@ async def list_events( r"""Lists the specified events. Args: - request (:class:`~.error_stats_service.ListEventsRequest`): + request (:class:`google.cloud.errorreporting_v1beta1.types.ListEventsRequest`): The request object. Specifies a set of error events to return. project_name (:class:`str`): @@ -271,12 +274,14 @@ async def list_events( Platform project ID `__. Example: ``projects/my-project-123``. + This corresponds to the ``project_name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. group_id (:class:`str`): Required. The group for which events shall be returned. + This corresponds to the ``group_id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -288,7 +293,7 @@ async def list_events( sent along with the request as metadata. Returns: - ~.pagers.ListEventsAsyncPager: + google.cloud.errorreporting_v1beta1.services.error_stats_service.pagers.ListEventsAsyncPager: Contains a set of requested error events. Iterating over this object will yield @@ -356,7 +361,7 @@ async def delete_events( r"""Deletes all error events of a given project. Args: - request (:class:`~.error_stats_service.DeleteEventsRequest`): + request (:class:`google.cloud.errorreporting_v1beta1.types.DeleteEventsRequest`): The request object. Deletes all events in the project. project_name (:class:`str`): Required. The resource name of the Google Cloud Platform @@ -364,6 +369,7 @@ async def delete_events( Platform project ID `__. Example: ``projects/my-project-123``. + This corresponds to the ``project_name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -375,7 +381,7 @@ async def delete_events( sent along with the request as metadata. Returns: - ~.error_stats_service.DeleteEventsResponse: + google.cloud.errorreporting_v1beta1.types.DeleteEventsResponse: Response message for deleting error events. diff --git a/google/cloud/errorreporting_v1beta1/services/error_stats_service/client.py b/google/cloud/errorreporting_v1beta1/services/error_stats_service/client.py index f04fbfef..ab63651e 100644 --- a/google/cloud/errorreporting_v1beta1/services/error_stats_service/client.py +++ b/google/cloud/errorreporting_v1beta1/services/error_stats_service/client.py @@ -115,6 +115,22 @@ def _get_default_mtls_endpoint(api_endpoint): 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: + ErrorStatsServiceClient: 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 @@ -127,7 +143,7 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): kwargs: Additional arguments to pass to the constructor. Returns: - {@api.name}: The constructed client. + ErrorStatsServiceClient: The constructed client. """ credentials = service_account.Credentials.from_service_account_file(filename) kwargs["credentials"] = credentials @@ -230,10 +246,10 @@ def __init__( 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, ~.ErrorStatsServiceTransport]): The + transport (Union[str, ErrorStatsServiceTransport]): The transport to use. If set to None, a transport is chosen automatically. - client_options (client_options_lib.ClientOptions): Custom options for the + client_options (google.api_core.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 @@ -269,21 +285,17 @@ def __init__( util.strtobool(os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false")) ) - ssl_credentials = None + client_cert_source_func = None is_mtls = False if use_client_cert: if client_options.client_cert_source: - import grpc # type: ignore - - cert, key = client_options.client_cert_source() - ssl_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) is_mtls = True + client_cert_source_func = client_options.client_cert_source else: - creds = SslCredentials() - is_mtls = creds.is_mtls - ssl_credentials = creds.ssl_credentials if is_mtls else None + is_mtls = mtls.has_default_client_cert_source() + client_cert_source_func = ( + mtls.default_client_cert_source() if is_mtls else None + ) # Figure out which api endpoint to use. if client_options.api_endpoint is not None: @@ -326,7 +338,7 @@ def __init__( credentials_file=client_options.credentials_file, host=api_endpoint, scopes=client_options.scopes, - ssl_channel_credentials=ssl_credentials, + client_cert_source_for_mtls=client_cert_source_func, quota_project_id=client_options.quota_project_id, client_info=client_info, ) @@ -344,10 +356,10 @@ def list_group_stats( r"""Lists the specified groups. Args: - request (:class:`~.error_stats_service.ListGroupStatsRequest`): + request (google.cloud.errorreporting_v1beta1.types.ListGroupStatsRequest): The request object. Specifies a set of `ErrorGroupStats` to return. - project_name (:class:`str`): + project_name (str): Required. The resource name of the Google Cloud Platform project. Written as projects/ plus the projects/my- project-123. + This corresponds to the ``project_name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - time_range (:class:`~.error_stats_service.QueryTimeRange`): + time_range (google.cloud.errorreporting_v1beta1.types.QueryTimeRange): Optional. List data for the given time range. If not set, a default time range is used. The field time_range_begin in the response will specify the @@ -368,6 +381,7 @@ def list_group_stats( unless the request contains an explicit group_id list. If a group_id list is given, also ErrorGroupStats with zero occurrences are returned. + This corresponds to the ``time_range`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -379,7 +393,7 @@ def list_group_stats( sent along with the request as metadata. Returns: - ~.pagers.ListGroupStatsPager: + google.cloud.errorreporting_v1beta1.services.error_stats_service.pagers.ListGroupStatsPager: Contains a set of requested error group stats. Iterating over this object will yield @@ -449,21 +463,23 @@ def list_events( r"""Lists the specified events. Args: - request (:class:`~.error_stats_service.ListEventsRequest`): + request (google.cloud.errorreporting_v1beta1.types.ListEventsRequest): The request object. Specifies a set of error events to return. - project_name (:class:`str`): + project_name (str): Required. The resource name of the Google Cloud Platform project. Written as ``projects/`` plus the `Google Cloud Platform project ID `__. Example: ``projects/my-project-123``. + This corresponds to the ``project_name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - group_id (:class:`str`): + group_id (str): Required. The group for which events shall be returned. + This corresponds to the ``group_id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -475,7 +491,7 @@ def list_events( sent along with the request as metadata. Returns: - ~.pagers.ListEventsPager: + google.cloud.errorreporting_v1beta1.services.error_stats_service.pagers.ListEventsPager: Contains a set of requested error events. Iterating over this object will yield @@ -544,14 +560,15 @@ def delete_events( r"""Deletes all error events of a given project. Args: - request (:class:`~.error_stats_service.DeleteEventsRequest`): + request (google.cloud.errorreporting_v1beta1.types.DeleteEventsRequest): The request object. Deletes all events in the project. - project_name (:class:`str`): + project_name (str): Required. The resource name of the Google Cloud Platform project. Written as ``projects/`` plus the `Google Cloud Platform project ID `__. Example: ``projects/my-project-123``. + This corresponds to the ``project_name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -563,7 +580,7 @@ def delete_events( sent along with the request as metadata. Returns: - ~.error_stats_service.DeleteEventsResponse: + google.cloud.errorreporting_v1beta1.types.DeleteEventsResponse: Response message for deleting error events. diff --git a/google/cloud/errorreporting_v1beta1/services/error_stats_service/pagers.py b/google/cloud/errorreporting_v1beta1/services/error_stats_service/pagers.py index 02a4faa4..63bb8413 100644 --- a/google/cloud/errorreporting_v1beta1/services/error_stats_service/pagers.py +++ b/google/cloud/errorreporting_v1beta1/services/error_stats_service/pagers.py @@ -25,7 +25,7 @@ class ListGroupStatsPager: """A pager for iterating through ``list_group_stats`` requests. This class thinly wraps an initial - :class:`~.error_stats_service.ListGroupStatsResponse` object, and + :class:`google.cloud.errorreporting_v1beta1.types.ListGroupStatsResponse` object, and provides an ``__iter__`` method to iterate through its ``error_group_stats`` field. @@ -34,7 +34,7 @@ class ListGroupStatsPager: through the ``error_group_stats`` field on the corresponding responses. - All the usual :class:`~.error_stats_service.ListGroupStatsResponse` + All the usual :class:`google.cloud.errorreporting_v1beta1.types.ListGroupStatsResponse` attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup. """ @@ -52,9 +52,9 @@ def __init__( Args: method (Callable): The method that was originally called, and which instantiated this pager. - request (:class:`~.error_stats_service.ListGroupStatsRequest`): + request (google.cloud.errorreporting_v1beta1.types.ListGroupStatsRequest): The initial request object. - response (:class:`~.error_stats_service.ListGroupStatsResponse`): + response (google.cloud.errorreporting_v1beta1.types.ListGroupStatsResponse): The initial response object. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. @@ -87,7 +87,7 @@ class ListGroupStatsAsyncPager: """A pager for iterating through ``list_group_stats`` requests. This class thinly wraps an initial - :class:`~.error_stats_service.ListGroupStatsResponse` object, and + :class:`google.cloud.errorreporting_v1beta1.types.ListGroupStatsResponse` object, and provides an ``__aiter__`` method to iterate through its ``error_group_stats`` field. @@ -96,7 +96,7 @@ class ListGroupStatsAsyncPager: through the ``error_group_stats`` field on the corresponding responses. - All the usual :class:`~.error_stats_service.ListGroupStatsResponse` + All the usual :class:`google.cloud.errorreporting_v1beta1.types.ListGroupStatsResponse` attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup. """ @@ -114,9 +114,9 @@ def __init__( Args: method (Callable): The method that was originally called, and which instantiated this pager. - request (:class:`~.error_stats_service.ListGroupStatsRequest`): + request (google.cloud.errorreporting_v1beta1.types.ListGroupStatsRequest): The initial request object. - response (:class:`~.error_stats_service.ListGroupStatsResponse`): + response (google.cloud.errorreporting_v1beta1.types.ListGroupStatsResponse): The initial response object. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. @@ -153,7 +153,7 @@ class ListEventsPager: """A pager for iterating through ``list_events`` requests. This class thinly wraps an initial - :class:`~.error_stats_service.ListEventsResponse` object, and + :class:`google.cloud.errorreporting_v1beta1.types.ListEventsResponse` object, and provides an ``__iter__`` method to iterate through its ``error_events`` field. @@ -162,7 +162,7 @@ class ListEventsPager: through the ``error_events`` field on the corresponding responses. - All the usual :class:`~.error_stats_service.ListEventsResponse` + All the usual :class:`google.cloud.errorreporting_v1beta1.types.ListEventsResponse` attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup. """ @@ -180,9 +180,9 @@ def __init__( Args: method (Callable): The method that was originally called, and which instantiated this pager. - request (:class:`~.error_stats_service.ListEventsRequest`): + request (google.cloud.errorreporting_v1beta1.types.ListEventsRequest): The initial request object. - response (:class:`~.error_stats_service.ListEventsResponse`): + response (google.cloud.errorreporting_v1beta1.types.ListEventsResponse): The initial response object. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. @@ -215,7 +215,7 @@ class ListEventsAsyncPager: """A pager for iterating through ``list_events`` requests. This class thinly wraps an initial - :class:`~.error_stats_service.ListEventsResponse` object, and + :class:`google.cloud.errorreporting_v1beta1.types.ListEventsResponse` object, and provides an ``__aiter__`` method to iterate through its ``error_events`` field. @@ -224,7 +224,7 @@ class ListEventsAsyncPager: through the ``error_events`` field on the corresponding responses. - All the usual :class:`~.error_stats_service.ListEventsResponse` + All the usual :class:`google.cloud.errorreporting_v1beta1.types.ListEventsResponse` attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup. """ @@ -242,9 +242,9 @@ def __init__( Args: method (Callable): The method that was originally called, and which instantiated this pager. - request (:class:`~.error_stats_service.ListEventsRequest`): + request (google.cloud.errorreporting_v1beta1.types.ListEventsRequest): The initial request object. - response (:class:`~.error_stats_service.ListEventsResponse`): + response (google.cloud.errorreporting_v1beta1.types.ListEventsResponse): The initial response object. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. diff --git a/google/cloud/errorreporting_v1beta1/services/error_stats_service/transports/grpc.py b/google/cloud/errorreporting_v1beta1/services/error_stats_service/transports/grpc.py index f9595d23..6a5328c5 100644 --- a/google/cloud/errorreporting_v1beta1/services/error_stats_service/transports/grpc.py +++ b/google/cloud/errorreporting_v1beta1/services/error_stats_service/transports/grpc.py @@ -58,6 +58,7 @@ def __init__( api_mtls_endpoint: str = None, client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, ssl_channel_credentials: grpc.ChannelCredentials = None, + client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: @@ -88,6 +89,10 @@ def __init__( ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials for 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 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): @@ -104,6 +109,11 @@ def __init__( """ self._ssl_channel_credentials = ssl_channel_credentials + 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: # Sanity check: Ensure that channel and credentials are not both # provided. @@ -113,11 +123,6 @@ def __init__( self._grpc_channel = channel self._ssl_channel_credentials = None elif api_mtls_endpoint: - warnings.warn( - "api_mtls_endpoint and client_cert_source are deprecated", - DeprecationWarning, - ) - host = ( api_mtls_endpoint if ":" in api_mtls_endpoint @@ -161,12 +166,18 @@ def __init__( scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id ) + 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 + ) + # create a new channel. The provided one is ignored. self._grpc_channel = type(self).create_channel( host, credentials=credentials, credentials_file=credentials_file, - ssl_credentials=ssl_channel_credentials, + ssl_credentials=self._ssl_channel_credentials, scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, options=[ diff --git a/google/cloud/errorreporting_v1beta1/services/error_stats_service/transports/grpc_asyncio.py b/google/cloud/errorreporting_v1beta1/services/error_stats_service/transports/grpc_asyncio.py index 4c687c11..336e180a 100644 --- a/google/cloud/errorreporting_v1beta1/services/error_stats_service/transports/grpc_asyncio.py +++ b/google/cloud/errorreporting_v1beta1/services/error_stats_service/transports/grpc_asyncio.py @@ -102,6 +102,7 @@ def __init__( api_mtls_endpoint: str = None, client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, ssl_channel_credentials: grpc.ChannelCredentials = None, + client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, quota_project_id=None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: @@ -133,6 +134,10 @@ def __init__( ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials for 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 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): @@ -149,6 +154,11 @@ def __init__( """ self._ssl_channel_credentials = ssl_channel_credentials + 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: # Sanity check: Ensure that channel and credentials are not both # provided. @@ -158,11 +168,6 @@ def __init__( self._grpc_channel = channel self._ssl_channel_credentials = None elif api_mtls_endpoint: - warnings.warn( - "api_mtls_endpoint and client_cert_source are deprecated", - DeprecationWarning, - ) - host = ( api_mtls_endpoint if ":" in api_mtls_endpoint @@ -206,12 +211,18 @@ def __init__( scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id ) + 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 + ) + # create a new channel. The provided one is ignored. self._grpc_channel = type(self).create_channel( host, credentials=credentials, credentials_file=credentials_file, - ssl_credentials=ssl_channel_credentials, + ssl_credentials=self._ssl_channel_credentials, scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, options=[ diff --git a/google/cloud/errorreporting_v1beta1/services/report_errors_service/async_client.py b/google/cloud/errorreporting_v1beta1/services/report_errors_service/async_client.py index 3b7c6fcf..9562776f 100644 --- a/google/cloud/errorreporting_v1beta1/services/report_errors_service/async_client.py +++ b/google/cloud/errorreporting_v1beta1/services/report_errors_service/async_client.py @@ -72,6 +72,7 @@ class ReportErrorsServiceAsyncClient: ReportErrorsServiceClient.parse_common_location_path ) + from_service_account_info = ReportErrorsServiceClient.from_service_account_info from_service_account_file = ReportErrorsServiceClient.from_service_account_file from_service_account_json = from_service_account_file @@ -157,7 +158,7 @@ async def report_error_event( ``POST https://clouderrorreporting.googleapis.com/v1beta1/projects/example-project/events:report?key=123ABC456`` Args: - request (:class:`~.report_errors_service.ReportErrorEventRequest`): + request (:class:`google.cloud.errorreporting_v1beta1.types.ReportErrorEventRequest`): The request object. A request for reporting an individual error event. project_name (:class:`str`): @@ -166,12 +167,14 @@ async def report_error_event( Platform project ID `__. Example: ``projects/my-project-123``. + This corresponds to the ``project_name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - event (:class:`~.report_errors_service.ReportedErrorEvent`): + event (:class:`google.cloud.errorreporting_v1beta1.types.ReportedErrorEvent`): Required. The error event to be reported. + This corresponds to the ``event`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -183,7 +186,7 @@ async def report_error_event( sent along with the request as metadata. Returns: - ~.report_errors_service.ReportErrorEventResponse: + google.cloud.errorreporting_v1beta1.types.ReportErrorEventResponse: Response for reporting an individual error event. Data may be added to this message in the future. diff --git a/google/cloud/errorreporting_v1beta1/services/report_errors_service/client.py b/google/cloud/errorreporting_v1beta1/services/report_errors_service/client.py index b10ecca4..01c3fb00 100644 --- a/google/cloud/errorreporting_v1beta1/services/report_errors_service/client.py +++ b/google/cloud/errorreporting_v1beta1/services/report_errors_service/client.py @@ -111,6 +111,22 @@ def _get_default_mtls_endpoint(api_endpoint): 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: + ReportErrorsServiceClient: 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 @@ -123,7 +139,7 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): kwargs: Additional arguments to pass to the constructor. Returns: - {@api.name}: The constructed client. + ReportErrorsServiceClient: The constructed client. """ credentials = service_account.Credentials.from_service_account_file(filename) kwargs["credentials"] = credentials @@ -215,10 +231,10 @@ def __init__( 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, ~.ReportErrorsServiceTransport]): The + transport (Union[str, ReportErrorsServiceTransport]): The transport to use. If set to None, a transport is chosen automatically. - client_options (client_options_lib.ClientOptions): Custom options for the + client_options (google.api_core.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 @@ -254,21 +270,17 @@ def __init__( util.strtobool(os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false")) ) - ssl_credentials = None + client_cert_source_func = None is_mtls = False if use_client_cert: if client_options.client_cert_source: - import grpc # type: ignore - - cert, key = client_options.client_cert_source() - ssl_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) is_mtls = True + client_cert_source_func = client_options.client_cert_source else: - creds = SslCredentials() - is_mtls = creds.is_mtls - ssl_credentials = creds.ssl_credentials if is_mtls else None + is_mtls = mtls.has_default_client_cert_source() + client_cert_source_func = ( + mtls.default_client_cert_source() if is_mtls else None + ) # Figure out which api endpoint to use. if client_options.api_endpoint is not None: @@ -311,7 +323,7 @@ def __init__( credentials_file=client_options.credentials_file, host=api_endpoint, scopes=client_options.scopes, - ssl_channel_credentials=ssl_credentials, + client_cert_source_for_mtls=client_cert_source_func, quota_project_id=client_options.quota_project_id, client_info=client_info, ) @@ -336,21 +348,23 @@ def report_error_event( ``POST https://clouderrorreporting.googleapis.com/v1beta1/projects/example-project/events:report?key=123ABC456`` Args: - request (:class:`~.report_errors_service.ReportErrorEventRequest`): + request (google.cloud.errorreporting_v1beta1.types.ReportErrorEventRequest): The request object. A request for reporting an individual error event. - project_name (:class:`str`): + project_name (str): Required. The resource name of the Google Cloud Platform project. Written as ``projects/`` plus the `Google Cloud Platform project ID `__. Example: ``projects/my-project-123``. + This corresponds to the ``project_name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - event (:class:`~.report_errors_service.ReportedErrorEvent`): + event (google.cloud.errorreporting_v1beta1.types.ReportedErrorEvent): Required. The error event to be reported. + This corresponds to the ``event`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -362,7 +376,7 @@ def report_error_event( sent along with the request as metadata. Returns: - ~.report_errors_service.ReportErrorEventResponse: + google.cloud.errorreporting_v1beta1.types.ReportErrorEventResponse: Response for reporting an individual error event. Data may be added to this message in the future. diff --git a/google/cloud/errorreporting_v1beta1/services/report_errors_service/transports/grpc.py b/google/cloud/errorreporting_v1beta1/services/report_errors_service/transports/grpc.py index f2c84d92..106dab79 100644 --- a/google/cloud/errorreporting_v1beta1/services/report_errors_service/transports/grpc.py +++ b/google/cloud/errorreporting_v1beta1/services/report_errors_service/transports/grpc.py @@ -57,6 +57,7 @@ def __init__( api_mtls_endpoint: str = None, client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, ssl_channel_credentials: grpc.ChannelCredentials = None, + client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: @@ -87,6 +88,10 @@ def __init__( ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials for 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 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): @@ -103,6 +108,11 @@ def __init__( """ self._ssl_channel_credentials = ssl_channel_credentials + 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: # Sanity check: Ensure that channel and credentials are not both # provided. @@ -112,11 +122,6 @@ def __init__( self._grpc_channel = channel self._ssl_channel_credentials = None elif api_mtls_endpoint: - warnings.warn( - "api_mtls_endpoint and client_cert_source are deprecated", - DeprecationWarning, - ) - host = ( api_mtls_endpoint if ":" in api_mtls_endpoint @@ -160,12 +165,18 @@ def __init__( scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id ) + 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 + ) + # create a new channel. The provided one is ignored. self._grpc_channel = type(self).create_channel( host, credentials=credentials, credentials_file=credentials_file, - ssl_credentials=ssl_channel_credentials, + ssl_credentials=self._ssl_channel_credentials, scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, options=[ diff --git a/google/cloud/errorreporting_v1beta1/services/report_errors_service/transports/grpc_asyncio.py b/google/cloud/errorreporting_v1beta1/services/report_errors_service/transports/grpc_asyncio.py index 39465e57..9b357ded 100644 --- a/google/cloud/errorreporting_v1beta1/services/report_errors_service/transports/grpc_asyncio.py +++ b/google/cloud/errorreporting_v1beta1/services/report_errors_service/transports/grpc_asyncio.py @@ -101,6 +101,7 @@ def __init__( api_mtls_endpoint: str = None, client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, ssl_channel_credentials: grpc.ChannelCredentials = None, + client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, quota_project_id=None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: @@ -132,6 +133,10 @@ def __init__( ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials for 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 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): @@ -148,6 +153,11 @@ def __init__( """ self._ssl_channel_credentials = ssl_channel_credentials + 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: # Sanity check: Ensure that channel and credentials are not both # provided. @@ -157,11 +167,6 @@ def __init__( self._grpc_channel = channel self._ssl_channel_credentials = None elif api_mtls_endpoint: - warnings.warn( - "api_mtls_endpoint and client_cert_source are deprecated", - DeprecationWarning, - ) - host = ( api_mtls_endpoint if ":" in api_mtls_endpoint @@ -205,12 +210,18 @@ def __init__( scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id ) + 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 + ) + # create a new channel. The provided one is ignored. self._grpc_channel = type(self).create_channel( host, credentials=credentials, credentials_file=credentials_file, - ssl_credentials=ssl_channel_credentials, + ssl_credentials=self._ssl_channel_credentials, scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, options=[ diff --git a/google/cloud/errorreporting_v1beta1/types/common.py b/google/cloud/errorreporting_v1beta1/types/common.py index 779aa453..e8371063 100644 --- a/google/cloud/errorreporting_v1beta1/types/common.py +++ b/google/cloud/errorreporting_v1beta1/types/common.py @@ -48,7 +48,7 @@ class ErrorGroup(proto.Message): the same kind of error occurs in different service contexts, it will receive the same group ID. - tracking_issues (Sequence[~.common.TrackingIssue]): + tracking_issues (Sequence[google.cloud.errorreporting_v1beta1.types.TrackingIssue]): Associated tracking issues. """ @@ -80,17 +80,17 @@ class ErrorEvent(proto.Message): system. Attributes: - event_time (~.timestamp.Timestamp): + event_time (google.protobuf.timestamp_pb2.Timestamp): Time when the event occurred as provided in the error report. If the report did not contain a timestamp, the time the error was received by the Error Reporting system is used. - service_context (~.common.ServiceContext): + service_context (google.cloud.errorreporting_v1beta1.types.ServiceContext): The ``ServiceContext`` for which this error was reported. message (str): The stack trace that was reported or logged by the service. - context (~.common.ErrorContext): + context (google.cloud.errorreporting_v1beta1.types.ErrorContext): Data about the context in which the error occurred. """ @@ -149,7 +149,7 @@ class ErrorContext(proto.Message): Engine logs. Attributes: - http_request (~.common.HttpRequestContext): + http_request (google.cloud.errorreporting_v1beta1.types.HttpRequestContext): The HTTP request which was processed when the error was triggered. user (str): @@ -160,7 +160,7 @@ class ErrorContext(proto.Message): this case the Error Reporting system will use other data, such as remote IP address, to distinguish affected users. See ``affected_users_count`` in ``ErrorGroupStats``. - report_location (~.common.SourceLocation): + report_location (google.cloud.errorreporting_v1beta1.types.SourceLocation): The location in the source code where the decision was made to report the error, usually the place where it was logged. For a logged diff --git a/google/cloud/errorreporting_v1beta1/types/error_group_service.py b/google/cloud/errorreporting_v1beta1/types/error_group_service.py index 70aa92a8..632e072f 100644 --- a/google/cloud/errorreporting_v1beta1/types/error_group_service.py +++ b/google/cloud/errorreporting_v1beta1/types/error_group_service.py @@ -47,7 +47,7 @@ class UpdateGroupRequest(proto.Message): r"""A request to replace the existing data for the given group. Attributes: - group (~.common.ErrorGroup): + group (google.cloud.errorreporting_v1beta1.types.ErrorGroup): Required. The group which replaces the resource on the server. """ diff --git a/google/cloud/errorreporting_v1beta1/types/error_stats_service.py b/google/cloud/errorreporting_v1beta1/types/error_stats_service.py index 51a14e89..dfd08020 100644 --- a/google/cloud/errorreporting_v1beta1/types/error_stats_service.py +++ b/google/cloud/errorreporting_v1beta1/types/error_stats_service.py @@ -75,13 +75,13 @@ class ListGroupStatsRequest(proto.Message): group_id (Sequence[str]): Optional. List all ErrorGroupStats with these IDs. - service_filter (~.error_stats_service.ServiceContextFilter): + service_filter (google.cloud.errorreporting_v1beta1.types.ServiceContextFilter): Optional. List only ErrorGroupStats which belong to a service context that matches the filter. Data for all service contexts is returned if this field is not specified. - time_range (~.error_stats_service.QueryTimeRange): + time_range (google.cloud.errorreporting_v1beta1.types.QueryTimeRange): Optional. List data for the given time range. If not set, a default time range is used. The field time_range_begin in the response will specify the beginning of this time range. @@ -89,17 +89,17 @@ class ListGroupStatsRequest(proto.Message): range are returned, unless the request contains an explicit group_id list. If a group_id list is given, also ErrorGroupStats with zero occurrences are returned. - timed_count_duration (~.duration.Duration): + timed_count_duration (google.protobuf.duration_pb2.Duration): Optional. The preferred duration for a single returned ``TimedCount``. If not set, no timed counts are returned. - alignment (~.error_stats_service.TimedCountAlignment): + alignment (google.cloud.errorreporting_v1beta1.types.TimedCountAlignment): Optional. The alignment of the timed counts to be returned. Default is ``ALIGNMENT_EQUAL_AT_END``. - alignment_time (~.timestamp.Timestamp): + alignment_time (google.protobuf.timestamp_pb2.Timestamp): Optional. Time where the timed counts shall be aligned if rounded alignment is chosen. Default is 00:00 UTC. - order (~.error_stats_service.ErrorGroupOrder): + order (google.cloud.errorreporting_v1beta1.types.ErrorGroupOrder): Optional. The sort order in which the results are returned. Default is ``COUNT_DESC``. page_size (int): @@ -140,7 +140,7 @@ class ListGroupStatsResponse(proto.Message): r"""Contains a set of requested error group stats. Attributes: - error_group_stats (Sequence[~.error_stats_service.ErrorGroupStats]): + error_group_stats (Sequence[google.cloud.errorreporting_v1beta1.types.ErrorGroupStats]): The error group stats which match the given request. next_page_token (str): @@ -148,7 +148,7 @@ class ListGroupStatsResponse(proto.Message): Pass this token, along with the same query parameters as the first request, to view the next page of results. - time_range_begin (~.timestamp.Timestamp): + time_range_begin (google.protobuf.timestamp_pb2.Timestamp): The timestamp specifies the start time to which the request was restricted. The start time is set based on the requested time range. It may @@ -177,7 +177,7 @@ class ErrorGroupStats(proto.Message): criteria, such as a given time period and/or service filter. Attributes: - group (~.common.ErrorGroup): + group (google.cloud.errorreporting_v1beta1.types.ErrorGroup): Group data that is independent of the filter criteria. count (int): @@ -195,22 +195,22 @@ class ErrorGroupStats(proto.Message): provided in the error report. If more users are implicitly affected, such as due to a crash of the whole service, this is not reflected here. - timed_counts (Sequence[~.error_stats_service.TimedCount]): + timed_counts (Sequence[google.cloud.errorreporting_v1beta1.types.TimedCount]): Approximate number of occurrences over time. Timed counts returned by ListGroups are guaranteed to be: - Inside the requested time interval - Non-overlapping, and - Ordered by ascending time. - first_seen_time (~.timestamp.Timestamp): + first_seen_time (google.protobuf.timestamp_pb2.Timestamp): Approximate first occurrence that was ever seen for this group and which matches the given filter criteria, ignoring the time_range that was specified in the request. - last_seen_time (~.timestamp.Timestamp): + last_seen_time (google.protobuf.timestamp_pb2.Timestamp): Approximate last occurrence that was ever seen for this group and which matches the given filter criteria, ignoring the time_range that was specified in the request. - affected_services (Sequence[~.common.ServiceContext]): + affected_services (Sequence[google.cloud.errorreporting_v1beta1.types.ServiceContext]): Service contexts with a non-zero error count for the given filter criteria. This list can be truncated if multiple services are affected. Refer to ``num_affected_services`` @@ -218,7 +218,7 @@ class ErrorGroupStats(proto.Message): num_affected_services (int): The total number of services with a non-zero error count for the given filter criteria. - representative (~.common.ErrorEvent): + representative (google.cloud.errorreporting_v1beta1.types.ErrorEvent): An arbitrary event that is chosen as representative for the whole group. The representative event is intended to be used as a @@ -259,10 +259,10 @@ class TimedCount(proto.Message): count (int): Approximate number of occurrences in the given time period. - start_time (~.timestamp.Timestamp): + start_time (google.protobuf.timestamp_pb2.Timestamp): Start of the time period to which ``count`` refers (included). - end_time (~.timestamp.Timestamp): + end_time (google.protobuf.timestamp_pb2.Timestamp): End of the time period to which ``count`` refers (excluded). """ @@ -286,12 +286,12 @@ class ListEventsRequest(proto.Message): group_id (str): Required. The group for which events shall be returned. - service_filter (~.error_stats_service.ServiceContextFilter): + service_filter (google.cloud.errorreporting_v1beta1.types.ServiceContextFilter): Optional. List only ErrorGroups which belong to a service context that matches the filter. Data for all service contexts is returned if this field is not specified. - time_range (~.error_stats_service.QueryTimeRange): + time_range (google.cloud.errorreporting_v1beta1.types.QueryTimeRange): Optional. List only data for the given time range. If not set a default time range is used. The field time_range_begin in the response will specify the beginning of this time @@ -323,7 +323,7 @@ class ListEventsResponse(proto.Message): r"""Contains a set of requested error events. Attributes: - error_events (Sequence[~.common.ErrorEvent]): + error_events (Sequence[google.cloud.errorreporting_v1beta1.types.ErrorEvent]): The error events which match the given request. next_page_token (str): @@ -331,7 +331,7 @@ class ListEventsResponse(proto.Message): Pass this token, along with the same query parameters as the first request, to view the next page of results. - time_range_begin (~.timestamp.Timestamp): + time_range_begin (google.protobuf.timestamp_pb2.Timestamp): The timestamp specifies the start time to which the request was restricted. """ @@ -356,7 +356,7 @@ class QueryTimeRange(proto.Message): durations might be adjusted for lower durations. Attributes: - period (~.error_stats_service.QueryTimeRange.Period): + period (google.cloud.errorreporting_v1beta1.types.QueryTimeRange.Period): Restricts the query to the specified time range. """ diff --git a/google/cloud/errorreporting_v1beta1/types/report_errors_service.py b/google/cloud/errorreporting_v1beta1/types/report_errors_service.py index 1a66727b..e53fa5e5 100644 --- a/google/cloud/errorreporting_v1beta1/types/report_errors_service.py +++ b/google/cloud/errorreporting_v1beta1/types/report_errors_service.py @@ -42,7 +42,7 @@ class ReportErrorEventRequest(proto.Message): Platform project ID `__. Example: ``projects/my-project-123``. - event (~.report_errors_service.ReportedErrorEvent): + event (google.cloud.errorreporting_v1beta1.types.ReportedErrorEvent): Required. The error event to be reported. """ @@ -62,12 +62,12 @@ class ReportedErrorEvent(proto.Message): system. Attributes: - event_time (~.timestamp.Timestamp): + event_time (google.protobuf.timestamp_pb2.Timestamp): Optional. Time when the event occurred. If not provided, the time when the event was received by the Error Reporting system will be used. - service_context (~.common.ServiceContext): + service_context (google.cloud.errorreporting_v1beta1.types.ServiceContext): Required. The service context in which this error has occurred. message (str): @@ -96,7 +96,7 @@ class ReportedErrorEvent(proto.Message): ```(string)$exception`` `__. - **Go**: Must be the return value of ```runtime.Stack()`` `__. - context (~.common.ErrorContext): + context (google.cloud.errorreporting_v1beta1.types.ErrorContext): Optional. A description of the context in which the error occurred. """ diff --git a/synth.metadata b/synth.metadata index 330ea88c..be4528bd 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,15 +4,15 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/python-error-reporting.git", - "sha": "b6887650c28d9fce253ed5894bb2d64a4fedae19" + "sha": "c4b168d1f4e045d72487abba88e118a15b1c99ef" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "dd372aa22ded7a8ba6f0e03a80e06358a3fa0907", - "internalRef": "347055288" + "sha": "20712b8fe95001b312f62c6c5f33e3e3ec92cfaf", + "internalRef": "354996675" } }, { @@ -42,6 +42,7 @@ } ], "generatedFiles": [ + ".coveragerc", ".flake8", ".github/CONTRIBUTING.md", ".github/ISSUE_TEMPLATE/bug_report.md", @@ -95,6 +96,9 @@ "docs/_static/custom.css", "docs/_templates/layout.html", "docs/conf.py", + "docs/errorreporting_v1beta1/error_group_service.rst", + "docs/errorreporting_v1beta1/error_stats_service.rst", + "docs/errorreporting_v1beta1/report_errors_service.rst", "docs/errorreporting_v1beta1/services.rst", "docs/errorreporting_v1beta1/types.rst", "docs/multiprocessing.rst", diff --git a/tests/unit/gapic/errorreporting_v1beta1/test_error_group_service.py b/tests/unit/gapic/errorreporting_v1beta1/test_error_group_service.py index da93c3df..5abefc9b 100644 --- a/tests/unit/gapic/errorreporting_v1beta1/test_error_group_service.py +++ b/tests/unit/gapic/errorreporting_v1beta1/test_error_group_service.py @@ -89,8 +89,21 @@ def test__get_default_mtls_endpoint(): ) +def test_error_group_service_client_from_service_account_info(): + creds = credentials.AnonymousCredentials() + with mock.patch.object( + service_account.Credentials, "from_service_account_info" + ) as factory: + factory.return_value = creds + info = {"valid": True} + client = ErrorGroupServiceClient.from_service_account_info(info) + assert client.transport._credentials == creds + + assert client.transport._host == "clouderrorreporting.googleapis.com:443" + + @pytest.mark.parametrize( - "client_class", [ErrorGroupServiceClient, ErrorGroupServiceAsyncClient] + "client_class", [ErrorGroupServiceClient, ErrorGroupServiceAsyncClient,] ) def test_error_group_service_client_from_service_account_file(client_class): creds = credentials.AnonymousCredentials() @@ -109,7 +122,10 @@ def test_error_group_service_client_from_service_account_file(client_class): def test_error_group_service_client_get_transport_class(): transport = ErrorGroupServiceClient.get_transport_class() - assert transport == transports.ErrorGroupServiceGrpcTransport + available_transports = [ + transports.ErrorGroupServiceGrpcTransport, + ] + assert transport in available_transports transport = ErrorGroupServiceClient.get_transport_class("grpc") assert transport == transports.ErrorGroupServiceGrpcTransport @@ -160,7 +176,7 @@ def test_error_group_service_client_client_options( credentials_file=None, host="squid.clam.whelk", scopes=None, - ssl_channel_credentials=None, + client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, ) @@ -176,7 +192,7 @@ def test_error_group_service_client_client_options( credentials_file=None, host=client.DEFAULT_ENDPOINT, scopes=None, - ssl_channel_credentials=None, + client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, ) @@ -192,7 +208,7 @@ def test_error_group_service_client_client_options( credentials_file=None, host=client.DEFAULT_MTLS_ENDPOINT, scopes=None, - ssl_channel_credentials=None, + client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, ) @@ -220,7 +236,7 @@ def test_error_group_service_client_client_options( credentials_file=None, host=client.DEFAULT_ENDPOINT, scopes=None, - ssl_channel_credentials=None, + client_cert_source_for_mtls=None, quota_project_id="octopus", client_info=transports.base.DEFAULT_CLIENT_INFO, ) @@ -281,29 +297,25 @@ def test_error_group_service_client_mtls_env_auto( client_cert_source=client_cert_source_callback ) with mock.patch.object(transport_class, "__init__") as patched: - ssl_channel_creds = mock.Mock() - with mock.patch( - "grpc.ssl_channel_credentials", return_value=ssl_channel_creds - ): - patched.return_value = None - client = client_class(client_options=options) + patched.return_value = None + client = client_class(client_options=options) - if use_client_cert_env == "false": - expected_ssl_channel_creds = None - expected_host = client.DEFAULT_ENDPOINT - else: - expected_ssl_channel_creds = ssl_channel_creds - expected_host = client.DEFAULT_MTLS_ENDPOINT + 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, - ssl_channel_credentials=expected_ssl_channel_creds, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) + 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, + ) # Check the case ADC client cert is provided. Whether client cert is used depends on # GOOGLE_API_USE_CLIENT_CERTIFICATE value. @@ -312,66 +324,53 @@ def test_error_group_service_client_mtls_env_auto( ): with mock.patch.object(transport_class, "__init__") as patched: with mock.patch( - "google.auth.transport.grpc.SslCredentials.__init__", return_value=None + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=True, ): with mock.patch( - "google.auth.transport.grpc.SslCredentials.is_mtls", - new_callable=mock.PropertyMock, - ) as is_mtls_mock: - with mock.patch( - "google.auth.transport.grpc.SslCredentials.ssl_credentials", - new_callable=mock.PropertyMock, - ) as ssl_credentials_mock: - if use_client_cert_env == "false": - is_mtls_mock.return_value = False - ssl_credentials_mock.return_value = None - expected_host = client.DEFAULT_ENDPOINT - expected_ssl_channel_creds = None - else: - is_mtls_mock.return_value = True - ssl_credentials_mock.return_value = mock.Mock() - expected_host = client.DEFAULT_MTLS_ENDPOINT - expected_ssl_channel_creds = ( - ssl_credentials_mock.return_value - ) - - patched.return_value = None - client = client_class() - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=expected_host, - scopes=None, - ssl_channel_credentials=expected_ssl_channel_creds, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) + "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 - # 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.grpc.SslCredentials.__init__", return_value=None - ): - with mock.patch( - "google.auth.transport.grpc.SslCredentials.is_mtls", - new_callable=mock.PropertyMock, - ) as is_mtls_mock: - is_mtls_mock.return_value = False patched.return_value = None client = client_class() patched.assert_called_once_with( credentials=None, credentials_file=None, - host=client.DEFAULT_ENDPOINT, + host=expected_host, scopes=None, - ssl_channel_credentials=None, + client_cert_source_for_mtls=expected_client_cert_source, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, ) + # 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() + 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, + ) + @pytest.mark.parametrize( "client_class,transport_class,transport_name", @@ -397,7 +396,7 @@ def test_error_group_service_client_client_options_scopes( credentials_file=None, host=client.DEFAULT_ENDPOINT, scopes=["1", "2"], - ssl_channel_credentials=None, + client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, ) @@ -427,7 +426,7 @@ def test_error_group_service_client_client_options_credentials_file( credentials_file="credentials.json", host=client.DEFAULT_ENDPOINT, scopes=None, - ssl_channel_credentials=None, + client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, ) @@ -446,7 +445,7 @@ def test_error_group_service_client_client_options_from_dict(): credentials_file=None, host="squid.clam.whelk", scopes=None, - ssl_channel_credentials=None, + client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, ) @@ -1014,6 +1013,53 @@ def test_error_group_service_transport_auth_adc(): ) +@pytest.mark.parametrize( + "transport_class", + [ + transports.ErrorGroupServiceGrpcTransport, + transports.ErrorGroupServiceGrpcAsyncIOTransport, + ], +) +def test_error_group_service_grpc_transport_client_cert_source_for_mtls( + transport_class, +): + cred = 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=("https://www.googleapis.com/auth/cloud-platform",), + 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_error_group_service_host_no_port(): client = ErrorGroupServiceClient( credentials=credentials.AnonymousCredentials(), @@ -1035,7 +1081,7 @@ def test_error_group_service_host_with_port(): def test_error_group_service_grpc_transport_channel(): - channel = grpc.insecure_channel("http://localhost/") + channel = grpc.secure_channel("http://localhost/", grpc.local_channel_credentials()) # Check that channel is used if provided. transport = transports.ErrorGroupServiceGrpcTransport( @@ -1047,7 +1093,7 @@ def test_error_group_service_grpc_transport_channel(): def test_error_group_service_grpc_asyncio_transport_channel(): - channel = aio.insecure_channel("http://localhost/") + channel = aio.secure_channel("http://localhost/", grpc.local_channel_credentials()) # Check that channel is used if provided. transport = transports.ErrorGroupServiceGrpcAsyncIOTransport( @@ -1058,6 +1104,8 @@ def test_error_group_service_grpc_asyncio_transport_channel(): 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", [ @@ -1072,7 +1120,7 @@ def test_error_group_service_transport_channel_mtls_with_client_cert_source( "grpc.ssl_channel_credentials", autospec=True ) as grpc_ssl_channel_cred: with mock.patch.object( - transport_class, "create_channel", autospec=True + transport_class, "create_channel" ) as grpc_create_channel: mock_ssl_cred = mock.Mock() grpc_ssl_channel_cred.return_value = mock_ssl_cred @@ -1110,6 +1158,8 @@ def test_error_group_service_transport_channel_mtls_with_client_cert_source( 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", [ @@ -1125,7 +1175,7 @@ def test_error_group_service_transport_channel_mtls_with_adc(transport_class): ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred), ): with mock.patch.object( - transport_class, "create_channel", autospec=True + transport_class, "create_channel" ) as grpc_create_channel: mock_grpc_channel = mock.Mock() grpc_create_channel.return_value = mock_grpc_channel diff --git a/tests/unit/gapic/errorreporting_v1beta1/test_error_stats_service.py b/tests/unit/gapic/errorreporting_v1beta1/test_error_stats_service.py index 2ea69420..97205ad6 100644 --- a/tests/unit/gapic/errorreporting_v1beta1/test_error_stats_service.py +++ b/tests/unit/gapic/errorreporting_v1beta1/test_error_stats_service.py @@ -92,8 +92,21 @@ def test__get_default_mtls_endpoint(): ) +def test_error_stats_service_client_from_service_account_info(): + creds = credentials.AnonymousCredentials() + with mock.patch.object( + service_account.Credentials, "from_service_account_info" + ) as factory: + factory.return_value = creds + info = {"valid": True} + client = ErrorStatsServiceClient.from_service_account_info(info) + assert client.transport._credentials == creds + + assert client.transport._host == "clouderrorreporting.googleapis.com:443" + + @pytest.mark.parametrize( - "client_class", [ErrorStatsServiceClient, ErrorStatsServiceAsyncClient] + "client_class", [ErrorStatsServiceClient, ErrorStatsServiceAsyncClient,] ) def test_error_stats_service_client_from_service_account_file(client_class): creds = credentials.AnonymousCredentials() @@ -112,7 +125,10 @@ def test_error_stats_service_client_from_service_account_file(client_class): def test_error_stats_service_client_get_transport_class(): transport = ErrorStatsServiceClient.get_transport_class() - assert transport == transports.ErrorStatsServiceGrpcTransport + available_transports = [ + transports.ErrorStatsServiceGrpcTransport, + ] + assert transport in available_transports transport = ErrorStatsServiceClient.get_transport_class("grpc") assert transport == transports.ErrorStatsServiceGrpcTransport @@ -163,7 +179,7 @@ def test_error_stats_service_client_client_options( credentials_file=None, host="squid.clam.whelk", scopes=None, - ssl_channel_credentials=None, + client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, ) @@ -179,7 +195,7 @@ def test_error_stats_service_client_client_options( credentials_file=None, host=client.DEFAULT_ENDPOINT, scopes=None, - ssl_channel_credentials=None, + client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, ) @@ -195,7 +211,7 @@ def test_error_stats_service_client_client_options( credentials_file=None, host=client.DEFAULT_MTLS_ENDPOINT, scopes=None, - ssl_channel_credentials=None, + client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, ) @@ -223,7 +239,7 @@ def test_error_stats_service_client_client_options( credentials_file=None, host=client.DEFAULT_ENDPOINT, scopes=None, - ssl_channel_credentials=None, + client_cert_source_for_mtls=None, quota_project_id="octopus", client_info=transports.base.DEFAULT_CLIENT_INFO, ) @@ -284,29 +300,25 @@ def test_error_stats_service_client_mtls_env_auto( client_cert_source=client_cert_source_callback ) with mock.patch.object(transport_class, "__init__") as patched: - ssl_channel_creds = mock.Mock() - with mock.patch( - "grpc.ssl_channel_credentials", return_value=ssl_channel_creds - ): - patched.return_value = None - client = client_class(client_options=options) + patched.return_value = None + client = client_class(client_options=options) - if use_client_cert_env == "false": - expected_ssl_channel_creds = None - expected_host = client.DEFAULT_ENDPOINT - else: - expected_ssl_channel_creds = ssl_channel_creds - expected_host = client.DEFAULT_MTLS_ENDPOINT + 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, - ssl_channel_credentials=expected_ssl_channel_creds, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) + 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, + ) # Check the case ADC client cert is provided. Whether client cert is used depends on # GOOGLE_API_USE_CLIENT_CERTIFICATE value. @@ -315,66 +327,53 @@ def test_error_stats_service_client_mtls_env_auto( ): with mock.patch.object(transport_class, "__init__") as patched: with mock.patch( - "google.auth.transport.grpc.SslCredentials.__init__", return_value=None + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=True, ): with mock.patch( - "google.auth.transport.grpc.SslCredentials.is_mtls", - new_callable=mock.PropertyMock, - ) as is_mtls_mock: - with mock.patch( - "google.auth.transport.grpc.SslCredentials.ssl_credentials", - new_callable=mock.PropertyMock, - ) as ssl_credentials_mock: - if use_client_cert_env == "false": - is_mtls_mock.return_value = False - ssl_credentials_mock.return_value = None - expected_host = client.DEFAULT_ENDPOINT - expected_ssl_channel_creds = None - else: - is_mtls_mock.return_value = True - ssl_credentials_mock.return_value = mock.Mock() - expected_host = client.DEFAULT_MTLS_ENDPOINT - expected_ssl_channel_creds = ( - ssl_credentials_mock.return_value - ) - - patched.return_value = None - client = client_class() - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=expected_host, - scopes=None, - ssl_channel_credentials=expected_ssl_channel_creds, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) + "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 - # 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.grpc.SslCredentials.__init__", return_value=None - ): - with mock.patch( - "google.auth.transport.grpc.SslCredentials.is_mtls", - new_callable=mock.PropertyMock, - ) as is_mtls_mock: - is_mtls_mock.return_value = False patched.return_value = None client = client_class() patched.assert_called_once_with( credentials=None, credentials_file=None, - host=client.DEFAULT_ENDPOINT, + host=expected_host, scopes=None, - ssl_channel_credentials=None, + client_cert_source_for_mtls=expected_client_cert_source, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, ) + # 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() + 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, + ) + @pytest.mark.parametrize( "client_class,transport_class,transport_name", @@ -400,7 +399,7 @@ def test_error_stats_service_client_client_options_scopes( credentials_file=None, host=client.DEFAULT_ENDPOINT, scopes=["1", "2"], - ssl_channel_credentials=None, + client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, ) @@ -430,7 +429,7 @@ def test_error_stats_service_client_client_options_credentials_file( credentials_file="credentials.json", host=client.DEFAULT_ENDPOINT, scopes=None, - ssl_channel_credentials=None, + client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, ) @@ -449,7 +448,7 @@ def test_error_stats_service_client_client_options_from_dict(): credentials_file=None, host="squid.clam.whelk", scopes=None, - ssl_channel_credentials=None, + client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, ) @@ -1575,6 +1574,53 @@ def test_error_stats_service_transport_auth_adc(): ) +@pytest.mark.parametrize( + "transport_class", + [ + transports.ErrorStatsServiceGrpcTransport, + transports.ErrorStatsServiceGrpcAsyncIOTransport, + ], +) +def test_error_stats_service_grpc_transport_client_cert_source_for_mtls( + transport_class, +): + cred = 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=("https://www.googleapis.com/auth/cloud-platform",), + 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_error_stats_service_host_no_port(): client = ErrorStatsServiceClient( credentials=credentials.AnonymousCredentials(), @@ -1596,7 +1642,7 @@ def test_error_stats_service_host_with_port(): def test_error_stats_service_grpc_transport_channel(): - channel = grpc.insecure_channel("http://localhost/") + channel = grpc.secure_channel("http://localhost/", grpc.local_channel_credentials()) # Check that channel is used if provided. transport = transports.ErrorStatsServiceGrpcTransport( @@ -1608,7 +1654,7 @@ def test_error_stats_service_grpc_transport_channel(): def test_error_stats_service_grpc_asyncio_transport_channel(): - channel = aio.insecure_channel("http://localhost/") + channel = aio.secure_channel("http://localhost/", grpc.local_channel_credentials()) # Check that channel is used if provided. transport = transports.ErrorStatsServiceGrpcAsyncIOTransport( @@ -1619,6 +1665,8 @@ def test_error_stats_service_grpc_asyncio_transport_channel(): 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", [ @@ -1633,7 +1681,7 @@ def test_error_stats_service_transport_channel_mtls_with_client_cert_source( "grpc.ssl_channel_credentials", autospec=True ) as grpc_ssl_channel_cred: with mock.patch.object( - transport_class, "create_channel", autospec=True + transport_class, "create_channel" ) as grpc_create_channel: mock_ssl_cred = mock.Mock() grpc_ssl_channel_cred.return_value = mock_ssl_cred @@ -1671,6 +1719,8 @@ def test_error_stats_service_transport_channel_mtls_with_client_cert_source( 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", [ @@ -1686,7 +1736,7 @@ def test_error_stats_service_transport_channel_mtls_with_adc(transport_class): ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred), ): with mock.patch.object( - transport_class, "create_channel", autospec=True + transport_class, "create_channel" ) as grpc_create_channel: mock_grpc_channel = mock.Mock() grpc_create_channel.return_value = mock_grpc_channel diff --git a/tests/unit/gapic/errorreporting_v1beta1/test_report_errors_service.py b/tests/unit/gapic/errorreporting_v1beta1/test_report_errors_service.py index f84d267f..4cbde17f 100644 --- a/tests/unit/gapic/errorreporting_v1beta1/test_report_errors_service.py +++ b/tests/unit/gapic/errorreporting_v1beta1/test_report_errors_service.py @@ -92,8 +92,21 @@ def test__get_default_mtls_endpoint(): ) +def test_report_errors_service_client_from_service_account_info(): + creds = credentials.AnonymousCredentials() + with mock.patch.object( + service_account.Credentials, "from_service_account_info" + ) as factory: + factory.return_value = creds + info = {"valid": True} + client = ReportErrorsServiceClient.from_service_account_info(info) + assert client.transport._credentials == creds + + assert client.transport._host == "clouderrorreporting.googleapis.com:443" + + @pytest.mark.parametrize( - "client_class", [ReportErrorsServiceClient, ReportErrorsServiceAsyncClient] + "client_class", [ReportErrorsServiceClient, ReportErrorsServiceAsyncClient,] ) def test_report_errors_service_client_from_service_account_file(client_class): creds = credentials.AnonymousCredentials() @@ -112,7 +125,10 @@ def test_report_errors_service_client_from_service_account_file(client_class): def test_report_errors_service_client_get_transport_class(): transport = ReportErrorsServiceClient.get_transport_class() - assert transport == transports.ReportErrorsServiceGrpcTransport + available_transports = [ + transports.ReportErrorsServiceGrpcTransport, + ] + assert transport in available_transports transport = ReportErrorsServiceClient.get_transport_class("grpc") assert transport == transports.ReportErrorsServiceGrpcTransport @@ -167,7 +183,7 @@ def test_report_errors_service_client_client_options( credentials_file=None, host="squid.clam.whelk", scopes=None, - ssl_channel_credentials=None, + client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, ) @@ -183,7 +199,7 @@ def test_report_errors_service_client_client_options( credentials_file=None, host=client.DEFAULT_ENDPOINT, scopes=None, - ssl_channel_credentials=None, + client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, ) @@ -199,7 +215,7 @@ def test_report_errors_service_client_client_options( credentials_file=None, host=client.DEFAULT_MTLS_ENDPOINT, scopes=None, - ssl_channel_credentials=None, + client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, ) @@ -227,7 +243,7 @@ def test_report_errors_service_client_client_options( credentials_file=None, host=client.DEFAULT_ENDPOINT, scopes=None, - ssl_channel_credentials=None, + client_cert_source_for_mtls=None, quota_project_id="octopus", client_info=transports.base.DEFAULT_CLIENT_INFO, ) @@ -288,29 +304,25 @@ def test_report_errors_service_client_mtls_env_auto( client_cert_source=client_cert_source_callback ) with mock.patch.object(transport_class, "__init__") as patched: - ssl_channel_creds = mock.Mock() - with mock.patch( - "grpc.ssl_channel_credentials", return_value=ssl_channel_creds - ): - patched.return_value = None - client = client_class(client_options=options) + patched.return_value = None + client = client_class(client_options=options) - if use_client_cert_env == "false": - expected_ssl_channel_creds = None - expected_host = client.DEFAULT_ENDPOINT - else: - expected_ssl_channel_creds = ssl_channel_creds - expected_host = client.DEFAULT_MTLS_ENDPOINT + 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, - ssl_channel_credentials=expected_ssl_channel_creds, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) + 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, + ) # Check the case ADC client cert is provided. Whether client cert is used depends on # GOOGLE_API_USE_CLIENT_CERTIFICATE value. @@ -319,66 +331,53 @@ def test_report_errors_service_client_mtls_env_auto( ): with mock.patch.object(transport_class, "__init__") as patched: with mock.patch( - "google.auth.transport.grpc.SslCredentials.__init__", return_value=None + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=True, ): with mock.patch( - "google.auth.transport.grpc.SslCredentials.is_mtls", - new_callable=mock.PropertyMock, - ) as is_mtls_mock: - with mock.patch( - "google.auth.transport.grpc.SslCredentials.ssl_credentials", - new_callable=mock.PropertyMock, - ) as ssl_credentials_mock: - if use_client_cert_env == "false": - is_mtls_mock.return_value = False - ssl_credentials_mock.return_value = None - expected_host = client.DEFAULT_ENDPOINT - expected_ssl_channel_creds = None - else: - is_mtls_mock.return_value = True - ssl_credentials_mock.return_value = mock.Mock() - expected_host = client.DEFAULT_MTLS_ENDPOINT - expected_ssl_channel_creds = ( - ssl_credentials_mock.return_value - ) - - patched.return_value = None - client = client_class() - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=expected_host, - scopes=None, - ssl_channel_credentials=expected_ssl_channel_creds, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) + "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 - # 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.grpc.SslCredentials.__init__", return_value=None - ): - with mock.patch( - "google.auth.transport.grpc.SslCredentials.is_mtls", - new_callable=mock.PropertyMock, - ) as is_mtls_mock: - is_mtls_mock.return_value = False patched.return_value = None client = client_class() patched.assert_called_once_with( credentials=None, credentials_file=None, - host=client.DEFAULT_ENDPOINT, + host=expected_host, scopes=None, - ssl_channel_credentials=None, + client_cert_source_for_mtls=expected_client_cert_source, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, ) + # 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() + 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, + ) + @pytest.mark.parametrize( "client_class,transport_class,transport_name", @@ -408,7 +407,7 @@ def test_report_errors_service_client_client_options_scopes( credentials_file=None, host=client.DEFAULT_ENDPOINT, scopes=["1", "2"], - ssl_channel_credentials=None, + client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, ) @@ -442,7 +441,7 @@ def test_report_errors_service_client_client_options_credentials_file( credentials_file="credentials.json", host=client.DEFAULT_ENDPOINT, scopes=None, - ssl_channel_credentials=None, + client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, ) @@ -461,7 +460,7 @@ def test_report_errors_service_client_client_options_from_dict(): credentials_file=None, host="squid.clam.whelk", scopes=None, - ssl_channel_credentials=None, + client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, ) @@ -860,6 +859,53 @@ def test_report_errors_service_transport_auth_adc(): ) +@pytest.mark.parametrize( + "transport_class", + [ + transports.ReportErrorsServiceGrpcTransport, + transports.ReportErrorsServiceGrpcAsyncIOTransport, + ], +) +def test_report_errors_service_grpc_transport_client_cert_source_for_mtls( + transport_class, +): + cred = 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=("https://www.googleapis.com/auth/cloud-platform",), + 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_report_errors_service_host_no_port(): client = ReportErrorsServiceClient( credentials=credentials.AnonymousCredentials(), @@ -881,7 +927,7 @@ def test_report_errors_service_host_with_port(): def test_report_errors_service_grpc_transport_channel(): - channel = grpc.insecure_channel("http://localhost/") + channel = grpc.secure_channel("http://localhost/", grpc.local_channel_credentials()) # Check that channel is used if provided. transport = transports.ReportErrorsServiceGrpcTransport( @@ -893,7 +939,7 @@ def test_report_errors_service_grpc_transport_channel(): def test_report_errors_service_grpc_asyncio_transport_channel(): - channel = aio.insecure_channel("http://localhost/") + channel = aio.secure_channel("http://localhost/", grpc.local_channel_credentials()) # Check that channel is used if provided. transport = transports.ReportErrorsServiceGrpcAsyncIOTransport( @@ -904,6 +950,8 @@ def test_report_errors_service_grpc_asyncio_transport_channel(): 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", [ @@ -918,7 +966,7 @@ def test_report_errors_service_transport_channel_mtls_with_client_cert_source( "grpc.ssl_channel_credentials", autospec=True ) as grpc_ssl_channel_cred: with mock.patch.object( - transport_class, "create_channel", autospec=True + transport_class, "create_channel" ) as grpc_create_channel: mock_ssl_cred = mock.Mock() grpc_ssl_channel_cred.return_value = mock_ssl_cred @@ -956,6 +1004,8 @@ def test_report_errors_service_transport_channel_mtls_with_client_cert_source( 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", [ @@ -971,7 +1021,7 @@ def test_report_errors_service_transport_channel_mtls_with_adc(transport_class): ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred), ): with mock.patch.object( - transport_class, "create_channel", autospec=True + transport_class, "create_channel" ) as grpc_create_channel: mock_grpc_channel = mock.Mock() grpc_create_channel.return_value = mock_grpc_channel From 1754100a65a8db02af11e0b250f51c8b4c1bec6c Mon Sep 17 00:00:00 2001 From: yoshi-automation Date: Sat, 6 Mar 2021 08:35:53 -0800 Subject: [PATCH 12/25] feat: Add Pub/Sub endpoints for Cloud Channel API. PiperOrigin-RevId: 355059873 Source-Author: Google APIs Source-Date: Mon Feb 1 17:13:22 2021 -0800 Source-Repo: googleapis/googleapis Source-Sha: 6ef9eaea379fc1cc0355e06a5a20b594543ee693 Source-Link: https://github.com/googleapis/googleapis/commit/6ef9eaea379fc1cc0355e06a5a20b594543ee693 --- google/cloud/errorreporting_v1beta1/__init__.py | 4 ++-- synth.metadata | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/google/cloud/errorreporting_v1beta1/__init__.py b/google/cloud/errorreporting_v1beta1/__init__.py index b6f762a3..43fc283f 100644 --- a/google/cloud/errorreporting_v1beta1/__init__.py +++ b/google/cloud/errorreporting_v1beta1/__init__.py @@ -53,6 +53,7 @@ "ErrorGroupOrder", "ErrorGroupServiceClient", "ErrorGroupStats", + "ErrorStatsServiceClient", "GetGroupRequest", "HttpRequestContext", "ListEventsRequest", @@ -62,7 +63,6 @@ "QueryTimeRange", "ReportErrorEventRequest", "ReportErrorEventResponse", - "ReportErrorsServiceClient", "ReportedErrorEvent", "ServiceContext", "ServiceContextFilter", @@ -71,5 +71,5 @@ "TimedCountAlignment", "TrackingIssue", "UpdateGroupRequest", - "ErrorStatsServiceClient", + "ReportErrorsServiceClient", ) diff --git a/synth.metadata b/synth.metadata index be4528bd..953feeb6 100644 --- a/synth.metadata +++ b/synth.metadata @@ -11,8 +11,8 @@ "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "20712b8fe95001b312f62c6c5f33e3e3ec92cfaf", - "internalRef": "354996675" + "sha": "6ef9eaea379fc1cc0355e06a5a20b594543ee693", + "internalRef": "355059873" } }, { From 1c7ab4cc6519272433470c3e63528a4be85c2793 Mon Sep 17 00:00:00 2001 From: yoshi-automation Date: Sat, 6 Mar 2021 08:36:47 -0800 Subject: [PATCH 13/25] fix: add proto opts & bazel targets to metadata PiperOrigin-RevId: 355748843 Source-Author: Google APIs Source-Date: Thu Feb 4 17:39:02 2021 -0800 Source-Repo: googleapis/googleapis Source-Sha: dccd3ea36ba19b88b978c521f5088eddd087c414 Source-Link: https://github.com/googleapis/googleapis/commit/dccd3ea36ba19b88b978c521f5088eddd087c414 --- google/cloud/errorreporting_v1beta1/__init__.py | 4 ++-- synth.metadata | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/google/cloud/errorreporting_v1beta1/__init__.py b/google/cloud/errorreporting_v1beta1/__init__.py index 43fc283f..b6f762a3 100644 --- a/google/cloud/errorreporting_v1beta1/__init__.py +++ b/google/cloud/errorreporting_v1beta1/__init__.py @@ -53,7 +53,6 @@ "ErrorGroupOrder", "ErrorGroupServiceClient", "ErrorGroupStats", - "ErrorStatsServiceClient", "GetGroupRequest", "HttpRequestContext", "ListEventsRequest", @@ -63,6 +62,7 @@ "QueryTimeRange", "ReportErrorEventRequest", "ReportErrorEventResponse", + "ReportErrorsServiceClient", "ReportedErrorEvent", "ServiceContext", "ServiceContextFilter", @@ -71,5 +71,5 @@ "TimedCountAlignment", "TrackingIssue", "UpdateGroupRequest", - "ReportErrorsServiceClient", + "ErrorStatsServiceClient", ) diff --git a/synth.metadata b/synth.metadata index 953feeb6..031a35e7 100644 --- a/synth.metadata +++ b/synth.metadata @@ -11,8 +11,8 @@ "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "6ef9eaea379fc1cc0355e06a5a20b594543ee693", - "internalRef": "355059873" + "sha": "dccd3ea36ba19b88b978c521f5088eddd087c414", + "internalRef": "355748843" } }, { From b4f469252f9fa29940702fc113fc98a7bb5b21df Mon Sep 17 00:00:00 2001 From: yoshi-automation Date: Sat, 6 Mar 2021 08:38:42 -0800 Subject: [PATCH 14/25] build: change package name to correct name PiperOrigin-RevId: 355768365 Source-Author: Google APIs Source-Date: Thu Feb 4 20:11:22 2021 -0800 Source-Repo: googleapis/googleapis Source-Sha: bb17e41ec1e9f1197520560bc13cc5da24e04e6f Source-Link: https://github.com/googleapis/googleapis/commit/bb17e41ec1e9f1197520560bc13cc5da24e04e6f --- google/cloud/errorreporting_v1beta1/__init__.py | 4 ++-- synth.metadata | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/google/cloud/errorreporting_v1beta1/__init__.py b/google/cloud/errorreporting_v1beta1/__init__.py index b6f762a3..8db40bd7 100644 --- a/google/cloud/errorreporting_v1beta1/__init__.py +++ b/google/cloud/errorreporting_v1beta1/__init__.py @@ -51,8 +51,8 @@ "ErrorEvent", "ErrorGroup", "ErrorGroupOrder", - "ErrorGroupServiceClient", "ErrorGroupStats", + "ErrorStatsServiceClient", "GetGroupRequest", "HttpRequestContext", "ListEventsRequest", @@ -71,5 +71,5 @@ "TimedCountAlignment", "TrackingIssue", "UpdateGroupRequest", - "ErrorStatsServiceClient", + "ErrorGroupServiceClient", ) diff --git a/synth.metadata b/synth.metadata index 031a35e7..1268dcd0 100644 --- a/synth.metadata +++ b/synth.metadata @@ -11,8 +11,8 @@ "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "dccd3ea36ba19b88b978c521f5088eddd087c414", - "internalRef": "355748843" + "sha": "bb17e41ec1e9f1197520560bc13cc5da24e04e6f", + "internalRef": "355768365" } }, { From 59480a05c95d947ff8adccbd47552a6709a521fe Mon Sep 17 00:00:00 2001 From: yoshi-automation Date: Sat, 6 Mar 2021 08:39:08 -0800 Subject: [PATCH 15/25] fix: Update bazel builds for ER client libraries. PiperOrigin-RevId: 355832930 Source-Author: Google APIs Source-Date: Fri Feb 5 05:42:21 2021 -0800 Source-Repo: googleapis/googleapis Source-Sha: 408590478542a058f2f1a706a402beb44844f66b Source-Link: https://github.com/googleapis/googleapis/commit/408590478542a058f2f1a706a402beb44844f66b --- google/cloud/errorreporting_v1beta1/__init__.py | 4 ++-- synth.metadata | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/google/cloud/errorreporting_v1beta1/__init__.py b/google/cloud/errorreporting_v1beta1/__init__.py index 8db40bd7..43fc283f 100644 --- a/google/cloud/errorreporting_v1beta1/__init__.py +++ b/google/cloud/errorreporting_v1beta1/__init__.py @@ -51,6 +51,7 @@ "ErrorEvent", "ErrorGroup", "ErrorGroupOrder", + "ErrorGroupServiceClient", "ErrorGroupStats", "ErrorStatsServiceClient", "GetGroupRequest", @@ -62,7 +63,6 @@ "QueryTimeRange", "ReportErrorEventRequest", "ReportErrorEventResponse", - "ReportErrorsServiceClient", "ReportedErrorEvent", "ServiceContext", "ServiceContextFilter", @@ -71,5 +71,5 @@ "TimedCountAlignment", "TrackingIssue", "UpdateGroupRequest", - "ErrorGroupServiceClient", + "ReportErrorsServiceClient", ) diff --git a/synth.metadata b/synth.metadata index 1268dcd0..00b36709 100644 --- a/synth.metadata +++ b/synth.metadata @@ -11,8 +11,8 @@ "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "bb17e41ec1e9f1197520560bc13cc5da24e04e6f", - "internalRef": "355768365" + "sha": "408590478542a058f2f1a706a402beb44844f66b", + "internalRef": "355832930" } }, { From cef9dfea5fa8aea003ad8f3ccde1e3549c67ad74 Mon Sep 17 00:00:00 2001 From: yoshi-automation Date: Sat, 6 Mar 2021 08:40:10 -0800 Subject: [PATCH 16/25] fix: Fix constraint resource pattern annotation PiperOrigin-RevId: 355915985 Source-Author: Google APIs Source-Date: Fri Feb 5 13:27:16 2021 -0800 Source-Repo: googleapis/googleapis Source-Sha: 35ce99fec72979f6f9b2a5adae835a49648a3231 Source-Link: https://github.com/googleapis/googleapis/commit/35ce99fec72979f6f9b2a5adae835a49648a3231 --- google/cloud/errorreporting_v1beta1/__init__.py | 4 ++-- synth.metadata | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/google/cloud/errorreporting_v1beta1/__init__.py b/google/cloud/errorreporting_v1beta1/__init__.py index 43fc283f..b6f762a3 100644 --- a/google/cloud/errorreporting_v1beta1/__init__.py +++ b/google/cloud/errorreporting_v1beta1/__init__.py @@ -53,7 +53,6 @@ "ErrorGroupOrder", "ErrorGroupServiceClient", "ErrorGroupStats", - "ErrorStatsServiceClient", "GetGroupRequest", "HttpRequestContext", "ListEventsRequest", @@ -63,6 +62,7 @@ "QueryTimeRange", "ReportErrorEventRequest", "ReportErrorEventResponse", + "ReportErrorsServiceClient", "ReportedErrorEvent", "ServiceContext", "ServiceContextFilter", @@ -71,5 +71,5 @@ "TimedCountAlignment", "TrackingIssue", "UpdateGroupRequest", - "ReportErrorsServiceClient", + "ErrorStatsServiceClient", ) diff --git a/synth.metadata b/synth.metadata index 00b36709..5b99aca7 100644 --- a/synth.metadata +++ b/synth.metadata @@ -11,8 +11,8 @@ "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "408590478542a058f2f1a706a402beb44844f66b", - "internalRef": "355832930" + "sha": "35ce99fec72979f6f9b2a5adae835a49648a3231", + "internalRef": "355915985" } }, { From fef544264b5edb5b504afe0465d190ee4f5a8355 Mon Sep 17 00:00:00 2001 From: yoshi-automation Date: Sat, 6 Mar 2021 08:40:10 -0800 Subject: [PATCH 17/25] chore: update gapic-generator-python PiperOrigin-RevId: 355923884 Source-Author: Google APIs Source-Date: Fri Feb 5 14:04:52 2021 -0800 Source-Repo: googleapis/googleapis Source-Sha: 5e3dacee19405529b841b53797df799c2383536c Source-Link: https://github.com/googleapis/googleapis/commit/5e3dacee19405529b841b53797df799c2383536c --- google/cloud/errorreporting_v1beta1/__init__.py | 4 ++-- .../services/error_stats_service/pagers.py | 11 ++++++++++- synth.metadata | 4 ++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/google/cloud/errorreporting_v1beta1/__init__.py b/google/cloud/errorreporting_v1beta1/__init__.py index b6f762a3..43fc283f 100644 --- a/google/cloud/errorreporting_v1beta1/__init__.py +++ b/google/cloud/errorreporting_v1beta1/__init__.py @@ -53,6 +53,7 @@ "ErrorGroupOrder", "ErrorGroupServiceClient", "ErrorGroupStats", + "ErrorStatsServiceClient", "GetGroupRequest", "HttpRequestContext", "ListEventsRequest", @@ -62,7 +63,6 @@ "QueryTimeRange", "ReportErrorEventRequest", "ReportErrorEventResponse", - "ReportErrorsServiceClient", "ReportedErrorEvent", "ServiceContext", "ServiceContextFilter", @@ -71,5 +71,5 @@ "TimedCountAlignment", "TrackingIssue", "UpdateGroupRequest", - "ErrorStatsServiceClient", + "ReportErrorsServiceClient", ) diff --git a/google/cloud/errorreporting_v1beta1/services/error_stats_service/pagers.py b/google/cloud/errorreporting_v1beta1/services/error_stats_service/pagers.py index 63bb8413..a5d6c02f 100644 --- a/google/cloud/errorreporting_v1beta1/services/error_stats_service/pagers.py +++ b/google/cloud/errorreporting_v1beta1/services/error_stats_service/pagers.py @@ -15,7 +15,16 @@ # limitations under the License. # -from typing import Any, AsyncIterable, Awaitable, Callable, Iterable, Sequence, Tuple +from typing import ( + Any, + AsyncIterable, + Awaitable, + Callable, + Iterable, + Sequence, + Tuple, + Optional, +) from google.cloud.errorreporting_v1beta1.types import common from google.cloud.errorreporting_v1beta1.types import error_stats_service diff --git a/synth.metadata b/synth.metadata index 5b99aca7..263377b1 100644 --- a/synth.metadata +++ b/synth.metadata @@ -11,8 +11,8 @@ "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "35ce99fec72979f6f9b2a5adae835a49648a3231", - "internalRef": "355915985" + "sha": "5e3dacee19405529b841b53797df799c2383536c", + "internalRef": "355923884" } }, { From 7b17458456029d7f0601ebadfc7f0b300f45d7c1 Mon Sep 17 00:00:00 2001 From: yoshi-automation Date: Sat, 6 Mar 2021 08:40:33 -0800 Subject: [PATCH 18/25] chore(python): include py.typed files in release A py.typed file must be included in the released package for it to be considered typed by type checkers. https://www.python.org/dev/peps/pep-0561/#packaging-type-information. See https://github.com/googleapis/python-secret-manager/issues/79 Source-Author: Bu Sun Kim <8822365+busunkim96@users.noreply.github.com> Source-Date: Fri Feb 5 17:32:06 2021 -0700 Source-Repo: googleapis/synthtool Source-Sha: 33366574ffb9e11737b3547eb6f020ecae0536e8 Source-Link: https://github.com/googleapis/synthtool/commit/33366574ffb9e11737b3547eb6f020ecae0536e8 --- google/cloud/errorreporting_v1beta1/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/google/cloud/errorreporting_v1beta1/__init__.py b/google/cloud/errorreporting_v1beta1/__init__.py index 43fc283f..b6f762a3 100644 --- a/google/cloud/errorreporting_v1beta1/__init__.py +++ b/google/cloud/errorreporting_v1beta1/__init__.py @@ -53,7 +53,6 @@ "ErrorGroupOrder", "ErrorGroupServiceClient", "ErrorGroupStats", - "ErrorStatsServiceClient", "GetGroupRequest", "HttpRequestContext", "ListEventsRequest", @@ -63,6 +62,7 @@ "QueryTimeRange", "ReportErrorEventRequest", "ReportErrorEventResponse", + "ReportErrorsServiceClient", "ReportedErrorEvent", "ServiceContext", "ServiceContextFilter", @@ -71,5 +71,5 @@ "TimedCountAlignment", "TrackingIssue", "UpdateGroupRequest", - "ReportErrorsServiceClient", + "ErrorStatsServiceClient", ) From 2a6dd5e6016ce36d318f0541de9f8ac985c87df0 Mon Sep 17 00:00:00 2001 From: yoshi-automation Date: Sat, 6 Mar 2021 08:41:22 -0800 Subject: [PATCH 19/25] feat: Make resolution status field available for error groups. Now callers can set the status of an error group by passing this to UpdateGroup. When not specified, it's treated like OPEN. feat: Make source location available for error groups created from GAE. PiperOrigin-RevId: 356330876 Source-Author: Google APIs Source-Date: Mon Feb 8 12:48:44 2021 -0800 Source-Repo: googleapis/googleapis Source-Sha: c1e59709c1d28795fe9b70eb479579556056bfad Source-Link: https://github.com/googleapis/googleapis/commit/c1e59709c1d28795fe9b70eb479579556056bfad --- .../cloud/errorreporting_v1beta1/__init__.py | 2 ++ .../errorreporting_v1beta1/proto/common.proto | 36 +++++++++++++++++-- .../proto/error_group_service.proto | 5 ++- .../proto/error_stats_service.proto | 17 ++++----- .../proto/report_errors_service.proto | 22 ++++++++---- .../error_group_service/async_client.py | 2 +- .../services/error_group_service/client.py | 2 +- .../error_stats_service/async_client.py | 24 +++++++------ .../services/error_stats_service/client.py | 24 +++++++------ .../report_errors_service/async_client.py | 19 +++++++--- .../services/report_errors_service/client.py | 19 +++++++--- .../report_errors_service/transports/grpc.py | 12 +++++-- .../transports/grpc_asyncio.py | 12 +++++-- .../errorreporting_v1beta1/types/__init__.py | 2 ++ .../errorreporting_v1beta1/types/common.py | 27 +++++++++++++- .../types/error_group_service.py | 2 +- .../types/error_stats_service.py | 22 ++++++------ .../types/report_errors_service.py | 7 ++-- synth.metadata | 4 +-- .../test_error_group_service.py | 28 ++++++++++++--- .../test_report_errors_service.py | 1 + 21 files changed, 209 insertions(+), 80 deletions(-) diff --git a/google/cloud/errorreporting_v1beta1/__init__.py b/google/cloud/errorreporting_v1beta1/__init__.py index b6f762a3..ec7448cd 100644 --- a/google/cloud/errorreporting_v1beta1/__init__.py +++ b/google/cloud/errorreporting_v1beta1/__init__.py @@ -22,6 +22,7 @@ from .types.common import ErrorEvent from .types.common import ErrorGroup from .types.common import HttpRequestContext +from .types.common import ResolutionStatus from .types.common import ServiceContext from .types.common import SourceLocation from .types.common import TrackingIssue @@ -64,6 +65,7 @@ "ReportErrorEventResponse", "ReportErrorsServiceClient", "ReportedErrorEvent", + "ResolutionStatus", "ServiceContext", "ServiceContextFilter", "SourceLocation", diff --git a/google/cloud/errorreporting_v1beta1/proto/common.proto b/google/cloud/errorreporting_v1beta1/proto/common.proto index 7a1d2003..e8786461 100644 --- a/google/cloud/errorreporting_v1beta1/proto/common.proto +++ b/google/cloud/errorreporting_v1beta1/proto/common.proto @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -16,9 +16,10 @@ syntax = "proto3"; package google.devtools.clouderrorreporting.v1beta1; -import "google/api/annotations.proto"; import "google/api/resource.proto"; +import "google/appengine/logging/v1/request_log.proto"; import "google/protobuf/timestamp.proto"; +import "google/api/annotations.proto"; option cc_enable_arenas = true; option csharp_namespace = "Google.Cloud.ErrorReporting.V1Beta1"; @@ -37,7 +38,7 @@ message ErrorGroup { }; // The group resource name. - // Example: projects/my-project-123/groups/my-groupid + // Example: projects/my-project-123/groups/CNSgkpnppqKCUw string name = 1; // Group IDs are unique for a given project. If the same kind of error @@ -46,6 +47,10 @@ message ErrorGroup { // Associated tracking issues. repeated TrackingIssue tracking_issues = 3; + + // Error group's resolution status. + // An unspecified resolution status will be interpreted as OPEN + ResolutionStatus resolution_status = 5; } // Information related to tracking the progress on resolving the error. @@ -123,6 +128,10 @@ message ErrorContext { // exception is logged, usually close to the place where it was // caught. SourceLocation report_location = 3; + + // Source code that was used to build the executable which has + // caused the given error message. + repeated google.appengine.logging.v1.SourceReference source_references = 4; } // HTTP request data that is related to a reported error. @@ -169,3 +178,24 @@ message SourceLocation { // For example, `my.package.MyClass.method` in case of Java. string function_name = 4; } + +// Resolution status of an error group. +enum ResolutionStatus { + // Status is unknown. When left unspecified in requests, it is treated like + // OPEN. + RESOLUTION_STATUS_UNSPECIFIED = 0; + + // The error group is not being addressed. This is the default for + // new groups. It is also used for errors re-occurring after marked RESOLVED. + OPEN = 1; + + // Error Group manually acknowledged, it can have an issue link attached. + ACKNOWLEDGED = 2; + + // Error Group manually resolved, more events for this group are not expected + // to occur. + RESOLVED = 3; + + // The error group is muted and excluded by default on group stats requests. + MUTED = 4; +} diff --git a/google/cloud/errorreporting_v1beta1/proto/error_group_service.proto b/google/cloud/errorreporting_v1beta1/proto/error_group_service.proto index 18182729..0104b62d 100644 --- a/google/cloud/errorreporting_v1beta1/proto/error_group_service.proto +++ b/google/cloud/errorreporting_v1beta1/proto/error_group_service.proto @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -11,7 +11,6 @@ // 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. -// syntax = "proto3"; @@ -58,7 +57,7 @@ service ErrorGroupService { // A request to return an individual group. message GetGroupRequest { - // The group resource name. Written as + // Required. The group resource name. Written as // `projects/{projectID}/groups/{group_name}`. Call // [`groupStats.list`](https://cloud.google.com/error-reporting/reference/rest/v1beta1/projects.groupStats/list) // to return a list of groups belonging to this project. diff --git a/google/cloud/errorreporting_v1beta1/proto/error_stats_service.proto b/google/cloud/errorreporting_v1beta1/proto/error_stats_service.proto index 0773f488..6c62edd9 100644 --- a/google/cloud/errorreporting_v1beta1/proto/error_stats_service.proto +++ b/google/cloud/errorreporting_v1beta1/proto/error_stats_service.proto @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -11,7 +11,6 @@ // 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. -// syntax = "proto3"; @@ -68,11 +67,11 @@ service ErrorStatsService { // Specifies a set of `ErrorGroupStats` to return. message ListGroupStatsRequest { // Required. The resource name of the Google Cloud Platform project. Written - // as projects/ plus the - // Google Cloud - // Platform project ID. + // as `projects/{projectID}` or `projects/{projectNumber}`, where `{projectID}` + // and `{projectNumber}` can be found in the + // [Google Cloud Console](https://support.google.com/cloud/answer/6158840). // - // Example: projects/my-project-123. + // Examples: `projects/my-project-123`, `projects/5551234`. string project_name = 1 [ (google.api.field_behavior) = REQUIRED, (google.api.resource_reference) = { @@ -258,9 +257,10 @@ enum ErrorGroupOrder { // Specifies a set of error events to return. message ListEventsRequest { // Required. The resource name of the Google Cloud Platform project. Written - // as `projects/` plus the + // as `projects/{projectID}`, where `{projectID}` is the // [Google Cloud Platform project // ID](https://support.google.com/cloud/answer/6158840). + // // Example: `projects/my-project-123`. string project_name = 1 [ (google.api.field_behavior) = REQUIRED, @@ -357,9 +357,10 @@ message ServiceContextFilter { // Deletes all events in the project. message DeleteEventsRequest { // Required. The resource name of the Google Cloud Platform project. Written - // as `projects/` plus the + // as `projects/{projectID}`, where `{projectID}` is the // [Google Cloud Platform project // ID](https://support.google.com/cloud/answer/6158840). + // // Example: `projects/my-project-123`. string project_name = 1 [ (google.api.field_behavior) = REQUIRED, diff --git a/google/cloud/errorreporting_v1beta1/proto/report_errors_service.proto b/google/cloud/errorreporting_v1beta1/proto/report_errors_service.proto index f46f546d..cd1e5100 100644 --- a/google/cloud/errorreporting_v1beta1/proto/report_errors_service.proto +++ b/google/cloud/errorreporting_v1beta1/proto/report_errors_service.proto @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -11,7 +11,6 @@ // 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. -// syntax = "proto3"; @@ -38,7 +37,7 @@ service ReportErrorsService { option (google.api.default_host) = "clouderrorreporting.googleapis.com"; option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; - // Report an individual error event. + // Report an individual error event and record the event to a log. // // This endpoint accepts **either** an OAuth token, // **or** an [API key](https://support.google.com/cloud/answer/6158862) @@ -46,7 +45,15 @@ service ReportErrorsService { // a `key` parameter. For example: // // `POST - // https://clouderrorreporting.googleapis.com/v1beta1/projects/example-project/events:report?key=123ABC456` + // https://clouderrorreporting.googleapis.com/v1beta1/{projectName}/events:report?key=123ABC456` + // + // **Note:** [Error Reporting](/error-reporting) is a global service built + // on Cloud Logging and doesn't analyze logs stored + // in regional log buckets or logs routed to other Google Cloud projects. + // + // For more information, see + // [Using Error Reporting with regionalized + // logs](/error-reporting/docs/regionalization). rpc ReportErrorEvent(ReportErrorEventRequest) returns (ReportErrorEventResponse) { option (google.api.http) = { post: "/v1beta1/{project_name=projects/*}/events:report" @@ -59,10 +66,11 @@ service ReportErrorsService { // A request for reporting an individual error event. message ReportErrorEventRequest { // Required. The resource name of the Google Cloud Platform project. Written - // as `projects/` plus the + // as `projects/{projectId}`, where `{projectId}` is the // [Google Cloud Platform project - // ID](https://support.google.com/cloud/answer/6158840). Example: - // `projects/my-project-123`. + // ID](https://support.google.com/cloud/answer/6158840). + // + // Example: // `projects/my-project-123`. string project_name = 1 [ (google.api.field_behavior) = REQUIRED, (google.api.resource_reference) = { diff --git a/google/cloud/errorreporting_v1beta1/services/error_group_service/async_client.py b/google/cloud/errorreporting_v1beta1/services/error_group_service/async_client.py index c44df685..201522ba 100644 --- a/google/cloud/errorreporting_v1beta1/services/error_group_service/async_client.py +++ b/google/cloud/errorreporting_v1beta1/services/error_group_service/async_client.py @@ -159,7 +159,7 @@ async def get_group( The request object. A request to return an individual group. group_name (:class:`str`): - The group resource name. Written as + Required. The group resource name. Written as ``projects/{projectID}/groups/{group_name}``. Call ```groupStats.list`` `__ to return a list of groups belonging to this project. diff --git a/google/cloud/errorreporting_v1beta1/services/error_group_service/client.py b/google/cloud/errorreporting_v1beta1/services/error_group_service/client.py index 2c00658d..db374a93 100644 --- a/google/cloud/errorreporting_v1beta1/services/error_group_service/client.py +++ b/google/cloud/errorreporting_v1beta1/services/error_group_service/client.py @@ -356,7 +356,7 @@ def get_group( The request object. A request to return an individual group. group_name (str): - The group resource name. Written as + Required. The group resource name. Written as ``projects/{projectID}/groups/{group_name}``. Call ```groupStats.list`` `__ to return a list of groups belonging to this project. diff --git a/google/cloud/errorreporting_v1beta1/services/error_stats_service/async_client.py b/google/cloud/errorreporting_v1beta1/services/error_stats_service/async_client.py index 15cb7577..eca1d0d5 100644 --- a/google/cloud/errorreporting_v1beta1/services/error_stats_service/async_client.py +++ b/google/cloud/errorreporting_v1beta1/services/error_stats_service/async_client.py @@ -163,14 +163,14 @@ async def list_group_stats( The request object. Specifies a set of `ErrorGroupStats` to return. project_name (:class:`str`): - Required. The resource name of the - Google Cloud Platform project. Written - as projects/ plus the Google - Cloud Platform project ID. + Required. The resource name of the Google Cloud Platform + project. Written as ``projects/{projectID}`` or + ``projects/{projectNumber}``, where ``{projectID}`` and + ``{projectNumber}`` can be found in the `Google Cloud + Console `__. - Example: projects/my- - project-123. + Examples: ``projects/my-project-123``, + ``projects/5551234``. This corresponds to the ``project_name`` field on the ``request`` instance; if ``request`` is provided, this @@ -270,9 +270,10 @@ async def list_events( return. project_name (:class:`str`): Required. The resource name of the Google Cloud Platform - project. Written as ``projects/`` plus the `Google Cloud - Platform project + project. Written as ``projects/{projectID}``, where + ``{projectID}`` is the `Google Cloud Platform project ID `__. + Example: ``projects/my-project-123``. This corresponds to the ``project_name`` field @@ -365,9 +366,10 @@ async def delete_events( The request object. Deletes all events in the project. project_name (:class:`str`): Required. The resource name of the Google Cloud Platform - project. Written as ``projects/`` plus the `Google Cloud - Platform project + project. Written as ``projects/{projectID}``, where + ``{projectID}`` is the `Google Cloud Platform project ID `__. + Example: ``projects/my-project-123``. This corresponds to the ``project_name`` field diff --git a/google/cloud/errorreporting_v1beta1/services/error_stats_service/client.py b/google/cloud/errorreporting_v1beta1/services/error_stats_service/client.py index ab63651e..7178412c 100644 --- a/google/cloud/errorreporting_v1beta1/services/error_stats_service/client.py +++ b/google/cloud/errorreporting_v1beta1/services/error_stats_service/client.py @@ -360,14 +360,14 @@ def list_group_stats( The request object. Specifies a set of `ErrorGroupStats` to return. project_name (str): - Required. The resource name of the - Google Cloud Platform project. Written - as projects/ plus the Google - Cloud Platform project ID. + Required. The resource name of the Google Cloud Platform + project. Written as ``projects/{projectID}`` or + ``projects/{projectNumber}``, where ``{projectID}`` and + ``{projectNumber}`` can be found in the `Google Cloud + Console `__. - Example: projects/my- - project-123. + Examples: ``projects/my-project-123``, + ``projects/5551234``. This corresponds to the ``project_name`` field on the ``request`` instance; if ``request`` is provided, this @@ -468,9 +468,10 @@ def list_events( return. project_name (str): Required. The resource name of the Google Cloud Platform - project. Written as ``projects/`` plus the `Google Cloud - Platform project + project. Written as ``projects/{projectID}``, where + ``{projectID}`` is the `Google Cloud Platform project ID `__. + Example: ``projects/my-project-123``. This corresponds to the ``project_name`` field @@ -564,9 +565,10 @@ def delete_events( The request object. Deletes all events in the project. project_name (str): Required. The resource name of the Google Cloud Platform - project. Written as ``projects/`` plus the `Google Cloud - Platform project + project. Written as ``projects/{projectID}``, where + ``{projectID}`` is the `Google Cloud Platform project ID `__. + Example: ``projects/my-project-123``. This corresponds to the ``project_name`` field diff --git a/google/cloud/errorreporting_v1beta1/services/report_errors_service/async_client.py b/google/cloud/errorreporting_v1beta1/services/report_errors_service/async_client.py index 9562776f..723ee800 100644 --- a/google/cloud/errorreporting_v1beta1/services/report_errors_service/async_client.py +++ b/google/cloud/errorreporting_v1beta1/services/report_errors_service/async_client.py @@ -148,14 +148,22 @@ async def report_error_event( timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> report_errors_service.ReportErrorEventResponse: - r"""Report an individual error event. + r"""Report an individual error event and record the event to a log. This endpoint accepts **either** an OAuth token, **or** an `API key `__ for authentication. To use an API key, append it to the URL as the value of a ``key`` parameter. For example: - ``POST https://clouderrorreporting.googleapis.com/v1beta1/projects/example-project/events:report?key=123ABC456`` + ``POST https://clouderrorreporting.googleapis.com/v1beta1/{projectName}/events:report?key=123ABC456`` + + **Note:** `Error Reporting `__ is a global + service built on Cloud Logging and doesn't analyze logs stored + in regional log buckets or logs routed to other Google Cloud + projects. + + For more information, see `Using Error Reporting with + regionalized logs `__. Args: request (:class:`google.cloud.errorreporting_v1beta1.types.ReportErrorEventRequest`): @@ -163,10 +171,11 @@ async def report_error_event( individual error event. project_name (:class:`str`): Required. The resource name of the Google Cloud Platform - project. Written as ``projects/`` plus the `Google Cloud - Platform project + project. Written as ``projects/{projectId}``, where + ``{projectId}`` is the `Google Cloud Platform project ID `__. - Example: ``projects/my-project-123``. + + Example: // ``projects/my-project-123``. This corresponds to the ``project_name`` field on the ``request`` instance; if ``request`` is provided, this diff --git a/google/cloud/errorreporting_v1beta1/services/report_errors_service/client.py b/google/cloud/errorreporting_v1beta1/services/report_errors_service/client.py index 01c3fb00..840e449f 100644 --- a/google/cloud/errorreporting_v1beta1/services/report_errors_service/client.py +++ b/google/cloud/errorreporting_v1beta1/services/report_errors_service/client.py @@ -338,14 +338,22 @@ def report_error_event( timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> report_errors_service.ReportErrorEventResponse: - r"""Report an individual error event. + r"""Report an individual error event and record the event to a log. This endpoint accepts **either** an OAuth token, **or** an `API key `__ for authentication. To use an API key, append it to the URL as the value of a ``key`` parameter. For example: - ``POST https://clouderrorreporting.googleapis.com/v1beta1/projects/example-project/events:report?key=123ABC456`` + ``POST https://clouderrorreporting.googleapis.com/v1beta1/{projectName}/events:report?key=123ABC456`` + + **Note:** `Error Reporting `__ is a global + service built on Cloud Logging and doesn't analyze logs stored + in regional log buckets or logs routed to other Google Cloud + projects. + + For more information, see `Using Error Reporting with + regionalized logs `__. Args: request (google.cloud.errorreporting_v1beta1.types.ReportErrorEventRequest): @@ -353,10 +361,11 @@ def report_error_event( individual error event. project_name (str): Required. The resource name of the Google Cloud Platform - project. Written as ``projects/`` plus the `Google Cloud - Platform project + project. Written as ``projects/{projectId}``, where + ``{projectId}`` is the `Google Cloud Platform project ID `__. - Example: ``projects/my-project-123``. + + Example: // ``projects/my-project-123``. This corresponds to the ``project_name`` field on the ``request`` instance; if ``request`` is provided, this diff --git a/google/cloud/errorreporting_v1beta1/services/report_errors_service/transports/grpc.py b/google/cloud/errorreporting_v1beta1/services/report_errors_service/transports/grpc.py index 106dab79..f7eea171 100644 --- a/google/cloud/errorreporting_v1beta1/services/report_errors_service/transports/grpc.py +++ b/google/cloud/errorreporting_v1beta1/services/report_errors_service/transports/grpc.py @@ -257,14 +257,22 @@ def report_error_event( ]: r"""Return a callable for the report error event method over gRPC. - Report an individual error event. + Report an individual error event and record the event to a log. This endpoint accepts **either** an OAuth token, **or** an `API key `__ for authentication. To use an API key, append it to the URL as the value of a ``key`` parameter. For example: - ``POST https://clouderrorreporting.googleapis.com/v1beta1/projects/example-project/events:report?key=123ABC456`` + ``POST https://clouderrorreporting.googleapis.com/v1beta1/{projectName}/events:report?key=123ABC456`` + + **Note:** `Error Reporting `__ is a global + service built on Cloud Logging and doesn't analyze logs stored + in regional log buckets or logs routed to other Google Cloud + projects. + + For more information, see `Using Error Reporting with + regionalized logs `__. Returns: Callable[[~.ReportErrorEventRequest], diff --git a/google/cloud/errorreporting_v1beta1/services/report_errors_service/transports/grpc_asyncio.py b/google/cloud/errorreporting_v1beta1/services/report_errors_service/transports/grpc_asyncio.py index 9b357ded..80327fd8 100644 --- a/google/cloud/errorreporting_v1beta1/services/report_errors_service/transports/grpc_asyncio.py +++ b/google/cloud/errorreporting_v1beta1/services/report_errors_service/transports/grpc_asyncio.py @@ -261,14 +261,22 @@ def report_error_event( ]: r"""Return a callable for the report error event method over gRPC. - Report an individual error event. + Report an individual error event and record the event to a log. This endpoint accepts **either** an OAuth token, **or** an `API key `__ for authentication. To use an API key, append it to the URL as the value of a ``key`` parameter. For example: - ``POST https://clouderrorreporting.googleapis.com/v1beta1/projects/example-project/events:report?key=123ABC456`` + ``POST https://clouderrorreporting.googleapis.com/v1beta1/{projectName}/events:report?key=123ABC456`` + + **Note:** `Error Reporting `__ is a global + service built on Cloud Logging and doesn't analyze logs stored + in regional log buckets or logs routed to other Google Cloud + projects. + + For more information, see `Using Error Reporting with + regionalized logs `__. Returns: Callable[[~.ReportErrorEventRequest], diff --git a/google/cloud/errorreporting_v1beta1/types/__init__.py b/google/cloud/errorreporting_v1beta1/types/__init__.py index fc7243be..8819a78f 100644 --- a/google/cloud/errorreporting_v1beta1/types/__init__.py +++ b/google/cloud/errorreporting_v1beta1/types/__init__.py @@ -23,6 +23,7 @@ ErrorContext, HttpRequestContext, SourceLocation, + ResolutionStatus, ) from .error_group_service import ( GetGroupRequest, @@ -56,6 +57,7 @@ "ErrorContext", "HttpRequestContext", "SourceLocation", + "ResolutionStatus", "GetGroupRequest", "UpdateGroupRequest", "ListGroupStatsRequest", diff --git a/google/cloud/errorreporting_v1beta1/types/common.py b/google/cloud/errorreporting_v1beta1/types/common.py index e8371063..58429a89 100644 --- a/google/cloud/errorreporting_v1beta1/types/common.py +++ b/google/cloud/errorreporting_v1beta1/types/common.py @@ -18,12 +18,14 @@ import proto # type: ignore +from google.appengine.logging.v1 import request_log_pb2 as request_log # type: ignore from google.protobuf import timestamp_pb2 as timestamp # type: ignore __protobuf__ = proto.module( package="google.devtools.clouderrorreporting.v1beta1", manifest={ + "ResolutionStatus", "ErrorGroup", "TrackingIssue", "ErrorEvent", @@ -35,6 +37,15 @@ ) +class ResolutionStatus(proto.Enum): + r"""Resolution status of an error group.""" + RESOLUTION_STATUS_UNSPECIFIED = 0 + OPEN = 1 + ACKNOWLEDGED = 2 + RESOLVED = 3 + MUTED = 4 + + class ErrorGroup(proto.Message): r"""Description of a group of similar error events. @@ -42,7 +53,7 @@ class ErrorGroup(proto.Message): name (str): The group resource name. Example: projects/my- - project-123/groups/my-groupid + project-123/groups/CNSgkpnppqKCUw group_id (str): Group IDs are unique for a given project. If the same kind of error occurs in different @@ -50,6 +61,10 @@ class ErrorGroup(proto.Message): ID. tracking_issues (Sequence[google.cloud.errorreporting_v1beta1.types.TrackingIssue]): Associated tracking issues. + resolution_status (google.cloud.errorreporting_v1beta1.types.ResolutionStatus): + Error group's resolution status. + An unspecified resolution status will be + interpreted as OPEN """ name = proto.Field(proto.STRING, number=1) @@ -60,6 +75,8 @@ class ErrorGroup(proto.Message): proto.MESSAGE, number=3, message="TrackingIssue", ) + resolution_status = proto.Field(proto.ENUM, number=5, enum="ResolutionStatus",) + class TrackingIssue(proto.Message): r"""Information related to tracking the progress on resolving the @@ -167,6 +184,10 @@ class ErrorContext(proto.Message): exception this would be the source line where the exception is logged, usually close to the place where it was caught. + source_references (Sequence[google.appengine.logging.v1.request_log_pb2.SourceReference]): + Source code that was used to build the + executable which has caused the given error + message. """ http_request = proto.Field(proto.MESSAGE, number=1, message="HttpRequestContext",) @@ -175,6 +196,10 @@ class ErrorContext(proto.Message): report_location = proto.Field(proto.MESSAGE, number=3, message="SourceLocation",) + source_references = proto.RepeatedField( + proto.MESSAGE, number=4, message=request_log.SourceReference, + ) + class HttpRequestContext(proto.Message): r"""HTTP request data that is related to a reported error. diff --git a/google/cloud/errorreporting_v1beta1/types/error_group_service.py b/google/cloud/errorreporting_v1beta1/types/error_group_service.py index 632e072f..e36854b6 100644 --- a/google/cloud/errorreporting_v1beta1/types/error_group_service.py +++ b/google/cloud/errorreporting_v1beta1/types/error_group_service.py @@ -32,7 +32,7 @@ class GetGroupRequest(proto.Message): Attributes: group_name (str): - The group resource name. Written as + Required. The group resource name. Written as ``projects/{projectID}/groups/{group_name}``. Call ```groupStats.list`` `__ to return a list of groups belonging to this project. diff --git a/google/cloud/errorreporting_v1beta1/types/error_stats_service.py b/google/cloud/errorreporting_v1beta1/types/error_stats_service.py index dfd08020..3973ca04 100644 --- a/google/cloud/errorreporting_v1beta1/types/error_stats_service.py +++ b/google/cloud/errorreporting_v1beta1/types/error_stats_service.py @@ -65,13 +65,13 @@ class ListGroupStatsRequest(proto.Message): Attributes: project_name (str): - Required. The resource name of the Google - Cloud Platform project. Written as - projects/ plus the Google - Cloud Platform project ID. + Required. The resource name of the Google Cloud Platform + project. Written as ``projects/{projectID}`` or + ``projects/{projectNumber}``, where ``{projectID}`` and + ``{projectNumber}`` can be found in the `Google Cloud + Console `__. - Example: projects/my-project-123. + Examples: ``projects/my-project-123``, ``projects/5551234``. group_id (Sequence[str]): Optional. List all ErrorGroupStats with these IDs. @@ -279,9 +279,10 @@ class ListEventsRequest(proto.Message): Attributes: project_name (str): Required. The resource name of the Google Cloud Platform - project. Written as ``projects/`` plus the `Google Cloud - Platform project + project. Written as ``projects/{projectID}``, where + ``{projectID}`` is the `Google Cloud Platform project ID `__. + Example: ``projects/my-project-123``. group_id (str): Required. The group for which events shall be @@ -404,9 +405,10 @@ class DeleteEventsRequest(proto.Message): Attributes: project_name (str): Required. The resource name of the Google Cloud Platform - project. Written as ``projects/`` plus the `Google Cloud - Platform project + project. Written as ``projects/{projectID}``, where + ``{projectID}`` is the `Google Cloud Platform project ID `__. + Example: ``projects/my-project-123``. """ diff --git a/google/cloud/errorreporting_v1beta1/types/report_errors_service.py b/google/cloud/errorreporting_v1beta1/types/report_errors_service.py index e53fa5e5..bdba6ee8 100644 --- a/google/cloud/errorreporting_v1beta1/types/report_errors_service.py +++ b/google/cloud/errorreporting_v1beta1/types/report_errors_service.py @@ -38,10 +38,11 @@ class ReportErrorEventRequest(proto.Message): Attributes: project_name (str): Required. The resource name of the Google Cloud Platform - project. Written as ``projects/`` plus the `Google Cloud - Platform project + project. Written as ``projects/{projectId}``, where + ``{projectId}`` is the `Google Cloud Platform project ID `__. - Example: ``projects/my-project-123``. + + Example: // ``projects/my-project-123``. event (google.cloud.errorreporting_v1beta1.types.ReportedErrorEvent): Required. The error event to be reported. """ diff --git a/synth.metadata b/synth.metadata index 263377b1..9f98cc5c 100644 --- a/synth.metadata +++ b/synth.metadata @@ -11,8 +11,8 @@ "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "5e3dacee19405529b841b53797df799c2383536c", - "internalRef": "355923884" + "sha": "c1e59709c1d28795fe9b70eb479579556056bfad", + "internalRef": "356330876" } }, { diff --git a/tests/unit/gapic/errorreporting_v1beta1/test_error_group_service.py b/tests/unit/gapic/errorreporting_v1beta1/test_error_group_service.py index 5abefc9b..0b7c1973 100644 --- a/tests/unit/gapic/errorreporting_v1beta1/test_error_group_service.py +++ b/tests/unit/gapic/errorreporting_v1beta1/test_error_group_service.py @@ -466,7 +466,9 @@ def test_get_group( with mock.patch.object(type(client.transport.get_group), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = common.ErrorGroup( - name="name_value", group_id="group_id_value", + name="name_value", + group_id="group_id_value", + resolution_status=common.ResolutionStatus.OPEN, ) response = client.get_group(request) @@ -485,6 +487,8 @@ def test_get_group( assert response.group_id == "group_id_value" + assert response.resolution_status == common.ResolutionStatus.OPEN + def test_get_group_from_dict(): test_get_group(request_type=dict) @@ -506,7 +510,11 @@ async def test_get_group_async( with mock.patch.object(type(client.transport.get_group), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - common.ErrorGroup(name="name_value", group_id="group_id_value",) + common.ErrorGroup( + name="name_value", + group_id="group_id_value", + resolution_status=common.ResolutionStatus.OPEN, + ) ) response = await client.get_group(request) @@ -524,6 +532,8 @@ async def test_get_group_async( assert response.group_id == "group_id_value" + assert response.resolution_status == common.ResolutionStatus.OPEN + @pytest.mark.asyncio async def test_get_group_async_from_dict(): @@ -665,7 +675,9 @@ def test_update_group( with mock.patch.object(type(client.transport.update_group), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = common.ErrorGroup( - name="name_value", group_id="group_id_value", + name="name_value", + group_id="group_id_value", + resolution_status=common.ResolutionStatus.OPEN, ) response = client.update_group(request) @@ -684,6 +696,8 @@ def test_update_group( assert response.group_id == "group_id_value" + assert response.resolution_status == common.ResolutionStatus.OPEN + def test_update_group_from_dict(): test_update_group(request_type=dict) @@ -705,7 +719,11 @@ async def test_update_group_async( with mock.patch.object(type(client.transport.update_group), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - common.ErrorGroup(name="name_value", group_id="group_id_value",) + common.ErrorGroup( + name="name_value", + group_id="group_id_value", + resolution_status=common.ResolutionStatus.OPEN, + ) ) response = await client.update_group(request) @@ -723,6 +741,8 @@ async def test_update_group_async( assert response.group_id == "group_id_value" + assert response.resolution_status == common.ResolutionStatus.OPEN + @pytest.mark.asyncio async def test_update_group_async_from_dict(): diff --git a/tests/unit/gapic/errorreporting_v1beta1/test_report_errors_service.py b/tests/unit/gapic/errorreporting_v1beta1/test_report_errors_service.py index 4cbde17f..db9c05c9 100644 --- a/tests/unit/gapic/errorreporting_v1beta1/test_report_errors_service.py +++ b/tests/unit/gapic/errorreporting_v1beta1/test_report_errors_service.py @@ -30,6 +30,7 @@ from google.api_core import gapic_v1 from google.api_core import grpc_helpers from google.api_core import grpc_helpers_async +from google.appengine.logging.v1 import request_log_pb2 as request_log # type: ignore from google.auth import credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.errorreporting_v1beta1.services.report_errors_service import ( From c0be32ada9883fe2816ff103457e592d9977dd5f Mon Sep 17 00:00:00 2001 From: yoshi-automation Date: Sat, 6 Mar 2021 08:41:53 -0800 Subject: [PATCH 20/25] fix: Remove dependency on AppEngine's proto definitions. This also removes the source_references field. PiperOrigin-RevId: 356540804 Source-Author: Google APIs Source-Date: Tue Feb 9 10:53:59 2021 -0800 Source-Repo: googleapis/googleapis Source-Sha: 4f60776fe99f1fd8261b6a0493a5f5f4d7e8d969 Source-Link: https://github.com/googleapis/googleapis/commit/4f60776fe99f1fd8261b6a0493a5f5f4d7e8d969 --- google/cloud/errorreporting_v1beta1/__init__.py | 4 ++-- google/cloud/errorreporting_v1beta1/proto/common.proto | 5 ----- google/cloud/errorreporting_v1beta1/types/common.py | 9 --------- synth.metadata | 4 ++-- .../errorreporting_v1beta1/test_report_errors_service.py | 1 - 5 files changed, 4 insertions(+), 19 deletions(-) diff --git a/google/cloud/errorreporting_v1beta1/__init__.py b/google/cloud/errorreporting_v1beta1/__init__.py index ec7448cd..8ced2656 100644 --- a/google/cloud/errorreporting_v1beta1/__init__.py +++ b/google/cloud/errorreporting_v1beta1/__init__.py @@ -54,6 +54,7 @@ "ErrorGroupOrder", "ErrorGroupServiceClient", "ErrorGroupStats", + "ErrorStatsServiceClient", "GetGroupRequest", "HttpRequestContext", "ListEventsRequest", @@ -63,7 +64,6 @@ "QueryTimeRange", "ReportErrorEventRequest", "ReportErrorEventResponse", - "ReportErrorsServiceClient", "ReportedErrorEvent", "ResolutionStatus", "ServiceContext", @@ -73,5 +73,5 @@ "TimedCountAlignment", "TrackingIssue", "UpdateGroupRequest", - "ErrorStatsServiceClient", + "ReportErrorsServiceClient", ) diff --git a/google/cloud/errorreporting_v1beta1/proto/common.proto b/google/cloud/errorreporting_v1beta1/proto/common.proto index e8786461..e9bb321e 100644 --- a/google/cloud/errorreporting_v1beta1/proto/common.proto +++ b/google/cloud/errorreporting_v1beta1/proto/common.proto @@ -17,7 +17,6 @@ syntax = "proto3"; package google.devtools.clouderrorreporting.v1beta1; import "google/api/resource.proto"; -import "google/appengine/logging/v1/request_log.proto"; import "google/protobuf/timestamp.proto"; import "google/api/annotations.proto"; @@ -128,10 +127,6 @@ message ErrorContext { // exception is logged, usually close to the place where it was // caught. SourceLocation report_location = 3; - - // Source code that was used to build the executable which has - // caused the given error message. - repeated google.appengine.logging.v1.SourceReference source_references = 4; } // HTTP request data that is related to a reported error. diff --git a/google/cloud/errorreporting_v1beta1/types/common.py b/google/cloud/errorreporting_v1beta1/types/common.py index 58429a89..e0d1a7eb 100644 --- a/google/cloud/errorreporting_v1beta1/types/common.py +++ b/google/cloud/errorreporting_v1beta1/types/common.py @@ -18,7 +18,6 @@ import proto # type: ignore -from google.appengine.logging.v1 import request_log_pb2 as request_log # type: ignore from google.protobuf import timestamp_pb2 as timestamp # type: ignore @@ -184,10 +183,6 @@ class ErrorContext(proto.Message): exception this would be the source line where the exception is logged, usually close to the place where it was caught. - source_references (Sequence[google.appengine.logging.v1.request_log_pb2.SourceReference]): - Source code that was used to build the - executable which has caused the given error - message. """ http_request = proto.Field(proto.MESSAGE, number=1, message="HttpRequestContext",) @@ -196,10 +191,6 @@ class ErrorContext(proto.Message): report_location = proto.Field(proto.MESSAGE, number=3, message="SourceLocation",) - source_references = proto.RepeatedField( - proto.MESSAGE, number=4, message=request_log.SourceReference, - ) - class HttpRequestContext(proto.Message): r"""HTTP request data that is related to a reported error. diff --git a/synth.metadata b/synth.metadata index 9f98cc5c..860f2bfb 100644 --- a/synth.metadata +++ b/synth.metadata @@ -11,8 +11,8 @@ "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "c1e59709c1d28795fe9b70eb479579556056bfad", - "internalRef": "356330876" + "sha": "4f60776fe99f1fd8261b6a0493a5f5f4d7e8d969", + "internalRef": "356540804" } }, { diff --git a/tests/unit/gapic/errorreporting_v1beta1/test_report_errors_service.py b/tests/unit/gapic/errorreporting_v1beta1/test_report_errors_service.py index db9c05c9..4cbde17f 100644 --- a/tests/unit/gapic/errorreporting_v1beta1/test_report_errors_service.py +++ b/tests/unit/gapic/errorreporting_v1beta1/test_report_errors_service.py @@ -30,7 +30,6 @@ from google.api_core import gapic_v1 from google.api_core import grpc_helpers from google.api_core import grpc_helpers_async -from google.appengine.logging.v1 import request_log_pb2 as request_log # type: ignore from google.auth import credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.errorreporting_v1beta1.services.report_errors_service import ( From fbc7e640c9181d6098152045e366ac48a937cc6c Mon Sep 17 00:00:00 2001 From: yoshi-automation Date: Sat, 6 Mar 2021 08:42:32 -0800 Subject: [PATCH 21/25] docs: Update rules for currency_code in budget_amount. PiperOrigin-RevId: 357051517 Source-Author: Google APIs Source-Date: Thu Feb 11 13:54:03 2021 -0800 Source-Repo: googleapis/googleapis Source-Sha: f3a60f63c13fb434745ea59b990a82d6ffc803b5 Source-Link: https://github.com/googleapis/googleapis/commit/f3a60f63c13fb434745ea59b990a82d6ffc803b5 --- google/cloud/errorreporting_v1beta1/__init__.py | 4 ++-- synth.metadata | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/google/cloud/errorreporting_v1beta1/__init__.py b/google/cloud/errorreporting_v1beta1/__init__.py index 8ced2656..ec7448cd 100644 --- a/google/cloud/errorreporting_v1beta1/__init__.py +++ b/google/cloud/errorreporting_v1beta1/__init__.py @@ -54,7 +54,6 @@ "ErrorGroupOrder", "ErrorGroupServiceClient", "ErrorGroupStats", - "ErrorStatsServiceClient", "GetGroupRequest", "HttpRequestContext", "ListEventsRequest", @@ -64,6 +63,7 @@ "QueryTimeRange", "ReportErrorEventRequest", "ReportErrorEventResponse", + "ReportErrorsServiceClient", "ReportedErrorEvent", "ResolutionStatus", "ServiceContext", @@ -73,5 +73,5 @@ "TimedCountAlignment", "TrackingIssue", "UpdateGroupRequest", - "ReportErrorsServiceClient", + "ErrorStatsServiceClient", ) diff --git a/synth.metadata b/synth.metadata index 860f2bfb..12195a7d 100644 --- a/synth.metadata +++ b/synth.metadata @@ -11,8 +11,8 @@ "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "4f60776fe99f1fd8261b6a0493a5f5f4d7e8d969", - "internalRef": "356540804" + "sha": "f3a60f63c13fb434745ea59b990a82d6ffc803b5", + "internalRef": "357051517" } }, { From 9ee192a302febb9bba9a283c271746a694be6b98 Mon Sep 17 00:00:00 2001 From: yoshi-automation Date: Sat, 6 Mar 2021 08:48:41 -0800 Subject: [PATCH 22/25] feat: Update documentai/v1beta3 protos: add support for boolean normalized value PiperOrigin-RevId: 359109762 Source-Author: Google APIs Source-Date: Tue Feb 23 12:45:26 2021 -0800 Source-Repo: googleapis/googleapis Source-Sha: 8c058c505afc717966bc815075bdd11ff76618e5 Source-Link: https://github.com/googleapis/googleapis/commit/8c058c505afc717966bc815075bdd11ff76618e5 --- google/cloud/errorreporting_v1beta1/__init__.py | 4 ++-- synth.metadata | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/google/cloud/errorreporting_v1beta1/__init__.py b/google/cloud/errorreporting_v1beta1/__init__.py index ec7448cd..8ced2656 100644 --- a/google/cloud/errorreporting_v1beta1/__init__.py +++ b/google/cloud/errorreporting_v1beta1/__init__.py @@ -54,6 +54,7 @@ "ErrorGroupOrder", "ErrorGroupServiceClient", "ErrorGroupStats", + "ErrorStatsServiceClient", "GetGroupRequest", "HttpRequestContext", "ListEventsRequest", @@ -63,7 +64,6 @@ "QueryTimeRange", "ReportErrorEventRequest", "ReportErrorEventResponse", - "ReportErrorsServiceClient", "ReportedErrorEvent", "ResolutionStatus", "ServiceContext", @@ -73,5 +73,5 @@ "TimedCountAlignment", "TrackingIssue", "UpdateGroupRequest", - "ErrorStatsServiceClient", + "ReportErrorsServiceClient", ) diff --git a/synth.metadata b/synth.metadata index 12195a7d..5ad7c138 100644 --- a/synth.metadata +++ b/synth.metadata @@ -11,8 +11,8 @@ "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "f3a60f63c13fb434745ea59b990a82d6ffc803b5", - "internalRef": "357051517" + "sha": "8c058c505afc717966bc815075bdd11ff76618e5", + "internalRef": "359109762" } }, { From 669ba6d9493c6f05915021e0dbfd70e21a6b57dc Mon Sep 17 00:00:00 2001 From: yoshi-automation Date: Sat, 6 Mar 2021 08:49:10 -0800 Subject: [PATCH 23/25] chore: update gapic-generator-python to 0.40.11 PiperOrigin-RevId: 359562873 Source-Author: Google APIs Source-Date: Thu Feb 25 10:52:32 2021 -0800 Source-Repo: googleapis/googleapis Source-Sha: 07932bb995e7dc91b43620ea8402c6668c7d102c Source-Link: https://github.com/googleapis/googleapis/commit/07932bb995e7dc91b43620ea8402c6668c7d102c --- .../cloud/errorreporting_v1beta1/__init__.py | 4 +- .../error_group_service/async_client.py | 32 +++++++++- .../error_stats_service/async_client.py | 32 +++++++++- .../report_errors_service/async_client.py | 32 +++++++++- synth.metadata | 4 +- .../gapic/errorreporting_v1beta1/__init__.py | 15 +++++ .../test_error_group_service.py | 42 +++++++++++++- .../test_error_stats_service.py | 58 ++++++++++++++++++- .../test_report_errors_service.py | 28 ++++++++- 9 files changed, 231 insertions(+), 16 deletions(-) diff --git a/google/cloud/errorreporting_v1beta1/__init__.py b/google/cloud/errorreporting_v1beta1/__init__.py index 8ced2656..56f82962 100644 --- a/google/cloud/errorreporting_v1beta1/__init__.py +++ b/google/cloud/errorreporting_v1beta1/__init__.py @@ -52,7 +52,6 @@ "ErrorEvent", "ErrorGroup", "ErrorGroupOrder", - "ErrorGroupServiceClient", "ErrorGroupStats", "ErrorStatsServiceClient", "GetGroupRequest", @@ -64,6 +63,7 @@ "QueryTimeRange", "ReportErrorEventRequest", "ReportErrorEventResponse", + "ReportErrorsServiceClient", "ReportedErrorEvent", "ResolutionStatus", "ServiceContext", @@ -73,5 +73,5 @@ "TimedCountAlignment", "TrackingIssue", "UpdateGroupRequest", - "ReportErrorsServiceClient", + "ErrorGroupServiceClient", ) diff --git a/google/cloud/errorreporting_v1beta1/services/error_group_service/async_client.py b/google/cloud/errorreporting_v1beta1/services/error_group_service/async_client.py index 201522ba..e2af4bb2 100644 --- a/google/cloud/errorreporting_v1beta1/services/error_group_service/async_client.py +++ b/google/cloud/errorreporting_v1beta1/services/error_group_service/async_client.py @@ -78,8 +78,36 @@ class ErrorGroupServiceAsyncClient: ErrorGroupServiceClient.parse_common_location_path ) - from_service_account_info = ErrorGroupServiceClient.from_service_account_info - from_service_account_file = ErrorGroupServiceClient.from_service_account_file + @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: + ErrorGroupServiceAsyncClient: The constructed client. + """ + return ErrorGroupServiceClient.from_service_account_info.__func__(ErrorGroupServiceAsyncClient, 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: + ErrorGroupServiceAsyncClient: The constructed client. + """ + return ErrorGroupServiceClient.from_service_account_file.__func__(ErrorGroupServiceAsyncClient, filename, *args, **kwargs) # type: ignore + from_service_account_json = from_service_account_file @property diff --git a/google/cloud/errorreporting_v1beta1/services/error_stats_service/async_client.py b/google/cloud/errorreporting_v1beta1/services/error_stats_service/async_client.py index eca1d0d5..ca116141 100644 --- a/google/cloud/errorreporting_v1beta1/services/error_stats_service/async_client.py +++ b/google/cloud/errorreporting_v1beta1/services/error_stats_service/async_client.py @@ -81,8 +81,36 @@ class ErrorStatsServiceAsyncClient: ErrorStatsServiceClient.parse_common_location_path ) - from_service_account_info = ErrorStatsServiceClient.from_service_account_info - from_service_account_file = ErrorStatsServiceClient.from_service_account_file + @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: + ErrorStatsServiceAsyncClient: The constructed client. + """ + return ErrorStatsServiceClient.from_service_account_info.__func__(ErrorStatsServiceAsyncClient, 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: + ErrorStatsServiceAsyncClient: The constructed client. + """ + return ErrorStatsServiceClient.from_service_account_file.__func__(ErrorStatsServiceAsyncClient, filename, *args, **kwargs) # type: ignore + from_service_account_json = from_service_account_file @property diff --git a/google/cloud/errorreporting_v1beta1/services/report_errors_service/async_client.py b/google/cloud/errorreporting_v1beta1/services/report_errors_service/async_client.py index 723ee800..61f223b6 100644 --- a/google/cloud/errorreporting_v1beta1/services/report_errors_service/async_client.py +++ b/google/cloud/errorreporting_v1beta1/services/report_errors_service/async_client.py @@ -72,8 +72,36 @@ class ReportErrorsServiceAsyncClient: ReportErrorsServiceClient.parse_common_location_path ) - from_service_account_info = ReportErrorsServiceClient.from_service_account_info - from_service_account_file = ReportErrorsServiceClient.from_service_account_file + @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: + ReportErrorsServiceAsyncClient: The constructed client. + """ + return ReportErrorsServiceClient.from_service_account_info.__func__(ReportErrorsServiceAsyncClient, 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: + ReportErrorsServiceAsyncClient: The constructed client. + """ + return ReportErrorsServiceClient.from_service_account_file.__func__(ReportErrorsServiceAsyncClient, filename, *args, **kwargs) # type: ignore + from_service_account_json = from_service_account_file @property diff --git a/synth.metadata b/synth.metadata index 5ad7c138..4629ad36 100644 --- a/synth.metadata +++ b/synth.metadata @@ -11,8 +11,8 @@ "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "8c058c505afc717966bc815075bdd11ff76618e5", - "internalRef": "359109762" + "sha": "07932bb995e7dc91b43620ea8402c6668c7d102c", + "internalRef": "359562873" } }, { diff --git a/tests/unit/gapic/errorreporting_v1beta1/__init__.py b/tests/unit/gapic/errorreporting_v1beta1/__init__.py index 8b137891..42ffdf2b 100644 --- a/tests/unit/gapic/errorreporting_v1beta1/__init__.py +++ b/tests/unit/gapic/errorreporting_v1beta1/__init__.py @@ -1 +1,16 @@ +# -*- 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 +# +# 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/tests/unit/gapic/errorreporting_v1beta1/test_error_group_service.py b/tests/unit/gapic/errorreporting_v1beta1/test_error_group_service.py index 0b7c1973..814cefe8 100644 --- a/tests/unit/gapic/errorreporting_v1beta1/test_error_group_service.py +++ b/tests/unit/gapic/errorreporting_v1beta1/test_error_group_service.py @@ -89,15 +89,19 @@ def test__get_default_mtls_endpoint(): ) -def test_error_group_service_client_from_service_account_info(): +@pytest.mark.parametrize( + "client_class", [ErrorGroupServiceClient, ErrorGroupServiceAsyncClient,] +) +def test_error_group_service_client_from_service_account_info(client_class): creds = credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_info" ) as factory: factory.return_value = creds info = {"valid": True} - client = ErrorGroupServiceClient.from_service_account_info(info) + client = client_class.from_service_account_info(info) assert client.transport._credentials == creds + assert isinstance(client, client_class) assert client.transport._host == "clouderrorreporting.googleapis.com:443" @@ -113,9 +117,11 @@ def test_error_group_service_client_from_service_account_file(client_class): factory.return_value = creds client = client_class.from_service_account_file("dummy/file/path.json") assert client.transport._credentials == creds + assert isinstance(client, client_class) client = client_class.from_service_account_json("dummy/file/path.json") assert client.transport._credentials == creds + assert isinstance(client, client_class) assert client.transport._host == "clouderrorreporting.googleapis.com:443" @@ -494,6 +500,22 @@ def test_get_group_from_dict(): test_get_group(request_type=dict) +def test_get_group_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 = ErrorGroupServiceClient( + credentials=credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_group), "__call__") as call: + client.get_group() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == error_group_service.GetGroupRequest() + + @pytest.mark.asyncio async def test_get_group_async( transport: str = "grpc_asyncio", request_type=error_group_service.GetGroupRequest @@ -703,6 +725,22 @@ def test_update_group_from_dict(): test_update_group(request_type=dict) +def test_update_group_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 = ErrorGroupServiceClient( + credentials=credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.update_group), "__call__") as call: + client.update_group() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == error_group_service.UpdateGroupRequest() + + @pytest.mark.asyncio async def test_update_group_async( transport: str = "grpc_asyncio", request_type=error_group_service.UpdateGroupRequest diff --git a/tests/unit/gapic/errorreporting_v1beta1/test_error_stats_service.py b/tests/unit/gapic/errorreporting_v1beta1/test_error_stats_service.py index 97205ad6..1966becb 100644 --- a/tests/unit/gapic/errorreporting_v1beta1/test_error_stats_service.py +++ b/tests/unit/gapic/errorreporting_v1beta1/test_error_stats_service.py @@ -92,15 +92,19 @@ def test__get_default_mtls_endpoint(): ) -def test_error_stats_service_client_from_service_account_info(): +@pytest.mark.parametrize( + "client_class", [ErrorStatsServiceClient, ErrorStatsServiceAsyncClient,] +) +def test_error_stats_service_client_from_service_account_info(client_class): creds = credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_info" ) as factory: factory.return_value = creds info = {"valid": True} - client = ErrorStatsServiceClient.from_service_account_info(info) + client = client_class.from_service_account_info(info) assert client.transport._credentials == creds + assert isinstance(client, client_class) assert client.transport._host == "clouderrorreporting.googleapis.com:443" @@ -116,9 +120,11 @@ def test_error_stats_service_client_from_service_account_file(client_class): factory.return_value = creds client = client_class.from_service_account_file("dummy/file/path.json") assert client.transport._credentials == creds + assert isinstance(client, client_class) client = client_class.from_service_account_json("dummy/file/path.json") assert client.transport._credentials == creds + assert isinstance(client, client_class) assert client.transport._host == "clouderrorreporting.googleapis.com:443" @@ -491,6 +497,22 @@ def test_list_group_stats_from_dict(): test_list_group_stats(request_type=dict) +def test_list_group_stats_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 = ErrorStatsServiceClient( + credentials=credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_group_stats), "__call__") as call: + client.list_group_stats() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == error_stats_service.ListGroupStatsRequest() + + @pytest.mark.asyncio async def test_list_group_stats_async( transport: str = "grpc_asyncio", @@ -887,6 +909,22 @@ def test_list_events_from_dict(): test_list_events(request_type=dict) +def test_list_events_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 = ErrorStatsServiceClient( + credentials=credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_events), "__call__") as call: + client.list_events() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == error_stats_service.ListEventsRequest() + + @pytest.mark.asyncio async def test_list_events_async( transport: str = "grpc_asyncio", request_type=error_stats_service.ListEventsRequest @@ -1246,6 +1284,22 @@ def test_delete_events_from_dict(): test_delete_events(request_type=dict) +def test_delete_events_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 = ErrorStatsServiceClient( + credentials=credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.delete_events), "__call__") as call: + client.delete_events() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == error_stats_service.DeleteEventsRequest() + + @pytest.mark.asyncio async def test_delete_events_async( transport: str = "grpc_asyncio", diff --git a/tests/unit/gapic/errorreporting_v1beta1/test_report_errors_service.py b/tests/unit/gapic/errorreporting_v1beta1/test_report_errors_service.py index 4cbde17f..98a83947 100644 --- a/tests/unit/gapic/errorreporting_v1beta1/test_report_errors_service.py +++ b/tests/unit/gapic/errorreporting_v1beta1/test_report_errors_service.py @@ -92,15 +92,19 @@ def test__get_default_mtls_endpoint(): ) -def test_report_errors_service_client_from_service_account_info(): +@pytest.mark.parametrize( + "client_class", [ReportErrorsServiceClient, ReportErrorsServiceAsyncClient,] +) +def test_report_errors_service_client_from_service_account_info(client_class): creds = credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_info" ) as factory: factory.return_value = creds info = {"valid": True} - client = ReportErrorsServiceClient.from_service_account_info(info) + client = client_class.from_service_account_info(info) assert client.transport._credentials == creds + assert isinstance(client, client_class) assert client.transport._host == "clouderrorreporting.googleapis.com:443" @@ -116,9 +120,11 @@ def test_report_errors_service_client_from_service_account_file(client_class): factory.return_value = creds client = client_class.from_service_account_file("dummy/file/path.json") assert client.transport._credentials == creds + assert isinstance(client, client_class) client = client_class.from_service_account_json("dummy/file/path.json") assert client.transport._credentials == creds + assert isinstance(client, client_class) assert client.transport._host == "clouderrorreporting.googleapis.com:443" @@ -501,6 +507,24 @@ def test_report_error_event_from_dict(): test_report_error_event(request_type=dict) +def test_report_error_event_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 = ReportErrorsServiceClient( + credentials=credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.report_error_event), "__call__" + ) as call: + client.report_error_event() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == report_errors_service.ReportErrorEventRequest() + + @pytest.mark.asyncio async def test_report_error_event_async( transport: str = "grpc_asyncio", From 6e35db2c33d70fa94db642ed3510a259ccdba548 Mon Sep 17 00:00:00 2001 From: yoshi-automation Date: Sat, 6 Mar 2021 08:50:01 -0800 Subject: [PATCH 24/25] chore: clean up unused gapic.legacy.yaml files Committer: @miraleung PiperOrigin-RevId: 359580699 Source-Author: Google APIs Source-Date: Thu Feb 25 12:03:52 2021 -0800 Source-Repo: googleapis/googleapis Source-Sha: d9b32e92fa57c37e5af0dc03badfe741170c5849 Source-Link: https://github.com/googleapis/googleapis/commit/d9b32e92fa57c37e5af0dc03badfe741170c5849 --- google/cloud/errorreporting_v1beta1/__init__.py | 4 ++-- synth.metadata | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/google/cloud/errorreporting_v1beta1/__init__.py b/google/cloud/errorreporting_v1beta1/__init__.py index 56f82962..ec7448cd 100644 --- a/google/cloud/errorreporting_v1beta1/__init__.py +++ b/google/cloud/errorreporting_v1beta1/__init__.py @@ -52,8 +52,8 @@ "ErrorEvent", "ErrorGroup", "ErrorGroupOrder", + "ErrorGroupServiceClient", "ErrorGroupStats", - "ErrorStatsServiceClient", "GetGroupRequest", "HttpRequestContext", "ListEventsRequest", @@ -73,5 +73,5 @@ "TimedCountAlignment", "TrackingIssue", "UpdateGroupRequest", - "ErrorGroupServiceClient", + "ErrorStatsServiceClient", ) diff --git a/synth.metadata b/synth.metadata index 4629ad36..ac53b1a4 100644 --- a/synth.metadata +++ b/synth.metadata @@ -11,8 +11,8 @@ "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "07932bb995e7dc91b43620ea8402c6668c7d102c", - "internalRef": "359562873" + "sha": "d9b32e92fa57c37e5af0dc03badfe741170c5849", + "internalRef": "359580699" } }, { From 1c71d7ed164fc336bd87b6a4ee392a183c1e90dc Mon Sep 17 00:00:00 2001 From: yoshi-automation Date: Sat, 6 Mar 2021 08:50:28 -0800 Subject: [PATCH 25/25] chore: update protobuf v3.15.3 This release makes --experimental_allow_proto3_optional no longer necessary. PiperOrigin-RevId: 359781040 Source-Author: Google APIs Source-Date: Fri Feb 26 09:59:49 2021 -0800 Source-Repo: googleapis/googleapis Source-Sha: f6dd7e47620566925a4b3f1ce029e74e1b2f2516 Source-Link: https://github.com/googleapis/googleapis/commit/f6dd7e47620566925a4b3f1ce029e74e1b2f2516 --- google/cloud/errorreporting_v1beta1/__init__.py | 4 ++-- synth.metadata | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/google/cloud/errorreporting_v1beta1/__init__.py b/google/cloud/errorreporting_v1beta1/__init__.py index ec7448cd..8ced2656 100644 --- a/google/cloud/errorreporting_v1beta1/__init__.py +++ b/google/cloud/errorreporting_v1beta1/__init__.py @@ -54,6 +54,7 @@ "ErrorGroupOrder", "ErrorGroupServiceClient", "ErrorGroupStats", + "ErrorStatsServiceClient", "GetGroupRequest", "HttpRequestContext", "ListEventsRequest", @@ -63,7 +64,6 @@ "QueryTimeRange", "ReportErrorEventRequest", "ReportErrorEventResponse", - "ReportErrorsServiceClient", "ReportedErrorEvent", "ResolutionStatus", "ServiceContext", @@ -73,5 +73,5 @@ "TimedCountAlignment", "TrackingIssue", "UpdateGroupRequest", - "ErrorStatsServiceClient", + "ReportErrorsServiceClient", ) diff --git a/synth.metadata b/synth.metadata index ac53b1a4..30b8c428 100644 --- a/synth.metadata +++ b/synth.metadata @@ -11,8 +11,8 @@ "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "d9b32e92fa57c37e5af0dc03badfe741170c5849", - "internalRef": "359580699" + "sha": "f6dd7e47620566925a4b3f1ce029e74e1b2f2516", + "internalRef": "359781040" } }, {