[][src]Struct gitea::Client

pub struct Client { /* fields omitted */ }

The gitea client that all gitea calls will go through. This wraps reqwest::Client and operates asyncronously.

Implementations

impl Client[src]

pub fn new<T>(base_url: String, token: String, user_agent: T) -> Result<Self> where
    T: Into<String>, 
[src]

Create a new API client with the given base URL, token and user agent. If you need inspiration for a user agent, try this:

const APP_USER_AGENT: &'static str =
   concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION"));
gitea::Client::new("https://tulpa.dev".into(), "ayylmao".into(), APP_USER_AGENT).unwrap();

pub async fn version<'_>(&'_ self) -> Result<Version>[src]

Gets the current version of gitea.

use gitea::Result;

#[tokio::main]
async fn main() -> Result<()> {
    let cli = gitea::Client::new("https://tulpa.dev".into(), "ayylmao".into(), "test/test")?;
    println!("{:?}", cli.version().await?);
    Ok(())
}

pub async fn get_release_by_tag<'_>(
    &'_ self,
    owner: String,
    repo: String,
    tag: String
) -> Result<Release>
[src]

Gets a release of a repo by its tag name.

use gitea::Result;

#[tokio::main]
async fn main() -> Result<()> {
    let cli = gitea::Client::new("https://tulpa.dev".into(), "ayylmao".into(), "test/test")?;
    let release = cli.get_release_by_tag("cadey".into(), "gitea-release".into(), "0.3.2".into()).await;
    Ok(())
}

pub async fn create_user_repo<'_>(&'_ self, cr: CreateRepo) -> Result<Repo>[src]

Creates a new gitea repo for the currently authenticated user with given details.

pub async fn create_org_repo<'_>(
    &'_ self,
    org: String,
    cr: CreateRepo
) -> Result<Repo>
[src]

Creates a new gitea repo for a given organization with given details.

pub async fn delete_repo<'_>(
    &'_ self,
    owner: String,
    repo: String
) -> Result<()>
[src]

Deletes a gitea repo by owner and name.

pub async fn get_repo<'_>(&'_ self, owner: String, repo: String) -> Result<Repo>[src]

Gets a gitea repo by name.

use gitea::Result;

#[tokio::main]
async fn main() -> Result<()> {
    let cli = gitea::Client::new("https://tulpa.dev".into(), "ayylmao".into(), "test/test")?;
    let repo = cli.get_repo("cadey".into(), "gitea-release".into()).await;
    Ok(())
}

pub async fn get_releases<'_>(
    &'_ self,
    owner: String,
    repo: String
) -> Result<Vec<Release>>
[src]

Gets all of the releases for a given gitea repo.

use gitea::Result;

#[tokio::main]
async fn main() -> Result<()> {
    let cli = gitea::Client::new("https://tulpa.dev".into(), "ayylmao".into(), "test/test")?;
    let repo = cli.get_releases("cadey".into(), "gitea-release".into()).await;
    Ok(())
}

pub async fn create_release<'_>(
    &'_ self,
    owner: String,
    repo: String,
    cr: CreateRelease
) -> Result<Release>
[src]

Creates a new gitea release.

use gitea::{CreateRelease, Result};

#[tokio::main]
async fn main() -> Result<()> {
    let cli = gitea::Client::new("https://tulpa.dev".into(), "ayylmao".into(), "test/test")?;
    let repo = cli.create_release(
        "cadey".into(),
        "gitea-release".into(),
        CreateRelease{
            body: "This is a cool release".into(),
            draft: false,
            name: "test".into(),
            prerelease: false,
            tag_name: "v4.2.0".into(),
            target_commitish: "HEAD".into(),
        },
    ).await;
    Ok(())
}

pub async fn delete_release<'_>(
    &'_ self,
    owner: String,
    repo: String,
    tag: String
) -> Result<()>
[src]

Deletes a given release by tag name.

use gitea::Result;

#[tokio::main]
async fn main() -> Result<()> {
    let cli = gitea::Client::new("https://tulpa.dev".into(), "ayylmao".into(), "test/test")?;
    let _ = cli.delete_release("cadey".into(), "gitea-release".into(), "4.2.0".into()).await;
    Ok(())
}

pub async fn whoami<'_>(&'_ self) -> Result<User>[src]

Returns information about the currently authenticated user.

Auto Trait Implementations

impl !RefUnwindSafe for Client

impl Send for Client

impl Sync for Client

impl Unpin for Client

impl !UnwindSafe for Client

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, U> Into<U> for T where
    U: From<T>, 
[src]

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.