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_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}
81pub 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}
102pub 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}
121pub 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}
140pub 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}
161pub 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}
183pub 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}
194pub 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}
212pub 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}
229pub 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}
252pub 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}
276pub 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}
291pub 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}
309pub 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}
328pub 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}
347pub 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}
366pub 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}
387pub 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}
408pub async fn issue_relation_delete(
410 client: &Client,
411 id: String,
412) -> Result<serde_json::Value, LinearError> {
413 let variables = serde_json::json!({ "id" : id });
414 let response_parts: Vec<String> = vec!["success".to_string(), "entityId".to_string()];
415 let query = String::from(
416 "mutation IssueRelationDelete($id: String!) { issueRelationDelete(id: $id) { ",
417 ) + &response_parts.join(" ")
418 + " } }";
419 client
420 .execute::<serde_json::Value>(&query, variables, "issueRelationDelete")
421 .await
422}
423pub async fn document_create<
427 T: serde::de::DeserializeOwned
428 + crate::field_selection::GraphQLFields<FullType = super::types::Document>,
429>(
430 client: &Client,
431 input: DocumentCreateInput,
432) -> Result<T, LinearError> {
433 let variables = serde_json::json!({ "input" : input });
434 let query = String::from(
435 "mutation DocumentCreate($input: DocumentCreateInput!) { documentCreate(input: $input) { success document { ",
436 ) + &T::selection() + " } } }";
437 client
438 .execute_mutation::<T>(&query, variables, "documentCreate", "document")
439 .await
440}
441pub async fn document_update<
445 T: serde::de::DeserializeOwned
446 + crate::field_selection::GraphQLFields<FullType = super::types::Document>,
447>(
448 client: &Client,
449 input: DocumentUpdateInput,
450 id: String,
451) -> Result<T, LinearError> {
452 let variables = serde_json::json!({ "input" : input, "id" : id });
453 let query = String::from(
454 "mutation DocumentUpdate($input: DocumentUpdateInput!, $id: String!) { documentUpdate(input: $input, id: $id) { success document { ",
455 ) + &T::selection() + " } } }";
456 client
457 .execute_mutation::<T>(&query, variables, "documentUpdate", "document")
458 .await
459}
460pub async fn document_delete<
464 T: serde::de::DeserializeOwned
465 + crate::field_selection::GraphQLFields<FullType = super::types::Document>,
466>(
467 client: &Client,
468 id: String,
469) -> Result<T, LinearError> {
470 let variables = serde_json::json!({ "id" : id });
471 let query = String::from(
472 "mutation DocumentDelete($id: String!) { documentDelete(id: $id) { success entity { ",
473 ) + &T::selection()
474 + " } } }";
475 client
476 .execute_mutation::<T>(&query, variables, "documentDelete", "entity")
477 .await
478}