diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index bf4011c1550..3114843c790 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -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. @@ -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 diff --git a/api/datadogV2/api_status_pages.go b/api/datadogV2/api_status_pages.go index 408f2325872..fb2da4247df 100644 --- a/api/datadogV2/api_status_pages.go +++ b/api/datadogV2/api_status_pages.go @@ -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. @@ -1585,6 +1586,12 @@ 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 @@ -1592,7 +1599,7 @@ func (r *ListDegradationsOptionalParameters) WithSort(sort string) *ListDegradat } // 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 @@ -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, "")) } diff --git a/examples/v2/status-pages/ListDegradations_3179419218.go b/examples/v2/status-pages/ListDegradations_3179419218.go new file mode 100644 index 00000000000..6f1eaa28abf --- /dev/null +++ b/examples/v2/status-pages/ListDegradations_3179419218.go @@ -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) +} diff --git a/tests/scenarios/features/v2/status_pages.feature b/tests/scenarios/features/v2/status_pages.feature index 99cb8e3ed61..0d8ec897210 100644 --- a/tests/scenarios/features/v2/status_pages.feature +++ b/tests/scenarios/features/v2/status_pages.feature @@ -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