Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: New ConfigurationId to group together a configuration identifier #54

Merged
merged 6 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"files": "^.secrets.baseline$",
"lines": null
},
"generated_at": "2025-01-16T08:29:42Z",
"generated_at": "2025-01-17T10:23:47Z",
"plugins_used": [
{
"name": "AWSKeyDetector"
Expand Down Expand Up @@ -81,25 +81,25 @@
{
"hashed_secret": "fb34629c9af1ed4045b5d6f287426276b2be3a1e",
"is_verified": false,
"line_number": 183,
"line_number": 43,
"type": "Secret Keyword",
"verified_result": null
}
],
"src/client/http.rs": [
"src/lib.rs": [
{
"hashed_secret": "91271e4ebcf7a9793e252299b9a2c77c8d964325",
"hashed_secret": "df1431b489758b92c84bdec3c9283b96066a44b8",
"is_verified": false,
"line_number": 42,
"line_number": 57,
"type": "Secret Keyword",
"verified_result": null
}
],
"src/lib.rs": [
"src/network/token_provider.rs": [
{
"hashed_secret": "df1431b489758b92c84bdec3c9283b96066a44b8",
"hashed_secret": "91271e4ebcf7a9793e252299b9a2c77c8d964325",
"is_verified": false,
"line_number": 57,
"line_number": 31,
"type": "Secret Keyword",
"verified_result": null
}
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ Create your client with the context (environment and collection) you want to con
```rust
use appconfiguration::{
AppConfigurationClient, AppConfigurationClientIBMCloud,
Entity, Result, Value, Feature
ConfigurationId, Entity, Result, Value, Feature
};

// Create the client connecting to the server
let client = AppConfigurationClientIBMCloud::new(&apikey, &region, &guid, &environment_id, &collection_id)?;
let configuration = ConfigurationId::new(guid, environment_id, collection_id);
let client = AppConfigurationClientIBMCloud::new(&apikey, &region, configuration)?;

// Get the feature you want to evaluate for your entities
let feature = client.get_feature("AB_testing_feature")?;
Expand Down
12 changes: 4 additions & 8 deletions examples/demo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
use std::{collections::HashMap, env, thread, time::Duration};

use appconfiguration::{
AppConfigurationClient, AppConfigurationClientIBMCloud, Entity, Feature, Property, Value,
AppConfigurationClient, AppConfigurationClientIBMCloud, ConfigurationId, Entity, Feature,
Property, Value,
};
use dotenvy::dotenv;
use std::error::Error;
Expand Down Expand Up @@ -50,13 +51,8 @@ fn main() -> std::result::Result<(), Box<dyn Error>> {
let feature_id = env::var("FEATURE_ID").expect("FEATURE_ID should be set.");
let property_id = env::var("PROPERTY_ID").expect("PROPERTY_ID should be set.");

let client = AppConfigurationClientIBMCloud::new(
&apikey,
&region,
&guid,
&environment_id,
&collection_id,
)?;
let configuration = ConfigurationId::new(guid, environment_id, collection_id);
let client = AppConfigurationClientIBMCloud::new(&apikey, &region, configuration)?;

let entity = CustomerEntity {
id: "user123".to_string(),
Expand Down
21 changes: 21 additions & 0 deletions src/client/app_configuration_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,27 @@ use crate::client::feature_snapshot::FeatureSnapshot;
use crate::client::property_proxy::PropertyProxy;
use crate::client::property_snapshot::PropertySnapshot;

/// Identifies a configuration
#[derive(Debug, Clone)]
pub struct ConfigurationId {
/// Instance ID of the App Configuration service. Obtain it from the service credentials section of the App Configuration dashboard
pub guid: String,
/// ID of the environment created in App Configuration service instance under the Environments section.
pub environment_id: String,
/// ID of the collection created in App Configuration service instance under the Collections section
pub collection_id: String,
}

impl ConfigurationId {
pub fn new(guid: String, environment_id: String, collection_id: String) -> Self {
Self {
guid,
environment_id,
collection_id,
}
}
}

/// AppConfiguration client for browsing, and evaluating features and properties.
pub trait AppConfigurationClient {
/// Returns the list of features.
Expand Down
Loading
Loading