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.
impl Client
Allow integration tests (in tests/ directory) to set base URL.
Source§impl Client
impl Client
pub 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 image_upload_from_url( &self, url: String, ) -> Result<Value, LinearError>
pub async fn comment_create( &self, input: CommentCreateInput, ) -> Result<Value, LinearError>
pub async fn issue_create( &self, input: IssueCreateInput, ) -> Result<Value, LinearError>
pub async fn issue_update( &self, input: IssueUpdateInput, id: String, ) -> Result<Value, LinearError>
pub async fn issue_archive( &self, trash: Option<bool>, id: String, ) -> Result<Value, LinearError>
pub async fn issue_unarchive(&self, id: String) -> Result<Value, LinearError>
pub async fn issue_delete( &self, permanently_delete: Option<bool>, id: String, ) -> Result<Value, LinearError>
pub async fn issue_relation_create( &self, override_created_at: Option<Value>, input: IssueRelationCreateInput, ) -> Result<Value, LinearError>
pub async fn document_create( &self, input: DocumentCreateInput, ) -> Result<Value, LinearError>
pub async fn document_update( &self, input: DocumentUpdateInput, id: String, ) -> Result<Value, LinearError>
pub async fn document_delete(&self, id: String) -> Result<Value, LinearError>
Source§impl Client
impl Client
pub fn workflow_states(&self) -> WorkflowStatesQuery<'_>
pub fn users(&self) -> UsersQuery<'_>
pub async fn whoami(&self) -> Result<User, LinearError>
pub fn projects(&self) -> ProjectsQuery<'_>
pub async fn project(&self, id: String) -> Result<Project, LinearError>
pub fn teams(&self) -> TeamsQuery<'_>
pub async fn team(&self, id: String) -> Result<Team, LinearError>
pub fn search_issues(&self, term: impl Into<String>) -> SearchIssuesQuery<'_>
pub fn issues(&self) -> IssuesQuery<'_>
pub async fn issue(&self, id: String) -> Result<Issue, LinearError>
pub fn issue_relations(&self) -> IssueRelationsQuery<'_>
pub async fn issue_relation( &self, id: String, ) -> Result<IssueRelation, LinearError>
pub fn issue_labels(&self) -> IssueLabelsQuery<'_>
pub fn documents(&self) -> DocumentsQuery<'_>
pub async fn document(&self, id: String) -> Result<Document, LinearError>
pub fn cycles(&self) -> CyclesQuery<'_>
pub async fn cycle(&self, id: String) -> Result<Cycle, LinearError>
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);