timeweb_rs/lib.rs
1//! # timeweb-rs
2//!
3//! Async Rust SDK for the [Timeweb Cloud](https://timeweb.cloud/?i=137383) API.
4//!
5//! The [`apis`] and [`models`] modules are generated from the official Timeweb
6//! Cloud `OpenAPI` specification, so the SDK covers the full public API
7//! surface: cloud servers, managed databases, Kubernetes, projects, domains, S3
8//! storage, load balancers, firewalls, mail, AI agents and everything else
9//! exposed by the control panel.
10//!
11//! ## Authentication
12//!
13//! Timeweb Cloud authenticates requests with a JWT token issued in the control
14//! panel (section "API и Terraform"). Build an authenticated configuration
15//! with [`authenticated`] and pass it to any function in [`apis`]:
16//!
17//! ```no_run
18//! # async fn run() -> Result<(), Box<dyn std::error::Error>> {
19//! use timeweb_rs::apis::servers_api;
20//!
21//! let config = timeweb_rs::authenticated("your-jwt-token");
22//! let servers = servers_api::get_servers(&config, None, None).await?;
23//! println!("{servers:#?}");
24//! # Ok(())
25//! # }
26//! ```
27//!
28//! ## Layout
29//!
30//! * [`apis`] — one module per API area ([`apis::servers_api`],
31//! [`apis::databases_api`], ...); every operation is a free async function
32//! taking `&Configuration` as its first argument.
33//! * [`models`] — request and response types.
34//! * [`apis::configuration::Configuration`] — connection settings and
35//! credentials; build it with [`authenticated`].
36//! * [`apis::Error`] — the error type returned by every API call.
37
38#![forbid(unsafe_code)]
39
40/// Generated API client modules, one per Timeweb Cloud API area.
41///
42/// Produced by `openapi-generator`; lint groups are relaxed for this generated
43/// code so the hand-written crate code stays under strict lints.
44#[allow(
45 clippy::all,
46 clippy::pedantic,
47 clippy::nursery,
48 unused_imports,
49 rustdoc::all
50)]
51pub mod apis;
52
53/// Generated request and response types.
54///
55/// Produced by `openapi-generator`; see [`apis`] for the lint rationale.
56#[allow(
57 clippy::all,
58 clippy::pedantic,
59 clippy::nursery,
60 unused_imports,
61 rustdoc::all
62)]
63pub mod models;
64
65mod client;
66
67pub use client::{DEFAULT_BASE_URL, authenticated, authenticated_with_base_url};