Sha256: 091f77ce2610544b097bdd57ed91cb62ebf210a78c1c8a47343cc7088b6e6b47
Contents?: true
Size: 1.85 KB
Versions: 1
Compression:
Stored size: 1.85 KB
Contents
module Fog module Resources class AzureRM # This class provides the actual implemention for service calls. class Real def tag_resource(resource_id, tag_name, tag_value) split_resource = resource_id.split('/') unless resource_id.nil? if split_resource.count != 9 raise 'Invalid Resource Id' end 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 = '' Fog::Logger.debug "Creating Tag #{tag_name} for Resource #{resource_name}" begin resource = @rmc.resources.get(resource_group_name, resource_provider_namespace, parent_resource_id, resource_type, resource_name, API_VERSION) resource.tags = {} if resource.tags.nil? resource.tags[tag_name] = tag_value @rmc.resources.create_or_update(resource_group_name, resource_provider_namespace, parent_resource_id, resource_type, resource_name, API_VERSION, resource) Fog::Logger.debug "Tag #{tag_name} created successfully for Resource #{resource_name}" true rescue MsRestAzure::AzureOperationError => e raise Fog::AzureRm::OperationError.new(e) end end end # This class provides the mock implementation for unit tests. class Mock def tag_resource(_resource_id, tag_name, _tag_value) Fog::Logger.debug "Tag #{tag_name} created successfully for Resource 'resource_name'" true end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fog-azure-rm-0.0.5 | lib/fog/azurerm/requests/resources/tag_resource.rb |