Job Status
Description
This API can be used to know the status of a job.
NOTE: Some of our APIs return a job identifier, this API can be used to know the status of the job. The job identifier could either be a name or an integer ID.
URL
GET
/api/v1/bulk_metadata/job/?**<params>**
Replace <params> with one of the parameters mentioned in the URL parameters section.
URL Parameters
Name | Description |
---|---|
id | Use this parameter if the API you were using returns an integer job identifier. The value for this parameter is an integer ID. For Example: https://yourcompany.alation.com/api/v1/bulk_metadata/job/?id=1 NOTE: The public push QLI API returns a job id representing the job that ingests the queries. This parameter can be used to find the status of such job. |
name | Use this parameter if the API you were using returns a string job identifier i.e. a job name. The value for this parameter is a job name. For Example: https://yourcompany.alation.com/api/v1/bulk_metadata/job/?name=MetadataExtraction%231_2017-10-05-19-36-45-431906-00-00-4ea1dc02-1c9f-41db-be6f-3f7cb1849da3 NOTE: The following APIs return a job name: 1. Lineage API 2. Report Sources API 3. Update Database Technical Metadata API |
Note: It is important to URL encode the job name since most of the job names contain #.
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
{
"status": "successful",
"msg": "Job finished in 1.0 seconds at 2017-01-12 23:52:34.307327+00:00",
"result": "{\"updated_objects\": 2, \"number_received\": 2, \"error_objects\": [], \"error\": \"\"}"
}
Name | Description |
---|---|
status | Status of the job. Status can be one of the following: running - specifies that the job is not yet completed. successful - specifies that the job has been completed successfully. failed - specifies that the job has failed. |
msg | Message describing the time taken to complete the job and the timestamp of job completion |
result | Contains detailed information about the job. updated_objects - Represent the number of objects updated. number_received - Represents the number of objects received. error_objects - Contains information about any errors that might have occurred while executing the API (the one that has returned the job name) request. error - Specifies the number of errors ignored NOTE: If the job is the one returned by push QLI API, this parameter contains just the ingestion information. For Example: {"result": "Bulk Query Ingestion Succeeded: 0 new events ingested, 1 previously-ingested events skipped."} |
Error Response
Invalid Token
Status: 401 UNAUTHORIZED
Body
{
"detail": "Authentication failed"
}
Missing Token Header
Status: 401 UNAUTHORIZED
Body
{
"detail": "Authentication credentials were not provided."
}
Code Samples
cURL
#!/bin/bash
# This is an example token. Please replace this with your token.
API_TOKEN="2abcd-4c04-4c21-8692-eda27a877f90"
BASE_URL="https://alation.yourcompany.com/api/v1/bulk_metadata/job"
# Get the status of a job that is returned from 'Update Database Technical Metadata' API
curl -H "TOKEN: ${API_TOKEN}" "${BASE_URL}/?name=MetadataExtraction%231_Virtual_2017-01-12-23-52-34-272077-00-00-f11a1877-2ce7-4f6c-98e7-9bf5f8c0abf2"
# Note that the # character in the job name above is encoded with %23
# Get the status of the job returned from Lineage API
curl -H "TOKEN: ${API_TOKEN}" "${BASE_URL}/?name=bulk_api_job_2017-09-10-17-07-04-918251-00-00-386321a8-4157-453a-8cf0-a5e68641c2ea"
# Get the status of the job returned by push QLI API
curl -H "TOKEN: ${API_TOKEN}" "${BASE_URL}/?id=1"
Python
import requests
import json
# This is an example token. Please replace this with your token.
headers = {'Token': '2abcd-4c04-4c21-8692-eda27a877f90'}
BASE_URL = 'https://alation.yourcompany.com/api/v1/bulk_metadata/job'
# Add a url encoded job name
# Alernatively you can use urllib.quote(<job_name>) to urlencode the job name
job_name = "MetadataExtraction%231_Virtual_2017-01-12-23-52-34-272077-00-00-f11a1877-2ce7-4f6c-98e7-9bf5f8c0abf2"
# Get the details of a job with name
response = requests.get(BASE_URL + '/?name=' + job_name, headers=headers)
job_details = json.loads(response.text)
result = json.loads(job_details['result'])
print "Status: %s, Message: %s, Updated Objects: %s" % (job_details['status'], job_details['msg'], result['updated_objects'])
# Get the details of a job with integer identifier
response = requests.get(BASE_URL + '/?id=1', headers=headers)
job_details = json.loads(response.text)
print "Status: %s, Message: %s, Result: %s" % (job_details['status'], job_details['msg'], job_details['result'])
Sample Request and Response
Get the status of the job by its name.
URL
GET
/api/v1/bulk_metadata/job/?name=**MetadataExtraction%231_2017-10-05-19-36-45-431906-00-00-4ea1dc02-1c9f-41db-be6f-3f7cb1849da3**
Success Response
{
"status": "successful",
"msg": "Job finished in 2.0 seconds at 2017-10-05 19:36:48.374593+00:00",
"result": "{\"updated_objects\": 1, \"number_received\": 2, \"error_objects\": [\"Line 1. Key: schema_b. Datasource id in key does not match the id in the request\"], \"error\": \"1 errors were ignored\"}"
}
Get the status of the job by its integer ID.
URL
GET
/api/v1/bulk_metadata/job/?id=**1**
Success Response
{
"status": "successful",
"msg": "Job finished in 0.585993 seconds at 2017-11-30 18:59:10.445133+00:00",
"result": "Bulk Query Ingestion Succeeded: 0 new events ingested, 1 previously-ingested events skipped."
}