Interact with the Greenative Platform Datasource API to list datasources, verify connections, and execute SQL statements.
User request: $ARGUMENTS
Manage datasources and execute SQL on the Greenative Platform. All requests are POST to $GN_ENDPOINT with a base64-encoded JSON body.
Build the authorization header from the environment variables:
AUTH=$(printf "%s:%s" "$GN_KEY" "$GN_SECRET" | base64 | tr -d '\n')
Every request must include this header: -H "Authorization: Basic $AUTH"
The JSON body must include:
component: "datasource"The JSON request body must be base64-encoded before sending. Use printf to build the JSON, pipe through base64, and pass via command substitution to curl -d:
AUTH=$(printf "%s:%s" "$GN_KEY" "$GN_SECRET" | base64 | tr -d '\n')
curl -s -X POST -H 'content-type: application/json' -H "Authorization: Basic $AUTH" \
-d "$(printf '{"component":"datasource","action":"..."}' | base64)" \
"$GN_ENDPOINT"
list)Parameters (all optional):
datasource — Filter by datasource nametype — Filter by datasource type (e.g., "oc" for Oracle, "as" for Avgidea Storage)AUTH=$(printf "%s:%s" "$GN_KEY" "$GN_SECRET" | base64 | tr -d '\n')
curl -s -X POST -H 'content-type: application/json' -H "Authorization: Basic $AUTH" \
-d "$(printf '{"component":"datasource","action":"list"}' | base64)" \
"$GN_ENDPOINT"
With filters:
AUTH=$(printf "%s:%s" "$GN_KEY" "$GN_SECRET" | base64 | tr -d '\n')
curl -s -X POST -H 'content-type: application/json' -H "Authorization: Basic $AUTH" \
-d "$(printf '{"component":"datasource","action":"list","type":"oc"}' | base64)" \
"$GN_ENDPOINT"
Response:
{
"data": [
{
"name": "ds1",
"type": "oc",
"description": "Oracle production",
"value": "connection-string",
"registeredAt": "2024-04-24T09:42:29.628Z"
}
],
"status": "success"
}
Response fields per datasource:
name — Datasource nametype — Datasource typedescription — Descriptionvalue — Connection string/valueregisteredAt — Registration timestampconnect)Parameters:
datasource (required) — Datasource name to testAUTH=$(printf "%s:%s" "$GN_KEY" "$GN_SECRET" | base64 | tr -d '\n')
curl -s -X POST -H 'content-type: application/json' -H "Authorization: Basic $AUTH" \
-d "$(printf '{"component":"datasource","action":"connect","datasource":"ds1"}' | base64)" \
"$GN_ENDPOINT"
Response:
{
"data": {
"host": "hostname",
"port": 1521,
"service": "service_name",
"type": "oc",
"uname": "username",
"value": "connection-string"
},
"status": "success"
}
execute with statement)Use the statement field for DDL (CREATE, ALTER, DROP) and DML (INSERT, UPDATE, DELETE) operations.
Parameters:
datasource (required) — Target database datasource namestatement (required) — SQL statement to executeargs (optional) — Array of bind variable values (placeholders use :1, :2, etc.)session (optional) — Database session settings object (e.g., {"NLS_DATE_FORMAT": "YYYY-MM-DD"})AUTH=$(printf "%s:%s" "$GN_KEY" "$GN_SECRET" | base64 | tr -d '\n')
curl -s -X POST -H 'content-type: application/json' -H "Authorization: Basic $AUTH" \
-d "$(printf '{"component":"datasource","action":"execute","datasource":"ds1","statement":"CREATE TABLE test (id NUMBER, name VARCHAR2(100))"}' | base64)" \
"$GN_ENDPOINT"
With bind variables:
AUTH=$(printf "%s:%s" "$GN_KEY" "$GN_SECRET" | base64 | tr -d '\n')
curl -s -X POST -H 'content-type: application/json' -H "Authorization: Basic $AUTH" \
-d "$(printf '{"component":"datasource","action":"execute","datasource":"ds1","statement":"INSERT INTO test (id, name) VALUES (:1, :2)","args":[1,"Alice"]}' | base64)" \
"$GN_ENDPOINT"
With session parameters:
AUTH=$(printf "%s:%s" "$GN_KEY" "$GN_SECRET" | base64 | tr -d '\n')
curl -s -X POST -H 'content-type: application/json' -H "Authorization: Basic $AUTH" \
-d "$(printf '{"component":"datasource","action":"execute","datasource":"ds1","statement":"INSERT INTO test (id, dt) VALUES (:1, :2)","args":[1,"2024-01-15"],"session":{"NLS_DATE_FORMAT":"YYYY-MM-DD"}}' | base64)" \
"$GN_ENDPOINT"
Response:
{"data": "Executed successfully", "status": "success"}
execute with query)Use the query field for SELECT operations. This is a different field from statement.
Parameters:
datasource (required) — Target database datasource namequery (required) — SELECT statementargs (optional) — Array of bind variable valuessession (optional) — Database session settings objectAUTH=$(printf "%s:%s" "$GN_KEY" "$GN_SECRET" | base64 | tr -d '\n')
curl -s -X POST -H 'content-type: application/json' -H "Authorization: Basic $AUTH" \
-d "$(printf '{"component":"datasource","action":"execute","datasource":"ds1","query":"SELECT id, name FROM test WHERE id = :1","args":[1]}' | base64)" \
"$GN_ENDPOINT"
Response (two-dimensional array — first row is headers):
{
"data": [
["ID", "NAME"],
[1, "Alice"],
[2, "Bob"]
],
"status": "success"
}
execute action uses statement for DDL/DML and query for SELECT — these are different field names.:1, :2 style (not ?).session parameter sets database session variables (e.g., Oracle NLS_DATE_FORMAT).list first to discover available datasources and their types.connect to verify a datasource is reachable before executing statements.