Skip to main content

Data Sources API

Data sources — cloud accounts — are managed through the REST API so you can automate onboarding and lifecycle. All calls require the x-optscale-token header (see Authentication).

List data sources

GET /restapi/v2/organizations/{organization_id}/cloud_accounts
Returns the cloud accounts connected to the organization, each with its identifier, name, type, and status. Use this to enumerate accounts before pulling cost or recommendation data.

Connect a data source

POST /restapi/v2/organizations/{organization_id}/cloud_accounts
Content-Type: application/json
Create a cloud account by supplying a name, a provider type, and a provider-specific config object. To connect Huawei Cloud, use the huawei_cnr type and provide the access key pair:
{
  "name": "Huawei Production",
  "type": "huawei_cnr",
  "config": {
    "access_key_id": "<AK>",
    "secret_access_key": "<SK>"
  }
}
KOSTRA validates the credentials during creation and, for Huawei Cloud, automatically determines the correct BSS billing endpoint. Other providers use their own type and config shape — for example, an AWS account uses AWS credentials and report settings. The response returns the created account, including the identifier you use in subsequent calls.

Get a data source

GET /restapi/v2/cloud_accounts/{id}
Returns a single cloud account by identifier, including its configuration summary and import status. Secret values are never returned.

Update a data source

PATCH /restapi/v2/cloud_accounts/{id}
Content-Type: application/json
Update mutable fields such as the account name or credentials. Provide only the fields you want to change. Rotating credentials is done here by submitting a new config; the previous secret is replaced, not merged.

Remove a data source

DELETE /restapi/v2/cloud_accounts/{id}
Disconnects the account from the organization. Use with care: removing a data source stops further imports for that account.

List resources for a data source

GET /restapi/v2/cloud_accounts/{cloud_account_id}/cloud_resources
Returns the resources KOSTRA has discovered for the account — for a Huawei Cloud account, this includes ECS instances, EVS volumes and snapshots, OBS buckets, Elastic IPs, RDS instances, load balancers, and images. Individual resources can be retrieved by identifier:
GET /restapi/v2/cloud_resources/{id}

A typical onboarding flow

  1. POST .../cloud_accounts to connect the account.
  2. Poll GET /cloud_accounts/{id} until the first import reports success.
  3. GET .../cloud_resources to confirm discovery, then pull cost and recommendation data from the other endpoint groups.