Crates.io | oci-sdk |
lib.rs | oci-sdk |
version | 0.3.0 |
source | src |
created_at | 2022-07-24 22:23:25.116405 |
updated_at | 2022-10-13 18:38:59.029556 |
description | Oracle Cloud Infrastructure SDK for Rust Lang |
homepage | |
repository | https://github.com/digital-divas/oci-rust-sdk |
max_upload_size | |
id | 632247 |
size | 25,357 |
Oracle Cloud Infrastructure SDK for Rust Lang
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(())}
}
You can look for the test folder for more examples.
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()));
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