Class ResourceManagerUtils
- java.lang.Object
-
- com.azure.resourcemanager.resources.fluentcore.utils.ResourceManagerUtils
-
public final class ResourceManagerUtils extends Object
Defines a few utilities.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classResourceManagerUtils.InternalRuntimeContextThe class provides the common methods required for SDK framework.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringcreateOdataFilterForTags(String tagName, String tagValue)Creates an Odata filter string that can be used for filtering list results by tags.static StringgetDefaultScopeFromRequest(com.azure.core.http.HttpRequest request, com.azure.core.management.AzureEnvironment environment)Generates default scope for oauth2 from the specific requeststatic StringgetDefaultSubscription(com.azure.core.http.rest.PagedIterable<Subscription> subscriptions)Gets the only subscription as the default one in the tenant if applicable.static StringgetStorageConnectionString(String accountName, String accountKey, com.azure.core.management.AzureEnvironment environment)Get the Azure storage account connection string.static voidsleep(Duration duration)Wrapper for thread sleep.static booleantoPrimitiveBoolean(Boolean value)Converts an object Boolean to a primitive boolean.static inttoPrimitiveInt(Integer value)Converts an object Integer to a primitive int.static inttoPrimitiveInt(Long value)Converts an object Long to a primitive int.static longtoPrimitiveLong(Long value)Converts an object Long to a primitive long.
-
-
-
Method Detail
-
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
-
sleep
public static void sleep(Duration duration)
Wrapper for thread sleep.- Parameters:
duration- the duration value for which thread should put on sleep.
-
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
-
getDefaultSubscription
public static String getDefaultSubscription(com.azure.core.http.rest.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
- Throws:
IllegalStateException- when no subscription or more than one subscription found
-
getDefaultScopeFromRequest
public static String getDefaultScopeFromRequest(com.azure.core.http.HttpRequest request, com.azure.core.management.AzureEnvironment environment)
Generates default scope for oauth2 from the specific request- Parameters:
request- a http requestenvironment- the azure environment with current request- Returns:
- the default scope
-
getStorageConnectionString
public static String getStorageConnectionString(String accountName, String accountKey, com.azure.core.management.AzureEnvironment environment)
Get the Azure storage account connection string.- Parameters:
accountName- storage account nameaccountKey- storage account keyenvironment- the Azure environment- Returns:
- the storage account connection string.
-
-