Class: Azure::ARM::Compute::Models::Usage

Inherits:
Object
  • Object
show all
Includes:
MsRestAzure
Defined in:
lib/azure_mgmt_compute/Models/usage.rb

Overview

Describes Compute Resource Usage.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#current_valueInteger



20
21
22
# File 'lib/azure_mgmt_compute/Models/usage.rb', line 20

def current_value
  @current_value
end

#limitInteger



23
24
25
# File 'lib/azure_mgmt_compute/Models/usage.rb', line 23

def limit
  @limit
end

#nameUsageName



26
27
28
# File 'lib/azure_mgmt_compute/Models/usage.rb', line 26

def name
  @name
end

#unitUsageUnit

measurement. Possible values for this property include: ‘Count’.



17
18
19
# File 'lib/azure_mgmt_compute/Models/usage.rb', line 17

def unit
  @unit
end

Class Method Details

.deserialize_object(object) ⇒ Usage

Deserializes given Ruby Hash into Model object.



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/azure_mgmt_compute/Models/usage.rb', line 67

def self.deserialize_object(object)
  return if object.nil?
  output_object = Usage.new

  deserialized_property = object['unit']
  if (!deserialized_property.nil? && !deserialized_property.empty?)
    enum_is_valid = UsageUnit.constants.any? { |e| UsageUnit.const_get(e).to_s.downcase == deserialized_property.downcase }
    fail MsRest::DeserializationError.new('Error occured while deserializing the enum', nil, nil, nil) unless enum_is_valid
  end
  output_object.unit = deserialized_property

  deserialized_property = object['currentValue']
  deserialized_property = Integer(deserialized_property) unless deserialized_property.to_s.empty?
  output_object.current_value = deserialized_property

  deserialized_property = object['limit']
  deserialized_property = Integer(deserialized_property) unless deserialized_property.to_s.empty?
  output_object.limit = deserialized_property

  deserialized_property = object['name']
  unless deserialized_property.nil?
    deserialized_property = UsageName.deserialize_object(deserialized_property)
  end
  output_object.name = deserialized_property

  output_object.validate

  output_object
end

.serialize_object(object) ⇒ Hash

Serializes given Model object into Ruby Hash.



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/azure_mgmt_compute/Models/usage.rb', line 40

def self.serialize_object(object)
  object.validate
  output_object = {}

  serialized_property = object.unit
  output_object['unit'] = serialized_property unless serialized_property.nil?

  serialized_property = object.current_value
  output_object['currentValue'] = serialized_property unless serialized_property.nil?

  serialized_property = object.limit
  output_object['limit'] = serialized_property unless serialized_property.nil?

  serialized_property = object.name
  unless serialized_property.nil?
    serialized_property = UsageName.serialize_object(serialized_property)
  end
  output_object['name'] = serialized_property unless serialized_property.nil?

  output_object
end

Instance Method Details

#validateObject

Validate the object. Throws ValidationError if validation fails.



31
32
33
# File 'lib/azure_mgmt_compute/Models/usage.rb', line 31

def validate
  @name.validate unless @name.nil?
end