Struct github_rs::github::Client [] [src]

pub struct Client {
    pub token: AccessToken,
    pub headers: Headers,
}

Struct used to make calls to the Github API.

Fields

token: AccessToken

Token generated from here on Github that grants the Client access to various parts of the API depending on what is allowed with that token.

headers: Headers

Headers that are automatically defined and used in API Calls to the GithubAPI via the new function. If you wish to define your own to change how you make calls you should modify this variable. However, this is discouraged as the automatically created Headers contain the Authorization, API Version, Media type, and UserAgent headers for you. If you must do so it might cause undefined behavior for the API and errors encountered are not tested for and not the fault of the library authors

Methods

impl Client
[src]

fn new(acc_token: AccessToken) -> Result<Client>

Generate a new Client struct with the access token so that calls can be made to the API using it

Trait Implementations

impl Activity for Client
[src]

fn get_events(&self) -> Result<Vec<Event>>

Request Type:

GET

Endpoint:

/events

Description

Returns a vector of recent Events from the API

fn get_repos_owner_repo_events(&self, owner: &str, repo: &str) -> Result<Vec<Event>>

Request Type:

GET

Endpoint:

/repos/:owner/:repo/events

Description

Returns a vector of Events from the repo of a given owner

fn get_repos_owner_repo_issues_events(&self, owner: &str, repo: &str) -> Result<Vec<Event>>

Request Type:

GET

Endpoint:

/repos/:owner/:repo/issues/events

Description

Returns a vector of Events from the issues of a repo of a given owner

fn get_networks_owner_repo_events(&self, owner: &str, repo: &str) -> Result<Vec<Event>>

Request Type:

GET

Endpoint:

/networks/:owner/:repo/events

Description

Returns a vector of Events from the network of a repo of a given owner

fn get_orgs_org_events(&self, org: &str) -> Result<Vec<Event>>

Request Type:

GET

Endpoint:

/orgs/:org/events

Description

Returns a vector of Events from a given organization

fn get_users_username_received_events(&self, username: &str) -> Result<Vec<Event>>

Request Type:

GET

Endpoint:

/users/:username/received_events

Description

Returns a vector of Events the username has received. If you are authenticated and use your own username you will see private Events

fn get_users_username_received_events_public(&self, username: &str) -> Result<Vec<Event>>

Request Type:

GET

Endpoint:

/users/:username/received_events/public

Description

Returns a vector of public Events the username has received.

fn get_users_username_events(&self, username: &str) -> Result<Vec<Event>>

Request Type:

GET

Endpoint:

/users/:username/events

Description

Returns a vector of Events performed by the username. If you are authenticated and use your own username you will see private Events

fn get_users_username_events_public(&self, username: &str) -> Result<Vec<Event>>

Request Type:

GET

Endpoint:

/users/:username/events/public

Description

Returns a vector of Events performed by the username. If you are authenticated and use your own username you will see private Events

fn get_users_username_events_orgs_org(&self, username: &str, org: &str) -> Result<Vec<Event>>

Request Type:

GET

Endpoint:

/users/:username/events/orgs/:org

Description

Returns a vector of Events from the username's org. You must be authenticated to view this.

impl Clone for Client
[src]

fn clone(&self) -> Client

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)
1.0.0

Performs copy-assignment from source. Read more

impl Debug for Client
[src]

fn fmt(&self, __arg_0: &mut Formatter) -> Result

Formats the value using the given formatter.

impl Misc for Client
[src]

Implementation of the Misc trait for the Client

fn get_meta(&self) -> Result<Meta>

Request Type:

GET

Endpoint:

/meta

Description

Returns a Meta struct which contains information about the Github service

fn get_rate_limit(&self) -> Result<RateLimit>

Request Type:

GET

Endpoint:

/rate_limit

Description

Returns a RateLimit struct to allow the user to know how many requests they can still make. Note hiting this endpoint with a request does not count against that limit.

fn get_gitignore_templates(&self) -> Result<Vec<String>>

Request Type:

GET

Endpoint:

/gitignore/templates

Description

Returns a vector of the languages that have gitignore templates on Github.

fn get_gitignore_templates_lang(&self, lang: &str) -> Result<GitIgnore>

Request Type:

GET

Endpoint:

/gitignore/templates/:lang

Description

Returns a GitIgnore struct that has the string for the gitignore file and the language as part of it.

fn post_markdown(&self, data: Markdown) -> Result<HTML>

Request Type:

POST

Endpoint:

/markdown

Description

Returns a rendered version of the Markdown sent to Github as HTML.

fn post_markdown_raw(&self, data: Markdown) -> Result<HTML>

Request Type:

POST

Endpoint:

/markdown/raw

Description

Returns a rendered version of the markdown posted to it. This expects the request to not be JSON so right now this function is broken until it can be updated to work properly.

impl Repos for Client
[src]

Implementation of the Repos trait for the Client

fn post_user_repos(&self, repo: RepoCreate) -> Result<Repo>

Request Type:

POST

Endpoint:

/user/repos

Description

Creates a new repo for the authenticated user and returns the new Repos stats

impl Users for Client
[src]

fn get_user(&self) -> Result<User>

Request Type:

GET

Endpoint:

/user

Description

Returns a User Struct for the authenticated user.

fn get_users_username(&self, username: &str) -> Result<User>

Request Type:

GET

Endpoint:

/users/:username

Description

Returns a User Struct for the person whose name is passed into the function

fn get_users(&self, user_id: Option<u64>, per_page: Option<u64>) -> Result<Vec<User>>

Request Type:

GET

Endpoint:

/users

Description

Returns a vector of Users from the website. This is a paginated request to the endpoint.

fn get_user_emails(&self, page_num: Option<u64>, per_page: Option<u64>) -> Result<Vec<Email>>

Request Type:

GET

Endpoint:

/user/emails

Description

Returns a vector of Emails of the authenticated user. This is a paginated request to the endpoint.

fn get_users_username_followers(&self, username: &str, page_num: Option<u64>, per_page: Option<u64>) -> Result<Vec<User>>

Request Type:

GET

Endpoint:

/users/:username/followers

Description

Returns a vector of Users following the username passed into the function. This is a paginated request to the endpoint.

fn get_user_followers(&self, page_num: Option<u64>, per_page: Option<u64>) -> Result<Vec<User>>

Request Type:

GET

Endpoint:

/user/followers

Description

Returns a vector of Users followin the authenticated user. This is a paginated request to the endpoint.

fn get_users_username_following(&self, username: &str, page_num: Option<u64>, per_page: Option<u64>) -> Result<Vec<User>>

Request Type:

GET

Endpoint:

/users/:username/following

Description

Returns a vector of Users that the given username is following. This is a paginated request to the endpoint.

fn get_user_following(&self, page_num: Option<u64>, per_page: Option<u64>) -> Result<Vec<User>>

Request Type:

GET

Endpoint:

/user/following

Description

Returns a vector of all Users the authenticated user is following. This is a paginated request to the endpoint.

fn patch_user(&self, user: PatchUser) -> Result<User>

Request Type:

PATCH

Endpoint:

/user

Description

Returns a User struct of the authenticated user once their data has been updated

fn post_user_emails(&self, emails: Vec<String>) -> Result<Vec<Email>>

Request Type:

POST

Endpoint:

/user/emails

Description

Returns a vector of Emails when they've been added to the user's profile

fn put_user_following_username(&self, username: &str) -> Result<bool>

Request Type:

PUT

Endpoint:

/user/following/:username

Description

Returns true is the user is now following the given username and false otherwise

fn delete_user_following_username(&self, username: &str) -> Result<bool>

Request Type:

DELETE

Endpoint:

/user/following/:username

Description

Returns true if the authenticated user unfollowed the username passed in and false otherwise.

fn get_user_following_username(&self, username: &str) -> Result<bool>

Request Type:

GET

Endpoint:

/user/following/:username

Description

Returns true if the authenticated user is following the username passed to the function and false otherwise.

fn get_users_username_following_target_user(&self, username: &str, target_user: &str) -> Result<bool>

Request Type:

GET

Endpoint:

/users/:username/following/:target_user

Description

Returns true is the username is following the target user and false otherwise.

fn get_users_username_keys(&self, username: &str) -> Result<Vec<SSHKey>>

Request Type:

GET

Endpoint:

/users/:username/keys

Description

Returns a Vector of all SSHKeys from the username specified

fn get_user_keys(&self) -> Result<Vec<SSHKey>>

Request Type:

GET

Endpoint:

/user/keys

Description

Returns a Vector of all SSHKeys that the authenticate user might have.

fn get_user_keys_id(&self, id: u64) -> Result<Option<SSHKey>>

Request Type:

GET

Endpoint:

/user/keys/:id

Description

Returns an SSHKey to the user that is specified by id. If it does not exist a None value is returned.

fn post_user_keys(&self, new_key: SSHKey) -> Result<SSHKey>

Request Type:

POST

Endpoint:

/user/keys

Description

Creates a new SSH key sending it back if it worked out properly.

fn delete_user_keys(&self, id: u64) -> Result<bool>

Request Type:

DELETE

Endpoint:

/user/keys

Description

Returns a boolean value. True is the ssh key was deleted and false otherwise. The id number of the key is what is used to determine which one to delete.

fn delete_user_emails(&self, emails: Vec<String>) -> Result<bool>

Request Type:

DELETE

Endpoint:

/user/emails

Description

Returns a boolean value. True if the email(s) were deleted and false otherwise. The email strings must match verbatim for the corresponding email to be deleted.