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

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

Uploaded Python 3

Supported by

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