Package: dcso-portal-python-sdk
DCSO Portal Python SDKCopyright (c) 2020, 2021, DCSO Deutsche Cyber-Sicherheitsorganisation GmbHDCSO Portal Python Software Development Kit (SDK) helps you create
application which need to interact with the DCSO Portal.Documentation:https://dcso.github.io/dcso-portal-python-sdk/dcso/portal/RequirementsThis library is, when installed, pure Python. We use only 3rd party tools
for installation and documentation generation.Python v3.7 or greater (Python v3.6 as best effort)Requirements:for distribution, seerequirements_dist.txtRequirements can be installed using, for example,pip:$ pip install -r requirements_dist.txtWe strongly advise to use a Virtual Environment for testing or for
development. This makes sure your local Python environment stays clean.$ python3 -m venv venvdir
$ source ./venvdir/bin/activate
(venvdir)$ pip install -r requirements.txtInstallationThis section explains how to install the DCSO Portal Python SDK. You can get
a copy and source onGitHub.From Python Package Index (PyPI)$ pip install -U dcso-portal-python-sdkUsing SourceInstallation is done usingsetup.py:$ pip install .
or
$ python3 setup.py installIt is advised, when developing or testing, to use a Virtual Environment (see
Prerequisites in this document).DocumentationDocumentation is available as HTML in thedocs/dcso/portalfolder.It is possible to generate it using:$ ./gendocs.pyAlternatively, it is also possible to have the documentation service
by the pdoc3 web server. This is mostly useful for working on the
documentation since it will rebuild automatically:$ PYTHONPATH="./lib" pdoc --http : --html \
    --template-dir support/doc_templates dcso.portal

open http://localhost:8080/dcso.portal/Seepdoc --helpfor more information.ExamplesThe folderexamplescontains code which can be used to learn how to
use this SDK.When running the examples, within the root of the repository, use
thePYTHONPATHvariable:$ PYTHONPATH="lib" python3 examples/basic.pyexample/portal_cli.pyTheportal_cli.py, Portal Command-Line Intereface, show how to create an
interactive client.
It will prompt for username, password, and if needed, also the one-time password.The result is showing all permissions the user has, and whether the user
has TDH Coordinator access.example/exec_graphql.pyTheexec_graphql.pyshows how to connect using a Machine Token (also known as
API Tokene), and execute some GraphQL.DevelopmentThe SDK itself and its tests stays as pure Python as possibly can be.An exception is the Setuptools requirement for installation or any tools
for packaging.DCSO NamespaceWe use thedcsopackage namespace, which can be recognized lacking the__init__.py. This helps having other Python project which can then
install in the same location.Running TestsDirectly using theunittestpackage from command line:$ PYTHONPATH="lib" python3 -m unittest discover -s ./lib/dcso/ -vvOr using the wrapper script, to run all tests:$ python3 test.pyIDE TipsPyCharmRight click on thelib/folder in the root of the repository and
select 'Mark Directory as > Sources Root'. This will make sure PyCharm
add the code to itsPYTHONPATH.DistributionDCSO Portal Python SDK is make available for downloading from GitHub as source
distributions are made available with each release.We also upload to the Python Package Index (PyPI) usingtwine, and an API token.Preparing a ReleaseIt is a good idea to start with a fresh Virtual Environment when creating a new
release.Install requirements:pip install -r requirements_dist.txtCreate a supporting branch which contains the version number to be releases,
for example,release/1.0.0-beta3Updatelib/dcso/portal/_version.pyand update the__version__variableGenerate documentation:./gendocs.pyCreate source distribution:python setup.py sdist --formats=zip(will be created
in sub folderdist)Upload to PyPIWith the source distribution created as ZIP-archive, we can now upload to PyPI using
the Twine module.python3 -m twine upload dist/dcso_portal_python_sdk-1.0.0b3.zipThetwinemodule is installed usingpip install -r requirements_dist.txt.Twine will ask you for credentials:Use__token__as usernameAs Password, enter the PyPI API Token for thedcso-portal-python-sdkproject (note
that this includes thepypi-prefix)LicenseMIT