Hansken Python API
hansken.py
is a Python module that facilitates use of the Hansken REST API from Python scripts.
hansken.py
is tested for Python 3.8 through 3.11.
Installation files
Installation files for hansken.py
are available below.
These can be installed by running the following command:
hansken.py for Python 3.8 and up
$ pip install hansken-2024.3.29-py3-none-any.whl
The distribution defines a number of extras, which enable additional functionality for hansken.py
.
Extras can be installed by adding [extra-name]
to the installation of hansken.py
through pip, e.g.
$ pip install hansken-2024.3.29-py3-none-any.whl[all]
The following extras are defined:
- shell
Enables the use of the shell command by installing the package
ipython
.- kerberos
Enables Kerberos authentication by installing the package
requests-kerberos
.- report
Enables the report recipe by installing the packages
jinja2
andweasyprint
.- mount
Enables the use of the mount command by installing the package
fusepy
.- all
Enables all of the above by installing every optional package required for all of the extras.
Hello, world!
Here is a simple “hello, world”-style script to print some details about files in a project with id deadbeef-c0de-c0de-c0de-badbadc0ffee
:
from hansken.remote import ProjectContext
# create a object that allows us to interact with Hansken in the context
# of a particular project
with ProjectContext('https://hansken.example.nl/gatekeeper',
'deadbeef-c0de-c0de-c0de-badbadc0ffee') as context:
# find all traces of type file
results = context.search('type:file')
for trace in results:
# print a number of properties for each trace to stdout
print(trace.id, trace.name, trace.file.modified_on)
It’s that simple!
Note that this example does not use authentication; a real endpoint likely requires us to identify ourselves.
Additionally, scripts will typically use hansken.tool.run
as a starting point, making any script you’ll write usable for other people.
If this is your first hansken.py
rodeo, see getting started for more info.
Documentation
- Getting started
- Examples
- Execute simple query
- List available projects
- Read PNG details from trace data
- Calculate the size of a folder
- Create a new trace from an existing one
- Create a report from a selection of traces
- Search with deduplication
- Add a large datastream to a single Trace
- Cleaning trace data with an HQL query
- Deleting cleaned data
- API Documentation
hansken.tool
— Command line interactionhansken.connect
— Connecting to Hanskenhansken
— Global valueshansken.trace
— Interact with traces / search resultshansken.query
— Constructing Hansken querieshansken.auth
— Authenticationhansken.remote
— Communication with Hanskenhansken.util
— Utilities for internal and external use
- Recipes
- Command line interface
- Changelog
Contributions and feedback
Todo
Link to hansken community scripts / forge / gist / …
Spot an error, something ambiguous or something unexpectedly brilliant, let us know!
Come across behavior that seems wrong / run into a bug, let us know!
Find yourself doing the same thing over and over, submit a feature request to have it turned into a recipe?
Recent changes
Release |
Change type |
Description |
---|---|---|
2024.03.29 |
Feature |
Add |
2024.03.20 |
Feature |
Maintain blocking behaviour of |
2024.02.14 |
Feature |
Add argument |
2024.02.05 |
Feature |
Expose |
2024.01.11.1 |
Feature |
Add arguments |
See full changelog.