Skip to content

Document case management attributes endpoints #803

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
4 changes: 2 additions & 2 deletions .generated-info
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"spec_repo_commit": "dcf594e",
"generated": "2025-07-31 10:00:30.229"
"spec_repo_commit": "b75095c",
"generated": "2025-07-31 10:50:58.895"
}
76 changes: 75 additions & 1 deletion .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6891,14 +6891,16 @@ components:
- data
type: object
CaseAttributes:
description: Case attributes
description: Case resource attributes
properties:
archived_at:
description: Timestamp of when the case was archived
format: date-time
nullable: true
readOnly: true
type: string
attributes:
$ref: '#/components/schemas/CaseObjectAttributes'
closed_at:
description: Timestamp of when the case was closed
format: date-time
Expand Down Expand Up @@ -7003,6 +7005,13 @@ components:
required:
- data
type: object
CaseObjectAttributes:
additionalProperties:
items:
type: string
type: array
description: The definition of `CaseObjectAttributes` object.
type: object
CasePriority:
default: NOT_DEFINED
description: Case priority
Expand Down Expand Up @@ -7098,6 +7107,33 @@ components:
type: string
x-enum-varnames:
- STANDARD
CaseUpdateAttributes:
description: Case update attributes
properties:
attributes:
$ref: '#/components/schemas/CaseUpdateAttributesAttributes'
type:
$ref: '#/components/schemas/CaseResourceType'
required:
- attributes
- type
type: object
CaseUpdateAttributesAttributes:
description: Case update attributes attributes
properties:
attributes:
$ref: '#/components/schemas/CaseObjectAttributes'
required:
- attributes
type: object
CaseUpdateAttributesRequest:
description: Case update attributes request
properties:
data:
$ref: '#/components/schemas/CaseUpdateAttributes'
required:
- data
type: object
CaseUpdatePriority:
description: Case priority status
properties:
Expand Down Expand Up @@ -45579,6 +45615,44 @@ paths:
summary: Assign case
tags:
- Case Management
/api/v2/cases/{case_id}/attributes:
post:
description: Update case attributes
operationId: UpdateAttributes
parameters:
- $ref: '#/components/parameters/CaseIDPathParameter'
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/CaseUpdateAttributesRequest'
description: Case attributes update payload
required: true
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/CaseResponse'
description: OK
'400':
$ref: '#/components/responses/BadRequestResponse'
'401':
$ref: '#/components/responses/UnauthorizedResponse'
'403':
$ref: '#/components/responses/ForbiddenResponse'
'404':
$ref: '#/components/responses/NotFoundResponse'
'429':
$ref: '#/components/responses/TooManyRequestsResponse'
security:
- apiKeyAuth: []
appKeyAuth: []
- AuthZ:
- cases_write
summary: Update case attributes
tags:
- Case Management
/api/v2/cases/{case_id}/priority:
post:
description: Update case priority
Expand Down
33 changes: 33 additions & 0 deletions examples/v2_case-management_UpdateAttributes.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Update case attributes returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_case_management::CaseManagementAPI;
use datadog_api_client::datadogV2::model::CaseResourceType;
use datadog_api_client::datadogV2::model::CaseUpdateAttributes;
use datadog_api_client::datadogV2::model::CaseUpdateAttributesAttributes;
use datadog_api_client::datadogV2::model::CaseUpdateAttributesRequest;
use std::collections::BTreeMap;

#[tokio::main]
async fn main() {
// there is a valid "case" in the system
let case_id = std::env::var("CASE_ID").unwrap();
let body = CaseUpdateAttributesRequest::new(CaseUpdateAttributes::new(
CaseUpdateAttributesAttributes::new(BTreeMap::from([
("env".to_string(), vec!["test".to_string()]),
(
"service".to_string(),
vec!["web-store".to_string(), "web-api".to_string()],
),
("team".to_string(), vec!["engineer".to_string()]),
])),
CaseResourceType::CASE,
));
let configuration = datadog::Configuration::new();
let api = CaseManagementAPI::with_config(configuration);
let resp = api.update_attributes(case_id.clone(), body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
160 changes: 160 additions & 0 deletions src/datadogV2/api/api_case_management.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,14 @@ pub enum UnassignCaseError {
UnknownValue(serde_json::Value),
}

/// UpdateAttributesError is a struct for typed errors of method [`CaseManagementAPI::update_attributes`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateAttributesError {
APIErrorResponse(crate::datadogV2::model::APIErrorResponse),
UnknownValue(serde_json::Value),
}

/// UpdatePriorityError is a struct for typed errors of method [`CaseManagementAPI::update_priority`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
Expand Down Expand Up @@ -1685,6 +1693,158 @@ impl CaseManagementAPI {
}
}

/// Update case attributes
pub async fn update_attributes(
&self,
case_id: String,
body: crate::datadogV2::model::CaseUpdateAttributesRequest,
) -> Result<crate::datadogV2::model::CaseResponse, datadog::Error<UpdateAttributesError>> {
match self.update_attributes_with_http_info(case_id, body).await {
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
} else {
Err(datadog::Error::Serde(serde::de::Error::custom(
"response content was None",
)))
}
}
Err(err) => Err(err),
}
}

/// Update case attributes
pub async fn update_attributes_with_http_info(
&self,
case_id: String,
body: crate::datadogV2::model::CaseUpdateAttributesRequest,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::CaseResponse>,
datadog::Error<UpdateAttributesError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.update_attributes";

let local_client = &self.client;

let local_uri_str = format!(
"{}/api/v2/cases/{case_id}/attributes",
local_configuration.get_operation_host(operation_id),
case_id = datadog::urlencode(case_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::POST, local_uri_str.as_str());

// build headers
let mut headers = HeaderMap::new();
headers.insert("Content-Type", HeaderValue::from_static("application/json"));
headers.insert("Accept", HeaderValue::from_static("application/json"));

// build user agent
match HeaderValue::from_str(local_configuration.user_agent.as_str()) {
Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent),
Err(e) => {
log::warn!("Failed to parse user agent header: {e}, falling back to default");
headers.insert(
reqwest::header::USER_AGENT,
HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()),
)
}
};

// build auth
if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") {
headers.insert(
"DD-API-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-API-KEY header"),
);
};
if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") {
headers.insert(
"DD-APPLICATION-KEY",
HeaderValue::from_str(local_key.key.as_str())
.expect("failed to parse DD-APPLICATION-KEY header"),
);
};

// build body parameters
let output = Vec::new();
let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter);
if body.serialize(&mut ser).is_ok() {
if let Some(content_encoding) = headers.get("Content-Encoding") {
match content_encoding.to_str().unwrap_or_default() {
"gzip" => {
let mut enc = GzEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
"deflate" => {
let mut enc = ZlibEncoder::new(Vec::new(), Compression::default());
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
"zstd1" => {
let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap();
let _ = enc.write_all(ser.into_inner().as_slice());
match enc.finish() {
Ok(buf) => {
local_req_builder = local_req_builder.body(buf);
}
Err(e) => return Err(datadog::Error::Io(e)),
}
}
_ => {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}
} else {
local_req_builder = local_req_builder.body(ser.into_inner());
}
}

local_req_builder = local_req_builder.headers(headers);
let local_req = local_req_builder.build()?;
log::debug!("request content: {:?}", local_req.body());
let local_resp = local_client.execute(local_req).await?;

let local_status = local_resp.status();
let local_content = local_resp.text().await?;
log::debug!("response content: {}", local_content);

if !local_status.is_client_error() && !local_status.is_server_error() {
match serde_json::from_str::<crate::datadogV2::model::CaseResponse>(&local_content) {
Ok(e) => {
return Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: Some(e),
})
}
Err(e) => return Err(datadog::Error::Serde(e)),
};
} else {
let local_entity: Option<UpdateAttributesError> =
serde_json::from_str(&local_content).ok();
let local_error = datadog::ResponseContent {
status: local_status,
content: local_content,
entity: local_entity,
};
Err(datadog::Error::ResponseError(local_error))
}
}

/// Update case priority
pub async fn update_priority(
&self,
Expand Down
6 changes: 6 additions & 0 deletions src/datadogV2/model/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,12 @@ pub mod model_case_assign;
pub use self::model_case_assign::CaseAssign;
pub mod model_case_assign_attributes;
pub use self::model_case_assign_attributes::CaseAssignAttributes;
pub mod model_case_update_attributes_request;
pub use self::model_case_update_attributes_request::CaseUpdateAttributesRequest;
pub mod model_case_update_attributes;
pub use self::model_case_update_attributes::CaseUpdateAttributes;
pub mod model_case_update_attributes_attributes;
pub use self::model_case_update_attributes_attributes::CaseUpdateAttributesAttributes;
pub mod model_case_update_priority_request;
pub use self::model_case_update_priority_request::CaseUpdatePriorityRequest;
pub mod model_case_update_priority;
Expand Down
2 changes: 1 addition & 1 deletion src/datadogV2/model/model_case.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::fmt::{self, Formatter};
#[skip_serializing_none]
#[derive(Clone, Debug, PartialEq, Serialize)]
pub struct Case {
/// Case attributes
/// Case resource attributes
#[serde(rename = "attributes")]
pub attributes: crate::datadogV2::model::CaseAttributes,
/// Case's identifier
Expand Down
Loading
Loading