Class: MsRestAzure::Resource
- Inherits:
-
Object
- Object
- MsRestAzure::Resource
- Defined in:
- lib/ms_rest_azure/resource.rb
Overview
Class which represents any Azure resource.
Instance Attribute Summary collapse
-
#id ⇒ String
The id of the resource.
-
#location ⇒ String
The location of the resource (required).
-
#name ⇒ String
The name of the resource.
-
#tags ⇒ Hash{String => String}
The tags attached to resources (optional).
-
#type ⇒ String
The type of the resource.
Class Method Summary collapse
-
.deserialize_object(object) ⇒ Resource
Deserializes given hash object into resource.
-
.serialize_object(object) ⇒ Hash
Serializes given resource object into hash.
Instance Method Summary collapse
-
#validate ⇒ Object
Validates the resource.
Instance Attribute Details
#id ⇒ String
Returns the id of the resource.
12 13 14 |
# File 'lib/ms_rest_azure/resource.rb', line 12 def id @id end |
#location ⇒ String
Returns the location of the resource (required).
21 22 23 |
# File 'lib/ms_rest_azure/resource.rb', line 21 def location @location end |
#name ⇒ String
Returns the name of the resource.
15 16 17 |
# File 'lib/ms_rest_azure/resource.rb', line 15 def name @name end |
#tags ⇒ Hash{String => String}
Returns the tags attached to resources (optional).
24 25 26 |
# File 'lib/ms_rest_azure/resource.rb', line 24 def @tags end |
#type ⇒ String
Returns the type of the resource.
18 19 20 |
# File 'lib/ms_rest_azure/resource.rb', line 18 def type @type end |
Class Method Details
.deserialize_object(object) ⇒ Resource
Deserializes given hash object into resource.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/ms_rest_azure/resource.rb', line 58 def self.deserialize_object(object) return if object.nil? output_object = Resource.new deserialized_property = object['id'] output_object.id = deserialized_property deserialized_property = object['name'] output_object.name = deserialized_property deserialized_property = object['type'] output_object.type = deserialized_property deserialized_property = object['location'] output_object.location = deserialized_property deserialized_property = object['tags'] output_object. = deserialized_property output_object.validate output_object end |
.serialize_object(object) ⇒ Hash
Serializes given resource object into hash.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/ms_rest_azure/resource.rb', line 31 def self.serialize_object(object) object.validate output_object = {} serialized_property = object.id output_object['id'] = serialized_property unless serialized_property.nil? serialized_property = object.name output_object['name'] = serialized_property unless serialized_property.nil? serialized_property = object.type output_object['type'] = serialized_property unless serialized_property.nil? serialized_property = object.location output_object['location'] = serialized_property unless serialized_property.nil? serialized_property = object. output_object['tags'] = serialized_property unless serialized_property.nil? output_object end |
Instance Method Details
#validate ⇒ Object
Validates the resource. Throws error if there is any property is incorrect.
84 85 86 |
# File 'lib/ms_rest_azure/resource.rb', line 84 def validate fail MsRest::ValidationError, 'Location cannot be nil in the Resource object' if @location.nil? end |