Skip to content

Commit 5af0814

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Create OpenAPI for SLO status endpoint (DataDog#3612)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 10f1298 commit 5af0814

12 files changed

Lines changed: 1092 additions & 0 deletions

File tree

.generator/schemas/v2/openapi.yaml

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,16 @@ components:
346346
required: true
347347
schema:
348348
type: string
349+
DisableCorrections:
350+
description: Whether to exclude correction windows from the SLO status calculation.
351+
Defaults to false.
352+
in: query
353+
name: disable_corrections
354+
required: false
355+
schema:
356+
default: false
357+
example: false
358+
type: boolean
349359
EntityID:
350360
description: UUID or Entity Ref.
351361
in: path
@@ -457,6 +467,15 @@ components:
457467
required: false
458468
schema:
459469
$ref: '#/components/schemas/RelationType'
470+
FromTimestamp:
471+
description: The starting timestamp for the SLO status query in epoch seconds.
472+
in: query
473+
name: from_ts
474+
required: true
475+
schema:
476+
example: 1690901870
477+
format: int64
478+
type: integer
460479
GCPSTSServiceAccountID:
461480
description: Your GCP STS enabled service account's unique ID.
462481
in: path
@@ -1104,6 +1123,14 @@ components:
11041123
required: false
11051124
schema:
11061125
type: boolean
1126+
SloID:
1127+
description: The ID of the SLO.
1128+
in: path
1129+
name: slo_id
1130+
required: true
1131+
schema:
1132+
example: 00000000-0000-0000-0000-000000000000
1133+
type: string
11071134
SpansMetricIDParameter:
11081135
description: The name of the span-based metric.
11091136
in: path
@@ -1125,6 +1152,15 @@ components:
11251152
required: true
11261153
schema:
11271154
type: string
1155+
ToTimestamp:
1156+
description: The ending timestamp for the SLO status query in epoch seconds.
1157+
in: query
1158+
name: to_ts
1159+
required: true
1160+
schema:
1161+
example: 1706803070
1162+
format: int64
1163+
type: integer
11281164
UserID:
11291165
description: The ID of the user.
11301166
in: path
@@ -46850,6 +46886,22 @@ components:
4685046886
from the other indexes
4685146887
type: string
4685246888
type: object
46889+
RawErrorBudgetRemaining:
46890+
description: The raw error budget remaining for the SLO.
46891+
properties:
46892+
unit:
46893+
description: The unit of the error budget (for example, `seconds`, `requests`).
46894+
example: seconds
46895+
type: string
46896+
value:
46897+
description: The numeric value of the remaining error budget.
46898+
example: 86400.5
46899+
format: double
46900+
type: number
46901+
required:
46902+
- value
46903+
- unit
46904+
type: object
4685346905
ReadinessGate:
4685446906
description: Used to merge multiple branches into a single branch.
4685546907
properties:
@@ -57827,6 +57879,70 @@ components:
5782757879
required:
5782857880
- attributes
5782957881
type: object
57882+
SloStatusData:
57883+
description: The data portion of the SLO status response.
57884+
properties:
57885+
attributes:
57886+
$ref: '#/components/schemas/SloStatusDataAttributes'
57887+
id:
57888+
description: The ID of the SLO.
57889+
example: 00000000-0000-0000-0000-000000000000
57890+
type: string
57891+
type:
57892+
$ref: '#/components/schemas/SloStatusType'
57893+
required:
57894+
- id
57895+
- type
57896+
- attributes
57897+
type: object
57898+
SloStatusDataAttributes:
57899+
description: The attributes of the SLO status.
57900+
properties:
57901+
error_budget_remaining:
57902+
description: The percentage of error budget remaining.
57903+
example: 99.5
57904+
format: double
57905+
type: number
57906+
raw_error_budget_remaining:
57907+
$ref: '#/components/schemas/RawErrorBudgetRemaining'
57908+
sli:
57909+
description: The current Service Level Indicator (SLI) value as a percentage.
57910+
example: 99.95
57911+
format: double
57912+
type: number
57913+
span_precision:
57914+
description: The precision of the time span in seconds.
57915+
example: 2
57916+
format: int64
57917+
type: integer
57918+
state:
57919+
description: The current state of the SLO (for example, `breached`, `warning`,
57920+
`ok`).
57921+
example: ok
57922+
type: string
57923+
required:
57924+
- sli
57925+
- error_budget_remaining
57926+
- raw_error_budget_remaining
57927+
- state
57928+
- span_precision
57929+
type: object
57930+
SloStatusResponse:
57931+
description: The SLO status response.
57932+
properties:
57933+
data:
57934+
$ref: '#/components/schemas/SloStatusData'
57935+
required:
57936+
- data
57937+
type: object
57938+
SloStatusType:
57939+
description: The type of the SLO status resource.
57940+
enum:
57941+
- slo_status
57942+
example: slo_status
57943+
type: string
57944+
x-enum-varnames:
57945+
- SLO_STATUS
5783057946
SoftwareCatalogTriggerWrapper:
5783157947
description: Schema for a Software Catalog-based trigger.
5783257948
properties:
@@ -94439,6 +94555,63 @@ paths:
9443994555
x-unstable: '**Note**: This feature is in private beta. To request access, use
9444094556
the request access form in the [Service Level Objectives](https://docs.datadoghq.com/service_management/service_level_objectives/#slo-csv-export)
9444194557
docs.'
94558+
/api/v2/slo/{slo_id}/status:
94559+
get:
94560+
description: 'Get the status of a Service Level Objective (SLO) for a given
94561+
time period.
94562+
94563+
94564+
This endpoint returns the current SLI value, error budget remaining, and other
94565+
status information for the specified SLO.'
94566+
operationId: GetSloStatus
94567+
parameters:
94568+
- $ref: '#/components/parameters/SloID'
94569+
- $ref: '#/components/parameters/FromTimestamp'
94570+
- $ref: '#/components/parameters/ToTimestamp'
94571+
- $ref: '#/components/parameters/DisableCorrections'
94572+
responses:
94573+
'200':
94574+
content:
94575+
application/json:
94576+
schema:
94577+
$ref: '#/components/schemas/SloStatusResponse'
94578+
description: OK
94579+
'400':
94580+
content:
94581+
application/json:
94582+
schema:
94583+
$ref: '#/components/schemas/JSONAPIErrorResponse'
94584+
description: Bad Request
94585+
'403':
94586+
content:
94587+
application/json:
94588+
schema:
94589+
$ref: '#/components/schemas/JSONAPIErrorResponse'
94590+
description: Forbidden
94591+
'404':
94592+
content:
94593+
application/json:
94594+
schema:
94595+
$ref: '#/components/schemas/JSONAPIErrorResponse'
94596+
description: Not Found
94597+
'429':
94598+
$ref: '#/components/responses/TooManyRequestsResponse'
94599+
security:
94600+
- apiKeyAuth: []
94601+
appKeyAuth: []
94602+
- AuthZ:
94603+
- slos_read
94604+
summary: Get SLO status
94605+
tags:
94606+
- Service Level Objectives
94607+
x-permission:
94608+
operator: OR
94609+
permissions:
94610+
- slos_read
94611+
x-unstable: '**Note**: This endpoint is in public beta and it''s subject to
94612+
change.
94613+
94614+
If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).'
9444294615
/api/v2/spa/recommendations/{service}:
9444394616
get:
9444494617
description: This endpoint is currently experimental and restricted to Datadog

api/datadog/configuration.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,7 @@ func NewConfiguration() *Configuration {
813813
"v2.CreateSLOReportJob": false,
814814
"v2.GetSLOReport": false,
815815
"v2.GetSLOReportJobStatus": false,
816+
"v2.GetSloStatus": false,
816817
"v2.GetSPARecommendations": false,
817818
"v2.GetSPARecommendationsWithShard": false,
818819
"v2.CreateCustomRule": false,

api/datadogV2/api_service_level_objectives.go

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,134 @@ func (a *ServiceLevelObjectivesApi) GetSLOReportJobStatus(ctx _context.Context,
284284
return localVarReturnValue, localVarHTTPResponse, nil
285285
}
286286

287+
// GetSloStatusOptionalParameters holds optional parameters for GetSloStatus.
288+
type GetSloStatusOptionalParameters struct {
289+
DisableCorrections *bool
290+
}
291+
292+
// NewGetSloStatusOptionalParameters creates an empty struct for parameters.
293+
func NewGetSloStatusOptionalParameters() *GetSloStatusOptionalParameters {
294+
this := GetSloStatusOptionalParameters{}
295+
return &this
296+
}
297+
298+
// WithDisableCorrections sets the corresponding parameter name and returns the struct.
299+
func (r *GetSloStatusOptionalParameters) WithDisableCorrections(disableCorrections bool) *GetSloStatusOptionalParameters {
300+
r.DisableCorrections = &disableCorrections
301+
return r
302+
}
303+
304+
// GetSloStatus Get SLO status.
305+
// Get the status of a Service Level Objective (SLO) for a given time period.
306+
//
307+
// This endpoint returns the current SLI value, error budget remaining, and other status information for the specified SLO.
308+
func (a *ServiceLevelObjectivesApi) GetSloStatus(ctx _context.Context, sloId string, fromTs int64, toTs int64, o ...GetSloStatusOptionalParameters) (SloStatusResponse, *_nethttp.Response, error) {
309+
var (
310+
localVarHTTPMethod = _nethttp.MethodGet
311+
localVarPostBody interface{}
312+
localVarReturnValue SloStatusResponse
313+
optionalParams GetSloStatusOptionalParameters
314+
)
315+
316+
if len(o) > 1 {
317+
return localVarReturnValue, nil, datadog.ReportError("only one argument of type GetSloStatusOptionalParameters is allowed")
318+
}
319+
if len(o) == 1 {
320+
optionalParams = o[0]
321+
}
322+
323+
operationId := "v2.GetSloStatus"
324+
isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId)
325+
if !isOperationEnabled {
326+
return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)}
327+
}
328+
if isOperationEnabled && a.Client.Cfg.Debug {
329+
_log.Printf("WARNING: Using unstable operation '%s'", operationId)
330+
}
331+
332+
localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.ServiceLevelObjectivesApi.GetSloStatus")
333+
if err != nil {
334+
return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()}
335+
}
336+
337+
localVarPath := localBasePath + "/api/v2/slo/{slo_id}/status"
338+
localVarPath = datadog.ReplacePathParameter(localVarPath, "{slo_id}", _neturl.PathEscape(datadog.ParameterToString(sloId, "")))
339+
340+
localVarHeaderParams := make(map[string]string)
341+
localVarQueryParams := _neturl.Values{}
342+
localVarFormParams := _neturl.Values{}
343+
localVarQueryParams.Add("from_ts", datadog.ParameterToString(fromTs, ""))
344+
localVarQueryParams.Add("to_ts", datadog.ParameterToString(toTs, ""))
345+
if optionalParams.DisableCorrections != nil {
346+
localVarQueryParams.Add("disable_corrections", datadog.ParameterToString(*optionalParams.DisableCorrections, ""))
347+
}
348+
localVarHeaderParams["Accept"] = "application/json"
349+
350+
if a.Client.Cfg.DelegatedTokenConfig != nil {
351+
err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig)
352+
if err != nil {
353+
return localVarReturnValue, nil, err
354+
}
355+
} else {
356+
datadog.SetAuthKeys(
357+
ctx,
358+
&localVarHeaderParams,
359+
[2]string{"apiKeyAuth", "DD-API-KEY"},
360+
[2]string{"appKeyAuth", "DD-APPLICATION-KEY"},
361+
)
362+
}
363+
req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil)
364+
if err != nil {
365+
return localVarReturnValue, nil, err
366+
}
367+
368+
localVarHTTPResponse, err := a.Client.CallAPI(req)
369+
if err != nil || localVarHTTPResponse == nil {
370+
return localVarReturnValue, localVarHTTPResponse, err
371+
}
372+
373+
localVarBody, err := datadog.ReadBody(localVarHTTPResponse)
374+
if err != nil {
375+
return localVarReturnValue, localVarHTTPResponse, err
376+
}
377+
378+
if localVarHTTPResponse.StatusCode >= 300 {
379+
newErr := datadog.GenericOpenAPIError{
380+
ErrorBody: localVarBody,
381+
ErrorMessage: localVarHTTPResponse.Status,
382+
}
383+
if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 {
384+
var v JSONAPIErrorResponse
385+
err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
386+
if err != nil {
387+
return localVarReturnValue, localVarHTTPResponse, newErr
388+
}
389+
newErr.ErrorModel = v
390+
return localVarReturnValue, localVarHTTPResponse, newErr
391+
}
392+
if localVarHTTPResponse.StatusCode == 429 {
393+
var v APIErrorResponse
394+
err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
395+
if err != nil {
396+
return localVarReturnValue, localVarHTTPResponse, newErr
397+
}
398+
newErr.ErrorModel = v
399+
}
400+
return localVarReturnValue, localVarHTTPResponse, newErr
401+
}
402+
403+
err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
404+
if err != nil {
405+
newErr := datadog.GenericOpenAPIError{
406+
ErrorBody: localVarBody,
407+
ErrorMessage: err.Error(),
408+
}
409+
return localVarReturnValue, localVarHTTPResponse, newErr
410+
}
411+
412+
return localVarReturnValue, localVarHTTPResponse, nil
413+
}
414+
287415
// NewServiceLevelObjectivesApi Returns NewServiceLevelObjectivesApi.
288416
func NewServiceLevelObjectivesApi(client *datadog.APIClient) *ServiceLevelObjectivesApi {
289417
return &ServiceLevelObjectivesApi{

api/datadogV2/doc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,7 @@
665665
// - [ServiceLevelObjectivesApi.CreateSLOReportJob]
666666
// - [ServiceLevelObjectivesApi.GetSLOReport]
667667
// - [ServiceLevelObjectivesApi.GetSLOReportJobStatus]
668+
// - [ServiceLevelObjectivesApi.GetSloStatus]
668669
// - [ServiceScorecardsApi.CreateScorecardOutcomesBatch]
669670
// - [ServiceScorecardsApi.CreateScorecardRule]
670671
// - [ServiceScorecardsApi.DeleteScorecardRule]

0 commit comments

Comments
 (0)