Skip to content

Commit b3e4a3c

Browse files
authored
feat(cockpit): add cockpit metrics (#120)
1 parent fd150fa commit b3e4a3c

File tree

8 files changed

+198
-0
lines changed

8 files changed

+198
-0
lines changed

scaleway-async/scaleway_async/cockpit/v1beta1/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from .types import ListTokensRequestOrderBy
77
from .types import Cockpit
88
from .types import CockpitEndpoints
9+
from .types import CockpitMetrics
910
from .types import ContactPoint
1011
from .types import ContactPointEmail
1112
from .types import GrafanaUser
@@ -24,6 +25,7 @@
2425
"ListTokensRequestOrderBy",
2526
"Cockpit",
2627
"CockpitEndpoints",
28+
"CockpitMetrics",
2729
"ContactPoint",
2830
"ContactPointEmail",
2931
"GrafanaUser",

scaleway-async/scaleway_async/cockpit/v1beta1/api.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# This file was automatically generated. DO NOT EDIT.
22
# If you have any remark or suggestion do not hesitate to open an issue.
33

4+
from datetime import datetime
45
from typing import Awaitable, List, Optional, Union
56

67
from scaleway_core.api import API
@@ -16,6 +17,7 @@
1617
ListGrafanaUsersRequestOrderBy,
1718
ListTokensRequestOrderBy,
1819
Cockpit,
20+
CockpitMetrics,
1921
ContactPoint,
2022
GrafanaUser,
2123
ListContactPointsResponse,
@@ -56,6 +58,7 @@
5658
unmarshal_GrafanaUser,
5759
unmarshal_Token,
5860
unmarshal_Cockpit,
61+
unmarshal_CockpitMetrics,
5962
unmarshal_ListContactPointsResponse,
6063
unmarshal_ListGrafanaUsersResponse,
6164
unmarshal_ListTokensResponse,
@@ -161,6 +164,43 @@ async def wait_for_cockpit(
161164
},
162165
)
163166

167+
async def get_cockpit_metrics(
168+
self,
169+
*,
170+
project_id: Optional[str] = None,
171+
start_date: Optional[datetime] = None,
172+
end_date: Optional[datetime] = None,
173+
metric_name: Optional[str] = None,
174+
) -> CockpitMetrics:
175+
"""
176+
Get cockpit metrics.
177+
Get the cockpit metrics with the given project ID.
178+
:param project_id: Project ID.
179+
:param start_date: Start date.
180+
:param end_date: End date.
181+
:param metric_name: Metric name.
182+
:return: :class:`CockpitMetrics <CockpitMetrics>`
183+
184+
Usage:
185+
::
186+
187+
result = await api.get_cockpit_metrics()
188+
"""
189+
190+
res = self._request(
191+
"GET",
192+
f"/cockpit/v1beta1/cockpit/metrics",
193+
params={
194+
"end_date": end_date,
195+
"metric_name": metric_name,
196+
"project_id": project_id or self.client.default_project_id,
197+
"start_date": start_date,
198+
},
199+
)
200+
201+
self._throw_on_error(res)
202+
return unmarshal_CockpitMetrics(res.json())
203+
164204
async def deactivate_cockpit(
165205
self,
166206
*,

scaleway-async/scaleway_async/cockpit/v1beta1/marshalling.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
from typing import Any, Dict
55

66
from scaleway_core.profile import ProfileDefaults
7+
from scaleway_core.bridge import (
8+
unmarshal_TimeSeries,
9+
)
710
from scaleway_core.utils import (
811
OneOfPossibility,
912
resolve_one_of,
@@ -13,6 +16,7 @@
1316
GrafanaUserRole,
1417
Cockpit,
1518
CockpitEndpoints,
19+
CockpitMetrics,
1620
ContactPoint,
1721
ContactPointEmail,
1822
GrafanaUser,
@@ -203,6 +207,20 @@ def unmarshal_Cockpit(data: Any) -> Cockpit:
203207
return Cockpit(**args)
204208

205209

210+
def unmarshal_CockpitMetrics(data: Any) -> CockpitMetrics:
211+
if type(data) is not dict:
212+
raise TypeError(
213+
f"Unmarshalling the type 'CockpitMetrics' failed as data isn't a dictionary."
214+
)
215+
216+
args: Dict[str, Any] = {}
217+
218+
field = data.get("timeseries")
219+
args["timeseries"] = [unmarshal_TimeSeries(v) for v in data["timeseries"]]
220+
221+
return CockpitMetrics(**args)
222+
223+
206224
def unmarshal_ListContactPointsResponse(data: Any) -> ListContactPointsResponse:
207225
if type(data) is not dict:
208226
raise TypeError(

scaleway-async/scaleway_async/cockpit/v1beta1/types.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
from enum import Enum
88
from typing import List, Optional
99

10+
from scaleway_core.bridge import (
11+
TimeSeries,
12+
)
13+
1014

1115
class CockpitStatus(str, Enum):
1216
UNKNOWN_STATUS = "unknown_status"
@@ -99,6 +103,18 @@ class CockpitEndpoints:
99103
grafana_url: str
100104

101105

106+
@dataclass
107+
class CockpitMetrics:
108+
"""
109+
Cockpit metrics.
110+
"""
111+
112+
timeseries: List[TimeSeries]
113+
"""
114+
Timeseries array.
115+
"""
116+
117+
102118
@dataclass
103119
class ContactPoint:
104120
"""
@@ -235,6 +251,29 @@ class GetCockpitRequest:
235251
project_id: Optional[str]
236252

237253

254+
@dataclass
255+
class GetCockpitMetricsRequest:
256+
project_id: Optional[str]
257+
"""
258+
Project ID.
259+
"""
260+
261+
start_date: Optional[datetime]
262+
"""
263+
Start date.
264+
"""
265+
266+
end_date: Optional[datetime]
267+
"""
268+
End date.
269+
"""
270+
271+
metric_name: Optional[str]
272+
"""
273+
Metric name.
274+
"""
275+
276+
238277
@dataclass
239278
class DeactivateCockpitRequest:
240279
project_id: Optional[str]

scaleway/scaleway/cockpit/v1beta1/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from .types import ListTokensRequestOrderBy
77
from .types import Cockpit
88
from .types import CockpitEndpoints
9+
from .types import CockpitMetrics
910
from .types import ContactPoint
1011
from .types import ContactPointEmail
1112
from .types import GrafanaUser
@@ -24,6 +25,7 @@
2425
"ListTokensRequestOrderBy",
2526
"Cockpit",
2627
"CockpitEndpoints",
28+
"CockpitMetrics",
2729
"ContactPoint",
2830
"ContactPointEmail",
2931
"GrafanaUser",

scaleway/scaleway/cockpit/v1beta1/api.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# This file was automatically generated. DO NOT EDIT.
22
# If you have any remark or suggestion do not hesitate to open an issue.
33

4+
from datetime import datetime
45
from typing import List, Optional
56

67
from scaleway_core.api import API
@@ -16,6 +17,7 @@
1617
ListGrafanaUsersRequestOrderBy,
1718
ListTokensRequestOrderBy,
1819
Cockpit,
20+
CockpitMetrics,
1921
ContactPoint,
2022
GrafanaUser,
2123
ListContactPointsResponse,
@@ -56,6 +58,7 @@
5658
unmarshal_GrafanaUser,
5759
unmarshal_Token,
5860
unmarshal_Cockpit,
61+
unmarshal_CockpitMetrics,
5962
unmarshal_ListContactPointsResponse,
6063
unmarshal_ListGrafanaUsersResponse,
6164
unmarshal_ListTokensResponse,
@@ -161,6 +164,43 @@ def wait_for_cockpit(
161164
},
162165
)
163166

167+
def get_cockpit_metrics(
168+
self,
169+
*,
170+
project_id: Optional[str] = None,
171+
start_date: Optional[datetime] = None,
172+
end_date: Optional[datetime] = None,
173+
metric_name: Optional[str] = None,
174+
) -> CockpitMetrics:
175+
"""
176+
Get cockpit metrics.
177+
Get the cockpit metrics with the given project ID.
178+
:param project_id: Project ID.
179+
:param start_date: Start date.
180+
:param end_date: End date.
181+
:param metric_name: Metric name.
182+
:return: :class:`CockpitMetrics <CockpitMetrics>`
183+
184+
Usage:
185+
::
186+
187+
result = api.get_cockpit_metrics()
188+
"""
189+
190+
res = self._request(
191+
"GET",
192+
f"/cockpit/v1beta1/cockpit/metrics",
193+
params={
194+
"end_date": end_date,
195+
"metric_name": metric_name,
196+
"project_id": project_id or self.client.default_project_id,
197+
"start_date": start_date,
198+
},
199+
)
200+
201+
self._throw_on_error(res)
202+
return unmarshal_CockpitMetrics(res.json())
203+
164204
def deactivate_cockpit(
165205
self,
166206
*,

scaleway/scaleway/cockpit/v1beta1/marshalling.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
from typing import Any, Dict
55

66
from scaleway_core.profile import ProfileDefaults
7+
from scaleway_core.bridge import (
8+
unmarshal_TimeSeries,
9+
)
710
from scaleway_core.utils import (
811
OneOfPossibility,
912
resolve_one_of,
@@ -13,6 +16,7 @@
1316
GrafanaUserRole,
1417
Cockpit,
1518
CockpitEndpoints,
19+
CockpitMetrics,
1620
ContactPoint,
1721
ContactPointEmail,
1822
GrafanaUser,
@@ -203,6 +207,20 @@ def unmarshal_Cockpit(data: Any) -> Cockpit:
203207
return Cockpit(**args)
204208

205209

210+
def unmarshal_CockpitMetrics(data: Any) -> CockpitMetrics:
211+
if type(data) is not dict:
212+
raise TypeError(
213+
f"Unmarshalling the type 'CockpitMetrics' failed as data isn't a dictionary."
214+
)
215+
216+
args: Dict[str, Any] = {}
217+
218+
field = data.get("timeseries")
219+
args["timeseries"] = [unmarshal_TimeSeries(v) for v in data["timeseries"]]
220+
221+
return CockpitMetrics(**args)
222+
223+
206224
def unmarshal_ListContactPointsResponse(data: Any) -> ListContactPointsResponse:
207225
if type(data) is not dict:
208226
raise TypeError(

scaleway/scaleway/cockpit/v1beta1/types.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
from enum import Enum
88
from typing import List, Optional
99

10+
from scaleway_core.bridge import (
11+
TimeSeries,
12+
)
13+
1014

1115
class CockpitStatus(str, Enum):
1216
UNKNOWN_STATUS = "unknown_status"
@@ -99,6 +103,18 @@ class CockpitEndpoints:
99103
grafana_url: str
100104

101105

106+
@dataclass
107+
class CockpitMetrics:
108+
"""
109+
Cockpit metrics.
110+
"""
111+
112+
timeseries: List[TimeSeries]
113+
"""
114+
Timeseries array.
115+
"""
116+
117+
102118
@dataclass
103119
class ContactPoint:
104120
"""
@@ -235,6 +251,29 @@ class GetCockpitRequest:
235251
project_id: Optional[str]
236252

237253

254+
@dataclass
255+
class GetCockpitMetricsRequest:
256+
project_id: Optional[str]
257+
"""
258+
Project ID.
259+
"""
260+
261+
start_date: Optional[datetime]
262+
"""
263+
Start date.
264+
"""
265+
266+
end_date: Optional[datetime]
267+
"""
268+
End date.
269+
"""
270+
271+
metric_name: Optional[str]
272+
"""
273+
Metric name.
274+
"""
275+
276+
238277
@dataclass
239278
class DeactivateCockpitRequest:
240279
project_id: Optional[str]

0 commit comments

Comments
 (0)