Create App
https://api.datadoghq.com/api/v2/app-builder/appshttps://api.us3.datadoghq.com/api/v2/app-builder/appshttps://api.us5.datadoghq.com/api/v2/app-builder/appshttps://api.datadoghq.eu/api/v2/app-builder/appshttps://api.ap1.datadoghq.com/api/v2/app-builder/appshttps://api.ap2.datadoghq.com/api/v2/app-builder/appshttps://api.uk1.datadoghq.com/api/v2/app-builder/appshttps://api.ddog-gov.com/api/v2/app-builder/appshttps://api.us2.ddog-gov.com/api/v2/app-builder/appsOverview
Create a new app, returning the app ID. This API requires a registered application key. Alternatively, you can configure these permissions in the UI.
Request
Body Data (required)
dataThe data object containing the app definition.
attributesApp definition attributes such as name, description, and components.
componentsThe UI components that make up the app.
eventsEvents to listen for on the grid component.
nameThe triggering action for the event.
pageChange, tableRowClick, _tableRowButtonClick, change, submit, click, toggleOpen, close, open, executionFinishedtypeThe response to the event.
custom, setComponentState, triggerQuery, openModal, closeModal, openUrl, downloadFile, setStateVariableValueidThe ID of the grid component. This property is deprecated; use name to identify individual components instead.
name [required]A unique identifier for this grid component. This name is also visible in the app editor.
properties [required]Properties of a grid component.
backgroundColorThe background color of the grid.
defaultchildrenThe child components of the grid.
eventsEvents to listen for on the UI component.
nameThe triggering action for the event.
pageChange, tableRowClick, _tableRowButtonClick, change, submit, click, toggleOpen, close, open, executionFinishedtypeThe response to the event.
custom, setComponentState, triggerQuery, openModal, closeModal, openUrl, downloadFile, setStateVariableValueidThe ID of the UI component. This property is deprecated; use name to identify individual components instead.
name [required]A unique identifier for this UI component. This name is also visible in the app editor.
properties [required]Properties of a UI component. Different component types can have their own additional unique properties. See the components documentation for more detail on each component type and its properties.
childrenThe child components of the UI component.
isVisibleWhether the UI component is visible. If this is a string, it must be a valid JavaScript expression that evaluates to a boolean.
Object 1Object 2If this is a string, it must be a valid JavaScript expression that evaluates to a boolean.
type [required]The UI component type.
table, textInput, textArea, button, text, select, modal, schemaForm, checkbox, tabsShow 10 more
vegaChart, radioButtons, numberInput, fileInput, jsonInput, gridCell, dateRangePicker, search, container, calloutValueisVisibleWhether the grid component and its children are visible. If a string, it must be a valid JavaScript expression that evaluates to a boolean.
Object 1Object 2truetype [required]The grid component type.
gridgriddescriptionA human-readable description for the app.
nameThe name of the app.
queriesAn array of queries, such as external actions and state variables, that the app uses.
<type=action>An action query. This query type is used to trigger an action, such as sending a HTTP request.
eventsEvents to listen for downstream of the action query.
nameThe triggering action for the event.
pageChange, tableRowClick, _tableRowButtonClick, change, submit, click, toggleOpen, close, open, executionFinishedtypeThe response to the event.
custom, setComponentState, triggerQuery, openModal, closeModal, openUrl, downloadFile, setStateVariableValueid [required]The ID of the action query.
name [required]A unique identifier for this action query. This name is also used to access the query's result throughout the app.
properties [required]The properties of the action query.
conditionWhether to run this query. If specified, the query will only run if this condition evaluates to true in JavaScript and all other conditions are also met.
Object 1Object 2debounceInMsThe minimum time in milliseconds that must pass before the query can be triggered again. This is useful for preventing accidental double-clicks from triggering the query multiple times.
Object 1Object 2If this is a string, it must be a valid JavaScript expression that evaluates to a number.
mockedOutputsThe mocked outputs of the action query. This is useful for testing the app without actually running the action.
Object 1Object 2The mocked outputs of the action query.
enabled [required]Whether to enable the mocked outputs for testing.
Object 1Object 2If this is a string, it must be a valid JavaScript expression that evaluates to a boolean.
outputsThe mocked outputs of the action query, serialized as JSON.
onlyTriggerManuallyDetermines when this query is executed. If set to false, the query will run when the app loads and whenever any query arguments change. If set to true, the query will only run when manually triggered from elsewhere in the app.
Object 1Object 2If this is a string, it must be a valid JavaScript expression that evaluates to a boolean.
outputsThe post-query transformation function, which is a JavaScript function that changes the query's .outputs property after the query's execution.
pollingIntervalInMsIf specified, the app will poll the query at the specified interval in milliseconds. The minimum polling interval is 15 seconds. The query will only poll when the app's browser tab is active.
Object 1Object 2If this is a string, it must be a valid JavaScript expression that evaluates to a number.
requiresConfirmationWhether to prompt the user to confirm this query before it runs.
Object 1Object 2If this is a string, it must be a valid JavaScript expression that evaluates to a boolean.
showToastOnErrorWhether to display a toast to the user when the query returns an error.
Object 1Object 2If this is a string, it must be a valid JavaScript expression that evaluates to a boolean.
spec [required]The definition of the action query.
Object 1Object 2The action query spec object.
connectionGroupThe connection group to use for an action query.
idThe ID of the connection group.
tagsThe tags of the connection group.
connectionIdThe ID of the custom connection to use for this action query.
fqn [required]The fully qualified name of the action type.
inputsThe inputs to the action query. These are the values that are passed to the action when it is triggered.
Object 1Object 2The inputs to the action query. See the Actions Catalog for more detail on each action and its inputs.
type [required]The action query type.
actionaction<type=dataTransform>A data transformer, which is custom JavaScript code that executes and transforms data when its inputs change.
id [required]The ID of the data transformer.
name [required]A unique identifier for this data transformer. This name is also used to access the transformer's result throughout the app.
properties [required]The properties of the data transformer.
outputsA JavaScript function that returns the transformed data.
type [required]The data transform type.
dataTransformdataTransform<type=stateVariable>A variable, which can be set and read by other components in the app.
id [required]The ID of the state variable.
name [required]A unique identifier for this state variable. This name is also used to access the variable's value throughout the app.
properties [required]The properties of the state variable.
defaultValueThe default value of the state variable.
type [required]The state variable type.
stateVariablestateVariablerootInstanceNameThe name of the root component of the app. This must be a grid component that contains all other components.
tagsA list of tags for the app, which can be used to filter apps.
type [required]The app definition type.
appDefinitionsappDefinitions{
"data": {
"attributes": {
"components": [],
"description": "This is a simple example app",
"name": "Example App",
"queries": [],
"rootInstanceName": "grid0"
},
"type": "appDefinitions"
}
}Response
Created
The response object after a new app is successfully created, with the app ID.
dataThe data object containing the app ID.
id [required]The ID of the created app.
type [required]The app definition type.
appDefinitionsappDefinitions{
"data": {
"id": "65bb1f25-52e1-4510-9f8d-22d1516ed693",
"type": "appDefinitions"
}
}Bad Request
API error response.
errors [required]A list of errors.
detailA human-readable explanation specific to this occurrence of the error.
metaNon-standard meta-information about the error
sourceReferences to the source of the error.
headerA string indicating the name of a single request header which caused the error.
parameterA string indicating which URI query parameter caused the error.
pointerA JSON pointer to the value in the request document that caused the error.
statusStatus code of the response.
titleShort human-readable summary of the error.
{
"errors": [
{
"detail": "Missing required attribute in body",
"meta": {},
"source": {
"header": "Authorization",
"parameter": "limit",
"pointer": "/data/attributes/title"
},
"status": "400",
"title": "Bad Request"
}
]
}Forbidden
API error response.
errors [required]A list of errors.
detailA human-readable explanation specific to this occurrence of the error.
metaNon-standard meta-information about the error
sourceReferences to the source of the error.
headerA string indicating the name of a single request header which caused the error.
parameterA string indicating which URI query parameter caused the error.
pointerA JSON pointer to the value in the request document that caused the error.
statusStatus code of the response.
titleShort human-readable summary of the error.
{
"errors": [
{
"detail": "Missing required attribute in body",
"meta": {},
"source": {
"header": "Authorization",
"parameter": "limit",
"pointer": "/data/attributes/title"
},
"status": "400",
"title": "Bad Request"
}
]
}Too many requests
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Code Example
# Set your Datadog site and credentials
export DD_SITE="datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/app-builder/apps" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"components": [],
"description": "This is a simple example app",
"name": "Example App",
"queries": [],
"rootInstanceName": "grid0"
},
"type": "appDefinitions"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="us3.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/app-builder/apps" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"components": [],
"description": "This is a simple example app",
"name": "Example App",
"queries": [],
"rootInstanceName": "grid0"
},
"type": "appDefinitions"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="us5.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/app-builder/apps" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"components": [],
"description": "This is a simple example app",
"name": "Example App",
"queries": [],
"rootInstanceName": "grid0"
},
"type": "appDefinitions"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="datadoghq.eu"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/app-builder/apps" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"components": [],
"description": "This is a simple example app",
"name": "Example App",
"queries": [],
"rootInstanceName": "grid0"
},
"type": "appDefinitions"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="ap1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/app-builder/apps" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"components": [],
"description": "This is a simple example app",
"name": "Example App",
"queries": [],
"rootInstanceName": "grid0"
},
"type": "appDefinitions"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="ap2.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/app-builder/apps" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"components": [],
"description": "This is a simple example app",
"name": "Example App",
"queries": [],
"rootInstanceName": "grid0"
},
"type": "appDefinitions"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="uk1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/app-builder/apps" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"components": [],
"description": "This is a simple example app",
"name": "Example App",
"queries": [],
"rootInstanceName": "grid0"
},
"type": "appDefinitions"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/app-builder/apps" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"components": [],
"description": "This is a simple example app",
"name": "Example App",
"queries": [],
"rootInstanceName": "grid0"
},
"type": "appDefinitions"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="us2.ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/app-builder/apps" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"components": [],
"description": "This is a simple example app",
"name": "Example App",
"queries": [],
"rootInstanceName": "grid0"
},
"type": "appDefinitions"
}
}
EOF// Create App returns "Created" response
package main
import (
"context"
"encoding/json"
"fmt"
"os"
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV2"
"github.com/google/uuid"
)
func main() {
body := datadogV2.CreateAppRequest{
Data: &datadogV2.CreateAppRequestData{
Type: datadogV2.APPDEFINITIONTYPE_APPDEFINITIONS,
Attributes: &datadogV2.CreateAppRequestDataAttributes{
RootInstanceName: datadog.PtrString("grid0"),
Components: []datadogV2.ComponentGrid{
{
Name: "grid0",
Type: datadogV2.COMPONENTGRIDTYPE_GRID,
Properties: datadogV2.ComponentGridProperties{
Children: []datadogV2.Component{
{
Type: datadogV2.COMPONENTTYPE_GRIDCELL,
Name: "gridCell0",
Properties: datadogV2.ComponentProperties{
Children: []datadogV2.Component{
{
Name: "text0",
Type: datadogV2.COMPONENTTYPE_TEXT,
Properties: datadogV2.ComponentProperties{
IsVisible: &datadogV2.ComponentPropertiesIsVisible{
Bool: datadog.PtrBool(true)},
AdditionalProperties: map[string]interface{}{
"content": "# Cat Facts",
"contentType": "markdown",
"textAlign": "left",
"verticalAlign": "top",
},
},
Events: []datadogV2.AppBuilderEvent{},
},
},
IsVisible: &datadogV2.ComponentPropertiesIsVisible{
String: datadog.PtrString("true")},
AdditionalProperties: map[string]interface{}{
"layout": "{'default': {'x': 0, 'y': 0, 'width': 4, 'height': 5}}",
},
},
Events: []datadogV2.AppBuilderEvent{},
},
{
Type: datadogV2.COMPONENTTYPE_GRIDCELL,
Name: "gridCell2",
Properties: datadogV2.ComponentProperties{
Children: []datadogV2.Component{
{
Name: "table0",
Type: datadogV2.COMPONENTTYPE_TABLE,
Properties: datadogV2.ComponentProperties{
IsVisible: &datadogV2.ComponentPropertiesIsVisible{
Bool: datadog.PtrBool(true)},
AdditionalProperties: map[string]interface{}{
"data": "${fetchFacts?.outputs?.body?.data}",
"columns": "[{'dataPath': 'fact', 'header': 'fact', 'isHidden': False, 'id': '0ae2ae9e-0280-4389-83c6-1c5949f7e674'}, {'dataPath': 'length', 'header': 'length', 'isHidden': True, 'id': 'c9048611-0196-4a00-9366-1ef9e3ec0408'}, {'id': '8fa9284b-7a58-4f13-9959-57b7d8a7fe8f', 'dataPath': 'Due Date', 'header': 'Unused Old Column', 'disableSortBy': False, 'formatter': {'type': 'formatted_time', 'format': 'LARGE_WITHOUT_TIME'}, 'isDeleted': True}]",
"summary": true,
"pageSize": "${pageSize?.value}",
"paginationType": "server_side",
"isLoading": "${fetchFacts?.isLoading}",
"rowButtons": "[]",
"isWrappable": false,
"isScrollable": "vertical",
"isSubRowsEnabled": false,
"globalFilter": false,
"totalCount": "${fetchFacts?.outputs?.body?.total}",
},
},
Events: []datadogV2.AppBuilderEvent{},
},
},
IsVisible: &datadogV2.ComponentPropertiesIsVisible{
String: datadog.PtrString("true")},
AdditionalProperties: map[string]interface{}{
"layout": "{'default': {'x': 0, 'y': 5, 'width': 12, 'height': 96}}",
},
},
Events: []datadogV2.AppBuilderEvent{},
},
{
Type: datadogV2.COMPONENTTYPE_GRIDCELL,
Name: "gridCell1",
Properties: datadogV2.ComponentProperties{
Children: []datadogV2.Component{
{
Name: "text1",
Type: datadogV2.COMPONENTTYPE_TEXT,
Properties: datadogV2.ComponentProperties{
IsVisible: &datadogV2.ComponentPropertiesIsVisible{
Bool: datadog.PtrBool(true)},
AdditionalProperties: map[string]interface{}{
"content": `## Random Fact
${randomFact?.outputs?.fact}`,
"contentType": "markdown",
"textAlign": "left",
"verticalAlign": "top",
},
},
Events: []datadogV2.AppBuilderEvent{},
},
},
IsVisible: &datadogV2.ComponentPropertiesIsVisible{
String: datadog.PtrString("true")},
AdditionalProperties: map[string]interface{}{
"layout": "{'default': {'x': 0, 'y': 101, 'width': 12, 'height': 16}}",
},
},
Events: []datadogV2.AppBuilderEvent{},
},
{
Type: datadogV2.COMPONENTTYPE_GRIDCELL,
Name: "gridCell3",
Properties: datadogV2.ComponentProperties{
Children: []datadogV2.Component{
{
Name: "button0",
Type: datadogV2.COMPONENTTYPE_BUTTON,
Properties: datadogV2.ComponentProperties{
IsVisible: &datadogV2.ComponentPropertiesIsVisible{
Bool: datadog.PtrBool(true)},
AdditionalProperties: map[string]interface{}{
"label": "Increase Page Size",
"level": "default",
"isPrimary": true,
"isBorderless": false,
"isLoading": false,
"isDisabled": false,
"iconLeft": "angleUp",
"iconRight": "",
},
},
Events: []datadogV2.AppBuilderEvent{
{
Name: datadogV2.APPBUILDEREVENTNAME_CLICK.Ptr(),
Type: datadogV2.APPBUILDEREVENTTYPE_SETSTATEVARIABLEVALUE.Ptr(),
AdditionalProperties: map[string]interface{}{
"variableName": "pageSize",
"value": "${pageSize?.value + 1}",
},
},
},
},
},
IsVisible: &datadogV2.ComponentPropertiesIsVisible{
String: datadog.PtrString("true")},
AdditionalProperties: map[string]interface{}{
"layout": "{'default': {'x': 10, 'y': 134, 'width': 2, 'height': 4}}",
},
},
Events: []datadogV2.AppBuilderEvent{},
},
{
Type: datadogV2.COMPONENTTYPE_GRIDCELL,
Name: "gridCell4",
Properties: datadogV2.ComponentProperties{
Children: []datadogV2.Component{
{
Name: "button1",
Type: datadogV2.COMPONENTTYPE_BUTTON,
Properties: datadogV2.ComponentProperties{
IsVisible: &datadogV2.ComponentPropertiesIsVisible{
Bool: datadog.PtrBool(true)},
AdditionalProperties: map[string]interface{}{
"label": "Decrease Page Size",
"level": "default",
"isPrimary": true,
"isBorderless": false,
"isLoading": false,
"isDisabled": false,
"iconLeft": "angleDown",
"iconRight": "",
},
},
Events: []datadogV2.AppBuilderEvent{
{
Name: datadogV2.APPBUILDEREVENTNAME_CLICK.Ptr(),
Type: datadogV2.APPBUILDEREVENTTYPE_SETSTATEVARIABLEVALUE.Ptr(),
AdditionalProperties: map[string]interface{}{
"variableName": "pageSize",
"value": "${pageSize?.value - 1}",
},
},
},
},
},
IsVisible: &datadogV2.ComponentPropertiesIsVisible{
String: datadog.PtrString("true")},
AdditionalProperties: map[string]interface{}{
"layout": "{'default': {'x': 10, 'y': 138, 'width': 2, 'height': 4}}",
},
},
Events: []datadogV2.AppBuilderEvent{},
},
},
BackgroundColor: datadog.PtrString("default"),
},
Events: []datadogV2.AppBuilderEvent{},
},
},
Queries: []datadogV2.Query{
datadogV2.Query{
ActionQuery: &datadogV2.ActionQuery{
Id: uuid.MustParse("92ff0bb8-553b-4f31-87c7-ef5bd16d47d5"),
Type: datadogV2.ACTIONQUERYTYPE_ACTION,
Name: "fetchFacts",
Events: []datadogV2.AppBuilderEvent{},
Properties: datadogV2.ActionQueryProperties{
Spec: datadogV2.ActionQuerySpec{
ActionQuerySpecObject: &datadogV2.ActionQuerySpecObject{
Fqn: "com.datadoghq.http.request",
ConnectionId: datadog.PtrString("5e63f4a8-4ce6-47de-ba11-f6617c1d54f3"),
Inputs: &datadogV2.ActionQuerySpecInputs{
ActionQuerySpecInput: map[string]interface{}{
"verb": "GET",
"url": "https://catfact.ninja/facts",
"urlParams": "[{'key': 'limit', 'value': '${pageSize.value.toString()}'}, {'key': 'page', 'value': '${(table0.pageIndex + 1).toString()}'}]",
}},
}},
},
}},
datadogV2.Query{
StateVariable: &datadogV2.StateVariable{
Type: datadogV2.STATEVARIABLETYPE_STATEVARIABLE,
Name: "pageSize",
Properties: datadogV2.StateVariableProperties{
DefaultValue: "${20}",
},
Id: uuid.MustParse("afd03c81-4075-4432-8618-ba09d52d2f2d"),
}},
datadogV2.Query{
DataTransform: &datadogV2.DataTransform{
Type: datadogV2.DATATRANSFORMTYPE_DATATRANSFORM,
Name: "randomFact",
Properties: datadogV2.DataTransformProperties{
Outputs: datadog.PtrString(`${(() => {const facts = fetchFacts.outputs.body.data
return facts[Math.floor(Math.random()*facts.length)]
})()}`),
},
Id: uuid.MustParse("0fb22859-47dc-4137-9e41-7b67d04c525c"),
}},
},
Name: datadog.PtrString("Example Cat Facts Viewer"),
Description: datadog.PtrString("This is a slightly complicated example app that fetches and displays cat facts"),
},
},
}
ctx := datadog.NewDefaultContext(context.Background())
ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewAppBuilderApi(apiClient)
resp, r, err := api.CreateApp(ctx, body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `AppBuilderApi.CreateApp`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `AppBuilderApi.CreateApp`:\n%s\n", responseContent)
}
Instructions
First install the library and its dependencies and then save the example to main.go and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"// Create App returns "Created" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.AppBuilderApi;
import com.datadog.api.client.v2.model.ActionQuery;
import com.datadog.api.client.v2.model.ActionQueryProperties;
import com.datadog.api.client.v2.model.ActionQuerySpec;
import com.datadog.api.client.v2.model.ActionQuerySpecInputs;
import com.datadog.api.client.v2.model.ActionQuerySpecObject;
import com.datadog.api.client.v2.model.ActionQueryType;
import com.datadog.api.client.v2.model.AppBuilderEvent;
import com.datadog.api.client.v2.model.AppBuilderEventName;
import com.datadog.api.client.v2.model.AppBuilderEventType;
import com.datadog.api.client.v2.model.AppDefinitionType;
import com.datadog.api.client.v2.model.Component;
import com.datadog.api.client.v2.model.ComponentGrid;
import com.datadog.api.client.v2.model.ComponentGridProperties;
import com.datadog.api.client.v2.model.ComponentGridType;
import com.datadog.api.client.v2.model.ComponentProperties;
import com.datadog.api.client.v2.model.ComponentPropertiesIsVisible;
import com.datadog.api.client.v2.model.ComponentType;
import com.datadog.api.client.v2.model.CreateAppRequest;
import com.datadog.api.client.v2.model.CreateAppRequestData;
import com.datadog.api.client.v2.model.CreateAppRequestDataAttributes;
import com.datadog.api.client.v2.model.CreateAppResponse;
import com.datadog.api.client.v2.model.DataTransform;
import com.datadog.api.client.v2.model.DataTransformProperties;
import com.datadog.api.client.v2.model.DataTransformType;
import com.datadog.api.client.v2.model.Query;
import com.datadog.api.client.v2.model.StateVariable;
import com.datadog.api.client.v2.model.StateVariableProperties;
import com.datadog.api.client.v2.model.StateVariableType;
import java.util.Arrays;
import java.util.Collections;
import java.util.Map;
import java.util.UUID;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
AppBuilderApi apiInstance = new AppBuilderApi(defaultClient);
CreateAppRequest body =
new CreateAppRequest()
.data(
new CreateAppRequestData()
.type(AppDefinitionType.APPDEFINITIONS)
.attributes(
new CreateAppRequestDataAttributes()
.rootInstanceName("grid0")
.components(
Collections.singletonList(
new ComponentGrid()
.name("grid0")
.type(ComponentGridType.GRID)
.properties(
new ComponentGridProperties()
.children(
Arrays.asList(
new Component()
.type(ComponentType.GRIDCELL)
.name("gridCell0")
.properties(
new ComponentProperties()
.children(
Collections.singletonList(
new Component()
.name("text0")
.type(
ComponentType
.TEXT)
.properties(
new ComponentProperties()
.isVisible(
new ComponentPropertiesIsVisible(
true)))))
.isVisible(
new ComponentPropertiesIsVisible(
"true"))),
new Component()
.type(ComponentType.GRIDCELL)
.name("gridCell2")
.properties(
new ComponentProperties()
.children(
Collections.singletonList(
new Component()
.name("table0")
.type(
ComponentType
.TABLE)
.properties(
new ComponentProperties()
.isVisible(
new ComponentPropertiesIsVisible(
true)))))
.isVisible(
new ComponentPropertiesIsVisible(
"true"))),
new Component()
.type(ComponentType.GRIDCELL)
.name("gridCell1")
.properties(
new ComponentProperties()
.children(
Collections.singletonList(
new Component()
.name("text1")
.type(
ComponentType
.TEXT)
.properties(
new ComponentProperties()
.isVisible(
new ComponentPropertiesIsVisible(
true)))))
.isVisible(
new ComponentPropertiesIsVisible(
"true"))),
new Component()
.type(ComponentType.GRIDCELL)
.name("gridCell3")
.properties(
new ComponentProperties()
.children(
Collections.singletonList(
new Component()
.name("button0")
.type(
ComponentType
.BUTTON)
.properties(
new ComponentProperties()
.isVisible(
new ComponentPropertiesIsVisible(
true)))
.events(
Collections
.singletonList(
new AppBuilderEvent()
.name(
AppBuilderEventName
.CLICK)
.type(
AppBuilderEventType
.SETSTATEVARIABLEVALUE)))))
.isVisible(
new ComponentPropertiesIsVisible(
"true"))),
new Component()
.type(ComponentType.GRIDCELL)
.name("gridCell4")
.properties(
new ComponentProperties()
.children(
Collections.singletonList(
new Component()
.name("button1")
.type(
ComponentType
.BUTTON)
.properties(
new ComponentProperties()
.isVisible(
new ComponentPropertiesIsVisible(
true)))
.events(
Collections
.singletonList(
new AppBuilderEvent()
.name(
AppBuilderEventName
.CLICK)
.type(
AppBuilderEventType
.SETSTATEVARIABLEVALUE)))))
.isVisible(
new ComponentPropertiesIsVisible(
"true")))))
.backgroundColor("default"))))
.queries(
Arrays.asList(
new Query(
new ActionQuery()
.id(
UUID.fromString(
"92ff0bb8-553b-4f31-87c7-ef5bd16d47d5"))
.type(ActionQueryType.ACTION)
.name("fetchFacts")
.properties(
new ActionQueryProperties()
.spec(
new ActionQuerySpec(
new ActionQuerySpecObject()
.fqn("com.datadoghq.http.request")
.connectionId(
"5e63f4a8-4ce6-47de-ba11-f6617c1d54f3")
.inputs(
new ActionQuerySpecInputs(
Map.ofEntries(
Map.entry(
"verb", "GET"),
Map.entry(
"url",
"https://catfact.ninja/facts"),
Map.entry(
"urlParams",
"[{'key': 'limit',"
+ " 'value':"
+ " '${pageSize.value.toString()}'},"
+ " {'key':"
+ " 'page',"
+ " 'value':"
+ " '${(table0.pageIndex"
+ " + 1).toString()}'}]")))))))),
new Query(
new StateVariable()
.type(StateVariableType.STATEVARIABLE)
.name("pageSize")
.properties(
new StateVariableProperties().defaultValue("${20}"))
.id(
UUID.fromString(
"afd03c81-4075-4432-8618-ba09d52d2f2d"))),
new Query(
new DataTransform()
.type(DataTransformType.DATATRANSFORM)
.name("randomFact")
.properties(
new DataTransformProperties()
.outputs(
"""
${(() => {const facts = fetchFacts.outputs.body.data
return facts[Math.floor(Math.random()*facts.length)]
})()}
"""))
.id(
UUID.fromString(
"0fb22859-47dc-4137-9e41-7b67d04c525c")))))
.name("Example Cat Facts Viewer")
.description(
"This is a slightly complicated example app that fetches and"
+ " displays cat facts")));
try {
CreateAppResponse result = apiInstance.createApp(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling AppBuilderApi#createApp");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Instructions
First install the library and its dependencies and then save the example to Example.java and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java""""
Create App returns "Created" response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.app_builder_api import AppBuilderApi
from datadog_api_client.v2.model.action_query import ActionQuery
from datadog_api_client.v2.model.action_query_properties import ActionQueryProperties
from datadog_api_client.v2.model.action_query_spec_input import ActionQuerySpecInput
from datadog_api_client.v2.model.action_query_spec_object import ActionQuerySpecObject
from datadog_api_client.v2.model.action_query_type import ActionQueryType
from datadog_api_client.v2.model.app_builder_event import AppBuilderEvent
from datadog_api_client.v2.model.app_builder_event_name import AppBuilderEventName
from datadog_api_client.v2.model.app_builder_event_type import AppBuilderEventType
from datadog_api_client.v2.model.app_definition_type import AppDefinitionType
from datadog_api_client.v2.model.component import Component
from datadog_api_client.v2.model.component_grid import ComponentGrid
from datadog_api_client.v2.model.component_grid_properties import ComponentGridProperties
from datadog_api_client.v2.model.component_grid_type import ComponentGridType
from datadog_api_client.v2.model.component_properties import ComponentProperties
from datadog_api_client.v2.model.component_type import ComponentType
from datadog_api_client.v2.model.create_app_request import CreateAppRequest
from datadog_api_client.v2.model.create_app_request_data import CreateAppRequestData
from datadog_api_client.v2.model.create_app_request_data_attributes import CreateAppRequestDataAttributes
from datadog_api_client.v2.model.data_transform import DataTransform
from datadog_api_client.v2.model.data_transform_properties import DataTransformProperties
from datadog_api_client.v2.model.data_transform_type import DataTransformType
from datadog_api_client.v2.model.state_variable import StateVariable
from datadog_api_client.v2.model.state_variable_properties import StateVariableProperties
from datadog_api_client.v2.model.state_variable_type import StateVariableType
from uuid import UUID
body = CreateAppRequest(
data=CreateAppRequestData(
type=AppDefinitionType.APPDEFINITIONS,
attributes=CreateAppRequestDataAttributes(
root_instance_name="grid0",
components=[
ComponentGrid(
name="grid0",
type=ComponentGridType.GRID,
properties=ComponentGridProperties(
children=[
Component(
type=ComponentType.GRIDCELL,
name="gridCell0",
properties=ComponentProperties(
children=[
Component(
name="text0",
type=ComponentType.TEXT,
properties=ComponentProperties(
content="# Cat Facts",
content_type="markdown",
text_align="left",
vertical_align="top",
is_visible=True,
),
events=[],
),
],
is_visible="true",
layout=dict([("default", "{'x': 0, 'y': 0, 'width': 4, 'height': 5}")]),
),
events=[],
),
Component(
type=ComponentType.GRIDCELL,
name="gridCell2",
properties=ComponentProperties(
children=[
Component(
name="table0",
type=ComponentType.TABLE,
properties=ComponentProperties(
data="${fetchFacts?.outputs?.body?.data}",
columns=[
dict(
[
("dataPath", "fact"),
("header", "fact"),
("isHidden", "False"),
("id", "0ae2ae9e-0280-4389-83c6-1c5949f7e674"),
]
),
dict(
[
("dataPath", "length"),
("header", "length"),
("isHidden", "True"),
("id", "c9048611-0196-4a00-9366-1ef9e3ec0408"),
]
),
dict(
[
("id", "8fa9284b-7a58-4f13-9959-57b7d8a7fe8f"),
("dataPath", "Due Date"),
("header", "Unused Old Column"),
("disableSortBy", "False"),
(
"formatter",
"{'type': 'formatted_time', 'format': 'LARGE_WITHOUT_TIME'}",
),
("isDeleted", "True"),
]
),
],
summary=True,
page_size="${pageSize?.value}",
pagination_type="server_side",
is_loading="${fetchFacts?.isLoading}",
row_buttons=[],
is_wrappable=False,
is_scrollable="vertical",
is_sub_rows_enabled=False,
global_filter=False,
is_visible=True,
total_count="${fetchFacts?.outputs?.body?.total}",
),
events=[],
),
],
is_visible="true",
layout=dict([("default", "{'x': 0, 'y': 5, 'width': 12, 'height': 96}")]),
),
events=[],
),
Component(
type=ComponentType.GRIDCELL,
name="gridCell1",
properties=ComponentProperties(
children=[
Component(
name="text1",
type=ComponentType.TEXT,
properties=ComponentProperties(
content="## Random Fact\n\n${randomFact?.outputs?.fact}",
content_type="markdown",
text_align="left",
vertical_align="top",
is_visible=True,
),
events=[],
),
],
is_visible="true",
layout=dict([("default", "{'x': 0, 'y': 101, 'width': 12, 'height': 16}")]),
),
events=[],
),
Component(
type=ComponentType.GRIDCELL,
name="gridCell3",
properties=ComponentProperties(
children=[
Component(
name="button0",
type=ComponentType.BUTTON,
properties=ComponentProperties(
label="Increase Page Size",
level="default",
is_primary=True,
is_borderless=False,
is_loading=False,
is_disabled=False,
is_visible=True,
icon_left="angleUp",
icon_right="",
),
events=[
AppBuilderEvent(
variable_name="pageSize",
value="${pageSize?.value + 1}",
name=AppBuilderEventName.CLICK,
type=AppBuilderEventType.SETSTATEVARIABLEVALUE,
),
],
),
],
is_visible="true",
layout=dict([("default", "{'x': 10, 'y': 134, 'width': 2, 'height': 4}")]),
),
events=[],
),
Component(
type=ComponentType.GRIDCELL,
name="gridCell4",
properties=ComponentProperties(
children=[
Component(
name="button1",
type=ComponentType.BUTTON,
properties=ComponentProperties(
label="Decrease Page Size",
level="default",
is_primary=True,
is_borderless=False,
is_loading=False,
is_disabled=False,
is_visible=True,
icon_left="angleDown",
icon_right="",
),
events=[
AppBuilderEvent(
variable_name="pageSize",
value="${pageSize?.value - 1}",
name=AppBuilderEventName.CLICK,
type=AppBuilderEventType.SETSTATEVARIABLEVALUE,
),
],
),
],
is_visible="true",
layout=dict([("default", "{'x': 10, 'y': 138, 'width': 2, 'height': 4}")]),
),
events=[],
),
],
background_color="default",
),
events=[],
),
],
queries=[
ActionQuery(
id=UUID("92ff0bb8-553b-4f31-87c7-ef5bd16d47d5"),
type=ActionQueryType.ACTION,
name="fetchFacts",
events=[],
properties=ActionQueryProperties(
spec=ActionQuerySpecObject(
fqn="com.datadoghq.http.request",
connection_id="5e63f4a8-4ce6-47de-ba11-f6617c1d54f3",
inputs=ActionQuerySpecInput(
[
("verb", "GET"),
("url", "https://catfact.ninja/facts"),
(
"urlParams",
"[{'key': 'limit', 'value': '${pageSize.value.toString()}'}, {'key': 'page', 'value': '${(table0.pageIndex + 1).toString()}'}]",
),
]
),
),
),
),
StateVariable(
type=StateVariableType.STATEVARIABLE,
name="pageSize",
properties=StateVariableProperties(
default_value="${20}",
),
id=UUID("afd03c81-4075-4432-8618-ba09d52d2f2d"),
),
DataTransform(
type=DataTransformType.DATATRANSFORM,
name="randomFact",
properties=DataTransformProperties(
outputs="${(() => {const facts = fetchFacts.outputs.body.data\nreturn facts[Math.floor(Math.random()*facts.length)]\n})()}",
),
id=UUID("0fb22859-47dc-4137-9e41-7b67d04c525c"),
),
],
name="Example Cat Facts Viewer",
description="This is a slightly complicated example app that fetches and displays cat facts",
),
),
)
configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
api_instance = AppBuilderApi(api_client)
response = api_instance.create_app(body=body)
print(response)
Instructions
First install the library and its dependencies and then save the example to example.py and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"# Create App returns "Created" response
require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
end
api_instance = DatadogAPIClient::V2::AppBuilderAPI.new
body = DatadogAPIClient::V2::CreateAppRequest.new({
data: DatadogAPIClient::V2::CreateAppRequestData.new({
type: DatadogAPIClient::V2::AppDefinitionType::APPDEFINITIONS,
attributes: DatadogAPIClient::V2::CreateAppRequestDataAttributes.new({
root_instance_name: "grid0",
components: [
DatadogAPIClient::V2::ComponentGrid.new({
name: "grid0",
type: DatadogAPIClient::V2::ComponentGridType::GRID,
properties: DatadogAPIClient::V2::ComponentGridProperties.new({
children: [
DatadogAPIClient::V2::Component.new({
type: DatadogAPIClient::V2::ComponentType::GRIDCELL,
name: "gridCell0",
properties: DatadogAPIClient::V2::ComponentProperties.new({
children: [
DatadogAPIClient::V2::Component.new({
name: "text0",
type: DatadogAPIClient::V2::ComponentType::TEXT,
properties: DatadogAPIClient::V2::ComponentProperties.new({
is_visible: true,
}),
events: [],
}),
],
is_visible: "true",
}),
events: [],
}),
DatadogAPIClient::V2::Component.new({
type: DatadogAPIClient::V2::ComponentType::GRIDCELL,
name: "gridCell2",
properties: DatadogAPIClient::V2::ComponentProperties.new({
children: [
DatadogAPIClient::V2::Component.new({
name: "table0",
type: DatadogAPIClient::V2::ComponentType::TABLE,
properties: DatadogAPIClient::V2::ComponentProperties.new({
is_visible: true,
}),
events: [],
}),
],
is_visible: "true",
}),
events: [],
}),
DatadogAPIClient::V2::Component.new({
type: DatadogAPIClient::V2::ComponentType::GRIDCELL,
name: "gridCell1",
properties: DatadogAPIClient::V2::ComponentProperties.new({
children: [
DatadogAPIClient::V2::Component.new({
name: "text1",
type: DatadogAPIClient::V2::ComponentType::TEXT,
properties: DatadogAPIClient::V2::ComponentProperties.new({
is_visible: true,
}),
events: [],
}),
],
is_visible: "true",
}),
events: [],
}),
DatadogAPIClient::V2::Component.new({
type: DatadogAPIClient::V2::ComponentType::GRIDCELL,
name: "gridCell3",
properties: DatadogAPIClient::V2::ComponentProperties.new({
children: [
DatadogAPIClient::V2::Component.new({
name: "button0",
type: DatadogAPIClient::V2::ComponentType::BUTTON,
properties: DatadogAPIClient::V2::ComponentProperties.new({
is_visible: true,
}),
events: [
DatadogAPIClient::V2::AppBuilderEvent.new({
name: DatadogAPIClient::V2::AppBuilderEventName::CLICK,
type: DatadogAPIClient::V2::AppBuilderEventType::SETSTATEVARIABLEVALUE,
}),
],
}),
],
is_visible: "true",
}),
events: [],
}),
DatadogAPIClient::V2::Component.new({
type: DatadogAPIClient::V2::ComponentType::GRIDCELL,
name: "gridCell4",
properties: DatadogAPIClient::V2::ComponentProperties.new({
children: [
DatadogAPIClient::V2::Component.new({
name: "button1",
type: DatadogAPIClient::V2::ComponentType::BUTTON,
properties: DatadogAPIClient::V2::ComponentProperties.new({
is_visible: true,
}),
events: [
DatadogAPIClient::V2::AppBuilderEvent.new({
name: DatadogAPIClient::V2::AppBuilderEventName::CLICK,
type: DatadogAPIClient::V2::AppBuilderEventType::SETSTATEVARIABLEVALUE,
}),
],
}),
],
is_visible: "true",
}),
events: [],
}),
],
background_color: "default",
}),
events: [],
}),
],
queries: [
DatadogAPIClient::V2::ActionQuery.new({
id: "92ff0bb8-553b-4f31-87c7-ef5bd16d47d5",
type: DatadogAPIClient::V2::ActionQueryType::ACTION,
name: "fetchFacts",
events: [],
properties: DatadogAPIClient::V2::ActionQueryProperties.new({
spec: {
"fqn": "com.datadoghq.http.request", "connectionId": "5e63f4a8-4ce6-47de-ba11-f6617c1d54f3", "inputs": "{'verb': 'GET', 'url': 'https://catfact.ninja/facts', 'urlParams': [{'key': 'limit', 'value': '${pageSize.value.toString()}'}, {'key': 'page', 'value': '${(table0.pageIndex + 1).toString()}'}]}",
},
}),
}),
DatadogAPIClient::V2::StateVariable.new({
type: DatadogAPIClient::V2::StateVariableType::STATEVARIABLE,
name: "pageSize",
properties: DatadogAPIClient::V2::StateVariableProperties.new({
default_value: "${20}",
}),
id: "afd03c81-4075-4432-8618-ba09d52d2f2d",
}),
DatadogAPIClient::V2::DataTransform.new({
type: DatadogAPIClient::V2::DataTransformType::DATATRANSFORM,
name: "randomFact",
properties: DatadogAPIClient::V2::DataTransformProperties.new({
outputs: '${(() => {const facts = fetchFacts.outputs.body.data\nreturn facts[Math.floor(Math.random()*facts.length)]\n})()}',
}),
id: "0fb22859-47dc-4137-9e41-7b67d04c525c",
}),
],
name: "Example Cat Facts Viewer",
description: "This is a slightly complicated example app that fetches and displays cat facts",
}),
}),
})
p api_instance.create_app(body)
Instructions
First install the library and its dependencies and then save the example to example.rb and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"// Create App returns "Created" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_app_builder::AppBuilderAPI;
use datadog_api_client::datadogV2::model::ActionQuery;
use datadog_api_client::datadogV2::model::ActionQueryProperties;
use datadog_api_client::datadogV2::model::ActionQuerySpec;
use datadog_api_client::datadogV2::model::ActionQuerySpecInputs;
use datadog_api_client::datadogV2::model::ActionQuerySpecObject;
use datadog_api_client::datadogV2::model::ActionQueryType;
use datadog_api_client::datadogV2::model::AppBuilderEvent;
use datadog_api_client::datadogV2::model::AppBuilderEventName;
use datadog_api_client::datadogV2::model::AppBuilderEventType;
use datadog_api_client::datadogV2::model::AppDefinitionType;
use datadog_api_client::datadogV2::model::Component;
use datadog_api_client::datadogV2::model::ComponentGrid;
use datadog_api_client::datadogV2::model::ComponentGridProperties;
use datadog_api_client::datadogV2::model::ComponentGridType;
use datadog_api_client::datadogV2::model::ComponentProperties;
use datadog_api_client::datadogV2::model::ComponentPropertiesIsVisible;
use datadog_api_client::datadogV2::model::ComponentType;
use datadog_api_client::datadogV2::model::CreateAppRequest;
use datadog_api_client::datadogV2::model::CreateAppRequestData;
use datadog_api_client::datadogV2::model::CreateAppRequestDataAttributes;
use datadog_api_client::datadogV2::model::DataTransform;
use datadog_api_client::datadogV2::model::DataTransformProperties;
use datadog_api_client::datadogV2::model::DataTransformType;
use datadog_api_client::datadogV2::model::Query;
use datadog_api_client::datadogV2::model::StateVariable;
use datadog_api_client::datadogV2::model::StateVariableProperties;
use datadog_api_client::datadogV2::model::StateVariableType;
use serde_json::Value;
use std::collections::BTreeMap;
use uuid::Uuid;
#[tokio::main]
async fn main() {
let body =
CreateAppRequest
::new().data(
CreateAppRequestData::new(
AppDefinitionType::APPDEFINITIONS,
).attributes(
CreateAppRequestDataAttributes::new()
.components(
vec![
ComponentGrid::new(
"grid0".to_string(),
ComponentGridProperties::new()
.background_color("default".to_string())
.children(
vec![
Component::new(
"gridCell0".to_string(),
ComponentProperties::new()
.children(
vec![
Component::new(
"text0".to_string(),
ComponentProperties
::new().is_visible(
ComponentPropertiesIsVisible::Bool(true),
),
ComponentType::TEXT,
).events(vec![])
],
)
.is_visible(
ComponentPropertiesIsVisible::String("true".to_string()),
),
ComponentType::GRIDCELL,
).events(vec![]),
Component::new(
"gridCell2".to_string(),
ComponentProperties::new()
.children(
vec![
Component::new(
"table0".to_string(),
ComponentProperties
::new().is_visible(
ComponentPropertiesIsVisible::Bool(true),
),
ComponentType::TABLE,
).events(vec![])
],
)
.is_visible(
ComponentPropertiesIsVisible::String("true".to_string()),
),
ComponentType::GRIDCELL,
).events(vec![]),
Component::new(
"gridCell1".to_string(),
ComponentProperties::new()
.children(
vec![
Component::new(
"text1".to_string(),
ComponentProperties
::new().is_visible(
ComponentPropertiesIsVisible::Bool(true),
),
ComponentType::TEXT,
).events(vec![])
],
)
.is_visible(
ComponentPropertiesIsVisible::String("true".to_string()),
),
ComponentType::GRIDCELL,
).events(vec![]),
Component::new(
"gridCell3".to_string(),
ComponentProperties::new()
.children(
vec![
Component::new(
"button0".to_string(),
ComponentProperties
::new().is_visible(
ComponentPropertiesIsVisible::Bool(true),
),
ComponentType::BUTTON,
).events(
vec![
AppBuilderEvent::new()
.name(AppBuilderEventName::CLICK)
.type_(
AppBuilderEventType::SETSTATEVARIABLEVALUE,
)
],
)
],
)
.is_visible(
ComponentPropertiesIsVisible::String("true".to_string()),
),
ComponentType::GRIDCELL,
).events(vec![]),
Component::new(
"gridCell4".to_string(),
ComponentProperties::new()
.children(
vec![
Component::new(
"button1".to_string(),
ComponentProperties
::new().is_visible(
ComponentPropertiesIsVisible::Bool(true),
),
ComponentType::BUTTON,
).events(
vec![
AppBuilderEvent::new()
.name(AppBuilderEventName::CLICK)
.type_(
AppBuilderEventType::SETSTATEVARIABLEVALUE,
)
],
)
],
)
.is_visible(
ComponentPropertiesIsVisible::String("true".to_string()),
),
ComponentType::GRIDCELL,
).events(vec![])
],
),
ComponentGridType::GRID,
).events(vec![])
],
)
.description(
"This is a slightly complicated example app that fetches and displays cat facts".to_string(),
)
.name("Example Cat Facts Viewer".to_string())
.queries(
vec![
Query::ActionQuery(
Box::new(
ActionQuery::new(
Uuid::parse_str(
"92ff0bb8-553b-4f31-87c7-ef5bd16d47d5",
).expect("invalid UUID"),
"fetchFacts".to_string(),
ActionQueryProperties::new(
ActionQuerySpec::ActionQuerySpecObject(
Box::new(
ActionQuerySpecObject::new(
"com.datadoghq.http.request".to_string(),
)
.connection_id(
"5e63f4a8-4ce6-47de-ba11-f6617c1d54f3".to_string(),
)
.inputs(
ActionQuerySpecInputs::ActionQuerySpecInput(
BTreeMap::from(
[
("verb".to_string(), Value::from("GET")),
(
"url".to_string(),
Value::from(
"https://catfact.ninja/facts",
),
),
],
),
),
),
),
),
),
ActionQueryType::ACTION,
).events(vec![]),
),
),
Query::StateVariable(
Box::new(
StateVariable::new(
Uuid::parse_str(
"afd03c81-4075-4432-8618-ba09d52d2f2d",
).expect("invalid UUID"),
"pageSize".to_string(),
StateVariableProperties::new().default_value(Value::from("${20}")),
StateVariableType::STATEVARIABLE,
),
),
),
Query::DataTransform(
Box::new(
DataTransform::new(
Uuid::parse_str(
"0fb22859-47dc-4137-9e41-7b67d04c525c",
).expect("invalid UUID"),
"randomFact".to_string(),
DataTransformProperties
::new().outputs(
r#"${(() => {const facts = fetchFacts.outputs.body.data
return facts[Math.floor(Math.random()*facts.length)]
})()}"#.to_string(),
),
DataTransformType::DATATRANSFORM,
),
),
)
],
)
.root_instance_name("grid0".to_string()),
),
);
let configuration = datadog::Configuration::new();
let api = AppBuilderAPI::with_config(configuration);
let resp = api.create_app(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
Instructions
First install the library and its dependencies and then save the example to src/main.rs and run following commands:
DD_SITE="datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="us3.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="us5.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="datadoghq.eu" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="ap1.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="ap2.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="uk1.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="us2.ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo run/**
* Create App returns "Created" response
*/
import { client, v2 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration({
authMethods: {
AuthZ: {
accessToken: process.env.DD_BEARER_TOKEN as string,
},
},
});
const apiInstance = new v2.AppBuilderApi(configuration);
const params: v2.AppBuilderApiCreateAppRequest = {
body: {
data: {
type: "appDefinitions",
attributes: {
rootInstanceName: "grid0",
components: [
{
name: "grid0",
type: "grid",
properties: {
children: [
{
type: "gridCell",
name: "gridCell0",
properties: {
children: [
{
name: "text0",
type: "text",
properties: {
isVisible: true,
},
events: [],
},
],
isVisible: "true",
},
events: [],
},
{
type: "gridCell",
name: "gridCell2",
properties: {
children: [
{
name: "table0",
type: "table",
properties: {
isVisible: true,
},
events: [],
},
],
isVisible: "true",
},
events: [],
},
{
type: "gridCell",
name: "gridCell1",
properties: {
children: [
{
name: "text1",
type: "text",
properties: {
isVisible: true,
},
events: [],
},
],
isVisible: "true",
},
events: [],
},
{
type: "gridCell",
name: "gridCell3",
properties: {
children: [
{
name: "button0",
type: "button",
properties: {
isVisible: true,
},
events: [
{
name: "click",
type: "setStateVariableValue",
},
],
},
],
isVisible: "true",
},
events: [],
},
{
type: "gridCell",
name: "gridCell4",
properties: {
children: [
{
name: "button1",
type: "button",
properties: {
isVisible: true,
},
events: [
{
name: "click",
type: "setStateVariableValue",
},
],
},
],
isVisible: "true",
},
events: [],
},
],
backgroundColor: "default",
},
events: [],
},
],
queries: [
{
id: "92ff0bb8-553b-4f31-87c7-ef5bd16d47d5",
type: "action",
name: "fetchFacts",
events: [],
properties: {
spec: {
fqn: "com.datadoghq.http.request",
connectionId: "5e63f4a8-4ce6-47de-ba11-f6617c1d54f3",
inputs: {
verb: "GET",
url: "https://catfact.ninja/facts",
urlParams:
"[{'key': 'limit', 'value': '${pageSize.value.toString()}'}, {'key': 'page', 'value': '${(table0.pageIndex + 1).toString()}'}]",
},
},
},
},
{
type: "stateVariable",
name: "pageSize",
properties: {
defaultValue: "${20}",
},
id: "afd03c81-4075-4432-8618-ba09d52d2f2d",
},
{
type: "dataTransform",
name: "randomFact",
properties: {
outputs:
"${(() => {const facts = fetchFacts.outputs.body.data\nreturn facts[Math.floor(Math.random()*facts.length)]\n})()}",
},
id: "0fb22859-47dc-4137-9e41-7b67d04c525c",
},
],
name: "Example Cat Facts Viewer",
description:
"This is a slightly complicated example app that fetches and displays cat facts",
},
},
},
};
apiInstance
.createApp(params)
.then((data: v2.CreateAppResponse) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
Instructions
First install the library and its dependencies and then save the example to example.ts and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"