chatbot
clear chat
Skip to main content

Python Example

Using the Generator

Requirements: Python >= 3.7

For the python example we used the same commands as described here. For the generator name, we selected the python generator provided from the openAPI Generator documentation, and for convenience we named the output folder python.

The command will be:

npx openapi-generator-cli generate -i specs/household.yaml -g python -o python/
note

For convenience and demonstration reasons we use an already existing account and scenario, so that we can make use of the authentication token and the scenario id in order to manipulate the household using the generated client.

Generated outcome

The openAPI Generator will then produce an api client in a structure that looks similiar (if not identical) to this:

├─ python
├─ .openapi-generator
│ ├─ FILES
│ └─ VERSION
├─ docs
│ ├─ apis
│ │ └─ tags
│ │ ├─ ChildrenApi.md
│ │ ├─ ParentsApi.md
│ │ ├─ PartnerApi.md
│ │ ├─ PersonsApi.md
│ │ └─ PrimaryApi.md
│ └─ models
│ ├─ ChildDto.md
│ ├─ PagableObject.md
│ ├─ PageChildDto.md
│ ├─ PageParentDto.md
│ ├─ PagePersonDto.md
│ ├─ ParentDto.md
│ ├─ PartnerDto.md
│ ├─ PersonDto.md
│ ├─ PrimaryDto.md
│ └─ SortObject.md
├─ openapi_client
│ ├─ apis
│ │ ├─ paths
│ │ │ ├─ __init__.py
│ │ │ ├─ scenarios_scenario_id_persons_children.py
│ │ │ ├─ scenarios_scenario_id_persons_parents.py
│ │ │ ├─ scenarios_scenario_id_persons_partner.py
│ │ │ ├─ scenarios_scenario_id_persons_person_id.py
│ │ │ ├─ scenarios_scenario_id_persons_primary.py
│ │ │ └─ scenarios_scenario_id_persons.py
│ │ ├─ tags
│ │ │ ├─ __init__.py
│ │ │ ├─ children_api.py
│ │ │ ├─ parents_api.py
│ │ │ ├─ partner_api.py
│ │ │ ├─ person_api.py
│ │ │ └─ primary_api.py
│ │ ├─ __init__.py
│ │ ├─ path_to_api.py
│ │ └─ tag_to_api.py
│ ├─ model
│ │ ├─ __init__.py
│ │ ├─ child_dto.py
│ │ ├─ child_dto.pyi
│ │ ├─ page_child_dto.py
│ │ ├─ page_child_dto.pyi
│ │ ├─ page_parent_dto.py
│ │ ├─ page_parent_dto.pyi
│ │ ├─ page_person_dto.py
│ │ ├─ page_person_dto.pyi
│ │ ├─ pageable_object.py
│ │ ├─ pageable_object.pyi
│ │ ├─ parent_dto.py
│ │ ├─ parent_dto.pyi
│ │ ├─ partner_dto.py
│ │ ├─ partner_dto.pyi
│ │ ├─ person_dto.py
│ │ ├─ person_dto.pyi
│ │ ├─ primary_dto.py
│ │ ├─ primary_dto.pyi
│ │ ├─ sort_object.py
│ │ └─ sort_object.pyi
│ ├─ models
│ │ └─ __init__.py
│ ├─ paths
│ │ ├─ scenarios_scenario_id_persons
│ │ │ ├─ __init__.py
│ │ │ ├─ get.py
│ │ │ └─ get.pyi
│ │ ├─ scenarios_scenario_id_persons_children
│ │ │ ├─ __init__.py
│ │ │ ├─ get.py
│ │ │ ├─ get.pyi
│ │ │ ├─ post.py
│ │ │ └─ post.pyi
│ │ ├─ scenarios_scenario_id_persons_parents
│ │ │ ├─ __init__.py
│ │ │ ├─ get.py
│ │ │ ├─ get.pyi
│ │ │ ├─ post.py
│ │ │ └─ post.pyi
│ │ ├─ scenarios_scenario_id_persons_partner
│ │ │ ├─ __init__.py
│ │ │ ├─ delete.py
│ │ │ ├─ delete.pyi
│ │ │ ├─ get.py
│ │ │ ├─ get.pyi
│ │ │ ├─ post.py
│ │ │ ├─ post.pyi
│ │ │ ├─ put.py
│ │ │ └─ put.pyi
│ │ ├─ scenarios_scenario_id_persons_person_id
│ │ │ ├─ __init__.py
│ │ │ ├─ delete.py
│ │ │ ├─ delete.pyi
│ │ │ ├─ get.py
│ │ │ ├─ get.pyi
│ │ │ ├─ put.py
│ │ │ └─ put.pyi
│ │ └─ scenarios_scenario_id_persons_primary
│ │ ├─ __init__.py
│ │ ├─ get.py
│ │ ├─ get.pyi
│ │ ├─ put.py
│ │ └─ put.pyi
│ ├─ __init__.py
│ ├─ api_client.py
│ ├─ configuration.py
│ ├─ exceptions.py
│ ├─ rest.py
│ └─ schemas.py
├─test
│ ├─ test_models
│ │ ├─ __init__.py
│ │ ├─ test_child_dto.py
│ │ ├─ test_page_child_dto.py
│ │ ├─ test_page_parent_dto.py
│ │ ├─ test_page_person_dto.py
│ │ ├─ test_pageable_object.py
│ │ ├─ test_parent_dto.py
│ │ ├─ test_partner_dto.py
│ │ ├─ test_person_dto.py
│ │ ├─ test_primary_dto.py
│ │ └─ test_sort_object.py
│ ├─ test_paths
│ │ ├─ test_scenarios_scenario_id_persons
│ │ │ ├─ __init__.py
│ │ │ └─ test_get.py
│ │ ├─ test_scenarios_scenario_id_persons_children
│ │ │ ├─ __init__.py
│ │ │ ├─ test_get.py
│ │ │ └─ test_post.py
│ │ ├─ test_scenarios_scenario_id_persons_parents
│ │ │ ├─ __init__.py
│ │ │ ├─ test_get.py
│ │ │ └─ test_post.py
│ │ ├─ test_scenarios_scenario_id_persons_partner
│ │ │ ├─ __init__.py
│ │ │ ├─ test_delete.py
│ │ │ ├─ test_get.py
│ │ │ ├─ test_post.py
│ │ │ └─ test_put.py
│ │ ├─ test_scenarios_scenario_id_persons_person_id
│ │ │ ├─ __init__.py
│ │ │ ├─ test_delete.py
│ │ │ ├─ test_get.py
│ │ │ └─ test_put.py
│ │ └─ test_scenarios_scenario_id_persons_primary
│ │ ├─ __init__.py
│ │ ├─ test_get.py
│ │ └─ test_put.py
│ └─ __init__.py
├─ .openapi-genarator-ignore
├─ .travis.yml
├─ README.md
├─ requirements.txt
├─ setup.cfg
├─ setup.py
├─ test-requirements.txt
└─ tox.ini
  • FILES is a text file that lists all the generated files.
  • VERSION is a file that lists the openAPI Tools version used.
  • docs directory includes generated markdown documentation files for the generated client usage.
  • test directory includes generated test files for the generated client.
  • .openapi-generator-ingore is a file that documents the files that you will not want to overwrite in the future.
  • api_client.py lists all supported client parameters.
  • configuration.py lists all supported configuration parameters.
  • exceptions.py lists all exceptions that might be raised.
  • rest.py describes the restfull api methods.
  • schemas.py describes the types validation schemas.

Here is where we will make use of the files from apis, model and paths directories, inside our own python project or script.

Using the Client

First we need to install the client using the setup.py file. Copy the contents of the generated python directory into your own project and run the following command:

python setup.py install --user

Alternatively, if the python package is hosted on a repository, we can install directly using:

pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git

This will create a build and a dist directory in our project.

Inside the openapi_client directory we will find the api_client.py file where we can see what arguments the ApiClient require. For example:

class ApiClient:
.
.
.

def __init__(
self,
configuration: typing.Optional[Configuration] = None,
header_name: typing.Optional[str] = None,
header_value: typing.Optional[str] = None,
cookie: typing.Optional[str] = None,
pool_threads: int = 1
):
if configuration is None:
configuration = Configuration()
self.configuration = configuration
self.pool_threads = pool_threads

self.rest_client = rest.RESTClientObject(configuration)
self.default_headers = HTTPHeaderDict()
if header_name is not None:
self.default_headers[header_name] = header_value
self.cookie = cookie
# Set default User-Agent.
self.user_agent = 'OpenAPI-Generator/1.0.0/python'

.
.
.
  • The configuration arg can be used to set the api client options like the host url. This argument is required.
  • header_name and header_value can be used to set the headers of the requests. These arguments are also required.

These arguments can be set and used like this:

configuration = openapi_client.Configuration(
host = "https://api.envizage.me"
)

auth_token = "Bearer " + "<our account authentication token>"

openapi_client.ApiClient(configuration, header_name="Authorization", header_value=auth_token)

To use the clients request methods, for example to update a person, we also need to pass some arguments to them:

class UpdatePerson(BaseApi):
.
.
.

def update_person(
self,
body: typing.Union[SchemaForRequestBodyApplicationJson,],
content_type: str = 'application/json',
path_params: RequestPathParams = frozendict.frozendict(),
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
skip_deserialization: bool = False,
):
return self._update_person_oapg(
body=body,
path_params=path_params,
content_type=content_type,
accept_content_types=accept_content_types,
stream=stream,
timeout=timeout,
skip_deserialization=skip_deserialization
)
  • path_params are the url path parameters of the request:
path_params = {
'scenarioId': "<your sceanrio id>",
'personId': "<person to be updated id>",
}
  • body arg is where you pass all the required and available data transfer objects (Dto) fields to update the person, as described in Dto files of the model directory:
person_to_update = PersonDto(
description="description_example",
educationLevel="NO_EDUCATION",
expectedRetirementAge=0,
gender="UNSPECIFIED",
healthStatus="CRITICALLY_ILL",
jobType="UNEMPLOYED",
lastName="last_name_example",
maritalStatus="UNSPECIFIED",
name="name_example",
primary=False,
properties={
"key": {},
},
yearOfBirth=1990,
)
  • descriptions for the rest request arguments can be found in the generated documentation, but these are the absolutely required in most request methods.

A typical call to this update person request (PUT) will be:

with openapi_client.ApiClient(configuration, header_name="Authorization", header_value=auth_token) as api_client:

persons_api_instance = persons_api.UpdatePerson(api_client)

persons_api_instance.update_person(path_params=path_params, body=person_to_update)

Imports

Now in order to see these in action we create a python file, for example: main.py.

First we need to handle all of our imports:

import openapi_client
from pprint import pprint
from openapi_client.apis.tags import primary_api
from openapi_client.model.primary_dto import PrimaryDto
from openapi_client.apis.tags import partner_api
from openapi_client.model.partner_dto import PartnerDto
from openapi_client.apis.tags import children_api
from openapi_client.model.child_dto import ChildDto
from openapi_client.apis.tags import parents_api
from openapi_client.model.parent_dto import ParentDto
from openapi_client.apis.tags import persons_api
from openapi_client.model.person_dto import PersonDto

Instatiations

We pass the host url to our openapi_client configuration. For example:

configuration = openapi_client.Configuration(
host = "https://api.envizage.me"
)

As stated before, for simplicity, we use an already existing account and scenario so we need to also pass the auth_token and scenario_id variables:

auth_token = "Bearer " + "<our account authentication token>"

scenario_id = "<our scenario id>"

Then we enter a context with an instance of the API client:

def main():

with openapi_client.ApiClient(configuration, header_name="Authorization", header_value=auth_token) as api_client:


if __name__ == main():
main()

Inside the context we create an instance of the API class we want to use and make the request with the required arguments.

Primary API

Update and get primary person.

Update primary person:

    with openapi_client.ApiClient(configuration, header_name="Authorization", header_value=auth_token) as api_client:

primary_api_instance = primary_api.PrimaryApi(api_client)

path_params = {
'scenarioId': scenario_id,
}

person_primary = PrimaryDto(
description="",
expectedRetirementAge=67,
gender="FEMALE",
healthStatus="EXCELLENT",
educationLevel="SECONDARY_EDUCATION",
jobType="ACTIVE",
id="",
lastName="",
maritalStatus="UNSPECIFIED",
name="ME",
primary=True,
properties={
"key": {},
},
yearOfBirth=1985,
)

try:
updated_primary = primary_api_instance.update_primary(path_params=path_params, body=person_primary)
pprint(updated_primary.body)
except openapi_client.ApiException as e:
print("Exception when calling PrimaryApi->get_primary: %s\n" % e)

and in the response's body property we can see the request's person's info:

DynamicSchema({'id': '63c6bfe57e5fa112a5fda0cd', 'name': 'ME', 'description': '', 'properties': DynamicSchema({'key': DynamicSchema({})}), 'lastName': '', 'yearOfBirth': Decimal('1985'), 'primary': <DynamicSchema: True>, 'gender': <DynamicSchema: 'FEMALE'>, 'maritalStatus': <DynamicSchema: 'UNSPECIFIED'>, 'healthStatus': <DynamicSchema: 'EXCELLENT'>, 'jobType': <DynamicSchema: 'ACTIVE'>, 'educationLevel': <DynamicSchema: 'SECONDARY_EDUCATION'>, 'expectedRetirementAge': Decimal('67')})

Get primary person:

        try:
primary = primary_api_instance.get_primary(path_params=path_params)
pprint(primary.body)
except openapi_client.ApiException as e:
print("Exception when calling PrimaryApi->get_primary: %s\n" % e)

Response's body:

DynamicSchema({'id': '63c6bfe57e5fa112a5fda0cd', 'name': 'ME', 'description': '', 'properties': DynamicSchema({'key': DynamicSchema({})}), 'lastName': '', 'yearOfBirth': Decimal('1985'), 'primary': <DynamicSchema: True>, 'gender': <DynamicSchema: 'FEMALE'>, 'maritalStatus': <DynamicSchema: 'UNSPECIFIED'>, 'healthStatus': <DynamicSchema: 'EXCELLENT'>, 'jobType': <DynamicSchema: 'ACTIVE'>, 'educationLevel': <DynamicSchema: 'SECONDARY_EDUCATION'>, 'expectedRetirementAge': Decimal('67')})

Partner API

Create, get, update and delete a partner person.

Create a partner person:

        partner_api_instance = partner_api.CreatePartner(api_client)

person_partner = PartnerDto(
description="",
expectedRetirementAge=67,
gender="MALE",
healthStatus="EXCELLENT",
educationLevel="SECONDARY_EDUCATION",
jobType="ACTIVE",
lastName="",
maritalStatus="UNSPECIFIED",
name="PARTNER",
primary=False,
properties={
"key": {},
},
yearOfBirth=1985,
)

try:
partner = partner_api_instance.create_partner(path_params=path_params, body=person_partner)
pprint(partner.body)
except openapi_client.ApiException as e:
print("Exception when calling PartnerApi->create_primary: %s\n" % e)

Response:

DynamicSchema({'id': '6487052d7791e476436ac67f', 'name': 'PARTNER', 'description': '', 'properties': DynamicSchema({'key': DynamicSchema({})}), 'lastName': '', 'yearOfBirth': Decimal('1985'), 'primary': <DynamicSchema: False>, 'gender': <DynamicSchema: 'MALE'>, 'maritalStatus': <DynamicSchema: 'UNSPECIFIED'>, 'healthStatus': <DynamicSchema: 'EXCELLENT'>, 'jobType': <DynamicSchema: 'ACTIVE'>, 'educationLevel': <DynamicSchema: 'SECONDARY_EDUCATION'>, 'expectedRetirementAge': Decimal('67')})

Get partner person:

        partner_api_instance = partner_api.GetPartner(api_client)

try:
partner_get = partner_api_instance.get_partner(path_params=path_params)
pprint(partner_get.body)
except openapi_client.ApiException as e:
print("Exception when calling PartnerApi->get_partner: %s\n" % e)

Response:

DynamicSchema({'id': '6487052d7791e476436ac67f', 'name': 'PARTNER', 'description': '', 'properties': DynamicSchema({'key': DynamicSchema({})}), 'lastName': '', 'yearOfBirth': Decimal('1985'), 'primary': <DynamicSchema: False>, 'gender': <DynamicSchema: 'MALE'>, 'maritalStatus': <DynamicSchema: 'UNSPECIFIED'>, 'healthStatus': <DynamicSchema: 'EXCELLENT'>, 'jobType': <DynamicSchema: 'ACTIVE'>, 'educationLevel': <DynamicSchema: 'SECONDARY_EDUCATION'>, 'expectedRetirementAge': Decimal('67')})

Get a partner person:

        partner_api_instance = partner_api.UpdatePartner(api_client)

person_partner_updated = PartnerDto(
id=str(partner_get.body["id"]),
description="",
expectedRetirementAge=67,
gender="MALE",
healthStatus="EXCELLENT",
educationLevel="SECONDARY_EDUCATION",
jobType="ACTIVE",
lastName="",
maritalStatus="MARRIED",
name="PARTNER",
primary=False,
properties={
"key": {},
},
yearOfBirth=1985,
)

try:
partner_update = partner_api_instance.update_partner(path_params=path_params, body=person_partner_updated)
pprint(partner_update.body)
except openapi_client.ApiException as e:
print("Exception when calling PartnerApi->update_partner: %s\n" % e)

Response:

DynamicSchema({'id': '6487052d7791e476436ac67f', 'name': 'PARTNER', 'description': '', 'properties': DynamicSchema({'key': DynamicSchema({})}), 'lastName': '', 'yearOfBirth': Decimal('1985'), 'primary': <DynamicSchema: False>, 'gender': <DynamicSchema: 'MALE'>, 'maritalStatus': <DynamicSchema: 'MARRIED'>, 'healthStatus': <DynamicSchema: 'EXCELLENT'>, 'jobType': <DynamicSchema: 'ACTIVE'>, 'educationLevel': <DynamicSchema: 'SECONDARY_EDUCATION'>, 'expectedRetirementAge': Decimal('67')})

Delete a partner person:

        partner_api_instance = partner_api.DeletePartner(api_client)

try:
partner_delete = partner_api_instance.delete_partner(path_params=path_params, skip_deserialization=True)
pprint(partner_delete)
except openapi_client.ApiException as e:
print("Exception when calling PartnerApi->delete_partner: %s\n" % e)

Children API

Create and get children persons.

Create a child:

        children_api_instance = children_api.CreateChild(api_client)

person_child = ChildDto(
description="",
gender="UNSPECIFIED",
healthStatus="CRITICALLY_ILL",
lastName="",
maritalStatus="UNSPECIFIED",
name="name_example",
primary=False,
properties={
"key": {},
},
yearOfBirth=2020,
)

try:
child_create = children_api_instance.create_child(path_params=path_params, body=person_child)
pprint(child_create.body)
except openapi_client.ApiException as e:
print("Exception when calling ChildrenApi->create_child: %s\n" % e)

Response:

DynamicSchema({'id': '648708017791e476436ac6c4', 'name': 'name_example', 'description': '', 'properties': DynamicSchema({'key': DynamicSchema({})}), 'lastName': '', 'yearOfBirth': Decimal('2020'), 'primary': <DynamicSchema: False>, 'gender': <DynamicSchema: 'UNSPECIFIED'>, 'maritalStatus': <DynamicSchema: 'UNSPECIFIED'>, 'healthStatus': <DynamicSchema: 'CRITICALLY_ILL'>})

Get children:

        children_api_instance = children_api.GetChildren(api_client)

try:
children_get = children_api_instance.get_children(path_params=path_params)
pprint(children_get.body['content'])
except openapi_client.ApiException as e:
print("Exception when calling ChildrenApi->get_child: %s\n" % e)

Response:

(DynamicSchema({'id': '648708017791e476436ac6c4', 'name': 'name_example', 'description': '', 'properties': DynamicSchema({'key': DynamicSchema({})}), 'lastName': '', 'yearOfBirth': Decimal('2020'), 'primary': <DynamicSchema: False>, 'gender': <DynamicSchema: 'UNSPECIFIED'>, 'maritalStatus': <DynamicSchema: 'UNSPECIFIED'>, 'healthStatus': <DynamicSchema: 'CRITICALLY_ILL'>}),)
note

The response for the get children method is a tuple (()), because there can be more than one children.

Parent API

Create and get parent persons.

Create a parent:

        parents_api_instance = parents_api.CreateParent(api_client)

person_parent = ParentDto(
description="description_example",
educationLevel="NO_EDUCATION",
expectedRetirementAge=0,
gender="UNSPECIFIED",
healthStatus="CRITICALLY_ILL",
jobType="UNEMPLOYED",
lastName="last_name_example",
maritalStatus="UNSPECIFIED",
name="name_example",
primary=False,
properties={
"key": {},
},
yearOfBirth=1965,
)

try:
parent_create = parents_api_instance.create_parent(path_params=path_params, body=person_parent)
pprint(parent_create.body)
except openapi_client.ApiException as e:
print("Exception when calling ParentsApi->create_parent: %s\n" % e)

Response:

DynamicSchema({'id': '64870bf3d5d17118d903ff95', 'name': 'name_example', 'description': 'description_example', 'properties': DynamicSchema({'key': DynamicSchema({})}), 'lastName': 'last_name_example', 'yearOfBirth': Decimal('1965'), 'primary': <DynamicSchema: False>, 'gender': <DynamicSchema: 'UNSPECIFIED'>, 'maritalStatus': <DynamicSchema: 'UNSPECIFIED'>, 'healthStatus': <DynamicSchema: 'CRITICALLY_ILL'>, 'jobType': <DynamicSchema: 'UNEMPLOYED'>, 'educationLevel': <DynamicSchema: 'NO_EDUCATION'>, 'expectedRetirementAge': Decimal('0')})

Get parents:

        parents_api_instance = parents_api.GetParents(api_client)

try:
parents_get = parents_api_instance.get_parents(path_params=path_params)
pprint(parents_get.body['content'])
except openapi_client.ApiException as e:
print("Exception when calling ParentsApi->get_parents: %s\n" % e)

Response:

(DynamicSchema({'id': '64870bf3d5d17118d903ff95', 'name': 'name_example', 'description': 'description_example', 'properties': DynamicSchema({'key': DynamicSchema({})}), 'lastName': 'last_name_example', 'yearOfBirth': Decimal('1965'), 'primary': <DynamicSchema: False>, 'gender': <DynamicSchema: 'UNSPECIFIED'>, 'maritalStatus': <DynamicSchema: 'UNSPECIFIED'>, 'healthStatus': <DynamicSchema: 'CRITICALLY_ILL'>, 'jobType': <DynamicSchema: 'UNEMPLOYED'>, 'educationLevel': <DynamicSchema: 'NO_EDUCATION'>, 'expectedRetirementAge': Decimal('0')}),)
note

The response for the get parents method is a tuple (()), because there can be more than up to two parents.

Persons API

Get, update and delete persons.

Get a person:

        path_params = {
'scenarioId': scenario_id,
'personId': "648708017791e476436ac6c4",
}

persons_api_instance = persons_api.GetPerson(api_client)

try:
person_get = persons_api_instance.get_person(path_params=path_params)
pprint(person_get.body)
except openapi_client.ApiException as e:
print("Exception when calling PersonsApi->get_person: %s\n" % e)

Response:

DynamicSchema({'id': '648708017791e476436ac6c4', 'name': 'name_example', 'description': '', 'properties': DynamicSchema({'key': DynamicSchema({})}), 'lastName': '', 'yearOfBirth': Decimal('2020'), 'primary': <DynamicSchema: False>, 'gender': <DynamicSchema: 'UNSPECIFIED'>, 'maritalStatus': <DynamicSchema: 'UNSPECIFIED'>, 'healthStatus': <DynamicSchema: 'CRITICALLY_ILL'>})

Update a person:

        persons_api_instance = persons_api.UpdatePerson(api_client)

person_child_update = PersonDto(
id=str(person_get.body["id"]),
description="",
gender="UNSPECIFIED",
healthStatus="EXCELLENT",
lastName="",
maritalStatus="UNSPECIFIED",
name="name_example",
primary=False,
properties={
"key": {},
},
yearOfBirth=2020,
)

path_params = {
'scenarioId': scenario_id,
'personId': str(partner_get.body["id"]),
}

try:
person_update = persons_api_instance.update_person( path_params=path_params, body=person_child_update)
pprint(person_update.body)
except openapi_client.ApiException as e:
print("Exception when calling PersonsApi->update_persons: %s\n" % e)
DynamicSchema({'id': '648708017791e476436ac6c4', 'name': 'name_example', 'description': '', 'properties': DynamicSchema({'key': DynamicSchema({})}), 'lastName': '', 'yearOfBirth': Decimal('2020'), 'primary': <DynamicSchema: False>, 'gender': <DynamicSchema: 'UNSPECIFIED'>, 'maritalStatus': <DynamicSchema: 'UNSPECIFIED'>, 'healthStatus': <DynamicSchema: 'EXCELLENT'>})

Get all persons:

        persons_api_instance = persons_api.GetPersons(api_client)

try:
persons_get = persons_api_instance.get_persons(path_params=path_params)
pprint(persons_get.body['content'])
except openapi_client.ApiException as e:
print("Exception when calling PersonsApi->get_persons: %s\n" % e)

Response:

(DynamicSchema({'id': '64870bf3d5d17118d903ff95', 'name': 'name_example', 'description': 'description_example', 'properties': DynamicSchema({'key': DynamicSchema({})}), 'lastName': 'last_name_example', 'yearOfBirth': Decimal('1965'), 'primary': <DynamicSchema: False>, 'gender': <DynamicSchema: 'UNSPECIFIED'>, 'maritalStatus': <DynamicSchema: 'UNSPECIFIED'>, 'healthStatus': <DynamicSchema: 'CRITICALLY_ILL'>}),
DynamicSchema({'id': '63c6bfe57e5fa112a5fda0cd', 'name': 'ME', 'description': '', 'properties': DynamicSchema({'key': DynamicSchema({})}), 'lastName': '', 'yearOfBirth': Decimal('1985'), 'primary': <DynamicSchema: True>, 'gender': <DynamicSchema: 'FEMALE'>, 'maritalStatus': <DynamicSchema: 'UNSPECIFIED'>, 'healthStatus': <DynamicSchema: 'EXCELLENT'>}),
DynamicSchema({'id': '648708017791e476436ac6c4', 'name': 'name_example', 'description': '', 'properties': DynamicSchema({'key': DynamicSchema({})}), 'lastName': '', 'yearOfBirth': Decimal('2020'), 'primary': <DynamicSchema: False>, 'gender': <DynamicSchema: 'UNSPECIFIED'>, 'maritalStatus': <DynamicSchema: 'UNSPECIFIED'>, 'healthStatus': <DynamicSchema: 'EXCELLENT'>}),
DynamicSchema({'id': '6487052d7791e476436ac67f', 'name': 'PARTNER', 'description': '', 'properties': DynamicSchema({'key': DynamicSchema({})}), 'lastName': '', 'yearOfBirth': Decimal('1985'), 'primary': <DynamicSchema: False>, 'gender': <DynamicSchema: 'MALE'>, 'maritalStatus': <DynamicSchema: 'MARRIED'>, 'healthStatus': <DynamicSchema: 'EXCELLENT'>}))

Delete a person:

        persons_api_instance = persons_api.DeletePerson(api_client)

path_params = {
'scenarioId': scenario_id,
'personId': str(partner_get.body["id"]),
}

try:
person_delete = persons_api_instance.delete_person(path_params=path_params, skip_deserialization=True)
pprint(person_delete)
except openapi_client.ApiException as e:
print("Exception when calling PersonsApi->delete_person: %s\n" % e)