Class: AzureResourceTypeCounts

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

Overview

Class object to maintain a count of the Azure Resource types that are found when a less specific test is carried out. For example if all the resoures of a resource group are called for, there will be variaous types and number of those types.

Each type is namespaced, so for example a virtual machine has the type ‘Microsoft.Compute/virtualMachines’ This is broken down into the ‘Microsoft’ class with the type ‘Compute/virtualMachines’ This has been done for two reasons:

1. Enable the dotted notation to work in the test
2. Allow third party resource types ot be catered for if they are ever enabled by Microsoft

Author:

  • Russell Seymour

Since:

  • 0.2.0

Instance Method Summary collapse

Constructor Details

#initialize(counts) ⇒ Object

Constructor to setup a new class for a specific Azure Resource type. It should be passed a hashtable with information such as:

{
  "Compute/virtualMachines" => 2,
  "Network/networkInterfaces" => 3
}

This will result in two methods being created on the class:

- Compute/virtualNetworks
- Network/networkInterfaces

Each of which will return the corresponding count value

Parameters:

  • Hash

    counts Hash table of types and the count of each one

Since:

  • 0.2.0



303
304
305
306
307
308
309
# File 'lib/resources/azure/azure_backend.rb', line 303

def initialize(counts)
  counts.each do |type, count|
    define_singleton_method type do
      count
    end
  end
end