Class: Azure::AG

Inherits:
Object
  • Object
show all
Defined in:
lib/azure/ag.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connection) ⇒ AG

Returns a new instance of AG.



64
65
66
# File 'lib/azure/ag.rb', line 64

def initialize(connection)
  @connection = connection
end

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



62
63
64
# File 'lib/azure/ag.rb', line 62

def description
  @description
end

#labelObject

Returns the value of attribute label.



62
63
64
# File 'lib/azure/ag.rb', line 62

def label
  @label
end

#locationObject

Returns the value of attribute location.



62
63
64
# File 'lib/azure/ag.rb', line 62

def location
  @location
end

#nameObject

Returns the value of attribute name.



62
63
64
# File 'lib/azure/ag.rb', line 62

def name
  @name
end

Instance Method Details

#create(params) ⇒ Object



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/azure/ag.rb', line 77

def create(params)
  builder = Nokogiri::XML::Builder.new(encoding: 'utf-8') do |xml|
    xml.CreateAffinityGroup(
      xmlns: 'http://schemas.microsoft.com/windowsazure'
    ) do
      xml.Name params[:azure_ag_name]
      xml.Label Base64.strict_encode64(params[:azure_ag_name])
      unless params[:azure_ag_desc].nil?
        xml.Description params[:azure_ag_desc]
      end
      xml.Location params[:azure_location]
    end
  end
  @connection.query_azure('affinitygroups',
                          'post',
                          builder.to_xml,
                          '',
                          false)
end

#parse(image) ⇒ Object



68
69
70
71
72
73
74
75
# File 'lib/azure/ag.rb', line 68

def parse(image)
  @name = image.at_css('Name').content
  @label = image.at_css('Label').content
  @description = image.at_css('Description').content if
    image.at_css('Description')
  @location = image.at_css('Location').content if image.at_css('Location')
  self
end