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
2 changes: 2 additions & 0 deletions scaleway-async/scaleway_async/cockpit/v1beta1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from .types import ListTokensRequestOrderBy
from .types import Cockpit
from .types import CockpitEndpoints
from .types import CockpitMetrics
from .types import ContactPoint
from .types import ContactPointEmail
from .types import GrafanaUser
Expand All @@ -24,6 +25,7 @@
"ListTokensRequestOrderBy",
"Cockpit",
"CockpitEndpoints",
"CockpitMetrics",
"ContactPoint",
"ContactPointEmail",
"GrafanaUser",
Expand Down
40 changes: 40 additions & 0 deletions scaleway-async/scaleway_async/cockpit/v1beta1/api.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# This file was automatically generated. DO NOT EDIT.
# If you have any remark or suggestion do not hesitate to open an issue.

from datetime import datetime
from typing import Awaitable, List, Optional, Union

from scaleway_core.api import API
Expand All @@ -16,6 +17,7 @@
ListGrafanaUsersRequestOrderBy,
ListTokensRequestOrderBy,
Cockpit,
CockpitMetrics,
ContactPoint,
GrafanaUser,
ListContactPointsResponse,
Expand Down Expand Up @@ -56,6 +58,7 @@
unmarshal_GrafanaUser,
unmarshal_Token,
unmarshal_Cockpit,
unmarshal_CockpitMetrics,
unmarshal_ListContactPointsResponse,
unmarshal_ListGrafanaUsersResponse,
unmarshal_ListTokensResponse,
Expand Down Expand Up @@ -161,6 +164,43 @@ async def wait_for_cockpit(
},
)

async def get_cockpit_metrics(
self,
*,
project_id: Optional[str] = None,
start_date: Optional[datetime] = None,
end_date: Optional[datetime] = None,
metric_name: Optional[str] = None,
) -> CockpitMetrics:
"""
Get cockpit metrics.
Get the cockpit metrics with the given project ID.
:param project_id: Project ID.
:param start_date: Start date.
:param end_date: End date.
:param metric_name: Metric name.
:return: :class:`CockpitMetrics <CockpitMetrics>`

Usage:
::

result = await api.get_cockpit_metrics()
"""

res = self._request(
"GET",
f"/cockpit/v1beta1/cockpit/metrics",
params={
"end_date": end_date,
"metric_name": metric_name,
"project_id": project_id or self.client.default_project_id,
"start_date": start_date,
},
)

self._throw_on_error(res)
return unmarshal_CockpitMetrics(res.json())

async def deactivate_cockpit(
self,
*,
Expand Down
18 changes: 18 additions & 0 deletions scaleway-async/scaleway_async/cockpit/v1beta1/marshalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
from typing import Any, Dict

from scaleway_core.profile import ProfileDefaults
from scaleway_core.bridge import (
unmarshal_TimeSeries,
)
from scaleway_core.utils import (
OneOfPossibility,
resolve_one_of,
Expand All @@ -13,6 +16,7 @@
GrafanaUserRole,
Cockpit,
CockpitEndpoints,
CockpitMetrics,
ContactPoint,
ContactPointEmail,
GrafanaUser,
Expand Down Expand Up @@ -203,6 +207,20 @@ def unmarshal_Cockpit(data: Any) -> Cockpit:
return Cockpit(**args)


def unmarshal_CockpitMetrics(data: Any) -> CockpitMetrics:
if type(data) is not dict:
raise TypeError(
f"Unmarshalling the type 'CockpitMetrics' failed as data isn't a dictionary."
)

args: Dict[str, Any] = {}

field = data.get("timeseries")
args["timeseries"] = [unmarshal_TimeSeries(v) for v in data["timeseries"]]

return CockpitMetrics(**args)


def unmarshal_ListContactPointsResponse(data: Any) -> ListContactPointsResponse:
if type(data) is not dict:
raise TypeError(
Expand Down
39 changes: 39 additions & 0 deletions scaleway-async/scaleway_async/cockpit/v1beta1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
from enum import Enum
from typing import List, Optional

from scaleway_core.bridge import (
TimeSeries,
)


class CockpitStatus(str, Enum):
UNKNOWN_STATUS = "unknown_status"
Expand Down Expand Up @@ -99,6 +103,18 @@ class CockpitEndpoints:
grafana_url: str


@dataclass
class CockpitMetrics:
"""
Cockpit metrics.
"""

timeseries: List[TimeSeries]
"""
Timeseries array.
"""


@dataclass
class ContactPoint:
"""
Expand Down Expand Up @@ -235,6 +251,29 @@ class GetCockpitRequest:
project_id: Optional[str]


@dataclass
class GetCockpitMetricsRequest:
project_id: Optional[str]
"""
Project ID.
"""

start_date: Optional[datetime]
"""
Start date.
"""

end_date: Optional[datetime]
"""
End date.
"""

metric_name: Optional[str]
"""
Metric name.
"""


@dataclass
class DeactivateCockpitRequest:
project_id: Optional[str]
Expand Down
2 changes: 2 additions & 0 deletions scaleway/scaleway/cockpit/v1beta1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from .types import ListTokensRequestOrderBy
from .types import Cockpit
from .types import CockpitEndpoints
from .types import CockpitMetrics
from .types import ContactPoint
from .types import ContactPointEmail
from .types import GrafanaUser
Expand All @@ -24,6 +25,7 @@
"ListTokensRequestOrderBy",
"Cockpit",
"CockpitEndpoints",
"CockpitMetrics",
"ContactPoint",
"ContactPointEmail",
"GrafanaUser",
Expand Down
40 changes: 40 additions & 0 deletions scaleway/scaleway/cockpit/v1beta1/api.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# This file was automatically generated. DO NOT EDIT.
# If you have any remark or suggestion do not hesitate to open an issue.

from datetime import datetime
from typing import List, Optional

from scaleway_core.api import API
Expand All @@ -16,6 +17,7 @@
ListGrafanaUsersRequestOrderBy,
ListTokensRequestOrderBy,
Cockpit,
CockpitMetrics,
ContactPoint,
GrafanaUser,
ListContactPointsResponse,
Expand Down Expand Up @@ -56,6 +58,7 @@
unmarshal_GrafanaUser,
unmarshal_Token,
unmarshal_Cockpit,
unmarshal_CockpitMetrics,
unmarshal_ListContactPointsResponse,
unmarshal_ListGrafanaUsersResponse,
unmarshal_ListTokensResponse,
Expand Down Expand Up @@ -161,6 +164,43 @@ def wait_for_cockpit(
},
)

def get_cockpit_metrics(
self,
*,
project_id: Optional[str] = None,
start_date: Optional[datetime] = None,
end_date: Optional[datetime] = None,
metric_name: Optional[str] = None,
) -> CockpitMetrics:
"""
Get cockpit metrics.
Get the cockpit metrics with the given project ID.
:param project_id: Project ID.
:param start_date: Start date.
:param end_date: End date.
:param metric_name: Metric name.
:return: :class:`CockpitMetrics <CockpitMetrics>`

Usage:
::

result = api.get_cockpit_metrics()
"""

res = self._request(
"GET",
f"/cockpit/v1beta1/cockpit/metrics",
params={
"end_date": end_date,
"metric_name": metric_name,
"project_id": project_id or self.client.default_project_id,
"start_date": start_date,
},
)

self._throw_on_error(res)
return unmarshal_CockpitMetrics(res.json())

def deactivate_cockpit(
self,
*,
Expand Down
18 changes: 18 additions & 0 deletions scaleway/scaleway/cockpit/v1beta1/marshalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
from typing import Any, Dict

from scaleway_core.profile import ProfileDefaults
from scaleway_core.bridge import (
unmarshal_TimeSeries,
)
from scaleway_core.utils import (
OneOfPossibility,
resolve_one_of,
Expand All @@ -13,6 +16,7 @@
GrafanaUserRole,
Cockpit,
CockpitEndpoints,
CockpitMetrics,
ContactPoint,
ContactPointEmail,
GrafanaUser,
Expand Down Expand Up @@ -203,6 +207,20 @@ def unmarshal_Cockpit(data: Any) -> Cockpit:
return Cockpit(**args)


def unmarshal_CockpitMetrics(data: Any) -> CockpitMetrics:
if type(data) is not dict:
raise TypeError(
f"Unmarshalling the type 'CockpitMetrics' failed as data isn't a dictionary."
)

args: Dict[str, Any] = {}

field = data.get("timeseries")
args["timeseries"] = [unmarshal_TimeSeries(v) for v in data["timeseries"]]

return CockpitMetrics(**args)


def unmarshal_ListContactPointsResponse(data: Any) -> ListContactPointsResponse:
if type(data) is not dict:
raise TypeError(
Expand Down
39 changes: 39 additions & 0 deletions scaleway/scaleway/cockpit/v1beta1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
from enum import Enum
from typing import List, Optional

from scaleway_core.bridge import (
TimeSeries,
)


class CockpitStatus(str, Enum):
UNKNOWN_STATUS = "unknown_status"
Expand Down Expand Up @@ -99,6 +103,18 @@ class CockpitEndpoints:
grafana_url: str


@dataclass
class CockpitMetrics:
"""
Cockpit metrics.
"""

timeseries: List[TimeSeries]
"""
Timeseries array.
"""


@dataclass
class ContactPoint:
"""
Expand Down Expand Up @@ -235,6 +251,29 @@ class GetCockpitRequest:
project_id: Optional[str]


@dataclass
class GetCockpitMetricsRequest:
project_id: Optional[str]
"""
Project ID.
"""

start_date: Optional[datetime]
"""
Start date.
"""

end_date: Optional[datetime]
"""
End date.
"""

metric_name: Optional[str]
"""
Metric name.
"""


@dataclass
class DeactivateCockpitRequest:
project_id: Optional[str]
Expand Down