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
29 changes: 29 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60000,6 +60000,35 @@ paths:
tags:
- Error Tracking
/api/v2/error-tracking/issues/{issue_id}/assignee:
delete:
description: Remove the assignee of an issue by `issue_id`.
operationId: DeleteIssueAssignee
parameters:
- $ref: '#/components/parameters/IssueIDPathParameter'
responses:
'204':
description: No Content
'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:
- error_tracking_read
- error_tracking_write
- cases_read
- cases_write
summary: Remove the assignee of an issue
tags:
- Error Tracking
put:
description: Update the assignee of an issue by `issue_id`.
operationId: UpdateIssueAssignee
Expand Down
4 changes: 2 additions & 2 deletions LICENSE-3rdparty.csv
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ native-tls,https://github.com/sfackler/rust-native-tls,MIT OR Apache-2.0,Steven
num-conv,https://github.com/jhpratt/num-conv,MIT OR Apache-2.0,Jacob Pratt <[email protected]>
num-traits,https://github.com/rust-num/num-traits,MIT OR Apache-2.0,The Rust Project Developers
once_cell,https://github.com/matklad/once_cell,MIT OR Apache-2.0,Aleksey Kladov <[email protected]>
openssl,https://github.com/sfackler/rust-openssl,Apache-2.0,Steven Fackler <[email protected]>
openssl,https://github.com/rust-openssl/rust-openssl,Apache-2.0,Steven Fackler <[email protected]>
openssl-macros,https://github.com/sfackler/rust-openssl,MIT OR Apache-2.0,The openssl-macros Authors
openssl-probe,https://github.com/alexcrichton/openssl-probe,MIT OR Apache-2.0,Alex Crichton <[email protected]>
openssl-sys,https://github.com/sfackler/rust-openssl,MIT,"Alex Crichton <[email protected]>, Steven Fackler <[email protected]>"
openssl-sys,https://github.com/rust-openssl/rust-openssl,MIT,"Alex Crichton <[email protected]>, Steven Fackler <[email protected]>"
parking_lot,https://github.com/Amanieu/parking_lot,Apache-2.0 OR MIT,Amanieu d'Antras <[email protected]>
parking_lot_core,https://github.com/Amanieu/parking_lot,Apache-2.0 OR MIT,Amanieu d'Antras <[email protected]>
percent-encoding,https://github.com/servo/rust-url,MIT OR Apache-2.0,The rust-url developers
Expand Down
17 changes: 17 additions & 0 deletions examples/v2_error-tracking_DeleteIssueAssignee.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Remove the assignee of an issue returns "No Content" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_error_tracking::ErrorTrackingAPI;

#[tokio::main]
async fn main() {
// there is a valid "issue" in the system
let issue_id = std::env::var("ISSUE_ID").unwrap();
let configuration = datadog::Configuration::new();
let api = ErrorTrackingAPI::with_config(configuration);
let resp = api.delete_issue_assignee(issue_id.clone()).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
96 changes: 96 additions & 0 deletions src/datadogV2/api/api_error_tracking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ impl SearchIssuesOptionalParams {
}
}

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

/// GetIssueError is a struct for typed errors of method [`ErrorTrackingAPI::get_issue`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
Expand Down Expand Up @@ -145,6 +153,94 @@ impl ErrorTrackingAPI {
Self { config, client }
}

/// Remove the assignee of an issue by `issue_id`.
pub async fn delete_issue_assignee(
&self,
issue_id: String,
) -> Result<(), datadog::Error<DeleteIssueAssigneeError>> {
match self.delete_issue_assignee_with_http_info(issue_id).await {
Ok(_) => Ok(()),
Err(err) => Err(err),
}
}

/// Remove the assignee of an issue by `issue_id`.
pub async fn delete_issue_assignee_with_http_info(
&self,
issue_id: String,
) -> Result<datadog::ResponseContent<()>, datadog::Error<DeleteIssueAssigneeError>> {
let local_configuration = &self.config;
let operation_id = "v2.delete_issue_assignee";

let local_client = &self.client;

let local_uri_str = format!(
"{}/api/v2/error-tracking/issues/{issue_id}/assignee",
local_configuration.get_operation_host(operation_id),
issue_id = datadog::urlencode(issue_id)
);
let mut local_req_builder =
local_client.request(reqwest::Method::DELETE, local_uri_str.as_str());

// build headers
let mut headers = HeaderMap::new();
headers.insert("Accept", HeaderValue::from_static("*/*"));

// 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"),
);
};

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() {
Ok(datadog::ResponseContent {
status: local_status,
content: local_content,
entity: None,
})
} else {
let local_entity: Option<DeleteIssueAssigneeError> =
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))
}
}

/// Retrieve the full details for a specific error tracking issue, including attributes and relationships.
pub async fn get_issue(
&self,
Expand Down
22 changes: 22 additions & 0 deletions tests/scenarios/features/v2/error_tracking.feature
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,28 @@ Feature: Error Tracking
Then the response status is 200 OK
And the response "data.id" is equal to "{{ issue.id }}"

@generated @skip @team:DataDog/error-tracking
Scenario: Remove the assignee of an issue returns "Bad Request" response
Given new "DeleteIssueAssignee" request
And request contains "issue_id" parameter from "REPLACE.ME"
When the request is sent
Then the response status is 400 Bad Request

@team:DataDog/error-tracking
Scenario: Remove the assignee of an issue returns "No Content" response
Given new "DeleteIssueAssignee" request
And there is a valid "issue" in the system
And request contains "issue_id" parameter from "issue.id"
When the request is sent
Then the response status is 204 No Content

@team:DataDog/error-tracking
Scenario: Remove the assignee of an issue returns "Not Found" response
Given new "DeleteIssueAssignee" request
And request contains "issue_id" parameter with value "67d80aa3-36ff-44b9-a694-c501a7591737"
When the request is sent
Then the response status is 404 Not Found

@team:DataDog/error-tracking
Scenario: Search error tracking issues returns "Bad Request" response
Given new "SearchIssues" request
Expand Down
6 changes: 6 additions & 0 deletions tests/scenarios/features/v2/undo.json
Original file line number Diff line number Diff line change
Expand Up @@ -1241,6 +1241,12 @@
"type": "safe"
}
},
"DeleteIssueAssignee": {
"tag": "Error Tracking",
"undo": {
"type": "idempotent"
}
},
"UpdateIssueAssignee": {
"tag": "Error Tracking",
"undo": {
Expand Down
29 changes: 29 additions & 0 deletions tests/scenarios/function_mappings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2770,6 +2770,10 @@ pub fn collect_function_calls(world: &mut DatadogWorld) {
world
.function_mappings
.insert("v2.GetIssue".into(), test_v2_get_issue);
world.function_mappings.insert(
"v2.DeleteIssueAssignee".into(),
test_v2_delete_issue_assignee,
);
world.function_mappings.insert(
"v2.UpdateIssueAssignee".into(),
test_v2_update_issue_assignee,
Expand Down Expand Up @@ -20515,6 +20519,31 @@ fn test_v2_get_issue(world: &mut DatadogWorld, _parameters: &HashMap<String, Val
world.response.code = response.status.as_u16();
}

fn test_v2_delete_issue_assignee(world: &mut DatadogWorld, _parameters: &HashMap<String, Value>) {
let api = world
.api_instances
.v2_api_error_tracking
.as_ref()
.expect("api instance not found");
let issue_id = serde_json::from_value(_parameters.get("issue_id").unwrap().clone()).unwrap();
let response = match block_on(api.delete_issue_assignee_with_http_info(issue_id)) {
Ok(response) => response,
Err(error) => {
return match error {
Error::ResponseError(e) => {
world.response.code = e.status.as_u16();
if let Some(entity) = e.entity {
world.response.object = serde_json::to_value(entity).unwrap();
}
}
_ => panic!("error parsing response: {error}"),
};
}
};
world.response.object = serde_json::to_value(response.entity).unwrap();
world.response.code = response.status.as_u16();
}

fn test_v2_update_issue_assignee(world: &mut DatadogWorld, _parameters: &HashMap<String, Value>) {
let api = world
.api_instances
Expand Down
Loading