Class: MistApi::AclPolicy

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/mist_api/models/acl_policy.rb

Overview

ACL Policy: - for GBP-based policy, all src_tags and dst_tags have to be gbp-based - for ACL-based policy, ‘network` is required in either the source or destination so that we know where to attach the policy to

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(actions = SKIP, name = SKIP, src_tags = SKIP) ⇒ AclPolicy

Returns a new instance of AclPolicy.



58
59
60
61
62
# File 'lib/mist_api/models/acl_policy.rb', line 58

def initialize(actions = SKIP, name = SKIP, src_tags = SKIP)
  @actions = actions unless actions == SKIP
  @name = name unless name == SKIP
  @src_tags = src_tags unless src_tags == SKIP
end

Instance Attribute Details

#actionsArray[AclPolicyAction]

ACL Policy Actions:

- for GBP-based policy, all src_tags and dst_tags have to be gbp-based
- for ACL-based policy, `network` is required in either the source or

destination so that we know where to attach the policy to

Returns:



19
20
21
# File 'lib/mist_api/models/acl_policy.rb', line 19

def actions
  @actions
end

#nameString

ACL Policy Actions:

- for GBP-based policy, all src_tags and dst_tags have to be gbp-based
- for ACL-based policy, `network` is required in either the source or

destination so that we know where to attach the policy to

Returns:

  • (String)


26
27
28
# File 'lib/mist_api/models/acl_policy.rb', line 26

def name
  @name
end

#src_tagsArray[String]

ACL Policy Source Tags:

- for GBP-based policy, all src_tags and dst_tags have to be gbp-based
- for ACL-based policy, `network` is required in either the source or

destination so that we know where to attach the policy to

Returns:

  • (Array[String])


33
34
35
# File 'lib/mist_api/models/acl_policy.rb', line 33

def src_tags
  @src_tags
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/mist_api/models/acl_policy.rb', line 65

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  # Parameter is an array, so we need to iterate through it
  actions = nil
  unless hash['actions'].nil?
    actions = []
    hash['actions'].each do |structure|
      actions << (AclPolicyAction.from_hash(structure) if structure)
    end
  end

  actions = SKIP unless hash.key?('actions')
  name = hash.key?('name') ? hash['name'] : SKIP
  src_tags = hash.key?('src_tags') ? hash['src_tags'] : SKIP

  # Create object from extracted values.
  AclPolicy.new(actions,
                name,
                src_tags)
end

.namesObject

A mapping from model property names to API property names.



36
37
38
39
40
41
42
# File 'lib/mist_api/models/acl_policy.rb', line 36

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['actions'] = 'actions'
  @_hash['name'] = 'name'
  @_hash['src_tags'] = 'src_tags'
  @_hash
end

.nullablesObject

An array for nullable fields



54
55
56
# File 'lib/mist_api/models/acl_policy.rb', line 54

def self.nullables
  []
end

.optionalsObject

An array for optional fields



45
46
47
48
49
50
51
# File 'lib/mist_api/models/acl_policy.rb', line 45

def self.optionals
  %w[
    actions
    name
    src_tags
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



95
96
97
98
99
# File 'lib/mist_api/models/acl_policy.rb', line 95

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} actions: #{@actions.inspect}, name: #{@name.inspect}, src_tags:"\
  " #{@src_tags.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



89
90
91
92
# File 'lib/mist_api/models/acl_policy.rb', line 89

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} actions: #{@actions}, name: #{@name}, src_tags: #{@src_tags}>"
end