pub struct Client { /* private fields */ }Expand description
The Linear API client.
Implementations§
Source§impl Client
impl Client
Sourcepub fn from_token(token: impl Into<String>) -> Result<Self, LinearError>
pub fn from_token(token: impl Into<String>) -> Result<Self, LinearError>
Create a client with an explicit API token.
Sourcepub fn from_env() -> Result<Self, LinearError>
pub fn from_env() -> Result<Self, LinearError>
Create a client from the LINEAR_API_TOKEN environment variable.
Sourcepub fn from_file() -> Result<Self, LinearError>
pub fn from_file() -> Result<Self, LinearError>
Create a client from the ~/.linear_api_token file.
Sourcepub fn auto() -> Result<Self, LinearError>
pub fn auto() -> Result<Self, LinearError>
Create a client by auto-detecting the token (env -> file).
Sourcepub async fn execute<T: DeserializeOwned>(
&self,
query: &str,
variables: Value,
data_path: &str,
) -> Result<T, LinearError>
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.
Sourcepub async fn execute_connection<T: DeserializeOwned>(
&self,
query: &str,
variables: Value,
data_path: &str,
) -> Result<Connection<T>, LinearError>
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
impl Client
Sourcepub fn workflow_states(&self) -> WorkflowStatesQueryBuilder<'_>
pub fn workflow_states(&self) -> WorkflowStatesQueryBuilder<'_>
All issue workflow states.
Sourcepub fn users(&self) -> UsersQueryBuilder<'_>
pub fn users(&self) -> UsersQueryBuilder<'_>
All users for the organization.
Sourcepub async fn whoami(&self) -> Result<User, LinearError>
pub async fn whoami(&self) -> Result<User, LinearError>
The currently authenticated user.
Sourcepub fn projects(&self) -> ProjectsQueryBuilder<'_>
pub fn projects(&self) -> ProjectsQueryBuilder<'_>
All projects.
Sourcepub fn teams(&self) -> TeamsQueryBuilder<'_>
pub fn teams(&self) -> TeamsQueryBuilder<'_>
All teams whose issues can be accessed by the user. This might be different from administrableTeams, which also includes teams whose settings can be changed by the user.
Sourcepub fn search_issues(
&self,
term: impl Into<String>,
) -> SearchIssuesQueryBuilder<'_>
pub fn search_issues( &self, term: impl Into<String>, ) -> SearchIssuesQueryBuilder<'_>
Search issues.
Sourcepub fn issues(&self) -> IssuesQueryBuilder<'_>
pub fn issues(&self) -> IssuesQueryBuilder<'_>
All issues.
Sourcepub fn issue_relations(&self) -> IssueRelationsQueryBuilder<'_>
pub fn issue_relations(&self) -> IssueRelationsQueryBuilder<'_>
All issue relationships.
Sourcepub async fn issue_relation(
&self,
id: String,
) -> Result<IssueRelation, LinearError>
pub async fn issue_relation( &self, id: String, ) -> Result<IssueRelation, LinearError>
One specific issue relation.
Sourcepub fn issue_labels(&self) -> IssueLabelsQueryBuilder<'_>
pub fn issue_labels(&self) -> IssueLabelsQueryBuilder<'_>
All issue labels.
Sourcepub fn documents(&self) -> DocumentsQueryBuilder<'_>
pub fn documents(&self) -> DocumentsQueryBuilder<'_>
All documents in the workspace.
Sourcepub async fn document(&self, id: String) -> Result<Document, LinearError>
pub async fn document(&self, id: String) -> Result<Document, LinearError>
One specific document.
Sourcepub fn cycles(&self) -> CyclesQueryBuilder<'_>
pub fn cycles(&self) -> CyclesQueryBuilder<'_>
All cycles.
Sourcepub async fn file_upload(
&self,
meta_data: Option<Value>,
make_public: Option<bool>,
size: i64,
content_type: String,
filename: String,
) -> Result<Value, LinearError>
pub async fn file_upload( &self, meta_data: Option<Value>, make_public: Option<bool>, size: i64, content_type: String, filename: String, ) -> Result<Value, LinearError>
XHR request payload to upload an images, video and other attachments directly to Linear’s cloud storage.
Sourcepub async fn image_upload_from_url(
&self,
url: String,
) -> Result<Value, LinearError>
pub async fn image_upload_from_url( &self, url: String, ) -> Result<Value, LinearError>
Upload an image from an URL to Linear.
Sourcepub async fn issue_create(
&self,
input: IssueCreateInput,
) -> Result<Value, LinearError>
pub async fn issue_create( &self, input: IssueCreateInput, ) -> Result<Value, LinearError>
Creates a new issue.
Sourcepub async fn issue_update(
&self,
input: IssueUpdateInput,
id: String,
) -> Result<Value, LinearError>
pub async fn issue_update( &self, input: IssueUpdateInput, id: String, ) -> Result<Value, LinearError>
Updates an issue.
Sourcepub async fn issue_archive(
&self,
trash: Option<bool>,
id: String,
) -> Result<Value, LinearError>
pub async fn issue_archive( &self, trash: Option<bool>, id: String, ) -> Result<Value, LinearError>
Archives an issue.
Sourcepub async fn issue_unarchive(&self, id: String) -> Result<Value, LinearError>
pub async fn issue_unarchive(&self, id: String) -> Result<Value, LinearError>
Unarchives an issue.
Sourcepub async fn issue_delete(
&self,
permanently_delete: Option<bool>,
id: String,
) -> Result<Value, LinearError>
pub async fn issue_delete( &self, permanently_delete: Option<bool>, id: String, ) -> Result<Value, LinearError>
Deletes (trashes) an issue.
Sourcepub async fn issue_relation_create(
&self,
override_created_at: Option<Value>,
input: IssueRelationCreateInput,
) -> Result<Value, LinearError>
pub async fn issue_relation_create( &self, override_created_at: Option<Value>, input: IssueRelationCreateInput, ) -> Result<Value, LinearError>
Creates a new issue relation.
Sourcepub async fn document_create(
&self,
input: DocumentCreateInput,
) -> Result<Value, LinearError>
pub async fn document_create( &self, input: DocumentCreateInput, ) -> Result<Value, LinearError>
Creates a new document.
Sourcepub async fn document_update(
&self,
input: DocumentUpdateInput,
id: String,
) -> Result<Value, LinearError>
pub async fn document_update( &self, input: DocumentUpdateInput, id: String, ) -> Result<Value, LinearError>
Updates a document.
Sourcepub async fn document_delete(&self, id: String) -> Result<Value, LinearError>
pub async fn document_delete(&self, id: String) -> Result<Value, LinearError>
Deletes (trashes) a document.
Sourcepub async fn comment_create(
&self,
input: CommentCreateInput,
) -> Result<Value, LinearError>
pub async fn comment_create( &self, input: CommentCreateInput, ) -> Result<Value, LinearError>
Creates a new comment.
Source§impl Client
impl Client
Sourcepub async fn download_url(
&self,
url: &str,
) -> Result<DownloadResult, LinearError>
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();Sourcepub async fn upload_file(
&self,
filename: &str,
content_type: &str,
bytes: Vec<u8>,
make_public: bool,
) -> Result<UploadResult, LinearError>
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:
- Call the
fileUploadGraphQL mutation to obtain a signed upload URL and required headers from Linear. PUTthe 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— Iftrue, 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);