Skip to main content

lineark_sdk/generated/
mutations.rs

1//! Generated mutation functions.
2//!
3//! Each mutation is exposed as a standalone async function. The
4//! [`Client`] re-exports these as methods for convenience.
5//!
6//! Generated by lineark-codegen — do not edit.
7#![allow(clippy::too_many_arguments)]
8use super::inputs::*;
9use crate::client::Client;
10use crate::error::LinearError;
11/// XHR request payload to upload an images, video and other attachments directly to Linear's cloud storage.
12pub async fn file_upload(
13    client: &Client,
14    meta_data: Option<serde_json::Value>,
15    make_public: Option<bool>,
16    size: i64,
17    content_type: String,
18    filename: String,
19) -> Result<serde_json::Value, LinearError> {
20    let variables = serde_json::json!(
21        { "metaData" : meta_data, "makePublic" : make_public, "size" : size,
22        "contentType" : content_type, "filename" : filename }
23    );
24    let mut response_parts: Vec<String> = vec!["success".to_string()];
25    response_parts.push(format!(
26        "{} {{ {} }}",
27        "uploadFile",
28        <super::types::UploadFile as crate::field_selection::GraphQLFields>::selection()
29    ));
30    let query = String::from(
31        "mutation FileUpload($metaData: JSON, $makePublic: Boolean, $size: Int!, $contentType: String!, $filename: String!) { fileUpload(metaData: $metaData, makePublic: $makePublic, size: $size, contentType: $contentType, filename: $filename) { ",
32    ) + &response_parts.join(" ") + " } }";
33    client
34        .execute::<serde_json::Value>(&query, variables, "fileUpload")
35        .await
36}
37/// Upload an image from an URL to Linear.
38pub async fn image_upload_from_url(
39    client: &Client,
40    url: String,
41) -> Result<serde_json::Value, LinearError> {
42    let variables = serde_json::json!({ "url" : url });
43    let response_parts: Vec<String> = vec!["url".to_string(), "success".to_string()];
44    let query = String::from(
45        "mutation ImageUploadFromUrl($url: String!) { imageUploadFromUrl(url: $url) { ",
46    ) + &response_parts.join(" ")
47        + " } }";
48    client
49        .execute::<serde_json::Value>(&query, variables, "imageUploadFromUrl")
50        .await
51}
52/// Creates a new comment.
53///
54/// Full type: [`Comment`](super::types::Comment)
55pub async fn comment_create<
56    T: serde::de::DeserializeOwned
57        + crate::field_selection::GraphQLFields<FullType = super::types::Comment>,
58>(
59    client: &Client,
60    input: CommentCreateInput,
61) -> Result<T, LinearError> {
62    let variables = serde_json::json!({ "input" : input });
63    let query = String::from(
64        "mutation CommentCreate($input: CommentCreateInput!) { commentCreate(input: $input) { success comment { ",
65    ) + &T::selection() + " } } }";
66    client
67        .execute_mutation::<T>(&query, variables, "commentCreate", "comment")
68        .await
69}
70/// Creates a new project.
71///
72/// Full type: [`Project`](super::types::Project)
73pub async fn project_create<
74    T: serde::de::DeserializeOwned
75        + crate::field_selection::GraphQLFields<FullType = super::types::Project>,
76>(
77    client: &Client,
78    slack_channel_name: Option<String>,
79    input: ProjectCreateInput,
80) -> Result<T, LinearError> {
81    let variables = serde_json::json!(
82        { "slackChannelName" : slack_channel_name, "input" : input }
83    );
84    let query = String::from(
85        "mutation ProjectCreate($slackChannelName: String, $input: ProjectCreateInput!) { projectCreate(slackChannelName: $slackChannelName, input: $input) { success project { ",
86    ) + &T::selection() + " } } }";
87    client
88        .execute_mutation::<T>(&query, variables, "projectCreate", "project")
89        .await
90}
91/// Updates a project.
92///
93/// Full type: [`Project`](super::types::Project)
94pub async fn project_update<
95    T: serde::de::DeserializeOwned
96        + crate::field_selection::GraphQLFields<FullType = super::types::Project>,
97>(
98    client: &Client,
99    input: ProjectUpdateInput,
100    id: String,
101) -> Result<T, LinearError> {
102    let variables = serde_json::json!({ "input" : input, "id" : id });
103    let query = String::from(
104        "mutation ProjectUpdate($input: ProjectUpdateInput!, $id: String!) { projectUpdate(input: $input, id: $id) { success project { ",
105    ) + &T::selection() + " } } }";
106    client
107        .execute_mutation::<T>(&query, variables, "projectUpdate", "project")
108        .await
109}
110/// Deletes (trashes) a project.
111///
112/// Full type: [`Project`](super::types::Project)
113pub async fn project_delete<
114    T: serde::de::DeserializeOwned
115        + crate::field_selection::GraphQLFields<FullType = super::types::Project>,
116>(
117    client: &Client,
118    id: String,
119) -> Result<T, LinearError> {
120    let variables = serde_json::json!({ "id" : id });
121    let query = String::from(
122        "mutation ProjectDelete($id: String!) { projectDelete(id: $id) { success entity { ",
123    ) + &T::selection()
124        + " } } }";
125    client
126        .execute_mutation::<T>(&query, variables, "projectDelete", "entity")
127        .await
128}
129/// Creates a new project milestone.
130///
131/// Full type: [`ProjectMilestone`](super::types::ProjectMilestone)
132pub async fn project_milestone_create<
133    T: serde::de::DeserializeOwned
134        + crate::field_selection::GraphQLFields<FullType = super::types::ProjectMilestone>,
135>(
136    client: &Client,
137    input: ProjectMilestoneCreateInput,
138) -> Result<T, LinearError> {
139    let variables = serde_json::json!({ "input" : input });
140    let query = String::from(
141        "mutation ProjectMilestoneCreate($input: ProjectMilestoneCreateInput!) { projectMilestoneCreate(input: $input) { success projectMilestone { ",
142    ) + &T::selection() + " } } }";
143    client
144        .execute_mutation::<T>(
145            &query,
146            variables,
147            "projectMilestoneCreate",
148            "projectMilestone",
149        )
150        .await
151}
152/// Updates a project milestone.
153///
154/// Full type: [`ProjectMilestone`](super::types::ProjectMilestone)
155pub async fn project_milestone_update<
156    T: serde::de::DeserializeOwned
157        + crate::field_selection::GraphQLFields<FullType = super::types::ProjectMilestone>,
158>(
159    client: &Client,
160    input: ProjectMilestoneUpdateInput,
161    id: String,
162) -> Result<T, LinearError> {
163    let variables = serde_json::json!({ "input" : input, "id" : id });
164    let query = String::from(
165        "mutation ProjectMilestoneUpdate($input: ProjectMilestoneUpdateInput!, $id: String!) { projectMilestoneUpdate(input: $input, id: $id) { success projectMilestone { ",
166    ) + &T::selection() + " } } }";
167    client
168        .execute_mutation::<T>(
169            &query,
170            variables,
171            "projectMilestoneUpdate",
172            "projectMilestone",
173        )
174        .await
175}
176/// Deletes a project milestone.
177pub async fn project_milestone_delete(
178    client: &Client,
179    id: String,
180) -> Result<serde_json::Value, LinearError> {
181    let variables = serde_json::json!({ "id" : id });
182    let response_parts: Vec<String> = vec!["success".to_string(), "entityId".to_string()];
183    let query = String::from(
184        "mutation ProjectMilestoneDelete($id: String!) { projectMilestoneDelete(id: $id) { ",
185    ) + &response_parts.join(" ")
186        + " } }";
187    client
188        .execute::<serde_json::Value>(&query, variables, "projectMilestoneDelete")
189        .await
190}
191/// Creates a new issue.
192///
193/// Full type: [`Issue`](super::types::Issue)
194pub async fn issue_create<
195    T: serde::de::DeserializeOwned
196        + crate::field_selection::GraphQLFields<FullType = super::types::Issue>,
197>(
198    client: &Client,
199    input: IssueCreateInput,
200) -> Result<T, LinearError> {
201    let variables = serde_json::json!({ "input" : input });
202    let query = String::from(
203        "mutation IssueCreate($input: IssueCreateInput!) { issueCreate(input: $input) { success issue { ",
204    ) + &T::selection() + " } } }";
205    client
206        .execute_mutation::<T>(&query, variables, "issueCreate", "issue")
207        .await
208}
209/// Updates an issue.
210///
211/// Full type: [`Issue`](super::types::Issue)
212pub async fn issue_update<
213    T: serde::de::DeserializeOwned
214        + crate::field_selection::GraphQLFields<FullType = super::types::Issue>,
215>(
216    client: &Client,
217    input: IssueUpdateInput,
218    id: String,
219) -> Result<T, LinearError> {
220    let variables = serde_json::json!({ "input" : input, "id" : id });
221    let query = String::from(
222        "mutation IssueUpdate($input: IssueUpdateInput!, $id: String!) { issueUpdate(input: $input, id: $id) { success issue { ",
223    ) + &T::selection() + " } } }";
224    client
225        .execute_mutation::<T>(&query, variables, "issueUpdate", "issue")
226        .await
227}
228/// Archives an issue.
229///
230/// Full type: [`Issue`](super::types::Issue)
231pub async fn issue_archive<
232    T: serde::de::DeserializeOwned
233        + crate::field_selection::GraphQLFields<FullType = super::types::Issue>,
234>(
235    client: &Client,
236    trash: Option<bool>,
237    id: String,
238) -> Result<T, LinearError> {
239    let variables = serde_json::json!({ "trash" : trash, "id" : id });
240    let query = String::from(
241        "mutation IssueArchive($trash: Boolean, $id: String!) { issueArchive(trash: $trash, id: $id) { success entity { ",
242    ) + &T::selection() + " } } }";
243    client
244        .execute_mutation::<T>(&query, variables, "issueArchive", "entity")
245        .await
246}
247/// Unarchives an issue.
248///
249/// Full type: [`Issue`](super::types::Issue)
250pub async fn issue_unarchive<
251    T: serde::de::DeserializeOwned
252        + crate::field_selection::GraphQLFields<FullType = super::types::Issue>,
253>(
254    client: &Client,
255    id: String,
256) -> Result<T, LinearError> {
257    let variables = serde_json::json!({ "id" : id });
258    let query = String::from(
259        "mutation IssueUnarchive($id: String!) { issueUnarchive(id: $id) { success entity { ",
260    ) + &T::selection()
261        + " } } }";
262    client
263        .execute_mutation::<T>(&query, variables, "issueUnarchive", "entity")
264        .await
265}
266/// Deletes (trashes) an issue.
267///
268/// Full type: [`Issue`](super::types::Issue)
269pub async fn issue_delete<
270    T: serde::de::DeserializeOwned
271        + crate::field_selection::GraphQLFields<FullType = super::types::Issue>,
272>(
273    client: &Client,
274    permanently_delete: Option<bool>,
275    id: String,
276) -> Result<T, LinearError> {
277    let variables = serde_json::json!(
278        { "permanentlyDelete" : permanently_delete, "id" : id }
279    );
280    let query = String::from(
281        "mutation IssueDelete($permanentlyDelete: Boolean, $id: String!) { issueDelete(permanentlyDelete: $permanentlyDelete, id: $id) { success entity { ",
282    ) + &T::selection() + " } } }";
283    client
284        .execute_mutation::<T>(&query, variables, "issueDelete", "entity")
285        .await
286}
287/// Creates a new issue relation.
288///
289/// Full type: [`IssueRelation`](super::types::IssueRelation)
290pub async fn issue_relation_create<
291    T: serde::de::DeserializeOwned
292        + crate::field_selection::GraphQLFields<FullType = super::types::IssueRelation>,
293>(
294    client: &Client,
295    override_created_at: Option<serde_json::Value>,
296    input: IssueRelationCreateInput,
297) -> Result<T, LinearError> {
298    let variables = serde_json::json!(
299        { "overrideCreatedAt" : override_created_at, "input" : input }
300    );
301    let query = String::from(
302        "mutation IssueRelationCreate($overrideCreatedAt: DateTime, $input: IssueRelationCreateInput!) { issueRelationCreate(overrideCreatedAt: $overrideCreatedAt, input: $input) { success issueRelation { ",
303    ) + &T::selection() + " } } }";
304    client
305        .execute_mutation::<T>(&query, variables, "issueRelationCreate", "issueRelation")
306        .await
307}
308/// Creates a new document.
309///
310/// Full type: [`Document`](super::types::Document)
311pub async fn document_create<
312    T: serde::de::DeserializeOwned
313        + crate::field_selection::GraphQLFields<FullType = super::types::Document>,
314>(
315    client: &Client,
316    input: DocumentCreateInput,
317) -> Result<T, LinearError> {
318    let variables = serde_json::json!({ "input" : input });
319    let query = String::from(
320        "mutation DocumentCreate($input: DocumentCreateInput!) { documentCreate(input: $input) { success document { ",
321    ) + &T::selection() + " } } }";
322    client
323        .execute_mutation::<T>(&query, variables, "documentCreate", "document")
324        .await
325}
326/// Updates a document.
327///
328/// Full type: [`Document`](super::types::Document)
329pub async fn document_update<
330    T: serde::de::DeserializeOwned
331        + crate::field_selection::GraphQLFields<FullType = super::types::Document>,
332>(
333    client: &Client,
334    input: DocumentUpdateInput,
335    id: String,
336) -> Result<T, LinearError> {
337    let variables = serde_json::json!({ "input" : input, "id" : id });
338    let query = String::from(
339        "mutation DocumentUpdate($input: DocumentUpdateInput!, $id: String!) { documentUpdate(input: $input, id: $id) { success document { ",
340    ) + &T::selection() + " } } }";
341    client
342        .execute_mutation::<T>(&query, variables, "documentUpdate", "document")
343        .await
344}
345/// Deletes (trashes) a document.
346///
347/// Full type: [`Document`](super::types::Document)
348pub async fn document_delete<
349    T: serde::de::DeserializeOwned
350        + crate::field_selection::GraphQLFields<FullType = super::types::Document>,
351>(
352    client: &Client,
353    id: String,
354) -> Result<T, LinearError> {
355    let variables = serde_json::json!({ "id" : id });
356    let query = String::from(
357        "mutation DocumentDelete($id: String!) { documentDelete(id: $id) { success entity { ",
358    ) + &T::selection()
359        + " } } }";
360    client
361        .execute_mutation::<T>(&query, variables, "documentDelete", "entity")
362        .await
363}