This projects aims at providing unified and easy-to-use Python library for communicating with the Data Stewardship Wizard API. For more info about the DSW project itself, see official webpage or the API documentation.
You can install this library via PyPI:
pip install dsw-sdk
The only mandatory step need in order to get going is to initialize the whole SDK and tell it, where is the DSW API located and how to connect to it:
from dsw_sdk import DataStewardshipWizardSDK
dsw_sdk = DataStewardshipWizardSDK(
api_url='http://localhost:3000',
email='albert.einstein@example.com',
password='password',
)
Now you are ready to go.
Note that this is only illustrative example and we encourage you not to store secrets like passwords in the source code. There are better mechanisms (env variables) introduced in the docs.
Most actions should be done via the high-level interfaces provided on an
instance of the DataStewardshipWizardSDK
class. These interfaces operate with
subclasses of Model
class (e.g. user.User
) -- these are the DSW data
entities. Basically they are just data classes with bunch of attributes and
methods for saving the entity (save()
) on the server and deleting it
(delete()
).
import os
user = dsw_sdk.users.create_user(
first_name='John',
last_name='Doe',
email='john.doe@example.com',
)
user.password = os.getenv('SECRET_PASSWORD')
user.save()
...
user.delete()
For more advanced usage, see the docs.
Want to fix a bug or help with implementing new features? Don't hesitate to contact us and read the contributing doc.