1. Stylelabs.M.Sdk.Models.Clients

Class EntityDefinitionsClientBase

Contains functionality to get entity definitions and their entities.

Inheritance

object

EntityDefinitionsClientBase

Implements

IEntityDefinitionsClient

Namespace: StylelabsStylelabs.MSdkStylelabs.M.Sdk.ModelsClients

Assembly: Stylelabs.M.Sdk.dll

Syntax

public abstract class EntityDefinitionsClientBase : IEntityDefinitionsClient

Remarks

This client exposes a lot of methods that also have cached version. It is generally advised to use the cached variants.

Constructors

EntityDefinitionsClientBase(IMClient)

Initializes a new instance of the EntityDefinitionsClientBase class.

Declaration

protected EntityDefinitionsClientBase(IMClient client)

Parameters

TypeNameDescription
IMClientclientThe client.

Methods

CreateEntityDefinitionIdIterator(long)

Creates an iterator to iterate over all the available entity definition ids in the system. Results are ordered ascending by id.

Declaration

public IIdIterator CreateEntityDefinitionIdIterator(long pageSize = null)

Parameters

TypeNameDescription
longpageSizeThe page size.

Returns

TypeDescription
IIdIteratorAn entity definition id iterator.

CreateEntityDefinitionIterator(long)

Creates an iterator to iterate over all the available IEntityDefinition instances in the system. Results are ordered ascending by id.

Declaration

public IEntityDefinitionIterator CreateEntityDefinitionIterator(long pageSize = null)

Parameters

TypeNameDescription
longpageSizeThe page size.

Returns

TypeDescription
IEntityDefinitionIteratorAn entity definition iterator.

DeleteAsync(long)

Deletes the entity definition in Content Hub. If the entity definition doesn't exist, nothing will happen.

Declaration

public abstract Task DeleteAsync(long id)

Parameters

TypeNameDescription
longidThe id of the entity definition to delete.

Returns

TypeDescription
TaskA representing the asynchronous operation.

Exceptions

TypeCondition
ForbiddenExceptionThrown when the entity definition exists but could not be deleted.

DeleteAsync(string)

Deletes the entity definition in Content Hub. If the entity definition doesn't exist, nothing will happen.

Declaration

public abstract Task DeleteAsync(string name)

Parameters

TypeNameDescription
stringnameThe name of the entity definition to delete.

Returns

TypeDescription
TaskA representing the asynchronous operation.

Exceptions

TypeCondition
ForbiddenExceptionThrown when the entity definition exists but could not be deleted.

GetAsync(long)

Gets the IEntityDefinition instance by the specified id.

Declaration

public abstract Task<IEntityDefinition> GetAsync(long id)

Parameters

TypeNameDescription
longidEntity definition id.

Returns

TypeDescription
Task<>IEntityDefinitionThe IEntityDefinition or null if the entity definition does not exist.

GetAsync(string)

Gets the IEntityDefinition instance by the specified name.

Declaration

public abstract Task<IEntityDefinition> GetAsync(string name)

Parameters

TypeNameDescription
stringnameEntity definition name (case insensitive).

Returns

TypeDescription
Task<>IEntityDefinitionThe IEntityDefinition or null if the entity definition does not exist.

GetCachedAsync(long)

Gets the cached IEntityDefinition instance by the specified id.

Declaration

public abstract Task<IEntityDefinition> GetCachedAsync(long id)

Parameters

TypeNameDescription
longidEntity definition id.

Returns

TypeDescription
Task<>IEntityDefinitionThe IEntityDefinition or null if the entity definition does not exist.

GetCachedAsync(string)

Gets the cached IEntityDefinition instance by the specified name.

Declaration

public abstract Task<IEntityDefinition> GetCachedAsync(string name)

Parameters

TypeNameDescription
stringnameEntity definition name (case insensitive).

Returns

TypeDescription
Task<>IEntityDefinitionThe IEntityDefinition or null if the entity definition does not exist.

GetIdAsync(string)

Gets the id of the specified entity definition.

Declaration

public abstract Task<long?> GetIdAsync(string name)

Parameters

TypeNameDescription
stringnameEntity definition name (case insensitive).

Returns

TypeDescription
Task<>longThe entity definition id or null if the entity definition does not exist.

GetIdCachedAsync(string)

Gets the id of the specified cached entity definition.

Declaration

public abstract Task<long?> GetIdCachedAsync(string name)

Parameters

TypeNameDescription
stringnameEntity definition name (case insensitive).

Returns

TypeDescription
Task<>longThe entity definition id or null if the entity definition does not exist.

GetIdsAsync(IEnumerable)

Gets the entity definition ids by the names of the definitions.

Declaration

public abstract Task<IDictionary<string, long>> GetIdsAsync(IEnumerable<string> names)

Parameters

TypeNameDescription
IEnumerable<>stringnamesEntity definition names (case insensitive).

Returns

TypeDescription
Task<>IDictionary<, >stringlongNon null, case-insensitive dictionary that maps the definition names to ids.

GetIdsCachedAsync(IEnumerable)

Gets the cached entity definition ids by the names of the definitions.

Declaration

public abstract Task<IDictionary<string, long>> GetIdsCachedAsync(IEnumerable<string> names)

Parameters

TypeNameDescription
IEnumerable<>stringnamesEntity definition names (case insensitive).

Returns

TypeDescription
Task<>IDictionary<, >stringlongNon null, case-insensitive dictionary that maps the definition names to ids.

GetManyAsync(IEnumerable)

Gets the IEntityDefinition instances by the ids of the definitions. The result can have a different ordering and size (when definitions don't exist) than the input.

Declaration

public abstract Task<IList<IEntityDefinition>> GetManyAsync(IEnumerable<long> ids)

Parameters

TypeNameDescription
IEnumerable<>longidsThe ids.

Returns

TypeDescription
Task<>IList<>IEntityDefinitionNon null collection of IEntityDefinition instances.

GetManyAsync(IEnumerable)

Gets the IEntityDefinition instances by the names of the definitions. The result can have a different ordering and size (when definitions don't exist) than the input.

Declaration

public abstract Task<IList<IEntityDefinition>> GetManyAsync(IEnumerable<string> names)

Parameters

TypeNameDescription
IEnumerable<>stringnamesEntity definition names (case insensitive).

Returns

TypeDescription
Task<>IList<>IEntityDefinitionNon null collection of IEntityDefinition instances.

GetManyCachedAsync(IEnumerable)

Gets the cached IEntityDefinition instances by the ids of the definitions. The result can have a different ordering and size (when definitions don't exist) than the input.

Declaration

public abstract Task<IList<IEntityDefinition>> GetManyCachedAsync(IEnumerable<long> ids)

Parameters

TypeNameDescription
IEnumerable<>longidsThe ids.

Returns

TypeDescription
Task<>IList<>IEntityDefinitionNon null collection of IEntityDefinition instances.

GetManyCachedAsync(IEnumerable)

Gets the cached IEntityDefinition instances by the names of the definitions. The result can have a different ordering and size (when definitions don't exist) than the input.

Declaration

public abstract Task<IList<IEntityDefinition>> GetManyCachedAsync(IEnumerable<string> names)

Parameters

TypeNameDescription
IEnumerable<>stringnamesEntity definition names (case insensitive).

Returns

TypeDescription
Task<>IList<>IEntityDefinitionNon null collection of IEntityDefinition instances.

GetManyIdsAsync(IEnumerable)

Gets the entity definition ids by the names of the definitions. The ids have the same ordering as the names, except for definitions that were not found.

Declaration

public abstract Task<IList<long>> GetManyIdsAsync(IEnumerable<string> names)

Parameters

TypeNameDescription
IEnumerable<>stringnamesEntity definition names (case insensitive).

Returns

TypeDescription
Task<>IList<>longNon null collection of entity definition ids.

Remarks

It is recommended to use GetIdsAsync(IEnumerable) instead, because the mapping is much clearer.

GetNameAsync(long)

Gets the name of the IEntityDefinition with the specified id.

Declaration

public abstract Task<string> GetNameAsync(long id)

Parameters

TypeNameDescription
longidThe id of the definition to get the name of.

Returns

TypeDescription
Task<>stringThe name of the specified definition or null if it doesn't exist.

GetNameCachedAsync(long)

Gets the name of the cached IEntityDefinition with the specified id.

Declaration

public abstract Task<string> GetNameCachedAsync(long id)

Parameters

TypeNameDescription
longidThe id of the definition to get the name of.

Returns

TypeDescription
Task<>stringThe name of the specified definition or null if it doesn't exist.

GetNamesAsync(IEnumerable)

Gets the entity definition names by the ids of the definitions.

Declaration

public abstract Task<IDictionary<long, string>> GetNamesAsync(IEnumerable<long> ids)

Parameters

TypeNameDescription
IEnumerable<>longidsEntity definition ids.

Returns

TypeDescription
Task<>IDictionary<, >longstringNon null dictionary that maps the definition ids to names.

GetNamesCachedAsync(IEnumerable)

Gets the cached entity definition names by the ids of the definitions.

Declaration

public abstract Task<IDictionary<long, string>> GetNamesCachedAsync(IEnumerable<long> ids)

Parameters

TypeNameDescription
IEnumerable<>longidsEntity definition ids.

Returns

TypeDescription
Task<>IDictionary<, >longstringNon null dictionary that maps the definition ids to names.

GetRangeAsync(long, long)

Gets a set of IEntityDefinition instances in the system by specified range. Results are ordered ascending by id.

Declaration

public abstract Task<IEntityDefinitionQueryResult> GetRangeAsync(long skip = null, long take = null)

Parameters

TypeNameDescription
longskipSkip specified number of entity definitions. If no value is specified, no items will be skipped.
longtakeTake only specified number of entity definitions.

Returns

TypeDescription
Task<>IEntityDefinitionQueryResultA query result of entity definitions.

GetRangeIdsAsync(long, long)

Gets a set of entity definition ids in the system by specified range. Results are ordered ascending by id.

Declaration

public abstract Task<IIdQueryResult> GetRangeIdsAsync(long skip = null, long take = null)

Parameters

TypeNameDescription
longskipSkip specified number of entity definitions. If no value is specified, no items will be skipped.
longtakeTake only specified number of entity definitions.

Returns

TypeDescription
Task<>IIdQueryResultA query result of entity definition ids.

SaveAsync(IEntityDefinition)

Saves the entity definition in Content Hub.

Declaration

public abstract Task<long> SaveAsync(IEntityDefinition entityDefinition)

Parameters

TypeNameDescription
IEntityDefinitionentityDefinitionThe entity definition to save.

Returns

TypeDescription
Task<>longThe id of the entity definition in Content Hub.

Exceptions

TypeCondition
ValidationExceptionThrown when the entity definition could not be saved because a validation error occurred.

Implements

IEntityDefinitionsClient

If you have suggestions for improving this article, let us know!