Class: Azure::AGs

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

Instance Method Summary collapse

Constructor Details

#initialize(connection) ⇒ AGs

Returns a new instance of AGs.



21
22
23
# File 'lib/azure/ag.rb', line 21

def initialize(connection)
  @connection = connection
end

Instance Method Details

#allObject



41
42
43
# File 'lib/azure/ag.rb', line 41

def all
  load.values
end

#create(params) ⇒ Object



53
54
55
56
# File 'lib/azure/ag.rb', line 53

def create(params)
  ag = AG.new(@connection)
  ag.create(params)
end

#exists?(name) ⇒ Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/azure/ag.rb', line 45

def exists?(name)
  load.key?(name)
end

#find(name) ⇒ Object



49
50
51
# File 'lib/azure/ag.rb', line 49

def find(name)
  load[name]
end

#loadObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/azure/ag.rb', line 25

def load
  @ags ||= begin
    @ags = {}
    response = @connection.query_azure('affinitygroups',
                                       'get',
                                       '',
                                       '',
                                       false)
    response.css('AffinityGroup').each do |ag|
      item = AG.new(@connection).parse(ag)
      @ags[item.name] = item
    end
    @ags
  end
end