-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from cloudant-labs/cloudant
Cloudant
- Loading branch information
Showing
29 changed files
with
1,258 additions
and
573 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,7 @@ | ||
local_credentials.py | ||
.idea | ||
cloudant.py | ||
|
||
*.py[cod] | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Packages | ||
*.egg | ||
*.egg-info | ||
dist | ||
venv | ||
*.pyc | ||
build | ||
eggs | ||
parts | ||
bin | ||
var | ||
sdist | ||
develop-eggs | ||
.installed.cfg | ||
lib | ||
lib64 | ||
|
||
# Installer logs | ||
pip-log.txt | ||
|
||
# Unit test / coverage reports | ||
.coverage | ||
.tox | ||
nosetests.xml | ||
|
||
# Translations | ||
*.mo | ||
|
||
# Mr Developer | ||
.mr.developer.cfg | ||
.project | ||
.pydevproject | ||
dist | ||
.coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
language: python | ||
python: | ||
- "2.7" | ||
services: | ||
- couchdb | ||
before_script: | ||
- pip install coverage coveralls | ||
script: | ||
- coverage run --source=cloudant setup.py test | ||
after_success: | ||
- coveralls |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
Contributors | ||
============ | ||
|
||
healthy is written and maintained by [Dustin Collins](https://github.com/dustinmm80) | ||
* [Dustin Collins](https://github.com/dustinmm80) | ||
* [Max Thayer](http://github.com/garbados) |
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
#!/usr/bin/env python | ||
# coding=utf-8 | ||
from resource import Resource | ||
from connection import Connection | ||
from database import Database | ||
from document import Document | ||
from attachment import Attachment | ||
from view import View |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from .resource import Resource | ||
|
||
|
||
class Attachment(Resource): | ||
|
||
""" | ||
Attachment methods for a single document | ||
""" | ||
|
||
pass # lawl everything is defined by the parent class :D |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
from .resource import Resource | ||
from .database import Database | ||
|
||
|
||
class Connection(Resource): | ||
|
||
""" | ||
A connection to a Cloudant or CouchDB instance. | ||
connection = cloudant.Connection() | ||
connection.login(USERNAME, PASSWORD).result() | ||
print connection.get().result().json() | ||
# {"couchdb": "Welcome", ...} | ||
""" | ||
|
||
def __init__(self, uri="http://localhost:5984", **kwargs): | ||
super(Connection, self).__init__(uri, **kwargs) | ||
|
||
def database(self, name, **kwargs): | ||
"""Create a `Database` object prefixed with this connection's URL.""" | ||
opts = dict(self.opts.items() + kwargs.items()) | ||
return Database(self._make_url(name), session=self._session, **opts) | ||
|
||
def __getitem__(self, name): | ||
"""Shortcut to `Connection.database`.""" | ||
return self.database(name, **self.opts) | ||
|
||
def all_dbs(self, **kwargs): | ||
"""List all databases.""" | ||
return self.get('_all_dbs', **kwargs) | ||
|
||
def session(self, **kwargs): | ||
"""Get current user's authentication and authorization status.""" | ||
return self.get('_session', **kwargs) | ||
|
||
def login(self, username, password, **kwargs): | ||
"""Authenticate the connection via cookie.""" | ||
headers = { | ||
"Content-Type": "application/x-www-form-urlencoded" | ||
} | ||
data = "name=%s&password=%s" % (username, password) | ||
return self.post('_session', headers=headers, data=data, **kwargs) | ||
|
||
def logout(self, **kwargs): | ||
"""De-authenticate the connection's cookie.""" | ||
return self.delete('_session', **kwargs) | ||
|
||
def active_tasks(self, **kwargs): | ||
"""List replication, compaction, and indexer tasks currently running.""" | ||
return self.get('_active_tasks', **kwargs) | ||
|
||
def replicate(self, source, target, opts={}, **kwargs): | ||
""" | ||
Begin a replication job. | ||
`opts` contains replication options such as whether the replication | ||
should create the target (`create_target`) or whether the replication | ||
is continuous (`continuous`). | ||
Note: unless continuous, will not return until the job is finished. | ||
""" | ||
|
||
params = { | ||
'source': source, | ||
'target': target | ||
} | ||
|
||
params.update(opts) | ||
if 'params' in kwargs: | ||
params.update(kwargs['params']) | ||
del kwargs['params'] | ||
|
||
return self.post('_replicate', params=params, **kwargs) | ||
|
||
def uuids(self, count=1, **kwargs): | ||
"""Generate an arbitrary number of UUIDs.""" | ||
params = dict(count=count) | ||
return self.get('_uuids', params=params, **kwargs) |
Oops, something went wrong.