Skip to content

Commit bfd911c

Browse files
jgsogorainerschoe
andauthored
feat: New ConfigurationId to group together a configuration identifier (#54)
closes #11 - New public `ConfigurationId` type to group together a configuration identifier - New `AppConfigurationHttp` client that can be instantiated with a custom server address (not public API) - Convert existing IBMCloud implement in a wrapper on top of that generic client --------- Signed-off-by: Javier G. Sogo <[email protected]> Co-authored-by: Rainer Schoenberger <[email protected]>
1 parent cf5b7cf commit bfd911c

13 files changed

+680
-453
lines changed

.secrets.baseline

+8-8
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"files": "^.secrets.baseline$",
44
"lines": null
55
},
6-
"generated_at": "2025-01-16T08:29:42Z",
6+
"generated_at": "2025-01-17T10:23:47Z",
77
"plugins_used": [
88
{
99
"name": "AWSKeyDetector"
@@ -81,25 +81,25 @@
8181
{
8282
"hashed_secret": "fb34629c9af1ed4045b5d6f287426276b2be3a1e",
8383
"is_verified": false,
84-
"line_number": 183,
84+
"line_number": 43,
8585
"type": "Secret Keyword",
8686
"verified_result": null
8787
}
8888
],
89-
"src/client/http.rs": [
89+
"src/lib.rs": [
9090
{
91-
"hashed_secret": "91271e4ebcf7a9793e252299b9a2c77c8d964325",
91+
"hashed_secret": "df1431b489758b92c84bdec3c9283b96066a44b8",
9292
"is_verified": false,
93-
"line_number": 42,
93+
"line_number": 57,
9494
"type": "Secret Keyword",
9595
"verified_result": null
9696
}
9797
],
98-
"src/lib.rs": [
98+
"src/network/token_provider.rs": [
9999
{
100-
"hashed_secret": "df1431b489758b92c84bdec3c9283b96066a44b8",
100+
"hashed_secret": "91271e4ebcf7a9793e252299b9a2c77c8d964325",
101101
"is_verified": false,
102-
"line_number": 57,
102+
"line_number": 31,
103103
"type": "Secret Keyword",
104104
"verified_result": null
105105
}

README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,12 @@ Create your client with the context (environment and collection) you want to con
3131
```rust
3232
use appconfiguration::{
3333
AppConfigurationClient, AppConfigurationClientIBMCloud,
34-
Entity, Result, Value, Feature
34+
ConfigurationId, Entity, Result, Value, Feature
3535
};
3636

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

4041
// Get the feature you want to evaluate for your entities
4142
let feature = client.get_feature("AB_testing_feature")?;

examples/demo.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
use std::{collections::HashMap, env, thread, time::Duration};
1616

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

53-
let client = AppConfigurationClientIBMCloud::new(
54-
&apikey,
55-
&region,
56-
&guid,
57-
&environment_id,
58-
&collection_id,
59-
)?;
54+
let configuration = ConfigurationId::new(guid, environment_id, collection_id);
55+
let client = AppConfigurationClientIBMCloud::new(&apikey, &region, configuration)?;
6056

6157
let entity = CustomerEntity {
6258
id: "user123".to_string(),

src/client/app_configuration_client.rs

+21
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,27 @@ use crate::client::feature_snapshot::FeatureSnapshot;
1919
use crate::client::property_proxy::PropertyProxy;
2020
use crate::client::property_snapshot::PropertySnapshot;
2121

22+
/// Identifies a configuration
23+
#[derive(Debug, Clone)]
24+
pub struct ConfigurationId {
25+
/// Instance ID of the App Configuration service. Obtain it from the service credentials section of the App Configuration dashboard
26+
pub guid: String,
27+
/// ID of the environment created in App Configuration service instance under the Environments section.
28+
pub environment_id: String,
29+
/// ID of the collection created in App Configuration service instance under the Collections section
30+
pub collection_id: String,
31+
}
32+
33+
impl ConfigurationId {
34+
pub fn new(guid: String, environment_id: String, collection_id: String) -> Self {
35+
Self {
36+
guid,
37+
environment_id,
38+
collection_id,
39+
}
40+
}
41+
}
42+
2243
/// AppConfiguration client for browsing, and evaluating features and properties.
2344
pub trait AppConfigurationClient {
2445
/// Returns the list of features.

0 commit comments

Comments
 (0)