HTTP

Generate Badge From HTTP Response

Generates the badge in SVG format from response of the given HTTP URL by processing the response with the given expression to resolve badge message. In the Globadge side, the execution steps are;

  • Takes HTTP URL and expression as input

  • Calls the given HTTP URL and gets the response

  • Processes the returned result with the given expression to resolve the badge message

  • Builds the badge from given label and resolve message to return to the client in SVG format

URL

https://api.globadge.com/v1/badgen/http/{expressionType}?httpURL=<httpURL>&label=<label>&labelColor=<labelColor>&messageExpression=<messageExpression>&messageColor=<messageColor>

  • expressionType (*): The type of the expression to be used while resolving badge message from HTTP URL response by message expression. Currently, only jq expressions are supported. This parameter is passed as path parameter and it is mandatory.

  • httpURL (*): The HTTP URL to be called with GET method for getting the response which will be used to resolve badge message by message expression. This parameter is passed as query parameter and it is mandatory.

  • label (*): The text of the badge label. This parameter is passed as query parameter and it is mandatory.

  • messageExpression (*): The expression to be used for resolving badge message from the response of the HTTP URL. The expression must be valid in the context of the expression type passed as path parameter as mentioned above. Currently, only jq expressions are supported. This parameter is passed as query parameter and it is mandatory.

  • labelColor: The color of the badge label. The supported colors are listed here. This parameter is passed as query parameter and it is optional.

  • messageColor: The color of the badge message. The supported colors are listed here. This parameter is passed as query parameter and it is optional.

Method

GET

Notes

  • Given HTTP URL is called only by GET method and it is not configurable by parameters.

  • Badge responses are cached during 5 minutes. So, even if the given HTTP URL returns different result, you will get the same badge response during 5 minutes (if the link has the same message expression and label parameters)

Example

The following example gets the latest version of the OpenTelemetry AWS Lambda Collector layer from Github releases:

  • expressionType: jq

  • httpURL: https://api.github.com/repos/open-telemetry/opentelemetry-lambda/releases

  • label: Collector

  • messageExpression:

    first(.[].tag_name | select(. | startswith(\"layer-collector\"))) | split(\"/\") | .[1] | sub(\"\\\\.\"; \"_\"; \"g\")

Note: Given parameters as part of the whole URL needs to be encoded as shown below.

Create Badge HTTP Config

Creates badge HTTP config from given options in the path parameter and request body. Then returns created config id and Globadge API URL to be invoked with GET request to generate the badge from saved config.

URL

https://api.globadge.com/v1/badgen/http/{expressionType}

Method

PUT

Request

{
    // [Mandatory] HTTP URL to be invoked with GET request to get response 
    "httpURL": "<HTTP-URL>",
    // [Optional] HTTP headers in string typed key/value format 
    "httpHeaders": {
        "<HEADER-1>": "<HEADER-1-VALUE>",
        ...
        "<HEADER-N>": "<HEADER-N-VALUE>",
    },
    // [Mandatory] Label of the badge
    "label": "<LABEL>",
    // [Mandatory] The expression to be used for resolving badge message from the response of the HTTP URL
    "messageExpression": "<MESSAGE-EXPRESSION>"
}

Example Request

{
    "httpURL": "https://api.github.com/repos/open-telemetry/opentelemetry-lambda/releases",
    "httpHeaders": {
        "Authorization": "Bearer ...",
        ...
    },
    "label": "Collector",
    "messageExpression": "first(.[].tag_name | select(. | startswith(\"layer-collector\"))) | split(\"/\") | .[1] | sub(\"\\\\.\"; \"_\"; \"g\")"
}

Response

Returns created config id and Globadge API URL to generate badge from saved configs:

{
    // Id (in UUID v4 format) of the created badge HTTP config
    "id": "<HTTP-CONFIG-ID>",
    // Globadge API URL to be invoked with GET request to generate badge from saved config
    // "<EXPRESSION-TYPE>" represent the value passed in the request path parameters for the expression type
    // "<HTTP-CONFIG-ID>" represents the created config id which is returned in the "id" field in this response (above). 
    "url": "https://api.globadge.com/v1/badge/http/<EXPRESSION-TYPE>/<HTTP-CONFIG-ID>"
}

Generate Badge From HTTP Response (By Created Config)

Generates the badge in SVG format from the given created badge HTTP config here.

In the Globadge side, the execution steps are;

  • Gets the badge config (HTTP URL, HTTP headers, expression, label, etc ...) from the given config id

  • Takes HTTP URL and expression as input

  • Calls the given HTTP URL with the configured HTTP headers (if there is) and gets the response

  • Processes the returned result with the given expression to resolve the badge message

  • Builds the badge from given label and resolve message to return to the client in SVG format

URL

https://api.globadge.com/v1/badgen/http/{expressionType}/{httpConfigId}

expressionType (*): The type of the expression to be used while resolving badge message from HTTP URL response by message expression. Currently, only jq expressions are supported. This parameter is passed as path parameter and it is mandatory.

httpConfigId (*): Id (in UUID v4 format) of the created badge HTTP config here. This parameter is passed as path parameter and it is mandatory.

Method

GET

Notes

  • Given HTTP URL is called only by GET method and it is not configurable by parameters.

  • Badge responses are cached during 5 minutes. So, even if the given HTTP URL returns different result, you will get the same badge response during 5 minutes.

Example

The following example shows the latest version of the OpenTelemetry AWS Lambda Collector layer from Github releases:

  • expressionType: jq

  • httpConfigId: e3309d56-dfd6-4dae-ac00-4498070d84f0

Last updated