Skip to main content

LabelsService

Struct LabelsService 

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

Issue label operations. Obtain via LinearClient::labels.

Implementations§

Source§

impl<'a> LabelsService<'a>

Source

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

Fetches one page of issue labels (issueLabels).

§Example
use linear_api::labels::ListLabelsRequest;

let client = linear_api::LinearClient::from_env()?;
let page = client
    .labels()
    .list(ListLabelsRequest::builder().first(25).build())
    .await?;
for label in &page.nodes {
    println!("{} ({})", label.name, label.color);
}
Source

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

Lazily streams every label matching the request across pages, starting from req.after when set (see paginate for the complexity note).

§Example
use futures::TryStreamExt;

let client = linear_api::LinearClient::from_env()?;
let labels = client.labels();
let mut stream = labels.list_stream(Default::default());
futures::pin_mut!(stream);
while let Some(label) = stream.try_next().await? {
    println!("{}", label.name);
}
Source

pub async fn create(&self, input: LabelCreateInput) -> Result<Label>

Creates a label (issueLabelCreate).

§Example
use linear_api::labels::LabelCreateInput;

let client = linear_api::LinearClient::from_env()?;
// No `team_id`: a workspace-level label.
let label = client
    .labels()
    .create(LabelCreateInput::builder().name("infra").build())
    .await?;
Source

pub async fn update( &self, id: &LabelId, input: LabelUpdateInput, ) -> Result<Label>

Updates a label (issueLabelUpdate).

§Example
use linear_api::{LabelId, Undefinable};
use linear_api::labels::LabelUpdateInput;

let client = linear_api::LinearClient::from_env()?;
let label = client
    .labels()
    .update(
        &LabelId::new("3d5a8ea4-9e4b-4caf-8d6f-1d914a518790"),
        LabelUpdateInput::builder().color("#26B5CE").build(),
    )
    .await?;
Source

pub async fn delete(&self, id: &LabelId) -> Result<()>

Deletes a label (issueLabelDelete).

§Example
use linear_api::LabelId;

let client = linear_api::LinearClient::from_env()?;
client
    .labels()
    .delete(&LabelId::new("3d5a8ea4-9e4b-4caf-8d6f-1d914a518790"))
    .await?;
Source

pub async fn ensure(&self, team: Option<&TeamId>, name: &str) -> Result<Label>

Finds a label by name (case-insensitive) or creates it — the find-or-create primitive behind “labels found or created on the team” in plan-apply flows.

With team == Some(_) the lookup is scoped to that team and a created label is team-scoped. With team == None the lookup is workspace-wide: a workspace-level match (label with no team) is preferred, any exact-name match is accepted otherwise, and a created label is workspace-level.

§Race tolerance

Linear has no idempotency keys, so two concurrent ensure calls can both miss the lookup and race the create. When the create fails with a duplicate-name/InvalidInput API error, the lookup is re-run once and the winner’s label is returned; if that re-lookup still finds nothing, the original create error is surfaced.

§Example
use linear_api::TeamId;

let client = linear_api::LinearClient::from_env()?;
let team = TeamId::new("9c2c88a6-99d3-4a63-a201-8ee5c7dcc374");
let label = client.labels().ensure(Some(&team), "bug").await?;

Trait Implementations§

Source§

impl<'a> Clone for LabelsService<'a>

Source§

fn clone(&self) -> LabelsService<'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 LabelsService<'a>

Auto Trait Implementations§

§

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

§

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

§

impl<'a> Freeze for LabelsService<'a>

§

impl<'a> Send for LabelsService<'a>

§

impl<'a> Sync for LabelsService<'a>

§

impl<'a> Unpin for LabelsService<'a>

§

impl<'a> UnsafeUnpin for LabelsService<'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