@@ -25,7 +25,7 @@ properties for distributed applications centrally.
2525
2626## Installation
2727
28- The current version of this SDK: 0.1.1
28+ The current version of this SDK: 0.2.0
2929
3030There are a few different ways to download and install the IBM App Configuration Go SDK project for use by your Go
3131application:
@@ -113,13 +113,15 @@ if err == nil {
113113## Get all features
114114
115115``` go
116- features := appConfiguration.GetFeatures ()
117- feature := features[" online-check-in" ]
118-
119- fmt.Println (" Feature Name" , feature.GetFeatureName ())
120- fmt.Println (" Feature Id" , feature.GetFeatureID ())
121- fmt.Println (" Feature Type" , feature.GetFeatureDataType ())
122- fmt.Println (" Feature is enabled" , feature.IsEnabled ())
116+ features , err := appConfiguration.GetFeatures ()
117+ if err == nil {
118+ feature := features[" online-check-in" ]
119+
120+ fmt.Println (" Feature Name" , feature.GetFeatureName ())
121+ fmt.Println (" Feature Id" , feature.GetFeatureID ())
122+ fmt.Println (" Feature Type" , feature.GetFeatureDataType ())
123+ fmt.Println (" Feature is enabled" , feature.IsEnabled ())
124+ }
123125```
124126
125127## Evaluate a feature
@@ -151,12 +153,14 @@ if err == nil {
151153## Get all properties
152154
153155``` go
154- properties := appConfiguration.GetProperties ()
155- property := properties[" check-in-charges" ]
156-
157- fmt.Println (" Property Name" , property.GetPropertyName ())
158- fmt.Println (" Property Id" , property.GetPropertyID ())
159- fmt.Println (" Property Type" , property.GetPropertyDataType ())
156+ properties , err := appConfiguration.GetProperties ()
157+ if err == nil {
158+ property := properties[" check-in-charges" ]
159+
160+ fmt.Println (" Property Name" , property.GetPropertyName ())
161+ fmt.Println (" Property Id" , property.GetPropertyID ())
162+ fmt.Println (" Property Type" , property.GetPropertyDataType ())
163+ }
160164```
161165
162166## Evaluate a property
@@ -174,6 +178,73 @@ entityAttributes["country"] = "India"
174178propertyVal := property.GetCurrentValue (entityId, entityAttributes)
175179```
176180
181+ ## Supported Data types
182+
183+ App Configuration service allows to configure the feature flag and properties in the following data types : Boolean,
184+ Numeric, String. The String data type can be of the format of a text string , JSON or YAML. The SDK processes each
185+ format accordingly as shown in the below table.
186+ <details ><summary >View Table</summary >
187+
188+ | ** Feature or Property value** | ** DataType** | ** DataFormat** | ** Type of data returned <br > by ` GetCurrentValue() ` ** | ** Example output** |
189+ | ------------------------------------------------------------------------------------------------------------------ | ------------ | -------------- | ----------------------------------------------------- | -------------------------------------------------------------------- |
190+ | ` true ` | BOOLEAN | not applicable | ` bool ` | ` true ` |
191+ | ` 25 ` | NUMERIC | not applicable | ` float64 ` | ` 25 ` |
192+ | "a string text" | STRING | TEXT | ` string ` | ` a string text ` |
193+ | <pre >{<br > "firefox": {<br > "name": "Firefox",<br > "pref_url": "about: config "<br > }<br >}</pre > | STRING | JSON | ` map[string]interface{} ` | ` map[browsers:map[firefox:map[name:Firefox pref_url:about:config]]] ` |
194+ | <pre >men:<br > - John Smith<br > - Bill Jones<br >women:<br > - Mary Smith<br > - Susan Williams</pre > | STRING | YAML | ` map[string]interface{} ` | ` map[men:[John Smith Bill Jones] women:[Mary Smith Susan Williams]] ` |
195+ </details >
196+
197+ <details ><summary >Feature flag</summary >
198+
199+ ``` go
200+ feature , err := appConfiguration.GetFeature (" json-feature" )
201+ if err == nil {
202+ feature.GetFeatureDataType () // STRING
203+ feature.GetFeatureDataFormat () // JSON
204+
205+ // Example (traversing the returned map)
206+ result := feature.GetCurrentValue (entityID, entityAttributes) // JSON value is returned as a Map
207+ result.(map [string ]interface {})[" key" ] // returns the value of the key
208+ }
209+
210+ feature , err := appConfiguration.GetFeature (" yaml-feature" )
211+ if err == nil {
212+ feature.GetFeatureDataType () // STRING
213+ feature.GetFeatureDataFormat () // YAML
214+
215+ // Example (traversing the returned map)
216+ result := feature.GetCurrentValue (entityID, entityAttributes) // YAML value is returned as a Map
217+ result.(map [string ]interface {})[" key" ] // returns the value of the key
218+ }
219+ ```
220+
221+ </details >
222+ <details ><summary >Property</summary >
223+
224+ ``` go
225+ property , err := appConfiguration.GetProperty (" json-property" )
226+ if err == nil {
227+ property.GetPropertyDataType () // STRING
228+ property.GetPropertyDataFormat () // JSON
229+
230+ // Example (traversing the returned map)
231+ result := property.GetCurrentValue (entityID, entityAttributes) // JSON value is returned as a Map
232+ result.(map [string ]interface {})[" key" ] // returns the value of the key
233+ }
234+
235+ property , err := appConfiguration.GetProperty (" yaml-property" )
236+ if err == nil {
237+ property.GetPropertyDataType () // STRING
238+ property.GetPropertyDataFormat () // YAML
239+
240+ // Example (traversing the returned map)
241+ result := property.GetCurrentValue (entityID, entityAttributes) // YAML value is returned as a Map
242+ result.(map [string ]interface {})[" key" ] // returns the value of the key
243+ }
244+ ```
245+
246+ </details >
247+
177248## Set listener for feature or property data changes
178249
179250To listen to the configurations changes in your App Configuration service instance, implement the ` RegisterConfigurationUpdateListener ` event listener as mentioned below
0 commit comments