Skip to main content

u_sdk/esa/
mod.rs

1//! ESA SDK
2//!
3//! API 文档地址: <https://api.aliyun.com/product/ESA>
4
5mod error;
6
7pub use error::Error;
8use std::fmt::{Debug, Formatter};
9
10pub(crate) mod utils;
11
12pub mod dns_record;
13pub mod origin_protection;
14pub mod site_management;
15
16use crate::credentials::CredentialsProvider;
17use bon::bon;
18use std::sync::Arc;
19use u_sdk_common::open_api_sign::OpenApiStyle;
20
21pub(crate) const OPENAPI_STYLE: OpenApiStyle = OpenApiStyle::RPC;
22pub(crate) const OPENAPI_VERSION: &str = "2024-09-10";
23
24pub struct Client {
25    credentials_provider: Arc<dyn CredentialsProvider>,
26    http_client: reqwest::Client,
27    host: String,
28}
29
30impl Debug for Client {
31    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
32        f.debug_struct("Client").field("host", &self.host).finish()
33    }
34}
35
36#[bon]
37impl Client {
38    #[builder(on(String, into))]
39    pub fn new(credentials_provider: Arc<dyn CredentialsProvider>, host: String) -> Self {
40        Self {
41            credentials_provider,
42            http_client: reqwest::Client::new(),
43            host,
44        }
45    }
46}