Skip to main content

IssuesService

Struct IssuesService 

Source
pub struct IssuesService<'a> { /* private fields */ }
Expand description

Issue operations. Obtained via LinearClient::issues; Copy, so it can be freely captured by pagination closures.

Implementations§

Source§

impl<'a> IssuesService<'a>

Source

pub async fn get(&self, issue: impl Into<IssueRef>) -> Result<Issue>

Fetches one issue by UUID or human identifier.

let client = linear_api::LinearClient::from_env()?;
let issue = client
    .issues()
    .get(linear_api::IssueRef::identifier("ENG-123"))
    .await?;
assert_eq!(issue.identifier, "ENG-123");
Source

pub async fn list(&self, req: ListIssuesRequest) -> Result<Page<Issue>>

Fetches one page of issues.

use linear_api::issues::ListIssuesRequest;

let client = linear_api::LinearClient::from_env()?;
let page = client
    .issues()
    .list(ListIssuesRequest::builder().first(25).build())
    .await?;
println!("{} issues, more: {}", page.nodes.len(), page.page_info.has_next_page);
Source

pub fn list_stream( &self, req: ListIssuesRequest, ) -> impl Stream<Item = Result<Issue>> + 'a

Lazily streams issues across pages, starting from req.after when set (the cursor then advances page by page).

use futures::TryStreamExt;
use linear_api::issues::ListIssuesRequest;

let client = linear_api::LinearClient::from_env()?;
let issues = client.issues();
let mut stream = std::pin::pin!(
    issues.list_stream(ListIssuesRequest::builder().first(50).build())
);
while let Some(issue) = stream.try_next().await? {
    println!("{}: {}", issue.identifier, issue.title);
}
Source

pub async fn search( &self, req: SearchIssuesRequest, ) -> Result<Page<IssueSearchResult>>

Full-text search over issues via the searchIssues API (rate-limited by Linear to 30 requests per minute).

use linear_api::issues::SearchIssuesRequest;

let client = linear_api::LinearClient::from_env()?;
let hits = client
    .issues()
    .search(SearchIssuesRequest::builder().term("flux capacitor").build())
    .await?;
for hit in &hits.nodes {
    println!("{}: {}", hit.identifier, hit.title);
}
Source

pub async fn create(&self, input: IssueCreateInput) -> Result<Issue>

Creates one issue.

use linear_api::TeamId;
use linear_api::issues::IssueCreateInput;

let client = linear_api::LinearClient::from_env()?;
let issue = client
    .issues()
    .create(
        IssueCreateInput::builder()
            .team_id(TeamId::new("9cfb482a-81e3-4154-b5b9-2c805e70a02d"))
            .title("Fix the flux capacitor")
            .build(),
    )
    .await?;
println!("created {}", issue.identifier);
Source

pub async fn batch_create( &self, issues: Vec<IssueCreateInput>, ) -> Result<Vec<Issue>>

Creates several issues in one transaction (issueBatchCreate).

use linear_api::TeamId;
use linear_api::issues::IssueCreateInput;

let client = linear_api::LinearClient::from_env()?;
let team = TeamId::new("9cfb482a-81e3-4154-b5b9-2c805e70a02d");
let issues = client
    .issues()
    .batch_create(vec![
        IssueCreateInput::builder().team_id(team.clone()).title("One").build(),
        IssueCreateInput::builder().team_id(team).title("Two").build(),
    ])
    .await?;
assert_eq!(issues.len(), 2);
Source

pub async fn update( &self, issue: impl Into<IssueRef>, input: IssueUpdateInput, ) -> Result<Issue>

Updates one issue by UUID or human identifier. See IssueUpdateInput for set/clear/leave-unchanged semantics.

use linear_api::issues::IssueUpdateInput;
use linear_api::{IssueRef, Undefinable};

let client = linear_api::LinearClient::from_env()?;
let issue = client
    .issues()
    .update(
        IssueRef::identifier("ENG-123"),
        IssueUpdateInput::builder()
            .title("Fix the flux capacitor for real")
            .due_date(Undefinable::Null) // clear the due date
            .build(),
    )
    .await?;
println!("updated {}", issue.identifier);
Source

pub async fn archive(&self, issue: impl Into<IssueRef>) -> Result<()>

Archives one issue.

let client = linear_api::LinearClient::from_env()?;
client
    .issues()
    .archive(linear_api::IssueRef::identifier("ENG-123"))
    .await?;
Source

pub async fn delete(&self, issue: impl Into<IssueRef>) -> Result<()>

Deletes (trashes) one issue. Linear keeps trashed issues recoverable for a grace period.

let client = linear_api::LinearClient::from_env()?;
client
    .issues()
    .delete(linear_api::IssueRef::identifier("ENG-123"))
    .await?;
Source

pub async fn add_label( &self, issue: impl Into<IssueRef>, label: &LabelId, ) -> Result<Issue>

Adds one label to an issue, returning the updated issue. For bulk label changes prefer IssuesService::update with IssueUpdateInput::added_label_ids.

let client = linear_api::LinearClient::from_env()?;
let label = linear_api::LabelId::new("2f7fb5b1-9d5d-4d70-a806-04f8ad4c3702");
let issue = client
    .issues()
    .add_label(linear_api::IssueRef::identifier("ENG-123"), &label)
    .await?;
println!("{} now has {} labels", issue.identifier, issue.labels.len());
Source

pub async fn remove_label( &self, issue: impl Into<IssueRef>, label: &LabelId, ) -> Result<Issue>

Removes one label from an issue, returning the updated issue. For bulk label changes prefer IssuesService::update with IssueUpdateInput::removed_label_ids.

let client = linear_api::LinearClient::from_env()?;
let label = linear_api::LabelId::new("2f7fb5b1-9d5d-4d70-a806-04f8ad4c3702");
let issue = client
    .issues()
    .remove_label(linear_api::IssueRef::identifier("ENG-123"), &label)
    .await?;
println!("{} now has {} labels", issue.identifier, issue.labels.len());

Trait Implementations§

Source§

impl<'a> Clone for IssuesService<'a>

Source§

fn clone(&self) -> IssuesService<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for IssuesService<'a>

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for IssuesService<'a>

§

impl<'a> !UnwindSafe for IssuesService<'a>

§

impl<'a> Freeze for IssuesService<'a>

§

impl<'a> Send for IssuesService<'a>

§

impl<'a> Sync for IssuesService<'a>

§

impl<'a> Unpin for IssuesService<'a>

§

impl<'a> UnsafeUnpin for IssuesService<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more