taxii2client.v21 package¶
Module contents¶
Python TAXII 2.1 Client API
-
class
taxii2client.v21.
ApiRoot
(url, conn=None, user=None, password=None, verify=True, proxies=None, auth=None, cert=None)¶ Bases:
taxii2client.common._TAXIIEndpoint
Information about a TAXII API Root.
This class corresponds to the
Get API Root Information
(section 4.2) andGet Collections
(section 5.1) endpoints, and contains the information found in the correspondingAPI Root Resource
(section 4.2.1) andCollections Resource
(section 5.1.1).As obtained from a Server, each ApiRoot instance gets its own connection pool(s). Collections returned by instances of this class share the same pools as the instance, so closing one closes all. Also, the same username/password is used to connect to them, as was used for this ApiRoot. If either of these is undesirable, Collection instances may be created manually.
-
collections
¶
-
custom_properties
¶
-
description
¶
-
get_status
(status_id, accept='application/taxii+json;version=2.1')¶
-
max_content_length
¶
-
refresh
(accept='application/taxii+json;version=2.1')¶ Update the API Root’s information and list of Collections
-
refresh_collections
(accept='application/taxii+json;version=2.1')¶ Update the list of Collections contained by this API Root.
This invokes the
Get Collections
endpoint.
-
refresh_information
(accept='application/taxii+json;version=2.1')¶ Update the properties of this API Root.
This invokes the
Get API Root Information
endpoint.
-
title
¶
-
versions
¶
-
-
class
taxii2client.v21.
Collection
(url, conn=None, user=None, password=None, verify=True, proxies=None, collection_info=None, auth=None, cert=None)¶ Bases:
taxii2client.common._TAXIIEndpoint
Information about a TAXII Collection.
This class represents the
Get a Collection
endpoint (section 5.2), and contains the information returned in theCollection Resource
(section 5.2.1).- Methods on this class can be used to invoke the following endpoints:
Get Objects
(section 5.3)Add Objects
(section 5.4)Get an Object
(section 5.5)Get Object Manifests
(section 5.6)
As obtained from an ApiRoot, an instance of this class shares connection(s) with all other collections obtained from the same ApiRoot, as well as the ApiRoot instance itself. Closing one will close them all. If this is undesirable, you may manually create Collection instances.
-
add_objects
(envelope, wait_for_completion=True, poll_interval=1, timeout=60, accept='application/taxii+json;version=2.1', content_type='application/taxii+json;version=2.1')¶ Implement the
Add Objects
endpoint (section 5.4)Add objects to the collection. This may be performed either synchronously or asynchronously. To add asynchronously, set wait_for_completion to False. If False, the latter two args are unused. If the caller wishes to monitor the status of the addition, it may do so in its own way. To add synchronously, set wait_for_completion to True, and optionally set the poll and timeout intervals. After initiating the addition, the caller will block, and the TAXII “status” service will be polled until the timeout expires, or the operation completes.
Parameters: - envelope – A TAXII envelope with the objects to add (string, dict, binary)
- wait_for_completion (bool) – Whether to wait for the add operation to complete before returning
- poll_interval (int) – If waiting for completion, how often to poll the status service (seconds)
- timeout (int) – If waiting for completion, how long to poll until giving up (seconds). Use <= 0 to wait forever
- accept (str) – media type to include in the
Accept:
header. - content_type (str) – media type to include in the
Content-Type:
header.
Returns: If
wait_for_completion
is False, a Status object corresponding to the initial status data returned from the service, is returned. The status may not yet be complete at this point.If
wait_for_completion
is True, a Status object corresponding to the completed operation is returned if it didn’t time out; otherwise a Status object corresponding to the most recent data obtained before the timeout, is returned.
-
alias
¶
-
can_read
¶
-
can_write
¶
-
custom_properties
¶
-
delete_object
(obj_id, accept='application/taxii+json;version=2.1', **filter_kwargs)¶ Implement the
Delete an Object
endpoint (section 5.7)
-
description
¶
-
get_manifest
(accept='application/taxii+json;version=2.1', **filter_kwargs)¶ Implement the
Get Object Manifests
endpoint (section 5.6).
-
get_object
(obj_id, accept='application/taxii+json;version=2.1', **filter_kwargs)¶ Implement the
Get an Object
endpoint (section 5.5)
-
get_objects
(accept='application/taxii+json;version=2.1', **filter_kwargs)¶ Implement the
Get Objects
endpoint (section 5.3)
-
id
¶
-
media_types
¶
-
object_versions
(obj_id, accept='application/taxii+json;version=2.1', **filter_kwargs)¶ Implement the
Get Object Versions
endpoint (section 5.8)
-
objects_url
¶
-
refresh
(accept='application/taxii+json;version=2.1')¶ Update Collection information
-
title
¶
-
class
taxii2client.v21.
Server
(url, conn=None, user=None, password=None, verify=True, proxies=None, auth=None, cert=None)¶ Bases:
taxii2client.common._TAXIIEndpoint
Information about a server hosting a Discovery service.
This class corresponds to the Server Discovery endpoint (section 4.1) and the Discovery Resource returned from that endpoint (section 4.1.1).
ApiRoot instances obtained from an instance of this class are created with the same username/password as was used in this instance. If that’s incorrect, an ApiRoot instance may be created directly with the desired username and password. Also, they use separate connection pools so that they can be independent: closing one won’t close others, and closing this server object won’t close any of the ApiRoot objects (which may refer to different hosts than was used for discovery).
-
api_roots
¶
-
contact
¶
-
custom_properties
¶
-
default
¶
-
description
¶
-
refresh
()¶ Update the Server information and list of API Roots
-
title
¶
-
-
class
taxii2client.v21.
Status
(url, conn=None, user=None, password=None, verify=True, proxies=None, status_info=None, auth=None, cert=None)¶ Bases:
taxii2client.common._TAXIIEndpoint
TAXII Status Resource.
This class represents the
Get Status
endpoint (section 4.3) and also contains the information about the Status Resource (section 4.3.1)-
custom_properties
¶
-
refresh
(accept='application/taxii+json;version=2.1')¶ Updates Status information
-
wait_until_final
(poll_interval=1, timeout=60)¶ It will poll the URL to grab the latest status resource in a given timeout and time interval.
Parameters: - poll_interval (int) – how often to poll the status service.
- timeout (int) – how long to poll the URL until giving up. Use <= 0 to wait forever
-
-
taxii2client.v21.
as_pages
(func, per_request=0, *args, **kwargs)¶ Creates a generator for TAXII 2.1 endpoints that support pagination.
Parameters: - func (callable) – A v21 function that supports paged requests. Currently Get Objects and Get Manifest.
- per_request (int) – How many items per request. Default 0.
Use args or kwargs to pass filter information or other arguments required to make the call.