Skip to main content

lineark_sdk/generated/
queries.rs

1//! Generated query methods on Client.
2//!
3//! Generated by lineark-codegen — do not edit.
4use super::types::*;
5use crate::client::Client;
6use crate::error::LinearError;
7use crate::pagination::Connection;
8#[must_use]
9pub struct WorkflowStatesQuery<'a> {
10    client: &'a Client,
11    before: Option<String>,
12    after: Option<String>,
13    first: Option<i64>,
14    last: Option<i64>,
15    include_archived: Option<bool>,
16}
17impl<'a> WorkflowStatesQuery<'a> {
18    pub fn before(mut self, value: impl Into<String>) -> Self {
19        self.before = Some(value.into());
20        self
21    }
22    pub fn after(mut self, value: impl Into<String>) -> Self {
23        self.after = Some(value.into());
24        self
25    }
26    pub fn first(mut self, value: i64) -> Self {
27        self.first = Some(value);
28        self
29    }
30    pub fn last(mut self, value: i64) -> Self {
31        self.last = Some(value);
32        self
33    }
34    pub fn include_archived(mut self, value: bool) -> Self {
35        self.include_archived = Some(value);
36        self
37    }
38    pub async fn send(self) -> Result<Connection<WorkflowState>, LinearError> {
39        let variables = serde_json::json!(
40            { "before" : self.before, "after" : self.after, "first" : self.first, "last"
41            : self.last, "includeArchived" : self.include_archived }
42        );
43        self.client
44            .execute_connection::<
45                WorkflowState,
46            >(
47                "query WorkflowStates($before: String, $after: String, $first: Int, $last: Int, $includeArchived: Boolean) { workflowStates(before: $before, after: $after, first: $first, last: $last, includeArchived: $includeArchived) { nodes { id createdAt updatedAt archivedAt name color description position type } pageInfo { hasNextPage endCursor } } }",
48                variables,
49                "workflowStates",
50            )
51            .await
52    }
53}
54#[must_use]
55pub struct UsersQuery<'a> {
56    client: &'a Client,
57    include_disabled: Option<bool>,
58    before: Option<String>,
59    after: Option<String>,
60    first: Option<i64>,
61    last: Option<i64>,
62    include_archived: Option<bool>,
63}
64impl<'a> UsersQuery<'a> {
65    pub fn include_disabled(mut self, value: bool) -> Self {
66        self.include_disabled = Some(value);
67        self
68    }
69    pub fn before(mut self, value: impl Into<String>) -> Self {
70        self.before = Some(value.into());
71        self
72    }
73    pub fn after(mut self, value: impl Into<String>) -> Self {
74        self.after = Some(value.into());
75        self
76    }
77    pub fn first(mut self, value: i64) -> Self {
78        self.first = Some(value);
79        self
80    }
81    pub fn last(mut self, value: i64) -> Self {
82        self.last = Some(value);
83        self
84    }
85    pub fn include_archived(mut self, value: bool) -> Self {
86        self.include_archived = Some(value);
87        self
88    }
89    pub async fn send(self) -> Result<Connection<User>, LinearError> {
90        let variables = serde_json::json!(
91            { "includeDisabled" : self.include_disabled, "before" : self.before, "after"
92            : self.after, "first" : self.first, "last" : self.last, "includeArchived" :
93            self.include_archived }
94        );
95        self.client
96            .execute_connection::<
97                User,
98            >(
99                "query Users($includeDisabled: Boolean, $before: String, $after: String, $first: Int, $last: Int, $includeArchived: Boolean) { users(includeDisabled: $includeDisabled, before: $before, after: $after, first: $first, last: $last, includeArchived: $includeArchived) { nodes { id createdAt updatedAt archivedAt name displayName email avatarUrl disableReason calendarHash description statusEmoji statusLabel statusUntilAt timezone lastSeen initials avatarBackgroundColor guest app isMentionable isAssignable active url createdIssueCount canAccessAnyPublicTeam isMe admin owner supportsAgentSessions inviteHash gitHubUserId } pageInfo { hasNextPage endCursor } } }",
100                variables,
101                "users",
102            )
103            .await
104    }
105}
106#[must_use]
107pub struct ProjectsQuery<'a> {
108    client: &'a Client,
109    before: Option<String>,
110    after: Option<String>,
111    first: Option<i64>,
112    last: Option<i64>,
113    include_archived: Option<bool>,
114}
115impl<'a> ProjectsQuery<'a> {
116    pub fn before(mut self, value: impl Into<String>) -> Self {
117        self.before = Some(value.into());
118        self
119    }
120    pub fn after(mut self, value: impl Into<String>) -> Self {
121        self.after = Some(value.into());
122        self
123    }
124    pub fn first(mut self, value: i64) -> Self {
125        self.first = Some(value);
126        self
127    }
128    pub fn last(mut self, value: i64) -> Self {
129        self.last = Some(value);
130        self
131    }
132    pub fn include_archived(mut self, value: bool) -> Self {
133        self.include_archived = Some(value);
134        self
135    }
136    pub async fn send(self) -> Result<Connection<Project>, LinearError> {
137        let variables = serde_json::json!(
138            { "before" : self.before, "after" : self.after, "first" : self.first, "last"
139            : self.last, "includeArchived" : self.include_archived }
140        );
141        self.client
142            .execute_connection::<
143                Project,
144            >(
145                "query Projects($before: String, $after: String, $first: Int, $last: Int, $includeArchived: Boolean) { projects(before: $before, after: $after, first: $first, last: $last, includeArchived: $includeArchived) { nodes { id createdAt updatedAt archivedAt updateReminderFrequencyInWeeks updateReminderFrequency frequencyResolution updateRemindersDay updateRemindersHour name description slugId icon color projectUpdateRemindersPausedUntilAt startDate startDateResolution targetDate targetDateResolution startedAt completedAt canceledAt autoArchivedAt trashed sortOrder prioritySortOrder priority health healthUpdatedAt issueCountHistory completedIssueCountHistory scopeHistory completedScopeHistory inProgressScopeHistory progressHistory currentProgress slackNewIssue slackIssueComments slackIssueStatuses labelIds url progress scope content contentState state priorityLabel } pageInfo { hasNextPage endCursor } } }",
146                variables,
147                "projects",
148            )
149            .await
150    }
151}
152#[must_use]
153pub struct TeamsQuery<'a> {
154    client: &'a Client,
155    before: Option<String>,
156    after: Option<String>,
157    first: Option<i64>,
158    last: Option<i64>,
159    include_archived: Option<bool>,
160}
161impl<'a> TeamsQuery<'a> {
162    pub fn before(mut self, value: impl Into<String>) -> Self {
163        self.before = Some(value.into());
164        self
165    }
166    pub fn after(mut self, value: impl Into<String>) -> Self {
167        self.after = Some(value.into());
168        self
169    }
170    pub fn first(mut self, value: i64) -> Self {
171        self.first = Some(value);
172        self
173    }
174    pub fn last(mut self, value: i64) -> Self {
175        self.last = Some(value);
176        self
177    }
178    pub fn include_archived(mut self, value: bool) -> Self {
179        self.include_archived = Some(value);
180        self
181    }
182    pub async fn send(self) -> Result<Connection<Team>, LinearError> {
183        let variables = serde_json::json!(
184            { "before" : self.before, "after" : self.after, "first" : self.first, "last"
185            : self.last, "includeArchived" : self.include_archived }
186        );
187        self.client
188            .execute_connection::<
189                Team,
190            >(
191                "query Teams($before: String, $after: String, $first: Int, $last: Int, $includeArchived: Boolean) { teams(before: $before, after: $after, first: $first, last: $last, includeArchived: $includeArchived) { nodes { id createdAt updatedAt archivedAt name key description icon color retiredAt cyclesEnabled cycleStartDay cycleDuration cycleCooldownTime cycleIssueAutoAssignStarted cycleIssueAutoAssignCompleted cycleLockToActive upcomingCycleCount timezone inheritWorkflowStatuses inheritIssueEstimation issueEstimationType issueOrderingNoPriorityFirst issueEstimationAllowZero setIssueSortOrderOnStateChange issueEstimationExtended defaultIssueEstimate triageEnabled requirePriorityToLeaveTriage defaultTemplateForMembersId defaultTemplateForNonMembersId private allMembersCanJoin securitySettings scimManaged scimGroupName progressHistory currentProgress groupIssueHistory aiThreadSummariesEnabled aiDiscussionSummariesEnabled slackNewIssue slackIssueComments slackIssueStatuses autoClosePeriod autoCloseStateId autoArchivePeriod autoCloseParentIssues autoCloseChildIssues joinByDefault cycleCalenderUrl displayName issueCount issueSortOrderDefaultToBottom inviteHash } pageInfo { hasNextPage endCursor } } }",
192                variables,
193                "teams",
194            )
195            .await
196    }
197}
198#[must_use]
199pub struct SearchIssuesQuery<'a> {
200    client: &'a Client,
201    term: String,
202    before: Option<String>,
203    after: Option<String>,
204    first: Option<i64>,
205    last: Option<i64>,
206    include_archived: Option<bool>,
207    include_comments: Option<bool>,
208    team_id: Option<String>,
209}
210impl<'a> SearchIssuesQuery<'a> {
211    pub fn before(mut self, value: impl Into<String>) -> Self {
212        self.before = Some(value.into());
213        self
214    }
215    pub fn after(mut self, value: impl Into<String>) -> Self {
216        self.after = Some(value.into());
217        self
218    }
219    pub fn first(mut self, value: i64) -> Self {
220        self.first = Some(value);
221        self
222    }
223    pub fn last(mut self, value: i64) -> Self {
224        self.last = Some(value);
225        self
226    }
227    pub fn include_archived(mut self, value: bool) -> Self {
228        self.include_archived = Some(value);
229        self
230    }
231    pub fn include_comments(mut self, value: bool) -> Self {
232        self.include_comments = Some(value);
233        self
234    }
235    pub fn team_id(mut self, value: impl Into<String>) -> Self {
236        self.team_id = Some(value.into());
237        self
238    }
239    pub async fn send(self) -> Result<Connection<Issue>, LinearError> {
240        let variables = serde_json::json!(
241            { "before" : self.before, "after" : self.after, "first" : self.first, "last"
242            : self.last, "includeArchived" : self.include_archived, "term" : self.term,
243            "includeComments" : self.include_comments, "teamId" : self.team_id }
244        );
245        self.client
246            .execute_connection::<
247                Issue,
248            >(
249                "query SearchIssues($before: String, $after: String, $first: Int, $last: Int, $includeArchived: Boolean, $term: String!, $includeComments: Boolean, $teamId: String) { searchIssues(before: $before, after: $after, first: $first, last: $last, includeArchived: $includeArchived, term: $term, includeComments: $includeComments, teamId: $teamId) { nodes { id createdAt updatedAt archivedAt number title priority estimate boardOrder sortOrder prioritySortOrder startedAt completedAt startedTriageAt triagedAt canceledAt autoClosedAt autoArchivedAt dueDate slaStartedAt slaMediumRiskAt slaHighRiskAt slaBreachesAt slaType addedToProjectAt addedToCycleAt addedToTeamAt trashed snoozedUntilAt suggestionsGeneratedAt activitySummary labelIds previousIdentifiers subIssueSortOrder reactionData priorityLabel integrationSourceType identifier url branchName customerTicketCount description } pageInfo { hasNextPage endCursor } } }",
250                variables,
251                "searchIssues",
252            )
253            .await
254    }
255}
256#[must_use]
257pub struct IssuesQuery<'a> {
258    client: &'a Client,
259    before: Option<String>,
260    after: Option<String>,
261    first: Option<i64>,
262    last: Option<i64>,
263    include_archived: Option<bool>,
264}
265impl<'a> IssuesQuery<'a> {
266    pub fn before(mut self, value: impl Into<String>) -> Self {
267        self.before = Some(value.into());
268        self
269    }
270    pub fn after(mut self, value: impl Into<String>) -> Self {
271        self.after = Some(value.into());
272        self
273    }
274    pub fn first(mut self, value: i64) -> Self {
275        self.first = Some(value);
276        self
277    }
278    pub fn last(mut self, value: i64) -> Self {
279        self.last = Some(value);
280        self
281    }
282    pub fn include_archived(mut self, value: bool) -> Self {
283        self.include_archived = Some(value);
284        self
285    }
286    pub async fn send(self) -> Result<Connection<Issue>, LinearError> {
287        let variables = serde_json::json!(
288            { "before" : self.before, "after" : self.after, "first" : self.first, "last"
289            : self.last, "includeArchived" : self.include_archived }
290        );
291        self.client
292            .execute_connection::<
293                Issue,
294            >(
295                "query Issues($before: String, $after: String, $first: Int, $last: Int, $includeArchived: Boolean) { issues(before: $before, after: $after, first: $first, last: $last, includeArchived: $includeArchived) { nodes { id createdAt updatedAt archivedAt number title priority estimate boardOrder sortOrder prioritySortOrder startedAt completedAt startedTriageAt triagedAt canceledAt autoClosedAt autoArchivedAt dueDate slaStartedAt slaMediumRiskAt slaHighRiskAt slaBreachesAt slaType addedToProjectAt addedToCycleAt addedToTeamAt trashed snoozedUntilAt suggestionsGeneratedAt activitySummary labelIds previousIdentifiers subIssueSortOrder reactionData priorityLabel integrationSourceType identifier url branchName customerTicketCount description } pageInfo { hasNextPage endCursor } } }",
296                variables,
297                "issues",
298            )
299            .await
300    }
301}
302#[must_use]
303pub struct IssueLabelsQuery<'a> {
304    client: &'a Client,
305    before: Option<String>,
306    after: Option<String>,
307    first: Option<i64>,
308    last: Option<i64>,
309    include_archived: Option<bool>,
310}
311impl<'a> IssueLabelsQuery<'a> {
312    pub fn before(mut self, value: impl Into<String>) -> Self {
313        self.before = Some(value.into());
314        self
315    }
316    pub fn after(mut self, value: impl Into<String>) -> Self {
317        self.after = Some(value.into());
318        self
319    }
320    pub fn first(mut self, value: i64) -> Self {
321        self.first = Some(value);
322        self
323    }
324    pub fn last(mut self, value: i64) -> Self {
325        self.last = Some(value);
326        self
327    }
328    pub fn include_archived(mut self, value: bool) -> Self {
329        self.include_archived = Some(value);
330        self
331    }
332    pub async fn send(self) -> Result<Connection<IssueLabel>, LinearError> {
333        let variables = serde_json::json!(
334            { "before" : self.before, "after" : self.after, "first" : self.first, "last"
335            : self.last, "includeArchived" : self.include_archived }
336        );
337        self.client
338            .execute_connection::<
339                IssueLabel,
340            >(
341                "query IssueLabels($before: String, $after: String, $first: Int, $last: Int, $includeArchived: Boolean) { issueLabels(before: $before, after: $after, first: $first, last: $last, includeArchived: $includeArchived) { nodes { id createdAt updatedAt archivedAt name description color isGroup lastAppliedAt retiredAt } pageInfo { hasNextPage endCursor } } }",
342                variables,
343                "issueLabels",
344            )
345            .await
346    }
347}
348#[must_use]
349pub struct CyclesQuery<'a> {
350    client: &'a Client,
351    before: Option<String>,
352    after: Option<String>,
353    first: Option<i64>,
354    last: Option<i64>,
355    include_archived: Option<bool>,
356}
357impl<'a> CyclesQuery<'a> {
358    pub fn before(mut self, value: impl Into<String>) -> Self {
359        self.before = Some(value.into());
360        self
361    }
362    pub fn after(mut self, value: impl Into<String>) -> Self {
363        self.after = Some(value.into());
364        self
365    }
366    pub fn first(mut self, value: i64) -> Self {
367        self.first = Some(value);
368        self
369    }
370    pub fn last(mut self, value: i64) -> Self {
371        self.last = Some(value);
372        self
373    }
374    pub fn include_archived(mut self, value: bool) -> Self {
375        self.include_archived = Some(value);
376        self
377    }
378    pub async fn send(self) -> Result<Connection<Cycle>, LinearError> {
379        let variables = serde_json::json!(
380            { "before" : self.before, "after" : self.after, "first" : self.first, "last"
381            : self.last, "includeArchived" : self.include_archived }
382        );
383        self.client
384            .execute_connection::<
385                Cycle,
386            >(
387                "query Cycles($before: String, $after: String, $first: Int, $last: Int, $includeArchived: Boolean) { cycles(before: $before, after: $after, first: $first, last: $last, includeArchived: $includeArchived) { nodes { id createdAt updatedAt archivedAt number name description startsAt endsAt completedAt autoArchivedAt issueCountHistory completedIssueCountHistory scopeHistory completedScopeHistory inProgressScopeHistory progressHistory currentProgress isActive isFuture isPast progress isNext isPrevious } pageInfo { hasNextPage endCursor } } }",
388                variables,
389                "cycles",
390            )
391            .await
392    }
393}
394impl Client {
395    pub fn workflow_states(&self) -> WorkflowStatesQuery<'_> {
396        WorkflowStatesQuery {
397            client: self,
398            before: None,
399            after: None,
400            first: None,
401            last: None,
402            include_archived: None,
403        }
404    }
405    pub fn users(&self) -> UsersQuery<'_> {
406        UsersQuery {
407            client: self,
408            include_disabled: None,
409            before: None,
410            after: None,
411            first: None,
412            last: None,
413            include_archived: None,
414        }
415    }
416    pub async fn whoami(&self) -> Result<User, LinearError> {
417        let variables = serde_json::json!({});
418        self.execute::<
419                User,
420            >(
421                "query Viewer { viewer { id createdAt updatedAt archivedAt name displayName email avatarUrl disableReason calendarHash description statusEmoji statusLabel statusUntilAt timezone lastSeen initials avatarBackgroundColor guest app isMentionable isAssignable active url createdIssueCount canAccessAnyPublicTeam isMe admin owner supportsAgentSessions inviteHash gitHubUserId } }",
422                variables,
423                "viewer",
424            )
425            .await
426    }
427    pub fn projects(&self) -> ProjectsQuery<'_> {
428        ProjectsQuery {
429            client: self,
430            before: None,
431            after: None,
432            first: None,
433            last: None,
434            include_archived: None,
435        }
436    }
437    pub async fn project(&self, id: String) -> Result<Project, LinearError> {
438        let variables = serde_json::json!({ "id" : id });
439        self.execute::<
440                Project,
441            >(
442                "query Project($id: String!) { project(id: $id) { id createdAt updatedAt archivedAt updateReminderFrequencyInWeeks updateReminderFrequency frequencyResolution updateRemindersDay updateRemindersHour name description slugId icon color projectUpdateRemindersPausedUntilAt startDate startDateResolution targetDate targetDateResolution startedAt completedAt canceledAt autoArchivedAt trashed sortOrder prioritySortOrder priority health healthUpdatedAt issueCountHistory completedIssueCountHistory scopeHistory completedScopeHistory inProgressScopeHistory progressHistory currentProgress slackNewIssue slackIssueComments slackIssueStatuses labelIds url progress scope content contentState state priorityLabel } }",
443                variables,
444                "project",
445            )
446            .await
447    }
448    pub fn teams(&self) -> TeamsQuery<'_> {
449        TeamsQuery {
450            client: self,
451            before: None,
452            after: None,
453            first: None,
454            last: None,
455            include_archived: None,
456        }
457    }
458    pub async fn team(&self, id: String) -> Result<Team, LinearError> {
459        let variables = serde_json::json!({ "id" : id });
460        self.execute::<
461                Team,
462            >(
463                "query Team($id: String!) { team(id: $id) { id createdAt updatedAt archivedAt name key description icon color retiredAt cyclesEnabled cycleStartDay cycleDuration cycleCooldownTime cycleIssueAutoAssignStarted cycleIssueAutoAssignCompleted cycleLockToActive upcomingCycleCount timezone inheritWorkflowStatuses inheritIssueEstimation issueEstimationType issueOrderingNoPriorityFirst issueEstimationAllowZero setIssueSortOrderOnStateChange issueEstimationExtended defaultIssueEstimate triageEnabled requirePriorityToLeaveTriage defaultTemplateForMembersId defaultTemplateForNonMembersId private allMembersCanJoin securitySettings scimManaged scimGroupName progressHistory currentProgress groupIssueHistory aiThreadSummariesEnabled aiDiscussionSummariesEnabled slackNewIssue slackIssueComments slackIssueStatuses autoClosePeriod autoCloseStateId autoArchivePeriod autoCloseParentIssues autoCloseChildIssues joinByDefault cycleCalenderUrl displayName issueCount issueSortOrderDefaultToBottom inviteHash } }",
464                variables,
465                "team",
466            )
467            .await
468    }
469    pub fn search_issues(&self, term: impl Into<String>) -> SearchIssuesQuery<'_> {
470        SearchIssuesQuery {
471            client: self,
472            term: term.into(),
473            before: None,
474            after: None,
475            first: None,
476            last: None,
477            include_archived: None,
478            include_comments: None,
479            team_id: None,
480        }
481    }
482    pub fn issues(&self) -> IssuesQuery<'_> {
483        IssuesQuery {
484            client: self,
485            before: None,
486            after: None,
487            first: None,
488            last: None,
489            include_archived: None,
490        }
491    }
492    pub async fn issue(&self, id: String) -> Result<Issue, LinearError> {
493        let variables = serde_json::json!({ "id" : id });
494        self.execute::<
495                Issue,
496            >(
497                "query Issue($id: String!) { issue(id: $id) { id createdAt updatedAt archivedAt number title priority estimate boardOrder sortOrder prioritySortOrder startedAt completedAt startedTriageAt triagedAt canceledAt autoClosedAt autoArchivedAt dueDate slaStartedAt slaMediumRiskAt slaHighRiskAt slaBreachesAt slaType addedToProjectAt addedToCycleAt addedToTeamAt trashed snoozedUntilAt suggestionsGeneratedAt activitySummary labelIds previousIdentifiers subIssueSortOrder reactionData priorityLabel integrationSourceType identifier url branchName customerTicketCount description } }",
498                variables,
499                "issue",
500            )
501            .await
502    }
503    pub fn issue_labels(&self) -> IssueLabelsQuery<'_> {
504        IssueLabelsQuery {
505            client: self,
506            before: None,
507            after: None,
508            first: None,
509            last: None,
510            include_archived: None,
511        }
512    }
513    pub fn cycles(&self) -> CyclesQuery<'_> {
514        CyclesQuery {
515            client: self,
516            before: None,
517            after: None,
518            first: None,
519            last: None,
520            include_archived: None,
521        }
522    }
523    pub async fn cycle(&self, id: String) -> Result<Cycle, LinearError> {
524        let variables = serde_json::json!({ "id" : id });
525        self.execute::<
526                Cycle,
527            >(
528                "query Cycle($id: String!) { cycle(id: $id) { id createdAt updatedAt archivedAt number name description startsAt endsAt completedAt autoArchivedAt issueCountHistory completedIssueCountHistory scopeHistory completedScopeHistory inProgressScopeHistory progressHistory currentProgress isActive isFuture isPast progress isNext isPrevious } }",
529                variables,
530                "cycle",
531            )
532            .await
533    }
534}