Update App Protection Level

PATCH https://api.ap1.datadoghq.com/api/v2/app-builder/apps/{app_id}/protection-levelhttps://api.ap2.datadoghq.com/api/v2/app-builder/apps/{app_id}/protection-levelhttps://api.datadoghq.eu/api/v2/app-builder/apps/{app_id}/protection-levelhttps://api.ddog-gov.com/api/v2/app-builder/apps/{app_id}/protection-levelhttps://api.us2.ddog-gov.com/api/v2/app-builder/apps/{app_id}/protection-levelhttps://api.datadoghq.com/api/v2/app-builder/apps/{app_id}/protection-levelhttps://api.us3.datadoghq.com/api/v2/app-builder/apps/{app_id}/protection-levelhttps://api.us5.datadoghq.com/api/v2/app-builder/apps/{app_id}/protection-level

Overview

Update the publication protection level of an app. When set to approval_required, future publishes must go through an approval workflow before going live. This endpoint requires the apps_write permission.

Arguments

Path Parameters

Name

Type

Description

app_id [required]

string

The ID of the app.

Request

Body Data (required)

Expand All

Field

Type

Description

data

object

Data for updating an app's publication protection level.

attributes

object

Attributes for updating an app's publication protection level.

protectionLevel [required]

enum

The publication protection level of the app. approval_required means changes must go through an approval workflow before being published. Allowed enum values: direct_publish,approval_required

type

enum

The protection-level resource type. Allowed enum values: protectionLevel

default: protectionLevel

{
  "data": {
    "attributes": {
      "protectionLevel": "approval_required"
    },
    "type": "protectionLevel"
  }
}

Response

OK

The response object after an app is successfully updated.

Expand All

Field

Type

Description

data

object

The data object containing the updated app definition.

attributes [required]

object

The updated app definition attributes, such as name, description, and components.

components

[object]

The UI components that make up the app.

events

[object]

Events to listen for on the grid component.

name

enum

The triggering action for the event. Allowed enum values: pageChange,tableRowClick,_tableRowButtonClick,change,submit,click,toggleOpen,close,open,executionFinished

type

enum

The response to the event. Allowed enum values: custom,setComponentState,triggerQuery,openModal,closeModal,openUrl,downloadFile,setStateVariableValue

id

string

The ID of the grid component. This property is deprecated; use name to identify individual components instead.

name [required]

string

A unique identifier for this grid component. This name is also visible in the app editor.

properties [required]

object

Properties of a grid component.

backgroundColor

string

The background color of the grid.

default: default

children

[object]

The child components of the grid.

events

[object]

Events to listen for on the UI component.

name

enum

The triggering action for the event. Allowed enum values: pageChange,tableRowClick,_tableRowButtonClick,change,submit,click,toggleOpen,close,open,executionFinished

type

enum

The response to the event. Allowed enum values: custom,setComponentState,triggerQuery,openModal,closeModal,openUrl,downloadFile,setStateVariableValue

id

string

The ID of the UI component. This property is deprecated; use name to identify individual components instead.

name [required]

string

A unique identifier for this UI component. This name is also visible in the app editor.

properties [required]

object

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.

children

[object]

The child components of the UI component.

isVisible

 <oneOf>

Whether the UI component is visible. If this is a string, it must be a valid JavaScript expression that evaluates to a boolean.

Option 1

boolean

Option 2

string

If this is a string, it must be a valid JavaScript expression that evaluates to a boolean.

type [required]

enum

The UI component type. Allowed enum values: table,textInput,textArea,button,text,select,modal,schemaForm,checkbox,tabs

Show 10 more,vegaChart,radioButtons,numberInput,fileInput,jsonInput,gridCell,dateRangePicker,search,container,calloutValue

isVisible

 <oneOf>

Whether the grid component and its children are visible. If a string, it must be a valid JavaScript expression that evaluates to a boolean.

Option 1

string

Option 2

boolean

default: true

type [required]

enum

The grid component type. Allowed enum values: grid

default: grid

description

string

The human-readable description for the app.

favorite

boolean

Whether the app is marked as a favorite by the current user.

name

string

The name of the app.

queries

[ <oneOf>]

An array of queries, such as external actions and state variables, that the app uses.

Option 1

object

An action query. This query type is used to trigger an action, such as sending a HTTP request.

events

[object]

Events to listen for downstream of the action query.

name

enum

The triggering action for the event. Allowed enum values: pageChange,tableRowClick,_tableRowButtonClick,change,submit,click,toggleOpen,close,open,executionFinished

type

enum

The response to the event. Allowed enum values: custom,setComponentState,triggerQuery,openModal,closeModal,openUrl,downloadFile,setStateVariableValue

id [required]

uuid

The ID of the action query.

name [required]

string

A unique identifier for this action query. This name is also used to access the query's result throughout the app.

properties [required]

object

The properties of the action query.

condition

 <oneOf>

Whether 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.

Option 1

boolean

Option 2

string

debounceInMs

 <oneOf>

The 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.

Option 1

double

Option 2

string

If this is a string, it must be a valid JavaScript expression that evaluates to a number.

mockedOutputs

 <oneOf>

The mocked outputs of the action query. This is useful for testing the app without actually running the action.

Option 1

string

Option 2

object

The mocked outputs of the action query.

enabled [required]

 <oneOf>

Whether to enable the mocked outputs for testing.

Option 1

boolean

Option 2

string

If this is a string, it must be a valid JavaScript expression that evaluates to a boolean.

outputs

string

The mocked outputs of the action query, serialized as JSON.

onlyTriggerManually

 <oneOf>

Determines 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.

Option 1

boolean

Option 2

string

If this is a string, it must be a valid JavaScript expression that evaluates to a boolean.

outputs

string

The post-query transformation function, which is a JavaScript function that changes the query's .outputs property after the query's execution.

pollingIntervalInMs

 <oneOf>

If 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.

Option 1

double

Option 2

string

If this is a string, it must be a valid JavaScript expression that evaluates to a number.

requiresConfirmation

 <oneOf>

Whether to prompt the user to confirm this query before it runs.

Option 1

boolean

Option 2

string

If this is a string, it must be a valid JavaScript expression that evaluates to a boolean.

showToastOnError

 <oneOf>

Whether to display a toast to the user when the query returns an error.

Option 1

boolean

Option 2

string

If this is a string, it must be a valid JavaScript expression that evaluates to a boolean.

spec [required]

 <oneOf>

The definition of the action query.

Option 1

string

Option 2

object

The action query spec object.

connectionGroup

object

The connection group to use for an action query.

id

uuid

The ID of the connection group.

tags

[string]

The tags of the connection group.

connectionId

string

The ID of the custom connection to use for this action query.

fqn [required]

string

The fully qualified name of the action type.

inputs

 <oneOf>

The inputs to the action query. These are the values that are passed to the action when it is triggered.

Option 1

string

Option 2

object

The inputs to the action query. See the Actions Catalog for more detail on each action and its inputs.

type [required]

enum

The action query type. Allowed enum values: action

default: action

Option 2

object

A data transformer, which is custom JavaScript code that executes and transforms data when its inputs change.

id [required]

uuid

The ID of the data transformer.

name [required]

string

A unique identifier for this data transformer. This name is also used to access the transformer's result throughout the app.

properties [required]

object

The properties of the data transformer.

outputs

string

A JavaScript function that returns the transformed data.

type [required]

enum

The data transform type. Allowed enum values: dataTransform

default: dataTransform

Option 3

object

A variable, which can be set and read by other components in the app.

id [required]

uuid

The ID of the state variable.

name [required]

string

A unique identifier for this state variable. This name is also used to access the variable's value throughout the app.

properties [required]

object

The properties of the state variable.

defaultValue

The default value of the state variable.

type [required]

enum

The state variable type. Allowed enum values: stateVariable

default: stateVariable

rootInstanceName

string

The name of the root component of the app. This must be a grid component that contains all other components.

tags

[string]

A list of tags for the app, which can be used to filter apps.

id [required]

uuid

The ID of the updated app.

type [required]

enum

The app definition type. Allowed enum values: appDefinitions

default: appDefinitions

included

[object]

Data on the version of the app that was published.

attributes

object

The attributes object containing the version ID of the published app.

app_version_id

uuid

The version ID of the app that was published. For an unpublished app, this is always the nil UUID (00000000-0000-0000-0000-000000000000).

id

uuid

The deployment ID.

meta

object

Metadata object containing the publication creation information.

created_at

date-time

Timestamp of when the app was published.

user_id

int64

The ID of the user who published the app.

user_name

string

The name (or email address) of the user who published the app.

user_uuid

uuid

The UUID of the user who published the app.

type

enum

The deployment type. Allowed enum values: deployment

default: deployment

meta

object

Metadata of an app.

created_at

date-time

Timestamp of when the app was created.

deleted_at

date-time

Timestamp of when the app was deleted.

org_id

int64

The Datadog organization ID that owns the app.

updated_at

date-time

Timestamp of when the app was last updated.

updated_since_deployment

boolean

Whether the app was updated since it was last published. Published apps are pinned to a specific version and do not automatically update when the app is updated.

user_id

int64

The ID of the user who created the app.

user_name

string

The name (or email address) of the user who created the app.

user_uuid

uuid

The UUID of the user who created the app.

version

int64

The version number of the app. This starts at 1 and increments with each update.

relationship

object

The app's publication relationship and custom connections.

connections

[object]

Array of custom connections used by the app.

attributes

object

The custom connection attributes.

name

string

The name of the custom connection.

onPremRunner

object

Information about the Private Action Runner used by the custom connection, if the custom connection is associated with a Private Action Runner.

id

string

The Private Action Runner ID.

url

string

The URL of the Private Action Runner.

id

uuid

The ID of the custom connection.

type

enum

The custom connection type. Allowed enum values: custom_connections

default: custom_connections

deployment

object

Information pointing to the app's publication status.

data

object

Data object containing the deployment ID.

id

uuid

The deployment ID.

type

enum

The deployment type. Allowed enum values: deployment

default: deployment

meta

object

Metadata object containing the publication creation information.

created_at

date-time

Timestamp of when the app was published.

user_id

int64

The ID of the user who published the app.

user_name

string

The name (or email address) of the user who published the app.

user_uuid

uuid

The UUID of the user who published the app.

{
  "data": {
    "attributes": {
      "components": [
        {
          "events": [
            {
              "name": "click",
              "type": "triggerQuery"
            }
          ],
          "id": "string",
          "name": "",
          "properties": {
            "backgroundColor": "string",
            "children": [
              {
                "events": [
                  {
                    "name": "click",
                    "type": "triggerQuery"
                  }
                ],
                "id": "string",
                "name": "",
                "properties": {
                  "children": [],
                  "isVisible": {
                    "type": "undefined"
                  }
                },
                "type": "text"
              }
            ],
            "isVisible": {
              "type": "undefined"
            }
          },
          "type": "grid"
        }
      ],
      "description": "string",
      "favorite": false,
      "name": "string",
      "queries": [
        {
          "events": [
            {
              "name": "click",
              "type": "triggerQuery"
            }
          ],
          "id": "65bb1f25-52e1-4510-9f8d-22d1516ed693",
          "name": "fetchPendingOrders",
          "properties": {
            "condition": {
              "type": "undefined"
            },
            "debounceInMs": {
              "example": "undefined",
              "format": "undefined",
              "type": "undefined"
            },
            "mockedOutputs": {
              "type": "undefined"
            },
            "onlyTriggerManually": {
              "type": "undefined"
            },
            "outputs": "${((outputs) => {return outputs.body.data})(self.rawOutputs)}",
            "pollingIntervalInMs": {
              "example": "undefined",
              "format": "undefined",
              "minimum": "undefined",
              "type": "undefined"
            },
            "requiresConfirmation": {
              "type": "undefined"
            },
            "showToastOnError": {
              "type": "undefined"
            },
            "spec": {
              "type": ""
            }
          },
          "type": "action"
        }
      ],
      "rootInstanceName": "string",
      "tags": [
        "service:webshop-backend",
        "team:webshop"
      ]
    },
    "id": "65bb1f25-52e1-4510-9f8d-22d1516ed693",
    "type": "appDefinitions"
  },
  "included": [
    {
      "attributes": {
        "app_version_id": "65bb1f25-52e1-4510-9f8d-22d1516ed693"
      },
      "id": "65bb1f25-52e1-4510-9f8d-22d1516ed693",
      "meta": {
        "created_at": "2019-09-19T10:00:00.000Z",
        "user_id": "integer",
        "user_name": "string",
        "user_uuid": "65bb1f25-52e1-4510-9f8d-22d1516ed693"
      },
      "type": "deployment"
    }
  ],
  "meta": {
    "created_at": "2019-09-19T10:00:00.000Z",
    "deleted_at": "2019-09-19T10:00:00.000Z",
    "org_id": "integer",
    "updated_at": "2019-09-19T10:00:00.000Z",
    "updated_since_deployment": false,
    "user_id": "integer",
    "user_name": "string",
    "user_uuid": "65bb1f25-52e1-4510-9f8d-22d1516ed693",
    "version": "integer"
  },
  "relationship": {
    "connections": [
      {
        "attributes": {
          "name": "string",
          "onPremRunner": {
            "id": "string",
            "url": "string"
          }
        },
        "id": "65bb1f25-52e1-4510-9f8d-22d1516ed693",
        "type": "custom_connections"
      }
    ],
    "deployment": {
      "data": {
        "id": "65bb1f25-52e1-4510-9f8d-22d1516ed693",
        "type": "deployment"
      },
      "meta": {
        "created_at": "2019-09-19T10:00:00.000Z",
        "user_id": "integer",
        "user_name": "string",
        "user_uuid": "65bb1f25-52e1-4510-9f8d-22d1516ed693"
      }
    }
  }
}

Bad Request

API error response.

Expand All

Field

Type

Description

errors [required]

[object]

A list of errors.

detail

string

A human-readable explanation specific to this occurrence of the error.

meta

object

Non-standard meta-information about the error

source

object

References to the source of the error.

header

string

A string indicating the name of a single request header which caused the error.

parameter

string

A string indicating which URI query parameter caused the error.

pointer

string

A JSON pointer to the value in the request document that caused the error.

status

string

Status code of the response.

title

string

Short 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.

Expand All

Field

Type

Description

errors [required]

[object]

A list of errors.

detail

string

A human-readable explanation specific to this occurrence of the error.

meta

object

Non-standard meta-information about the error

source

object

References to the source of the error.

header

string

A string indicating the name of a single request header which caused the error.

parameter

string

A string indicating which URI query parameter caused the error.

pointer

string

A JSON pointer to the value in the request document that caused the error.

status

string

Status code of the response.

title

string

Short 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"
    }
  ]
}

Not Found

API error response.

Expand All

Field

Type

Description

errors [required]

[object]

A list of errors.

detail

string

A human-readable explanation specific to this occurrence of the error.

meta

object

Non-standard meta-information about the error

source

object

References to the source of the error.

header

string

A string indicating the name of a single request header which caused the error.

parameter

string

A string indicating which URI query parameter caused the error.

pointer

string

A JSON pointer to the value in the request document that caused the error.

status

string

Status code of the response.

title

string

Short 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.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Code Example

                          ## default
# 

# Path parameters
export app_id="65bb1f25-52e1-4510-9f8d-22d1516ed693"
# Curl command
curl -X PATCH "https://api.ap1.datadoghq.com"https://api.ap2.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.us2.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v2/app-builder/apps/${app_id}/protection-level" \ -H "Accept: application/json" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \ -d @- << EOF { "data": { "attributes": { "protectionLevel": "approval_required" }, "type": "protectionLevel" } } EOF
// Update App Protection Level returns "OK" 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.UpdateAppProtectionLevelRequest{
		Data: &datadogV2.UpdateAppProtectionLevelRequestData{
			Attributes: &datadogV2.UpdateAppProtectionLevelRequestDataAttributes{
				ProtectionLevel: datadogV2.APPPROTECTIONLEVEL_APPROVAL_REQUIRED,
			},
			Type: datadogV2.APPPROTECTIONLEVELTYPE_PROTECTIONLEVEL.Ptr(),
		},
	}
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV2.NewAppBuilderApi(apiClient)
	resp, r, err := api.UpdateProtectionLevel(ctx, uuid.MustParse("9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d"), body)

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `AppBuilderApi.UpdateProtectionLevel`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `AppBuilderApi.UpdateProtectionLevel`:\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.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" go run "main.go"
// Update App Protection Level returns "OK" 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.AppProtectionLevel;
import com.datadog.api.client.v2.model.AppProtectionLevelType;
import com.datadog.api.client.v2.model.UpdateAppProtectionLevelRequest;
import com.datadog.api.client.v2.model.UpdateAppProtectionLevelRequestData;
import com.datadog.api.client.v2.model.UpdateAppProtectionLevelRequestDataAttributes;
import com.datadog.api.client.v2.model.UpdateAppResponse;
import java.util.UUID;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = ApiClient.getDefaultApiClient();
    AppBuilderApi apiInstance = new AppBuilderApi(defaultClient);

    UpdateAppProtectionLevelRequest body =
        new UpdateAppProtectionLevelRequest()
            .data(
                new UpdateAppProtectionLevelRequestData()
                    .attributes(
                        new UpdateAppProtectionLevelRequestDataAttributes()
                            .protectionLevel(AppProtectionLevel.APPROVAL_REQUIRED))
                    .type(AppProtectionLevelType.PROTECTIONLEVEL));

    try {
      UpdateAppResponse result =
          apiInstance.updateProtectionLevel(
              UUID.fromString("65bb1f25-52e1-4510-9f8d-22d1516ed693"), body);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling AppBuilderApi#updateProtectionLevel");
      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.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" java "Example.java"
"""
Update App Protection Level returns "OK" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.app_builder_api import AppBuilderApi
from datadog_api_client.v2.model.app_protection_level import AppProtectionLevel
from datadog_api_client.v2.model.app_protection_level_type import AppProtectionLevelType
from datadog_api_client.v2.model.update_app_protection_level_request import UpdateAppProtectionLevelRequest
from datadog_api_client.v2.model.update_app_protection_level_request_data import UpdateAppProtectionLevelRequestData
from datadog_api_client.v2.model.update_app_protection_level_request_data_attributes import (
    UpdateAppProtectionLevelRequestDataAttributes,
)
from uuid import UUID

body = UpdateAppProtectionLevelRequest(
    data=UpdateAppProtectionLevelRequestData(
        attributes=UpdateAppProtectionLevelRequestDataAttributes(
            protection_level=AppProtectionLevel.APPROVAL_REQUIRED,
        ),
        type=AppProtectionLevelType.PROTECTIONLEVEL,
    ),
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = AppBuilderApi(api_client)
    response = api_instance.update_protection_level(app_id=UUID("9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d"), 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.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python3 "example.py"
# Update App Protection Level returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V2::AppBuilderAPI.new

body = DatadogAPIClient::V2::UpdateAppProtectionLevelRequest.new({
  data: DatadogAPIClient::V2::UpdateAppProtectionLevelRequestData.new({
    attributes: DatadogAPIClient::V2::UpdateAppProtectionLevelRequestDataAttributes.new({
      protection_level: DatadogAPIClient::V2::AppProtectionLevel::APPROVAL_REQUIRED,
    }),
    type: DatadogAPIClient::V2::AppProtectionLevelType::PROTECTIONLEVEL,
  }),
})
p api_instance.update_protection_level("9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d", body)

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"
// Update App Protection Level returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_app_builder::AppBuilderAPI;
use datadog_api_client::datadogV2::model::AppProtectionLevel;
use datadog_api_client::datadogV2::model::AppProtectionLevelType;
use datadog_api_client::datadogV2::model::UpdateAppProtectionLevelRequest;
use datadog_api_client::datadogV2::model::UpdateAppProtectionLevelRequestData;
use datadog_api_client::datadogV2::model::UpdateAppProtectionLevelRequestDataAttributes;
use uuid::Uuid;

#[tokio::main]
async fn main() {
    let body = UpdateAppProtectionLevelRequest::new().data(
        UpdateAppProtectionLevelRequestData::new()
            .attributes(UpdateAppProtectionLevelRequestDataAttributes::new(
                AppProtectionLevel::APPROVAL_REQUIRED,
            ))
            .type_(AppProtectionLevelType::PROTECTIONLEVEL),
    );
    let configuration = datadog::Configuration::new();
    let api = AppBuilderAPI::with_config(configuration);
    let resp = api
        .update_protection_level(
            Uuid::parse_str("00000000-0000-0000-0000-000000000000").expect("invalid UUID"),
            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.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo run
/**
 * Update App Protection Level returns "OK" response
 */

import { client, v2 } from "@datadog/datadog-api-client";

const configuration = client.createConfiguration();
const apiInstance = new v2.AppBuilderApi(configuration);

const params: v2.AppBuilderApiUpdateProtectionLevelRequest = {
  body: {
    data: {
      attributes: {
        protectionLevel: "approval_required",
      },
      type: "protectionLevel",
    },
  },
  appId: "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
};

apiInstance
  .updateProtectionLevel(params)
  .then((data: v2.UpdateAppResponse) => {
    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.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" tsc "example.ts"