Skip to content

Latest commit

 

History

History
314 lines (242 loc) · 7.11 KB

API.md

File metadata and controls

314 lines (242 loc) · 7.11 KB

Schema API

GET/schemas

Returns:

List containing names of available schemas.

Response body example:

[
    "exception-test",
    "poc",
    "secret-configs"
]

GET/schema/{schemaName}

Path variable:

schemaName - Name of the schema, same as the branch name.

Throws exception if requested schema doesn't exists, or is the same as master.

Returns:

SchemaControllerResponse object.

Response body example:

{
    "commitRef": "5d2e48fecf34dcac3a6a03006fd8f2013f1a2abf",
    "resources": [
          {
            "kind": "Th2Box",
            "name": "codec8",
            "spec": {
                "image-name": "ghcr.io/th2-net/th2-codec-fix",
                "image-version": "3.4.1",
                "type": "th2-codec",
                "custom-config": {
                    "codecClassName": "com.exactpro.sf.externalapi.codec.impl.ExternalFixCodecFactory"
                },
                "pins": [
                    {
                        "name": "in_codec_encode",
                        "connection-type": "mq",
                        "attributes": [
                            "encoder_in",
                            "parsed",
                            "subscribe"
                        ]
                    },
                    {
                        "name": "out_codec_decode",
                        "connection-type": "mq",
                        "attributes": [
                            "decoder_out",
                            "parsed",
                            "publish"
                        ]
                    },
                    {
                        "name": "in_codec_general_encode",
                        "connection-type": "mq",
                        "attributes": [
                            "general_encoder_in",
                            "parsed",
                            "subscribe"
                        ]
                    },
                    {
                        "name": "out_codec_general_decode",
                        "connection-type": "mq",
                        "attributes": [
                            "general_decoder_out",
                            "parsed",
                            "publish"
                        ]
                    }
                ]
            },
            "sourceHash": "d42736f7985cf01619e8b316b4d7b896815da5d344281be6c11e74de14daf330"
        }
    ]
}                  

PUT/schema/{schemaName}

Path variable:

schemaName - Name of the schema, same as the branch name.

creates a schema named {schemaName} based on master branch.

Throws exception if requested schema already exists, or is the same as master.

Returns:

SchemaControllerResponse object fot the newly created schema.

Response body example:

see the response body example above.

POST/schema/{schemaName}

Path variables:

schemaName - Name of the schema, same as the branch name.

Updates existing schema with resources provided in request body.

Throws exception if requested schema doesn't exists, or is the same as master.

Request Body:

need to provide request body of List<RequestEntry>

[
    {
        "operation": "update",
        "payload": {
            "kind": "Th2Box",
            "name": "act",
            "spec": {
                "image-name": "ghcr.io/th2-net/th2-act-template",
                "image-version": "v2.2.0-beta",
                "type": "th2-act",
                "pins": [
                    {
                        "name": "test",
                        "connection-type": "grpc",
                        "attributes": [
                            "grpc_to_verifier"
                        ]
                    }
                ],
                "prometheus": {
                    "enabled": "true"
                },
                "extended-settings": {
                    "service": {
                        "enabled": "false"
                    },
                    "envVariables": {
                        "JAVA_TOOL_OPTIONS": "-XX:+ExitOnOutOfMemoryError"
                    }
                }
            }
        }
    }
]

Returns:

SchemaControllerResponse object fot the newly updated schema.

Response body example:

see the response body example above.

Subscription API

GET/subscriptions/schema/{schemaName}

Path variables:

schemaName - Name of the schema, same as the branch name.

Starts a subscription on requested schema.

Returns:

SseEmitter object.

Descriptor API

GET/descriptor/{schema}/{kind}/{box}

Path variables:

schema - Name of the schema, same as the branch name.

kind - Kind of the box as defined in Th2 kinds enum: Th2CoreBox, Th2Mstore, Th2Estore, Th2Box

box - Name of the resource

Returns:

value of protobuf-description-base64 label for specified box.

Response body examples:

case 1: protobuf-description-base64 is present in box manifest and has non-null value

{
"descriptor": "protobuf-description-base64",
"content": "eyJncnBjLWNoZWNrMS0yLjIuMS5qYXIiOnsidGgyX2dycGNfY2hlY2sx ...... "
}

case 2: protobuf-description-base64 is NOT present in box manifest or has null value

Response body is empty, with 204 No Content response code.

Secrets API

/secrets/** are accessible for users with admin role only. Please look at the README for http configuration to configure admin users.

GET/secrets/{schema}

Returns:

Set containing names of keys of custom secrets in specified schema.

Response body example:

CURL example:

curl -u "admin:password" 'http://my-cluster:30000/editor/backend/secrets/my-schema'

["cassandraPassword"]

If there are two keys in custom secrets file of this schema

[
    "key1",
    "key2"
]

PUT/secrets/{schema}

Request Body:

[
   {
    "key": "key1",
    "data": "dXBkYXRlZHZhbHVl"
   },
   {
    "key": "key2",
    "data":"c29tZS1zZWNyZXQtdmFsdWU="
   }
]

Returns:

Set containing names of created/updated keys.

Response body example:

[
    "key1",
    "key2"
]

CURL example:

curl curl -X PUT 'http://my-cluster:30000/editor/backend/secrets/my-schema' -u "admin:password" -H 'Content-Type: application/json' -d '[{"key":"key1","data":"dXBkYXRlZHZhbHVl","key":"key2","data":"c29tZS1zZWNyZXQtdmFsdWU="}]'

DELETE/secrets/{schema}

RequestBody:

[
    "key1"
]

Deletes key from custom secrets file of specified namespace

Returns:

List containing names of deleted keys.

Response body example:

[
    "key1"
]

Namespace API

/namespace/** endpoints are accessible for users with admin role only. Please look at the README for http configuration to configure admin users.

DELETE/namespace/{schema}

Deletes Kubernetes namespace related to schema if related git branch is deleted or spec.k8s-propagation: deny

Returns:

Name of deleted Kubernetes namespace.

Response body example: th2-my-schema

CURL example: curl -X DELETE 'http://my-cluster:30000/editor/backend/namespace/my-schema' -u "admin:password"