Package com.contentful.java.cda
Class CDAClient
- java.lang.Object
-
- com.contentful.java.cda.CDAClient
-
public class CDAClient extends java.lang.ObjectClient to be used when requesting information from the Delivery API. Every client is associated with exactly one Space, but there is no limit to the concurrent number of clients existing at any one time. Avoid creating multiple clients for the same Space. Usebuilder()to create a new client instance.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCDAClient.BuilderThis builder will be used to configure and then create aCDAClient.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static CDAClient.Builderbuilder()CDAClientclearCache()Clear the java internal cache.<T extends CDAResource>
FetchQuery<T>fetch(java.lang.Class<T> type)Returns aFetchQueryfor a giventype, which can be used to fulfil the request synchronously or asynchronously when a callback is provided.CDASpacefetchSpace()<C extends CDACallback<CDASpace>>
CfetchSpace(C callback)Asynchronously fetch the space.<T extends CDAResource>
ObserveQuery<T>observe(java.lang.Class<T> type)Returns anObserveQueryfor a giventype, which can be used to return anFlowablethat fetches the desired resources.<T> TransformQuery<T>observeAndTransform(java.lang.Class<T> type)Returns aTransformQueryto transform the default contentful response into a specific custom model type.io.reactivex.rxjava3.core.Flowable<java.lang.Integer>observeContentTypeCachePopulation()Populate the content type cache with _all_ available content types.io.reactivex.rxjava3.core.Flowable<java.lang.Integer>observeContentTypeCachePopulation(int limit)Populate the content type cache with _all_ available content types.io.reactivex.rxjava3.core.Flowable<CDASpace>observeSpace()intpopulateContentTypeCache()Populate the content type cache with _all_ available content types.intpopulateContentTypeCache(int limit)Populate the content type cache with _all_ available content types.SyncQuerysync()Returns aSyncQueryfor initial synchronization via the Sync API.SyncQuerysync(SynchronizedSpace synchronizedSpace)Returns aSyncQueryfor synchronization with an existing space.SyncQuerysync(SyncType type)Returns aSyncQueryfor synchronization with the providedsyncTokenvia the Sync API.SyncQuerysync(java.lang.String syncToken)Returns aSyncQueryfor synchronization with the providedsyncTokenvia the Sync API.
-
-
-
Method Detail
-
fetch
public <T extends CDAResource> FetchQuery<T> fetch(java.lang.Class<T> type)
Returns aFetchQueryfor a giventype, which can be used to fulfil the request synchronously or asynchronously when a callback is provided.- Type Parameters:
T- type for avoiding casting on calling side.- Parameters:
type- resource type. This can be either aCDALocale, aCDAEntry, aCDAAsset, or aCDAContentType- Returns:
- A query to call
FetchQuery.all()orFetchQuery.one(String)on it. - See Also:
fetchSpace()
-
observeAndTransform
public <T> TransformQuery<T> observeAndTransform(java.lang.Class<T> type)
Returns aTransformQueryto transform the default contentful response into a specific custom model type.- Type Parameters:
T- An annotated customTransformQuery.ContentfulEntryModelmodel.- Returns:
- a query for async calls to Contentful transforming the response to custom types
- See Also:
TransformQuery.ContentfulEntryModel,TransformQuery.ContentfulField,TransformQuery.ContentfulSystemField
-
observe
public <T extends CDAResource> ObserveQuery<T> observe(java.lang.Class<T> type)
Returns anObserveQueryfor a giventype, which can be used to return anFlowablethat fetches the desired resources.- Type Parameters:
T- type for avoiding casting on calling side.- Parameters:
type- resource type. This can be either aCDALocale, aCDAEntry, aCDAAsset, or aCDAContentType- Returns:
- A query to call
ObserveQuery.all()orObserveQuery.one(String)on it. - See Also:
observeSpace()
-
populateContentTypeCache
public int populateContentTypeCache()
Populate the content type cache with _all_ available content types.This method will run through all the content types, saving them in the process and also takes care of paging.
This method is synchronous.
- Returns:
- the number of content types cached.
-
populateContentTypeCache
public int populateContentTypeCache(int limit)
Populate the content type cache with _all_ available content types.This method is synchronous.
- Parameters:
limit- the number of content types per page.- Returns:
- the number of content types cached.
- Throws:
java.lang.IllegalArgumentException- if limit is less or equal to 0.java.lang.IllegalArgumentException- if limit is more then 1_000.- See Also:
populateContentTypeCache()
-
observeContentTypeCachePopulation
public io.reactivex.rxjava3.core.Flowable<java.lang.Integer> observeContentTypeCachePopulation()
Populate the content type cache with _all_ available content types.This method will run through all the content types, saving them in the process and also takes care of paging.
This method is asynchronous and needs to be subscribed to.
- Returns:
- the flowable representing the asynchronous call.
-
observeContentTypeCachePopulation
public io.reactivex.rxjava3.core.Flowable<java.lang.Integer> observeContentTypeCachePopulation(int limit)
Populate the content type cache with _all_ available content types.This method will run through all the content types, saving them in the process and also takes care of paging.
This method is asynchronous and needs to be subscribed to.
- Parameters:
limit- the number of content types per page.- Returns:
- the flowable representing the asynchronous call.
- Throws:
java.lang.IllegalArgumentException- if limit is less or equal to 0.java.lang.IllegalArgumentException- if limit is more then 1_000.
-
sync
public SyncQuery sync()
Returns aSyncQueryfor initial synchronization via the Sync API.- Returns:
- query instance.
-
sync
public SyncQuery sync(SyncType type)
Returns aSyncQueryfor synchronization with the providedsyncTokenvia the Sync API.If called from a
previewclient, this will always do an initial sync.- Parameters:
type- the type to be sync'ed.- Returns:
- query instance.
-
sync
public SyncQuery sync(java.lang.String syncToken)
Returns aSyncQueryfor synchronization with the providedsyncTokenvia the Sync API.If called from a
previewclient, this will always do an initial sync.- Parameters:
syncToken- sync token.- Returns:
- query instance.
-
sync
public SyncQuery sync(SynchronizedSpace synchronizedSpace)
Returns aSyncQueryfor synchronization with an existing space.If called from a
previewclient, this will always do an initial sync.- Parameters:
synchronizedSpace- space to sync.- Returns:
- query instance.
-
fetchSpace
public CDASpace fetchSpace()
- Returns:
- the space for this client (synchronously).
-
fetchSpace
public <C extends CDACallback<CDASpace>> C fetchSpace(C callback)
Asynchronously fetch the space.- Type Parameters:
C- the type of the callback to be used.- Parameters:
callback- the value of the callback to be called back.- Returns:
- the space for this client (asynchronously).
-
observeSpace
public io.reactivex.rxjava3.core.Flowable<CDASpace> observeSpace()
- Returns:
- an
Flowablethat fetches the space for this client.
-
clearCache
public CDAClient clearCache()
Clear the java internal cache.- Returns:
- this client for chaining.
-
builder
public static CDAClient.Builder builder()
- Returns:
- a
CDAClientbuilder.
-
-