Skip to content
Open
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
7 changes: 6 additions & 1 deletion .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -190482,7 +190482,7 @@ paths:
- status_pages_settings_write
/api/v2/statuspages/degradations:
get:
description: Lists all degradations for the organization. Optionally filter by status and page.
description: Lists all degradations for the organization. Optionally filter by status, page, and source ID.
operationId: ListDegradations
parameters:
- description: Optional page id filter.
Expand Down Expand Up @@ -190514,6 +190514,11 @@ paths:
name: filter[status]
schema:
type: string
- description: "Optional source ID filter. Returns only degradations whose source matches this ID (e.g. an incident ID)."
in: query
name: filter[source_id]
schema:
type: string
- description: "Sort order. Prefix with '-' for descending. Supported values: created_at, -created_at, modified_at, -modified_at."
in: query
name: sort
Expand Down
24 changes: 17 additions & 7 deletions api/datadogV2/api_status_pages.go
Original file line number Diff line number Diff line change
Expand Up @@ -1541,12 +1541,13 @@ func (a *StatusPagesApi) ListComponents(ctx _context.Context, pageId uuid.UUID,

// ListDegradationsOptionalParameters holds optional parameters for ListDegradations.
type ListDegradationsOptionalParameters struct {
FilterPageId *string
PageOffset *int64
PageLimit *int64
Include *string
FilterStatus *string
Sort *string
FilterPageId *string
PageOffset *int64
PageLimit *int64
Include *string
FilterStatus *string
FilterSourceId *string
Sort *string
}

// NewListDegradationsOptionalParameters creates an empty struct for parameters.
Expand Down Expand Up @@ -1585,14 +1586,20 @@ func (r *ListDegradationsOptionalParameters) WithFilterStatus(filterStatus strin
return r
}

// WithFilterSourceId sets the corresponding parameter name and returns the struct.
func (r *ListDegradationsOptionalParameters) WithFilterSourceId(filterSourceId string) *ListDegradationsOptionalParameters {
r.FilterSourceId = &filterSourceId
return r
}

// WithSort sets the corresponding parameter name and returns the struct.
func (r *ListDegradationsOptionalParameters) WithSort(sort string) *ListDegradationsOptionalParameters {
r.Sort = &sort
return r
}

// ListDegradations List degradations.
// Lists all degradations for the organization. Optionally filter by status and page.
// Lists all degradations for the organization. Optionally filter by status, page, and source ID.
func (a *StatusPagesApi) ListDegradations(ctx _context.Context, o ...ListDegradationsOptionalParameters) (DegradationArray, *_nethttp.Response, error) {
var (
localVarHTTPMethod = _nethttp.MethodGet
Expand Down Expand Up @@ -1633,6 +1640,9 @@ func (a *StatusPagesApi) ListDegradations(ctx _context.Context, o ...ListDegrada
if optionalParams.FilterStatus != nil {
localVarQueryParams.Add("filter[status]", datadog.ParameterToString(*optionalParams.FilterStatus, ""))
}
if optionalParams.FilterSourceId != nil {
localVarQueryParams.Add("filter[source_id]", datadog.ParameterToString(*optionalParams.FilterSourceId, ""))
}
if optionalParams.Sort != nil {
localVarQueryParams.Add("sort", datadog.ParameterToString(*optionalParams.Sort, ""))
}
Expand Down
33 changes: 33 additions & 0 deletions examples/v2/status-pages/ListDegradations_3179419218.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// List degradations with source ID filter returns "OK" response

package main

import (
"context"
"encoding/json"
"fmt"
"os"

"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV2"
"github.com/google/uuid"
)

func main() {
// there is a valid "degradation" in the system
DegradationDataID := uuid.MustParse(os.Getenv("DEGRADATION_DATA_ID"))

ctx := datadog.NewDefaultContext(context.Background())
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewStatusPagesApi(apiClient)
resp, r, err := api.ListDegradations(ctx, *datadogV2.NewListDegradationsOptionalParameters().WithFilterSourceId(DegradationDataID))

if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `StatusPagesApi.ListDegradations`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}

responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `StatusPagesApi.ListDegradations`:\n%s\n", responseContent)
}
9 changes: 9 additions & 0 deletions tests/scenarios/features/v2/status_pages.feature
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,15 @@ Feature: Status Pages
When the request is sent
Then the response status is 200 OK

@team:DataDog/incident-app
Scenario: List degradations with source ID filter returns "OK" response
Given new "ListDegradations" request
And there is a valid "status_page" in the system
And there is a valid "degradation" in the system
And request contains "filter[source_id]" parameter from "degradation.data.id"
When the request is sent
Then the response status is 200 OK

@team:DataDog/incident-app
Scenario: List maintenances returns "OK" response
Given there is a valid "status_page" in the system
Expand Down
Loading