Class: SDM::Activity

Inherits:
Object
  • Object
show all
Defined in:
lib/models/porcelain.rb

Overview

An Activity is a record of an action taken against a strongDM deployment, e.g. a user creation, resource deletion, sso configuration change, etc.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(actor: nil, completed_at: nil, description: nil, entities: nil, id: nil, ip_address: nil, user_agent: nil, verb: nil) ⇒ Activity

Returns a new instance of Activity.



2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
# File 'lib/models/porcelain.rb', line 2204

def initialize(
  actor: nil,
  completed_at: nil,
  description: nil,
  entities: nil,
  id: nil,
  ip_address: nil,
  user_agent: nil,
  verb: nil
)
  @actor = actor == nil ? nil : actor
  @completed_at = completed_at == nil ? nil : completed_at
  @description = description == nil ? "" : description
  @entities = entities == nil ? [] : entities
  @id = id == nil ? "" : id
  @ip_address = ip_address == nil ? "" : ip_address
  @user_agent = user_agent == nil ? "" : user_agent
  @verb = verb == nil ? "" : verb
end

Instance Attribute Details

#actorObject

The account who executed this activity. If the actor later has a name or email change, that change is not reflected here. Actor is a snapshot of the executing account at the time an activity took place.



2185
2186
2187
# File 'lib/models/porcelain.rb', line 2185

def actor
  @actor
end

#completed_atObject

The time this activity took effect.



2187
2188
2189
# File 'lib/models/porcelain.rb', line 2187

def completed_at
  @completed_at
end

#descriptionObject

A humanized description of the activity.



2189
2190
2191
# File 'lib/models/porcelain.rb', line 2189

def description
  @description
end

#entitiesObject

The entities involved in this activity. These entities can be any first class entity in the strongDM system, eg. a user, a role, a node, an account grant. Not every activity affects explicit entities.



2193
2194
2195
# File 'lib/models/porcelain.rb', line 2193

def entities
  @entities
end

#idObject

Unique identifier of the Activity.



2195
2196
2197
# File 'lib/models/porcelain.rb', line 2195

def id
  @id
end

#ip_addressObject

The IP from which this action was taken.



2197
2198
2199
# File 'lib/models/porcelain.rb', line 2197

def ip_address
  @ip_address
end

#user_agentObject

The User Agent present when this request was executed. Generally a client type and version like strongdm-cli/55.66.77



2200
2201
2202
# File 'lib/models/porcelain.rb', line 2200

def user_agent
  @user_agent
end

#verbObject

The kind of activity which has taken place, one of the ActivityVerb constants.



2202
2203
2204
# File 'lib/models/porcelain.rb', line 2202

def verb
  @verb
end

Instance Method Details

#to_json(options = {}) ⇒ Object



2224
2225
2226
2227
2228
2229
2230
# File 'lib/models/porcelain.rb', line 2224

def to_json(options = {})
  hash = {}
  self.instance_variables.each do |var|
    hash[var.id2name.delete_prefix("@")] = self.instance_variable_get var
  end
  hash.to_json
end