lib/misp/feed.rb in misp-0.1.0 vs lib/misp/feed.rb in misp-0.1.1
- old
+ new
@@ -1,30 +1,52 @@
# frozen_string_literal: true
module MISP
class Feed < Base
+ # @return [String]
attr_reader :id
+ # @return [String]
attr_reader :name
+ # @return [String]
attr_reader :provider
+ # @return [String]
attr_reader :url
+ # @return [String]
attr_reader :rules
+ # @return [Boolean]
attr_reader :enabled
+ # @return [String]
attr_reader :distribution
+ # @return [String]
attr_reader :sharing_group_id
+ # @return [String]
attr_reader :tag_id
+ # @return [String]
attr_reader :default
+ # @return [String]
attr_reader :source_format
+ # @return [Boolean]
attr_reader :fixed_event
+ # @return [Boolean]
attr_reader :delta_merge
+ # @return [String]
attr_reader :event_id
+ # @return [String]
attr_reader :publish
+ # @return [String]
attr_reader :override_ids
+ # @return [String]
attr_reader :settings
+ # @return [String]
attr_reader :input_source
+ # @return [Boolean]
attr_reader :delete_local_file
+ # @return [Boolean]
attr_reader :lookup_visible
+ # @return [String]
attr_reader :headers
+ # @return [Boolean]
attr_reader :caching_enabled
def initialize(**attributes)
attributes = normalize_attributes(attributes)
@@ -50,10 +72,15 @@
@lookup_visible = attributes.dig(:lookup_visible) || true
@headers = attributes.dig(:headers) || ""
@caching_enabled = attributes.dig(:caching_enabled) || true
end
+ #
+ # Returns a hash representation of the attribute data.
+ #
+ # @return [Hash]
+ #
def to_h
{
id: id,
name: name,
provider: provider,
@@ -77,34 +104,53 @@
headers: headers,
caching_enabled: caching_enabled,
}.compact
end
+ #
+ # List feeds
+ #
+ # @return [Array<MISP::Feed>]
+ #
def list
_get("/feeds/index") do |feeds|
feeds.map do |feed|
- Feed.new symbolize_keys(feed)
+ Feed.new feed
end
end
end
- def self.list
- new.list
- end
-
+ #
+ # Create a feed
+ #
+ # @return [MISP::Feed]
+ #
def get
- _get("/feeds/view/#{id}") { |feed| Feed.new symbolize_keys(feed) }
+ _get("/feeds/view/#{id}") { |feed| Feed.new feed }
end
- def self.get(id)
- new(id: id).get
- end
-
+ #
+ # Create a feed
+ #
+ # @param [Hash] **attributes attributes
+ #
+ # @return [MIPS::Feed]
+ #
def create(**attributes)
- _post("/feeds/add", wrap(attributes)) { |feed| Feed.new symbolize_keys(feed) }
+ _post("/feeds/add", wrap(attributes)) { |feed| Feed.new feed }
end
- def self.create(attributes)
- new.create attributes
+ class << self
+ def list
+ new.list
+ end
+
+ def get(id)
+ new(id: id).get
+ end
+
+ def create(**attributes)
+ new.create attributes
+ end
end
end
end