Skip to content

Microsoft SQL Server Data Source API

Audience: Data Owners

Content Summary: The mssql endpoint allows you to connect and manage Microsoft SQL Server data sources in Immuta.

Note

Additional fields may be included in some responses you receive; however, these attributes are for internal purposes and are therefore undocumented.

MSSQL Workflow

  1. Create a data source.
  2. Get information about a data source.
  3. Manage data sources.

Create a Data Source

Endpoint

Method Path Purpose
POST /mssql/handler Save the provided connection information as a data source.

Query Parameters

None.

Payload Parameters

Attribute Description Required
Private boolean When false, the data source will be publicly available in the Immuta UI. Yes
BlobHandler array[object] A list of full URLs providing the locations of all blob store handlers to use with this data source. Yes
BlobHandlerType string Describes the type of underlying blob handler that will be used with this data source (e.g., MS SQL). Yes
RecordFormat string The data format of blobs in the data source, such as json, xml, html, or jpeg. Yes
Type string The type of data source: ingested (metadata will exist in Immuta) or queryable (metadata is dynamically queried). Yes
Name string The name of the data source. It must be unique within the Immuta instance. Yes
SqlTableName string A string that represents this data source's table in the Query Engine. Yes
Organization string The organization that owns the data source. Yes
Category string The category of the data source. No
Description string The description of the data source. No
Owner array[object] Users and groups that should be added as owners to this data source. Profiles must be a list of profile IDs and groups must be a list of group IDs: { "profiles": [3, 5], "groups": [4, 1999] }. No
Expert array[object] Users and groups that should be added as expert users to this data source. Profiles must be a list of profile IDs and groups must be a list of group IDs: { "profiles": [87, 199], "groups": [324] }. No
Ingest array[object] Users and groups that should be added as ingest users to this data source. Profiles must be a list of profile IDs and groups must be a list of group IDs: { "profiles": [34, 23], "groups": [32] }. No
HasExamples boolean When true, the data source contains examples. No

Response Parameters

Attribute Description
Id integer The handler ID.
DataSourceId integer The ID of the data source.
Warnings string This message describes issues with the created data source, such as the data source being unhealthy.
ConnectionString string The connection string used to connect the data source to Immuta.

Request Example

This request creates a Microsoft SQL Server data source.

curl \
    --request POST \
    --header "Content-Type: application/json" \
    --header "Authorization: Bearer dea464c07bd07300095caa8" \
    --data @example-payload.json \
    https://demo.immuta.com/mssql/handler

Payload Example

{
  "handler": {
    "metadata": {
      "ssl": true,
      "userFiles": [],
      "port": 1433,
      "hostname": "your-demo.host.example.com",
      "database": "databasename",
      "username": "yourusername",
      "password": "yourpassword",
      "schemaProjectName": "Dbo",
      "schema": "dbo",
      "table": "MATRIX",
      "bodataSchemaName": "dbo",
      "columns": [{
        "name": "ID",
        "dataType": "int",
        "remoteType": "int",
        "isPrimaryKey": true,
        "nullable": false
      }, {
        "name": "WEEK",
        "dataType": "text",
        "remoteType": "varchar(16)",
        "nullable": true
      }, {
        "name": "ORIGINDOW",
        "dataType": "text",
        "remoteType": "varchar(16)",
        "nullable": true
      }, {
        "name": "ORIGINGAMETIME",
        "dataType": "text",
        "remoteType": "varchar(16)",
        "nullable": true
      }, {
        "name": "DESTINATIONDOW",
        "dataType": "text",
        "remoteType": "varchar(16)",
        "nullable": true
      }, {
        "name": "DESTINATIONGAMETIME",
        "dataType": "text",
        "remoteType": "varchar(16)",
        "nullable": true
      }, {
        "name": "ORIGINADDRESS",
        "dataType": "text",
        "remoteType": "varchar(200)",
        "nullable": true
      }, {
        "name": "ORIGINAWAY",
        "dataType": "text",
        "remoteType": "varchar(150)",
        "nullable": true
      }, {
        "name": "ORIGINHOME",
        "dataType": "text",
        "remoteType": "varchar(150)",
        "nullable": true
      }, {
        "name": "DESTINATIONADDRESS",
        "dataType": "text",
        "remoteType": "varchar(200)",
        "nullable": true
      }, {
        "name": "DESTINATIONAWAY",
        "dataType": "text",
        "remoteType": "varchar(150)",
        "nullable": true
      }, {
        "name": "DESTINATIONHOME",
        "dataType": "text",
        "remoteType": "varchar(150)",
        "nullable": true
      }, {
        "name": "DURATION",
        "dataType": "int",
        "remoteType": "int",
        "nullable": false
      }],
      "highCardinality": "ID",
      "staleDataTolerance": 86400,
      "bodataTableName": "matrix",
      "dataSourceName": "Matrix"
    }
  },
  "dataSource": {
    "blobHandler": {
      "scheme": "https",
      "url": ""
    },
    "expiration": "2021-11-01T03:59:59.999Z",
    "blobHandlerType": "Microsoft SQL Server",
    "recordFormat": "",
    "type": "queryable",
    "schemaEvolutionId": null,
    "columnEvolutionEnabled": true,
    "name": "Matrix",
    "sqlTableName": "matrix"
  },
  "schemaEvolution": {
    "ownerProfileId": 2,
    "config": {
      "nameTemplate": {
        "nameFormat": "<Schema> <Tablename>",
        "tableFormat": "<tablename>",
        "sqlSchemaNameFormat": "<schema>",
        "schemaProjectNameFormat": "<Schema>"
      }
    },
    "schemas": []
  }
}

Response Example

{
  "id": 21,
  "dataSourceId": 21,
  "warnings": []
}

Get Information About a Data Source

Endpoint

Method Path Purpose
GET /mssql/handler/{handlerId} Get the handler metadata associated with the provided handler ID.

Query Parameters

Attribute Description Required
HandlerID integer The ID of the handler. Yes
SkipCache boolean When true, will skip the handler cache when retrieving metadata. No

Response Parameters

Attribute Description
Body array[object] Metadata about the data source, including the data source ID, schema, database, and connection string.

Request Example

This request returns metadata for the handler with the ID 1.

curl \
    --request GET \
    --header "Content-Type: application/json" \
    --header "Authorization: Bearer dea464c07bd07300095caa8" \
    https://demo.immuta.com/mssql/handler/1

Response Example

{
  "dataSourceId": 1,
  "metadata": {
    "ssl": true,
    "port": 3306,
    "query": null,
    "table": "credit_accounts",
    "schema": "public",
    "database": "public",
    "hostname": "demo-databases.example.com",
    "username": "example",
    "eventTime": null,
    "userFiles": [],
    "dataSourceName": "Public Credit Accounts",
    "bodataTableName": "credit_accounts",
    "highCardinality": "id",
    "bodataSchemaName": "public",
    "columnsNormalized": false,
    "schemaProjectName": "Public",
    "staleDataTolerance": 86400
  },
  "type": "odbcHandler",
  "connectionString": "example@demo-databases.example.com:3306/public",
  "remoteTableDescription": "[{\"name\":\"id\",\"dataType\":\"text\",\"isPrimaryKey\":null,\"nullable\":\"YES\"},{\"name\":\"first_name\",\"dataType\":\"text\",\"isPrimaryKey\":null,\"nullable\":\"YES\"},{\"name\":\"last_name\",\"dataType\":\"text\",\"isPrimaryKey\":null,\"nullable\":\"YES\"},{\"name\":\"ssn\",\"dataType\":\"text\",\"isPrimaryKey\":null,\"nullable\":\"YES\"},{\"name\":\"email\",\"dataType\":\"text\",\"isPrimaryKey\":null,\"nullable\":\"YES\"},{\"name\":\"address_street\",\"dataType\":\"text\",\"isPrimaryKey\":null,\"nullable\":\"YES\"},{\"name\":\"address_city\",\"dataType\":\"text\",\"isPrimaryKey\":null,\"nullable\":\"YES\"},{\"name\":\"address_state\",\"dataType\":\"text\",\"isPrimaryKey\":null,\"nullable\":\"YES\"},{\"name\":\"phone_number\",\"dataType\":\"text\",\"isPrimaryKey\":null,\"nullable\":\"YES\"}]",
  "id": 1,
  "createdAt": "2021-09-09T14:12:09.412Z",
  "updatedAt": "2021-09-27T19:35:36.106Z",
  "dbms": {
    "name": "mssql"
  }
}

Manage Data Sources

Method Path Purpose
PUT /mssql/handler/{handlerId} Update the data source metadata associated with the provided handler ID. This endpoint does not perform partial updates, but will allow the dictionary to be omitted. In this case, it uses the current dictionary.
PUT /mssql/bulk Update the data source metadata associated with the provided connection string.
PUT /mssql/handler/{handlerId}/triggerHighCardinalityJob Recalculate the high cardinality column for the specified data source.

Update a Specific Data Source

Endpoint

Method Path Purpose
PUT /mssql/handler/{handlerId} Update the data source metadata associated with the provided handler ID. This endpoint does not perform partial updates, but will allow the dictionary to be omitted. In this case, it uses the current dictionary.

Query Parameters

Attribute Description Required
HandlerID integer The ID of the handler. Yes
SkipCache boolean When true, will skip the handler cache when retrieving metadata. No

Payload Parameters

Attribute Description Required
Handler metadata Includes metadata about the handler, such as ssl, port, database, hostname, username, and password. Yes
ConnectionString string The connection string used to connect to the data source. Yes

Response Parameters

Attribute Description
Id integer The ID of the handler.
Ca string The certificate authority.
Columns array[object] This is a Data Dictionary object, which provides metadata about the columns in the data source, including the name and data type of the column.

Request Example

This request updates the metadata for the data source with the handler ID 29.

curl \
    --request PUT \
    --header "Content-Type: application/json" \
    --header "Authorization: Bearer dea464c07bd07300095caa8" \
    --data @example-payload.json \
    https://demo.immuta.com/mssql/handler/29
Payload Example

The payload below updates the name of the data source to Hippa Revised.

{
  "handler": {
    "policyHandler": null,
    "dataSourceId": 29,
    "metadata": {
      "ssl": true,
      "port": 1433,
      "table": "hipaa",
      "schema": "dbo",
      "database": "database-example",
      "hostname": "demo.databases.dev-test.example.io",
      "username": "user",
      "eventTime": null,
      "userFiles": [],
      "dataSourceName": "Hipaa Revised",
      "bodataTableName": "hipaa",
      "highCardinality": "id",
      "bodataSchemaName": "dbo",
      "columnsNormalized": false,
      "schemaProjectName": "Dbo",
      "staleDataTolerance": 86400,
      "columns": [{
        "name": "firstname",
        "dataType": "text",
        "nullable": true,
        "remoteType": "varchar(255)"
      }, {
        "name": "lastname",
        "dataType": "text",
        "nullable": true,
        "remoteType": "varchar(255)"
      }, {
        "name": "bloodpressure_sys",
        "dataType": "int",
        "nullable": true,
        "remoteType": "int"
      }, {
        "name": "bloodpressure_dia",
        "dataType": "int",
        "nullable": true,
        "remoteType": "int"
      }, {
        "name": "address",
        "dataType": "text",
        "nullable": true,
        "remoteType": "varchar(255)"
      }, {
        "name": "city",
        "dataType": "text",
        "nullable": true,
        "remoteType": "varchar(255)"
      }, {
        "name": "zip",
        "dataType": "text",
        "nullable": true,
        "remoteType": "varchar(10)"
      }, {
        "name": "test_date",
        "dataType": "text",
        "nullable": true,
        "remoteType": "varchar(255)"
      }, {
        "name": "birthdate",
        "dataType": "text",
        "nullable": true,
        "remoteType": "varchar(255)"
      }, {
        "name": "income",
        "dataType": "int",
        "nullable": true,
        "remoteType": "int"
      }, {
        "name": "smoker",
        "dataType": "int",
        "nullable": true,
        "remoteType": "int"
      }, {
        "name": "id",
        "dataType": "int",
        "nullable": false,
        "remoteType": "int",
        "isPrimaryKey": true
      }, {
        "name": "personal_number",
        "dataType": "text",
        "nullable": true,
        "remoteType": "varchar(13)"
      }, {
        "name": "phone",
        "dataType": "text",
        "nullable": true,
        "remoteType": "varchar(100)"
      }]
    },
    "type": "odbcHandler",
    "connectionString": "user@edemo.databases.dev-test.example.io:1433/database-example",
    "remoteTableDescription": "[{\"name\":\"firstname\",\"isPrimaryKey\":null,\"dataType\":\"varchar(255)\",\"nullable\":\"YES\"},{\"name\":\"lastname\",\"isPrimaryKey\":null,\"dataType\":\"varchar(255)\",\"nullable\":\"YES\"},{\"name\":\"bloodpressure_sys\",\"isPrimaryKey\":null,\"dataType\":\"int\",\"nullable\":\"YES\"},{\"name\":\"bloodpressure_dia\",\"isPrimaryKey\":null,\"dataType\":\"int\",\"nullable\":\"YES\"},{\"name\":\"address\",\"isPrimaryKey\":null,\"dataType\":\"varchar(255)\",\"nullable\":\"YES\"},{\"name\":\"city\",\"isPrimaryKey\":null,\"dataType\":\"varchar(255)\",\"nullable\":\"YES\"},{\"name\":\"zip\",\"isPrimaryKey\":null,\"dataType\":\"varchar(10)\",\"nullable\":\"YES\"},{\"name\":\"test_date\",\"isPrimaryKey\":null,\"dataType\":\"varchar(255)\",\"nullable\":\"YES\"},{\"name\":\"birthdate\",\"isPrimaryKey\":null,\"dataType\":\"varchar(255)\",\"nullable\":\"YES\"},{\"name\":\"income\",\"isPrimaryKey\":null,\"dataType\":\"int\",\"nullable\":\"YES\"},{\"name\":\"smoker\",\"isPrimaryKey\":null,\"dataType\":\"int\",\"nullable\":\"YES\"},{\"name\":\"id\",\"isPrimaryKey\":1,\"dataType\":\"int\",\"nullable\":\"NO\"},{\"name\":\"personal_number\",\"isPrimaryKey\":null,\"dataType\":\"varchar(13)\",\"nullable\":\"YES\"},{\"name\":\"phone\",\"isPrimaryKey\":null,\"dataType\":\"varchar(100)\",\"nullable\":\"YES\"}]",
    "id": 29,
    "createdAt": "2021-10-01T14:23:27.996Z",
    "updatedAt": "2021-10-01T14:23:28.078Z",
    "dbms": {
      "name": "mssql"
    }
  }
}

Response Example

{
  "id": 29,
  "ca": ["-----BEGIN CERTIFICATE-----\ncertificatedata\n-----END CERTIFICATE-----"],
  "metadata": {
    "columns": [{
      "name": "firstname",
      "dataType": "text",
      "remoteType": "varchar(255)",
      "nullable": true
    }, {
      "name": "lastname",
      "dataType": "text",
      "remoteType": "varchar(255)",
      "nullable": true
    }, {
      "name": "bloodpressure_sys",
      "dataType": "int",
      "remoteType": "int",
      "nullable": true
    }, {
      "name": "bloodpressure_dia",
      "dataType": "int",
      "remoteType": "int",
      "nullable": true
    }, {
      "name": "address",
      "dataType": "text",
      "remoteType": "varchar(255)",
      "nullable": true
    }, {
      "name": "city",
      "dataType": "text",
      "remoteType": "varchar(255)",
      "nullable": true
    }, {
      "name": "zip",
      "dataType": "text",
      "remoteType": "varchar(10)",
      "nullable": true
    }, {
      "name": "test_date",
      "dataType": "text",
      "remoteType": "varchar(255)",
      "nullable": true
    }, {
      "name": "birthdate",
      "dataType": "text",
      "remoteType": "varchar(255)",
      "nullable": true
    }, {
      "name": "income",
      "dataType": "int",
      "remoteType": "int",
      "nullable": true
    }, {
      "name": "smoker",
      "dataType": "int",
      "remoteType": "int",
      "nullable": true
    }, {
      "name": "id",
      "dataType": "int",
      "remoteType": "int",
      "isPrimaryKey": true,
      "nullable": false
    }, {
      "name": "personal_number",
      "dataType": "text",
      "remoteType": "varchar(13)",
      "nullable": true
    }, {
      "name": "phone",
      "dataType": "text",
      "remoteType": "varchar(100)",
      "nullable": true
    }]
  }
}

Update Multiple Data Sources

Endpoint

Method Path Purpose
PUT /mssql/bulk Update the data source metadata associated with the provided connection string.

Query Parameters

None.

Payload Parameters

Attribute Description Required
Handler metadata Includes metadata about the handler, such as ssl, port, database, hostname, username, and password. Yes
ConnectionString string The connection string used to connect to the data sources. Yes

Response Parameters

Attribute Description
BulkId string The ID of the bulk data source update.
ConnectionString string The connection string shared by the data sources bulk updated.
JobsCreated integer The number of jobs that ran to update the data sources; this number corresponds to the number of data sources updated.

Request Example

This request updates the metadata for all data sources with the connection string specified in example-payload.json.

curl \
    --request PUT \
    --header "Content-Type: application/json" \
    --header "Authorization: Bearer dea464c07bd07300095caa8" \
    --data @example-payload.json \
    https://demo.immuta.com/mssql/bulk
Payload Example

The payload below adds a certificate (certificate.json) required to connect to the data sources.

{
  "handler": {
    "metadata": {
      "ssl": true,
      "port": 1433,
      "database": "database-example",
      "hostname": "demo.databases.dev-test.example.io",
      "username": "user",
      "userFiles": [{
        "keyName": "test",
        "filename": "a57d936d16844b091730ce3929b1f81076b808c8.json",
        "userFilename": "certificate.json"
      }],
      "password": "password"
    }
  },
  "connectionString": "demo.databases.dev-test.example.io:1433/database-example/dbo"
}

Response Example

{
  "bulkId": "bulk_ds_update_be8ddbd563f2hashedvalue5fb44e",
  "connectionString": "user@edemo.databases.dev-test.example.ioo:1433/database-example",
  "jobsCreated": 4
}

Recalculate the High Cardinality Column for a Data Source

Endpoint

Method Path Purpose
PUT /mssql/handler/{handlerId}/triggerHighCardinalityJob Recalculate the high cardinality column for the specified data source.

Query Parameters

Attribute Description Required
HandlerID integer The ID of the handler. Yes

Response Parameters

The response returns a string of characters that identify the high cardinality job run.

Request Example

This request re-runs job to calculate the high cardinality column for the data source with the handler ID 1.

curl \
    --request PUT \
    --header "Content-Type: application/json" \
    --header "Authorization: Bearer dea464c07bd07300095caa8" \
    https://demo.immuta.com/mssql/handler/1/triggerHighCardinalityJob

Response Example

6ae93070-22cd-11ec-b2b8-874838eeef05