---
title: "Interface IDataSourcesClient"
slug: "sdk--stylelabs.m.sdk.clients.idatasourcesclient"
abstract: ""
---
# Interface IDataSourcesClient

Provides functionality to query, create and manipulate datasources.

## Namespace: StylelabsStylelabs.MSdkClients

## Assembly: Stylelabs.M.Sdk.dll

## Syntax

```csharp
public interface IDataSourcesClient
```

## Methods

### CreateAsync(IDataSource)

Creates a new datasource.

#### Declaration

```csharp
Task CreateAsync(IDataSource dataSource)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| [IDataSource](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.idatasource.html) | dataSource | The datasource to create. |

#### Returns

| Type | Description |
| --- | --- |
| Task | A representing the asynchronous operation. |

#### Exceptions

| Type | Condition |
| --- | --- |
| ValidationException | Thrown when the datasource could not be created because it is not valid. Common cases:The name of the datasource is invalid.The datasource contains hierarchical values but has type "Flat".A datasource with the specified name already exists.Not all values have an identifier.The identifiers of the values are not unique. |
| ForbiddenException | Thrown when the user is not allowed to create datasources. |

### DeleteAsync(string)

Deletes the datasource with the specified `name`.

#### Declaration

```csharp
Task DeleteAsync(string name)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| string | name | The name of the datasource to delete (case insensitive). |

#### Returns

| Type | Description |
| --- | --- |
| Task | A representing the asynchronous operation. |

#### Exceptions

| Type | Condition |
| --- | --- |
| [ForbiddenException](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.exceptions.forbiddenexception.html) | Thrown when the user is not allowed to delete the datasource. |
| [ValidationException](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.exceptions.validationexception.html) | Thrown when the datasource could not be deleted because a validation error occurred. Common case: the datasource is being used in one or more EntityDefinitions. |

### GetAllAsync()

Gets the names of all datasources that exist in the M.

#### Declaration

```csharp
Task<IList<string>> GetAllAsync()
```

#### Returns

| Type | Description |
| --- | --- |
| Task<>IList<>string | The names of all datasources that exist in M. |

### GetAsync(string)

Gets the datasource with the specified `name`.

#### Declaration

```csharp
Task<IDataSource> GetAsync(string name)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| string | name | The name of the datasource to get (case insensitive). |

#### Returns

| Type | Description |
| --- | --- |
| Task<>[IDataSource](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.idatasource.html) | The datasource with the specified `name` or null if the datasource could not be found. |

### GetManyAsync(IEnumerable<string>)

Gets the [IDataSource](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.idatasource.html) instances by the names of the option lists. The result can have a different ordering and size (when option list don't exist) than the input.

#### Declaration

```csharp
Task<IList<IDataSource>> GetManyAsync(IEnumerable<string> names)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| IEnumerable<>string | names | Option list names (case insensitive). |

#### Returns

| Type | Description |
| --- | --- |
| Task<>IList<>[IDataSource](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.idatasource.html) | Non null collection of [IDataSource](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.idatasource.html) instances. |

### GetManyCachedAsync(IEnumerable<string>)

Gets the cached [IDataSource](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.idatasource.html) instances by the names of the definitions. The result can have a different ordering and size (when option list don't exist) than the input.

#### Declaration

```csharp
Task<IList<IDataSource>> GetManyCachedAsync(IEnumerable<string> names)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| IEnumerable<>string | names | Option list names (case insensitive). |

#### Returns

| Type | Description |
| --- | --- |
| Task<>IList<>[IDataSource](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.idatasource.html) | Non null collection of [IDataSource](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.idatasource.html) instances. |

### UpdateAsync(IDataSource)

Updates a datasource.

#### Declaration

```csharp
Task UpdateAsync(IDataSource dataSource)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| [IDataSource](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.idatasource.html) | dataSource | The datasource to update. |

#### Returns

| Type | Description |
| --- | --- |
| Task | A representing the asynchronous operation. |

#### Exceptions

| Type | Condition |
| --- | --- |
| ValidationException | Thrown when the datasource could not be created because it is not valid. Common cases:The datasource contains hierarchical values but has type "Flat".Not all values have an identifier.The identifiers of the values are not unique. |
| ForbiddenException | Thrown when the user is not allowed to update datasources. |
| NotFoundException | Thrown when the datasource with the specified name could not be found. |
