@@ -207,6 +207,12 @@ type CockpitEndpoints struct {
207207 GrafanaURL string `json:"grafana_url"`
208208}
209209
210+ // CockpitMetrics: cockpit metrics.
211+ type CockpitMetrics struct {
212+ // Timeseries: timeseries array.
213+ Timeseries []* scw.TimeSeries `json:"timeseries"`
214+ }
215+
210216// ContactPoint: alert contact point.
211217// Contact point.
212218type ContactPoint struct {
@@ -359,6 +365,49 @@ func (s *API) GetCockpit(req *GetCockpitRequest, opts ...scw.RequestOption) (*Co
359365 return & resp , nil
360366}
361367
368+ type GetCockpitMetricsRequest struct {
369+ // ProjectID: project ID.
370+ ProjectID string `json:"-"`
371+ // StartDate: start date.
372+ StartDate * time.Time `json:"-"`
373+ // EndDate: end date.
374+ EndDate * time.Time `json:"-"`
375+ // MetricName: metric name.
376+ MetricName * string `json:"-"`
377+ }
378+
379+ // GetCockpitMetrics: get cockpit metrics.
380+ // Get the cockpit metrics with the given project ID.
381+ func (s * API ) GetCockpitMetrics (req * GetCockpitMetricsRequest , opts ... scw.RequestOption ) (* CockpitMetrics , error ) {
382+ var err error
383+
384+ if req .ProjectID == "" {
385+ defaultProjectID , _ := s .client .GetDefaultProjectID ()
386+ req .ProjectID = defaultProjectID
387+ }
388+
389+ query := url.Values {}
390+ parameter .AddToQuery (query , "project_id" , req .ProjectID )
391+ parameter .AddToQuery (query , "start_date" , req .StartDate )
392+ parameter .AddToQuery (query , "end_date" , req .EndDate )
393+ parameter .AddToQuery (query , "metric_name" , req .MetricName )
394+
395+ scwReq := & scw.ScalewayRequest {
396+ Method : "GET" ,
397+ Path : "/cockpit/v1beta1/cockpit/metrics" ,
398+ Query : query ,
399+ Headers : http.Header {},
400+ }
401+
402+ var resp CockpitMetrics
403+
404+ err = s .client .Do (scwReq , & resp , opts ... )
405+ if err != nil {
406+ return nil , err
407+ }
408+ return & resp , nil
409+ }
410+
362411type DeactivateCockpitRequest struct {
363412 ProjectID string `json:"project_id"`
364413}
0 commit comments