3 releases (breaking)
0.3.0 | Oct 13, 2022 |
---|---|
0.2.0 | Oct 11, 2022 |
0.1.0 | Jul 24, 2022 |
#13 in #lang
18KB
333 lines
oci-rust-sdk
Oracle Cloud Infrastructure SDK for Rust Lang
About
OCI-Rust-SDK is written to access the OCI API using async methods.
use oci_sdk::{
config::AuthConfig,
identity::Identity
};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
// Set up auth config
let auth_config = AuthConfig::from_file(
Some("~/.oci/config".to_string()),
Some("DEFAULT".to_string())
);
// Create a service client
let identity = Identity::new(auth_config, None);
//# Get the current user
let response = identity.get_current_user().await?;
// parse information
let body = response.text().await?;
println!("{}", body);
// {
// "compartment_id": "ocid1.tenancy.oc1...",
// "description": "Test user",
// "id": "ocid1.user.oc1...",
// "inactive_status": null,
// "lifecycle_state": "ACTIVE",
// "name": "test-user@corp.com",
// "time_created": "2016-08-30T23:46:44.680000+00:00"
// }
Ok(())}
}
Examples
You can look for the test folder for more examples.
Development
OCI-Emulator
We recommend you to use oci-emulator to develop new features and testing.
To do so, just run:
docker run -d --name oci-emulator -p 12000:12000 cameritelabs/oci-emulator:latest
You can then use the service_endpoint
parameter available on every client to use it. For example:
let auth_config = AuthConfig::from_file(None, None);
Nosql::new(auth_config, Some("http://localhost:12000".to_string()));
Running Tests
We're using tarpaulin to generate code coverage. To use it, you'll need to install it using cargo:
cargo install tarpaulin
After installing it, you can build/test and generate the coverage simply using:
cargo tarpaulin --out Lcov
We're using Lcov format to upload the coverage to codecov
.
You can view the coverage on VSCode using Coverage Gutters.
If you don't want to generate coverage you can simply use:
cargo test
Dependencies
~9–22MB
~327K SLoC