> Documentation index: https://www.gooddata.ai/docs/gooddata-ui/llms.txt lists every page of these docs as Markdown.

# IDataSourcesService

- Package: [@gooddata/sdk-backend-spi](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/index.md)
- Kind: interface
- Stability: alpha
- Source: https://github.com/gooddata/gooddata-ui-sdk/blob/rel/11.64/libs/sdk-backend-spi/src/dataSources/index.ts

> **Alpha API.** Initial API, highly likely to change outside SemVer. Don't build on it in production. See [API maturity](https://www.gooddata.ai/docs/gooddata-ui/latest/integrations/platform/api-maturity/index.md).
> 

Service to work with data sources

**Signature:**

```typescript
export interface IDataSourcesService 
```

## Methods

| Method | Description |
| --- | --- |
| [createDataSource(definition)](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.idatasourcesservice/index.md#idatasourcesservicecreatedatasource) | **_(ALPHA)_** Creates a data source. |
| [deleteDataSource(id)](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.idatasourcesservice/index.md#idatasourcesservicedeletedatasource) | **_(ALPHA)_** Deletes a data source. |
| [files()](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.idatasourcesservice/index.md#idatasourcesservicefiles) | **_(ALPHA)_** Returns service that can be used to manage files of data sources that keep their data in files. |
| [generateLogicalModel(dataSourceId, request)](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.idatasourcesservice/index.md#idatasourcesservicegeneratelogicalmodel) | **_(ALPHA)_** Generates a logical data model from the physical data model of a data source. |
| [getDataSource(id)](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.idatasourcesservice/index.md#idatasourcesservicegetdatasource) | **_(ALPHA)_** Returns a data source with its connection details. |
| [getDataSourceIdentifier(id)](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.idatasourcesservice/index.md#idatasourcesservicegetdatasourceidentifier) | **_(ALPHA)_** Returns the identifier of one data source, with the permissions of the current user. |
| [getDataSourceIdentifiers()](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.idatasourcesservice/index.md#idatasourcesservicegetdatasourceidentifiers) | **_(ALPHA)_** Returns data source identifiers |
| [getDataSources()](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.idatasourcesservice/index.md#idatasourcesservicegetdatasources) | **_(ALPHA)_** Returns all data sources that the current user can see, sorted by name. |
| [getSchemata(dataSourceId)](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.idatasourcesservice/index.md#idatasourcesservicegetschemata) | **_(ALPHA)_** Returns names of the schemata available in a data source. |
| [hasDataSources()](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.idatasourcesservice/index.md#idatasourcesservicehasdatasources) | **_(ALPHA)_** Checks if the current user can see at least one data source. |
| [patchDataSource(id, patch)](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.idatasourcesservice/index.md#idatasourcesservicepatchdatasource) | **_(ALPHA)_** Changes some properties of a data source. |
| [registerUploadNotification(dataSourceId)](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.idatasourcesservice/index.md#idatasourcesserviceregisteruploadnotification) | **_(ALPHA)_** Registers an upload notification for a data source. The backend then computes the reports again with the new data and drops the cached results of the data source. |
| [scan(dataSourceId, request)](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.idatasourcesservice/index.md#idatasourcesservicescan) | **_(ALPHA)_** Reads the physical data model of a data source. |
| [scanSql(dataSourceId, sql)](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.idatasourcesservice/index.md#idatasourcesservicescansql) | **_(ALPHA)_** Reads the columns of the result of an SQL statement and the first rows of the result. |
| [testConnection(connection, dataSourceId)](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.idatasourcesservice/index.md#idatasourcesservicetestconnection) | **_(ALPHA)_** Tests a connection to a data source. |
| [updateDataSource(id, definition)](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.idatasourcesservice/index.md#idatasourcesserviceupdatedatasource) | **_(ALPHA)_** Replaces a data source with a new definition. |

## Method details

### IDataSourcesService.createDataSource()

> **Alpha API.** Initial API, highly likely to change outside SemVer. Don't build on it in production. See [API maturity](https://www.gooddata.ai/docs/gooddata-ui/latest/integrations/platform/api-maturity/index.md).
> 

Creates a data source.

**Signature:**

```typescript
createDataSource(definition: IDataSourceDefinition): Promise<IDataSourceDescriptor>;
```

#### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| definition | [IDataSourceDefinition](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/sdk-model.idatasourcedefinition/index.md) | definition of the data source |

**Returns:**

Promise&lt;[IDataSourceDescriptor](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/sdk-model.idatasourcedescriptor/index.md)&gt;

### IDataSourcesService.deleteDataSource()

> **Alpha API.** Initial API, highly likely to change outside SemVer. Don't build on it in production. See [API maturity](https://www.gooddata.ai/docs/gooddata-ui/latest/integrations/platform/api-maturity/index.md).
> 

Deletes a data source.

**Signature:**

```typescript
deleteDataSource(id: string): Promise<void>;
```

#### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| id | string | identifier of the data source |

**Returns:**

Promise&lt;void&gt;

### IDataSourcesService.files()

> **Alpha API.** Initial API, highly likely to change outside SemVer. Don't build on it in production. See [API maturity](https://www.gooddata.ai/docs/gooddata-ui/latest/integrations/platform/api-maturity/index.md).
> 

Returns service that can be used to manage files of data sources that keep their data in files.

**Signature:**

```typescript
files(): IDataSourceFilesService;
```
**Returns:**

[IDataSourceFilesService](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.idatasourcefilesservice/index.md)

### IDataSourcesService.generateLogicalModel()

> **Alpha API.** Initial API, highly likely to change outside SemVer. Don't build on it in production. See [API maturity](https://www.gooddata.ai/docs/gooddata-ui/latest/integrations/platform/api-maturity/index.md).
> 

Generates a logical data model from the physical data model of a data source.

**Signature:**

```typescript
generateLogicalModel(dataSourceId: string, request: IGenerateLogicalModelRequest): Promise<IDeclarativeLogicalModel>;
```

#### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| dataSourceId | string | identifier of the data source |
| request | [IGenerateLogicalModelRequest](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/sdk-model.igeneratelogicalmodelrequest/index.md) | options of the generation |

**Returns:**

Promise&lt;[IDeclarativeLogicalModel](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/sdk-model.ideclarativelogicalmodel/index.md)&gt;

### IDataSourcesService.getDataSource()

> **Alpha API.** Initial API, highly likely to change outside SemVer. Don't build on it in production. See [API maturity](https://www.gooddata.ai/docs/gooddata-ui/latest/integrations/platform/api-maturity/index.md).
> 

Returns a data source with its connection details.

**Signature:**

```typescript
getDataSource(id: string): Promise<IDataSourceDescriptor>;
```

#### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| id | string | identifier of the data source |

**Returns:**

Promise&lt;[IDataSourceDescriptor](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/sdk-model.idatasourcedescriptor/index.md)&gt;

### IDataSourcesService.getDataSourceIdentifier()

> **Alpha API.** Initial API, highly likely to change outside SemVer. Don't build on it in production. See [API maturity](https://www.gooddata.ai/docs/gooddata-ui/latest/integrations/platform/api-maturity/index.md).
> 

Returns the identifier of one data source, with the permissions of the current user.

**Signature:**

```typescript
getDataSourceIdentifier(id: string): Promise<IDataSourceDescriptor>;
```

#### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| id | string | identifier of the data source |

**Returns:**

Promise&lt;[IDataSourceDescriptor](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/sdk-model.idatasourcedescriptor/index.md)&gt;

#### Remarks

Unlike [IDataSourcesService.getDataSource()](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-backend-spi/sdk-backend-spi.idatasourcesservice/index.md#idatasourcesservicegetdatasource), this needs only the permission to use the data source. The result has no connection details.

### IDataSourcesService.getDataSourceIdentifiers()

> **Alpha API.** Initial API, highly likely to change outside SemVer. Don't build on it in production. See [API maturity](https://www.gooddata.ai/docs/gooddata-ui/latest/integrations/platform/api-maturity/index.md).
> 

Returns data source identifiers

**Signature:**

```typescript
getDataSourceIdentifiers(): Promise<IDataSourceIdentifierDescriptor[]>;
```
**Returns:**

Promise&lt;[IDataSourceIdentifierDescriptor](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/sdk-model.idatasourceidentifierdescriptor/index.md)[]&gt;

### IDataSourcesService.getDataSources()

> **Alpha API.** Initial API, highly likely to change outside SemVer. Don't build on it in production. See [API maturity](https://www.gooddata.ai/docs/gooddata-ui/latest/integrations/platform/api-maturity/index.md).
> 

Returns all data sources that the current user can see, sorted by name.

**Signature:**

```typescript
getDataSources(): Promise<IDataSourceDescriptor[]>;
```
**Returns:**

Promise&lt;[IDataSourceDescriptor](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/sdk-model.idatasourcedescriptor/index.md)[]&gt;

#### Remarks

The result contains the permissions of the current user, but not the connection details.

### IDataSourcesService.getSchemata()

> **Alpha API.** Initial API, highly likely to change outside SemVer. Don't build on it in production. See [API maturity](https://www.gooddata.ai/docs/gooddata-ui/latest/integrations/platform/api-maturity/index.md).
> 

Returns names of the schemata available in a data source.

**Signature:**

```typescript
getSchemata(dataSourceId: string): Promise<string[]>;
```

#### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| dataSourceId | string | identifier of the data source |

**Returns:**

Promise&lt;string[]&gt;

### IDataSourcesService.hasDataSources()

> **Alpha API.** Initial API, highly likely to change outside SemVer. Don't build on it in production. See [API maturity](https://www.gooddata.ai/docs/gooddata-ui/latest/integrations/platform/api-maturity/index.md).
> 

Checks if the current user can see at least one data source.

**Signature:**

```typescript
hasDataSources(): Promise<boolean>;
```
**Returns:**

Promise&lt;boolean&gt;

false also when the backend refuses the request

### IDataSourcesService.patchDataSource()

> **Alpha API.** Initial API, highly likely to change outside SemVer. Don't build on it in production. See [API maturity](https://www.gooddata.ai/docs/gooddata-ui/latest/integrations/platform/api-maturity/index.md).
> 

Changes some properties of a data source.

**Signature:**

```typescript
patchDataSource(id: string, patch: IDataSourcePatch): Promise<IDataSourceDescriptor>;
```

#### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| id | string | identifier of the data source |
| patch | [IDataSourcePatch](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/sdk-model.idatasourcepatch/index.md) | properties to change |

**Returns:**

Promise&lt;[IDataSourceDescriptor](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/sdk-model.idatasourcedescriptor/index.md)&gt;

### IDataSourcesService.registerUploadNotification()

> **Alpha API.** Initial API, highly likely to change outside SemVer. Don't build on it in production. See [API maturity](https://www.gooddata.ai/docs/gooddata-ui/latest/integrations/platform/api-maturity/index.md).
> 

Registers an upload notification for a data source. The backend then computes the reports again with the new data and drops the cached results of the data source.

**Signature:**

```typescript
registerUploadNotification(dataSourceId: string): Promise<void>;
```

#### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| dataSourceId | string | identifier of the data source |

**Returns:**

Promise&lt;void&gt;

### IDataSourcesService.scan()

> **Alpha API.** Initial API, highly likely to change outside SemVer. Don't build on it in production. See [API maturity](https://www.gooddata.ai/docs/gooddata-ui/latest/integrations/platform/api-maturity/index.md).
> 

Reads the physical data model of a data source.

**Signature:**

```typescript
scan(dataSourceId: string, request: IDataSourceScanRequest): Promise<IDataSourceScanResult>;
```

#### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| dataSourceId | string | identifier of the data source |
| request | [IDataSourceScanRequest](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/sdk-model.idatasourcescanrequest/index.md) | options of the scan |

**Returns:**

Promise&lt;[IDataSourceScanResult](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/sdk-model.idatasourcescanresult/index.md)&gt;

### IDataSourcesService.scanSql()

> **Alpha API.** Initial API, highly likely to change outside SemVer. Don't build on it in production. See [API maturity](https://www.gooddata.ai/docs/gooddata-ui/latest/integrations/platform/api-maturity/index.md).
> 

Reads the columns of the result of an SQL statement and the first rows of the result.

**Signature:**

```typescript
scanSql(dataSourceId: string, sql: string): Promise<ISqlScanResult>;
```

#### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| dataSourceId | string | identifier of the data source |
| sql | string | the SQL statement |

**Returns:**

Promise&lt;[ISqlScanResult](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/sdk-model.isqlscanresult/index.md)&gt;

### IDataSourcesService.testConnection()

> **Alpha API.** Initial API, highly likely to change outside SemVer. Don't build on it in production. See [API maturity](https://www.gooddata.ai/docs/gooddata-ui/latest/integrations/platform/api-maturity/index.md).
> 

Tests a connection to a data source.

**Signature:**

```typescript
testConnection(connection: IDataSourceConnectionTest, dataSourceId?: string): Promise<IDataSourceConnectionTestResult>;
```

#### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| connection | [IDataSourceConnectionTest](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/sdk-model.idatasourceconnectiontest/index.md) | connection details to test |
| dataSourceId | string | _(Optional)_ identifier of a saved data source; when set, the backend uses its stored secrets for the details that the connection does not specify |

**Returns:**

Promise&lt;[IDataSourceConnectionTestResult](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/sdk-model.idatasourceconnectiontestresult/index.md)&gt;

promise that does not reject when the test fails; the result has the reason instead

### IDataSourcesService.updateDataSource()

> **Alpha API.** Initial API, highly likely to change outside SemVer. Don't build on it in production. See [API maturity](https://www.gooddata.ai/docs/gooddata-ui/latest/integrations/platform/api-maturity/index.md).
> 

Replaces a data source with a new definition.

**Signature:**

```typescript
updateDataSource(id: string, definition: IDataSourceDefinition): Promise<IDataSourceDescriptor>;
```

#### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| id | string | identifier of the data source |
| definition | [IDataSourceDefinition](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/sdk-model.idatasourcedefinition/index.md) | new definition of the data source |

**Returns:**

Promise&lt;[IDataSourceDescriptor](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/sdk-model.idatasourcedescriptor/index.md)&gt;
