1use crate::auth::OciConfig;
6use crate::client::signer::OciSigner;
7use crate::error::Result;
8use reqwest::Client;
9
10#[derive(Clone)]
12pub struct OciClient {
13 client: Client,
15
16 config: OciConfig,
18
19 signer: OciSigner,
21}
22
23impl OciClient {
24 pub fn new(config: &OciConfig) -> Result<Self> {
26 let client = Client::builder().build()?;
27 let signer = OciSigner::new(config)?;
28
29 Ok(Self {
30 client,
31 config: config.clone(),
32 signer,
33 })
34 }
35
36 pub fn config(&self) -> &OciConfig {
38 &self.config
39 }
40
41 pub fn signer(&self) -> &OciSigner {
43 &self.signer
44 }
45
46 pub fn client(&self) -> &Client {
48 &self.client
49 }
50
51 pub fn region(&self) -> &str {
53 &self.config.region
54 }
55
56 pub fn tenancy_id(&self) -> &str {
58 &self.config.tenancy_id
59 }
60
61 pub fn compartment_id(&self) -> &str {
63 self.config
64 .compartment_id
65 .as_ref()
66 .unwrap_or(&self.config.tenancy_id)
67 }
68}