run_datasource_operation¶
- DatasourcesApi.run_datasource_operation(datasource_id, role_id, action=None, schema_name=None, table_name=None, _request_timeout=None, _request_auth=None, _content_type=None, _headers=None, _host_index=0)¶
Run a read-only datasource operation
Dispatches on the action query parameter. Caller needs at least read/view on the datasource (else AUTH-1012). Safe to retry (read-only). Actions: testDatasource (jdbc, email, s3, ext-api, amorphic, arcgis — other types fail with GE-1004); getSampleData (ext-api only; other types return 200 Message); getSupportedItemTypes (arcgis only; other types return 200 Message); getSchemas, getSchemaTables, getTableMetadata (JDBC bulkdataload or advanceddataload only — otherwise the handler leaves the response unset and can fail with 500).
- Parameters:
datasource_id (str) – UUID of the datasource. Rejected with IPV-1045 if missing or unknown. (required)
role_id (str) – Amorphic role ID. Must grant at least read/view on the datasource. (required)
action (str) – Operation to run. Schema extract actions also require IngestionType bulkdataload or advanceddataload.
schema_name (str) – Required for getSchemaTables and getTableMetadata. Missing value returns IPV-1045.
table_name (str) – Required for getTableMetadata with schemaName. Missing either returns IPV-1045.
_request_timeout (int, tuple(int, int), optional) – timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts.
_request_auth (dict, optional) – set to override the auth_settings for an a single request; this effectively ignores the authentication in the spec for a single request.
_content_type (str, Optional) – force content-type for the request.
_headers (dict, optional) – set to override the headers for a single request; this effectively ignores the headers in the spec for a single request.
_host_index (int, optional) – set to override the host_index for a single request; this effectively ignores the host_index in the spec for a single request.
- Return type:
- Returns:
Returns the result object.
Request and Response Examples¶
HTTP: GET /datasources/{datasource_id}/operations
Success (HTTP 200)¶
Success response varies by action. testDatasource returns Message; getSampleData returns Status, Data, Headers, and Message for ext-api, or Message when unsupported; getSupportedItemTypes returns SupportedItemTypes for ArcGIS, or Message when unsupported; getSchemas and getSchemaTables return an array of names; and getTableMetadata returns an array of objects containing name and type.
Connection test succeeded
{
"Message": "Datasource tested successfully"
}
External API sample (hex-encoded body)
{
"Status": "success",
"Data": "7b226964223a31207d",
"Headers": {
"Content-Type": "application/json",
"Content-Length": "10",
"Status-Code": 200
},
"Message": "API response validated successfully"
}
ArcGIS supported item types
{
"SupportedItemTypes": [
{
"ItemType": "Feature Service",
"IngestionSupported": true,
"HasLayers": true
},
{
"ItemType": "Web Map",
"IngestionSupported": false,
"HasLayers": false
}
]
}
JDBC schema name list
[
"public",
"sales"
]
getSampleData on non-ext-api (still 200)
{
"Message": "Sample data retrieval not supported for jdbc datasource type"
}
Errors¶
Documented error codes: AUTH-1012, IPV-1045, GE-1004, DTSC-1007, GE-1034.
HTTP 400
Validation or authorization failure. Body is {“Message”: “<CODE> - <text>”}. Common codes: AUTH-1012 (no view access), IPV-1045 (unknown datasource, missing schemaName/tableName/action for schema extract), GE-1004 (testDatasource or getSampleData failure).
Caller lacks view access
{
"Message": "AUTH-1012 - User: user1 requires at least read-only access on the resource to perform this action."
}
Unknown datasource_id
{
"Message": "IPV-1045 - Invalid parameter - DatasourceId(b1e6c2a0-9f4d-4c7a-8f2e-1a2b3c4d5e6f), value either missing or is invalid."
}
Connection test failed
{
"Message": "GE-1004 - Failed to test datasources due to error - connection refused"
}
getSchemaTables without schemaName
{
"Message": "IPV-1045 - Invalid parameter - schemaName, value either missing or is invalid."
}
HTTP 500
Backend failure. Body is {“Message”: “<CODE> - <text>”}. Schema extract may return DTSC-1007 (bulk) or GE-1034 (advanced). Unsupported action/IngestionType combinations can surface as an unbound response (generic 500).
Schema conversion lambda failed (bulk)
{
"Message": "DTSC-1007 - Datasource operation failed with error - Failed to fetch source schema's/tables with error - connection timed out"
}