GitHubClient

Struct GitHubClient 

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

GitHub API client

Implementations§

Source§

impl GitHubClient

Source

pub fn new( token: impl Into<String>, owner: impl Into<String>, repo: impl Into<String>, ) -> Result<Self>

Create a new GitHub client with personal access token

§Arguments
  • token - GitHub personal access token (ghp_xxx)
  • owner - Repository owner (user or organization)
  • repo - Repository name
§Example
use miyabi_github::GitHubClient;

let client = GitHubClient::new("ghp_xxx", "user", "repo")?;
Source

pub fn octocrab(&self) -> &Octocrab

Get the underlying Octocrab client for advanced usage

Source

pub fn owner(&self) -> &str

Get repository owner

Source

pub fn repo(&self) -> &str

Get repository name

Source

pub fn full_name(&self) -> String

Get full repository name (owner/repo)

Source

pub async fn verify_auth(&self) -> Result<String>

Verify authentication by fetching current user

Source

pub async fn get_repository(&self) -> Result<Repository>

Get repository information

Source§

impl GitHubClient

Source

pub async fn get_issue(&self, number: u64) -> Result<Issue>

Get a single issue by number

§Arguments
  • number - Issue number
§Returns

Issue struct with all metadata

Source

pub async fn list_issues( &self, state: Option<State>, labels: Vec<String>, ) -> Result<Vec<Issue>>

List issues with optional filtering

§Arguments
  • state - Filter by state (Open/Closed/All)
  • labels - Filter by labels (empty = all)
§Returns

Vector of Issue structs

Source

pub async fn create_issue( &self, title: &str, body: Option<&str>, ) -> Result<Issue>

Create a new issue

§Arguments
  • title - Issue title
  • body - Issue body (optional)
§Returns

Created Issue struct

Source

pub async fn update_issue( &self, number: u64, title: Option<&str>, body: Option<&str>, state: Option<State>, ) -> Result<Issue>

Update an existing issue

§Arguments
  • number - Issue number to update
  • title - New title (optional)
  • body - New body (optional)
  • state - New state (optional)
§Returns

Updated Issue struct

Source

pub async fn close_issue(&self, number: u64) -> Result<Issue>

Close an issue

Source

pub async fn reopen_issue(&self, number: u64) -> Result<Issue>

Reopen an issue

Source

pub async fn add_labels( &self, number: u64, labels: &[String], ) -> Result<Vec<String>>

Add labels to an issue

§Arguments
  • number - Issue number
  • labels - Labels to add
Source

pub async fn remove_label(&self, number: u64, label: &str) -> Result<()>

Remove a label from an issue

§Arguments
  • number - Issue number
  • label - Label to remove
Source

pub async fn replace_labels( &self, number: u64, labels: &[String], ) -> Result<Vec<String>>

Replace all labels on an issue

§Arguments
  • number - Issue number
  • labels - New set of labels
Source

pub async fn get_issues_by_state(&self, state: IssueState) -> Result<Vec<Issue>>

Get issues by state label (e.g., “state:pending”)

§Arguments
  • state - IssueState enum value
§Returns

Vector of issues with that state label

Source§

impl GitHubClient

Source

pub async fn list_labels(&self) -> Result<Vec<Label>>

List all labels in the repository

Source

pub async fn get_label(&self, name: &str) -> Result<Label>

Get a single label by name

Source

pub async fn create_label( &self, name: &str, color: &str, description: Option<&str>, ) -> Result<Label>

Create a new label

§Arguments
  • name - Label name
  • color - Label color (hex without #, e.g., “ff0000”)
  • description - Label description (optional)
Source

pub async fn update_label( &self, name: &str, new_name: Option<&str>, color: Option<&str>, description: Option<&str>, ) -> Result<Label>

Update an existing label

§Arguments
  • name - Current label name
  • new_name - New label name (optional)
  • color - New color (optional)
  • description - New description (optional)
Source

pub async fn delete_label(&self, name: &str) -> Result<()>

Delete a label

Source

pub async fn bulk_create_labels(&self, labels: Vec<Label>) -> Result<Vec<Label>>

Bulk create labels from a list

§Arguments
  • labels - Vector of labels to create
§Returns

Vector of created labels (some may fail, errors are logged)

Source

pub async fn label_exists(&self, name: &str) -> Result<bool>

Check if a label exists

Source

pub async fn sync_labels(&self, labels: Vec<Label>) -> Result<usize>

Sync labels from a YAML/JSON definition file (Useful for setting up the 53-label system)

§Arguments
  • labels - Labels to sync
§Returns

Number of labels created/updated

Source§

impl GitHubClient

GitHub Projects V2 client

Source

pub async fn get_project_items( &self, project_number: u32, ) -> Result<Vec<ProjectItem>>

Get all items from a GitHub Project V2

§Arguments
  • project_number - Project number (e.g., 1 for /projects/1)
§Example
use miyabi_github::GitHubClient;

let client = GitHubClient::new("ghp_xxx", "owner", "repo")?;
let items = client.get_project_items(1).await?;
println!("Found {} items", items.len());
Source

pub async fn update_project_field( &self, project_id: &str, item_id: &str, field_name: &str, value: &str, ) -> Result<()>

Update a custom field value for a project item

§Arguments
  • project_id - Project node ID (e.g., “PVT_kwDOAB…”)
  • item_id - Project item node ID
  • field_name - Custom field name (e.g., “Status”, “Agent”)
  • value - New value
§Example
use miyabi_github::GitHubClient;

let client = GitHubClient::new("ghp_xxx", "owner", "repo")?;
client.update_project_field(
    "PVT_kwDOAB...",
    "PVTI_lADO...",
    "Status",
    "Done"
).await?;
Source

pub async fn calculate_project_kpis( &self, project_number: u32, ) -> Result<KPIReport>

Calculate KPIs from project data

§Arguments
  • project_number - Project number
§Returns

KPIReport with aggregated metrics

Source§

impl GitHubClient

Source

pub async fn get_pull_request(&self, number: u64) -> Result<PRResult>

Get a single pull request by number

§Arguments
  • number - Pull request number
Source

pub async fn list_pull_requests( &self, state: Option<State>, ) -> Result<Vec<PRResult>>

List pull requests with optional filtering

§Arguments
  • state - Filter by state (Open/Closed/All)
Source

pub async fn create_pull_request( &self, title: &str, head: &str, base: &str, body: Option<&str>, draft: bool, ) -> Result<PRResult>

Create a pull request

§Arguments
  • title - PR title
  • head - Branch containing changes
  • base - Base branch (e.g., “main”)
  • body - PR body (optional)
  • draft - Create as draft PR
Source

pub async fn update_pull_request( &self, number: u64, title: Option<&str>, body: Option<&str>, state: Option<PullState>, ) -> Result<PRResult>

Update a pull request

§Arguments
  • number - PR number to update
  • title - New title (optional)
  • body - New body (optional)
  • state - New state (optional)
Source

pub async fn close_pull_request(&self, number: u64) -> Result<PRResult>

Close a pull request (without merging)

Source

pub async fn merge_pull_request( &self, number: u64, commit_title: Option<&str>, commit_message: Option<&str>, ) -> Result<()>

Merge a pull request

§Arguments
  • number - PR number to merge
  • commit_title - Merge commit title (optional)
  • commit_message - Merge commit message (optional)
Source

pub async fn is_mergeable(&self, number: u64) -> Result<bool>

Check if a pull request is mergeable

Trait Implementations§

Source§

impl Clone for GitHubClient

Source§

fn clone(&self) -> GitHubClient

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

Auto Trait Implementations§

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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
Source§

impl<T> ErasedDestructor for T
where T: 'static,