Skip to content

Commit

Permalink
Merge pull request #7 from racker/remove_session_concept
Browse files Browse the repository at this point in the history
Remove session concept
  • Loading branch information
Kami committed Mar 28, 2013
2 parents 438ebbd + 75fc7fa commit 0fec294
Show file tree
Hide file tree
Showing 22 changed files with 140 additions and 495 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -2,3 +2,5 @@
*.pyc
_trial_temp
mock_api_server.log
dist/
txServiceRegistry.egg-info
171 changes: 3 additions & 168 deletions README.md
Expand Up @@ -18,175 +18,10 @@ RACKSPACE_KEY = 'api key'

client = Client(RACKSPACE_USERNAME, RACKSPACE_KEY)

# Do something
reactor.run()

def resultCallback(result):
print result
reactor.stop()
```

## 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'}
heartbeatTimeout = 10

d = client.sessions.create(heartbeatTimeout, options)
d.addCallback(resultCallback)
```

List sessions:

```Python
d = client.sessions.list()
d.addCallback(resultCallback)
```

Get session:

```Python
sessionId = 'seFoo'

d = client.sessions.get(sessionId)
d.addCallback(resultCallback)
```

Heartbeat a session:

```Python
sessionId = 'seFoo'
token = 'token'

d = client.sessions.heartbeat(sessionId, token)
d.addCallback(resultCallback)
```

Update existing session:

```Python
sessionId = 'seFoo'
payload = {'heartbeat_timeout': 15}

d = client.sessions.update(sessionId, payload)
d.addCallback(resultCallback)
```

## Events

List events:

```Python
marker = 'last-seen-token'

d = client.events.list(marker)
d.addCallback(resultCallback)
```

## Services

List services:

```Python

d = client.services.list()
d.addCallback(resultCallback)
```

List services for a specific tag:

```Python
tag = 'tag'

d = client.services.listForTag(tag)
d.addCallback(resultCallback)
```

Get service by ID:

```Python
serviceId = 'messenger1'

d = client.services.get(serviceId)
d.addCallback(resultCallback)
```

Create a new service:

```Python
sessionId = 'sessionId'
serviceId = 'messenger1'
payload = {
'tags': ['messenger', 'stats'],
'metadata': {'someKey': 'someValue', 'anotherKey': 'anotherValue'}
}

d = client.services.register(sessionId, serviceId, payload)
d.addCallback(resultCallback)
```

Update existing service:

```Python
serviceId = 'messenger1'
payload = {
'tags': ['tag1', 'tag2'],
'metadata': {'aKey': 'aValue'}
}

d = client.services.update(serviceId, payload)
d.addCallback(resultCallback)
```

## Configuration

List configuration values:

```Python

d = client.configuration.list()
d.addCallback(resultCallback)
```

Get configuration value by id:

```Python
configurationId = 'configId'

d = client.configuration.get(configurationId)
d.addCallback(resultCallback)
```

Update configuration value:

```Python
configurationId = 'configId'
value = 'new-value'

d = client.configuration.set(configurationId, value)
d.addCallback(resultCallback)
```

Delete configuration value:

```Python
configurationId = 'configId'

d = client.configuration.remove(configurationId)
d.addCallback(resultCallback)
```

## Accounts

Get account limits:

```Python
d = client.account.getLimits()
d.addCallback(resultCallback)
```

Also, make sure to call:

```Python
reactor.run()
```
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -100,7 +100,7 @@ def run(self):

setup(
name='txServiceRegistry',
version='0.1.3',
version='0.2.0',
description='A Twisted Python client for Rackspace Service Registry.',
author='Rackspace Hosting, Inc.',
author_email='sr@rackspace.com',
Expand Down

0 comments on commit 0fec294

Please sign in to comment.