Skip to main content

Client

Struct Client 

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

Implementations§

Source§

impl Client

Source

pub fn start_copilot_agent_task( &self, input: &StartTask, scope: &TaskScope, ) -> Result<Task, Error>

Source

pub fn start_copilot_agent_task_with_submission( &self, input: &StartTask, scope: &TaskScope, submission: &Submission, ) -> Result<Task, Error>

Source

pub fn list_my_copilot_agent_tasks(&self) -> Result<TaskList, Error>

The authenticated work user’s recent tasks across every repository. Missing repository names and pull node ids are resolved once per repository, not once per task.

Source

pub fn get_copilot_agent_task_detail( &self, task_id: &str, subject: Option<Subject>, ) -> Result<TaskDetail, Error>

One task and its sessions, by id, without a repository path.

Source§

impl Client

Source

pub fn copilot_api_url(&self) -> Result<String, Error>

The Copilot API base for the work account. GraphQL answers it, and the answer is kept for the run, so one process asks once.

Source

pub fn copilot_agent_session( &self, session_id: &str, ) -> Result<CopilotAgentSession, Error>

One session document. It carries the pull request number and state the REST task artifact may be missing.

Source

pub fn copilot_agent_session_log( &self, session_id: &str, max_bytes: usize, ) -> Result<SessionLog, Error>

One session’s log, parsed. max_bytes never goes above MAX_LOG_BYTES; a log the cap cut says so.

Source§

impl Client

Source

pub fn prepare_issue_report(&self, report: PreparedReport) -> ReportPlan

Resolve credentials in the existing priority, using gh’s active account. Performs no HTTP request and never switches or refreshes an account.

Source

pub fn submit_issue_report(&self, plan: ReportPlan) -> Result<Outcome, Error>

Consume the review plan. No automatic retry, including parse failures.

Source§

impl Client

Source

pub fn bind_read(&self, login: &str) -> Result<BoundRead, Error>

Capture one credential and verify that it owns the requested login.

Source

pub fn new(credentials: Arc<Credentials>) -> Self

Examples found in repository?
examples/github_smoke.rs (line 18)
14fn main() {
15    let config = config::path()
16        .map(|path| config::load(&path).0)
17        .unwrap_or_default();
18    let client = Client::new(Arc::new(Credentials::from_system(&config)));
19    let login = active_login(&client);
20    let first_pr = print_sections(&client, &login);
21    print_diff(&client, &login, first_pr.as_deref());
22}

One bounded repository search. Scope is part of the GraphQL repository, so user search text cannot widen it to other repositories.

Source

pub fn agent_write( &self, login: &str, key: &str, action: &str, fields: Value, ) -> Result<Value, Error>

Named GraphQL writes, each sent once. Never offers a raw HTTP surface.

Source

pub fn with_api_url(self, api_url: impl Into<String>) -> Self

Sends every request to api_url instead of api.github.com (tests).

Source

pub fn with_work_account(self, login: Option<String>) -> Self

Prefer this configured gh account for Copilot work, before EMU detection.

Source

pub fn accounts(&self) -> Result<GitHubAccounts, Error>

The accounts to offer: the signed-in and gh accounts for github.com; but when the token comes from the environment or the config file, the one account that token belongs to (REQ-60).

Examples found in repository?
examples/github_smoke.rs (line 26)
25fn active_login(client: &Client) -> String {
26    let accounts = match client.accounts() {
27        Ok(accounts) => accounts,
28        Err(error) => {
29            eprintln!("accounts: {error}");
30            std::process::exit(1);
31        }
32    };
33    println!("accounts: {}", accounts.logins.join(", "));
34    let Some(login) = accounts
35        .active
36        .clone()
37        .or_else(|| accounts.logins.first().cloned())
38    else {
39        eprintln!("no account");
40        std::process::exit(1);
41    };
42    println!("active: {login} (short: {})", short_login(&login));
43    login
44}
Source

pub fn viewer_login(&self, login: Option<&str>) -> Result<String, Error>

The login of the token for login (or the default token).

Source

pub fn work_login(&self) -> Result<String, Error>

Selects the chosen gh account, else the first enterprise (EMU) login, and verifies that the selected credential really belongs to it. Environment tokens belonging to another account are rejected.

Source

pub fn credential( &self, login: Option<&str>, ) -> Result<Credential, CredentialError>

The credential for login (REQ-21), for callers that only need to know whether one exists.

Source

pub fn section( &self, login: &str, section_id: &str, repos: Option<&[String]>, ) -> Result<SectionResponse, Error>

One section: up to 50 items, most recently updated first. repos limits it to those repositories (None: everything the account can see); a repos_only section without repositories is empty and sends nothing. Long repository lists run as several searches in parallel, merged by update time.

Source

pub fn repositories( &self, login: &str, text: &str, ) -> Result<Vec<GhRepository>, Error>

Repositories the account can see for text: GitHub’s repository search, or with no text the account’s own and member repositories, most recently pushed first. At most 30.

Source

pub fn sections( &self, login: &str, ) -> Vec<(&'static str, Result<SectionResponse, Error>)>

Every section, account-wide, in SECTIONS order, in parallel.

Examples found in repository?
examples/github_smoke.rs (line 49)
47fn print_sections(client: &Client, login: &str) -> Option<String> {
48    let mut first_pr = None;
49    for (id, result) in client.sections(login) {
50        match result {
51            Ok(section) => {
52                println!(
53                    "section {id}: {} items of {}",
54                    section.items.len(),
55                    section.total
56                );
57                if first_pr.is_none() {
58                    first_pr = section
59                        .items
60                        .iter()
61                        .find(|item| item.kind == ItemKind::Pr)
62                        .map(|item| item.key.clone());
63                }
64            }
65            Err(error) => println!("section {id}: error: {error}"),
66        }
67    }
68    first_pr
69}
Source

pub fn item(&self, login: &str, key: &str) -> Result<GhItemDetail, Error>

The detail of key (owner/name#number).

Source

pub fn assignable( &self, login: &str, repo: &str, ) -> Result<AssignableResponse, Error>

The people who can be assigned in repo, cached for 10 minutes.

Source

pub fn review( &self, login: &str, key: &str, event: ReviewEvent, body: &str, ) -> Result<GhItemDetail, Error>

Approves, requests changes or comments as a review; returns the fresh detail. The body is required except for an approval.

Source

pub fn default_branch(&self, login: &str, repo: &str) -> Result<String, Error>

The repository’s default branch, which a cloud agent task branches from when the caller names none.

Source

pub fn comment( &self, login: &str, key: &str, body: &str, ) -> Result<GhItemDetail, Error>

Comments on an issue or pull request; returns the fresh detail.

Source

pub fn set_assignees( &self, login: &str, key: &str, add: &[String], remove: &[String], ) -> Result<GhItemDetail, Error>

Adds and removes assignees (at most 10 each, at least one in all); returns the fresh detail.

Source

pub fn diff(&self, login: &str, key: &str) -> Result<DiffResponse, Error>

A pull request’s changed files, with the merge base as the old side of every patch. Cached per base and head SHA.

Examples found in repository?
examples/github_smoke.rs (line 76)
71fn print_diff(client: &Client, login: &str, key: Option<&str>) {
72    let Some(key) = key else {
73        println!("diff: no pull request in any section");
74        return;
75    };
76    match client.diff(login, key) {
77        Ok(diff) => println!(
78            "diff: a pull request with {} files of {} (merge base {}…, head {}…)",
79            diff.files.len(),
80            diff.total,
81            &diff.base_sha[..7],
82            &diff.head_sha[..7]
83        ),
84        Err(error) => println!("diff: error: {error}"),
85    }
86}
Source

pub fn file( &self, login: &str, repo: &str, sha: &str, path: &str, ) -> Result<FileResponse, Error>

One file’s text at a commit, up to 1 MB (else 413); a binary file is a 415. Cached per account, up to 50 MB.

Source

pub fn image( &self, login: &str, repo: &str, sha: &str, path: &str, ) -> Result<Image, Error>

One image at a commit, up to 10 MB. Only the extensions of image_type; other paths are a 415. Not cached.

Trait Implementations§

Source§

impl ActionsApi for Client

Source§

fn actions_workflows( &self, login: &str, repo: &str, ) -> Result<Page<Workflow>, Error>

Source§

fn actions_runs( &self, login: &str, repo: &str, filters: &RunFilters, ) -> Result<Page<WorkflowRun>, Error>

Source§

fn actions_run( &self, login: &str, repo: &str, run_id: u64, ) -> Result<WorkflowRun, Error>

Source§

fn actions_jobs( &self, login: &str, repo: &str, run_id: u64, ) -> Result<Page<Job>, Error>

Source§

fn actions_job_log( &self, login: &str, repo: &str, job_id: u64, ) -> Result<JobLog, Error>

Source§

fn actions_workflow_definition( &self, login: &str, repo: &str, sha: &str, path: &str, ) -> Result<Definition<WorkflowDefinition>, Error>

Source§

fn actions_pending_deployments( &self, login: &str, repo: &str, run_id: u64, ) -> Result<Vec<PendingDeployment>, Error>

Source§

fn actions_environments( &self, login: &str, repo: &str, ) -> Result<Page<Environment>, Error>

Source§

fn actions_deployments( &self, login: &str, repo: &str, environment: Option<&str>, ) -> Result<Page<Deployment>, Error>

Source§

fn actions_latest_deployment( &self, login: &str, repo: &str, environment: &str, ) -> Result<Option<Deployment>, Error>

Source§

fn actions_releases( &self, login: &str, repo: &str, ) -> Result<Page<Release>, Error>

Source§

fn actions_tags(&self, login: &str, repo: &str) -> Result<Page<TagRef>, Error>

Source§

fn dispatch_workflow( &self, login: &str, request: &DispatchRequest<'_>, ) -> Result<(), Error>

Source§

fn rerun_workflow( &self, login: &str, repo: &str, run_id: u64, ) -> Result<(), Error>

Source§

fn rerun_failed_jobs( &self, login: &str, repo: &str, run_id: u64, ) -> Result<(), Error>

Source§

fn cancel_workflow( &self, login: &str, repo: &str, run_id: u64, ) -> Result<(), Error>

Source§

fn review_pending_deployments( &self, login: &str, request: &ReviewPendingRequest<'_>, ) -> Result<(), Error>

Auto Trait Implementations§

§

impl !Freeze for Client

§

impl !RefUnwindSafe for Client

§

impl !UnwindSafe for Client

§

impl Forget for Client

§

impl Move for Client

§

impl Send for Client

§

impl Sync for Client

§

impl Unpin for Client

§

impl UnsafeUnpin 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> 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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