Skip to content
Merged
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
164 changes: 161 additions & 3 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76024,6 +76024,45 @@ components:
required:
- data
type: object
IssueSnoozeRequest:
description: Snooze issue request payload.
properties:
data:
$ref: "#/components/schemas/IssueSnoozeRequestData"
required:
- data
type: object
IssueSnoozeRequestData:
description: Snooze issue request.
properties:
attributes:
$ref: "#/components/schemas/IssueSnoozeRequestDataAttributes"
id:
description: Issue identifier.
example: "c1726a66-1f64-11ee-b338-da7ad0900002"
type: string
type:
$ref: "#/components/schemas/IssueSnoozeRequestDataType"
required:
- id
- type
- attributes
type: object
IssueSnoozeRequestDataAttributes:
description: Object describing an issue snooze request.
properties:
condition:
$ref: "#/components/schemas/IssueWatchCondition"
required:
- condition
type: object
IssueSnoozeRequestDataType:
description: Type of the object.
enum: ["error_tracking_issue"]
example: "error_tracking_issue"
type: string
x-enum-varnames:
- ERROR_TRACKING_ISSUE
IssueState:
description: State of the issue
enum:
Expand Down Expand Up @@ -76288,26 +76327,39 @@ components:
`ELAPSED_TIME` uses `duration`, and `ANY` and `ALL` use `operands`.
properties:
duration:
description: Time that must elapse before the condition is met, as a Go duration string.
description: |-
Time that must elapse from when the watch started, as a Go duration string, such as `24h`, or `168h` for a
week.
example: "168h0m0s"
type: string
kind:
$ref: "#/components/schemas/IssueWatchConditionKind"
operands:
description: Nested conditions combined by `ANY` or `ALL`.
example:
- duration: 168h
kind: ELAPSED_TIME
- kind: OCCURRENCES
threshold: 100
items:
$ref: "#/components/schemas/IssueWatchCondition"
type: array
projection:
description: Attributes whose distinct values are counted for `CARDINALITY`.
description: |-
Attributes whose distinct values `CARDINALITY` counts, in search syntax: `@` for attributes, such as
`@usr.id` or `@account.id`, and no prefix for tags and reserved fields, such as `org_id` or `service`.
Only use attributes that the issue's errors carry: a condition on an attribute they don't carry is never
met.
example: ["@usr.id"]
items:
description: Attribute path.
example: "@usr.id"
type: string
type: array
threshold:
description: Number of occurrences, or of distinct values for `CARDINALITY`, that triggers the condition.
description: |-
Number of new occurrences, or of distinct values for `CARDINALITY`, that meets the condition, counted from
when the watch started.
example: 100
format: int64
type: integer
Expand Down Expand Up @@ -182656,6 +182708,112 @@ paths:
- Error Tracking
x-unstable: |-
**Note**: This endpoint is in preview and is subject to change.
/api/v2/error-tracking/issues/{issue_id}/snooze:
post:
description: |-
Snooze an issue by `issue_id`: move it to `IGNORED` until a condition is met, then back to `OPEN`.
The condition can be a number of occurrences, a number of distinct values of an attribute such as `@usr.id`,
an elapsed time, or any or all of several conditions.
Snoozing an issue that is already snoozed replaces its snooze. Updating the state of the issue with
`UpdateIssueState` cancels the snooze.
The response includes the watch that reopens the issue.
operationId: SnoozeIssue
parameters:
- $ref: "#/components/parameters/IssueIDPathParameter"
requestBody:
content:
application/json:
examples:
default:
value:
data:
attributes:
condition:
kind: ANY
operands:
- duration: 168h
kind: ELAPSED_TIME
- kind: OCCURRENCES
threshold: 100
id: c1726a66-1f64-11ee-b338-da7ad0900002
type: error_tracking_issue
schema:
$ref: "#/components/schemas/IssueSnoozeRequest"
description: Snooze issue request payload.
required: true
responses:
"200":
content:
application/json:
examples:
default:
value:
data:
attributes:
error_message: "object of type 'NoneType' has no len()"
error_type: builtins.TypeError
service: test-service
state: IGNORED
id: c1726a66-1f64-11ee-b338-da7ad0900002
relationships:
watches:
data:
- id: e7a1c3b5-2d4f-4a6b-8c9d-0e1f2a3b4c5d
type: error_tracking_issue_watch
type: issue
included:
- attributes:
action:
from: IGNORED
kind: CHANGE_ISSUE_STATE
to: OPEN
condition:
kind: ANY
operands:
- duration: 168h0m0s
kind: ELAPSED_TIME
- kind: OCCURRENCES
threshold: 100
started_at: "2025-01-01T00:00:00Z"
status: ACTIVE
id: e7a1c3b5-2d4f-4a6b-8c9d-0e1f2a3b4c5d
type: error_tracking_issue_watch
schema:
$ref: "#/components/schemas/IssueResponse"
description: OK
"400":
content:
application/json:
schema:
$ref: "#/components/schemas/JSONAPIErrorResponse"
description: Bad Request
"401":
$ref: "#/components/responses/UnauthorizedResponse"
"403":
content:
application/json:
schema:
$ref: "#/components/schemas/JSONAPIErrorResponse"
description: Forbidden
"404":
content:
application/json:
schema:
$ref: "#/components/schemas/JSONAPIErrorResponse"
description: Not Found
"429":
$ref: "#/components/responses/TooManyRequestsResponse"
security:
- apiKeyAuth: []
appKeyAuth: []
- AuthZ:
- error_tracking_read
- error_tracking_write
summary: Snooze an issue
tags:
- Error Tracking
x-unstable: |-
**Note**: This endpoint is in preview and is subject to change.
/api/v2/error-tracking/issues/{issue_id}/state:
put:
description: Update the state of an issue by `issue_id`. Use this endpoint to move an issue between states such as `OPEN`, `RESOLVED`, or `IGNORED`.
Expand Down
38 changes: 38 additions & 0 deletions examples/v2/error-tracking/SnoozeIssue.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"""
Snooze an issue returns "OK" response
"""

from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.error_tracking_api import ErrorTrackingApi
from datadog_api_client.v2.model.issue_snooze_request import IssueSnoozeRequest
from datadog_api_client.v2.model.issue_snooze_request_data import IssueSnoozeRequestData
from datadog_api_client.v2.model.issue_snooze_request_data_attributes import IssueSnoozeRequestDataAttributes
from datadog_api_client.v2.model.issue_snooze_request_data_type import IssueSnoozeRequestDataType
from datadog_api_client.v2.model.issue_watch_condition import IssueWatchCondition
from datadog_api_client.v2.model.issue_watch_condition_kind import IssueWatchConditionKind

# there is a valid "issue" in the system
ISSUE_ID = environ["ISSUE_ID"]

body = IssueSnoozeRequest(
data=IssueSnoozeRequestData(
attributes=IssueSnoozeRequestDataAttributes(
condition=IssueWatchCondition(
kind=IssueWatchConditionKind.ELAPSED_TIME,
duration="168h",
),
),
id=ISSUE_ID,
type=IssueSnoozeRequestDataType.ERROR_TRACKING_ISSUE,
),
)

configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
configuration.unstable_operations["snooze_issue"] = True
with ApiClient(configuration) as api_client:
api_instance = ErrorTrackingApi(api_client)
response = api_instance.snooze_issue(issue_id=ISSUE_ID, body=body)

print(response)
1 change: 1 addition & 0 deletions src/datadog_api_client/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,7 @@ def __init__(
"v2.update_deployment_gate": False,
"v2.update_deployment_rule": False,
"v2.get_issue_impact": False,
"v2.snooze_issue": False,
"v2.get_eudm_device": False,
"v2.get_eudm_devices": False,
"v2.clone_form": False,
Expand Down
54 changes: 54 additions & 0 deletions src/datadog_api_client/v2/api/error_tracking_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from datadog_api_client.v2.model.issue_sample_bias import IssueSampleBias
from datadog_api_client.v2.model.issue_update_assignee_request import IssueUpdateAssigneeRequest
from datadog_api_client.v2.model.issue_impact_response import IssueImpactResponse
from datadog_api_client.v2.model.issue_snooze_request import IssueSnoozeRequest
from datadog_api_client.v2.model.issue_update_state_request import IssueUpdateStateRequest


Expand Down Expand Up @@ -151,6 +152,32 @@ def __init__(self, api_client=None):
api_client=api_client,
)

self._snooze_issue_endpoint = _Endpoint(
settings={
"response_type": (IssueResponse,),
"auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"],
"endpoint_path": "/api/v2/error-tracking/issues/{issue_id}/snooze",
"operation_id": "snooze_issue",
"http_method": "POST",
"version": "v2",
},
params_map={
"issue_id": {
"required": True,
"openapi_types": (str,),
"attribute": "issue_id",
"location": "path",
},
"body": {
"required": True,
"openapi_types": (IssueSnoozeRequest,),
"location": "body",
},
},
headers_map={"accept": ["application/json"], "content_type": ["application/json"]},
api_client=api_client,
)

self._update_issue_assignee_endpoint = _Endpoint(
settings={
"response_type": (IssueResponse,),
Expand Down Expand Up @@ -309,6 +336,33 @@ def search_issues(

return self._search_issues_endpoint.call_with_http_info(**kwargs)

def snooze_issue(
self,
issue_id: str,
body: IssueSnoozeRequest,
) -> IssueResponse:
"""Snooze an issue.

Snooze an issue by ``issue_id`` : move it to ``IGNORED`` until a condition is met, then back to ``OPEN``.
The condition can be a number of occurrences, a number of distinct values of an attribute such as ``@usr.id`` ,
an elapsed time, or any or all of several conditions.
Snoozing an issue that is already snoozed replaces its snooze. Updating the state of the issue with
``UpdateIssueState`` cancels the snooze.
The response includes the watch that reopens the issue.

:param issue_id: The identifier of the issue.
:type issue_id: str
:param body: Snooze issue request payload.
:type body: IssueSnoozeRequest
:rtype: IssueResponse
"""
kwargs: Dict[str, Any] = {}
kwargs["issue_id"] = issue_id

kwargs["body"] = body

return self._snooze_issue_endpoint.call_with_http_info(**kwargs)

def update_issue_assignee(
self,
issue_id: str,
Expand Down
40 changes: 40 additions & 0 deletions src/datadog_api_client/v2/model/issue_snooze_request.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
# This product includes software developed at Datadog (https://www.datadoghq.com/).
# Copyright 2019-Present Datadog, Inc.
from __future__ import annotations

from typing import TYPE_CHECKING

from datadog_api_client.model_utils import (
ModelNormal,
cached_property,
)


if TYPE_CHECKING:
from datadog_api_client.v2.model.issue_snooze_request_data import IssueSnoozeRequestData


class IssueSnoozeRequest(ModelNormal):
@cached_property
def openapi_types(_):
from datadog_api_client.v2.model.issue_snooze_request_data import IssueSnoozeRequestData

return {
"data": (IssueSnoozeRequestData,),
}

attribute_map = {
"data": "data",
}

def __init__(self_, data: IssueSnoozeRequestData, **kwargs):
"""
Snooze issue request payload.

:param data: Snooze issue request.
:type data: IssueSnoozeRequestData
"""
super().__init__(kwargs)

self_.data = data
Loading
Loading