Class: OpenC3::MicroserviceStatusModel

Inherits:
Model show all
Defined in:
lib/openc3/models/microservice_status_model.rb

Constant Summary collapse

PRIMARY_KEY =
'openc3_microservice_status'

Instance Attribute Summary collapse

Attributes inherited from Model

#name, #plugin, #scope, #updated_at

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Model

#check_disable_erb, #create, #deploy, #destroy, #destroyed?, filter, find_all_by_plugin, from_json, get_all_models, get_model, handle_config, set, store, store_queued, #undeploy, #update

Constructor Details

#initialize(name:, state: nil, count: 0, error: nil, custom: nil, updated_at: nil, plugin: nil, scope:) ⇒ MicroserviceStatusModel

Returns a new instance of MicroserviceStatusModel.



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/openc3/models/microservice_status_model.rb', line 48

def initialize(
  name:,
  state: nil,
  count: 0,
  error: nil,
  custom: nil,
  updated_at: nil,
  plugin: nil,
  scope:
)
  super("#{scope}__#{PRIMARY_KEY}", name: name, updated_at: updated_at, plugin: plugin, scope: scope)
  @state = state
  @count = count
  @error = error
  @custom = custom
end

Instance Attribute Details

#countObject

Returns the value of attribute count.



30
31
32
# File 'lib/openc3/models/microservice_status_model.rb', line 30

def count
  @count
end

#customObject

Returns the value of attribute custom.



32
33
34
# File 'lib/openc3/models/microservice_status_model.rb', line 32

def custom
  @custom
end

#errorObject

Returns the value of attribute error.



31
32
33
# File 'lib/openc3/models/microservice_status_model.rb', line 31

def error
  @error
end

#stateObject

Returns the value of attribute state.



29
30
31
# File 'lib/openc3/models/microservice_status_model.rb', line 29

def state
  @state
end

Class Method Details

.all(scope:) ⇒ Object



44
45
46
# File 'lib/openc3/models/microservice_status_model.rb', line 44

def self.all(scope:)
  super("#{scope}__#{PRIMARY_KEY}")
end

.get(name:, scope:) ⇒ Object

NOTE: The following three class methods are used by the ModelController and are reimplemented to enable various Model class methods to work



36
37
38
# File 'lib/openc3/models/microservice_status_model.rb', line 36

def self.get(name:, scope:)
  super("#{scope}__#{PRIMARY_KEY}", name: name)
end

.names(scope:) ⇒ Object



40
41
42
# File 'lib/openc3/models/microservice_status_model.rb', line 40

def self.names(scope:)
  super("#{scope}__#{PRIMARY_KEY}")
end

Instance Method Details

#as_json(*a) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
# File 'lib/openc3/models/microservice_status_model.rb', line 65

def as_json(*a)
  {
    'name' => @name,
    'state' => @state,
    'count' => @count,
    'error' => @error.as_json(:allow_nan => true),
    'custom' => @custom.as_json(:allow_nan => true),
    'plugin' => @plugin,
    'updated_at' => @updated_at
  }
end