Class: SDM::Healthcheck

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

Overview

Healthcheck defines the status of the link between a node and a resource

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(error_msg: nil, healthy: nil, id: nil, node_id: nil, node_name: nil, resource_id: nil, resource_name: nil, timestamp: nil) ⇒ Healthcheck

Returns a new instance of Healthcheck.



6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
# File 'lib/models/porcelain.rb', line 6505

def initialize(
  error_msg: nil,
  healthy: nil,
  id: nil,
  node_id: nil,
  node_name: nil,
  resource_id: nil,
  resource_name: nil,
  timestamp: nil
)
  @error_msg = error_msg == nil ? "" : error_msg
  @healthy = healthy == nil ? false : healthy
  @id = id == nil ? "" : id
  @node_id = node_id == nil ? "" : node_id
  @node_name = node_name == nil ? "" : node_name
  @resource_id = resource_id == nil ? "" : resource_id
  @resource_name = resource_name == nil ? "" : resource_name
  @timestamp = timestamp == nil ? nil : timestamp
end

Instance Attribute Details

#error_msgObject

The error if unhealthy



6489
6490
6491
# File 'lib/models/porcelain.rb', line 6489

def error_msg
  @error_msg
end

#healthyObject

Whether the healthcheck succeeded.



6491
6492
6493
# File 'lib/models/porcelain.rb', line 6491

def healthy
  @healthy
end

#idObject

Unique identifier of the healthcheck.



6493
6494
6495
# File 'lib/models/porcelain.rb', line 6493

def id
  @id
end

#node_idObject

Unique identifier of the healthcheck node.



6495
6496
6497
# File 'lib/models/porcelain.rb', line 6495

def node_id
  @node_id
end

#node_nameObject

The name of the node.



6497
6498
6499
# File 'lib/models/porcelain.rb', line 6497

def node_name
  @node_name
end

#resource_idObject

Unique identifier of the healthcheck resource.



6499
6500
6501
# File 'lib/models/porcelain.rb', line 6499

def resource_id
  @resource_id
end

#resource_nameObject

The name of the resource.



6501
6502
6503
# File 'lib/models/porcelain.rb', line 6501

def resource_name
  @resource_name
end

#timestampObject

The time at which the healthcheck state was recorded.



6503
6504
6505
# File 'lib/models/porcelain.rb', line 6503

def timestamp
  @timestamp
end

Instance Method Details

#to_json(options = {}) ⇒ Object



6525
6526
6527
6528
6529
6530
6531
# File 'lib/models/porcelain.rb', line 6525

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