1#![allow(clippy::too_many_arguments)]
8use super::inputs::*;
9use crate::client::Client;
10use crate::error::LinearError;
11pub 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}
37pub 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}
52pub async fn project_create<
56 T: serde::de::DeserializeOwned
57 + crate::field_selection::GraphQLFields<FullType = super::types::Project>,
58>(
59 client: &Client,
60 slack_channel_name: Option<String>,
61 input: ProjectCreateInput,
62) -> Result<T, LinearError> {
63 let variables = serde_json::json!(
64 { "slackChannelName" : slack_channel_name, "input" : input }
65 );
66 let query = String::from(
67 "mutation ProjectCreate($slackChannelName: String, $input: ProjectCreateInput!) { projectCreate(slackChannelName: $slackChannelName, input: $input) { success project { ",
68 ) + &T::selection() + " } } }";
69 client
70 .execute_mutation::<T>(&query, variables, "projectCreate", "project")
71 .await
72}
73pub async fn project_update<
77 T: serde::de::DeserializeOwned
78 + crate::field_selection::GraphQLFields<FullType = super::types::Project>,
79>(
80 client: &Client,
81 input: ProjectUpdateInput,
82 id: String,
83) -> Result<T, LinearError> {
84 let variables = serde_json::json!({ "input" : input, "id" : id });
85 let query = String::from(
86 "mutation ProjectUpdate($input: ProjectUpdateInput!, $id: String!) { projectUpdate(input: $input, id: $id) { success project { ",
87 ) + &T::selection() + " } } }";
88 client
89 .execute_mutation::<T>(&query, variables, "projectUpdate", "project")
90 .await
91}
92pub async fn project_delete<
96 T: serde::de::DeserializeOwned
97 + crate::field_selection::GraphQLFields<FullType = super::types::Project>,
98>(
99 client: &Client,
100 id: String,
101) -> Result<T, LinearError> {
102 let variables = serde_json::json!({ "id" : id });
103 let query = String::from(
104 "mutation ProjectDelete($id: String!) { projectDelete(id: $id) { success entity { ",
105 ) + &T::selection()
106 + " } } }";
107 client
108 .execute_mutation::<T>(&query, variables, "projectDelete", "entity")
109 .await
110}
111pub async fn team_create<
115 T: serde::de::DeserializeOwned
116 + crate::field_selection::GraphQLFields<FullType = super::types::Team>,
117>(
118 client: &Client,
119 copy_settings_from_team_id: Option<String>,
120 input: TeamCreateInput,
121) -> Result<T, LinearError> {
122 let variables = serde_json::json!(
123 { "copySettingsFromTeamId" : copy_settings_from_team_id, "input" : input }
124 );
125 let query = String::from(
126 "mutation TeamCreate($copySettingsFromTeamId: String, $input: TeamCreateInput!) { teamCreate(copySettingsFromTeamId: $copySettingsFromTeamId, input: $input) { success team { ",
127 ) + &T::selection() + " } } }";
128 client
129 .execute_mutation::<T>(&query, variables, "teamCreate", "team")
130 .await
131}
132pub async fn team_update<
136 T: serde::de::DeserializeOwned
137 + crate::field_selection::GraphQLFields<FullType = super::types::Team>,
138>(
139 client: &Client,
140 mapping: Option<InheritanceEntityMapping>,
141 input: TeamUpdateInput,
142 id: String,
143) -> Result<T, LinearError> {
144 let variables = serde_json::json!(
145 { "mapping" : mapping, "input" : input, "id" : id }
146 );
147 let query = String::from(
148 "mutation TeamUpdate($mapping: InheritanceEntityMapping, $input: TeamUpdateInput!, $id: String!) { teamUpdate(mapping: $mapping, input: $input, id: $id) { success team { ",
149 ) + &T::selection() + " } } }";
150 client
151 .execute_mutation::<T>(&query, variables, "teamUpdate", "team")
152 .await
153}
154pub async fn team_delete(client: &Client, id: String) -> Result<serde_json::Value, LinearError> {
156 let variables = serde_json::json!({ "id" : id });
157 let response_parts: Vec<String> = vec!["success".to_string(), "entityId".to_string()];
158 let query = String::from("mutation TeamDelete($id: String!) { teamDelete(id: $id) { ")
159 + &response_parts.join(" ")
160 + " } }";
161 client
162 .execute::<serde_json::Value>(&query, variables, "teamDelete")
163 .await
164}
165pub async fn team_membership_create<
169 T: serde::de::DeserializeOwned
170 + crate::field_selection::GraphQLFields<FullType = super::types::TeamMembership>,
171>(
172 client: &Client,
173 input: TeamMembershipCreateInput,
174) -> Result<T, LinearError> {
175 let variables = serde_json::json!({ "input" : input });
176 let query = String::from(
177 "mutation TeamMembershipCreate($input: TeamMembershipCreateInput!) { teamMembershipCreate(input: $input) { success teamMembership { ",
178 ) + &T::selection() + " } } }";
179 client
180 .execute_mutation::<T>(&query, variables, "teamMembershipCreate", "teamMembership")
181 .await
182}
183pub async fn team_membership_delete(
185 client: &Client,
186 also_leave_parent_teams: Option<bool>,
187 id: String,
188) -> Result<serde_json::Value, LinearError> {
189 let variables = serde_json::json!(
190 { "alsoLeaveParentTeams" : also_leave_parent_teams, "id" : id }
191 );
192 let response_parts: Vec<String> = vec!["success".to_string(), "entityId".to_string()];
193 let query = String::from(
194 "mutation TeamMembershipDelete($alsoLeaveParentTeams: Boolean, $id: String!) { teamMembershipDelete(alsoLeaveParentTeams: $alsoLeaveParentTeams, id: $id) { ",
195 ) + &response_parts.join(" ") + " } }";
196 client
197 .execute::<serde_json::Value>(&query, variables, "teamMembershipDelete")
198 .await
199}
200pub async fn project_milestone_create<
204 T: serde::de::DeserializeOwned
205 + crate::field_selection::GraphQLFields<FullType = super::types::ProjectMilestone>,
206>(
207 client: &Client,
208 input: ProjectMilestoneCreateInput,
209) -> Result<T, LinearError> {
210 let variables = serde_json::json!({ "input" : input });
211 let query = String::from(
212 "mutation ProjectMilestoneCreate($input: ProjectMilestoneCreateInput!) { projectMilestoneCreate(input: $input) { success projectMilestone { ",
213 ) + &T::selection() + " } } }";
214 client
215 .execute_mutation::<T>(
216 &query,
217 variables,
218 "projectMilestoneCreate",
219 "projectMilestone",
220 )
221 .await
222}
223pub async fn project_milestone_update<
227 T: serde::de::DeserializeOwned
228 + crate::field_selection::GraphQLFields<FullType = super::types::ProjectMilestone>,
229>(
230 client: &Client,
231 input: ProjectMilestoneUpdateInput,
232 id: String,
233) -> Result<T, LinearError> {
234 let variables = serde_json::json!({ "input" : input, "id" : id });
235 let query = String::from(
236 "mutation ProjectMilestoneUpdate($input: ProjectMilestoneUpdateInput!, $id: String!) { projectMilestoneUpdate(input: $input, id: $id) { success projectMilestone { ",
237 ) + &T::selection() + " } } }";
238 client
239 .execute_mutation::<T>(
240 &query,
241 variables,
242 "projectMilestoneUpdate",
243 "projectMilestone",
244 )
245 .await
246}
247pub async fn project_milestone_delete(
249 client: &Client,
250 id: String,
251) -> Result<serde_json::Value, LinearError> {
252 let variables = serde_json::json!({ "id" : id });
253 let response_parts: Vec<String> = vec!["success".to_string(), "entityId".to_string()];
254 let query = String::from(
255 "mutation ProjectMilestoneDelete($id: String!) { projectMilestoneDelete(id: $id) { ",
256 ) + &response_parts.join(" ")
257 + " } }";
258 client
259 .execute::<serde_json::Value>(&query, variables, "projectMilestoneDelete")
260 .await
261}
262pub async fn issue_create<
266 T: serde::de::DeserializeOwned
267 + crate::field_selection::GraphQLFields<FullType = super::types::Issue>,
268>(
269 client: &Client,
270 input: IssueCreateInput,
271) -> Result<T, LinearError> {
272 let variables = serde_json::json!({ "input" : input });
273 let query = String::from(
274 "mutation IssueCreate($input: IssueCreateInput!) { issueCreate(input: $input) { success issue { ",
275 ) + &T::selection() + " } } }";
276 client
277 .execute_mutation::<T>(&query, variables, "issueCreate", "issue")
278 .await
279}
280pub async fn issue_update<
284 T: serde::de::DeserializeOwned
285 + crate::field_selection::GraphQLFields<FullType = super::types::Issue>,
286>(
287 client: &Client,
288 input: IssueUpdateInput,
289 id: String,
290) -> Result<T, LinearError> {
291 let variables = serde_json::json!({ "input" : input, "id" : id });
292 let query = String::from(
293 "mutation IssueUpdate($input: IssueUpdateInput!, $id: String!) { issueUpdate(input: $input, id: $id) { success issue { ",
294 ) + &T::selection() + " } } }";
295 client
296 .execute_mutation::<T>(&query, variables, "issueUpdate", "issue")
297 .await
298}
299pub async fn issue_batch_update<
303 T: serde::de::DeserializeOwned
304 + crate::field_selection::GraphQLFields<FullType = super::types::Issue>,
305>(
306 client: &Client,
307 input: IssueUpdateInput,
308 ids: Vec<String>,
309) -> Result<Vec<T>, LinearError> {
310 let variables = serde_json::json!({ "input" : input, "ids" : ids });
311 let query = String::from(
312 "mutation IssueBatchUpdate($input: IssueUpdateInput!, $ids: [UUID!]!) { issueBatchUpdate(input: $input, ids: $ids) { success issues { ",
313 ) + &T::selection() + " } } }";
314 client
315 .execute_mutation::<Vec<T>>(&query, variables, "issueBatchUpdate", "issues")
316 .await
317}
318pub async fn issue_archive<
322 T: serde::de::DeserializeOwned
323 + crate::field_selection::GraphQLFields<FullType = super::types::Issue>,
324>(
325 client: &Client,
326 trash: Option<bool>,
327 id: String,
328) -> Result<T, LinearError> {
329 let variables = serde_json::json!({ "trash" : trash, "id" : id });
330 let query = String::from(
331 "mutation IssueArchive($trash: Boolean, $id: String!) { issueArchive(trash: $trash, id: $id) { success entity { ",
332 ) + &T::selection() + " } } }";
333 client
334 .execute_mutation::<T>(&query, variables, "issueArchive", "entity")
335 .await
336}
337pub async fn issue_unarchive<
341 T: serde::de::DeserializeOwned
342 + crate::field_selection::GraphQLFields<FullType = super::types::Issue>,
343>(
344 client: &Client,
345 id: String,
346) -> Result<T, LinearError> {
347 let variables = serde_json::json!({ "id" : id });
348 let query = String::from(
349 "mutation IssueUnarchive($id: String!) { issueUnarchive(id: $id) { success entity { ",
350 ) + &T::selection()
351 + " } } }";
352 client
353 .execute_mutation::<T>(&query, variables, "issueUnarchive", "entity")
354 .await
355}
356pub async fn issue_delete<
360 T: serde::de::DeserializeOwned
361 + crate::field_selection::GraphQLFields<FullType = super::types::Issue>,
362>(
363 client: &Client,
364 permanently_delete: Option<bool>,
365 id: String,
366) -> Result<T, LinearError> {
367 let variables = serde_json::json!(
368 { "permanentlyDelete" : permanently_delete, "id" : id }
369 );
370 let query = String::from(
371 "mutation IssueDelete($permanentlyDelete: Boolean, $id: String!) { issueDelete(permanentlyDelete: $permanentlyDelete, id: $id) { success entity { ",
372 ) + &T::selection() + " } } }";
373 client
374 .execute_mutation::<T>(&query, variables, "issueDelete", "entity")
375 .await
376}
377pub async fn issue_relation_create<
381 T: serde::de::DeserializeOwned
382 + crate::field_selection::GraphQLFields<FullType = super::types::IssueRelation>,
383>(
384 client: &Client,
385 override_created_at: Option<serde_json::Value>,
386 input: IssueRelationCreateInput,
387) -> Result<T, LinearError> {
388 let variables = serde_json::json!(
389 { "overrideCreatedAt" : override_created_at, "input" : input }
390 );
391 let query = String::from(
392 "mutation IssueRelationCreate($overrideCreatedAt: DateTime, $input: IssueRelationCreateInput!) { issueRelationCreate(overrideCreatedAt: $overrideCreatedAt, input: $input) { success issueRelation { ",
393 ) + &T::selection() + " } } }";
394 client
395 .execute_mutation::<T>(&query, variables, "issueRelationCreate", "issueRelation")
396 .await
397}
398pub async fn issue_relation_delete(
400 client: &Client,
401 id: String,
402) -> Result<serde_json::Value, LinearError> {
403 let variables = serde_json::json!({ "id" : id });
404 let response_parts: Vec<String> = vec!["success".to_string(), "entityId".to_string()];
405 let query = String::from(
406 "mutation IssueRelationDelete($id: String!) { issueRelationDelete(id: $id) { ",
407 ) + &response_parts.join(" ")
408 + " } }";
409 client
410 .execute::<serde_json::Value>(&query, variables, "issueRelationDelete")
411 .await
412}
413pub async fn issue_label_create<
417 T: serde::de::DeserializeOwned
418 + crate::field_selection::GraphQLFields<FullType = super::types::IssueLabel>,
419>(
420 client: &Client,
421 replace_team_labels: Option<bool>,
422 input: IssueLabelCreateInput,
423) -> Result<T, LinearError> {
424 let variables = serde_json::json!(
425 { "replaceTeamLabels" : replace_team_labels, "input" : input }
426 );
427 let query = String::from(
428 "mutation IssueLabelCreate($replaceTeamLabels: Boolean, $input: IssueLabelCreateInput!) { issueLabelCreate(replaceTeamLabels: $replaceTeamLabels, input: $input) { success issueLabel { ",
429 ) + &T::selection() + " } } }";
430 client
431 .execute_mutation::<T>(&query, variables, "issueLabelCreate", "issueLabel")
432 .await
433}
434pub async fn issue_label_update<
438 T: serde::de::DeserializeOwned
439 + crate::field_selection::GraphQLFields<FullType = super::types::IssueLabel>,
440>(
441 client: &Client,
442 replace_team_labels: Option<bool>,
443 input: IssueLabelUpdateInput,
444 id: String,
445) -> Result<T, LinearError> {
446 let variables = serde_json::json!(
447 { "replaceTeamLabels" : replace_team_labels, "input" : input, "id" : id }
448 );
449 let query = String::from(
450 "mutation IssueLabelUpdate($replaceTeamLabels: Boolean, $input: IssueLabelUpdateInput!, $id: String!) { issueLabelUpdate(replaceTeamLabels: $replaceTeamLabels, input: $input, id: $id) { success issueLabel { ",
451 ) + &T::selection() + " } } }";
452 client
453 .execute_mutation::<T>(&query, variables, "issueLabelUpdate", "issueLabel")
454 .await
455}
456pub async fn issue_label_delete(
458 client: &Client,
459 id: String,
460) -> Result<serde_json::Value, LinearError> {
461 let variables = serde_json::json!({ "id" : id });
462 let response_parts: Vec<String> = vec!["success".to_string(), "entityId".to_string()];
463 let query =
464 String::from("mutation IssueLabelDelete($id: String!) { issueLabelDelete(id: $id) { ")
465 + &response_parts.join(" ")
466 + " } }";
467 client
468 .execute::<serde_json::Value>(&query, variables, "issueLabelDelete")
469 .await
470}
471pub async fn document_create<
475 T: serde::de::DeserializeOwned
476 + crate::field_selection::GraphQLFields<FullType = super::types::Document>,
477>(
478 client: &Client,
479 input: DocumentCreateInput,
480) -> Result<T, LinearError> {
481 let variables = serde_json::json!({ "input" : input });
482 let query = String::from(
483 "mutation DocumentCreate($input: DocumentCreateInput!) { documentCreate(input: $input) { success document { ",
484 ) + &T::selection() + " } } }";
485 client
486 .execute_mutation::<T>(&query, variables, "documentCreate", "document")
487 .await
488}
489pub async fn document_update<
493 T: serde::de::DeserializeOwned
494 + crate::field_selection::GraphQLFields<FullType = super::types::Document>,
495>(
496 client: &Client,
497 input: DocumentUpdateInput,
498 id: String,
499) -> Result<T, LinearError> {
500 let variables = serde_json::json!({ "input" : input, "id" : id });
501 let query = String::from(
502 "mutation DocumentUpdate($input: DocumentUpdateInput!, $id: String!) { documentUpdate(input: $input, id: $id) { success document { ",
503 ) + &T::selection() + " } } }";
504 client
505 .execute_mutation::<T>(&query, variables, "documentUpdate", "document")
506 .await
507}
508pub async fn document_delete<
512 T: serde::de::DeserializeOwned
513 + crate::field_selection::GraphQLFields<FullType = super::types::Document>,
514>(
515 client: &Client,
516 id: String,
517) -> Result<T, LinearError> {
518 let variables = serde_json::json!({ "id" : id });
519 let query = String::from(
520 "mutation DocumentDelete($id: String!) { documentDelete(id: $id) { success entity { ",
521 ) + &T::selection()
522 + " } } }";
523 client
524 .execute_mutation::<T>(&query, variables, "documentDelete", "entity")
525 .await
526}
527pub async fn comment_create<
531 T: serde::de::DeserializeOwned
532 + crate::field_selection::GraphQLFields<FullType = super::types::Comment>,
533>(
534 client: &Client,
535 input: CommentCreateInput,
536) -> Result<T, LinearError> {
537 let variables = serde_json::json!({ "input" : input });
538 let query = String::from(
539 "mutation CommentCreate($input: CommentCreateInput!) { commentCreate(input: $input) { success comment { ",
540 ) + &T::selection() + " } } }";
541 client
542 .execute_mutation::<T>(&query, variables, "commentCreate", "comment")
543 .await
544}
545pub async fn comment_update<
549 T: serde::de::DeserializeOwned
550 + crate::field_selection::GraphQLFields<FullType = super::types::Comment>,
551>(
552 client: &Client,
553 skip_edited_at: Option<bool>,
554 input: CommentUpdateInput,
555 id: String,
556) -> Result<T, LinearError> {
557 let variables = serde_json::json!(
558 { "skipEditedAt" : skip_edited_at, "input" : input, "id" : id }
559 );
560 let query = String::from(
561 "mutation CommentUpdate($skipEditedAt: Boolean, $input: CommentUpdateInput!, $id: String!) { commentUpdate(skipEditedAt: $skipEditedAt, input: $input, id: $id) { success comment { ",
562 ) + &T::selection() + " } } }";
563 client
564 .execute_mutation::<T>(&query, variables, "commentUpdate", "comment")
565 .await
566}
567pub async fn comment_delete(client: &Client, id: String) -> Result<serde_json::Value, LinearError> {
569 let variables = serde_json::json!({ "id" : id });
570 let response_parts: Vec<String> = vec!["success".to_string(), "entityId".to_string()];
571 let query = String::from("mutation CommentDelete($id: String!) { commentDelete(id: $id) { ")
572 + &response_parts.join(" ")
573 + " } }";
574 client
575 .execute::<serde_json::Value>(&query, variables, "commentDelete")
576 .await
577}
578pub async fn comment_resolve<
582 T: serde::de::DeserializeOwned
583 + crate::field_selection::GraphQLFields<FullType = super::types::Comment>,
584>(
585 client: &Client,
586 resolving_comment_id: Option<String>,
587 id: String,
588) -> Result<T, LinearError> {
589 let variables = serde_json::json!(
590 { "resolvingCommentId" : resolving_comment_id, "id" : id }
591 );
592 let query = String::from(
593 "mutation CommentResolve($resolvingCommentId: String, $id: String!) { commentResolve(resolvingCommentId: $resolvingCommentId, id: $id) { success comment { ",
594 ) + &T::selection() + " } } }";
595 client
596 .execute_mutation::<T>(&query, variables, "commentResolve", "comment")
597 .await
598}
599pub async fn comment_unresolve<
603 T: serde::de::DeserializeOwned
604 + crate::field_selection::GraphQLFields<FullType = super::types::Comment>,
605>(
606 client: &Client,
607 id: String,
608) -> Result<T, LinearError> {
609 let variables = serde_json::json!({ "id" : id });
610 let query = String::from(
611 "mutation CommentUnresolve($id: String!) { commentUnresolve(id: $id) { success comment { ",
612 ) + &T::selection()
613 + " } } }";
614 client
615 .execute_mutation::<T>(&query, variables, "commentUnresolve", "comment")
616 .await
617}