Skip to main content

Generieke client voor GEMMA-zaken componenten

Project description

Build status

De ZDS-Client is een (voorlopig) interne client die op basis van OAS 3.0 specificaties met GEMMA-zaken componenten communiceert.

1 Features

  • Ophalen van OAS 3.0 spec & caching

  • Aanmaken van resources volgens specificatie

  • Generieke opzet, maar specifiek gebruik in de zaakgericht-werken services

  • Introspectie in het OAS schema: lees op basis van een resource URL uit wat er precies hoort achter deze URL te zitten.

  • ZDS autorisatiemodel via JWT out-of-the-box ondersteund.

2 Installatie

2.1 Benodigdheden

  • Python 3.6 of hoger

  • setuptools 30.3.0 of hoger

2.2 Installeren

pip install gemma-zds-client

3 Gebruik

3.1 Initialiseren (statische configuratie)

De client moet geinitialiseerd worden met de locatie van de componenten. Dit kan eenmalig of just-in-time wanneer je de client nodig hebt:

from zds_client import Client

Client.load_config('/pad/naar/config.yml')

De makkelijkste manier is configuratie via een yaml bestand, in het formaat:

---

zrc:
  scheme: http
  host: localhost
  port: 8000
  auth:
    client_id: my-zrc-client-id
    secret: my-zrc-client-secret
    scopes:
      - zds.scopes.zaken.aanmaken

drc:
  scheme: http
  host: localhost
  port: 8001

ztc:
  scheme: http
  host: localhost
  port: 8002

orc:
  scheme: http
  host: localhost
  port: 8003

De key is de naam van de component.

Je kan echter ook de configuratie zonder yaml bestand doen, en volledig gebruik maken van Python dictonaries, bijvoorbeeld:

from zds_client import Client

ZRC = {
    'scheme': 'http',
    'host': 'localhost',
    'port': 8000,
}

DRC = {
    'scheme': 'http',
    'host': 'localhost',
    'port': 8001,
}

Client.load_config(**{
    'zrc': ZRC,
    'drc': DRC,
    ...
})

3.2 Initialiseren (ad-hoc configuratie)

Je kan ook een client instance verkrijgen op basis van een specifieke resource URL.

from zds_client import Client

client = Client.from_url('https://api.nl/v1/resource/123')

Indien authorisatie hierop nodig is, kan je deze zelf assignen:

from zds_client import ClientAuth

client.auth = ClientAuth(
    client_id='my-client-id',
    secret='my-client-secret',
    **claims
)

3.3 Resources manipuleren

Per component kan je vervolgens een client resources laten opvragen of manipuleren:

zrc_client = Client('zrc')  # gebruik alias uit configuratie

# oplijsten
zaken = zrc_client.list('zaak')

# opvragen
zaak = zrc_client.retrieve('zaak', uuid='<uuid>')

# opvragen met URL
zaak = zrc_client.retrieve('zaak', url='<zaak_url>')

# aanmaken
zaak = zrc_client.create('zaak', {
    'bronorganisatie': '000000000',
    'zaaktype': 'http://localhost:8002/api/v1/zaaktypen/<uuid>'
})

3.4 Schema introspectie

Met de schema module kan je introspectie doen op resource URLs:

from zds_client import Client
from zds_client.schema import Schema

zrc_client = Client('zrc')  # gebruik alias uit configuratie

schema = Schema(zrc_client.schema)

input_schema = schema.get_request_resource_schema(
    'https://api.nl/v1/resource/123', method='GET'
)
assert input_schema['type'] == 'object'

params = schema.get_request_parameters(
    'https://api.nl/v1/resource/123', method='GET'
)
assert type(params) == list

output_schema = schema.get_response_resource_schema(
    'https://api.nl/v1/resource/123',
    method='GET', status_code='200'
)
assert output_schema['type'] == 'object'

Project details


Download files

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

Source Distribution

gemma-zds-client-0.12.0.tar.gz (11.5 kB view details)

Uploaded Source

Built Distribution

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

gemma_zds_client-0.12.0-py2.py3-none-any.whl (13.7 kB view details)

Uploaded Python 2Python 3

File details

Details for the file gemma-zds-client-0.12.0.tar.gz.

File metadata

  • Download URL: gemma-zds-client-0.12.0.tar.gz
  • Upload date:
  • Size: 11.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.9

File hashes

Hashes for gemma-zds-client-0.12.0.tar.gz
Algorithm Hash digest
SHA256 541d3a07eaa1aa8e4ada038dd7f5bc8e5a5afeee883115c1a4a63fd2621b1776
MD5 eb61a51cf0a3a01cae490f7e6b2b20eb
BLAKE2b-256 137d95d4f03829e4d8ba6b65338faacd4bf5fc229229c164aa92e5b0766cdb19

See more details on using hashes here.

File details

Details for the file gemma_zds_client-0.12.0-py2.py3-none-any.whl.

File metadata

  • Download URL: gemma_zds_client-0.12.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 13.7 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.9

File hashes

Hashes for gemma_zds_client-0.12.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 775b059fb5130feda334191c0a0ba47d241f2caf07cd4ffd0379bdb141f1acc9
MD5 3d525badd4168797b6998c8b9e72f9a9
BLAKE2b-256 a00a075070d142d66808fc977e30cf8d7379a27c971f4015a41b3ab053ebe92a

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