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/// Deletes a comment.
71pub async fn comment_delete(client: &Client, id: String) -> Result<serde_json::Value, LinearError> {
72    let variables = serde_json::json!({ "id" : id });
73    let response_parts: Vec<String> = vec!["success".to_string(), "entityId".to_string()];
74    let query = String::from("mutation CommentDelete($id: String!) { commentDelete(id: $id) { ")
75        + &response_parts.join(" ")
76        + " } }";
77    client
78        .execute::<serde_json::Value>(&query, variables, "commentDelete")
79        .await
80}
81/// Creates a new project.
82///
83/// Full type: [`Project`](super::types::Project)
84pub async fn project_create<
85    T: serde::de::DeserializeOwned
86        + crate::field_selection::GraphQLFields<FullType = super::types::Project>,
87>(
88    client: &Client,
89    slack_channel_name: Option<String>,
90    input: ProjectCreateInput,
91) -> Result<T, LinearError> {
92    let variables = serde_json::json!(
93        { "slackChannelName" : slack_channel_name, "input" : input }
94    );
95    let query = String::from(
96        "mutation ProjectCreate($slackChannelName: String, $input: ProjectCreateInput!) { projectCreate(slackChannelName: $slackChannelName, input: $input) { success project { ",
97    ) + &T::selection() + " } } }";
98    client
99        .execute_mutation::<T>(&query, variables, "projectCreate", "project")
100        .await
101}
102/// Updates a project.
103///
104/// Full type: [`Project`](super::types::Project)
105pub async fn project_update<
106    T: serde::de::DeserializeOwned
107        + crate::field_selection::GraphQLFields<FullType = super::types::Project>,
108>(
109    client: &Client,
110    input: ProjectUpdateInput,
111    id: String,
112) -> Result<T, LinearError> {
113    let variables = serde_json::json!({ "input" : input, "id" : id });
114    let query = String::from(
115        "mutation ProjectUpdate($input: ProjectUpdateInput!, $id: String!) { projectUpdate(input: $input, id: $id) { success project { ",
116    ) + &T::selection() + " } } }";
117    client
118        .execute_mutation::<T>(&query, variables, "projectUpdate", "project")
119        .await
120}
121/// Deletes (trashes) a project.
122///
123/// Full type: [`Project`](super::types::Project)
124pub async fn project_delete<
125    T: serde::de::DeserializeOwned
126        + crate::field_selection::GraphQLFields<FullType = super::types::Project>,
127>(
128    client: &Client,
129    id: String,
130) -> Result<T, LinearError> {
131    let variables = serde_json::json!({ "id" : id });
132    let query = String::from(
133        "mutation ProjectDelete($id: String!) { projectDelete(id: $id) { success entity { ",
134    ) + &T::selection()
135        + " } } }";
136    client
137        .execute_mutation::<T>(&query, variables, "projectDelete", "entity")
138        .await
139}
140/// Creates a new team. The user who creates the team will automatically be added as a member to the newly created team.
141///
142/// Full type: [`Team`](super::types::Team)
143pub async fn team_create<
144    T: serde::de::DeserializeOwned
145        + crate::field_selection::GraphQLFields<FullType = super::types::Team>,
146>(
147    client: &Client,
148    copy_settings_from_team_id: Option<String>,
149    input: TeamCreateInput,
150) -> Result<T, LinearError> {
151    let variables = serde_json::json!(
152        { "copySettingsFromTeamId" : copy_settings_from_team_id, "input" : input }
153    );
154    let query = String::from(
155        "mutation TeamCreate($copySettingsFromTeamId: String, $input: TeamCreateInput!) { teamCreate(copySettingsFromTeamId: $copySettingsFromTeamId, input: $input) { success team { ",
156    ) + &T::selection() + " } } }";
157    client
158        .execute_mutation::<T>(&query, variables, "teamCreate", "team")
159        .await
160}
161/// Updates a team.
162///
163/// Full type: [`Team`](super::types::Team)
164pub async fn team_update<
165    T: serde::de::DeserializeOwned
166        + crate::field_selection::GraphQLFields<FullType = super::types::Team>,
167>(
168    client: &Client,
169    mapping: Option<InheritanceEntityMapping>,
170    input: TeamUpdateInput,
171    id: String,
172) -> Result<T, LinearError> {
173    let variables = serde_json::json!(
174        { "mapping" : mapping, "input" : input, "id" : id }
175    );
176    let query = String::from(
177        "mutation TeamUpdate($mapping: InheritanceEntityMapping, $input: TeamUpdateInput!, $id: String!) { teamUpdate(mapping: $mapping, input: $input, id: $id) { success team { ",
178    ) + &T::selection() + " } } }";
179    client
180        .execute_mutation::<T>(&query, variables, "teamUpdate", "team")
181        .await
182}
183/// Deletes a team.
184pub async fn team_delete(client: &Client, id: String) -> Result<serde_json::Value, LinearError> {
185    let variables = serde_json::json!({ "id" : id });
186    let response_parts: Vec<String> = vec!["success".to_string(), "entityId".to_string()];
187    let query = String::from("mutation TeamDelete($id: String!) { teamDelete(id: $id) { ")
188        + &response_parts.join(" ")
189        + " } }";
190    client
191        .execute::<serde_json::Value>(&query, variables, "teamDelete")
192        .await
193}
194/// Creates a new team membership.
195///
196/// Full type: [`TeamMembership`](super::types::TeamMembership)
197pub async fn team_membership_create<
198    T: serde::de::DeserializeOwned
199        + crate::field_selection::GraphQLFields<FullType = super::types::TeamMembership>,
200>(
201    client: &Client,
202    input: TeamMembershipCreateInput,
203) -> Result<T, LinearError> {
204    let variables = serde_json::json!({ "input" : input });
205    let query = String::from(
206        "mutation TeamMembershipCreate($input: TeamMembershipCreateInput!) { teamMembershipCreate(input: $input) { success teamMembership { ",
207    ) + &T::selection() + " } } }";
208    client
209        .execute_mutation::<T>(&query, variables, "teamMembershipCreate", "teamMembership")
210        .await
211}
212/// Deletes a team membership.
213pub async fn team_membership_delete(
214    client: &Client,
215    also_leave_parent_teams: Option<bool>,
216    id: String,
217) -> Result<serde_json::Value, LinearError> {
218    let variables = serde_json::json!(
219        { "alsoLeaveParentTeams" : also_leave_parent_teams, "id" : id }
220    );
221    let response_parts: Vec<String> = vec!["success".to_string(), "entityId".to_string()];
222    let query = String::from(
223        "mutation TeamMembershipDelete($alsoLeaveParentTeams: Boolean, $id: String!) { teamMembershipDelete(alsoLeaveParentTeams: $alsoLeaveParentTeams, id: $id) { ",
224    ) + &response_parts.join(" ") + " } }";
225    client
226        .execute::<serde_json::Value>(&query, variables, "teamMembershipDelete")
227        .await
228}
229/// Creates a new project milestone.
230///
231/// Full type: [`ProjectMilestone`](super::types::ProjectMilestone)
232pub async fn project_milestone_create<
233    T: serde::de::DeserializeOwned
234        + crate::field_selection::GraphQLFields<FullType = super::types::ProjectMilestone>,
235>(
236    client: &Client,
237    input: ProjectMilestoneCreateInput,
238) -> Result<T, LinearError> {
239    let variables = serde_json::json!({ "input" : input });
240    let query = String::from(
241        "mutation ProjectMilestoneCreate($input: ProjectMilestoneCreateInput!) { projectMilestoneCreate(input: $input) { success projectMilestone { ",
242    ) + &T::selection() + " } } }";
243    client
244        .execute_mutation::<T>(
245            &query,
246            variables,
247            "projectMilestoneCreate",
248            "projectMilestone",
249        )
250        .await
251}
252/// Updates a project milestone.
253///
254/// Full type: [`ProjectMilestone`](super::types::ProjectMilestone)
255pub async fn project_milestone_update<
256    T: serde::de::DeserializeOwned
257        + crate::field_selection::GraphQLFields<FullType = super::types::ProjectMilestone>,
258>(
259    client: &Client,
260    input: ProjectMilestoneUpdateInput,
261    id: String,
262) -> Result<T, LinearError> {
263    let variables = serde_json::json!({ "input" : input, "id" : id });
264    let query = String::from(
265        "mutation ProjectMilestoneUpdate($input: ProjectMilestoneUpdateInput!, $id: String!) { projectMilestoneUpdate(input: $input, id: $id) { success projectMilestone { ",
266    ) + &T::selection() + " } } }";
267    client
268        .execute_mutation::<T>(
269            &query,
270            variables,
271            "projectMilestoneUpdate",
272            "projectMilestone",
273        )
274        .await
275}
276/// Deletes a project milestone.
277pub async fn project_milestone_delete(
278    client: &Client,
279    id: String,
280) -> Result<serde_json::Value, LinearError> {
281    let variables = serde_json::json!({ "id" : id });
282    let response_parts: Vec<String> = vec!["success".to_string(), "entityId".to_string()];
283    let query = String::from(
284        "mutation ProjectMilestoneDelete($id: String!) { projectMilestoneDelete(id: $id) { ",
285    ) + &response_parts.join(" ")
286        + " } }";
287    client
288        .execute::<serde_json::Value>(&query, variables, "projectMilestoneDelete")
289        .await
290}
291/// Creates a new issue.
292///
293/// Full type: [`Issue`](super::types::Issue)
294pub async fn issue_create<
295    T: serde::de::DeserializeOwned
296        + crate::field_selection::GraphQLFields<FullType = super::types::Issue>,
297>(
298    client: &Client,
299    input: IssueCreateInput,
300) -> Result<T, LinearError> {
301    let variables = serde_json::json!({ "input" : input });
302    let query = String::from(
303        "mutation IssueCreate($input: IssueCreateInput!) { issueCreate(input: $input) { success issue { ",
304    ) + &T::selection() + " } } }";
305    client
306        .execute_mutation::<T>(&query, variables, "issueCreate", "issue")
307        .await
308}
309/// Updates an issue.
310///
311/// Full type: [`Issue`](super::types::Issue)
312pub async fn issue_update<
313    T: serde::de::DeserializeOwned
314        + crate::field_selection::GraphQLFields<FullType = super::types::Issue>,
315>(
316    client: &Client,
317    input: IssueUpdateInput,
318    id: String,
319) -> Result<T, LinearError> {
320    let variables = serde_json::json!({ "input" : input, "id" : id });
321    let query = String::from(
322        "mutation IssueUpdate($input: IssueUpdateInput!, $id: String!) { issueUpdate(input: $input, id: $id) { success issue { ",
323    ) + &T::selection() + " } } }";
324    client
325        .execute_mutation::<T>(&query, variables, "issueUpdate", "issue")
326        .await
327}
328/// Archives an issue.
329///
330/// Full type: [`Issue`](super::types::Issue)
331pub async fn issue_archive<
332    T: serde::de::DeserializeOwned
333        + crate::field_selection::GraphQLFields<FullType = super::types::Issue>,
334>(
335    client: &Client,
336    trash: Option<bool>,
337    id: String,
338) -> Result<T, LinearError> {
339    let variables = serde_json::json!({ "trash" : trash, "id" : id });
340    let query = String::from(
341        "mutation IssueArchive($trash: Boolean, $id: String!) { issueArchive(trash: $trash, id: $id) { success entity { ",
342    ) + &T::selection() + " } } }";
343    client
344        .execute_mutation::<T>(&query, variables, "issueArchive", "entity")
345        .await
346}
347/// Unarchives an issue.
348///
349/// Full type: [`Issue`](super::types::Issue)
350pub async fn issue_unarchive<
351    T: serde::de::DeserializeOwned
352        + crate::field_selection::GraphQLFields<FullType = super::types::Issue>,
353>(
354    client: &Client,
355    id: String,
356) -> Result<T, LinearError> {
357    let variables = serde_json::json!({ "id" : id });
358    let query = String::from(
359        "mutation IssueUnarchive($id: String!) { issueUnarchive(id: $id) { success entity { ",
360    ) + &T::selection()
361        + " } } }";
362    client
363        .execute_mutation::<T>(&query, variables, "issueUnarchive", "entity")
364        .await
365}
366/// Deletes (trashes) an issue.
367///
368/// Full type: [`Issue`](super::types::Issue)
369pub async fn issue_delete<
370    T: serde::de::DeserializeOwned
371        + crate::field_selection::GraphQLFields<FullType = super::types::Issue>,
372>(
373    client: &Client,
374    permanently_delete: Option<bool>,
375    id: String,
376) -> Result<T, LinearError> {
377    let variables = serde_json::json!(
378        { "permanentlyDelete" : permanently_delete, "id" : id }
379    );
380    let query = String::from(
381        "mutation IssueDelete($permanentlyDelete: Boolean, $id: String!) { issueDelete(permanentlyDelete: $permanentlyDelete, id: $id) { success entity { ",
382    ) + &T::selection() + " } } }";
383    client
384        .execute_mutation::<T>(&query, variables, "issueDelete", "entity")
385        .await
386}
387/// Creates a new issue relation.
388///
389/// Full type: [`IssueRelation`](super::types::IssueRelation)
390pub async fn issue_relation_create<
391    T: serde::de::DeserializeOwned
392        + crate::field_selection::GraphQLFields<FullType = super::types::IssueRelation>,
393>(
394    client: &Client,
395    override_created_at: Option<serde_json::Value>,
396    input: IssueRelationCreateInput,
397) -> Result<T, LinearError> {
398    let variables = serde_json::json!(
399        { "overrideCreatedAt" : override_created_at, "input" : input }
400    );
401    let query = String::from(
402        "mutation IssueRelationCreate($overrideCreatedAt: DateTime, $input: IssueRelationCreateInput!) { issueRelationCreate(overrideCreatedAt: $overrideCreatedAt, input: $input) { success issueRelation { ",
403    ) + &T::selection() + " } } }";
404    client
405        .execute_mutation::<T>(&query, variables, "issueRelationCreate", "issueRelation")
406        .await
407}
408/// Creates a new document.
409///
410/// Full type: [`Document`](super::types::Document)
411pub async fn document_create<
412    T: serde::de::DeserializeOwned
413        + crate::field_selection::GraphQLFields<FullType = super::types::Document>,
414>(
415    client: &Client,
416    input: DocumentCreateInput,
417) -> Result<T, LinearError> {
418    let variables = serde_json::json!({ "input" : input });
419    let query = String::from(
420        "mutation DocumentCreate($input: DocumentCreateInput!) { documentCreate(input: $input) { success document { ",
421    ) + &T::selection() + " } } }";
422    client
423        .execute_mutation::<T>(&query, variables, "documentCreate", "document")
424        .await
425}
426/// Updates a document.
427///
428/// Full type: [`Document`](super::types::Document)
429pub async fn document_update<
430    T: serde::de::DeserializeOwned
431        + crate::field_selection::GraphQLFields<FullType = super::types::Document>,
432>(
433    client: &Client,
434    input: DocumentUpdateInput,
435    id: String,
436) -> Result<T, LinearError> {
437    let variables = serde_json::json!({ "input" : input, "id" : id });
438    let query = String::from(
439        "mutation DocumentUpdate($input: DocumentUpdateInput!, $id: String!) { documentUpdate(input: $input, id: $id) { success document { ",
440    ) + &T::selection() + " } } }";
441    client
442        .execute_mutation::<T>(&query, variables, "documentUpdate", "document")
443        .await
444}
445/// Deletes (trashes) a document.
446///
447/// Full type: [`Document`](super::types::Document)
448pub async fn document_delete<
449    T: serde::de::DeserializeOwned
450        + crate::field_selection::GraphQLFields<FullType = super::types::Document>,
451>(
452    client: &Client,
453    id: String,
454) -> Result<T, LinearError> {
455    let variables = serde_json::json!({ "id" : id });
456    let query = String::from(
457        "mutation DocumentDelete($id: String!) { documentDelete(id: $id) { success entity { ",
458    ) + &T::selection()
459        + " } } }";
460    client
461        .execute_mutation::<T>(&query, variables, "documentDelete", "entity")
462        .await
463}