Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 1 addition & 60 deletions dynatrace/environment_v2/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,65 +141,6 @@ class Transformation(Enum):
SETUNIT = "setUnit"


class Unit(Enum):
BIT = "Bit"
BITPERHOUR = "BitPerHour"
BITPERMINUTE = "BitPerMinute"
BITPERSECOND = "BitPerSecond"
BYTE = "Byte"
BYTEPERHOUR = "BytePerHour"
BYTEPERMINUTE = "BytePerMinute"
BYTEPERSECOND = "BytePerSecond"
CORES = "Cores"
COUNT = "Count"
DAY = "Day"
DECIBELMILLIWATT = "DecibelMilliWatt"
GIBIBYTE = "GibiByte"
GIGA = "Giga"
GIGABYTE = "GigaByte"
HOUR = "Hour"
KIBIBYTE = "KibiByte"
KIBIBYTEPERHOUR = "KibiBytePerHour"
KIBIBYTEPERMINUTE = "KibiBytePerMinute"
KIBIBYTEPERSECOND = "KibiBytePerSecond"
KILO = "Kilo"
KILOBYTE = "KiloByte"
KILOBYTEPERHOUR = "KiloBytePerHour"
KILOBYTEPERMINUTE = "KiloBytePerMinute"
KILOBYTEPERSECOND = "KiloBytePerSecond"
MSU = "MSU"
MEBIBYTE = "MebiByte"
MEBIBYTEPERHOUR = "MebiBytePerHour"
MEBIBYTEPERMINUTE = "MebiBytePerMinute"
MEBIBYTEPERSECOND = "MebiBytePerSecond"
MEGA = "Mega"
MEGABYTE = "MegaByte"
MEGABYTEPERHOUR = "MegaBytePerHour"
MEGABYTEPERMINUTE = "MegaBytePerMinute"
MEGABYTEPERSECOND = "MegaBytePerSecond"
MICROSECOND = "MicroSecond"
MILLICORES = "MilliCores"
MILLISECOND = "MilliSecond"
MILLISECONDPERMINUTE = "MilliSecondPerMinute"
MINUTE = "Minute"
MONTH = "Month"
NANOSECOND = "NanoSecond"
NANOSECONDPERMINUTE = "NanoSecondPerMinute"
NOTAPPLICABLE = "NotApplicable"
PERHOUR = "PerHour"
PERMINUTE = "PerMinute"
PERSECOND = "PerSecond"
PERCENT = "Percent"
PIXEL = "Pixel"
PROMILLE = "Promille"
RATIO = "Ratio"
SECOND = "Second"
STATE = "State"
UNSPECIFIED = "Unspecified"
WEEK = "Week"
YEAR = "Year"


class MetricDescriptor(DynatraceObject):
def _create_from_raw_data(self, raw_element):

Expand Down Expand Up @@ -227,7 +168,7 @@ def _create_from_raw_data(self, raw_element):
self.root_cause_relevant: Optional[bool] = raw_element.get("rootCauseRelevant")
self.tags: Optional[List[str]] = raw_element.get("tags")
self.transformations: Optional[List[Transformation]] = [Transformation(element) for element in raw_element.get("transformations", [])]
self.unit: Optional[Unit] = Unit(raw_element.get("unit")) if raw_element.get("unit") else None
self.unit: Optional[str] = raw_element.get("unit")
self.warnings: Optional[List[str]] = raw_element.get("warnings")


Expand Down
5 changes: 2 additions & 3 deletions dynatrace/environment_v2/problems.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
from dynatrace.http_client import HttpClient
from dynatrace.dynatrace_object import DynatraceObject
from dynatrace.environment_v2.schemas import ManagementZone
from dynatrace.environment_v2.metrics import Unit
from dynatrace.environment_v2.monitored_entities import EntityStub
from dynatrace.environment_v2.custom_tags import METag
from dynatrace.configuration_v1.alerting_profiles import AlertingProfileStub
Expand Down Expand Up @@ -228,7 +227,7 @@ def _create_from_raw_data(self, raw_element: Dict[str, Any]):
self.value_before_change_point: Optional[float] = raw_element.get("valueBeforeChangePoint")
self.value_after_change_point: Optional[float] = raw_element.get("valueAfterChangePoint")
self.end_time: Optional[datetime] = int64_to_datetime(raw_element.get("endTime"))
self.unit: Optional[Unit] = Unit(raw_element.get("unit"))
self.unit: Optional[str] = raw_element.get("unit")


class MetricEvidence(Evidence):
Expand All @@ -237,7 +236,7 @@ def _create_from_raw_data(self, raw_element: Dict[str, Any]):
self.value_before_change_point: Optional[float] = raw_element.get("valueBeforeChangePoint")
self.value_after_change_point: Optional[float] = raw_element.get("valueAfterChangePoint")
self.end_time: Optional[datetime] = int64_to_datetime(raw_element.get("endTime"))
self.unit: Optional[Unit] = Unit(raw_element.get("unit"))
self.unit: Optional[str] = raw_element.get("unit")
self.metric_id: Optional[str] = raw_element.get("metricId")


Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "dt"
version = "1.1.73"
version = "1.2.0"
description = "Dynatrace API Python client"
readme = "README.md"
authors = ["David Lopes <davidribeirolopes@gmail.com>"]
Expand Down
10 changes: 5 additions & 5 deletions test/environment_v2/test_metrics.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from dynatrace import Dynatrace
import pytest

from dynatrace.environment_v2.metrics import MetricDescriptor, Unit, AggregationType, Transformation, ValueType, MetricSeriesCollection
from dynatrace.environment_v2.metrics import MetricDescriptor, AggregationType, Transformation, ValueType, MetricSeriesCollection
from dynatrace.pagination import PaginatedList
from dynatrace.utils import int64_to_datetime

Expand All @@ -14,7 +14,7 @@ def test_list(dt: Dynatrace):
assert metric.metric_id == "builtin:apps.other.apdex.osAndGeo"
assert metric.display_name == "Apdex (by OS, geolocation) [mobile, custom]"
assert metric.description == ""
assert metric.unit == Unit.NOTAPPLICABLE
assert metric.unit == "NotApplicable"
break


Expand All @@ -29,7 +29,7 @@ def test_list_fields(dt: Dynatrace):
assert metric.metric_id == "builtin:apps.other.apdex.osAndGeo"
assert metric.display_name == "Apdex (by OS, geolocation) [mobile, custom]"
assert metric.description == ""
assert metric.unit == Unit.NOTAPPLICABLE
assert metric.unit == "NotApplicable"
assert not metric.ddu_billable
assert metric.created is None
assert metric.last_written == int64_to_datetime(1620514220905)
Expand Down Expand Up @@ -60,7 +60,7 @@ def test_list_params(dt: Dynatrace):
assert metric.metric_id == "builtin:host.cpu.idle"
assert metric.display_name == "CPU idle"
assert metric.description == ""
assert metric.unit == Unit.PERCENT
assert metric.unit == "Percent"
assert not metric.ddu_billable
assert metric.last_written == int64_to_datetime(1621030025348)
assert metric.entity_type == ["HOST"]
Expand All @@ -77,7 +77,7 @@ def test_get(dt: Dynatrace):
assert metric.metric_id == "builtin:host.cpu.idle"
assert metric.display_name == "CPU idle"
assert metric.description == ""
assert metric.unit == Unit.PERCENT
assert metric.unit == "Percent"
assert not metric.ddu_billable
assert metric.last_written == int64_to_datetime(1621030565348)
assert metric.entity_type == ["HOST"]
Expand Down
Loading