Class: MISP::SharingGroup
Instance Attribute Summary collapse
- #active ⇒ Boolean readonly
- #created ⇒ String readonly
- #description ⇒ String readonly
- #id ⇒ String readonly
- #local ⇒ Boolean readonly
- #modified ⇒ String readonly
- #name ⇒ String readonly
- #org_id ⇒ String readonly
- #organisation_uuid ⇒ String readonly
- #organization ⇒ MISP::Org? readonly
- #releasability ⇒ String readonly
- #roaming ⇒ Boolean readonly
- #sharing_group_orgs ⇒ Array<MISP::SharingGroupOrg> readonly
- #sharing_group_servers ⇒ Array<MISP::SharingGroupServer> readonly
- #sync_user_id ⇒ String readonly
- #uuid ⇒ String readonly
Class Method Summary collapse
Instance Method Summary collapse
-
#create(**attributes) ⇒ MISP::SharingGroup
Create a sharing group.
-
#initialize(**attributes) ⇒ SharingGroup
constructor
A new instance of SharingGroup.
-
#list ⇒ Array<MISP::SharingGroup>
List sharing groups.
-
#to_h ⇒ Hash
Returns a hash representation of the attribute data.
Constructor Details
#initialize(**attributes) ⇒ SharingGroup
Returns a new instance of SharingGroup.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/misp/sharing_group.rb', line 40 def initialize(**attributes) attributes = normalize_attributes(attributes) @id = attributes.dig(:id) @name = attributes.dig(:name) || "default name" @releasability = attributes.dig(:releasability) || "default sharability" @description = attributes.dig(:description) @uuid = attributes.dig(:uuid) @organisation_uuid = attributes.dig(:organisation_uuid) @org_id = attributes.dig(:org_id) @sync_user_id = attributes.dig(:sync_user_id) @active = attributes.dig(:active) @created = attributes.dig(:created) @modified = attributes.dig(:modified) @local = attributes.dig(:local) @roaming = attributes.dig(:roaming) @organisation = build_attribute(item: attributes.dig(:Organization), klass: Org) @sharing_group_orgs = build_plural_attribute(items: attributes.dig(:SharingGroupOrg), klass: SharingGroupOrg) @sharing_group_servers = build_plural_attribute(items: attributes.dig(:SharingGroupServer), klass: SharingGroupServer) end |
Instance Attribute Details
#active ⇒ Boolean (readonly)
22 23 24 |
# File 'lib/misp/sharing_group.rb', line 22 def active @active end |
#created ⇒ String (readonly)
24 25 26 |
# File 'lib/misp/sharing_group.rb', line 24 def created @created end |
#description ⇒ String (readonly)
12 13 14 |
# File 'lib/misp/sharing_group.rb', line 12 def description @description end |
#id ⇒ String (readonly)
6 7 8 |
# File 'lib/misp/sharing_group.rb', line 6 def id @id end |
#local ⇒ Boolean (readonly)
28 29 30 |
# File 'lib/misp/sharing_group.rb', line 28 def local @local end |
#modified ⇒ String (readonly)
26 27 28 |
# File 'lib/misp/sharing_group.rb', line 26 def modified @modified end |
#name ⇒ String (readonly)
8 9 10 |
# File 'lib/misp/sharing_group.rb', line 8 def name @name end |
#org_id ⇒ String (readonly)
18 19 20 |
# File 'lib/misp/sharing_group.rb', line 18 def org_id @org_id end |
#organisation_uuid ⇒ String (readonly)
16 17 18 |
# File 'lib/misp/sharing_group.rb', line 16 def organisation_uuid @organisation_uuid end |
#organization ⇒ MISP::Org? (readonly)
33 34 35 |
# File 'lib/misp/sharing_group.rb', line 33 def organization @organization end |
#releasability ⇒ String (readonly)
10 11 12 |
# File 'lib/misp/sharing_group.rb', line 10 def releasability @releasability end |
#roaming ⇒ Boolean (readonly)
30 31 32 |
# File 'lib/misp/sharing_group.rb', line 30 def roaming @roaming end |
#sharing_group_orgs ⇒ Array<MISP::SharingGroupOrg> (readonly)
36 37 38 |
# File 'lib/misp/sharing_group.rb', line 36 def sharing_group_orgs @sharing_group_orgs end |
#sharing_group_servers ⇒ Array<MISP::SharingGroupServer> (readonly)
38 39 40 |
# File 'lib/misp/sharing_group.rb', line 38 def sharing_group_servers @sharing_group_servers end |
#sync_user_id ⇒ String (readonly)
20 21 22 |
# File 'lib/misp/sharing_group.rb', line 20 def sync_user_id @sync_user_id end |
#uuid ⇒ String (readonly)
14 15 16 |
# File 'lib/misp/sharing_group.rb', line 14 def uuid @uuid end |
Class Method Details
.create(**attributes) ⇒ Object
119 120 121 |
# File 'lib/misp/sharing_group.rb', line 119 def create(**attributes) new.create attributes end |
.list ⇒ Object
115 116 117 |
# File 'lib/misp/sharing_group.rb', line 115 def list new.list end |
Instance Method Details
#create(**attributes) ⇒ MISP::SharingGroup
Create a sharing group
110 111 112 |
# File 'lib/misp/sharing_group.rb', line 110 def create(**attributes) _post("/sharing_groups/add", wrap(attributes)) { |sharing_group| SharingGroup.new sharing_group } end |
#list ⇒ Array<MISP::SharingGroup>
List sharing groups
94 95 96 97 98 99 100 101 |
# File 'lib/misp/sharing_group.rb', line 94 def list _get("/sharing_groups/") do |res| sharing_groups = res.dig(:response) || [] sharing_groups.map do |sharing_group| SharingGroup.new sharing_group end end end |
#to_h ⇒ Hash
Returns a hash representation of the attribute data.
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/misp/sharing_group.rb', line 68 def to_h { id: id, name: name, releasability: releasability, description: description, uuid: uuid, organisation_uuid: organisation_uuid, org_id: org_id, sync_user_id: sync_user_id, active: active, created: created, modified: modified, local: local, roaming: roaming, Organisation: organisation.to_h, SharingGroupOrg: sharing_group_orgs.map(&:to_h), SharingGroupServer: sharing_group_servers.map(&:to_h) }.compact end |