Class ResourceUtils
- java.lang.Object
-
- com.azure.resourcemanager.resources.fluentcore.arm.ResourceUtils
-
public final class ResourceUtils extends Object
Utility methods for Azure resource IDs.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringconstructResourceId(String subscriptionId, String resourceGroupName, String resourceProviderNamespace, String resourceType, String resourceName, String parentResourcePath)Creates a resource ID from information of a generic resource.static StringdefaultApiVersion(String id, Provider provider)Find out the default api version to make a REST request with from the resource provider.static StringextractFromResourceId(String id, String identifier)Extract information from a resource ID string with the resource type as the identifier.static StringgroupFromResourceId(String id)Extract resource group from a resource ID string.static StringnameFromResourceId(String id)Extract name of the resource from a resource ID.static StringparentRelativePathFromResourceId(String id)Extract parent resource path from a resource ID string.static StringparentResourceIdFromResourceId(String id)Extract parent resource ID from a resource ID string.static StringrelativePathFromResourceId(String id)Extract the relative path to the current resource provider.static StringresourceProviderFromResourceId(String id)Extract resource provider from a resource ID string.static StringresourceTypeFromResourceId(String id)Extract resource type from a resource ID string.static StringsubscriptionFromResourceId(String id)Extract the subscription ID from a resource ID string.
-
-
-
Method Detail
-
groupFromResourceId
public static String groupFromResourceId(String id)
Extract resource group from a resource ID string.- Parameters:
id- the resource ID string- Returns:
- the resource group name
-
subscriptionFromResourceId
public static String subscriptionFromResourceId(String id)
Extract the subscription ID from a resource ID string.- Parameters:
id- the resource ID string- Returns:
- the subscription ID
-
resourceProviderFromResourceId
public static String resourceProviderFromResourceId(String id)
Extract resource provider from a resource ID string.- Parameters:
id- the resource ID string- Returns:
- the resource group name
-
resourceTypeFromResourceId
public static String resourceTypeFromResourceId(String id)
Extract resource type from a resource ID string.- Parameters:
id- the resource ID string- Returns:
- the resource type
-
parentResourceIdFromResourceId
public static String parentResourceIdFromResourceId(String id)
Extract parent resource ID from a resource ID string. E.g. subscriptions/s/resourcegroups/r/foos/foo/bars/bar will return subscriptions/s/resourcegroups/r/foos/foo.- Parameters:
id- the resource ID string- Returns:
- the parent resource ID
-
parentRelativePathFromResourceId
public static String parentRelativePathFromResourceId(String id)
Extract parent resource path from a resource ID string. E.g. subscriptions/s/resourcegroups/r/foos/foo/bars/bar will return foos/foo.- Parameters:
id- the resource ID string- Returns:
- the parent resource ID
-
relativePathFromResourceId
public static String relativePathFromResourceId(String id)
Extract the relative path to the current resource provider. E.g. subscriptions/sub1/resourceGroups/rg1/providers/Microsoft.Foo/foos/foo1 will return foos/foo1.- Parameters:
id- the id of the resource- Returns:
- the relative path
-
extractFromResourceId
public static String extractFromResourceId(String id, String identifier)
Extract information from a resource ID string with the resource type as the identifier.- Parameters:
id- the resource IDidentifier- the identifier to match, e.g. "resourceGroups", "storageAccounts"- Returns:
- the information extracted from the identifier
-
nameFromResourceId
public static String nameFromResourceId(String id)
Extract name of the resource from a resource ID.- Parameters:
id- the resource ID- Returns:
- the name of the resource
-
defaultApiVersion
public static String defaultApiVersion(String id, Provider provider)
Find out the default api version to make a REST request with from the resource provider.- Parameters:
id- the resource IDprovider- the resource provider- Returns:
- the default api version to use
-
constructResourceId
public static String constructResourceId(String subscriptionId, String resourceGroupName, String resourceProviderNamespace, String resourceType, String resourceName, String parentResourcePath)
Creates a resource ID from information of a generic resource.- Parameters:
subscriptionId- the subscription UUIDresourceGroupName- the resource group nameresourceProviderNamespace- the resource provider namespaceresourceType- the type of the resource or nested resourceresourceName- name of the resource or nested resourceparentResourcePath- parent resource's relative path to the provider, if the resource is a generic resource- Returns:
- the resource ID string
-
-