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

fix: Reintroduce deprecated field/enum ServiceTier for backward compatibility #240

Merged
merged 2 commits into from Oct 13, 2021
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
2 changes: 2 additions & 0 deletions google/cloud/monitoring/__init__.py
Expand Up @@ -64,6 +64,7 @@
from google.cloud.monitoring_v3.types.common import TimeInterval
from google.cloud.monitoring_v3.types.common import TypedValue
from google.cloud.monitoring_v3.types.common import ComparisonType
from google.cloud.monitoring_v3.types.common import ServiceTier
from google.cloud.monitoring_v3.types.dropped_labels import DroppedLabels
from google.cloud.monitoring_v3.types.group import Group
from google.cloud.monitoring_v3.types.group_service import CreateGroupRequest
Expand Down Expand Up @@ -235,6 +236,7 @@
"TimeInterval",
"TypedValue",
"ComparisonType",
"ServiceTier",
"DroppedLabels",
"Group",
"CreateGroupRequest",
Expand Down
2 changes: 2 additions & 0 deletions google/cloud/monitoring_v3/__init__.py
Expand Up @@ -40,6 +40,7 @@
from .types.common import TimeInterval
from .types.common import TypedValue
from .types.common import ComparisonType
from .types.common import ServiceTier
from .types.dropped_labels import DroppedLabels
from .types.group import Group
from .types.group_service import CreateGroupRequest
Expand Down Expand Up @@ -215,6 +216,7 @@
"ServiceLevelIndicator",
"ServiceLevelObjective",
"ServiceMonitoringServiceClient",
"ServiceTier",
"SpanContext",
"TextLocator",
"TimeInterval",
Expand Down
Expand Up @@ -29,6 +29,7 @@
from google.api import label_pb2 # type: ignore
from google.api import launch_stage_pb2 # type: ignore
from google.cloud.monitoring_v3.services.notification_channel_service import pagers
from google.cloud.monitoring_v3.types import common
from google.cloud.monitoring_v3.types import mutation_record
from google.cloud.monitoring_v3.types import notification
from google.cloud.monitoring_v3.types import notification_service
Expand Down
Expand Up @@ -33,6 +33,7 @@
from google.api import label_pb2 # type: ignore
from google.api import launch_stage_pb2 # type: ignore
from google.cloud.monitoring_v3.services.notification_channel_service import pagers
from google.cloud.monitoring_v3.types import common
from google.cloud.monitoring_v3.types import mutation_record
from google.cloud.monitoring_v3.types import notification
from google.cloud.monitoring_v3.types import notification_service
Expand Down
2 changes: 2 additions & 0 deletions google/cloud/monitoring_v3/types/__init__.py
Expand Up @@ -27,6 +27,7 @@
TimeInterval,
TypedValue,
ComparisonType,
ServiceTier,
)
from .dropped_labels import DroppedLabels
from .group import Group
Expand Down Expand Up @@ -143,6 +144,7 @@
"TimeInterval",
"TypedValue",
"ComparisonType",
"ServiceTier",
"DroppedLabels",
"Group",
"CreateGroupRequest",
Expand Down
6 changes: 3 additions & 3 deletions google/cloud/monitoring_v3/types/alert.py
Expand Up @@ -404,8 +404,8 @@ class LogMatch(proto.Message):
Attributes:
filter (str):
Required. A logs-based filter. See `Advanced Logs
Queries </logging/docs/view/advanced-queries>`__ for how
this filter should be constructed.
Queries <https://cloud.google.com/logging/docs/view/advanced-queries>`__
for how this filter should be constructed.
label_extractors (Sequence[google.cloud.monitoring_v3.types.AlertPolicy.Condition.LogMatch.LabelExtractorsEntry]):
Optional. A map from a label key to an extractor expression,
which is used to extract the value for this label key. Each
Expand All @@ -417,7 +417,7 @@ class LogMatch(proto.Message):
generated by this condition.

Please see `the documentation on logs-based metric
``valueExtractor``\ s </logging/docs/reference/v2/rest/v2/projects.metrics#LogMetric.FIELDS.value_extractor>`__
``valueExtractor``\ s <https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.metrics#LogMetric.FIELDS.value_extractor>`__
for syntax and examples.
"""

Expand Down
19 changes: 18 additions & 1 deletion google/cloud/monitoring_v3/types/common.py
Expand Up @@ -22,7 +22,13 @@

__protobuf__ = proto.module(
package="google.monitoring.v3",
manifest={"ComparisonType", "TypedValue", "TimeInterval", "Aggregation",},
manifest={
"ComparisonType",
"ServiceTier",
"TypedValue",
"TimeInterval",
"Aggregation",
},
)


Expand All @@ -39,6 +45,17 @@ class ComparisonType(proto.Enum):
COMPARISON_NE = 6


class ServiceTier(proto.Enum):
r"""The tier of service for a Workspace. Please see the `service tiers
documentation <https://cloud.google.com/monitoring/workspaces/tiers>`__
for more details.
"""
_pb_options = {"deprecated": True}
SERVICE_TIER_UNSPECIFIED = 0
SERVICE_TIER_BASIC = 1
SERVICE_TIER_PREMIUM = 2


class TypedValue(proto.Message):
r"""A single strongly-typed value.

Expand Down
7 changes: 7 additions & 0 deletions google/cloud/monitoring_v3/types/notification.py
Expand Up @@ -17,6 +17,7 @@

from google.api import label_pb2 # type: ignore
from google.api import launch_stage_pb2 # type: ignore
from google.cloud.monitoring_v3.types import common
from google.cloud.monitoring_v3.types import mutation_record
from google.protobuf import wrappers_pb2 # type: ignore

Expand Down Expand Up @@ -63,6 +64,9 @@ class NotificationChannelDescriptor(proto.Message):
corresponding type. Each label includes a
description for how that field should be
populated.
supported_tiers (Sequence[google.cloud.monitoring_v3.types.ServiceTier]):
The tiers that support this notification channel; the
project service tier must be one of the supported_tiers.
launch_stage (google.api.launch_stage_pb2.LaunchStage):
The product launch stage for channels of this
type.
Expand All @@ -75,6 +79,9 @@ class NotificationChannelDescriptor(proto.Message):
labels = proto.RepeatedField(
proto.MESSAGE, number=4, message=label_pb2.LabelDescriptor,
)
supported_tiers = proto.RepeatedField(
proto.ENUM, number=5, enum=common.ServiceTier,
)
launch_stage = proto.Field(proto.ENUM, number=7, enum=launch_stage_pb2.LaunchStage,)


Expand Down
Expand Up @@ -45,6 +45,7 @@
from google.cloud.monitoring_v3.services.notification_channel_service.transports.base import (
_GOOGLE_AUTH_VERSION,
)
from google.cloud.monitoring_v3.types import common
from google.cloud.monitoring_v3.types import mutation_record
from google.cloud.monitoring_v3.types import notification
from google.cloud.monitoring_v3.types import notification_service
Expand Down Expand Up @@ -987,6 +988,7 @@ def test_get_notification_channel_descriptor(
type_="type__value",
display_name="display_name_value",
description="description_value",
supported_tiers=[common.ServiceTier.SERVICE_TIER_BASIC],
)
response = client.get_notification_channel_descriptor(request)

Expand All @@ -1001,6 +1003,7 @@ def test_get_notification_channel_descriptor(
assert response.type_ == "type__value"
assert response.display_name == "display_name_value"
assert response.description == "description_value"
assert response.supported_tiers == [common.ServiceTier.SERVICE_TIER_BASIC]


def test_get_notification_channel_descriptor_from_dict():
Expand Down Expand Up @@ -1048,6 +1051,7 @@ async def test_get_notification_channel_descriptor_async(
type_="type__value",
display_name="display_name_value",
description="description_value",
supported_tiers=[common.ServiceTier.SERVICE_TIER_BASIC],
)
)
response = await client.get_notification_channel_descriptor(request)
Expand All @@ -1063,6 +1067,7 @@ async def test_get_notification_channel_descriptor_async(
assert response.type_ == "type__value"
assert response.display_name == "display_name_value"
assert response.description == "description_value"
assert response.supported_tiers == [common.ServiceTier.SERVICE_TIER_BASIC]


@pytest.mark.asyncio
Expand Down