def get_collections(self, uri=None): """Get collections from Collection Management Service. if ``uri`` is not provided, client will try to discover services and find Collection Management Service among them. :param str uri: URI path to a specific Collection Management service :return: list of collections :rtype: list of :py:class:`cabby.entities.Collection` :raises ValueError: if URI provided is invalid or schema is not supported :raises `cabby.exceptions.HTTPError`: if HTTP error happened :raises `cabby.exceptions.UnsuccessfulStatusError`: if Status Message received and status_type is not `SUCCESS` :raises `cabby.exceptions.ServiceNotFoundError`: if no service found :raises `cabby.exceptions.AmbiguousServicesError`: more than one service with type specified :raises `cabby.exceptions.NoURIProvidedError`: no URI provided and client can't discover services """ request = tm11.CollectionInformationRequest( message_id=self._generate_id()) response = self._execute_request( request, uri=uri, service_type=const.SVC_COLLECTION_MANAGEMENT) return to_collection_entities(response.collection_informations, version=11)
def test_01(self): """ Send a collection information request, look to get a collection information response back """ cir = tm11.CollectionInformationRequest(generate_message_id()) msg = make_request(COLLECTION_MGMT_11_PATH, cir.to_xml(), get_headers(VID_TAXII_SERVICES_11, False), MSG_COLLECTION_INFORMATION_RESPONSE)
def perform_collection_information(path="/"): # Create discovery request msg_id=tm11.generate_message_id() req = tm11.CollectionInformationRequest(message_id=msg_id) # Convert to XML for request body req_xml = req.to_xml() # Create HTTP client client = tc.HttpClient() client.setProxy('noproxy') # Call TAXII service, using the body resp = client.callTaxiiService2(host, path, t.VID_TAXII_XML_11, req_xml, port) # Get response resp = t.get_message_from_http_response(resp, '0') print(resp.to_xml())
def create_request_message(self, args): return tm11.CollectionInformationRequest(message_id=tm11.generate_message_id())