1use crate::auth::OciConfig;
6use crate::client::signer::OciSigner;
7use crate::error::Result;
8use reqwest::Client;
9
10pub struct OciClient {
12 client: Client,
14
15 config: OciConfig,
17
18 signer: OciSigner,
20}
21
22impl OciClient {
23 pub fn new(config: &OciConfig) -> Result<Self> {
25 let client = Client::builder().build()?;
26 let signer = OciSigner::new(config)?;
27
28 Ok(Self {
29 client,
30 config: config.clone(),
31 signer,
32 })
33 }
34
35 pub fn config(&self) -> &OciConfig {
37 &self.config
38 }
39
40 pub fn signer(&self) -> &OciSigner {
42 &self.signer
43 }
44
45 pub fn client(&self) -> &Client {
47 &self.client
48 }
49
50 pub fn region(&self) -> &str {
52 &self.config.region
53 }
54
55 pub fn compartment_id(&self) -> &str {
57 self.config
58 .compartment_id
59 .as_ref()
60 .unwrap_or(&self.config.tenancy_id)
61 }
62}