Skip to main content

Client

Struct Client 

Source
pub struct Client { /* private fields */ }
Expand description

The Linear API client.

Implementations§

Source§

impl Client

Source

pub fn from_token(token: impl Into<String>) -> Result<Self, LinearError>

Create a client with an explicit API token.

Source

pub fn from_env() -> Result<Self, LinearError>

Create a client from the LINEAR_API_TOKEN environment variable.

Source

pub fn from_file() -> Result<Self, LinearError>

Create a client from the ~/.linear_api_token file.

Source

pub fn auto() -> Result<Self, LinearError>

Create a client by auto-detecting the token (env -> file).

Source

pub async fn execute<T: DeserializeOwned>( &self, query: &str, variables: Value, data_path: &str, ) -> Result<T, LinearError>

Execute a GraphQL query and extract a single object from the response.

Source

pub async fn execute_connection<T: DeserializeOwned>( &self, query: &str, variables: Value, data_path: &str, ) -> Result<Connection<T>, LinearError>

Execute a GraphQL query and extract a Connection from the response.

Source§

impl Client

This impl block contains no items.

Allow integration tests (in tests/ directory) to set base URL.

Source§

impl Client

Source

pub async fn file_upload( &self, meta_data: Option<Value>, make_public: Option<bool>, size: i64, content_type: String, filename: String, ) -> Result<Value, LinearError>

Source

pub async fn image_upload_from_url( &self, url: String, ) -> Result<Value, LinearError>

Source

pub async fn comment_create( &self, input: CommentCreateInput, ) -> Result<Value, LinearError>

Source

pub async fn issue_create( &self, input: IssueCreateInput, ) -> Result<Value, LinearError>

Source

pub async fn issue_update( &self, input: IssueUpdateInput, id: String, ) -> Result<Value, LinearError>

Source

pub async fn issue_archive( &self, trash: Option<bool>, id: String, ) -> Result<Value, LinearError>

Source

pub async fn issue_unarchive(&self, id: String) -> Result<Value, LinearError>

Source

pub async fn issue_delete( &self, permanently_delete: Option<bool>, id: String, ) -> Result<Value, LinearError>

Source

pub async fn issue_relation_create( &self, override_created_at: Option<Value>, input: IssueRelationCreateInput, ) -> Result<Value, LinearError>

Source

pub async fn document_create( &self, input: DocumentCreateInput, ) -> Result<Value, LinearError>

Source

pub async fn document_update( &self, input: DocumentUpdateInput, id: String, ) -> Result<Value, LinearError>

Source

pub async fn document_delete(&self, id: String) -> Result<Value, LinearError>

Source§

impl Client

Source

pub fn workflow_states(&self) -> WorkflowStatesQuery<'_>

Source

pub fn users(&self) -> UsersQuery<'_>

Source

pub async fn whoami(&self) -> Result<User, LinearError>

Source

pub fn projects(&self) -> ProjectsQuery<'_>

Source

pub async fn project(&self, id: String) -> Result<Project, LinearError>

Source

pub fn teams(&self) -> TeamsQuery<'_>

Source

pub async fn team(&self, id: String) -> Result<Team, LinearError>

Source

pub fn search_issues(&self, term: impl Into<String>) -> SearchIssuesQuery<'_>

Source

pub fn issues(&self) -> IssuesQuery<'_>

Source

pub async fn issue(&self, id: String) -> Result<Issue, LinearError>

Source

pub fn issue_relations(&self) -> IssueRelationsQuery<'_>

Source

pub async fn issue_relation( &self, id: String, ) -> Result<IssueRelation, LinearError>

Source

pub fn issue_labels(&self) -> IssueLabelsQuery<'_>

Source

pub fn documents(&self) -> DocumentsQuery<'_>

Source

pub async fn document(&self, id: String) -> Result<Document, LinearError>

Source

pub fn cycles(&self) -> CyclesQuery<'_>

Source

pub async fn cycle(&self, id: String) -> Result<Cycle, LinearError>

Source§

impl Client

Source

pub async fn download_url( &self, url: &str, ) -> Result<DownloadResult, LinearError>

Download a file from a URL.

Handles Linear’s signed/expiring CDN URLs (e.g. https://uploads.linear.app/...) as well as any other publicly accessible URL. Returns the raw bytes and content type so the caller can write them to disk or process them further.

§Errors

Returns LinearError::HttpError if the server responds with a non-2xx status, or LinearError::Network if the request fails at the transport level.

§Example
let client = lineark_sdk::Client::auto()?;
let result = client.download_url("https://uploads.linear.app/...").await?;
std::fs::write("output.png", &result.bytes).unwrap();
Source

pub async fn upload_file( &self, filename: &str, content_type: &str, bytes: Vec<u8>, make_public: bool, ) -> Result<UploadResult, LinearError>

Upload a file to Linear’s cloud storage.

This is a two-step process:

  1. Call the fileUpload GraphQL mutation to obtain a signed upload URL and required headers from Linear.
  2. PUT the raw file bytes to that signed URL (a Google Cloud Storage endpoint).

On success, returns an UploadResult containing the permanent asset_url that can be referenced in issue descriptions, comments, or attachments.

§Arguments
  • filename — The original filename (e.g. "screenshot.png"). Linear uses this for display and content-type inference on its side.
  • content_type — MIME type of the file (e.g. "image/png").
  • bytes — The raw file content.
  • make_public — If true, the uploaded file will be publicly accessible without authentication.
§Errors

Returns an error if the fileUpload mutation fails, if the signed URL upload fails, or if the response is missing expected fields.

§Example
let client = lineark_sdk::Client::auto()?;
let bytes = std::fs::read("screenshot.png").unwrap();
let result = client
    .upload_file("screenshot.png", "image/png", bytes, false)
    .await?;
println!("Uploaded to: {}", result.asset_url);

Trait Implementations§

Source§

impl Clone for Client

Source§

fn clone(&self) -> Client

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Client

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Client

§

impl !RefUnwindSafe for Client

§

impl Send for Client

§

impl Sync for Client

§

impl Unpin for Client

§

impl !UnwindSafe for Client

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: 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: 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