Class: OTX::Pulses
Overview
Retrieve and parse into the appropriate object a pulse from the OTX System
Instance Method Summary collapse
-
#create(params) ⇒ Object
Create a Pulse.
-
#edit(id, params) ⇒ Object
Edit a Pulses information.
-
#get_indicator_types ⇒ Array<OTX::Indicator::IndicatorType>
GET list of Pulse Indicator Types.
-
#get_indicators(id, limit = 10, page = 1) ⇒ Array<OTX::Pulse>
GET a Pulses Indicators.
-
#get_pulse(id) ⇒ OTX::Pulse
Download an individually identified pulse and parse the output.
-
#get_related(id, limit = 10, page = 1) ⇒ Array<OTX::Pulse>
GET Pulses that share indicators with a Pulse.
-
#get_user_pulses(username, limit = 10, page = 1) ⇒ Array<OTX::Pulse>
GET Pulses from a user.
-
#search(query, limit = 10, page = 1, sort = :created) ⇒ Array<OTX::Pulse>
Search for Pulses including the query in their datafields.
-
#validate_indicator(indicator) ⇒ Object
Validate a Pulse indicator.
Methods inherited from Base
#get, #initialize, #patch, #post
Constructor Details
This class inherits a constructor from OTX::Base
Instance Method Details
#create(params) ⇒ Object
Create a Pulse
11 12 13 14 15 16 17 |
# File 'lib/otx_ruby/pulses.rb', line 11 def create(params) uri = '/api/v1/pulses/create' pulse = { body: params } post(uri, pulse) end |
#edit(id, params) ⇒ Object
Edit a Pulses information
82 83 84 85 86 |
# File 'lib/otx_ruby/pulses.rb', line 82 def edit(id, params) uri = "/api/v1/pulses/#{id}" patch(uri, params) end |
#get_indicator_types ⇒ Array<OTX::Indicator::IndicatorType>
GET list of Pulse Indicator Types
159 160 161 162 163 164 165 166 167 168 169 170 |
# 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_indicators(id, limit = 10, page = 1) ⇒ Array<OTX::Pulse>
GET a Pulses Indicators
140 141 142 143 144 145 146 147 148 149 150 151 152 |
# 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 |
#get_pulse(id) ⇒ OTX::Pulse
Download an individually identified pulse and parse the output
36 37 38 39 40 41 42 43 44 |
# 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_related(id, limit = 10, page = 1) ⇒ Array<OTX::Pulse>
GET Pulses that share indicators with a Pulse
118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/otx_ruby/pulses.rb', line 118 def (id, limit = 10, page = 1) uri = "/api/v1/pulses/#{id}/related" 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 |
#get_user_pulses(username, limit = 10, page = 1) ⇒ Array<OTX::Pulse>
GET Pulses from a user
96 97 98 99 100 101 102 103 104 105 106 107 108 |
# 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(query, limit = 10, page = 1, sort = :created) ⇒ Array<OTX::Pulse>
Search for Pulses including the query in their datafields
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# 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_indicator(indicator) ⇒ Object
Validate a Pulse indicator
24 25 26 27 28 |
# File 'lib/otx_ruby/pulses.rb', line 24 def validate_indicator(indicator) uri = '/api/v1/pulses/indicators/validate' post(uri, indicator) end |