ResourceManagerUtils Class

  • java.lang.Object
    • com.azure.resourcemanager.resources.fluentcore.utils.ResourceManagerUtils

public final class ResourceManagerUtils

Defines a few utilities.

Method Summary

Modifier and Type Method and Description
static String createOdataFilterForTags(String tagName, String tagValue)

Creates an Odata filter string that can be used for filtering list results by tags.

static String getDefaultScopeFromRequest(HttpRequest request, AzureEnvironment environment)

Generates default scope for oauth2 from the specific request

static String getDefaultSubscription(PagedIterable<Subscription> subscriptions)

Gets the only subscription as the default one in the tenant if applicable.

static String getStorageConnectionString(String accountName, String accountKey, AzureEnvironment environment)

Get the Azure storage account connection string.

static void sleep(Duration duration)

Wrapper for thread sleep.

static boolean toPrimitiveBoolean(Boolean value)

Converts an object Boolean to a primitive boolean.

static int toPrimitiveInt(Integer value)

Converts an object Integer to a primitive int.

static int toPrimitiveInt(Long value)

Converts an object Long to a primitive int.

static long toPrimitiveLong(Long value)

Converts an object Long to a primitive long.

Methods inherited from java.lang.Object

Method Details

createOdataFilterForTags

public static String createOdataFilterForTags(String tagName, String tagValue)

Creates an Odata filter string that can be used for filtering list results by tags.

Parameters:

tagName - the name of the tag. If not provided, all resources will be returned.
tagValue - the value of the tag. If not provided, only tag name will be filtered.

Returns:

the Odata filter to pass into list methods

getDefaultScopeFromRequest

public static String getDefaultScopeFromRequest(HttpRequest request, AzureEnvironment environment)

Generates default scope for oauth2 from the specific request

Parameters:

request - a http request
environment - the azure environment with current request

Returns:

the default scope

getDefaultSubscription

public static String getDefaultSubscription(PagedIterable<Subscription> subscriptions)

Gets the only subscription as the default one in the tenant if applicable.

Parameters:

subscriptions - the list of subscriptions

Returns:

the only subscription existing in the tenant

getStorageConnectionString

public static String getStorageConnectionString(String accountName, String accountKey, AzureEnvironment environment)

Get the Azure storage account connection string.

Parameters:

accountName - storage account name
accountKey - storage account key
environment - the Azure environment

Returns:

the storage account connection string.

sleep

public static void sleep(Duration duration)

Wrapper for thread sleep.

Parameters:

duration - the duration value for which thread should put on sleep.

toPrimitiveBoolean

public static boolean toPrimitiveBoolean(Boolean value)

Converts an object Boolean to a primitive boolean.

Parameters:

value - the Boolean value

Returns:

false if the given Boolean value is null or false else true

toPrimitiveInt

public static int toPrimitiveInt(Integer value)

Converts an object Integer to a primitive int.

Parameters:

value - the Integer value

Returns:

0 if the given Integer value is null else integer value

toPrimitiveInt

public static int toPrimitiveInt(Long value)

Converts an object Long to a primitive int.

Parameters:

value - the Long value

Returns:

0 if the given Long value is null else integer value

toPrimitiveLong

public static long toPrimitiveLong(Long value)

Converts an object Long to a primitive long.

Parameters:

value - the Long value

Returns:

0 if the given Long value is null else long value

Applies to