get_resource_stats

ResourceStatsApi.get_resource_stats(role_id, from_time, to_time, type=None, _request_timeout=None, _request_auth=None, _content_type=None, _headers=None, _host_index=0)

Get resource count and cost stats

Returns daily resource counts and/or costs between from_time and to_time (inclusive of to_time). Requires system-settings.view. Sorted by EventDate descending.

Parameters:
  • role_id (str) – Amorphic role ID the request is authorized against. Must be a role the user belongs to. Also recorded in audit logs. (required)

  • from_time (str) – Range start as YYYY-MM-DD. Other formats return IPV-1070. Compared to stored EventTime/Date as the start of that day. (required)

  • to_time (str) – Range end as YYYY-MM-DD. Other formats return IPV-1070. The handler includes the full day (through 23:59:59). (required)

  • type (str) – ResourcesCount returns EventDate and ResourcesCount only. ResourcesCost returns EventDate, Unit (USD), and ResourcesCost. Omit for both on each day (Unit USD). Any other value returns 400 with no code prefix.

  • _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:

List[ResourceStatsOutputInner]

Returns:

Returns the result object.

Request and Response Examples

HTTP: GET /resource-stats

Success (HTTP 200)

Array of daily rows, newest EventDate first. Shape depends on type (see ResourceStatsOutput). Empty range is [].

type omitted (count and cost)

[
  {
    "EventDate": "2024-06-02",
    "Unit": "USD",
    "ResourcesCount": {
      "Datasets": "12",
      "Datalabs": "3"
    },
    "ResourcesCost": {
      "Jobs": 1.25,
      "Datalabs": 0,
      "Datasources": 0.4,
      "QueryEngine": 0,
      "Notifications": 0
    }
  }
]

type=ResourcesCount

[
  {
    "EventDate": "2024-06-02",
    "ResourcesCount": {
      "Datasets": "12",
      "Datalabs": "3"
    }
  }
]

type=ResourcesCost

[
  {
    "EventDate": "2024-06-02",
    "Unit": "USD",
    "ResourcesCost": {
      "Jobs": 1.25,
      "Datalabs": 0,
      "Datasources": 0.4,
      "QueryEngine": 0,
      "Notifications": 0
    }
  }
]

Errors

Documented error codes: AUTH-1001, AUTH-1003, AUTH-1030, IPV-1070, RTE-1001, EMF-1001.

HTTP 400

Validation or authorization failure. Coded errors are {“Message”: “<CODE> - <text>”}. Codes: AUTH-1001, AUTH-1003, AUTH-1030 (missing system-settings.view), IPV-1070 (from_time or to_time not YYYY-MM-DD). Invalid type is {“Message”: “Invalid ‘Type’ specified in Query String Parameters”} with no code.

Caller lacks system-settings.view

{
  "Message": "AUTH-1030 - User is not authorized to get resource stats like ResourceCount and ResourceCost due to the following missing permission(s) - {'System Settings': ['view']}"
}

from_time or to_time is not YYYY-MM-DD

{
  "Message": "IPV-1070 - Invalid parameter - from_time, please follow the following Date format, YYYY-MM-DD"
}

type is not ResourcesCount or ResourcesCost

{
  "Message": "Invalid 'Type' specified in Query String Parameters"
}

HTTP 500

GenericFailureException and InconsistentMetadataException are HTTP 500. Other uncaught errors use {“Message”: “RTE-1001 - <exception>.”} via EMF-1001. Missing queryStringParameters (null) fails this way.

Uncaught handler failure

{
  "Message": "RTE-1001 - 'NoneType' object is not subscriptable."
}