Get Schemas in a Data Source
Description
This API can be used to get a list of schemas in a data source in JSON format.
Name | Description |
---|---|
custom_fields | Custom fields like Stewards etc. |
title | Friendly title of schema. |
description | HTML description of the schema. |
id | Unique numeric schema identifier. |
url | Relative URL path to the Alation schema catalog page. |
ds_id | Unique numeric identifier of the data source. |
name | Fully qualified name of the schema in the database. For Redshift, SQL-Server, Vertica, Postgres schema name constructed as CATALOG.SCHEMA. |
NOTE: This API is available from version 3.4 and later.
URL
GET
/catalog/datasource/**<datasource_id>**/schema/?**<params>**
Replace with your list of parameters. Multiple parameters can be combined as PARAM1&PARAM2.
Replace <datasource_id> with the id of the data source which can be obtained either from the Alation URL for the data source or through Get Data Sources API.
URL Parameters
Parameters can be none, any or all of the following:
Name | Required | Description |
---|---|---|
id | No | Unique numeric ID of a schema. Used to get metadata for a specific schema. Schema ID can be obtained from Alation URL for the schema. Example: Get metadata for schema 92 in data source 9 /catalog/datasource/9/schema/?id=92 |
title | No | Get all schemas with a title. Title value is case sensitive. Example: Get all schemas titled “Retail Sales” in Data Source 9. /catalog/datasource/9/schema/?title=Retail Sales |
name | No | Get all schemas with a specific name in a datasource. name is the name of the schema in the database. TODO: Note about concatenated schema names for SQL-Server, Redshift. Example: Get metadata about schema named “retail” in data source 9. /catalog/datasource/9/schema/?name=retail |
limit | No | Limit the number of schemas returned. Example: /catalog/datasource/9/schema/?limit=10 |
skip | No | Skip a number of records and return the rest. limit and skip are used for pagination of the results. Example: /catalog/datasource/9/schema/?skip=10 |
custom_fields | No | Filter results based on Custom Field values. The general format for the filter is: /catalog/datasource/<datasource_id>/schema/?custom_fields=[,] Example Filter: Get all data sources with Jake Magner as a Steward. /catalog/datasource/<datasource_id>/schema/?custom_fields=[{"field_name":"Steward", "value":"[email protected]", "value_type":"user"}] Example Filter: Get all data sources with "Gov Council" (user group) in Stewards. /catalog/datasource/<datasource_id>/schema/?custom_fields=[{"field_name":"Steward", "value":"Gov Council", "value_type":"groupprofile"}] Example Filter: Get all data sources with Season (text field) set to Spring. /catalog/datasource/<datasource_id>/schema/?custom_fields=[{"field_name":"Season", "value":"Spring", "value_type":"text"}] |
order_by | No | Order schemas either by title or name. Example: Order schemas by title and return the first 5 results in data source 9. /catalog/datasource/9/schema/?order_by=title&limit=5 |
Headers
HTTP Header | Value |
---|---|
TOKEN | <your_token> |
Replace <your_token> with API Token which can be obtained from getToken API call (Get API Token).
Success Response
Content-Type: application/json
Status: 200 OK
Body
[
{
"custom_fields":
[
{
"value": "[email protected]",
"value_type": "user",
"field_name": "Steward"
}
],
"description": "",
"ds_id": 9,
"id": 92,
"name": "retail",
"title": "Retail Sales",
"url": "/schema/92/"
},
{
"custom_fields":
[
{
"value": "[email protected]",
"value_type": "user",
"field_name": "Steward"
},
{
"value": "[email protected]",
"value_type": "user",
"field_name": "Steward"
}
],
"description": "",
"ds_id": 9,
"id": 85,
"name": "chandra_db",
"title": "Retail Sales",
"url": "/schema/85/"
}
]
Error Response
Invalid Token
Status: 403 Forbidden
Body
{
"detail": "Authentication failed"
}
Missing Token Header
Status: 403 Forbidden
Body
{
"detail": "Authentication credentials were not provided."
}
Code Samples
cURL
#!/bin/bash
#This is an example token. Please replace this with your token.
TOKEN="3b3bf108-e631-4a26-96ba-942a68182b67"
DATASOURCE_ID=9
BASE_URL="http://test-production.alationdata.com/catalog/datasource/${DATASOURCE_ID}/schema/"
# List all the schemas in data source ID 9
curl -H "TOKEN: ${TOKEN}" "$BASE_URL"
# Get schema with ID 92 in data source ID 9
curl -H "TOKEN: ${TOKEN}" "${BASE_URL}?id=92"
# Get all schemas titled Retail Sales
curl -H "TOKEN: ${TOKEN}" "${BASE_URL}?title=Retail Sales"
# Order schemas by name, skip the first 2 and return the next 3
curl -H "TOKEN: ${TOKEN}" "${BASE_URL}?order_by=name&skip=2&limit=3"
Python
import requests
import json
#This is an example token. Please replace this with your token.
headers = {'Token': '3b3bf108-e631-4a26-96ba-942a68182b67'}
datasource_id = 9
# Get the first 10 schemas (ordered by name) from data source 9
url = 'http://test-production.alationdata.com/catalog/datasource/%s/schema/?order_by=name&limit=10' % datasource_id
req = requests.get(url, headers=headers)
schemas = json.loads(req.text)
for schema in schemas:
print ("ID: %d, Name: %s" % (schema['id'], schema['name']))