API reference — OpenTAXII 0.1.3 documentation

# API reference

This document is the API reference for OpenTAXII. It describes all classes, methods, functions, and attributes that are part of the public API.

Most of the terminology in the OpenTAXII API comes straight from the TAXII specification. See the TAXII documentation for more detailed explanations.

## Configuration

class `opentaxii.config.` `ServerConfig`(optional_env_var='OPENTAXII_CONFIG')

  Bases: `dict`

  Class responsible for loading configuration files.

  This class will load default configuration file (shipped with OpenTAXII) and apply user specified configuration file on top of default one.

  Users can specify custom configuration file (YAML formatted) using enviromental variable. The variable should contain a full path to a custom configuration file.

  Parameters: | optional_env_var (str) – name of the enviromental variable

## TAXII server layer

class `opentaxii.server.` `TAXIIServer`(config)

  Bases: `object`

  TAXII Server class.

  This class keeps Presistence API and Auth API managers instances and creates TAXII Service instances on request.

  Parameters: | persistence_manager (opentaxii.persistence.manager.PersistenceManager) – persistence manager instance auth_manager (opentaxii.auth.manager.AuthManager) – authentication manager instance

  `TYPE_TO_SERVICE` = {'poll': <class 'opentaxii.taxii.services.poll.PollService'>, 'collection_management': <class 'opentaxii.taxii.services.collection_management.CollectionManagementService'>, 'inbox': <class 'opentaxii.taxii.services.inbox.InboxService'>, 'discovery': <class 'opentaxii.taxii.services.discovery.DiscoveryService'>}
  `get_domain`(service_id)
  `is_basic_auth_supported`()
  `get_services`(service_ids=None)

    Get services registered with this TAXII server instance.

    Parameters: | service_ids (list) – list of service IDs (as strings)
    Returns: | list of services
    Return type: | list of `opentaxii.taxii.services.abstract.TAXIIService`

  `get_service`(id)

    Get service by ID.

    Parameters: | id (str) – service ID
    Returns: | service with specified ID or None
    Return type: | `opentaxii.taxii.services.abstract.TAXIIService`

  `get_services_for_collection`(collection, service_type)

    Get list of services with type `service_type`, attached to collection `collection`.

    Parameters: | collection (opentaxii.taxii.entities.CollectionEntity) – collection in question service_type (str) – service type, supported values are listed as keys in `TYPE_TO_SERVICE`
    Returns: | list of services
    Return type: | list of `opentaxii.taxii.services.abstract.TAXIIService`

class `opentaxii.entities.` `Account`(id, **details)

  Bases: `object`

  Represents Account entity.

  This class holds user-specific information and is used for authorization.

  Parameters: | id (str) – account id details (dict) – additional details of an account

## HTTP layer

`opentaxii.middleware.` `create_app`(server)

  Create Flask application and attach TAXII server instance `server` to it.

  Parameters: | server (opentaxii.server.TAXIIServer) – TAXII server instance
  Returns: | Flask app

## Version agnostic TAXII entities

class `opentaxii.taxii.entities.` `Entity`

  Bases: `object`

  Abstract TAXII entity class.

class `opentaxii.taxii.entities.` `ServiceEntity`(type, properties, id=None)

  Bases: `opentaxii.taxii.entities.Entity`

  TAXII Service entity.

  Parameters: | type (str) – service type, supported values are listed as keys in `opentaxii.server.TAXIIServer.TYPE_TO_SERVICE` properties (dict) – a dictionary with service-specific properties id (str) – service ID

class `opentaxii.taxii.entities.` `ContentBindingEntity`(binding, subtypes=None)

  Bases: `opentaxii.taxii.entities.Entity`

  TAXII Content Binding entity.

  Parameters: | binding (str) – content binding ID subtypes (list) – list of subtype ids

class `opentaxii.taxii.entities.` `CollectionEntity`(name, id=None, description=None, type='DATA_FEED', accept_all_content=False, supported_content=None, available=True)

  Bases: `opentaxii.taxii.entities.Entity`

  TAXII Collection entity.

  Parameters: | id (str) – collection id name (str) – collection name description (str) – description for the collection type (`TYPE_FEED` or `TYPE_SET`) – collection type accept_all_content (bool) – if collection accepts all content types supported_content (list) – list of the supported content bindings as a list of `ContentBindingEntity` instances available (bool) – if collection is available

  `TYPE_FEED` = 'DATA_FEED'
  `TYPE_SET` = 'DATA_SET'
  `is_content_supported`(content_binding)
  `get_matching_bindings`(requested_bindings)

class `opentaxii.taxii.entities.` `ContentBlockEntity`(content, timestamp_label, content_binding=None, id=None, message=None, inbox_message_id=None)

  Bases: `opentaxii.taxii.entities.Entity`

  TAXII Content Block entity.

  Parameters: | id (str) – content block ID content (str) – payload timestamp_label (datetime) – content block timestamp content_binding (ContentBindingEntity) – content binding message (str) – message attached to the content block inbox_message_id (str) – internal ID of the inbox message entity

class `opentaxii.taxii.entities.` `InboxMessageEntity`(message_id, original_message, content_block_count, service_id, id=None, result_id=None, destination_collections=None, record_count=None, partial_count=False, subscription_collection_name=None, subscription_id=None, exclusive_begin_timestamp_label=None, inclusive_end_timestamp_label=None)

  Bases: `opentaxii.taxii.entities.Entity`

  TAXII Inbox Message Entity

  Parameters: | message_id (str) – TAXII message ID original_message (str) – XML serialized original TAXII message content_block_count (int) – how many content blocks this message contains service_id (str) – ID of the Inbox Service that received the message id (str) – internal ID of the inbox message entity result_id (str) – ID of the Result Set part of which this message delivers destination_collections (list) – a list of destination collections, as a list of strings record_count (int) – how many items left in the Result Set this message is part of partial_count (bool) – if the record count is partial subscription_id (str) – ID of a subscription subscription_collection_name (str) – collection name of the subscription exclusive_begin_timestamp_label (datetime) – subscription’s exclusive begin timestamp label inclusive_begin_timestamp_label (datetime) – subscription’s inclusive begin timestamp label

class `opentaxii.taxii.entities.` `ResultSetEntity`(result_id, collection_id, content_bindings=None, timeframe=None)

  Bases: `opentaxii.taxii.entities.Entity`

  TAXII Result Set entity.

  Parameters: | result_id (str) – ID of a Result Set collection_id (str) – ID of a collection content_bindings (list) – list of `ContentBindingEntity` instances timeframe (tuple) – a timeframe of the Result Set in a form of `(begin, end)`

class `opentaxii.taxii.entities.` `SubscriptionParameters`(response_type='FULL', content_bindings=None)

  Bases: `opentaxii.taxii.entities.Entity`

  TAXII Subscription Parameters entity.

  Note: query formats specification is not supported

  Parameters: | response_type (str) – response type, supported values are `FULL` and `COUNT_ONLY` content_bindings (list) – list of `ContentBindingEntity` instances

  `FULL` = 'FULL'
  `COUNT_ONLY` = 'COUNT_ONLY'

class `opentaxii.taxii.entities.` `PollRequestParametersEntity`(response_type='FULL', content_bindings=None)

  Bases: `opentaxii.taxii.entities.SubscriptionParameters`

  TAXII Poll Request Parameters entity.

  Note: allow_asynch and delivery_parameters fields are not supported

  Parameters: | response_type (str) – response type, supported values are `FULL` and `COUNT_ONLY` content_bindings (list) – list of `ContentBindingEntity` instances

class `opentaxii.taxii.entities.` `SubscriptionEntity`(service_id, collection_id, subscription_id=None, status='ACTIVE', poll_request_params=None)

  Bases: `opentaxii.taxii.entities.Entity`

  TAXII Subscription entity.

  Parameters: | service_id (str) – ID of a service collection_id (str) – ID of a collection subscription_id (str) – ID of a subscription status (str) – subscription status, supported values are: `ACTIVE`, `PAUSED`, `UNSUBSCRIBED` poll_request_params (PollRequestParametersEntity) – Poll Request Parameters entity

  `ACTIVE` = 'ACTIVE'
  `PAUSED` = 'PAUSED'
  `UNSUBSCRIBED` = 'UNSUBSCRIBED'

## TAXII services

class `opentaxii.taxii.services.abstract.` `TAXIIService`(id, server, address, description=None, path=None, protocol_bindings=None, available=True, authentication_required=False)

  Bases: `object`

  Generic TAXII Service class.

  This class implements common methods for all TAXII services.

  Parameters: | id (str) – service ID address (str) – service address as absolute URL description (str) – service description protocol_bindings (list) – list of supported protocol bindings as a list of strings available (bool) – if the service is available authentication_required (bool) – if authentication required path (str) – relative path if service is configured in the server

  `supported_message_bindings` = ['urn:taxii.mitre.org:message:xml:1.0', 'urn:taxii.mitre.org:message:xml:1.1']
  `id` = None
  `server` = None
  `description` = 'Default TAXII service description'
  `supported_protocol_bindings` = ()
  `available` = True
  `authentication_required` = False
  `generate_id`()
  `process`(headers, message)
  `get_message_handler`(message)
  `to_service_instances`(version)
  `get_absolute_address`(binding)

class `opentaxii.taxii.services.discovery.` `DiscoveryService`(services=None, **kwargs)

  Bases: `opentaxii.taxii.services.abstract.TAXIIService`

  `service_type` = 'DISCOVERY'
  `handlers` = {'Discovery_Request': <class 'opentaxii.taxii.services.handlers.discovery_request_handlers.DiscoveryRequestHandler'>}
  `advertised_services` = []
  `set_advertised_services`(services)

class `opentaxii.taxii.services.inbox.` `InboxService`(accept_all_content=False, destination_collection_required=False, supported_content=None, **kwargs)

  Bases: `opentaxii.taxii.services.abstract.TAXIIService`

  `service_type` = 'INBOX'
  `handlers` = {'Inbox_Message': <class 'opentaxii.taxii.services.handlers.inbox_message_handlers.InboxMessageHandler'>}
  `accept_all_content` = False
  `supported_content` = []
  `destination_collection_required` = False
  `is_content_supported`(content_binding, version=None)
  `get_destination_collections`()
  `validate_destination_collection_names`(name_list, in_response_to)
  `to_service_instances`(version)
  `get_supported_content`(version)

class `opentaxii.taxii.services.poll.` `PollService`(subscription_required=False, max_result_size=-1, max_result_count=-1, **kwargs)

  Bases: `opentaxii.taxii.services.abstract.TAXIIService`

  `handlers` = {'Poll_Fulfillment': <class 'opentaxii.taxii.services.handlers.poll_fulfilment_request_handlers.PollFulfilmentRequestHandler'>, 'Poll_Request': <class 'opentaxii.taxii.services.handlers.poll_request_handlers.PollRequestHandler'>}
  `service_type` = 'POLL'
  `wait_time` = 300
  `can_push` = False
  `subscription_required` = False
  `max_result_size` = 9223372036854775807
  `max_result_count` = 9223372036854775807
  `get_collection`(name)
  `get_offset_limit`(part_number)
  `get_content_blocks_count`(collection, timeframe=None, content_bindings=None)
  `get_content_blocks`(collection, timeframe=None, content_bindings=None, part_number=1)
  `create_result_set`(collection, content_bindings=None, timeframe=(None, None))
  `get_result_set`(result_set_id)
  `get_subscription`(subscription_id)

class `opentaxii.taxii.services.collection_management.` `CollectionManagementService`(subscription_supported=True, subscription_message=None, **kwargs)

  Bases: `opentaxii.taxii.services.abstract.TAXIIService`

  `subscription_handlers` = {'Subscription_Management_Request': <class 'opentaxii.taxii.services.handlers.subscription_request_handlers.SubscriptionRequestHandler'>}
  `service_type` = 'COLLECTION_MANAGEMENT'
  `subscription_message` = 'Default subscription message'
  `subscription_supported` = True
  `handlers` = {'Collection_Information_Request': <class 'opentaxii.taxii.services.handlers.collection_information_request_handlers.CollectionInformationRequestHandler'>, 'Feed_Information_Request': <class 'opentaxii.taxii.services.handlers.collection_information_request_handlers.CollectionInformationRequestHandler'>}
  `advertised_collections`
  `get_collection`(name)
  `get_push_methods`(collection)
  `get_polling_services`(collection)
  `get_subscription_services`(collection)
  `create_subscription`(subscription)
  `get_subscription`(subscription_id)
  `get_subscriptions`()
  `update_subscription`(subscription)
  `get_receiving_inbox_services`(collection)
  `get_volume`(collection)