Skip to content

Waldur SDK

Waldur SDK is a python wrapper for typical REST operations. You can use it, if you want to send requests to Waldur REST API directly from Python. SDK is represented by Python module called waldur_client.py from ansible-waldur-module repository.

Installation

Due to frequent SDK updates, installation from the public GitHub repository is highly recommended:

1
pip install git+https://github.com/waldur/ansible-waldur-module.git@develop

In order to perform operations, a user needs to create an instance of WaldurClient class:

1
2
3
from waldur_client import WaldurClient

client = WaldurClient('<api-url>', '<api-token>')

This instance provides interface for further interaction with Waldur and will be used across examples in related documentation.

Error handling

If the client fails to perform an operation, it raises WaldurClientException. This can be handled using try...except block. Example:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
from waldur_client import WaldurClient, WaldurClientException
import pprint

client = WaldurClient('https://abc.example.com/api', 'some-token')

try:
    client.list_marketplace_resources()
except WaldurClientException as e:
    pprint.pprint(e)

# WaldurClientException("HTTPSConnectionPool(host='abc.example.com', port=443):
# Max retries exceeded with url: /api/marketplace-resources/?page_size=200
# (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x110636430>:
# Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known'))")

Last update: 2021-10-08