Skip to content

Instantly share code, notes, and snippets.

@kognate
Created December 22, 2016 14:15
Show Gist options
  • Save kognate/4279b7a3091e5d20875b8ed079dd85c0 to your computer and use it in GitHub Desktop.
Save kognate/4279b7a3091e5d20875b8ed079dd85c0 to your computer and use it in GitHub Desktop.
I've add the source and a python notebook to get a config from discovery using the python sdk (version 0.23 has discovery)
import watson_developer_cloud
DISCOVERY_USERNAME='CHANGE_ME'
DISCOVERY_PASSWORD='CHANGE_ME'
ENVIRONMENT_NAME='CHANGE_ME'
CONFIGURATION_NAME='CHANGE_ME'
discovery = watson_developer_cloud.DiscoveryV1(
'2016-12-15',
username=DISCOVERY_USERNAME,
password=DISCOVERY_PASSWORD)
environments = discovery.get_environments()
target_environment = [x for x in environments['environments'] if x['name'] == ENVIRONMENT_NAME]
target_environment_id = target_environments[0]['environment_id']
configs = discovery.list_configurations(environment_id=target_environment_id)
target_config = [x for x in configs['configurations'] if x['name'] == CONFIGURATION_NAME]
target_config_id = target_config[0]['configuration_id']
config_data = discovery.get_configuration(environment_id=target_environment_id,
configuration_id=target_config_id)
print(config_data)
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import watson_developer_cloud\n",
"\n",
"DISCOVERY_USERNAME='CHANGE_ME'\n",
"DISCOVERY_PASSWORD='CHANGE_ME'\n",
"ENVIRONMENT_NAME='CHANGE_ME' # this is the 'name' field of your environment\n",
"CONFIGURATION_NAME='CHANGE_ME' # this is the 'name' field of your cofiguration"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"discovery = watson_developer_cloud.DiscoveryV1(\n",
" '2016-12-15',\n",
" username=DISCOVERY_USERNAME,\n",
" password=DISCOVERY_PASSWORD)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"environments = discovery.get_environments()\n",
"\n",
"target_environment = [x for x in environments['environments'] if x['name'] == ENVIRONMENT_NAME]\n",
"target_environment_id = target_environments[0]['environment_id']\n",
"print(target_environment_id)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"configs = discovery.list_configurations(environment_id=target_environment_id)\n",
"\n",
"target_config = [x for x in configs['configurations'] if x['name'] == CONFIGURATION_NAME]\n",
"target_config_id = target_config[0]['configuration_id']\n",
"print(target_config_id)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"config_data = discovery.get_configuration(environment_id=target_environment_id,\n",
" configuration_id=target_config_id)\n",
"print(config_data)"
]
}
],
"metadata": {
"anaconda-cloud": {},
"kernelspec": {
"display_name": "Python [Root]",
"language": "python",
"name": "Python [Root]"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.2"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment