Gestalt Platform REST API Guidance

REST API Documentation

Meta REST API

Accessing Meta Resources via REST API

The Gestalt UI web application is likely the primary means for interacting with the existing resources in Meta. The actions include the standard REST actions of create, update, remove, and search.

Organization

Organizations are used to organize your other resources in Gestalt, and are typically aligned with an entity's actual organizational structure. Organizations are flexible and provide variance in how you manage resources. The primary strategy is to model your organization structure within Gestalt. It is very likely that wherever you maintain a department or team in your business, you are likely to also want policies, entitlements, workspaces, etc.

REST - GET /fqon

fqon = fully qualified organization name

Workspace

Workspaces are resources that are generally project level groupings of resources. Workspaces contain environments which is where you actually deploy containers and lambdas.

REST - GET /fqon/workspaces/uuid

uuid = unique workspace id

Environment

Environments are where the deployments actually happen. This grouping enables easier management and migration of deployments between environments for development, testing, and production. Containers and lambdas can be migrated from one environment to another, enabling a different set of providers, entitlements, users, groups, etc.

REST - GET /fqon/workspaces/wuuid/environments/euuid

wuuid = unique workspace id

euuid = unique environment id

Gestalt REST API Command Examples

# Setup httpie to cache authentication tokens

mkdir -p ~/.httpie
cat > ~/.httpie/config.json <<EOF
{
    "__meta__": {
        "about": "HTTPie configuration file",
        "help": "https://httpie.org/docs#config",
        "httpie": "0.9.8"
    },
    "default_options": [
        "--session=default"
    ]
}
EOF

Security

http -f $security/root/oauth/issue grant_type=password username=$username password=$password | jq -r .access_token

token=...

# Use with meta
http $meta/root Authorization:\"Bearer $token\""

Meta

Users

meta /root/users?expand=true

Create API Key for User

user= (uuid)
root_org= (uuid)
gestalt_url=https://(gestalt host)
api_key= ...
api_secret= ...

echo "{\"orgId\":\"$root_org\"}" | http POST $gestalt_url/security/accounts/$user/apiKeys --auth "$api_key:$api_secret"

Example:

$ echo '{"orgId":"d45b81b2-2e54-482e-b257-2bfdd50f90e3"}' | http POST $security/accounts/4c5fb6e7-c379-4e51-9bf4-7c0d5c771a2e/apiKeys --auth '4db7f01e-d91c-4b8e-8903-9ddef532e1ba:/lON8eNU4/v7VJ5gIKvbVRPoAgg8W9xssglUagaT'

Providers

Initialize Providers (admin function)

http POST $meta/root/providers/initialize

Rename a provider

echo '[{"op": "replace", "path": "/name", "value": "INT Cluster"}]' | http PATCH $meta/root/providers/9ca3e96f-dc5c-423b-aef1-ec8a919324b7

Delete a provider

http DELETE $meta/root/providers/d45cabc6-11fb-4246-a6af-31f3231f9b2b

List a provider's containers

$ http $meta/root/providers/e6954e1b-ae92-4fdf-b979-af78b4cf59ce/containers

Get all resource of type Container in root (28cbf0e0-2c48-4589-85d5-df97a3a1f318 is a magic resource type for containers)

http $meta/root/resourcetypes/28cbf0e0-2c48-4589-85d5-df97a3a1f318/resources

Get for all orgs

All orgs:

http $meta/orgs

All Meta ::Container resources:

http $meta/orgs?expand=true | jq -r '.[].properties.fqon' | xargs -I{} http GET $meta/{}/resourcetypes/28cbf0e0-2c48-4589-85d5-df97a3a1f318/resources

List provider containers

$ http $meta/root/providers | jq '.[].id' | xargs -I{} http GET $meta/root/providers/{}/containers | jq -r '.[].id'
4d24a7a1-e229-444a-adf7-f025728c8f4c
f1f0dc93-4c04-4a9d-b693-7618a705052c
5876d33f-4b4f-4513-acbb-885afd18494f
8c4e7f8c-cc41-479c-9851-b2ddafbed53c
d152a903-6089-4f3c-a340-174d95f349e4

Delete provider containers

http $meta/root/providers | jq '.[].id' \
| xargs -I{} http GET $meta/root/providers/{}/containers \
| jq -r '.[].id' | xargs -I{} http DELETE $meta/root/containers/{}

Patch a provider to add environment types

echo '[{"op": "add", "path": "/properties/environment_types", "value": ["development", "test", "production"]}]' \
 | http PATCH $meta/root/providers/d45cabc6-11fb-4246-a6af-31f3231f9b2b

Update a linked logging provider with type and typeId

echo '[{"op": "replace", "path": "/properties/linked_providers", "value": [{
    "id": "f6ed0cf7-4291-40cf-9aae-a50377a8013c",
    "name": "gestalt-logging-provider-dev",
    "type": "Gestalt::Configuration::Provider::Logging",
    "typeId": "e1782fef-4b7c-4f75-b8b8-6e6e2ecd82b2"
}]}]' \
 | http PATCH $meta/root/providers/0c5df5a5-e24b-4790-9b0e-4712c8eb98a5

Patch a provider to set linked providers to nothing []

echo '[{"op": "replace", "path": "/properties/linked_providers", "value": []}]' \
 | http PATCH $meta/root/providers/d45cabc6-11fb-4246-a6af-31f3231f9b2b

Patch a Provider ID

$ http $meta/root/providers/d45cabc6-11fb-4246-a6af-31f3231f9b2b \
| jq '.properties.services[0].container_spec.properties.provider'
{
  "id": "9ca3e96f-dc5c-423b-aef1-ec8a919324b7"
}

Lambdas

Async lambda invocation :

http $gateway/api/async < sms.event.json
HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 51
Content-Type: application/json
Date: Tue, 13 Jun 2017 13:50:28 GMT
Via: kong/0.8.0
X-Kong-Proxy-Latency: 12
X-Kong-Upstream-Latency: 16

{
    "lambdaId": "eea4335d-9e43-4b05-8618-9fb4ab1a749f"
}

Results endpoint is simply /results/:id off of the kong provider

$ http $gateway/results/eea4335d-9e43-4b05-8618-9fb4ab1a749f "Authorization:Bearer 506bc265-d822-4be6-93cc-19d9a22d93c6"
HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 184
Content-Type: application/json
Date: Tue, 13 Jun 2017 13:50:54 GMT
Via: kong/0.8.0
X-Kong-Proxy-Latency: 0
X-Kong-Upstream-Latency: 50

{
    "contentType": "text/plain",
    "executionId": "eea4335d-9e43-4b05-8618-9fb4ab1a749f",
    "executionTime": 1497361828797,
    "lambdaId": "89e70743-d184-4f1d-96d3-fa3dce554468",
    "result": "Hello Async"
}