Page tree
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Keys and Values can be created, edited, and deleted through the key-values api. Once keys have been created, you can add them to demand tag targeting via groups.

Create Keys

SDK

In [1]: import springserve


In [2]: key = springserve.keys.new({'name': 'New Key', 'key': 'new_key', 'definition_type':'predefined'})


In [3]: key.ok
Out [3]: True


In [4]: print key.id
Out [4]: 28

API

POST /api/v0/keys

Headers

Content-Type application/json
Authorization "yourAuthToken"

Body (example)

{
   "name": "TEST API DOCS",
   "key": "test_api",
   "definition_type": "predefined"

}


Required parameters: name, key, definition_type

Response

Status code 200

Get Keys and Values

SDK

In [1]: key = springserve.keys.get(27)

In [2]: key.ok
Out [2]: True


In [3]: values = key.get_values()


In [4]: for v in values:
  ....:     print v.id
Out [4]: 104
		 105
		 106

API

GET /api/v0/keys

Headers

Content-Type application/json
Authorization "yourAuthToken"


Response

Status code 200

Edit Keys

SDK

In [1]: key = springserve.keys.get(27)

In [2]: key.description = "Updated Description"


In [3]: saved = key.save()


In [4]: saved.ok
Out [4]: True

API

PUT /api/v0/keys/<id>

Headers

Content-Type application/json
Authorization "yourAuthToken"

Body (example)

{
   "name": "I want to change the name"

}


Response

Status code 200

Edit Values

SDK

In [1]: key = springserve.keys.get(27)

In [2]: values = key.get_values()


In [3]: value = values[0]


In [4]: value.name = 'Updated value name'


In [5]: saved = value.save()


In [6]: saved.ok
Out [6]: True

API

PUT /api/v0/keys/<id>/values/<id>

Headers

Content-Type application/json
Authorization "yourAuthToken"

Body (example)

{
   "name": "I want to change the name"

}


Response

Status code 200

Add Values to Existing Key

SDK

In [1]: key = springserve.keys.get(27)

In [2]: value = key._add_values({'name': 'new_value', 'value': '4'})


In [3]: saved = value.save()


In [4]: saved.ok
Out [4]: True

API

POST /api/v0/keys/<id>/values

Headers

Content-Type application/json
Authorization "yourAuthToken"

Body (example)

{
   "name": "TEST API DOCS",
   "value": "test_api"

}

Required parameters: name, value

Response

Status code 200

  • No labels