Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: migrate to use microgen #23

Merged
merged 3 commits into from Aug 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 6 additions & 7 deletions .coveragerc
Expand Up @@ -21,15 +21,14 @@ branch = True
[report]
fail_under = 100
show_missing = True
omit = google/cloud/errorreporting/__init__.py, .nox/*
exclude_lines =
# Re-enable the standard pragma
pragma: NO COVER
# Ignore debug-only repr
def __repr__
# Ignore abstract methods
raise NotImplementedError
omit =
*/gapic/*.py
*/proto/*.py
*/core/*.py
*/site-packages/*.py
# Ignore pkg_resources exceptions.
# 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
6 changes: 4 additions & 2 deletions README.rst
Expand Up @@ -54,11 +54,13 @@ dependencies.

Supported Python Versions
^^^^^^^^^^^^^^^^^^^^^^^^^
Python >= 3.5
Python >= 3.6

Deprecated Python Versions
^^^^^^^^^^^^^^^^^^^^^^^^^^
Python == 2.7. Python 2.7 support will be removed on January 1, 2020.
Python == 2.7.

The last version of this library compatible with Python 2.7 is google-cloud-error-reporting==0.34.0.


Mac/Linux
Expand Down
12 changes: 12 additions & 0 deletions docs/errorreporting_v1beta1/services.rst
@@ -0,0 +1,12 @@
Services for Google Cloud Errorreporting v1beta1 API
====================================================

.. 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:
5 changes: 5 additions & 0 deletions docs/errorreporting_v1beta1/types.rst
@@ -0,0 +1,5 @@
Types for Google Cloud Errorreporting v1beta1 API
=================================================

.. automodule:: google.cloud.errorreporting_v1beta1.types
:members:
6 changes: 0 additions & 6 deletions docs/gapic/v1beta1/api.rst

This file was deleted.

5 changes: 0 additions & 5 deletions docs/gapic/v1beta1/types.rst

This file was deleted.

4 changes: 2 additions & 2 deletions docs/index.rst
Expand Up @@ -19,8 +19,8 @@ API Reference

client
util
gapic/v1beta1/api
gapic/v1beta1/types
errorreporting_v1beta1/services
errorreporting_v1beta1/types


Changelog
Expand Down
25 changes: 16 additions & 9 deletions google/cloud/error_reporting/_gapic.py
Expand Up @@ -13,10 +13,9 @@
# limitations under the License.

"""GAX wrapper for Error Reporting API requests."""
import json

from google.cloud.errorreporting_v1beta1.gapic import report_errors_service_client
from google.cloud.errorreporting_v1beta1.proto import report_errors_service_pb2
from google.protobuf.json_format import ParseDict
import google.cloud.errorreporting_v1beta1


def make_report_error_api(client):
Expand All @@ -28,7 +27,7 @@ def make_report_error_api(client):
:rtype: :class:_ErrorReportingGapicApi
:returns: An Error Reporting API instance.
"""
gapic_api = report_errors_service_client.ReportErrorsServiceClient(
gapic_api = google.cloud.errorreporting_v1beta1.ReportErrorsServiceClient(
credentials=client._credentials,
client_info=client._client_info,
client_options=client._client_options,
Expand All @@ -40,7 +39,7 @@ class _ErrorReportingGapicApi(object):
"""Helper mapping Error Reporting-related APIs

:type gapic:
:class:`report_errors_service_client.ReportErrorsServiceClient`
:class:`google.cloud.errorreporting_v1beta1.ReportErrorsServiceClient`
:param gapic: API object used to make RPCs.

:type project: str
Expand All @@ -62,7 +61,15 @@ def report_error_event(self, error_report):
Use
:meth:~`google.cloud.error_reporting.client._build_error_report`
"""
project_name = self._gapic_api.project_path(self._project)
error_report_payload = report_errors_service_pb2.ReportedErrorEvent()
ParseDict(error_report, error_report_payload)
self._gapic_api.report_error_event(project_name, error_report_payload)
project_name = f"projects/{self._project}"

# Since error_report uses camel case for key names (like serviceContext),
# but ReportedErrorEvent uses snake case for key names (like service_context),
# we need to route throught json.
error_report_payload = google.cloud.errorreporting_v1beta1.ReportedErrorEvent.from_json(
arithmetic1728 marked this conversation as resolved.
Show resolved Hide resolved
json.dumps(error_report)
)

self._gapic_api.report_error_event(
project_name=project_name, event=error_report_payload
)
82 changes: 56 additions & 26 deletions google/cloud/errorreporting_v1beta1/__init__.py
@@ -1,45 +1,75 @@
# Copyright 2018 Google LLC
# -*- 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
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

from __future__ import absolute_import

from google.cloud.errorreporting_v1beta1 import types
from google.cloud.errorreporting_v1beta1.gapic import enums
from google.cloud.errorreporting_v1beta1.gapic import error_group_service_client
from google.cloud.errorreporting_v1beta1.gapic import error_stats_service_client
from google.cloud.errorreporting_v1beta1.gapic import report_errors_service_client


class ErrorGroupServiceClient(error_group_service_client.ErrorGroupServiceClient):
__doc__ = error_group_service_client.ErrorGroupServiceClient.__doc__
enums = enums


class ErrorStatsServiceClient(error_stats_service_client.ErrorStatsServiceClient):
__doc__ = error_stats_service_client.ErrorStatsServiceClient.__doc__
enums = enums


class ReportErrorsServiceClient(report_errors_service_client.ReportErrorsServiceClient):
__doc__ = report_errors_service_client.ReportErrorsServiceClient.__doc__
enums = enums
from .services.error_group_service import ErrorGroupServiceClient
from .services.error_stats_service import ErrorStatsServiceClient
from .services.report_errors_service import ReportErrorsServiceClient
from .types.common import ErrorContext
from .types.common import ErrorEvent
from .types.common import ErrorGroup
from .types.common import HttpRequestContext
from .types.common import ServiceContext
from .types.common import SourceLocation
from .types.common import TrackingIssue
from .types.error_group_service import GetGroupRequest
from .types.error_group_service import UpdateGroupRequest
from .types.error_stats_service import DeleteEventsRequest
from .types.error_stats_service import DeleteEventsResponse
from .types.error_stats_service import ErrorGroupOrder
from .types.error_stats_service import ErrorGroupStats
from .types.error_stats_service import ListEventsRequest
from .types.error_stats_service import ListEventsResponse
from .types.error_stats_service import ListGroupStatsRequest
from .types.error_stats_service import ListGroupStatsResponse
from .types.error_stats_service import QueryTimeRange
from .types.error_stats_service import ServiceContextFilter
from .types.error_stats_service import TimedCount
from .types.error_stats_service import TimedCountAlignment
from .types.report_errors_service import ReportErrorEventRequest
from .types.report_errors_service import ReportErrorEventResponse
from .types.report_errors_service import ReportedErrorEvent


__all__ = (
"enums",
"types",
"DeleteEventsRequest",
"DeleteEventsResponse",
"ErrorContext",
"ErrorEvent",
"ErrorGroup",
"ErrorGroupOrder",
"ErrorGroupServiceClient",
"ErrorGroupStats",
"ErrorStatsServiceClient",
"GetGroupRequest",
"HttpRequestContext",
"ListEventsRequest",
"ListEventsResponse",
"ListGroupStatsRequest",
"ListGroupStatsResponse",
"QueryTimeRange",
"ReportErrorEventRequest",
"ReportErrorEventResponse",
"ReportedErrorEvent",
"ServiceContext",
"ServiceContextFilter",
"SourceLocation",
"TimedCount",
"TimedCountAlignment",
"TrackingIssue",
"UpdateGroupRequest",
"ReportErrorsServiceClient",
)
Empty file.
89 changes: 0 additions & 89 deletions google/cloud/errorreporting_v1beta1/gapic/enums.py

This file was deleted.