Class CosmosAuthorizationHeaderFromUrl
- java.lang.Object
-
- com.adaptris.core.ServiceImp
-
- com.adaptris.interlok.azure.cosmosdb.CosmosAuthorizationHeaderImpl
-
- com.adaptris.interlok.azure.cosmosdb.CosmosAuthorizationHeaderFromUrl
-
- All Implemented Interfaces:
AdaptrisComponent
,ComponentLifecycle
,ComponentLifecycleExtension
,MessageEventGenerator
,Service
,StateManagedComponent
@ComponentProfile(summary="Builds an authorization header for Azure CosmosDB", since="3.9.2", tag="azure,cosmosdb,cosmos") public class CosmosAuthorizationHeaderFromUrl extends CosmosAuthorizationHeaderImpl
Builds an authorization header for Azure CosmosDB from a URL.This differs from
CosmosAuthorizationHeader
in that it parses the URL for an appropriate ResourceID and ResourceType. Once it has figured out an appropriate resourceID and ResourceType it builds an instance ofCosmosAuthorizationHeader
and executes it. Note that if the URL convention changes for Azure CosmosDB, then this service may well generate an incorrect ResourceType/ResourceID; you may still need to useCosmosAuthorizationHeader
directly.Given this example list of URLS; then then corresponding ResourceType / ResourceIDs will be generated. Essentially if the number of path fragments is
even
then the ResourceID is full path, and the ResourceType is the penultimate fragment; if the number of path fragments isodd
then the ResourceID is everything up to the last/
and the ResoucrceType is the last fragment.URL example ResourceType ResourceID https://azuredb.microsoft.com/ ""
(the service will fail; since ResourceType must be set)""
https://azuredb.microsoft.com/dbs dbs
""
https://azuredb.microsoft.com/dbs/tempdb/colls/tempcoll/docs docs
dbs/tmpdb/colls/tempcoll
https://azuredb.microsoft.com/dbs/tempdb/colls/tempcoll/docs/MyName docs
dbs/tempdb/colls/tempcoll/docs/MyName
https://azuredb.microsoft.com/dbs/tempdb/colls colls
dbs/tempdb
In the adapter configuration file this class is aliased as cosmosdb-authorization-header-from-url which is the preferred alternative to the fully qualified classname when building your configuration.
-
-
Field Summary
-
Fields inherited from class com.adaptris.interlok.azure.cosmosdb.CosmosAuthorizationHeaderImpl
DEFAULT_METADATA_KEY, X_MS_DATE
-
Fields inherited from class com.adaptris.core.ServiceImp
log
-
-
Constructor Summary
Constructors Constructor Description CosmosAuthorizationHeaderFromUrl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
doService(AdaptrisMessage msg)
@NonNull java.lang.String
getCosmosEndpointUrl()
The Cosmos URL Endpoint that you will be hitting with your REST request.void
prepare()
void
setCosmosEndpointUrl(@NonNull java.lang.String cosmosEndpointUrl)
The Cosmos URL Endpoint that you will be hitting with your REST request.CosmosAuthorizationHeaderFromUrl
withCosmosEndpointUrl(java.lang.String s)
-
Methods inherited from class com.adaptris.interlok.azure.cosmosdb.CosmosAuthorizationHeaderImpl
closeService, getHttpVerb, getMasterKey, getTargetKey, initService, setHttpVerb, setMasterKey, setTargetKey, targetKey, withHttpVerb, withMasterKey, withTargetKey
-
Methods inherited from class com.adaptris.core.ServiceImp
changeState, close, continueOnFailure, createName, createQualifier, getContinueOnFail, getIsTrackingEndpoint, getUniqueId, init, isBranching, isTrackingEndpoint, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, setContinueOnFail, setIsTrackingEndpoint, setUniqueId, start, stop
-
-
-
-
Method Detail
-
prepare
public void prepare() throws CoreException
- Specified by:
prepare
in interfaceComponentLifecycleExtension
- Overrides:
prepare
in classCosmosAuthorizationHeaderImpl
- Throws:
CoreException
-
doService
public void doService(AdaptrisMessage msg) throws ServiceException
- Throws:
ServiceException
-
withCosmosEndpointUrl
public CosmosAuthorizationHeaderFromUrl withCosmosEndpointUrl(java.lang.String s)
-
getCosmosEndpointUrl
@NonNull public @NonNull java.lang.String getCosmosEndpointUrl()
The Cosmos URL Endpoint that you will be hitting with your REST request.
-
setCosmosEndpointUrl
public void setCosmosEndpointUrl(@NonNull @NonNull java.lang.String cosmosEndpointUrl)
The Cosmos URL Endpoint that you will be hitting with your REST request.
-
-