pub struct Client { /* private fields */ }
Expand description
The gitea client that all gitea calls will go through. This wraps reqwest::Client and operates asyncronously.
Implementations§
Source§impl Client
impl Client
Sourcepub fn new<T>(base_url: String, token: String, user_agent: T) -> Result<Self>
pub fn new<T>(base_url: String, token: String, user_agent: T) -> Result<Self>
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();
Sourcepub async fn version(&self) -> Result<Version>
pub async fn version(&self) -> Result<Version>
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(())
}
Sourcepub async fn get_release_by_tag(
&self,
owner: String,
repo: String,
tag: String,
) -> Result<Release>
pub async fn get_release_by_tag( &self, owner: String, repo: String, tag: String, ) -> Result<Release>
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(())
}
Sourcepub async fn create_user_repo(&self, cr: CreateRepo) -> Result<Repo>
pub async fn create_user_repo(&self, cr: CreateRepo) -> Result<Repo>
Creates a new gitea repo for the currently authenticated user with given details.
Sourcepub async fn create_org_repo(&self, org: String, cr: CreateRepo) -> Result<Repo>
pub async fn create_org_repo(&self, org: String, cr: CreateRepo) -> Result<Repo>
Creates a new gitea repo for a given organization with given details.
Sourcepub async fn delete_repo(&self, owner: String, repo: String) -> Result<()>
pub async fn delete_repo(&self, owner: String, repo: String) -> Result<()>
Deletes a gitea repo by owner and name.
Sourcepub async fn get_repo(&self, owner: String, repo: String) -> Result<Repo>
pub async fn get_repo(&self, owner: String, repo: String) -> Result<Repo>
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(())
}
Sourcepub async fn get_releases(
&self,
owner: String,
repo: String,
) -> Result<Vec<Release>>
pub async fn get_releases( &self, owner: String, repo: String, ) -> Result<Vec<Release>>
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(())
}
Sourcepub async fn create_release(
&self,
owner: String,
repo: String,
cr: CreateRelease,
) -> Result<Release>
pub async fn create_release( &self, owner: String, repo: String, cr: CreateRelease, ) -> Result<Release>
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(())
}
Sourcepub async fn delete_release(
&self,
owner: String,
repo: String,
tag: String,
) -> Result<()>
pub async fn delete_release( &self, owner: String, repo: String, tag: String, ) -> Result<()>
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(())
}
Auto Trait Implementations§
impl Freeze for Client
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more