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 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}
70pub async fn comment_update<
74 T: serde::de::DeserializeOwned
75 + crate::field_selection::GraphQLFields<FullType = super::types::Comment>,
76>(
77 client: &Client,
78 skip_edited_at: Option<bool>,
79 input: CommentUpdateInput,
80 id: String,
81) -> Result<T, LinearError> {
82 let variables = serde_json::json!(
83 { "skipEditedAt" : skip_edited_at, "input" : input, "id" : id }
84 );
85 let query = String::from(
86 "mutation CommentUpdate($skipEditedAt: Boolean, $input: CommentUpdateInput!, $id: String!) { commentUpdate(skipEditedAt: $skipEditedAt, input: $input, id: $id) { success comment { ",
87 ) + &T::selection() + " } } }";
88 client
89 .execute_mutation::<T>(&query, variables, "commentUpdate", "comment")
90 .await
91}
92pub async fn comment_delete(client: &Client, id: String) -> Result<serde_json::Value, LinearError> {
94 let variables = serde_json::json!({ "id" : id });
95 let response_parts: Vec<String> = vec!["success".to_string(), "entityId".to_string()];
96 let query = String::from("mutation CommentDelete($id: String!) { commentDelete(id: $id) { ")
97 + &response_parts.join(" ")
98 + " } }";
99 client
100 .execute::<serde_json::Value>(&query, variables, "commentDelete")
101 .await
102}
103pub async fn comment_resolve<
107 T: serde::de::DeserializeOwned
108 + crate::field_selection::GraphQLFields<FullType = super::types::Comment>,
109>(
110 client: &Client,
111 resolving_comment_id: Option<String>,
112 id: String,
113) -> Result<T, LinearError> {
114 let variables = serde_json::json!(
115 { "resolvingCommentId" : resolving_comment_id, "id" : id }
116 );
117 let query = String::from(
118 "mutation CommentResolve($resolvingCommentId: String, $id: String!) { commentResolve(resolvingCommentId: $resolvingCommentId, id: $id) { success comment { ",
119 ) + &T::selection() + " } } }";
120 client
121 .execute_mutation::<T>(&query, variables, "commentResolve", "comment")
122 .await
123}
124pub async fn comment_unresolve<
128 T: serde::de::DeserializeOwned
129 + crate::field_selection::GraphQLFields<FullType = super::types::Comment>,
130>(
131 client: &Client,
132 id: String,
133) -> Result<T, LinearError> {
134 let variables = serde_json::json!({ "id" : id });
135 let query = String::from(
136 "mutation CommentUnresolve($id: String!) { commentUnresolve(id: $id) { success comment { ",
137 ) + &T::selection()
138 + " } } }";
139 client
140 .execute_mutation::<T>(&query, variables, "commentUnresolve", "comment")
141 .await
142}
143pub async fn project_create<
147 T: serde::de::DeserializeOwned
148 + crate::field_selection::GraphQLFields<FullType = super::types::Project>,
149>(
150 client: &Client,
151 slack_channel_name: Option<String>,
152 input: ProjectCreateInput,
153) -> Result<T, LinearError> {
154 let variables = serde_json::json!(
155 { "slackChannelName" : slack_channel_name, "input" : input }
156 );
157 let query = String::from(
158 "mutation ProjectCreate($slackChannelName: String, $input: ProjectCreateInput!) { projectCreate(slackChannelName: $slackChannelName, input: $input) { success project { ",
159 ) + &T::selection() + " } } }";
160 client
161 .execute_mutation::<T>(&query, variables, "projectCreate", "project")
162 .await
163}
164pub async fn project_update<
168 T: serde::de::DeserializeOwned
169 + crate::field_selection::GraphQLFields<FullType = super::types::Project>,
170>(
171 client: &Client,
172 input: ProjectUpdateInput,
173 id: String,
174) -> Result<T, LinearError> {
175 let variables = serde_json::json!({ "input" : input, "id" : id });
176 let query = String::from(
177 "mutation ProjectUpdate($input: ProjectUpdateInput!, $id: String!) { projectUpdate(input: $input, id: $id) { success project { ",
178 ) + &T::selection() + " } } }";
179 client
180 .execute_mutation::<T>(&query, variables, "projectUpdate", "project")
181 .await
182}
183pub async fn project_delete<
187 T: serde::de::DeserializeOwned
188 + crate::field_selection::GraphQLFields<FullType = super::types::Project>,
189>(
190 client: &Client,
191 id: String,
192) -> Result<T, LinearError> {
193 let variables = serde_json::json!({ "id" : id });
194 let query = String::from(
195 "mutation ProjectDelete($id: String!) { projectDelete(id: $id) { success entity { ",
196 ) + &T::selection()
197 + " } } }";
198 client
199 .execute_mutation::<T>(&query, variables, "projectDelete", "entity")
200 .await
201}
202pub async fn team_create<
206 T: serde::de::DeserializeOwned
207 + crate::field_selection::GraphQLFields<FullType = super::types::Team>,
208>(
209 client: &Client,
210 copy_settings_from_team_id: Option<String>,
211 input: TeamCreateInput,
212) -> Result<T, LinearError> {
213 let variables = serde_json::json!(
214 { "copySettingsFromTeamId" : copy_settings_from_team_id, "input" : input }
215 );
216 let query = String::from(
217 "mutation TeamCreate($copySettingsFromTeamId: String, $input: TeamCreateInput!) { teamCreate(copySettingsFromTeamId: $copySettingsFromTeamId, input: $input) { success team { ",
218 ) + &T::selection() + " } } }";
219 client
220 .execute_mutation::<T>(&query, variables, "teamCreate", "team")
221 .await
222}
223pub async fn team_update<
227 T: serde::de::DeserializeOwned
228 + crate::field_selection::GraphQLFields<FullType = super::types::Team>,
229>(
230 client: &Client,
231 mapping: Option<InheritanceEntityMapping>,
232 input: TeamUpdateInput,
233 id: String,
234) -> Result<T, LinearError> {
235 let variables = serde_json::json!(
236 { "mapping" : mapping, "input" : input, "id" : id }
237 );
238 let query = String::from(
239 "mutation TeamUpdate($mapping: InheritanceEntityMapping, $input: TeamUpdateInput!, $id: String!) { teamUpdate(mapping: $mapping, input: $input, id: $id) { success team { ",
240 ) + &T::selection() + " } } }";
241 client
242 .execute_mutation::<T>(&query, variables, "teamUpdate", "team")
243 .await
244}
245pub async fn team_delete(client: &Client, id: String) -> Result<serde_json::Value, LinearError> {
247 let variables = serde_json::json!({ "id" : id });
248 let response_parts: Vec<String> = vec!["success".to_string(), "entityId".to_string()];
249 let query = String::from("mutation TeamDelete($id: String!) { teamDelete(id: $id) { ")
250 + &response_parts.join(" ")
251 + " } }";
252 client
253 .execute::<serde_json::Value>(&query, variables, "teamDelete")
254 .await
255}
256pub async fn team_membership_create<
260 T: serde::de::DeserializeOwned
261 + crate::field_selection::GraphQLFields<FullType = super::types::TeamMembership>,
262>(
263 client: &Client,
264 input: TeamMembershipCreateInput,
265) -> Result<T, LinearError> {
266 let variables = serde_json::json!({ "input" : input });
267 let query = String::from(
268 "mutation TeamMembershipCreate($input: TeamMembershipCreateInput!) { teamMembershipCreate(input: $input) { success teamMembership { ",
269 ) + &T::selection() + " } } }";
270 client
271 .execute_mutation::<T>(&query, variables, "teamMembershipCreate", "teamMembership")
272 .await
273}
274pub async fn team_membership_delete(
276 client: &Client,
277 also_leave_parent_teams: Option<bool>,
278 id: String,
279) -> Result<serde_json::Value, LinearError> {
280 let variables = serde_json::json!(
281 { "alsoLeaveParentTeams" : also_leave_parent_teams, "id" : id }
282 );
283 let response_parts: Vec<String> = vec!["success".to_string(), "entityId".to_string()];
284 let query = String::from(
285 "mutation TeamMembershipDelete($alsoLeaveParentTeams: Boolean, $id: String!) { teamMembershipDelete(alsoLeaveParentTeams: $alsoLeaveParentTeams, id: $id) { ",
286 ) + &response_parts.join(" ") + " } }";
287 client
288 .execute::<serde_json::Value>(&query, variables, "teamMembershipDelete")
289 .await
290}
291pub async fn project_milestone_create<
295 T: serde::de::DeserializeOwned
296 + crate::field_selection::GraphQLFields<FullType = super::types::ProjectMilestone>,
297>(
298 client: &Client,
299 input: ProjectMilestoneCreateInput,
300) -> Result<T, LinearError> {
301 let variables = serde_json::json!({ "input" : input });
302 let query = String::from(
303 "mutation ProjectMilestoneCreate($input: ProjectMilestoneCreateInput!) { projectMilestoneCreate(input: $input) { success projectMilestone { ",
304 ) + &T::selection() + " } } }";
305 client
306 .execute_mutation::<T>(
307 &query,
308 variables,
309 "projectMilestoneCreate",
310 "projectMilestone",
311 )
312 .await
313}
314pub async fn project_milestone_update<
318 T: serde::de::DeserializeOwned
319 + crate::field_selection::GraphQLFields<FullType = super::types::ProjectMilestone>,
320>(
321 client: &Client,
322 input: ProjectMilestoneUpdateInput,
323 id: String,
324) -> Result<T, LinearError> {
325 let variables = serde_json::json!({ "input" : input, "id" : id });
326 let query = String::from(
327 "mutation ProjectMilestoneUpdate($input: ProjectMilestoneUpdateInput!, $id: String!) { projectMilestoneUpdate(input: $input, id: $id) { success projectMilestone { ",
328 ) + &T::selection() + " } } }";
329 client
330 .execute_mutation::<T>(
331 &query,
332 variables,
333 "projectMilestoneUpdate",
334 "projectMilestone",
335 )
336 .await
337}
338pub async fn project_milestone_delete(
340 client: &Client,
341 id: String,
342) -> Result<serde_json::Value, LinearError> {
343 let variables = serde_json::json!({ "id" : id });
344 let response_parts: Vec<String> = vec!["success".to_string(), "entityId".to_string()];
345 let query = String::from(
346 "mutation ProjectMilestoneDelete($id: String!) { projectMilestoneDelete(id: $id) { ",
347 ) + &response_parts.join(" ")
348 + " } }";
349 client
350 .execute::<serde_json::Value>(&query, variables, "projectMilestoneDelete")
351 .await
352}
353pub async fn issue_create<
357 T: serde::de::DeserializeOwned
358 + crate::field_selection::GraphQLFields<FullType = super::types::Issue>,
359>(
360 client: &Client,
361 input: IssueCreateInput,
362) -> Result<T, LinearError> {
363 let variables = serde_json::json!({ "input" : input });
364 let query = String::from(
365 "mutation IssueCreate($input: IssueCreateInput!) { issueCreate(input: $input) { success issue { ",
366 ) + &T::selection() + " } } }";
367 client
368 .execute_mutation::<T>(&query, variables, "issueCreate", "issue")
369 .await
370}
371pub async fn issue_update<
375 T: serde::de::DeserializeOwned
376 + crate::field_selection::GraphQLFields<FullType = super::types::Issue>,
377>(
378 client: &Client,
379 input: IssueUpdateInput,
380 id: String,
381) -> Result<T, LinearError> {
382 let variables = serde_json::json!({ "input" : input, "id" : id });
383 let query = String::from(
384 "mutation IssueUpdate($input: IssueUpdateInput!, $id: String!) { issueUpdate(input: $input, id: $id) { success issue { ",
385 ) + &T::selection() + " } } }";
386 client
387 .execute_mutation::<T>(&query, variables, "issueUpdate", "issue")
388 .await
389}
390pub async fn issue_batch_update<
394 T: serde::de::DeserializeOwned
395 + crate::field_selection::GraphQLFields<FullType = super::types::Issue>,
396>(
397 client: &Client,
398 input: IssueUpdateInput,
399 ids: Vec<String>,
400) -> Result<Vec<T>, LinearError> {
401 let variables = serde_json::json!({ "input" : input, "ids" : ids });
402 let query = String::from(
403 "mutation IssueBatchUpdate($input: IssueUpdateInput!, $ids: [UUID!]!) { issueBatchUpdate(input: $input, ids: $ids) { success issues { ",
404 ) + &T::selection() + " } } }";
405 client
406 .execute_mutation::<Vec<T>>(&query, variables, "issueBatchUpdate", "issues")
407 .await
408}
409pub async fn issue_archive<
413 T: serde::de::DeserializeOwned
414 + crate::field_selection::GraphQLFields<FullType = super::types::Issue>,
415>(
416 client: &Client,
417 trash: Option<bool>,
418 id: String,
419) -> Result<T, LinearError> {
420 let variables = serde_json::json!({ "trash" : trash, "id" : id });
421 let query = String::from(
422 "mutation IssueArchive($trash: Boolean, $id: String!) { issueArchive(trash: $trash, id: $id) { success entity { ",
423 ) + &T::selection() + " } } }";
424 client
425 .execute_mutation::<T>(&query, variables, "issueArchive", "entity")
426 .await
427}
428pub async fn issue_unarchive<
432 T: serde::de::DeserializeOwned
433 + crate::field_selection::GraphQLFields<FullType = super::types::Issue>,
434>(
435 client: &Client,
436 id: String,
437) -> Result<T, LinearError> {
438 let variables = serde_json::json!({ "id" : id });
439 let query = String::from(
440 "mutation IssueUnarchive($id: String!) { issueUnarchive(id: $id) { success entity { ",
441 ) + &T::selection()
442 + " } } }";
443 client
444 .execute_mutation::<T>(&query, variables, "issueUnarchive", "entity")
445 .await
446}
447pub async fn issue_delete<
451 T: serde::de::DeserializeOwned
452 + crate::field_selection::GraphQLFields<FullType = super::types::Issue>,
453>(
454 client: &Client,
455 permanently_delete: Option<bool>,
456 id: String,
457) -> Result<T, LinearError> {
458 let variables = serde_json::json!(
459 { "permanentlyDelete" : permanently_delete, "id" : id }
460 );
461 let query = String::from(
462 "mutation IssueDelete($permanentlyDelete: Boolean, $id: String!) { issueDelete(permanentlyDelete: $permanentlyDelete, id: $id) { success entity { ",
463 ) + &T::selection() + " } } }";
464 client
465 .execute_mutation::<T>(&query, variables, "issueDelete", "entity")
466 .await
467}
468pub async fn issue_relation_create<
472 T: serde::de::DeserializeOwned
473 + crate::field_selection::GraphQLFields<FullType = super::types::IssueRelation>,
474>(
475 client: &Client,
476 override_created_at: Option<serde_json::Value>,
477 input: IssueRelationCreateInput,
478) -> Result<T, LinearError> {
479 let variables = serde_json::json!(
480 { "overrideCreatedAt" : override_created_at, "input" : input }
481 );
482 let query = String::from(
483 "mutation IssueRelationCreate($overrideCreatedAt: DateTime, $input: IssueRelationCreateInput!) { issueRelationCreate(overrideCreatedAt: $overrideCreatedAt, input: $input) { success issueRelation { ",
484 ) + &T::selection() + " } } }";
485 client
486 .execute_mutation::<T>(&query, variables, "issueRelationCreate", "issueRelation")
487 .await
488}
489pub async fn issue_relation_delete(
491 client: &Client,
492 id: String,
493) -> Result<serde_json::Value, LinearError> {
494 let variables = serde_json::json!({ "id" : id });
495 let response_parts: Vec<String> = vec!["success".to_string(), "entityId".to_string()];
496 let query = String::from(
497 "mutation IssueRelationDelete($id: String!) { issueRelationDelete(id: $id) { ",
498 ) + &response_parts.join(" ")
499 + " } }";
500 client
501 .execute::<serde_json::Value>(&query, variables, "issueRelationDelete")
502 .await
503}
504pub async fn issue_label_create<
508 T: serde::de::DeserializeOwned
509 + crate::field_selection::GraphQLFields<FullType = super::types::IssueLabel>,
510>(
511 client: &Client,
512 replace_team_labels: Option<bool>,
513 input: IssueLabelCreateInput,
514) -> Result<T, LinearError> {
515 let variables = serde_json::json!(
516 { "replaceTeamLabels" : replace_team_labels, "input" : input }
517 );
518 let query = String::from(
519 "mutation IssueLabelCreate($replaceTeamLabels: Boolean, $input: IssueLabelCreateInput!) { issueLabelCreate(replaceTeamLabels: $replaceTeamLabels, input: $input) { success issueLabel { ",
520 ) + &T::selection() + " } } }";
521 client
522 .execute_mutation::<T>(&query, variables, "issueLabelCreate", "issueLabel")
523 .await
524}
525pub async fn issue_label_update<
529 T: serde::de::DeserializeOwned
530 + crate::field_selection::GraphQLFields<FullType = super::types::IssueLabel>,
531>(
532 client: &Client,
533 replace_team_labels: Option<bool>,
534 input: IssueLabelUpdateInput,
535 id: String,
536) -> Result<T, LinearError> {
537 let variables = serde_json::json!(
538 { "replaceTeamLabels" : replace_team_labels, "input" : input, "id" : id }
539 );
540 let query = String::from(
541 "mutation IssueLabelUpdate($replaceTeamLabels: Boolean, $input: IssueLabelUpdateInput!, $id: String!) { issueLabelUpdate(replaceTeamLabels: $replaceTeamLabels, input: $input, id: $id) { success issueLabel { ",
542 ) + &T::selection() + " } } }";
543 client
544 .execute_mutation::<T>(&query, variables, "issueLabelUpdate", "issueLabel")
545 .await
546}
547pub async fn issue_label_delete(
549 client: &Client,
550 id: String,
551) -> Result<serde_json::Value, LinearError> {
552 let variables = serde_json::json!({ "id" : id });
553 let response_parts: Vec<String> = vec!["success".to_string(), "entityId".to_string()];
554 let query =
555 String::from("mutation IssueLabelDelete($id: String!) { issueLabelDelete(id: $id) { ")
556 + &response_parts.join(" ")
557 + " } }";
558 client
559 .execute::<serde_json::Value>(&query, variables, "issueLabelDelete")
560 .await
561}
562pub async fn document_create<
566 T: serde::de::DeserializeOwned
567 + crate::field_selection::GraphQLFields<FullType = super::types::Document>,
568>(
569 client: &Client,
570 input: DocumentCreateInput,
571) -> Result<T, LinearError> {
572 let variables = serde_json::json!({ "input" : input });
573 let query = String::from(
574 "mutation DocumentCreate($input: DocumentCreateInput!) { documentCreate(input: $input) { success document { ",
575 ) + &T::selection() + " } } }";
576 client
577 .execute_mutation::<T>(&query, variables, "documentCreate", "document")
578 .await
579}
580pub async fn document_update<
584 T: serde::de::DeserializeOwned
585 + crate::field_selection::GraphQLFields<FullType = super::types::Document>,
586>(
587 client: &Client,
588 input: DocumentUpdateInput,
589 id: String,
590) -> Result<T, LinearError> {
591 let variables = serde_json::json!({ "input" : input, "id" : id });
592 let query = String::from(
593 "mutation DocumentUpdate($input: DocumentUpdateInput!, $id: String!) { documentUpdate(input: $input, id: $id) { success document { ",
594 ) + &T::selection() + " } } }";
595 client
596 .execute_mutation::<T>(&query, variables, "documentUpdate", "document")
597 .await
598}
599pub async fn document_delete<
603 T: serde::de::DeserializeOwned
604 + crate::field_selection::GraphQLFields<FullType = super::types::Document>,
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 DocumentDelete($id: String!) { documentDelete(id: $id) { success entity { ",
612 ) + &T::selection()
613 + " } } }";
614 client
615 .execute_mutation::<T>(&query, variables, "documentDelete", "entity")
616 .await
617}