send_app_usage

ManagementApi.send_app_usage(role_id, usage_metrics_for, x_source=None, send_app_usage_request=None, _request_timeout=None, _request_auth=None, _content_type=None, _headers=None, _host_index=0)

Publish CICD or SDK usage metrics

Publishes a usage payload to the usage SNS topic for CICD or SDK traffic. Requires header X-Source of cicd or sdk; other values are treated as invalid. usageMetricsFor must be cicd or sdk (exact case). There is no extra permission check. role_id is recorded in audit logs. This handler catches validation errors inside send_custom_app_usage_sns and returns HTTP 500 with GE-1008, not 400.

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

  • usage_metrics_for (str) – Which payload shape to read. cicd uses CREATE, UPDATE, UPDATE_ON_CHANGES, DELETE, IMPORT. sdk uses Action. Must match exactly. (required)

  • x_source (str) – Caller identity. Must be cicd or sdk. Compared as stored; Other values are rejected.

  • send_app_usage_request (SendAppUsageRequest)

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

SendAppUsageResponse

Returns:

Returns the result object.

Request and Response Examples

HTTP: POST /usage-metrics

Request

usageMetricsFor=cicd

{
  "CREATE": {
    "datasets": 1
  },
  "UPDATE": {},
  "UPDATE_ON_CHANGES": {},
  "DELETE": {},
  "IMPORT": {},
  "AdditionalInfo": {
    "BranchName": "main",
    "CICDVersion": "1.2.0"
  }
}

usageMetricsFor=sdk

{
  "Action": "create_dataset",
  "AdditionalInfo": {
    "SDKVersion": "2.0.0"
  }
}

Success (HTTP 200)

SNS publish succeeded. Body is Message only.

SNS publish ok

{
  "Message": "Successfully published usage info to SNS Topic."
}

Errors

Documented error codes: IPV-1052, GE-1008, EMF-1001.

HTTP 400

This POST path does not return 400 for IPV-1052. Invalid X-Source or usageMetricsFor is caught as Exception and mapped to 500 GE-1008.

Validation is returned as 500 from this Lambda

{
  "Message": "IPV-1052 - Missing mandatory parameter(s) usageMetricsFor in queryStringParameters/pathParameters"
}

HTTP 500

GE-1008 via EMF-1001. Body includes Details with the original exception text (including wrapped IPV-1052). Lambda handler catch uses the GET response builder.

Wrapped failure

{
  "Message": "GE-1008 - Could not complete the request. Please try again.",
  "Details": "IPV-1052 - Missing mandatory parameter(s) usageMetricsFor in queryStringParameters/pathParameters"
}