Class EndpointBuilder
- java.lang.Object
-
- com.oracle.bmc.internal.EndpointBuilder
-
public class EndpointBuilder extends Object
EndpointBuilder provides a wrapper to construct the appropriate endpoint for a service.The service may override the endpoint template, but if not, a default template will be used.
-
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_ENDPOINT_TEMPLATEstatic StringDUAL_STACK_OPTIONstatic PatternOPTIONS_PATTERNstatic StringOPTIONS_REGEXRegex to detect options defined in the endpoint template.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringcreateEndpoint(Service service, Region region)Creates the service endpoint using theDefaultEndpointConfigurationmethod.static StringcreateEndpoint(Service service, String regionId, Realm realm)Creates the service endpoint using theDefaultEndpointConfigurationmethod.protected static StringgetEndpointWithPopulatedServiceParams(String baseUriString, Map<String,Object> requiredParametersMap, Map<String,Boolean> optionsMap)Populate the parameters in the endpoint with its corresponding value, process options, and return the processed endpoint.static StringgetRealmSpecificEndpointTemplate(String regionId, Service service, Realm realm)static StringgetServiceEndpointTemplateToUse(String regionId, Service service, Realm realm)static booleanisEndpointParameterized(String endpoint)Checks if the given endpoint string contains any placeholders.static voidoverrideRegionId(String regionId, String overrideRegionId)Temporary ability to override the region for a given regionId.static WrappedWebTargetpopulateServiceParametersInEndpoint(RestClient client, Map<String,Object> requiredParametersMap)Populate the parameters in the endpoint with its corresponding value and update the base endpoint.static StringremoveAllParametersFromEndpoint(String updatedEndpoint)Removes all placeholders from the given endpoint string.
-
-
-
Field Detail
-
DEFAULT_ENDPOINT_TEMPLATE
public static final String DEFAULT_ENDPOINT_TEMPLATE
- See Also:
- Constant Field Values
-
OPTIONS_REGEX
public static final String OPTIONS_REGEX
Regex to detect options defined in the endpoint template.It checks for the following pattern:
- Starts with an opening curly brace ({)
- Followed by 1 or more word characters
- Followed by a question mark (?)
- Followed by any one of the following:
- one or more word characters, followed by a period:one or more word characters, followed by a period
- one or more word characters, followed by a period:zero or more whitespace characters
- zero or more whitespace characters:one or more word characters, followed by a period
- Ends with a closing curly brace (})
Example: {option?v1.:v2.}, {option?:v2.}, {option?v1.:} are valid patterns
Example: {option?v1:v2+}, {option?:v2}, {option?v1?:} {option?:} are invalid pattern
- See Also:
- Constant Field Values
-
OPTIONS_PATTERN
public static final Pattern OPTIONS_PATTERN
-
DUAL_STACK_OPTION
public static final String DUAL_STACK_OPTION
- See Also:
- Constant Field Values
-
-
Method Detail
-
createEndpoint
public static String createEndpoint(@Nonnull Service service, @Nonnull String regionId, @Nonnull Realm realm)
Creates the service endpoint using theDefaultEndpointConfigurationmethod.- Parameters:
service- The serviceregionId- The regionIdrealm- The realm this region belongs to.- Returns:
- The endpoint (protocol + FQDN) for this service.
-
getRealmSpecificEndpointTemplate
public static String getRealmSpecificEndpointTemplate(String regionId, Service service, Realm realm)
-
getServiceEndpointTemplateToUse
public static String getServiceEndpointTemplateToUse(String regionId, Service service, Realm realm)
-
createEndpoint
public static String createEndpoint(@Nonnull Service service, @Nonnull Region region)
Creates the service endpoint using theDefaultEndpointConfigurationmethod.- Parameters:
service- The serviceregion- The region- Returns:
- The endpoint (protocol + FQDN) for this service.
-
overrideRegionId
public static void overrideRegionId(@Nonnull String regionId, @Nonnull String overrideRegionId)
Temporary ability to override the region for a given regionId.This will most likely be removed at a later point in time. It is not intended for use outside of the SDK.
- Parameters:
regionId- The value obtained fromRegion.getRegionId().overrideRegionId- The alternative regionId to use.
-
populateServiceParametersInEndpoint
public static final WrappedWebTarget populateServiceParametersInEndpoint(RestClient client, Map<String,Object> requiredParametersMap)
Populate the parameters in the endpoint with its corresponding value and update the base endpoint.The value will be populated iff the parameter in endpoint is a required request path parameter or a required request query parameter. If not, the parameter in the endpoint will be ignored and left blank.
- Parameters:
client- The RestClient in userequiredParametersMap- Map of parameter name as key and value set in request path or query parameter as value
-
getEndpointWithPopulatedServiceParams
protected static String getEndpointWithPopulatedServiceParams(String baseUriString, Map<String,Object> requiredParametersMap, Map<String,Boolean> optionsMap)
Populate the parameters in the endpoint with its corresponding value, process options, and return the processed endpoint.For parameters, the value will be populated iff the parameter in endpoint is a required request path parameter or a required request query parameter. If not, the parameter in the endpoint will be ignored and left blank.
For options, the true-choice or the false-choice will be entered into the endpoint, depending on the state of the option. If the option is unknown, the entire option construct will be removed, meaning neither the true-choice nor the false-choice will be used.
- Parameters:
baseUriString- base URI string, may be parameterizedrequiredParametersMap- the map from required parameter name to their valuesoptionsMap- the map from option name to enabled/disabled status- Returns:
- endpoint with parameters replaced with their values
-
isEndpointParameterized
public static boolean isEndpointParameterized(String endpoint)
Checks if the given endpoint string contains any placeholders.A placeholder is denoted by the presence of ‘{’ character.
- Parameters:
endpoint- the endpoint string to check for parameterization- Returns:
- true if the endpoint is parameterized, false otherwise
-
removeAllParametersFromEndpoint
public static String removeAllParametersFromEndpoint(String updatedEndpoint)
Removes all placeholders from the given endpoint string.- Parameters:
updatedEndpoint- the endpoint string to remove parameters from- Returns:
- the endpoint string with all placeholders removed
-
-