Skip to main content

RESTAction

API Group: templates.krateo.io
Kind: RESTAction
Version: v1
Scope: Namespaced

Overview

The RESTAction is a Krateo PlatformOps resource that enables users to declaratively define one or more REST API calls within Kubernetes.

It allows you to chain HTTP requests, handle dependencies between them, extract data, and use filters to process results — all through a Kubernetes-native manifest.

This approach is particularly useful for integrating external systems or Kubernetes APIs into workflows managed by Krateo PlatformOps.

RESTAction defines one or more declarative HTTP (REST) calls that can optionally depend on other calls.

It allows you to orchestrate a chain of API requests across multiple endpoints using Kubernetes resources.

A RESTAction resource declaratively defines one or more HTTP calls (spec.api) that can depend on each other.

Each call can produce a JSON response that becomes part of a shared global context, enabling subsequent calls to reference previous results using JQ expressions, iterators, and filters.

To fully leverage these advanced capabilities — such as resolving JQ expressions, using custom JQ functions or modules, and managing interdependent API calls — the RESTAction must be executed through the snowplow service endpoint (/call).

Only this endpoint implements the orchestration logic that:

  • Executes all HTTP requests defined under spec.api, respecting their declared dependencies (dependsOn).
  • Stores all API responses in a global JSON context.
  • Evaluates and resolves any JQ expressions or iterators defined within the resource.
  • Returns the computed output in the resource’s status field.

When a RESTAction is retrieved directly via Kubernetes (e.g. kubectl get restaction <name>), the resource is shown as-is, without JQ resolution or execution of any API calls.

spec

The spec field defines the configuration for the REST action workflow.

FieldTypeDescriptionRequired
apiarrayList of API requests to execute. Each item defines one HTTP call.
filterstringOptional filter to apply to the overall output or results.

spec.api[]

Defines a single HTTP request and its dependencies.

FieldTypeDescriptionRequired
namestringA unique identifier for this API call.
verbstringThe HTTP method (e.g., GET, POST, PUT, DELETE). Defaults to GET.
pathstringThe URI path of the request.
payloadstringThe request body (for methods like POST, PUT, etc.).
headersarrayArray of custom request headers to include in the request.
filterstringOptional filter to process or extract data from the response.
errorKeystringKey to identify error fields in the response.
exportJwtbooleanIf true, exports a JWT token from this request for later use.
continueOnErrorbooleanIf true, continues execution even if this call fails.
endpointRefobjectReference to a Kubernetes Endpoint object defining the target service.
dependsOnobjectDeclares a dependency on another API call defined in this spec.

spec.api[].endpointRef

Defines the reference to an Endpoint resource that this API should call.

FieldTypeDescriptionRequired
namestringName of the referenced Endpoint object.
namespacestringNamespace of the referenced Endpoint object.

spec.api[].dependsOn

Defines a dependency on another API call within the same RESTAction definition.
Useful for chaining calls where one must complete before another.

FieldTypeDescriptionRequired
namestringName of another API call in the list that this call depends on.
iteratorstringOptional field on which to iterate (used for loop-like behavior).

Example

apiVersion: templates.krateo.io/v1
kind: RESTAction
metadata:
name: example-restaction
spec:
api:
- name: get-user
endpointRef:
name: user-endpoint
namespace: default
verb: GET
path: /users
headers:
- "Authorization: Bearer $(TOKEN)"
continueOnError: false

- name: update-user
dependsOn:
name: get-user
endpointRef:
name: user-endpoint
namespace: default
verb: PUT
path: /users/123
payload: '{"status":"active"}'

filter: ""