ibm-appconfiguration-python-sdk


Nameibm-appconfiguration-python-sdk JSON
Version 0.3.3 PyPI version JSON
download
home_pagehttps://github.com/IBM/appconfiguration-python-sdk
SummaryIBM Cloud App Configuration Python SDK
upload_time2024-03-22 12:38:25
maintainerNone
docs_urlNone
authorIBM
requires_python>=3.0
licenseApache 2.0
keywords python ibm_appconfiguration ibm ibm cloud feature_flags
VCS
bugtrack_url
requirements python_dateutil requests websocket-client ibm-cloud-sdk-core pyyaml schema mmh3
Travis-CI No Travis.
coveralls test coverage
            # IBM Cloud App Configuration Python server SDK

IBM Cloud App Configuration SDK is used to perform feature flag and property evaluation based on the configuration on IBM Cloud App Configuration service.

## Table of Contents

  - [Overview](#overview)
  - [Installation](#installation)
  - [Import the SDK](#import-the-sdk)
  - [Initialize SDK](#initialize-sdk)
  - [License](#license)

## Overview

IBM Cloud App Configuration is a centralized feature management and configuration service on [IBM Cloud](https://www.cloud.ibm.com) for use with web and mobile applications, microservices, and distributed environments.

Instrument your applications with App Configuration Python SDK, and use the App Configuration dashboard, CLI or API to define feature flags or properties, organized into collections and targeted to segments. Toggle feature flag states in the cloud to activate or deactivate features in your application or environment, when required. You can also manage the properties for distributed applications centrally.

## Installation

To install, use `pip` or `easy_install`:

```sh
pip install --upgrade ibm-appconfiguration-python-sdk
```

or

```sh
 easy_install --upgrade ibm-appconfiguration-python-sdk
```

## Import the SDK

```py
from ibm_appconfiguration import AppConfiguration, Feature, Property, ConfigurationType
```

## Initialize SDK

```py
appconfig_client = AppConfiguration.get_instance()
appconfig_client.init(region='region', guid='guid', apikey='apikey')
appconfig_client.set_context(collection_id='airlines-webapp', environment_id='dev')
```

:red_circle: **Important** :red_circle:

The **`init()`** and **`set_context()`** are the initialisation methods and should be invoked **only once** using
appconfig_client. The appconfig_client, once initialised, can be obtained across modules
using **`AppConfiguration.get_instance()`**.  [See this example below](#fetching-the-appconfig_client-across-other-modules).

- region : Region name where the App Configuration service instance is created. Use
  - `AppConfiguration.REGION_US_SOUTH` for Dallas
  - `AppConfiguration.REGION_EU_GB` for London
  - `AppConfiguration.REGION_AU_SYD` for Sydney
  - `AppConfiguration.REGION_US_EAST` for Washington DC
  - `AppConfiguration.REGION_EU_DE` for Frankfurt
- guid : GUID of the App Configuration service. Obtain it from the service credentials section of the dashboard
- apikey : ApiKey of the App Configuration service. Obtain it from the service credentials section of the dashboard
- collection_id : Id of the collection created in App Configuration service instance under the **Collections** section.
- environment_id : Id of the environment created in App Configuration service instance under the **Environments**
  section.

### Connect using private network connection (optional)

Set the SDK to connect to App Configuration service by using a private endpoint that is accessible only through the IBM
Cloud private network.

```py
appconfig_client.use_private_endpoint(True);
```

This must be done before calling the `init` function on the SDK.

### (Optional)

In order for your application and SDK to continue its operations even during the unlikely scenario of App Configuration
service across your application restarts, you can configure the SDK to work using a persistent cache. The SDK uses the
persistent cache to store the App Configuration data that will be available across your application restarts.

```python
# 1. default (without persistent cache)
appconfig_client.set_context(collection_id='airlines-webapp', environment_id='dev')

# 2. optional (with persistent cache)
appconfig_client.set_context(collection_id='airlines-webapp', environment_id='dev', options={
  'persistent_cache_dir': '/var/lib/docker/volumes/'
})
```

* persistent_cache_dir: Absolute path to a directory which has read & write permission for the user. The SDK will create
  a file - `appconfiguration.json` in the specified directory, and it will be used as the persistent cache to store the
  App Configuration service information.

When persistent cache is enabled, the SDK will keep the last known good configuration at the persistent cache. In the
case of App Configuration server being unreachable, the latest configurations at the persistent cache is loaded to the
application to continue working.

Please ensure that the cache file created in the given directory is not lost or deleted in any case. For example,
consider the case when a kubernetes pod is restarted and the cache file (appconfiguration.json) was stored in ephemeral
volume of the pod. As pod gets restarted, kubernetes destroys the ephermal volume in the pod, as a result the cache file
gets deleted. So, make sure that the cache file created by the SDK is always stored in persistent volume by providing
the correct absolute path of the persistent directory.

### (Optional)

The SDK is also designed to serve configurations, perform feature flag & property evaluations without being connected to
App Configuration service.

```python
appconfig_client.set_context(collection_id='airlines-webapp', environment_id='dev', options={
  'bootstrap_file': 'saflights/flights.json',
  'live_config_update_enabled': False
})
```

* bootstrap_file: Absolute path of the JSON file which contains configuration details. Make sure to provide a proper
  JSON file. You can generate this file using `ibmcloud ac config` command of the IBM Cloud App Configuration CLI.
* live_config_update_enabled: Live configuration update from the server. Set this value to `False` if the new
  configuration values shouldn't be fetched from the server. By default, this parameter (`live_config_update_enabled`)
  is set to True.

## Get single feature

```py
feature = appconfig_client.get_feature('online-check-in')  # feature can be None incase of an invalid feature id

if feature is not None:
    print(f'Feature Name : {0}'.format(feature.get_feature_name()))
    print(f'Feature Id : {0}'.format(feature.get_feature_id()))
    print(f'Feature Data Type : {0}'.format(feature.get_feature_data_type()))
    if feature.is_enabled():
        # feature flag is enabled
    else:
        # feature flag is disabled

```

## Get all features

```py
features_dictionary = appconfig_client.get_features()
```

## Evaluate a feature

Use the `feature.get_current_value(entity_id=entity_id, entity_attributes=entity_attributes)` method to evaluate the
value of the feature flag. This method returns one of the Enabled/Disabled/Overridden value based on the evaluation. The
data type of returned value matches that of feature flag.

    ```py
    entity_id = "john_doe"
    entity_attributes = {
      'city': 'Bangalore',
      'country': 'India'
    }
    feature_value = feature.get_current_value(entity_id=entity_id, entity_attributes=entity_attributes)
    ```

- entity_id: Id of the Entity. This will be a string identifier related to the Entity against which the feature is
  evaluated. For example, an entity might be an instance of an app that runs on a mobile device, a microservice that
  runs on the cloud, or a component of infrastructure that runs that microservice. For any entity to interact with App
  Configuration, it must provide a unique entity ID.
- entity_attributes: A dictionary consisting of the attribute name and their values that defines the specified entity.
  This is an optional parameter if the feature flag is not configured with any targeting definition. If the targeting is
  configured, then entity_attributes should be provided for the rule evaluation. An attribute is a parameter that is
  used to define a segment. The SDK uses the attribute values to determine if the specified entity satisfies the
  targeting rules, and returns the appropriate feature flag value.

## Get single Property

```py
property = appconfig_client.get_property('check-in-charges')  # property can be None incase of an invalid property id
if property is not None:
    print(f'Property Name : {0}'.format(property.get_property_name()))
    print(f'Property Id : {0}'.format(property.get_property_id()))
    print(f'Property Data Type : {0}'.format(property.get_property_data_type()))
```

## Get all Properties

```py
properties_dictionary = appconfig_client.get_properties()
```

## Evaluate a property

Use the `property.get_current_value(entity_id=entity_id, entity_attributes=entity_attributes)` method to evaluate the
value of the property. This method returns the default property value or its overridden value based on the evaluation.
The data type of returned value matches that of property.

    ```py
    entity_id = "john_doe"
    entity_attributes = {
    'city': 'Bangalore',
    'country': 'India'
    }
    property_value = property.get_current_value(entity_id=entity_id, entity_attributes=entity_attributes)
    ```

- entity_id: Id of the Entity. This will be a string identifier related to the Entity against which the property is
  evaluated. For example, an entity might be an instance of an app that runs on a mobile device, a microservice that
  runs on the cloud, or a component of infrastructure that runs that microservice. For any entity to interact with App
  Configuration, it must provide a unique entity ID.
- entity_attributes: A dictionary consisting of the attribute name and their values that defines the specified entity.
  This is an optional parameter if the property is not configured with any targeting definition. If the targeting is
  configured, then entity_attributes should be provided for the rule evaluation. An attribute is a parameter that is
  used to define a segment. The SDK uses the attribute values to determine if the specified entity satisfies the
  targeting rules, and returns the appropriate property value.

## Fetching the appconfig_client across other modules

Once the SDK is initialized, the appconfig_client can be obtained across other modules as shown below:

```python
# **other modules**

from ibm_appconfiguration import AppConfiguration

appconfig_client = AppConfiguration.get_instance()
feature = appconfig_client.get_feature('online-check-in')
enabled = feature.is_enabled()
feature_value = feature.get_current_value(entity_id, entity_attributes)
```

## Supported Data types

App Configuration service allows to configure the feature flag and properties in the following data types : Boolean,
Numeric, String. The String data type can be of the format of a TEXT string , JSON or YAML. The SDK processes each
format accordingly as shown in the below table.
<details><summary>View Table</summary>

| **Feature or Property value**                                                                                      | **DataType** | **DataFormat** | **Type of data returned <br> by `GetCurrentValue()`** | **Example output**                                                   |
| ------------------------------------------------------------------------------------------------------------------ | ------------ | -------------- | ----------------------------------------------------- | -------------------------------------------------------------------- |
| `true`                                                                                                             | BOOLEAN      | not applicable | `bool`                                                | `true`                                                               |
| `25`                                                                                                               | NUMERIC      | not applicable | `int`                                             | `25`                                                                 |
| "a string text"                                                                                                    | STRING       | TEXT           | `string`                                              | `a string text`                                                      |
| <pre>{<br>  "firefox": {<br>    "name": "Firefox",<br>    "pref_url": "about:config"<br>  }<br>}</pre> | STRING       | JSON           | `Dictionary or List of Dictionary`                              | `{'firefox': {'name': 'Firefox', 'pref_url': 'about:config'}}` |
| <pre>men:<br>  - John Smith<br>  - Bill Jones<br>women:<br>  - Mary Smith<br>  - Susan Williams</pre>  | STRING       | YAML           | `Dictionary`                              | `{'men': ['John Smith', 'Bill Jones'], 'women': ['Mary Smith', 'Susan Williams']}` |
</details>

<details><summary>Feature flag</summary>

  ```py
  feature = appconfig_client.get_feature('json-feature')
  feature.get_feature_data_type() // STRING
  feature.get_feature_data_format() // JSON
  feature.get_current_value(entityId, entityAttributes) // returns single dictionary object or list of dictionary object

  // Example Below
  // input json :- [{"role": "developer", "description": "do coding"},{"role": "tester", "description": "do testing"}]
  // expected output :- "do coding"

  tar_val = feature.get_current_value(entityId, entityAttributes)
  expected_output = tar_val[0]['description']

  // input json :- {"role": "tester", "description": "do testing"}
  // expected output :- "tester"

  tar_val = feature.get_current_value(entityId, entityAttributes)
  expected_output = tar_val['role']

  feature = appconfig_client.getFeature('yaml-feature')
  feature.get_feature_data_type() // STRING
  feature.get_feature_data_format() // YAML
  feature.get_current_value(entityId, entityAttributes) // returns dictionary object

  // Example Below
  // input yaml string :- "---\nrole: tester\ndescription: do_testing"
  // expected output :- "do_testing"

  tar_val = feature.get_current_value(entityId, entityAttributes)
  expected_output = tar_val['description']
  ```
</details>
<details><summary>Property</summary>

  ```py
  property = appconfig_client.get_property('json-property')
  property.get_property_data_type() // STRING
  property.get_property_data_format() // JSON
  property.get_current_value(entityId, entityAttributes) // returns single dictionary object or list of dictionary object

  // Example Below
  // input json :- [{"role": "developer", "description": "do coding"},{"role": "tester", "description": "do testing"}]
  // expected output :- "do coding"

  tar_val = property.get_current_value(entityId, entityAttributes)
  expected_output = tar_val[0]['description']

  // input json :- {"role": "tester", "description": "do testing"}
  // expected output :- "tester"

  tar_val = property.get_current_value(entityId, entityAttributes)
  expected_output = tar_val['role']

  property = appconfig_client.get_property('yaml-property')
  property.get_property_data_type() // STRING
  property.get_property_data_format() // YAML
  property.get_current_value(entityId, entityAttributes) // returns dictionary object 

  // Example Below
  // input yaml string :- "---\nrole: tester\ndescription: do_testing"
  // expected output :- "do_testing"

  tar_val = property.get_current_value(entityId, entityAttributes)
  expected_output = tar_val['description']
  ```
</details>

## Set listener for the feature and property data changes

The SDK provides mechanism to notify you in real-time when feature flag's or property's configuration changes. You can
subscribe to configuration changes using the same appconfig_client.

```py
def configuration_update(self):
    print('Received updates on configurations')
    # **add your code**
    # To find the effect of any configuration changes, you can call the feature or property related methods

    # feature = appconfig_client.getFeature('online-check-in')
    # new_value = feature.get_current_value(entity_id, entity_attributes)

appconfig_client.register_configuration_update_listener(configuration_update)

```

## Fetch latest data

Fetch the latest configuration data. 

```py
appconfig_client.fetch_configurations()
```

## Enable debugger (Optional)

Use this method to enable/disable the logging in SDK.

```py
appconfig_client.enable_debug(True)
```

## Examples

The [examples](https://github.com/IBM/appconfiguration-python-sdk/tree/master/examples) folder has the examples.

## License

This project is released under the Apache 2.0 license. The license's full text can be found
in [LICENSE](https://github.com/IBM/appconfiguration-python-sdk/blob/master/LICENSE)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/IBM/appconfiguration-python-sdk",
    "name": "ibm-appconfiguration-python-sdk",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.0",
    "maintainer_email": null,
    "keywords": "python, ibm_appconfiguration, ibm, ibm cloud, feature_flags",
    "author": "IBM",
    "author_email": "mdevsrvs@in.ibm.com",
    "download_url": "https://files.pythonhosted.org/packages/46/3f/35d6bcf6cfc84f50a6ba982b01852891590b237c821a4b594994934e3e58/ibm-appconfiguration-python-sdk-0.3.3.tar.gz",
    "platform": null,
    "description": "# IBM Cloud App Configuration Python server SDK\n\nIBM Cloud App Configuration SDK is used to perform feature flag and property evaluation based on the configuration on IBM Cloud App Configuration service.\n\n## Table of Contents\n\n  - [Overview](#overview)\n  - [Installation](#installation)\n  - [Import the SDK](#import-the-sdk)\n  - [Initialize SDK](#initialize-sdk)\n  - [License](#license)\n\n## Overview\n\nIBM Cloud App Configuration is a centralized feature management and configuration service on [IBM Cloud](https://www.cloud.ibm.com) for use with web and mobile applications, microservices, and distributed environments.\n\nInstrument your applications with App Configuration Python SDK, and use the App Configuration dashboard, CLI or API to define feature flags or properties, organized into collections and targeted to segments. Toggle feature flag states in the cloud to activate or deactivate features in your application or environment, when required. You can also manage the properties for distributed applications centrally.\n\n## Installation\n\nTo install, use `pip` or `easy_install`:\n\n```sh\npip install --upgrade ibm-appconfiguration-python-sdk\n```\n\nor\n\n```sh\n easy_install --upgrade ibm-appconfiguration-python-sdk\n```\n\n## Import the SDK\n\n```py\nfrom ibm_appconfiguration import AppConfiguration, Feature, Property, ConfigurationType\n```\n\n## Initialize SDK\n\n```py\nappconfig_client = AppConfiguration.get_instance()\nappconfig_client.init(region='region', guid='guid', apikey='apikey')\nappconfig_client.set_context(collection_id='airlines-webapp', environment_id='dev')\n```\n\n:red_circle: **Important** :red_circle:\n\nThe **`init()`** and **`set_context()`** are the initialisation methods and should be invoked **only once** using\nappconfig_client. The appconfig_client, once initialised, can be obtained across modules\nusing **`AppConfiguration.get_instance()`**.  [See this example below](#fetching-the-appconfig_client-across-other-modules).\n\n- region : Region name where the App Configuration service instance is created. Use\n  - `AppConfiguration.REGION_US_SOUTH` for Dallas\n  - `AppConfiguration.REGION_EU_GB` for London\n  - `AppConfiguration.REGION_AU_SYD` for Sydney\n  - `AppConfiguration.REGION_US_EAST` for Washington DC\n  - `AppConfiguration.REGION_EU_DE` for Frankfurt\n- guid : GUID of the App Configuration service. Obtain it from the service credentials section of the dashboard\n- apikey : ApiKey of the App Configuration service. Obtain it from the service credentials section of the dashboard\n- collection_id : Id of the collection created in App Configuration service instance under the **Collections** section.\n- environment_id : Id of the environment created in App Configuration service instance under the **Environments**\n  section.\n\n### Connect using private network connection (optional)\n\nSet the SDK to connect to App Configuration service by using a private endpoint that is accessible only through the IBM\nCloud private network.\n\n```py\nappconfig_client.use_private_endpoint(True);\n```\n\nThis must be done before calling the `init` function on the SDK.\n\n### (Optional)\n\nIn order for your application and SDK to continue its operations even during the unlikely scenario of App Configuration\nservice across your application restarts, you can configure the SDK to work using a persistent cache. The SDK uses the\npersistent cache to store the App Configuration data that will be available across your application restarts.\n\n```python\n# 1. default (without persistent cache)\nappconfig_client.set_context(collection_id='airlines-webapp', environment_id='dev')\n\n# 2. optional (with persistent cache)\nappconfig_client.set_context(collection_id='airlines-webapp', environment_id='dev', options={\n  'persistent_cache_dir': '/var/lib/docker/volumes/'\n})\n```\n\n* persistent_cache_dir: Absolute path to a directory which has read & write permission for the user. The SDK will create\n  a file - `appconfiguration.json` in the specified directory, and it will be used as the persistent cache to store the\n  App Configuration service information.\n\nWhen persistent cache is enabled, the SDK will keep the last known good configuration at the persistent cache. In the\ncase of App Configuration server being unreachable, the latest configurations at the persistent cache is loaded to the\napplication to continue working.\n\nPlease ensure that the cache file created in the given directory is not lost or deleted in any case. For example,\nconsider the case when a kubernetes pod is restarted and the cache file (appconfiguration.json) was stored in ephemeral\nvolume of the pod. As pod gets restarted, kubernetes destroys the ephermal volume in the pod, as a result the cache file\ngets deleted. So, make sure that the cache file created by the SDK is always stored in persistent volume by providing\nthe correct absolute path of the persistent directory.\n\n### (Optional)\n\nThe SDK is also designed to serve configurations, perform feature flag & property evaluations without being connected to\nApp Configuration service.\n\n```python\nappconfig_client.set_context(collection_id='airlines-webapp', environment_id='dev', options={\n  'bootstrap_file': 'saflights/flights.json',\n  'live_config_update_enabled': False\n})\n```\n\n* bootstrap_file: Absolute path of the JSON file which contains configuration details. Make sure to provide a proper\n  JSON file. You can generate this file using `ibmcloud ac config` command of the IBM Cloud App Configuration CLI.\n* live_config_update_enabled: Live configuration update from the server. Set this value to `False` if the new\n  configuration values shouldn't be fetched from the server. By default, this parameter (`live_config_update_enabled`)\n  is set to True.\n\n## Get single feature\n\n```py\nfeature = appconfig_client.get_feature('online-check-in')  # feature can be None incase of an invalid feature id\n\nif feature is not None:\n    print(f'Feature Name : {0}'.format(feature.get_feature_name()))\n    print(f'Feature Id : {0}'.format(feature.get_feature_id()))\n    print(f'Feature Data Type : {0}'.format(feature.get_feature_data_type()))\n    if feature.is_enabled():\n        # feature flag is enabled\n    else:\n        # feature flag is disabled\n\n```\n\n## Get all features\n\n```py\nfeatures_dictionary = appconfig_client.get_features()\n```\n\n## Evaluate a feature\n\nUse the `feature.get_current_value(entity_id=entity_id, entity_attributes=entity_attributes)` method to evaluate the\nvalue of the feature flag. This method returns one of the Enabled/Disabled/Overridden value based on the evaluation. The\ndata type of returned value matches that of feature flag.\n\n    ```py\n    entity_id = \"john_doe\"\n    entity_attributes = {\n      'city': 'Bangalore',\n      'country': 'India'\n    }\n    feature_value = feature.get_current_value(entity_id=entity_id, entity_attributes=entity_attributes)\n    ```\n\n- entity_id: Id of the Entity. This will be a string identifier related to the Entity against which the feature is\n  evaluated. For example, an entity might be an instance of an app that runs on a mobile device, a microservice that\n  runs on the cloud, or a component of infrastructure that runs that microservice. For any entity to interact with App\n  Configuration, it must provide a unique entity ID.\n- entity_attributes: A dictionary consisting of the attribute name and their values that defines the specified entity.\n  This is an optional parameter if the feature flag is not configured with any targeting definition. If the targeting is\n  configured, then entity_attributes should be provided for the rule evaluation. An attribute is a parameter that is\n  used to define a segment. The SDK uses the attribute values to determine if the specified entity satisfies the\n  targeting rules, and returns the appropriate feature flag value.\n\n## Get single Property\n\n```py\nproperty = appconfig_client.get_property('check-in-charges')  # property can be None incase of an invalid property id\nif property is not None:\n    print(f'Property Name : {0}'.format(property.get_property_name()))\n    print(f'Property Id : {0}'.format(property.get_property_id()))\n    print(f'Property Data Type : {0}'.format(property.get_property_data_type()))\n```\n\n## Get all Properties\n\n```py\nproperties_dictionary = appconfig_client.get_properties()\n```\n\n## Evaluate a property\n\nUse the `property.get_current_value(entity_id=entity_id, entity_attributes=entity_attributes)` method to evaluate the\nvalue of the property. This method returns the default property value or its overridden value based on the evaluation.\nThe data type of returned value matches that of property.\n\n    ```py\n    entity_id = \"john_doe\"\n    entity_attributes = {\n    'city': 'Bangalore',\n    'country': 'India'\n    }\n    property_value = property.get_current_value(entity_id=entity_id, entity_attributes=entity_attributes)\n    ```\n\n- entity_id: Id of the Entity. This will be a string identifier related to the Entity against which the property is\n  evaluated. For example, an entity might be an instance of an app that runs on a mobile device, a microservice that\n  runs on the cloud, or a component of infrastructure that runs that microservice. For any entity to interact with App\n  Configuration, it must provide a unique entity ID.\n- entity_attributes: A dictionary consisting of the attribute name and their values that defines the specified entity.\n  This is an optional parameter if the property is not configured with any targeting definition. If the targeting is\n  configured, then entity_attributes should be provided for the rule evaluation. An attribute is a parameter that is\n  used to define a segment. The SDK uses the attribute values to determine if the specified entity satisfies the\n  targeting rules, and returns the appropriate property value.\n\n## Fetching the appconfig_client across other modules\n\nOnce the SDK is initialized, the appconfig_client can be obtained across other modules as shown below:\n\n```python\n# **other modules**\n\nfrom ibm_appconfiguration import AppConfiguration\n\nappconfig_client = AppConfiguration.get_instance()\nfeature = appconfig_client.get_feature('online-check-in')\nenabled = feature.is_enabled()\nfeature_value = feature.get_current_value(entity_id, entity_attributes)\n```\n\n## Supported Data types\n\nApp Configuration service allows to configure the feature flag and properties in the following data types : Boolean,\nNumeric, String. The String data type can be of the format of a TEXT string , JSON or YAML. The SDK processes each\nformat accordingly as shown in the below table.\n<details><summary>View Table</summary>\n\n| **Feature or Property value**                                                                                      | **DataType** | **DataFormat** | **Type of data returned <br> by `GetCurrentValue()`** | **Example output**                                                   |\n| ------------------------------------------------------------------------------------------------------------------ | ------------ | -------------- | ----------------------------------------------------- | -------------------------------------------------------------------- |\n| `true`                                                                                                             | BOOLEAN      | not applicable | `bool`                                                | `true`                                                               |\n| `25`                                                                                                               | NUMERIC      | not applicable | `int`                                             | `25`                                                                 |\n| \"a string text\"                                                                                                    | STRING       | TEXT           | `string`                                              | `a string text`                                                      |\n| <pre>{<br>  \"firefox\": {<br>    \"name\": \"Firefox\",<br>    \"pref_url\": \"about:config\"<br>  }<br>}</pre> | STRING       | JSON           | `Dictionary or List of Dictionary`                              | `{'firefox': {'name': 'Firefox', 'pref_url': 'about:config'}}` |\n| <pre>men:<br>  - John Smith<br>  - Bill Jones<br>women:<br>  - Mary Smith<br>  - Susan Williams</pre>  | STRING       | YAML           | `Dictionary`                              | `{'men': ['John Smith', 'Bill Jones'], 'women': ['Mary Smith', 'Susan Williams']}` |\n</details>\n\n<details><summary>Feature flag</summary>\n\n  ```py\n  feature = appconfig_client.get_feature('json-feature')\n  feature.get_feature_data_type() // STRING\n  feature.get_feature_data_format() // JSON\n  feature.get_current_value(entityId, entityAttributes) // returns single dictionary object or list of dictionary object\n\n  // Example Below\n  // input json :- [{\"role\": \"developer\", \"description\": \"do coding\"},{\"role\": \"tester\", \"description\": \"do testing\"}]\n  // expected output :- \"do coding\"\n\n  tar_val = feature.get_current_value(entityId, entityAttributes)\n  expected_output = tar_val[0]['description']\n\n  // input json :- {\"role\": \"tester\", \"description\": \"do testing\"}\n  // expected output :- \"tester\"\n\n  tar_val = feature.get_current_value(entityId, entityAttributes)\n  expected_output = tar_val['role']\n\n  feature = appconfig_client.getFeature('yaml-feature')\n  feature.get_feature_data_type() // STRING\n  feature.get_feature_data_format() // YAML\n  feature.get_current_value(entityId, entityAttributes) // returns dictionary object\n\n  // Example Below\n  // input yaml string :- \"---\\nrole: tester\\ndescription: do_testing\"\n  // expected output :- \"do_testing\"\n\n  tar_val = feature.get_current_value(entityId, entityAttributes)\n  expected_output = tar_val['description']\n  ```\n</details>\n<details><summary>Property</summary>\n\n  ```py\n  property = appconfig_client.get_property('json-property')\n  property.get_property_data_type() // STRING\n  property.get_property_data_format() // JSON\n  property.get_current_value(entityId, entityAttributes) // returns single dictionary object or list of dictionary object\n\n  // Example Below\n  // input json :- [{\"role\": \"developer\", \"description\": \"do coding\"},{\"role\": \"tester\", \"description\": \"do testing\"}]\n  // expected output :- \"do coding\"\n\n  tar_val = property.get_current_value(entityId, entityAttributes)\n  expected_output = tar_val[0]['description']\n\n  // input json :- {\"role\": \"tester\", \"description\": \"do testing\"}\n  // expected output :- \"tester\"\n\n  tar_val = property.get_current_value(entityId, entityAttributes)\n  expected_output = tar_val['role']\n\n  property = appconfig_client.get_property('yaml-property')\n  property.get_property_data_type() // STRING\n  property.get_property_data_format() // YAML\n  property.get_current_value(entityId, entityAttributes) // returns dictionary object \n\n  // Example Below\n  // input yaml string :- \"---\\nrole: tester\\ndescription: do_testing\"\n  // expected output :- \"do_testing\"\n\n  tar_val = property.get_current_value(entityId, entityAttributes)\n  expected_output = tar_val['description']\n  ```\n</details>\n\n## Set listener for the feature and property data changes\n\nThe SDK provides mechanism to notify you in real-time when feature flag's or property's configuration changes. You can\nsubscribe to configuration changes using the same appconfig_client.\n\n```py\ndef configuration_update(self):\n    print('Received updates on configurations')\n    # **add your code**\n    # To find the effect of any configuration changes, you can call the feature or property related methods\n\n    # feature = appconfig_client.getFeature('online-check-in')\n    # new_value = feature.get_current_value(entity_id, entity_attributes)\n\nappconfig_client.register_configuration_update_listener(configuration_update)\n\n```\n\n## Fetch latest data\n\nFetch the latest configuration data. \n\n```py\nappconfig_client.fetch_configurations()\n```\n\n## Enable debugger (Optional)\n\nUse this method to enable/disable the logging in SDK.\n\n```py\nappconfig_client.enable_debug(True)\n```\n\n## Examples\n\nThe [examples](https://github.com/IBM/appconfiguration-python-sdk/tree/master/examples) folder has the examples.\n\n## License\n\nThis project is released under the Apache 2.0 license. The license's full text can be found\nin [LICENSE](https://github.com/IBM/appconfiguration-python-sdk/blob/master/LICENSE)\n",
    "bugtrack_url": null,
    "license": "Apache 2.0",
    "summary": "IBM Cloud App Configuration Python SDK",
    "version": "0.3.3",
    "project_urls": {
        "Homepage": "https://github.com/IBM/appconfiguration-python-sdk"
    },
    "split_keywords": [
        "python",
        " ibm_appconfiguration",
        " ibm",
        " ibm cloud",
        " feature_flags"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b451008300c8007b7fa844dd5bbeb4111117014b776be73896e5c3aa8720e1d0",
                "md5": "e289a5effbd14bda8f36a4cb369668ef",
                "sha256": "fd4037c036c9aa982f523b5a6261cf0e37c4fddd207c87dbe92f9d4df71ab224"
            },
            "downloads": -1,
            "filename": "ibm_appconfiguration_python_sdk-0.3.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e289a5effbd14bda8f36a4cb369668ef",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.0",
            "size": 69386,
            "upload_time": "2024-03-22T12:38:23",
            "upload_time_iso_8601": "2024-03-22T12:38:23.203937Z",
            "url": "https://files.pythonhosted.org/packages/b4/51/008300c8007b7fa844dd5bbeb4111117014b776be73896e5c3aa8720e1d0/ibm_appconfiguration_python_sdk-0.3.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "463f35d6bcf6cfc84f50a6ba982b01852891590b237c821a4b594994934e3e58",
                "md5": "51261acf87c43c7efd254632c2d224f6",
                "sha256": "556a91bd8c57dc1e4ef12e39964289de8305d9d5fee11fafd46f5f0998b4b2f8"
            },
            "downloads": -1,
            "filename": "ibm-appconfiguration-python-sdk-0.3.3.tar.gz",
            "has_sig": false,
            "md5_digest": "51261acf87c43c7efd254632c2d224f6",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.0",
            "size": 41581,
            "upload_time": "2024-03-22T12:38:25",
            "upload_time_iso_8601": "2024-03-22T12:38:25.021136Z",
            "url": "https://files.pythonhosted.org/packages/46/3f/35d6bcf6cfc84f50a6ba982b01852891590b237c821a4b594994934e3e58/ibm-appconfiguration-python-sdk-0.3.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-22 12:38:25",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "IBM",
    "github_project": "appconfiguration-python-sdk",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": false,
    "requirements": [
        {
            "name": "python_dateutil",
            "specs": [
                [
                    "<",
                    "3.0.0"
                ],
                [
                    ">=",
                    "2.8"
                ]
            ]
        },
        {
            "name": "requests",
            "specs": [
                [
                    ">=",
                    "2.31.0"
                ],
                [
                    "<",
                    "3.0"
                ]
            ]
        },
        {
            "name": "websocket-client",
            "specs": [
                [
                    "==",
                    "0.57.0"
                ]
            ]
        },
        {
            "name": "ibm-cloud-sdk-core",
            "specs": [
                [
                    ">=",
                    "3.18.0"
                ],
                [
                    "<",
                    "4.0.0"
                ]
            ]
        },
        {
            "name": "pyyaml",
            "specs": [
                [
                    ">=",
                    "5.4.1"
                ]
            ]
        },
        {
            "name": "schema",
            "specs": [
                [
                    ">=",
                    "0.7.5"
                ]
            ]
        },
        {
            "name": "mmh3",
            "specs": [
                [
                    "==",
                    "3.0.0"
                ]
            ]
        }
    ],
    "lcname": "ibm-appconfiguration-python-sdk"
}
        
IBM
Elapsed time: 0.22302s