A REST client - inspired by restmod for javascript.
Test status
Quick start for contributing
virtualenv -p `which python3` virtualenv source virtualenv/bin/activate pip install -r requirements.txt pip install -r dev_requirements.txt nosetests
Usage
from peace import PeaceMaker
def set_authorization_header(request):
request.headers['Authorization'] = authorization_value
return request
maker = PeaceMaker('http://api.example.com')
Employee = maker.make(
'Employee',
'/employees'
has: {
'user': maker.make('Company'),
},
intercept: set_authorization_header,
)
employees = Employee.search(last_name='Smith')
bob = Employee.get('100')
bob.last_name = 'Smith-Jones'
bob.save()
bob.refresh()
company = bob.company
print(company.name) # prints name
Peace requires the REST API to conform to a particular structure. A JSON response should look something like this:
{
"data": {
"id": 100,
"first_name": "Bob",
"last_name": "Smith",
},
"links": {
"self": {"href": "/employees/100"},
"company": {
"href": "/companies/5",
"data": {
"name": "Big Corp",
},
},
},
}
Links can be followed (e.g. bob.company). Initially, the data returned in the original request will be immediately available, but if you try to access other fields that a direct load is required to make available, (i.e. were not in the original response), then a load of the linked object will be done first (e.g. GET /companies/5).
Metadata
Release files for peace 0.0.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| peace-0.0.8.tar.gz | 7.0 kB | Without provenance | Details |
Release files / peace-0.0.8.tar.gz
| Download URL | peace-0.0.8.tar.gz |
|---|---|
| Size | 7.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8f47b4695f85bba7c35064bcbf4024129f0a710a627eb8bee783782cc66032f1
|
|
BLAKE2b-256 checksum How to use checksums |
cdd45dddad716e662a57b3660905fc24fe17b0d967a23d950e4d923677f5a1ea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for peace 0.0.8
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.