Client library to parse and return service credentials from environment variables that IBM Cloud provides.
Project description
Parse and return service credentials from environment variables that IBM Cloud provides.
Installation
$ pip install vcap_services
Usage
from vcap_services import load_from_vcap_services
credentials = load_from_vcap_services('personality_insights')
print(credentials);
If VCAP_SERVICES is:
{
"personality_insights": [{
"credentials": {
"password": "<password>",
"url": "<url>",
"username": "<username>"
},
"label": "personality_insights",
"name": "personality-insights-service",
"plan": "standard"
}]
}
Output:
{
"password": "<password>",
"url": "<url>",
"username": "<username>"
}
Getting credentials for a specific plan
Get credentials that match a specific service plan (only for VCAP_SERVICES).
from vcap_services import load_from_vcap_services
credentials = load_from_vcap_services('personality_insights', 'standard')
print(credentials);
Getting credentials for a specific instance
Get credentials that match a specific service instance (replace “YOUR NLC NAME” with the name of your service instance).
from vcap_services import load_from_vcap_services
credentials = load_from_vcap_services('natural_language_classifier', None, 'YOUR NLC NAME')
print(credentials);
Getting credentials for a specific plan and instance
Get credentials that match a specific service plan and instance (replace “YOUR NLC NAME” with the name of your service instance).
from vcap_services import load_from_vcap_services
credentials = load_from_vcap_services('natural_language_classifier', 'standard', 'YOUR NLC NAME')
print(credentials);
Tests
Running all the tests:
$ pip install -r requirements.txt
$ cp .env.mock .env
$ pytest --cov=vcap_services
License
MIT.
Contributing
See CONTRIBUTING.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file vcap_services-1.0.0.tar.gz
.
File metadata
- Download URL: vcap_services-1.0.0.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/2.7.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
1b856576ce0290c717022e0b76d5e5d448cd1bee94985affcca22cde6a11905e
|
|
MD5 |
684a62aa404a8d35e356edd5fdc41c94
|
|
BLAKE2b-256 |
364134f21399a1100de41a3e8763160efe3ecda51c5a8fefedbe60ba29d596fa
|