Skip to main content

Skip/Hopskotch broker module for the TOM Toolkit

Project description

pypi run-tests Codacy Badge Coverage Status

tom_scimma

This module adds Hopskotch and Skip support to the TOM Toolkit. Using this module, TOMs can query alerts submitted to the Hopskotch stream, and publish alerts to Hopskotch.

Installation

Install the module into your TOM environment:

pip install tom-scimma

Add tom_scimma.scimma.SCIMMABroker to the TOM_ALERT_CLASSES in your TOM's settings.py:

TOM_ALERT_CLASSES = [
    'tom_alerts.brokers.mars.MARSBroker',
    ...
    'tom_scimma.scimma.SCIMMABroker'
]

Though Skip alerts are public (for now), you'll need Hopskotch credentials to submit alerts. You can register for an account here. Add the appropriate Skip and Hopskotch credentials to your project's settings.py:

    BROKERS = {
        'SCIMMA': {
            'url': 'http://skip.dev.hop.scimma.org',
            'api_key': os.getenv('SKIP_API_KEY', ''),
            'hopskotch_url': 'dev.hop.scimma.org',
            'hopskotch_username': os.getenv('HOPSKOTCH_USERNAME', ''),
            'hopskotch_password': os.getenv('HOPSKOTCH_PASSWORD', ''),
            'default_hopskotch_topic': ''
        }
    }

Configurable settings

url: The URL for Skip requests, i.e. for retrieving alerts.

api_key: The API key used to authenticate/authorize with Skip. Currently unused.

hopskotch_url: The URL for Hopskotch broker submissions, i.e. submitting alerts.

hopskotch_username: The username used to authenticate with Hopskotch.

hopskotch_password: The password used to authenticate with Hopskotch.

default_hopskotch_topic: The Hopskotch topic to submit alerts to when none is provided.

Available templatetags

Though the TOM Toolkit provides a broker submission templatetag, tom_scimma provides an additional templatetag that includes a keyword argument for topic. To use it,

Add tom_scimma to your settings.INSTALLED_APPS:

    INSTALLED_APPS = [
        'django.contrib.admin',
        'django.contrib.auth',
        ...
        'tom_scimma'
    ]

Then, add scimma_extras to the {% load ... %} statement of your desired template:

    {% load bootstrap4 targets_extras ... scimma_extras %}

Finally, add your desired templatetag where you would like it in your template:

    {% submit_upstream_scimma_form target observation_record redirect_url topic_name %}

The signature and docstring of the submit_upstream_to_scimma button are as follows:

```
def submit_upstream_scimma_form(target=None, observation_record=None, redirect_url=None, topic=None):
    """
    Renders a button to submit an alert upstream to a broker. At least one of target/obs record should be given.

    :param broker: The name of the broker to which the button will lead, as in the name field of the broker module.
    :type broker: str

    :param target: The target to be submitted as an alert, if any.
    :type target: ``Target``

    :param observation_record: The observation record to be submitted as an alert, if any.
    :type observation_record: ``ObservationRecord``

    :param topic: The topic to submit the alerts to.
    :type topic: str

    :param redirect_url:
    :type redirect_url: str
    """
```

Running the tests

In order to run the tests, run the following in your virtualenv:

python tom_scimma/tests/run_tests.py

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tom-scimma-1.1.6.tar.gz (25.4 kB view details)

Uploaded Source

Built Distribution

tom_scimma-1.1.6-py3-none-any.whl (24.5 kB view details)

Uploaded Python 3

File details

Details for the file tom-scimma-1.1.6.tar.gz.

File metadata

  • Download URL: tom-scimma-1.1.6.tar.gz
  • Upload date:
  • Size: 25.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for tom-scimma-1.1.6.tar.gz
Algorithm Hash digest
SHA256 7362b9606c9b17d421b49cbc33a1fa05de328ed3614e9a1cf5fec9f0d81ce192
MD5 8e78d04f90a382ef504c6b199d7ab8f7
BLAKE2b-256 9f5b4280ac15db3aacb2259edfb8c0dc5035541db6752448eeded66debec3751

See more details on using hashes here.

File details

Details for the file tom_scimma-1.1.6-py3-none-any.whl.

File metadata

  • Download URL: tom_scimma-1.1.6-py3-none-any.whl
  • Upload date:
  • Size: 24.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for tom_scimma-1.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 9974b2e0cf02e82a8c4dc929dedfbc0cd79c6457d7cefc3f70fe4ba1a9b7063a
MD5 24e58328d244838bf595e24dea332a68
BLAKE2b-256 714c7f1caab0828ad62963c00650db0e94eb1363ce77297146500bdfeb0b1e51

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page