java.lang.Object
com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils

public final class ResourceUtils extends Object
Utility methods for Azure resource IDs.
  • Method Details

    • 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 ID
      identifier - 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 ID
      provider - 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 UUID
      resourceGroupName - the resource group name
      resourceProviderNamespace - the resource provider namespace
      resourceType - the type of the resource or nested resource
      resourceName - name of the resource or nested resource
      parentResourcePath - parent resource's relative path to the provider, if the resource is a generic resource
      Returns:
      the resource ID string