|
1
|
//! A typed client for the [sigit.si](https://sigit.si) JSON API. |
|
2
|
//! |
|
3
|
//! ```no_run |
|
4
|
//! use sigit_si_api::{Client, Environment, issues::State}; |
|
5
|
//! |
|
6
|
//! # async fn example() -> sigit_si_api::Result<()> { |
|
7
|
//! let client = Client::new(Environment::Production)?.with_token("…"); |
|
8
|
//! |
|
9
|
//! let me = client.user().await?; |
|
10
|
//! let repos = client.repos().await?; |
|
11
|
//! let open = client.pulls("seto/sigit-si", State::Open).await?; |
|
12
|
//! # Ok(()) |
|
13
|
//! # } |
|
14
|
//! ``` |
|
15
|
//! |
|
16
|
//! Two transports sit behind one [`Client`]. Accounts, repositories, hooks, |
|
17
|
//! Cloud Sessions, and billing are plain REST under `/api/v1`. Issues, pull |
|
18
|
//! requests, and code search have no REST surface yet, so they go over the |
|
19
|
//! JSON-RPC MCP endpoint at `/api/v1/mcp` — that split is invisible at the call |
|
20
|
//! site, and can disappear later without breaking callers. |
|
21
|
|
|
22
|
//! |
|
23
|
//! # Features |
|
24
|
//! |
|
25
|
//! - `client` (default): the HTTP [`Client`] and the endpoint modules. |
|
26
|
//! - `rustls-tls-native-roots` (default), `rustls-tls-webpki-roots`, |
|
27
|
//! `native-tls`: the TLS backend of the `reqwest::Client` the crate builds |
|
28
|
//! itself. With none of them enabled, HTTPS requests fail unless you pass |
|
29
|
//! your own client to [`client::ClientBuilder::http_client`]. |
|
30
|
//! |
|
31
|
//! With `default-features = false` only the wire types remain ([`models`], |
|
32
|
//! [`ErrorResponse`], [`error::codes`], [`Environment`], [`CLIENT_HEADER`]), |
|
33
|
//! with no HTTP stack. That suits code that serves or proxies this API. |
|
34
|
|
|
35
|
#[cfg(feature = "client")] |
|
36
|
pub mod account; |
|
37
|
#[cfg(feature = "client")] |
|
38
|
pub mod billing; |
|
39
|
#[cfg(feature = "client")] |
|
40
|
pub mod client; |
|
41
|
#[cfg(feature = "client")] |
|
42
|
pub mod code; |
|
43
|
pub mod environment; |
|
44
|
pub mod error; |
|
45
|
#[cfg(feature = "client")] |
|
46
|
pub mod issues; |
|
47
|
#[cfg(feature = "client")] |
|
48
|
pub mod mcp; |
|
49
|
pub mod models; |
|
50
|
#[cfg(feature = "client")] |
|
51
|
pub mod pulls; |
|
52
|
#[cfg(feature = "client")] |
|
53
|
pub mod repos; |
|
54
|
#[cfg(feature = "client")] |
|
55
|
pub mod sessions; |
|
56
|
#[cfg(feature = "client")] |
|
57
|
pub mod statuses; |
|
58
|
|
|
59
|
/// Request header a client uses to name itself. [`client::ClientBuilder::client_name`] |
|
60
|
/// sends it on every request. |
|
61
|
pub const CLIENT_HEADER: &str = "x-sigit-client"; |
|
62
|
|
|
63
|
pub use {environment::Environment, error::ErrorResponse}; |
|
64
|
|
|
65
|
#[cfg(feature = "client")] |
|
66
|
pub use { |
|
67
|
client::Client, |
|
68
|
error::{ApiError, Result}, |
|
69
|
issues::State, |
|
70
|
repos::NewRepository, |
|
71
|
statuses::NewStatus, |
|
72
|
}; |