pub struct LabelsService<'a> { /* private fields */ }Expand description
Issue label operations. Obtain via LinearClient::labels.
Implementations§
Source§impl<'a> LabelsService<'a>
impl<'a> LabelsService<'a>
Sourcepub async fn list(&self, req: ListLabelsRequest) -> Result<Page<Label>>
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);
}Sourcepub fn list_stream(
&self,
req: ListLabelsRequest,
) -> impl Stream<Item = Result<Label>> + 'a
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);
}Sourcepub async fn create(&self, input: LabelCreateInput) -> Result<Label>
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?;Sourcepub async fn update(
&self,
id: &LabelId,
input: LabelUpdateInput,
) -> Result<Label>
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?;Sourcepub async fn delete(&self, id: &LabelId) -> Result<()>
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?;Sourcepub async fn ensure(&self, team: Option<&TeamId>, name: &str) -> Result<Label>
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>
impl<'a> Clone for LabelsService<'a>
Source§fn clone(&self) -> LabelsService<'a>
fn clone(&self) -> LabelsService<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more