class OTX::Pulses
Retrieve and parse into the appropriate object a pulse from the OTX
System
Public Instance Methods
GET list of Pulse
Indicator
Types
@return [Array<OTX::Indicator::IndicatorType>]
# File lib/otx_ruby/pulses.rb, line 159 def get_indicator_types uri = '/api/v1/pulses/indicators/types' types = [] json_data = get(uri) json_data['detail'].each do |type| types << OTX::Indicator::IndicatorType.new(type) end return types end
GET a Pulses
Indicators
@param id [String] ID of the Pulse
to retrieve Indicators
from @param limit [Integer] Limit results per page to this number @param page [Integer] Return results for this page @return [Array<OTX::Pulse>] Parsed Indicators
# File lib/otx_ruby/pulses.rb, line 140 def get_indicators(id, limit = 10, page = 1) uri = "/api/v1/pulses/#{id}/indicators" params = { limit: limit, page: page } results = [] json_data = get(uri, params) json_data['results'].each do |indicator| results << OTX::Indicators.new(indicator) end return results end
Download an individually identified pulse and parse the output
@param id [String] The id value for the pulse to Download @return [OTX::Pulse] Parsed Pulse
# File lib/otx_ruby/pulses.rb, line 36 def get_pulse(id) uri = "/api/v1/pulses/#{id}" json_data = get(uri) pulse = OTX::Pulse.new(json_data) return pulse end
GET Pulses
from a user
@param username [String] Name of the User
to retrieve pulses from @param limit [Integer] Limit results per page to this number @param page [Integer] Return results for this page @return [Array<OTX::Pulse>] Parsed Pulses
# File lib/otx_ruby/pulses.rb, line 96 def get_user_pulses(username, limit = 10, page = 1) uri = "/api/v1/pulses/user/#{username}" params = { limit: limit, page: page } results = [] json_data = get(uri, params) json_data['results'].each do |pulse| results << OTX::Pulse.new(pulse) end return results end
Search for Pulses
including the query in their datafields
@param query [String] Query to search @param limit [Integer] Limit results per page to this number @param page [Integer] Return results for this page @param sort [Symbol] Sort results by modified, created or subscriber_count @return [Array<OTX::Pulse>] Parsed Pulses
# File lib/otx_ruby/pulses.rb, line 55 def search(query, limit = 10, page = 1, sort = :created) uri = '/api/v1/search/users' if sort == :modified || sort == :subscriber_count sort_by = sort.to_s else sort_by = 'created' end params = { q: query, limit: limit, page: page, sort: sort_by } results = [] json_data = get(uri, params) json_data['results'].each do |pulse| results << OTX::Pulse.new(pulse) end return results end
Validate a Pulse
indicator
@param indicator [Hash] An indicator key value pair
# File lib/otx_ruby/pulses.rb, line 24 def validate_indicator(indicator) uri = '/api/v1/pulses/indicators/validate' post(uri, indicator) end