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.4.1 lib/fog/azurerm/requests/resources/list_tagged_resources.rb
fog-azure-rm-0.4.0 lib/fog/azurerm/requests/resources/list_tagged_resources.rb
fog-azure-rm-0.3.9 lib/fog/azurerm/requests/resources/list_tagged_resources.rb
fog-azure-rm-0.3.8 lib/fog/azurerm/requests/resources/list_tagged_resources.rb
fog-azure-rm-0.3.7 lib/fog/azurerm/requests/resources/list_tagged_resources.rb
fog-azure-rm-0.3.6 lib/fog/azurerm/requests/resources/list_tagged_resources.rb
fog-azure-rm-0.3.5 lib/fog/azurerm/requests/resources/list_tagged_resources.rb
fog-azure-rm-0.3.4 lib/fog/azurerm/requests/resources/list_tagged_resources.rb
fog-azure-rm-temp-0.0.4 lib/fog/azurerm/requests/resources/list_tagged_resources.rb
fog-azure-rm-temp-0.0.3 lib/fog/azurerm/requests/resources/list_tagged_resources.rb
fog-azure-rm-0.3.3 lib/fog/azurerm/requests/resources/list_tagged_resources.rb
fog-azure-rm-temp-0.0.2 lib/fog/azurerm/requests/resources/list_tagged_resources.rb
fog-azure-rm-temp-0.0.1 lib/fog/azurerm/requests/resources/list_tagged_resources.rb
fog-azure-rm-0.3.2 lib/fog/azurerm/requests/resources/list_tagged_resources.rb
fog-azure-rm-downgraded-0.3.1 lib/fog/azurerm/requests/resources/list_tagged_resources.rb
fog-azure-rm-0.3.1 lib/fog/azurerm/requests/resources/list_tagged_resources.rb
fog-azure-rm-downgraded-0.3.0 lib/fog/azurerm/requests/resources/list_tagged_resources.rb
fog-azure-rm-0.3.0 lib/fog/azurerm/requests/resources/list_tagged_resources.rb
fog-azure-rm-0.2.7 lib/fog/azurerm/requests/resources/list_tagged_resources.rb
fog-azure-rm-0.2.6 lib/fog/azurerm/requests/resources/list_tagged_resources.rb