Sha256: 3b47b115548cd85baf48012357fd8605091ab83316e165150883c41043d9d263

Contents?: true

Size: 1.69 KB

Versions: 48

Compression:

Stored size: 1.69 KB

Contents

module Fog
  module Resources
    class AzureRM
      # This class provides the actual implementation for service calls.
      class Real
        def list_tagged_resources(tag_name, tag_value = nil)
          msg = "Listing Resources with tagname: #{tag_name}"
          Fog::Logger.debug msg
          unless tag_name.nil?
            query_filter = "tagname eq '#{tag_name}' "
            query_filter += tag_value.nil? ? '' : "and tagvalue eq '#{tag_value}'"
            begin
              resources = @rmc.resources.list_as_lazy(query_filter)
            rescue MsRestAzure::AzureOperationError => e
              raise_azure_exception(e, msg)
            end
            resources.next_link = '' if resources.next_link.nil?
            resources.value
          end
        end
      end

      # This class provides the mock implementation for unit tests.
      class Mock
        def list_tagged_resources(tag_name, tag_value)
          resources = {
            'value' => [
              {
                'id' => '/subscriptions/########-####-####-####-############/fog-rg',
                'name' => 'your-resource-name',
                'type' => 'providernamespace/resourcetype',
                'location' => 'westus',
                'tags' =>
                  {
                    tag_name => tag_value
                  },
                'plan' =>
                  {
                    'name' => 'free'
                  }
              }
            ]
          }
          result_mapper = Azure::ARM::Resources::Models::ResourceListResult.mapper
          @rmc.deserialize(result_mapper, resources, 'result.body').value
        end
      end
    end
  end
end

Version data entries

48 entries across 48 versions & 4 rubygems

Version Path
fog-azure-rm-0.6.0 lib/fog/azurerm/requests/resources/list_tagged_resources.rb
fog-azure-rm-0.5.3 lib/fog/azurerm/requests/resources/list_tagged_resources.rb
fog-azure-rm-0.5.2 lib/fog/azurerm/requests/resources/list_tagged_resources.rb
far-gem-0.5.6 lib/fog/azurerm/requests/resources/list_tagged_resources.rb
fog-azure-rm-0.5.1 lib/fog/azurerm/requests/resources/list_tagged_resources.rb
far-gem-0.5.5 lib/fog/azurerm/requests/resources/list_tagged_resources.rb
fog-azure-rm-0.5.0 lib/fog/azurerm/requests/resources/list_tagged_resources.rb
far-gem-0.5.4 lib/fog/azurerm/requests/resources/list_tagged_resources.rb
far-gem-0.5.3 lib/fog/azurerm/requests/resources/list_tagged_resources.rb
fog-azure-rm-0.4.9 lib/fog/azurerm/requests/resources/list_tagged_resources.rb
far-gem-0.5.2 lib/fog/azurerm/requests/resources/list_tagged_resources.rb
fog-azure-rm-0.4.8 lib/fog/azurerm/requests/resources/list_tagged_resources.rb
fog-azure-rm-0.4.7 lib/fog/azurerm/requests/resources/list_tagged_resources.rb
fog-azure-rm-0.4.6 lib/fog/azurerm/requests/resources/list_tagged_resources.rb
fog-azure-rm-0.4.5 lib/fog/azurerm/requests/resources/list_tagged_resources.rb
fog-azure-rm-temp-0.0.5 lib/fog/azurerm/requests/resources/list_tagged_resources.rb
fog-azure-rm-0.4.4 lib/fog/azurerm/requests/resources/list_tagged_resources.rb
fog-azure-rm-0.4.3 lib/fog/azurerm/requests/resources/list_tagged_resources.rb
far-gem-0.5.1 lib/fog/azurerm/requests/resources/list_tagged_resources.rb
fog-azure-rm-0.4.2 lib/fog/azurerm/requests/resources/list_tagged_resources.rb