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.



2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
# File 'lib/models/porcelain.rb', line 2473

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

#actor ⇒ Object

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.



2454
2455
2456
# File 'lib/models/porcelain.rb', line 2454

def actor
  @actor
end

#completed_at ⇒ Object

The time this activity took effect.



2456
2457
2458
# File 'lib/models/porcelain.rb', line 2456

def completed_at
  @completed_at
end

#description ⇒ Object

A humanized description of the activity.



2458
2459
2460
# File 'lib/models/porcelain.rb', line 2458

def description
  @description
end

#entities ⇒ Object

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.



2462
2463
2464
# File 'lib/models/porcelain.rb', line 2462

def entities
  @entities
end

#id ⇒ Object

Unique identifier of the Activity.



2464
2465
2466
# File 'lib/models/porcelain.rb', line 2464

def id
  @id
end

#ip_address ⇒ Object

The IP from which this action was taken.



2466
2467
2468
# File 'lib/models/porcelain.rb', line 2466

def ip_address
  @ip_address
end

#user_agent ⇒ Object

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



2469
2470
2471
# File 'lib/models/porcelain.rb', line 2469

def user_agent
  @user_agent
end

#verb ⇒ Object

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



2471
2472
2473
# File 'lib/models/porcelain.rb', line 2471

def verb
  @verb
end

Instance Method Details

#to_json(options = {}) ⇒ Object



2493
2494
2495
2496
2497
2498
2499
# File 'lib/models/porcelain.rb', line 2493

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