Class: MistApi::ProtectRe
- Defined in:
- lib/mist_api/models/protect_re.rb
Overview
Restrict inbound-traffic to host when enabled, all traffic that is not essential to our operation will be dropped e.g. ntp / dns / traffic to mist will be allowed by default, if dhcpd is enabled, we’ll make sure it works
Instance Attribute Summary collapse
-
#allowed_services ⇒ Array[ProtectReAllowedServiceEnum]
Optionally, services we’ll allow.
-
#custom ⇒ Array[ProtectReCustom]
Optionally, services we’ll allow.
-
#enabled ⇒ TrueClass | FalseClass
When enabled, all traffic that is not essential to our operation will be dropped e.g.
-
#hit_count ⇒ TrueClass | FalseClass
Whether to enable hit count for Protect_RE policy.
-
#trusted_hosts ⇒ Array[String]
host/subnets we’ll allow traffic to/from.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
-
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
Instance Method Summary collapse
-
#initialize(allowed_services = SKIP, custom = SKIP, enabled = false, hit_count = false, trusted_hosts = SKIP) ⇒ ProtectRe
constructor
A new instance of ProtectRe.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(allowed_services = SKIP, custom = SKIP, enabled = false, hit_count = false, trusted_hosts = SKIP) ⇒ ProtectRe
Returns a new instance of ProtectRe.
64 65 66 67 68 69 70 71 |
# File 'lib/mist_api/models/protect_re.rb', line 64 def initialize(allowed_services = SKIP, custom = SKIP, enabled = false, hit_count = false, trusted_hosts = SKIP) @allowed_services = allowed_services unless allowed_services == SKIP @custom = custom unless custom == SKIP @enabled = enabled unless enabled == SKIP @hit_count = hit_count unless hit_count == SKIP @trusted_hosts = trusted_hosts unless trusted_hosts == SKIP end |
Instance Attribute Details
#allowed_services ⇒ Array[ProtectReAllowedServiceEnum]
Optionally, services we’ll allow
16 17 18 |
# File 'lib/mist_api/models/protect_re.rb', line 16 def allowed_services @allowed_services end |
#custom ⇒ Array[ProtectReCustom]
Optionally, services we’ll allow
20 21 22 |
# File 'lib/mist_api/models/protect_re.rb', line 20 def custom @custom end |
#enabled ⇒ TrueClass | FalseClass
When enabled, all traffic that is not essential to our operation will be dropped e.g. ntp / dns / traffic to mist will be allowed by default
if dhcpd is enabled, we'll make sure it works
27 28 29 |
# File 'lib/mist_api/models/protect_re.rb', line 27 def enabled @enabled end |
#hit_count ⇒ TrueClass | FalseClass
Whether to enable hit count for Protect_RE policy
31 32 33 |
# File 'lib/mist_api/models/protect_re.rb', line 31 def hit_count @hit_count end |
#trusted_hosts ⇒ Array[String]
host/subnets we’ll allow traffic to/from
35 36 37 |
# File 'lib/mist_api/models/protect_re.rb', line 35 def trusted_hosts @trusted_hosts end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/mist_api/models/protect_re.rb', line 74 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. allowed_services = hash.key?('allowed_services') ? hash['allowed_services'] : SKIP # Parameter is an array, so we need to iterate through it custom = nil unless hash['custom'].nil? custom = [] hash['custom'].each do |structure| custom << (ProtectReCustom.from_hash(structure) if structure) end end custom = SKIP unless hash.key?('custom') enabled = hash['enabled'] ||= false hit_count = hash['hit_count'] ||= false trusted_hosts = hash.key?('trusted_hosts') ? hash['trusted_hosts'] : SKIP # Create object from extracted values. ProtectRe.new(allowed_services, custom, enabled, hit_count, trusted_hosts) end |
.names ⇒ Object
A mapping from model property names to API property names.
38 39 40 41 42 43 44 45 46 |
# File 'lib/mist_api/models/protect_re.rb', line 38 def self.names @_hash = {} if @_hash.nil? @_hash['allowed_services'] = 'allowed_services' @_hash['custom'] = 'custom' @_hash['enabled'] = 'enabled' @_hash['hit_count'] = 'hit_count' @_hash['trusted_hosts'] = 'trusted_hosts' @_hash end |
.nullables ⇒ Object
An array for nullable fields
60 61 62 |
# File 'lib/mist_api/models/protect_re.rb', line 60 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
49 50 51 52 53 54 55 56 57 |
# File 'lib/mist_api/models/protect_re.rb', line 49 def self.optionals %w[ allowed_services custom enabled hit_count trusted_hosts ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
104 105 106 107 108 109 110 |
# File 'lib/mist_api/models/protect_re.rb', line 104 def self.validate(value) return true if value.instance_of? self return false unless value.instance_of? Hash true end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
120 121 122 123 124 125 |
# File 'lib/mist_api/models/protect_re.rb', line 120 def inspect class_name = self.class.name.split('::').last "<#{class_name} allowed_services: #{@allowed_services.inspect}, custom: #{@custom.inspect},"\ " enabled: #{@enabled.inspect}, hit_count: #{@hit_count.inspect}, trusted_hosts:"\ " #{@trusted_hosts.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
113 114 115 116 117 |
# File 'lib/mist_api/models/protect_re.rb', line 113 def to_s class_name = self.class.name.split('::').last "<#{class_name} allowed_services: #{@allowed_services}, custom: #{@custom}, enabled:"\ " #{@enabled}, hit_count: #{@hit_count}, trusted_hosts: #{@trusted_hosts}>" end |