Class: MistApi::Template

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

Overview

Template

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(name = nil, applies = SKIP, created_time = SKIP, deviceprofile_ids = SKIP, exceptions = SKIP, filter_by_deviceprofile = SKIP, id = SKIP, modified_time = SKIP, org_id = SKIP, additional_properties = nil) ⇒ Template

Returns a new instance of Template.



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/mist_api/models/template.rb', line 83

def initialize(name = nil, applies = SKIP, created_time = SKIP,
               deviceprofile_ids = SKIP, exceptions = SKIP,
               filter_by_deviceprofile = SKIP, id = SKIP,
               modified_time = SKIP, org_id = SKIP,
               additional_properties = nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @applies = applies unless applies == SKIP
  @created_time = created_time unless created_time == SKIP
  @deviceprofile_ids = deviceprofile_ids unless deviceprofile_ids == SKIP
  @exceptions = exceptions unless exceptions == SKIP
  @filter_by_deviceprofile = filter_by_deviceprofile unless filter_by_deviceprofile == SKIP
  @id = id unless id == SKIP
  @modified_time = modified_time unless modified_time == SKIP
  @name = name
  @org_id = org_id unless org_id == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#appliesTemplateApplies

Where this template should be applied to, can be org_id, site_ids, sitegroup_ids

Returns:



15
16
17
# File 'lib/mist_api/models/template.rb', line 15

def applies
  @applies
end

#created_timeFloat

When the object has been created, in epoch

Returns:

  • (Float)


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

def created_time
  @created_time
end

#deviceprofile_idsArray[UUID | String]

List of Device Profile ids

Returns:

  • (Array[UUID | String])


23
24
25
# File 'lib/mist_api/models/template.rb', line 23

def deviceprofile_ids
  @deviceprofile_ids
end

#exceptionsTemplateExceptions

Where this template should not be applied to (takes precedence)

Returns:



27
28
29
# File 'lib/mist_api/models/template.rb', line 27

def exceptions
  @exceptions
end

#filter_by_deviceprofileTrueClass | FalseClass

Whether to further filter by Device Profile

Returns:

  • (TrueClass | FalseClass)


31
32
33
# File 'lib/mist_api/models/template.rb', line 31

def filter_by_deviceprofile
  @filter_by_deviceprofile
end

#idUUID | String

Unique ID of the object instance in the Mist Organization

Returns:

  • (UUID | String)


35
36
37
# File 'lib/mist_api/models/template.rb', line 35

def id
  @id
end

#modified_timeFloat

When the object has been modified for the last time, in epoch

Returns:

  • (Float)


39
40
41
# File 'lib/mist_api/models/template.rb', line 39

def modified_time
  @modified_time
end

#nameString

When the object has been modified for the last time, in epoch

Returns:

  • (String)


43
44
45
# File 'lib/mist_api/models/template.rb', line 43

def name
  @name
end

#org_idUUID | String

When the object has been modified for the last time, in epoch

Returns:

  • (UUID | String)


47
48
49
# File 'lib/mist_api/models/template.rb', line 47

def org_id
  @org_id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/mist_api/models/template.rb', line 104

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  name = hash.key?('name') ? hash['name'] : nil
  applies = TemplateApplies.from_hash(hash['applies']) if hash['applies']
  created_time = hash.key?('created_time') ? hash['created_time'] : SKIP
  deviceprofile_ids =
    hash.key?('deviceprofile_ids') ? hash['deviceprofile_ids'] : SKIP
  exceptions = TemplateExceptions.from_hash(hash['exceptions']) if hash['exceptions']
  filter_by_deviceprofile =
    hash.key?('filter_by_deviceprofile') ? hash['filter_by_deviceprofile'] : SKIP
  id = hash.key?('id') ? hash['id'] : SKIP
  modified_time = hash.key?('modified_time') ? hash['modified_time'] : SKIP
  org_id = hash.key?('org_id') ? hash['org_id'] : SKIP

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  Template.new(name,
               applies,
               created_time,
               deviceprofile_ids,
               exceptions,
               filter_by_deviceprofile,
               id,
               modified_time,
               org_id,
               additional_properties)
end

.namesObject

A mapping from model property names to API property names.



50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/mist_api/models/template.rb', line 50

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['applies'] = 'applies'
  @_hash['created_time'] = 'created_time'
  @_hash['deviceprofile_ids'] = 'deviceprofile_ids'
  @_hash['exceptions'] = 'exceptions'
  @_hash['filter_by_deviceprofile'] = 'filter_by_deviceprofile'
  @_hash['id'] = 'id'
  @_hash['modified_time'] = 'modified_time'
  @_hash['name'] = 'name'
  @_hash['org_id'] = 'org_id'
  @_hash
end

.nullablesObject

An array for nullable fields



79
80
81
# File 'lib/mist_api/models/template.rb', line 79

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    applies
    created_time
    deviceprofile_ids
    exceptions
    filter_by_deviceprofile
    id
    modified_time
    org_id
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



150
151
152
153
154
155
156
157
# File 'lib/mist_api/models/template.rb', line 150

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} applies: #{@applies.inspect}, created_time: #{@created_time.inspect},"\
  " deviceprofile_ids: #{@deviceprofile_ids.inspect}, exceptions: #{@exceptions.inspect},"\
  " filter_by_deviceprofile: #{@filter_by_deviceprofile.inspect}, id: #{@id.inspect},"\
  " modified_time: #{@modified_time.inspect}, name: #{@name.inspect}, org_id:"\
  " #{@org_id.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



141
142
143
144
145
146
147
# File 'lib/mist_api/models/template.rb', line 141

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} applies: #{@applies}, created_time: #{@created_time}, deviceprofile_ids:"\
  " #{@deviceprofile_ids}, exceptions: #{@exceptions}, filter_by_deviceprofile:"\
  " #{@filter_by_deviceprofile}, id: #{@id}, modified_time: #{@modified_time}, name: #{@name},"\
  " org_id: #{@org_id}, additional_properties: #{@additional_properties}>"
end