ibm-appconfiguration-python-sdk


Nameibm-appconfiguration-python-sdk JSON
Version 1.1.0 PyPI version JSON
download
home_pagehttps://github.com/IBM/appconfiguration-python-sdk
SummaryIBM Cloud App Configuration Python SDK
upload_time2021-04-08 11:22:45
maintainer
docs_urlNone
authorIBM
requires_python>=3.0
licenseApache 2.0
keywords python ibm_appconfiguration ibm ibm cloud feature_flags
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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
app_config = AppConfiguration.get_instance()
app_config.init(region=AppConfiguration.REGION_US_SOUTH,
               guid='GUID',
               apikey='APIKEY')

## Initialize configurations 
app_config.set_collection_id(collection_id='collection_id') 
```

- region : Region name where the service instance is created. Use
  - `AppConfiguration.REGION_US_SOUTH` for Dallas
  - `AppConfiguration.REGION_EU_GB` for London
  - `AppConfiguration.REGION_AU_SYD` for Sydney
- guid : GUID of the App Configuration service. Get it from the service credentials section of the dashboard
- apikey : ApiKey of the App Configuration service. Get it from the service credentials section of the dashboard
- collection_id : Id of the collection created in App Configuration service instance.

## Work offline with local configuration file

You can also work offline with local configuration file and perform feature and property related operations.

After setting the collection Id, follow the below steps

```py
## set the file or offline configurations
app_config.fetch_configuration_from_file(configuration_file='custom/userJson.json', 
                                    live_config_update_enabled=True)
```
- configuration_file : Path to the JSON file which contains configuration details.
- live_config_update_enabled : Set this value to false if the new configuration values shouldn't be fetched from the server. Make sure to provide a proper JSON file in the configuration_file path. By default, this value is enabled.

## Get single feature

```py
feature = app_config.get_feature('feature_id')
if (feature) {
    print('Feature Name : {0}'.format(feature.get_feature_name()));
    print('Feature Id : {0}'.format(feature.get_feature_id()));
    print('Feature Type : {0}'.format(feature.get_feature_data_type()));
    print('Feature is enabled : {0}'.format(feature.is_enabled()));
}
```

## Get all features 

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

## Evaluate a feature

You can use the feature.get_current_value(identity_id, identity_attributes) method to evaluate the value of the feature flag. 

You should pass an unique identity_id as the parameter to perform the feature flag evaluation. If the feature flag is configured with segments in the App Configuration service, you can set the attributes values as a dictionary.

```py

identity_attributes = {
    'city': 'Bangalore',
    'country': 'India'
}
feature_value = feature.get_current_value(identity_id='identity_id', identity_attributes=identity_attributes)
```

## Get single Property

```py
property = app_config.get_property('property_id')
if (property) {
    print('Property Name : {0}'.format(property.get_property_name()));
    print('Property Id : {0}'.format(property.get_property_id()));
    print('Property Type : {0}'.format(property.get_property_data_type()));
}
```

## Get all Properties 

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

## Evaluate a property

You can use the property.get_current_value(identity_id, identity_attributes) method to evaluate the value of the property. 

You should pass an unique identity_id as the parameter to perform the property evaluation. If the property is configured with segments in the App Configuration service, you can set the attributes values as a dictionary.

```py

identity_attributes = {
    'city': 'Bangalore',
    'country': 'India'
}
property_value = property.get_current_value(identity_id='identity_id', identity_attributes=identity_attributes)
```

## Set listener for the feature and property data changes

To listen to the data changes add the following code in your application.

```py
def configuration_update(self):
    print('Get your Feature/Property value now')

app_config.register_configuration_update_listener(configuration_update)

```

## Fetch latest data

```py
app_config.fetch_configurations()
```

## Enable debugger (Optional)

```py
app_config.enable_debug(True)
```

## 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": "",
    "docs_url": null,
    "requires_python": ">=3.0",
    "maintainer_email": "",
    "keywords": "python,ibm_appconfiguration,ibm,ibm cloud,feature_flags",
    "author": "IBM",
    "author_email": "mdevsrvs@in.ibm.com",
    "download_url": "https://files.pythonhosted.org/packages/a2/91/136ce073a7c4488ad34fb472d09967b28f726e8c0403e6595d08889c5bbc/ibm-appconfiguration-python-sdk-1.1.0.tar.gz",
    "platform": "",
    "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```\nor\n\n```sh\n easy_install --upgrade ibm-appconfiguration-python-sdk\n```\n## Import the SDK\n\n```py\nfrom ibm_appconfiguration import AppConfiguration, Feature, Property, ConfigurationType\n```\n## Initialize SDK\n\n```py\napp_config = AppConfiguration.get_instance()\napp_config.init(region=AppConfiguration.REGION_US_SOUTH,\n               guid='GUID',\n               apikey='APIKEY')\n\n## Initialize configurations \napp_config.set_collection_id(collection_id='collection_id') \n```\n\n- region : Region name where the 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- guid : GUID of the App Configuration service. Get it from the service credentials section of the dashboard\n- apikey : ApiKey of the App Configuration service. Get it from the service credentials section of the dashboard\n- collection_id : Id of the collection created in App Configuration service instance.\n\n## Work offline with local configuration file\n\nYou can also work offline with local configuration file and perform feature and property related operations.\n\nAfter setting the collection Id, follow the below steps\n\n```py\n## set the file or offline configurations\napp_config.fetch_configuration_from_file(configuration_file='custom/userJson.json', \n                                    live_config_update_enabled=True)\n```\n- configuration_file : Path to the JSON file which contains configuration details.\n- live_config_update_enabled : Set this value to false if the new configuration values shouldn't be fetched from the server. Make sure to provide a proper JSON file in the configuration_file path. By default, this value is enabled.\n\n## Get single feature\n\n```py\nfeature = app_config.get_feature('feature_id')\nif (feature) {\n    print('Feature Name : {0}'.format(feature.get_feature_name()));\n    print('Feature Id : {0}'.format(feature.get_feature_id()));\n    print('Feature Type : {0}'.format(feature.get_feature_data_type()));\n    print('Feature is enabled : {0}'.format(feature.is_enabled()));\n}\n```\n\n## Get all features \n\n```py\nfeatures_dictionary = app_config.get_features()\n```\n\n## Evaluate a feature\n\nYou can use the feature.get_current_value(identity_id, identity_attributes) method to evaluate the value of the feature flag. \n\nYou should pass an unique identity_id as the parameter to perform the feature flag evaluation. If the feature flag is configured with segments in the App Configuration service, you can set the attributes values as a dictionary.\n\n```py\n\nidentity_attributes = {\n    'city': 'Bangalore',\n    'country': 'India'\n}\nfeature_value = feature.get_current_value(identity_id='identity_id', identity_attributes=identity_attributes)\n```\n\n## Get single Property\n\n```py\nproperty = app_config.get_property('property_id')\nif (property) {\n    print('Property Name : {0}'.format(property.get_property_name()));\n    print('Property Id : {0}'.format(property.get_property_id()));\n    print('Property Type : {0}'.format(property.get_property_data_type()));\n}\n```\n\n## Get all Properties \n\n```py\nproperties_dictionary = app_config.get_properties()\n```\n\n## Evaluate a property\n\nYou can use the property.get_current_value(identity_id, identity_attributes) method to evaluate the value of the property. \n\nYou should pass an unique identity_id as the parameter to perform the property evaluation. If the property is configured with segments in the App Configuration service, you can set the attributes values as a dictionary.\n\n```py\n\nidentity_attributes = {\n    'city': 'Bangalore',\n    'country': 'India'\n}\nproperty_value = property.get_current_value(identity_id='identity_id', identity_attributes=identity_attributes)\n```\n\n## Set listener for the feature and property data changes\n\nTo listen to the data changes add the following code in your application.\n\n```py\ndef configuration_update(self):\n    print('Get your Feature/Property value now')\n\napp_config.register_configuration_update_listener(configuration_update)\n\n```\n\n## Fetch latest data\n\n```py\napp_config.fetch_configurations()\n```\n\n## Enable debugger (Optional)\n\n```py\napp_config.enable_debug(True)\n```\n\n## License\n\nThis 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)\n\n\n",
    "bugtrack_url": null,
    "license": "Apache 2.0",
    "summary": "IBM Cloud App Configuration Python SDK",
    "version": "1.1.0",
    "split_keywords": [
        "python",
        "ibm_appconfiguration",
        "ibm",
        "ibm cloud",
        "feature_flags"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "69ecf8989af6bfdc01b16d5d74b0f287",
                "sha256": "2efd6f9a49c706fd42489996dcf9371f1deaf988b75c472fd49e2288be680c98"
            },
            "downloads": -1,
            "filename": "ibm_appconfiguration_python_sdk-1.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "69ecf8989af6bfdc01b16d5d74b0f287",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.0",
            "size": 47307,
            "upload_time": "2021-04-08T11:22:43",
            "upload_time_iso_8601": "2021-04-08T11:22:43.933846Z",
            "url": "https://files.pythonhosted.org/packages/00/cd/c59dc6f6fe3d2a3fa7b6ba6644b8a8a9e7643bcb1019273ee36bc28190df/ibm_appconfiguration_python_sdk-1.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "9de1b3f7f2ba76d1afa94d77e3d34082",
                "sha256": "067cc6489ae58a0a0ca192a2faea88c7fe42af80eeb14b0836f1a8e4ee6adddd"
            },
            "downloads": -1,
            "filename": "ibm-appconfiguration-python-sdk-1.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "9de1b3f7f2ba76d1afa94d77e3d34082",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.0",
            "size": 21751,
            "upload_time": "2021-04-08T11:22:45",
            "upload_time_iso_8601": "2021-04-08T11:22:45.445262Z",
            "url": "https://files.pythonhosted.org/packages/a2/91/136ce073a7c4488ad34fb472d09967b28f726e8c0403e6595d08889c5bbc/ibm-appconfiguration-python-sdk-1.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2021-04-08 11:22:45",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": null,
    "github_project": "IBM",
    "error": "Could not fetch GitHub repository",
    "lcname": "ibm-appconfiguration-python-sdk"
}
        
IBM
Elapsed time: 0.33771s