Sha256: 6f889d54bdc1b99fc9c165d124b5deada3151a90893179552190ce9fa596b680
Contents?: true
Size: 1.61 KB
Versions: 21
Compression:
Stored size: 1.61 KB
Contents
module Fog module Resources class AzureRM # This class provides the actual implementation for service calls. class Real def check_azure_resource_exists(resource_id, api_version = API_VERSION) split_resource = resource_id.split('/') unless resource_id.nil? raise 'Invalid Resource Id' if split_resource.count != 9 resource_group_name = get_resource_from_resource_id(resource_id, RESOURCE_GROUP_NAME) resource_provider_namespace = get_resource_from_resource_id(resource_id, RESOURCE_PROVIDER_NAMESPACE) resource_type = get_resource_from_resource_id(resource_id, RESOURCE_TYPE) resource_name = get_resource_from_resource_id(resource_id, RESOURCE_NAME) parent_resource_id = '' msg = "Checking Resource #{resource_name}" Fog::Logger.debug msg begin resource_exists = @rmc.resources.check_existence(resource_group_name, resource_provider_namespace, parent_resource_id, resource_type, resource_name, api_version) Fog::Logger.debug "Resource #{resource_name} exists." if resource_exists resource_exists rescue MsRestAzure::AzureOperationError => e if e.response.status == 405 Fog::Logger.debug "Resource #{resource_name} doesn't exist." false else raise_azure_exception(e, msg) end end end end # This class provides the mock implementation for unit tests. class Mock def check_azure_resource_exists(*) true end end end end end
Version data entries
21 entries across 21 versions & 3 rubygems
Version | Path |
---|---|
fog-azure-rm-0.4.1 | lib/fog/azurerm/requests/resources/check_azure_resource_exists.rb |