@@ -46,8 +46,8 @@ const (
4646 DataSourceOriginUnknownOrigin = DataSourceOrigin ("unknown_origin" )
4747 // Data source managed by Scaleway, used to store and query metrics and logs from Scaleway resources.
4848 DataSourceOriginScaleway = DataSourceOrigin ("scaleway" )
49- // Data source created by the user, used to store and query metrics, logs and traces from user's external resources.
50- DataSourceOriginExternal = DataSourceOrigin ("external " )
49+ // Data source created by the user, used to store and query metrics, logs and traces from user's custom resources.
50+ DataSourceOriginCustom = DataSourceOrigin ("custom " )
5151)
5252
5353func (enum DataSourceOrigin ) String () string {
@@ -62,7 +62,7 @@ func (enum DataSourceOrigin) Values() []DataSourceOrigin {
6262 return []DataSourceOrigin {
6363 "unknown_origin" ,
6464 "scaleway" ,
65- "external " ,
65+ "custom " ,
6666 }
6767}
6868
@@ -725,6 +725,11 @@ type AlertManager struct {
725725 Region scw.Region `json:"region"`
726726}
727727
728+ // CockpitMetrics: cockpit metrics.
729+ type CockpitMetrics struct {
730+ Timeseries []* scw.TimeSeries `json:"timeseries"`
731+ }
732+
728733// GetConfigResponse: Cockpit configuration.
729734type GetConfigResponse struct {
730735 // CustomMetricsRetention: custom metrics retention configuration.
@@ -1185,6 +1190,17 @@ type RegionalAPIGetAlertManagerRequest struct {
11851190 ProjectID string `json:"project_id"`
11861191}
11871192
1193+ // RegionalAPIGetCockpitMetricsRequest: regional api get cockpit metrics request.
1194+ type RegionalAPIGetCockpitMetricsRequest struct {
1195+ ProjectID string `json:"-"`
1196+
1197+ StartDate * time.Time `json:"-"`
1198+
1199+ EndDate * time.Time `json:"-"`
1200+
1201+ Query string `json:"-"`
1202+ }
1203+
11881204// RegionalAPIGetConfigRequest: Get Cockpit configuration.
11891205type RegionalAPIGetConfigRequest struct {
11901206 // Region: region to target. If none is passed will use default region from the config.
@@ -2471,3 +2487,33 @@ func (s *RegionalAPI) TriggerTestAlert(req *RegionalAPITriggerTestAlertRequest,
24712487 }
24722488 return nil
24732489}
2490+
2491+ // GetCockpitMetrics:
2492+ func (s * RegionalAPI ) GetCockpitMetrics (req * RegionalAPIGetCockpitMetricsRequest , opts ... scw.RequestOption ) (* CockpitMetrics , error ) {
2493+ var err error
2494+
2495+ if req .ProjectID == "" {
2496+ defaultProjectID , _ := s .client .GetDefaultProjectID ()
2497+ req .ProjectID = defaultProjectID
2498+ }
2499+
2500+ query := url.Values {}
2501+ parameter .AddToQuery (query , "project_id" , req .ProjectID )
2502+ parameter .AddToQuery (query , "start_date" , req .StartDate )
2503+ parameter .AddToQuery (query , "end_date" , req .EndDate )
2504+ parameter .AddToQuery (query , "query" , req .Query )
2505+
2506+ scwReq := & scw.ScalewayRequest {
2507+ Method : "GET" ,
2508+ Path : "/cockpit/v1beta1/cockpit/metrics" ,
2509+ Query : query ,
2510+ }
2511+
2512+ var resp CockpitMetrics
2513+
2514+ err = s .client .Do (scwReq , & resp , opts ... )
2515+ if err != nil {
2516+ return nil , err
2517+ }
2518+ return & resp , nil
2519+ }
0 commit comments