Adding Connectors to Layar
Using the LiveSource URL
Pre-Reqs
Before a document search can be done the API requests must be authenticated. Make sure you have already followed the instructions for importing dependencies and authentication from the Getting Started Guide.
Check Your Imported ModulesMake sure you have imported the
requestsandjsonmodule before proceeding with this guide.
The following header can be used in your request.
header = {'Accept': 'application/json',
'Content-Type': 'application/json',
'Authorization': f"Bearer {token}",
'X-Vyasa-Client': 'layar',
'X-Vyasa-Data-Providers' : 'sandbox.certara.ai',
'X-Vyasa-Data-Fabric' : 'YOUR_FABRIC_ID'
}Creating a New Connector Body
Before creating a new connector we will need to create an object to pass the connector type's required parameters. Create a body object and then find the required parameters for the connector type you would like to add below.
Finding ParametersRemember, you can go to
https://YOUR_ENVIRONMENT/layar/swagger-ui.htmlin order to look up required parameters.
Google BigQuery Connector
In order to add a Google BigQuery connector, you will need your BigQuery project ID and GCP Service Account Key. To find this information please follow Google's Support Documentation. Once you have these parameters, add them to your body as shown below.
body = {
'liveSourceType' : 'GBQ_PROJECT',
'name' : 'bigquery-project-id',
'description' : 'Description of your BigQuery project', #Optional
'credentials' : [{
'type' : 'service_account',
'project_id' : 'projectID',
'private_key_id' : 'keyID',
'private_key' : '--BEGIN PRIVATE KEY--\nprivate-key\n--END PRIVATE KEY--\n',
'client_email' : 'serviceAccountEmail',
'client_id' : 'clientID',
'auth_uri' : 'https://accounts.google.com/o/oauth2/auth',
'token_uri' : 'https://accounts.google.com/o/oauth2/token',
'auth_provider_x509_cert_url' : 'https://www.googleapis.com/oauth2/v1/certs',
'client_x509_cert_url' : 'https://www.googleapis.com/robot/v1/metadata/x509/service-account-email'
}]
}Adding The Connector
Once you have built out your bodyobject, you'll want to pass it to the requests.post method in order to create your new connector as shown below. The method will return a response object containing a connectorId which you will need to make sure you store in a variable for when it's time for Managing Connectors.
Response = requests.post(connectorUrl,
headers = header,
json = body)
connectorId = Response.json().get('id') #This adds the connectorId to a variable which we can use later
pprint(response) #OptionalUpdated about 1 month ago
Now that we know how to create a Connector, we can manage that connector.
