Python client for Rackspace Service Registry.
Project description
# Python Rackspace Service Registry client
A Python client for Rackspace Service Registry.
# License
This library is distributed under the [Apache license](http://www.apache.org/licenses/LICENSE-2.0.html).
# Usage
```Python
from service_registry import Client
RACKSPACE_USERNAME = 'username'
RACKSPACE_KEY = 'api key'
client = Client(RACKSPACE_USERNAME, RACKSPACE_KEY)
```
## Sessions
Create a session with a heartbeat timeout of 10:
```Python
# Optional metadata (must contain string keys and values, up to 255 chars)
options = {'key': 'value'}
heartbeat_timeout = 10
client.sessions.create(heartbeat_timeout, options)
```
List sessions:
```Python
client.sessions.list()
```
Get session:
```Python
session_id = 'seFoo'
client.sessions.get(session_id)
```
Heartbeat a session:
```Python
session_id = 'seFoo'
token = 'token'
client.sessions.heartbeat(session_id, token)
```
Update existing session:
```Python
session_id = 'seFoo'
payload = {'heartbeat_timeout': 15}
client.sessions.update(session_id, payload)
```
## Events
List events:
```Python
marker = 'last-seen-token'
client.events.list(marker)
```
## Services
List services:
```Python
client.services.list()
```
List services for a specific tag:
```Python
tag = 'tag'
client.services.list_for_tag(tag)
```
Get service by ID:
```Python
service_id = 'messenger1'
client.services.get(service_id)
```
Create a new service:
```Python
session_id = 'session_id'
service_id = 'messenger1'
payload = {
'tags': ['messenger', 'stats'],
'metadata': {'someKey': 'someValue', 'anotherKey': 'anotherValue'}
}
client.services.register(session_id, service_id, payload)
```
Update existing service:
```Python
service_id = 'messenger1'
payload = {
'tags': ['tag1', 'tag2'],
'metadata': {'aKey': 'aValue'}
}
client.services.update(service_id, payload)
```
## Configuration
List configuration values:
```Python
client.configuration.list()
```
Get configuration value by id:
```Python
configuration_id = 'configId'
client.configuration.get(configuration_id)
```
Update configuration value:
```Python
configuration_id = 'configId'
value = 'new-value'
client.configuration.set(configuration_id, value)
```
Delete configuration value:
```Python
configuration_id = 'configId'
client.configuration.remove(configuration_id)
```
## Accounts
Get account limits:
```Python
client.account.get_limits()
```
A Python client for Rackspace Service Registry.
# License
This library is distributed under the [Apache license](http://www.apache.org/licenses/LICENSE-2.0.html).
# Usage
```Python
from service_registry import Client
RACKSPACE_USERNAME = 'username'
RACKSPACE_KEY = 'api key'
client = Client(RACKSPACE_USERNAME, RACKSPACE_KEY)
```
## Sessions
Create a session with a heartbeat timeout of 10:
```Python
# Optional metadata (must contain string keys and values, up to 255 chars)
options = {'key': 'value'}
heartbeat_timeout = 10
client.sessions.create(heartbeat_timeout, options)
```
List sessions:
```Python
client.sessions.list()
```
Get session:
```Python
session_id = 'seFoo'
client.sessions.get(session_id)
```
Heartbeat a session:
```Python
session_id = 'seFoo'
token = 'token'
client.sessions.heartbeat(session_id, token)
```
Update existing session:
```Python
session_id = 'seFoo'
payload = {'heartbeat_timeout': 15}
client.sessions.update(session_id, payload)
```
## Events
List events:
```Python
marker = 'last-seen-token'
client.events.list(marker)
```
## Services
List services:
```Python
client.services.list()
```
List services for a specific tag:
```Python
tag = 'tag'
client.services.list_for_tag(tag)
```
Get service by ID:
```Python
service_id = 'messenger1'
client.services.get(service_id)
```
Create a new service:
```Python
session_id = 'session_id'
service_id = 'messenger1'
payload = {
'tags': ['messenger', 'stats'],
'metadata': {'someKey': 'someValue', 'anotherKey': 'anotherValue'}
}
client.services.register(session_id, service_id, payload)
```
Update existing service:
```Python
service_id = 'messenger1'
payload = {
'tags': ['tag1', 'tag2'],
'metadata': {'aKey': 'aValue'}
}
client.services.update(service_id, payload)
```
## Configuration
List configuration values:
```Python
client.configuration.list()
```
Get configuration value by id:
```Python
configuration_id = 'configId'
client.configuration.get(configuration_id)
```
Update configuration value:
```Python
configuration_id = 'configId'
value = 'new-value'
client.configuration.set(configuration_id, value)
```
Delete configuration value:
```Python
configuration_id = 'configId'
client.configuration.remove(configuration_id)
```
## Accounts
Get account limits:
```Python
client.account.get_limits()
```
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
service-registry-0.1.5.tar.gz
(11.4 kB
view details)
File details
Details for the file service-registry-0.1.5.tar.gz
.
File metadata
- Download URL: service-registry-0.1.5.tar.gz
- Upload date:
- Size: 11.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 231d5b62e4b29fb165ddfc773a57be5e85f2db0e2fe3d356e662bae0149303e3 |
|
MD5 | 0e219a85e42ae4eadf69f4e451cef16a |
|
BLAKE2b-256 | 3567d2cdac457cdc9895bb8ee3d758a4b48ff68aa8ff00f7d9908e7fe46b986a |