Module: Azure::BaseManagement::Serialization
- Defined in:
- lib/azure/base_management/serialization.rb
Class Method Summary collapse
- .affinity_group_from_xml(affinity_xml) ⇒ Object
- .affinity_group_to_xml(name, location, label, options = {}) ⇒ Object
- .affinity_groups_from_xml(affinity_xml) ⇒ Object
- .locations_from_xml(locationXML) ⇒ Object
- .resource_to_xml(label, options = {}) ⇒ Object
Class Method Details
.affinity_group_from_xml(affinity_xml) ⇒ Object
66 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 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/azure/base_management/serialization.rb', line 66 def self.affinity_group_from_xml(affinity_xml) hosted_services_xml = affinity_xml.css( 'AffinityGroup HostedServices HostedService' ) storage_services_xml = affinity_xml.css( 'AffinityGroup StorageServices StorageService' ) capability_xml = affinity_xml.css( 'AffinityGroup Capabilities Capability' ) AffinityGroup.new do |affinity_group| affinity_group.name = xml_content( affinity_xml, 'AffinityGroup Name' ) affinity_group.label = Base64.decode64( xml_content( affinity_xml, 'AffinityGroup Label' ) ) affinity_group.description = xml_content( affinity_xml, 'AffinityGroup Description' ) affinity_group.location = xml_content( affinity_xml, 'AffinityGroup Location' ) affinity_group.hosted_services = [] hosted_services_xml.each do |hosted_service_xml| affinity_group.hosted_services << { url: xml_content(hosted_service_xml, 'Url'), service_name: xml_content(hosted_service_xml, 'ServiceName') } end affinity_group.storage_services = [] storage_services_xml.each do |storage_service_xml| affinity_group.storage_services << { url: xml_content(storage_service_xml, 'Url'), service_name: xml_content(storage_service_xml, 'ServiceName') } end affinity_group.capability = capability_xml.map { |x| x.content } end end |
.affinity_group_to_xml(name, location, label, options = {}) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/azure/base_management/serialization.rb', line 32 def self.affinity_group_to_xml(name, location, label, = {}) builder = Nokogiri::XML::Builder.new do |xml| xml.CreateAffinityGroup( 'xmlns' => 'http://schemas.microsoft.com/windowsazure' ) do xml.Name name xml.Label Base64.encode64(label).strip xml.Description [:description] xml.Location location end end builder.doc.to_xml end |
.affinity_groups_from_xml(affinity_xml) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/azure/base_management/serialization.rb', line 46 def self.affinity_groups_from_xml(affinity_xml) affinity_groups = [] affinity_group_services_xml = affinity_xml.css( 'AffinityGroups AffinityGroup' ) affinity_group_services_xml.each do |ag_xml| affinity_group = AffinityGroup.new affinity_group.name = xml_content(ag_xml, 'Name') affinity_group.label = Base64.decode64(xml_content(ag_xml, 'Label')) affinity_group.description = xml_content(ag_xml, 'Description') affinity_group.location = xml_content(ag_xml, 'Location') capabilities = ag_xml.css('Capabilities Capability') affinity_group.capability = capabilities.map { |x| x.content } affinity_groups << affinity_group end affinity_groups.compact end |
.locations_from_xml(locationXML) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/azure/base_management/serialization.rb', line 19 def self.locations_from_xml(locationXML) location_objs = [] xml = locationXML.css('Locations Location') xml.each do || loc = Location.new loc.name = xml_content(, 'Name') available_services = .css('AvailableServices').children loc.available_services = available_services.to_ary.join(', ') location_objs << loc end location_objs end |
.resource_to_xml(label, options = {}) ⇒ Object
116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/azure/base_management/serialization.rb', line 116 def self.resource_to_xml(label, = {}) builder = Nokogiri::XML::Builder.new do |xml| xml.UpdateAffinityGroup( 'xmlns' => 'http://schemas.microsoft.com/windowsazure' ) do xml.Label Base64.encode64(label).strip xml.Description [:description] if [:description] end end builder.doc.to_xml end |