Class ResourceUtils
java.lang.Object
com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils
Utility methods for Azure resource IDs.
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
constructResourceId
(String subscriptionId, String resourceGroupName, String resourceProviderNamespace, String resourceType, String resourceName, String parentResourcePath) Creates a resource ID from information of a generic resource.static String
defaultApiVersion
(String id, Provider provider) Find out the default api version to make a REST request with from the resource provider.static String
extractFromResourceId
(String id, String identifier) Extract information from a resource ID string with the resource type as the identifier.static String
Extract resource group from a resource ID string.static String
Extract name of the resource from a resource ID.static String
Extract parent resource path from a resource ID string.static String
Extract parent resource ID from a resource ID string.static String
Extract the relative path to the current resource provider.static String
Extract resource provider from a resource ID string.static String
Extract resource type from a resource ID string.static String
Extract the subscription ID from a resource ID string.
-
Method Details
-
groupFromResourceId
Extract resource group from a resource ID string.- Parameters:
id
- the resource ID string- Returns:
- the resource group name
-
subscriptionFromResourceId
Extract the subscription ID from a resource ID string.- Parameters:
id
- the resource ID string- Returns:
- the subscription ID
-
resourceProviderFromResourceId
Extract resource provider from a resource ID string.- Parameters:
id
- the resource ID string- Returns:
- the resource group name
-
resourceTypeFromResourceId
Extract resource type from a resource ID string.- Parameters:
id
- the resource ID string- Returns:
- the resource type
-
parentResourceIdFromResourceId
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
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
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
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
Extract name of the resource from a resource ID.- Parameters:
id
- the resource ID- Returns:
- the name of the resource
-
defaultApiVersion
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
-