Skip to main content

azure_devops/work_items/methods/
create_with_options.rs

1use super::super::models::{JsonPatchOperation, WorkItem};
2use super::super::options::CreateWorkItemOptions;
3use super::super::WorkItemsClient;
4use crate::constants::ApiPath;
5use crate::error::Result;
6
7impl WorkItemsClient<'_> {
8    /// Create a new work item with additional options.
9    ///
10    /// # Arguments
11    ///
12    /// * `project` — The project name.
13    /// * `work_item_type` — The work item type (e.g., `"Bug"`).
14    /// * `patch_document` — A slice of [`JsonPatchOperation`] describing the fields.
15    /// * `options` — [`CreateWorkItemOptions`] for validation, rule bypass, and notifications.
16    ///
17    /// # Returns
18    ///
19    /// The newly created [`WorkItem`].
20    pub async fn create_with_options(
21        &self,
22        project: &str,
23        work_item_type: &str,
24        patch_document: &[JsonPatchOperation],
25        options: &CreateWorkItemOptions,
26    ) -> Result<WorkItem> {
27        let qp = options.to_query_params();
28        let q = crate::util::ref_query(&qp);
29        let body = crate::work_items::helpers::serialize_patch(patch_document)?;
30        let p = ApiPath::work_item_create(project, work_item_type);
31        self.http.post_json_patch(&p, &q, &body).await
32    }
33}