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

« Previous Version 3 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

{
    "id":30,
    "account_id":1,
    "name":"TEST API DOCS",
    "key":"test_api",
    "description":null,
    "definition_type":"predefined"
}

Get Keys

SDK

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

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

In [3]: print key.name
Out [3]: "TEST API DOCS"

API

GET /api/v0/keys

Headers

Content-Type application/json
Authorization "yourAuthToken"


Response

Status code 200

{
    "id":30,
    "account_id":1,
    "name":"TEST API DOCS",
    "key":"test_api",
    "description":null,
    "definition_type":"predefined"
}

Get Values

SDK

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

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

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

API

GET /api/v0/keys/<key_id>/values/<id>

Headers

Content-Type application/json
Authorization "yourAuthToken"


Response

Status code 200

{
    "id":57,
    "name":"TEST API DOCS",
    "value":"test_api"
}

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

{
    "id":30,
    "account_id":1,
    "name":"I want to change the name",
    "key":"test_api",
    "description":null,
    "definition_type":"predefined"
}

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

{
    "id":57,
    "name":"I want to change the name",
    "value":"test_api"
}

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

{
    "id":57,
    "name":"TEST API DOCS",
    "value":"test_api"
}
  • No labels