[][src]Struct octocrab::Octocrab

pub struct Octocrab {
    pub base_url: Url,
    // some fields omitted
}

The GitHub API client.

Fields

base_url: Url

Implementations

impl Octocrab[src]

pub fn builder() -> OctocrabBuilder[src]

Returns a new OctocrabBuilder.

impl Octocrab[src]

pub fn actions(&self) -> ActionsHandler<'_>[src]

Creates a new actions::ActionsHandler for accessing information from GitHub Actions.

pub fn current(&self) -> CurrentAuthHandler<'_>[src]

Creates a current::CurrentAuthHandler that allows you to access information about the current authenticated user.

pub fn activity(&self) -> ActivityHandler<'_>[src]

Creates a activity::ActivityHandler for the current authenticated user.

pub fn gitignore(&self) -> GitignoreHandler<'_>[src]

Creates a gitignore::GitignoreHandler for accessing information about gitignore.

pub fn issues(
    &self,
    owner: impl Into<String>,
    repo: impl Into<String>
) -> IssueHandler<'_>
[src]

Creates a issues::IssueHandler for the repo specified at owner/repo, that allows you to access GitHub's issues API.

pub fn licenses(&self) -> LicenseHandler<'_>[src]

pub fn markdown(&self) -> MarkdownHandler<'_>[src]

pub fn orgs(&self, owner: impl Into<String>) -> OrgHandler<'_>[src]

Creates an orgs::OrgHandler for the specified organization, that allows you to access GitHub's organization API.

pub fn pulls(
    &self,
    owner: impl Into<String>,
    repo: impl Into<String>
) -> PullRequestHandler<'_>
[src]

Creates a pulls::PullRequestHandler for the repo specified at owner/repo, that allows you to access GitHub's pull request API.

pub fn repos(
    &self,
    owner: impl Into<String>,
    repo: impl Into<String>
) -> RepoHandler<'_>
[src]

Creates a repos::RepoHandler for the repo specified at owner/repo, that allows you to access GitHub's repository API.

pub fn search(&self) -> SearchHandler<'_>[src]

Creates a search::SearchHandler that allows you to construct general queries to GitHub's API.

pub fn teams(&self, owner: impl Into<String>) -> TeamHandler<'_>[src]

Creates a teams::TeamHandler for the specified organization that allows you to access GitHub's teams API.

impl Octocrab[src]

pub async fn graphql<R: FromResponse>(
    &self,
    body: &impl Serialize + ?Sized
) -> Result<R>
[src]

Sends a graphql query to GitHub, and deserialises the response from JSON.

let response: serde_json::Value = octocrab::instance()
    .graphql("query { viewer { login }}")
    .await?;

impl Octocrab[src]

HTTP Methods

A collection of different of HTTP methods to use with Octocrab's configuration (Authenication, etc.). All of the HTTP methods (get, post, etc.) perform some amount of pre-processing such as making relative urls absolute, and post processing such as mapping any potential GitHub errors into Err() variants, and deserializing the response body.

This isn't always ideal when working with GitHub's API and as such there are additional methods available prefixed with _ (e.g. _get, _post, etc.) that perform no pre or post processing and directly return the reqwest::Response struct.

pub async fn post<P: Serialize + ?Sized, R: FromResponse>(
    &self,
    route: impl AsRef<str>,
    body: Option<&P>
) -> Result<R>
[src]

Send a POST request to route with an optional body, returning the body of the response.

pub async fn _post<P: Serialize + ?Sized>(
    &self,
    url: impl IntoUrl,
    body: Option<&P>
) -> Result<Response>
[src]

Send a POST request with no additional pre/post-processing.

pub async fn get<R, A, P: ?Sized>(
    &self,
    route: A,
    parameters: Option<&P>
) -> Result<R> where
    A: AsRef<str>,
    P: Serialize,
    R: FromResponse
[src]

Send a GET request to route with optional query parameters, returning the body of the response.

pub async fn _get<P: Serialize + ?Sized>(
    &self,
    url: impl IntoUrl,
    parameters: Option<&P>
) -> Result<Response>
[src]

Send a GET request with no additional post-processing.

pub async fn patch<R, A, B: ?Sized>(
    &self,
    route: A,
    body: Option<&B>
) -> Result<R> where
    A: AsRef<str>,
    B: Serialize,
    R: FromResponse
[src]

Send a PATCH request to route with optional query parameters, returning the body of the response.

pub async fn _patch<B: Serialize + ?Sized>(
    &self,
    url: impl IntoUrl,
    parameters: Option<&B>
) -> Result<Response>
[src]

Send a PATCH request with no additional post-processing.

pub async fn put<R, A, B: ?Sized>(
    &self,
    route: A,
    body: Option<&B>
) -> Result<R> where
    A: AsRef<str>,
    B: Serialize,
    R: FromResponse
[src]

Send a PUT request to route with optional query parameters, returning the body of the response.

pub async fn _put<B: Serialize + ?Sized>(
    &self,
    url: impl IntoUrl,
    body: Option<&B>
) -> Result<Response>
[src]

Send a PATCH request with no additional post-processing.

pub async fn delete<R, A, P: ?Sized>(
    &self,
    route: A,
    parameters: Option<&P>
) -> Result<R> where
    A: AsRef<str>,
    P: Serialize,
    R: FromResponse
[src]

Send a DELETE request to route with optional query parameters, returning the body of the response.

pub async fn _delete<P: Serialize + ?Sized>(
    &self,
    url: impl IntoUrl,
    parameters: Option<&P>
) -> Result<Response>
[src]

Send a DELETE request with no additional post-processing.

pub fn request_builder(
    &self,
    url: impl IntoUrl,
    method: Method
) -> RequestBuilder
[src]

Construct a reqwest::RequestBuilder with the given http method. This can be executed with execute.

let octocrab = octocrab::instance();
let url = format!("{}/events", octocrab.base_url);
let builder = octocrab::instance().request_builder(&url, reqwest::Method::GET)
    .header("if-none-match", "\"73ca617c70cd2bd9b6f009dab5e2d49d\"");
let response = octocrab.execute(builder).await?;

pub async fn execute(&self, request: RequestBuilder) -> Result<Response>[src]

Execute the given request octocrab's Client.

impl Octocrab[src]

pub fn absolute_url(&self, url: impl AsRef<str>) -> Result<Url>[src]

Returns an absolute url version of url using the base_url (default: https://api.github.com)

pub async fn get_page<R: DeserializeOwned>(
    &self,
    url: &Option<Url>
) -> Result<Option<Page<R>>>
[src]

A convience method to get the a page of results (if present).

Trait Implementations

impl Clone for Octocrab[src]

impl Debug for Octocrab[src]

impl Default for Octocrab[src]

Defaults for Octocrab:

  • base_url: https://api.github.com
  • auth: None
  • client: reqwest client with the octocrab user agent.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.