Expand description
This crate is a simple Gitea API client. It’s goal is to give you the ability to write exactly as much code as you need to interact with the specific parts of the Gitea API you need, but no more.
§Usage
The main way to interact with the Gitea API is through the Client
struct. You can create a
new Client by calling Client::new with the base URL of your Gitea instance and a personal
token. The crate does currently not support basic HTML or OAuth2 authentication.
Once you have obtained a Client, you can interact with the Gitea API by calling the various methods the instance provides. For example, to create a new repository for the currently authenticated user, you can call:
let client = Client::new("https://gitea.example.com", Auth::Token("your-token"));
let repo = client
.user()
.create_repo("my-new-repo")
// Optional fields
.description("This is my new repo")
.private(true)
// Send the request
.send(&client)
.await
.unwrap();
Similarly, to get a list of commits for a repository, you can call:
let client = Client::new("https://gitea.example.com", Auth::Token("your-token"));
let commits = client
.repos("owner", "repo-name")
.get_commits()
// Optional fields
.page(2)
.send(&client)
.await
.unwrap();
If you want to create a new access token for a user, you can call:
let basic = Auth::Basic("username", "password");
let client = Client::new("https://gitea.example.com", basic);
let token = client
.user()
.create_access_token("username", "my-new-token", vec!["write:repo"])
.send(&client)
.await
.unwrap();
println!("Token {} created: {}", token.name, token.sha1);
// You can now create a new client with the token and use it to interact with the API.
let new_client = Client::new("https://gitea.example.com", Auth::Token(token.sha1));
Modules§
Structs§
- Client
- Represents a Gitea client.
- Create
Access Token Option
Enums§
- Auth
- Represents the authentication method to use with the Gitea API.