Class: MistApi::License

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

Overview

License

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(amendments = SKIP, entitled = SKIP, fully_loaded = SKIP, licenses = SKIP, summary = SKIP, usages = SKIP) ⇒ License

Returns a new instance of License.



72
73
74
75
76
77
78
79
80
# File 'lib/mist_api/models/license.rb', line 72

def initialize(amendments = SKIP, entitled = SKIP, fully_loaded = SKIP,
               licenses = SKIP, summary = SKIP, usages = SKIP)
  @amendments = amendments unless amendments == SKIP
  @entitled = entitled unless entitled == SKIP
  @fully_loaded = fully_loaded unless fully_loaded == SKIP
  @licenses = licenses unless licenses == SKIP
  @summary = summary unless summary == SKIP
  @usages = usages unless usages == SKIP
end

Instance Attribute Details

#amendmentsArray[LicenseAmendment]

TODO: Write general description for this method

Returns:



14
15
16
# File 'lib/mist_api/models/license.rb', line 14

def amendments
  @amendments
end

#entitledHash[String, Integer]

Property key is license type (e.g. SUB-MAN) and Property value is the number of licenses entitled.

Returns:

  • (Hash[String, Integer])


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

def entitled
  @entitled
end

#fully_loadedHash[String, Integer]

Maximum number of licenses that may be required if the service is enabled on all the Organization Devices. Property key is the service name (e.g. “SUB-MAN”).

Returns:

  • (Hash[String, Integer])


25
26
27
# File 'lib/mist_api/models/license.rb', line 25

def fully_loaded
  @fully_loaded
end

#licensesArray[LicenseSub]

Maximum number of licenses that may be required if the service is enabled on all the Organization Devices. Property key is the service name (e.g. “SUB-MAN”).

Returns:



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

def licenses
  @licenses
end

#summaryHash[String, Integer]

Number of licenses currently consumed. Property key is license type (e.g. SUB-MAN).

Returns:

  • (Hash[String, Integer])


36
37
38
# File 'lib/mist_api/models/license.rb', line 36

def summary
  @summary
end

#usagesHash[String, Integer]

Number of available licenes. Property key is the service name (e.g. “SUB-MAN”). name (e.g. “SUB-MAN”)

Returns:

  • (Hash[String, Integer])


41
42
43
# File 'lib/mist_api/models/license.rb', line 41

def usages
  @usages
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/mist_api/models/license.rb', line 83

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
  amendments = nil
  unless hash['amendments'].nil?
    amendments = []
    hash['amendments'].each do |structure|
      amendments << (LicenseAmendment.from_hash(structure) if structure)
    end
  end

  amendments = SKIP unless hash.key?('amendments')
  entitled = hash.key?('entitled') ? hash['entitled'] : SKIP
  fully_loaded = hash.key?('fully_loaded') ? hash['fully_loaded'] : SKIP
  # Parameter is an array, so we need to iterate through it
  licenses = nil
  unless hash['licenses'].nil?
    licenses = []
    hash['licenses'].each do |structure|
      licenses << (LicenseSub.from_hash(structure) if structure)
    end
  end

  licenses = SKIP unless hash.key?('licenses')
  summary = hash.key?('summary') ? hash['summary'] : SKIP
  usages = hash.key?('usages') ? hash['usages'] : SKIP

  # Create object from extracted values.
  License.new(amendments,
              entitled,
              fully_loaded,
              licenses,
              summary,
              usages)
end

.namesObject

A mapping from model property names to API property names.



44
45
46
47
48
49
50
51
52
53
# File 'lib/mist_api/models/license.rb', line 44

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['amendments'] = 'amendments'
  @_hash['entitled'] = 'entitled'
  @_hash['fully_loaded'] = 'fully_loaded'
  @_hash['licenses'] = 'licenses'
  @_hash['summary'] = 'summary'
  @_hash['usages'] = 'usages'
  @_hash
end

.nullablesObject

An array for nullable fields



68
69
70
# File 'lib/mist_api/models/license.rb', line 68

def self.nullables
  []
end

.optionalsObject

An array for optional fields



56
57
58
59
60
61
62
63
64
65
# File 'lib/mist_api/models/license.rb', line 56

def self.optionals
  %w[
    amendments
    entitled
    fully_loaded
    licenses
    summary
    usages
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



129
130
131
132
133
134
# File 'lib/mist_api/models/license.rb', line 129

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} amendments: #{@amendments.inspect}, entitled: #{@entitled.inspect},"\
  " fully_loaded: #{@fully_loaded.inspect}, licenses: #{@licenses.inspect}, summary:"\
  " #{@summary.inspect}, usages: #{@usages.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



122
123
124
125
126
# File 'lib/mist_api/models/license.rb', line 122

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} amendments: #{@amendments}, entitled: #{@entitled}, fully_loaded:"\
  " #{@fully_loaded}, licenses: #{@licenses}, summary: #{@summary}, usages: #{@usages}>"
end