Class: Taxii::PollClient
- Inherits:
-
Object
show all
- Includes:
- Client
- Defined in:
- lib/taxii/poll_client.rb
Constant Summary
collapse
- PARSE_OPTIONS =
Nokogiri::XML::ParseOptions::DEFAULT_XML | Nokogiri::XML::ParseOptions::NOBLANKS
- CONTENT_XPATH =
'/taxii_11:Poll_Response/taxii_11:Content_Block/taxii_11:Content'
Instance Method Summary
collapse
Methods included from Client
#build_request, #collection_management_service_url, #discover_feeds, #discover_services, #discovery_service_url, #get_service_address, #inbox_service_url, included, #poll_service_url, #scheme_protocol
Instance Method Details
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/taxii/poll_client.rb', line 21
def format_request(request_message)
case request_message
when String
request_message
when Taxii::Messages::PollRequest
request_message.to_xml
else
fail ArgumentError, 'request message must be String or PollRequest'
end
end
|
#get(poll_request_message, url: self.poll_service_url) ⇒ Object
8
9
10
11
|
# File 'lib/taxii/poll_client.rb', line 8
def get( poll_request_message, url: self.poll_service_url)
msg = format_request(poll_request_message)
build_request(url: url, payload: msg).execute
end
|
#get_content_blocks(poll_request_message, url: self.poll_service_url, xpath: CONTENT_XPATH) ⇒ Object
13
14
15
16
17
18
19
|
# File 'lib/taxii/poll_client.rb', line 13
def get_content_blocks( poll_request_message,
url: self.poll_service_url,
xpath: CONTENT_XPATH )
response = self.get(poll_request_message, url: url)
content_xml = Nokogiri::XML(response.body,nil,nil,PARSE_OPTIONS)
content_xml.xpath(xpath).flat_map { |blk| blk.children.map(&:to_s) }
end
|