azure_devops/work_items/methods/update.rs
1use super::super::models::{JsonPatchOperation, WorkItem};
2use super::super::WorkItemsClient;
3use crate::constants::ApiPath;
4use crate::error::Result;
5
6impl WorkItemsClient<'_> {
7 /// Update an existing work item.
8 ///
9 /// # Arguments
10 ///
11 /// * `id` — The work item ID to update.
12 /// * `patch_document` — A slice of [`JsonPatchOperation`] describing the
13 /// fields to modify. Use [`JsonPatchOperation::replace()`] or
14 /// [`JsonPatchOperation::add()`] to build operations.
15 ///
16 /// # Returns
17 ///
18 /// The updated [`WorkItem`].
19 pub async fn update(&self, id: i64, patch_document: &[JsonPatchOperation]) -> Result<WorkItem> {
20 let body = crate::work_items::helpers::serialize_patch(patch_document)?;
21 let p = ApiPath::work_item(id);
22 self.http.patch_json_patch(&p, &[], &body).await
23 }
24}