Skip to main content

Toolkit for creating clients of HAL based Hypermedia APIs.

Project description

HALchemy

HAL-based Hypermedia API clients for humans

Methods

  • def url_from_rel(resource, rel, parameters={}, template={}):
  • def post_to_url(self, url, data):
  • def post_to_rel(self, resource, rel, data, parameters={}, template={}):
  • def patch_resource(self, resource, data):
  • def put_to_resource(self, resource, data, rel='self'):
  • def get(self, url='/'):
  • def get_from_rel(self, resource, rel='self', parameters={}, template={}):
  • def get_from_rel_with_lookup(self, resource, rel, lookup, parameters={}):
  • def delete_collection(self, url):
  • def delete_resource(self, resource):

Features

  • parameters and templates

  • additional lookup (implicit templates)

  • requests library remembers defaults

    • base url (allowing .get('/path')
    • auth (saving managing headers with each request - defaults to Basic root:password)
  • can use python dict for POST/PUT/PATCH data (automatically converts to JSON)

  • in post_to_url():

except:
    if response.status_code == 422:
        issue = response.json().get('_issues', {}).get('name', '')
        if 'is not unique' in issue:
            new_data = json.loads(data)
            new_data['name'] += ' ~'
            return self._api.post(url, data=new_data)
    message = f'{response.status_code} {response.reason}'
    details = response.text
            raise RuntimeError(f'POST {url} - {message}\n{details}\n\n{data}')

Roadmap

  • chainable requests
  • HAL Forms
  • as many languages as we can get to

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

HALchemy-0.1.4-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file HALchemy-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: HALchemy-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for HALchemy-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 dacf61896f5960dbfe473c11b817692d000d3abf356259d4d81453f554375361
MD5 34d5c0f21b83428f2a6d506e33310c7e
BLAKE2b-256 245ba0e29c4e8abe0a732176cc4d3f3cfaa9ee4ae34f60ec8a5b7c4e717f7134

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page