For convenient reference in development, here are the Archelon Daemon API docs.
Abstract base class for data stores
Bases: object
Abstract Data storage for command history
Abstract class implementation of a database for use with command history. Generally a command data item needs just two things, an ID and the command itself. It also needs order. See the archelond.data.MemoryData class as the simplest structure using an collections.OrderedDict.
An ID can be any string, and the concrete implementation of HistoryData is responsible for type casting it if needed.
It is also required implicitly that there is only one entry per command. Thus add ing the same command multiple times should result in the return of just one command when filtered by a term equal to that command.
Add or update a command
Save (update or create) a command to the data store.
Parameters: |
|
---|---|
Returns: | Command ID (str): The id of the command stored |
Unfiltered but ordered command history
Return the full data set as a list of dict structures in the specified order.
Parameters: |
|
---|---|
Returns: | A list of dictionaries where each dictionary must have at least a command key and an id key. |
Return type: | list |
Delete a command
Remove a command from the data store, raise a KeyError if it is not available to be deleted.
Parameters: |
|
---|
Get a filtered by term and ordered command history
Parameters: |
|
---|---|
Returns: | A list of dictionaries where each dictionary must have at least a command key and an id key. |
Return type: | list |
Get a single command
Retrieve a single command by username and id. Raise a KeyError if the command does not exist.
Parameters: |
|
---|---|
Returns: | Command – Dictionary with at least the keys id and command |
Return type: | dict |
In memory data store implementation for development and testing
Bases: archelond.data.abstract.HistoryData
A quick in memory deduplicated structure for standalone testing and development.
ElasticSearch implementation of the data store. Currently the recommended default data store.
Bases: archelond.data.abstract.HistoryData
An ElasticSearch implementation of HistoryData. This is what should be used in production
Add the command to the index with a time stamp and id by hash of the command and append username to doc type for user separation of data.
Decorators for authentication via basic auth or tokens
This function is called to check if a username / password combination is valid via the htpasswd file.
Check to see who this is and if their token gets them into the system.
Configure the flask application
Configure logging
Classic utility module for removing repetitive tasks and such
Main entry point for flask application
Actions for individual command history items.
Updates, gets, or deletes a command from the active data store.
PUT: Takes a payload in either form or JSON request, and runs the add routine by passing the dictinoary minus command, username, and host as kwargs to the data stores add routine.
If started from command line, rebuild object in debug mode and run directly