@sigit / si Mirror · read-only
Fork 0

Mirror of github.com/getsigit/si.

Mirrored from https://github.com/getsigit/si.git

Synced Nov 24, 09:30 UTC

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 agent_runs;
39 #[cfg(feature = "client")]
40 pub mod billing;
41 #[cfg(feature = "client")]
42 pub mod client;
43 #[cfg(feature = "client")]
44 pub mod code;
45 pub mod environment;
46 pub mod error;
47 #[cfg(feature = "client")]
48 pub mod issues;
49 #[cfg(feature = "client")]
50 pub mod mcp;
51 pub mod models;
52 #[cfg(feature = "client")]
53 pub mod pulls;
54 #[cfg(feature = "client")]
55 pub mod repos;
56 #[cfg(feature = "client")]
57 pub mod sessions;
58 #[cfg(feature = "client")]
59 pub mod statuses;
60
61 /// Request header a client uses to name itself. [`client::ClientBuilder::client_name`]
62 /// sends it on every request.
63 pub const CLIENT_HEADER: &str = "x-sigit-client";
64
65 pub use {environment::Environment, error::ErrorResponse};
66
67 #[cfg(feature = "client")]
68 pub use {
69 client::Client,
70 error::{ApiError, Result},
71 issues::State,
72 repos::NewRepository,
73 statuses::NewStatus,
74 };