Sub-Task Messaging API
Safe Haven users with the LSH Data Scientist persona can use Analytic Environment's Sub-Task Messaging API to send messages based on error states. This API enables users to embed error information specifically for sub-tasks or steps within their scripts, triggering automatic alert notifications via Google Pub/Sub in alignment with their scripts.
Note
To use this feature, it must be enabled for your account and you must be given a service account. To request it, create a LiveRamp Community portal or contact your Customer Success Manager.
case in theRequest an Access Token
Use the name of the service account and password that LiveRamp provided to request a token via the following post method.
Python Example
import requests url = 'https://serviceaccounts.liveramp.com/authn/v1/oauth2/token' headers = {'Content-Type': 'application/x-www-form-urlencoded'} data = {'grant_type': 'password', 'username': '<account_id>', 'password':'<secret_key>', 'scope': 'openid', 'client_id': 'liveramp-api', 'response_type': 'token'} response = requests.post(url, headers=headers, data=data) print(response.text)
Sample Response
{ "access_token": "ey************Ag", "token_type": "Bearer", "expires_in": 1800, "scope": "liveramp-api" }
Access tokens expire quickly. See the expires_in
value for the time limit. The example above shows 30 minutes (1800 seconds). To ensure that calls to Sub-Task Messaging API are successful, set up an automated way to fetch new access tokens.
Post the Pub/Sub Message
Use the access_token to call the Sub-Task Messaging API to post the Pub/Sub message.
Python Example
import requests url = 'https://api.liveramp.com/analytics-environment/v1/job-pub-sub-messages' headers = {'Content-Type': 'application/json', 'Tenant-ID': <Target_Tenant_Id>, 'Authorization': 'Bearer <access_token>'} data = {'jobId': '<str>', 'pipeId': <int>, 'stepId': <int>, 'operationId': <int>, 'gitVersion': <str>, 'timestamp': <str>, 'stepCode': <int>, 'msgCode': <int>, 'tenantId': <int> , 'envId': <int> , 'placeholder1': <int> , 'placeholder2': <int> } requests.post(url, headers=headers, data=data)
Note
The value of the <Target_Tenant_Id> in the request header is used to verify that your service account can send the message to the pub/sub topic that is bound to the tenant ID.
Request Body Parameters
Parameter | Description |
---|---|
envId | An integer greater than 0 and less than 10 |
gitVersion | A valid Git version in v<integer>.<integer>.<integer> format, such as v1.0.0 |
jobId | A unique job ID that is prefixed with |
msgCode | An integer greater than 0 and less than 255 |
operationId | An integer greater than 0 and less than 20 |
pipeId | An integer greater than 0 |
placeholder1 | An integer greater than 0 |
placeholder2 | An integer greater than 0 |
stepCode | An integer greater than 0 and less than 10 |
stepId | An integer greater than 0 and less than 10 |
tenantId | The unique ID of your Safe Haven tenant |
timestamp | The timestamp in yyyy-MM-dd HH:mm:ss format |