Interface IContentfulClient
Defines a set of methods to call underlying api endpoints at contentful.
Namespace:Contentful.Core
Assembly:cs.temp.dll.dll
Syntax
public interface IContentfulClient
Properties
ContentTypeResolver
Gets or sets the resolver used when resolving entries to typed objects.
Declaration
IContentTypeResolver ContentTypeResolver { get; set; }
Property Value
Type | Description |
---|---|
IContentTypeResolver |
IsPreviewClient
Returns whether or not the client is using the preview API.
Declaration
bool IsPreviewClient { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
ResolveEntriesSelectively
If set the GetEntries methods will evaluate the class to serialize into and only serialize the parts that are part of the class structure.
Declaration
bool ResolveEntriesSelectively { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
SerializerSettings
Gets or sets the settings that should be used for deserialization.
Declaration
JsonSerializerSettings SerializerSettings { get; set; }
Property Value
Type | Description |
---|---|
JsonSerializerSettings |
Methods
GetAsset(String, QueryBuilder<Asset>, CancellationToken)
Gets a single Asset by the specified ID.
Declaration
Task<Asset> GetAsset(string assetId, QueryBuilder<Asset> queryBuilder, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.String | assetId | The ID of the asset. |
QueryBuilder<Asset> | queryBuilder | The optional QueryBuilder<T> to add additional filtering to the query. |
System.Threading.CancellationToken | cancellationToken | The optional cancellation token to cancel the operation. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Asset> | The response from the API serialized into an Asset |
Exceptions
Type | Condition |
---|---|
ContentfulException | There was an error when communicating with the Contentful API. |
System.ArgumentException | The assetId parameter was null or emtpy. |
GetAsset(String, String, CancellationToken)
Gets a single Asset by the specified ID.
Declaration
Task<Asset> GetAsset(string assetId, string queryString, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.String | assetId | The ID of the asset. |
System.String | queryString | The optional querystring to add additional filtering to the query. |
System.Threading.CancellationToken | cancellationToken | The optional cancellation token to cancel the operation. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Asset> | The response from the API serialized into an Asset |
Exceptions
Type | Condition |
---|---|
ContentfulException | There was an error when communicating with the Contentful API. |
System.ArgumentException | The assetId parameter was null or emtpy. |
GetAssets(QueryBuilder<Asset>, CancellationToken)
Gets all assets of a space, filtered by an optional QueryBuilder<T>.
Declaration
Task<ContentfulCollection<Asset>> GetAssets(QueryBuilder<Asset> queryBuilder, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
QueryBuilder<Asset> | queryBuilder | The optional QueryBuilder<T> to add additional filtering to the query. |
System.Threading.CancellationToken | cancellationToken | The optional cancellation token to cancel the operation. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<ContentfulCollection<Asset>> | An System.Collections.Generic.IEnumerable<T> of Asset. |
Exceptions
Type | Condition |
---|---|
ContentfulException | There was an error when communicating with the Contentful API. |
GetAssets(String, CancellationToken)
Gets all assets of a space, filtered by an optional querystring. A simpler approach than to construct a query manually is to use the QueryBuilder<T> class.
Declaration
Task<ContentfulCollection<Asset>> GetAssets(string queryString = null, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.String | queryString | The optional querystring to add additional filtering to the query. |
System.Threading.CancellationToken | cancellationToken | The optional cancellation token to cancel the operation. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<ContentfulCollection<Asset>> | An System.Collections.Generic.IEnumerable<T> of Asset. |
Exceptions
Type | Condition |
---|---|
ContentfulException | There was an error when communicating with the Contentful API. |
GetContentType(String, CancellationToken)
Gets a ContentType by the specified ID.
Declaration
Task<ContentType> GetContentType(string contentTypeId, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.String | contentTypeId | The ID of the content type. |
System.Threading.CancellationToken | cancellationToken | The optional cancellation token to cancel the operation. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<ContentType> | The response from the API serialized into a ContentType. |
Exceptions
Type | Condition |
---|---|
ContentfulException | There was an error when communicating with the Contentful API. |
System.ArgumentException | The contentTypeId parameter was null or empty |
GetContentTypes(CancellationToken)
Get all content types of a space.
Declaration
Task<IEnumerable<ContentType>> GetContentTypes(CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.Threading.CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<ContentType>> | An System.Collections.Generic.IEnumerable<T> of ContentType. |
GetEntries<T>(QueryBuilder<T>, CancellationToken)
Gets all the entries of a space, filtered by an optional QueryBuilder<T>.
Declaration
Task<ContentfulCollection<T>> GetEntries<T>(QueryBuilder<T> queryBuilder, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
QueryBuilder<T> | queryBuilder | The optional QueryBuilder<T> to add additional filtering to the query. |
System.Threading.CancellationToken | cancellationToken | The optional cancellation token to cancel the operation. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<ContentfulCollection<T>> | A ContentfulCollection<T> of items. |
Type Parameters
Name | Description |
---|---|
T | The class to serialize the response into. If you want the metadata to be included in the serialized response use the Entry<T> class as a type parameter. |
Exceptions
Type | Condition |
---|---|
ContentfulException | There was an error when communicating with the Contentful API. |
GetEntries<T>(String, CancellationToken)
Gets all the entries of a space, filtered by an optional querystring. A simpler approach than to construct a query manually is to use the QueryBuilder<T> class.
Declaration
Task<ContentfulCollection<T>> GetEntries<T>(string queryString = null, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.String | queryString | The optional querystring to add additional filtering to the query. |
System.Threading.CancellationToken | cancellationToken | The optional cancellation token to cancel the operation. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<ContentfulCollection<T>> | A ContentfulCollection<T> of items. |
Type Parameters
Name | Description |
---|---|
T | The class to serialize the response into. If you want the metadata to be included in the serialized response use the Entry<T> class as a type parameter. |
Exceptions
Type | Condition |
---|---|
ContentfulException | There was an error when communicating with the Contentful API. |
GetEntriesByType<T>(String, QueryBuilder<T>, CancellationToken)
Gets all the entries with the specified content type.
Declaration
Task<ContentfulCollection<T>> GetEntriesByType<T>(string contentTypeId, QueryBuilder<T> queryBuilder = null, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.String | contentTypeId | The ID of the content type to get entries for. |
QueryBuilder<T> | queryBuilder | The optional QueryBuilder<T> to add additional filtering to the query. |
System.Threading.CancellationToken | cancellationToken | The optional cancellation token to cancel the operation. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<ContentfulCollection<T>> | A ContentfulCollection<T> of items. |
Type Parameters
Name | Description |
---|---|
T | The class to serialize the response into. If you want the metadata to be included in the serialized response use the Entry<T> class as a type parameter. |
Exceptions
Type | Condition |
---|---|
ContentfulException | There was an error when communicating with the Contentful API. |
GetEntry<T>(String, QueryBuilder<T>, CancellationToken)
Get a single entry by the specified ID.
Declaration
Task<T> GetEntry<T>(string entryId, QueryBuilder<T> queryBuilder, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.String | entryId | The ID of the entry. |
QueryBuilder<T> | queryBuilder | The optional QueryBuilder<T> to add additional filtering to the query. |
System.Threading.CancellationToken | cancellationToken | The optional cancellation token to cancel the operation. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<T> | The response from the API serialized into |
Type Parameters
Name | Description |
---|---|
T | The type to serialize this entry into. If you want the metadata to be included in the serialized response use the Entry<T> class as a type parameter. |
Exceptions
Type | Condition |
---|---|
ContentfulException | There was an error when communicating with the Contentful API. |
System.ArgumentException | The entryId parameter was null or empty. |
GetEntry<T>(String, String, CancellationToken)
Get a single entry by the specified ID.
Declaration
Task<T> GetEntry<T>(string entryId, string queryString = null, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.String | entryId | The ID of the entry. |
System.String | queryString | The optional querystring to add additional filtering to the query. |
System.Threading.CancellationToken | cancellationToken | The optional cancellation token to cancel the operation. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<T> | The response from the API serialized into |
Type Parameters
Name | Description |
---|---|
T | The type to serialize this entry into. If you want the metadata to be included in the serialized response use the Entry<T> class as a type parameter. |
Exceptions
Type | Condition |
---|---|
ContentfulException | There was an error when communicating with the Contentful API. |
System.ArgumentException | The entryId parameter was null or empty. |
GetLocales(CancellationToken)
Get all locales of an environment.
Declaration
Task<IEnumerable<Locale>> GetLocales(CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.Threading.CancellationToken | cancellationToken | The optional cancellation token to cancel the operation. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<Locale>> | An System.Collections.Generic.IEnumerable<T> of Locale. |
GetSpace(CancellationToken)
Gets the Space for this client.
Declaration
Task<Space> GetSpace(CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.Threading.CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Space> | The Space. |
Exceptions
Type | Condition |
---|---|
ContentfulException | There was an error when communicating with the Contentful API. |
SyncInitial(SyncType, String, CancellationToken)
Fetches an initial sync result of content. Note that this sync might not contain the entire result. If the SyncResult returned contains a NextPageUrl that means there are more resources to fetch. See also the SyncInitialRecursive(SyncType, String, CancellationToken) method.
Declaration
Task<SyncResult> SyncInitial(SyncType syncType = SyncType.All, string contentTypeId = "", CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
SyncType | syncType | The optional type of items that should be synced. |
System.String | contentTypeId | The content type ID to filter entries by. Only applicable when the syncType is Entry. |
System.Threading.CancellationToken | cancellationToken | The optional cancellation token to cancel the operation. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<SyncResult> | A SyncResult containing all synced resources. |
Exceptions
Type | Condition |
---|---|
ContentfulException | There was an error when communicating with the Contentful API. |
SyncInitialRecursive(SyncType, String, CancellationToken)
Fetches an inital sync result of content and then recursively calls the api for any further content available using the NextPageUrl. Note that this might result in multiple outgoing calls to the Contentful API. If you have a large amount of entries to sync consider using the SyncInitial(SyncType, String, CancellationToken) method in conjunction with the SyncNextResult(String, CancellationToken) method and handling each response separately.
Declaration
Task<SyncResult> SyncInitialRecursive(SyncType syncType = SyncType.All, string contentTypeId = "", CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
SyncType | syncType | The optional type of items that should be synced. |
System.String | contentTypeId | The content type ID to filter entries by. Only applicable when the syncType is Entry. |
System.Threading.CancellationToken | cancellationToken | The optional cancellation token to cancel the operation. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<SyncResult> | A SyncResult containing all synced resources. |
Exceptions
Type | Condition |
---|---|
ContentfulException | There was an error when communicating with the Contentful API. |
SyncNextResult(String, CancellationToken)
Syncs the delta changes since the last sync or the next page of an incomplete sync.
Declaration
Task<SyncResult> SyncNextResult(string nextSyncOrPageUrl, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.String | nextSyncOrPageUrl | The next page or next sync url from another SyncResult, you can either pass the entire URL or only the syncToken query string parameter. |
System.Threading.CancellationToken | cancellationToken | The optional cancellation token to cancel the operation. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<SyncResult> | A SyncResult containing all synced resources. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | The nextSyncOrPageUrl parameter was null or empty |
ContentfulException | There was an error when communicating with the Contentful API. |