Migrate from Cloud Foundry credentials API to Settings API

The Cloud Foundry credentials API has been deprecated with Dynatrace version 1.288. It is replaced by the Settings API and the Cloud Foundry schema (builtin:cloud.cloudfoundry). We recommend that you migrate to the new API at your earliest convenience.

The migration affects endpoint URLs, query parameters, and response/request body parameters, as well as the scope of the token for the request.

Base URL

new Settings 2.0
old Cloud Foundry credentials
/api/v2/settings
/api/config/v1/cloudFoundry/credentials

Authentication token scope

new Settings 2.0
old Cloud Foundry credentials
Read settings (settings.read)
Write settings (settings.write)
Read configuration (ReadConfig)
Write configuration (WriteConfig)

Parameters

To learn about new query/body parameters, see the documentation of individual requests in the Settings API.

In the Settings 2.0 framework, each Cloud Foundry connection is represented by a settings object. An object contains some metadata (like the scope or creation timestamp) and the configuration itself, encapsulated in the value object. To learn about the parameters of a Cloud Foundry connection, query the Cloud Foundry schema (builtin:cloud.cloudfoundry) with the GET a schema request. The configuration differs from the Cloud Foundry credentials API – check the examples below to see the differences.

Examples

Here are some examples of differences in API usage.

List all Cloud Foundry connection settings

To list all Cloud Foundry connection settings, you need the GET objects request. In query parameters, set schemaIds to builtin:cloud.cloudfoundry and scopes to environment.

Request URL

GET https://mySampleEnv.live.dynatrace.com/api/v2/settings/objects?schemaIds=builtin:cloud.cloudfoundry&scopes=environment

Response body

{
"items": [
{
"objectId": "<OBJECT-ID-1>",
"value": {
"enabled": true,
"label": "my-test-foundation",
"apiUrl": "https://api.sample-cloud-foundry-foundation.com/",
"loginUrl": "https://login.sample-cloud-foundry-foundation.com/",
"username": "my-foundation-admin",
"password": "<PASSWORD>",
"activeGateGroup": "testgroup"
}
},
{
"objectId": "<OBJECT-ID-2>",
"value": {
"enabled": true,
"label": "my-other-foundation",
"apiUrl": "https://api.other-cloud-foundry-foundation.com/",
"loginUrl": "https://login.other-cloud-foundry-foundation.com/",
"username": "my-other-admin",
"password": "<PASSWORD>"
}
}
],
"totalCount": 2,
"pageSize": 100
}

Details for a specific Cloud Foundry connection

To get details for a specific Cloud Foundry connection, you need the GET object request. Use the objectId of the object from which you want to get details as parameter in the path.

Request URL

GET https://mySampleEnv.live.dynatrace.com/api/v2/settings/objects/<OBJECT-ID>

Response body

{
"objectId": "<OBJECT-ID>",
"summary": "my\\-test\\-foundation",
"searchSummary": "my-test-foundation",
"created": 1674052402929,
"modified": 1674541517381,
"author": "user.account",
"updateToken": "<UPDATE-TOKEN>",
"scope": "environment",
"schemaId": "builtin:cloud.cloudfoundry",
"schemaVersion": "1.1",
"value": {
"enabled": true,
"label": "my-test-foundation",
"apiUrl": "https://api.sample-cloud-foundry-foundation.com/",
"loginUrl": "https://login.sample-cloud-foundry-foundation.com/",
"username": "my-foundation-admin",
"password": "<PASSWORD>",
"activeGateGroup": "testgroup"
}
}

Validate creation of a Cloud Foundry connection

In this example, we validate if the request for creating a new Cloud Foundry connection would be successful.

To validate creation of a Cloud Foundry connection, you need the POST an object request with the parameter validateOnly set to true. In the request body, set schemaId to builtin:cloud.cloudfoundry and scope to environment. Provide the Cloud Foundry connection configuration in the value object.

Request URL

POST https://mySampleEnv.live.dynatrace.com/api/v2/settings/objects?validateOnly=true

Request body

[
{
"scope": "environment",
"schemaId": "builtin:cloud.cloudfoundry",
"value": {
"enabled": true,
"label": "new-foundation",
"apiUrl": "https://api.new-cloud-foundry-foundation.com/",
"loginUrl": "https://login.new-cloud-foundry-foundation.com/",
"username": "new-foundation-admin",
"password": "<PASSWORD>",
"activeGateGroup": "new-group"
}
}
]

Response body

[
{
"code": 200
}
]

Example response body in case validation fails

[
{
"code": 400,
"error": {
"code": 400,
"message": "Validation failed for 2 Validators.",
"constraintViolations": [
{
"path": "builtin:cloud.cloudfoundry",
"message": "Specified URL is already used in another configuration.",
"parameterLocation": "PAYLOAD_BODY",
"location": null
},
{
"path": "builtin:cloud.cloudfoundry",
"message": "Specified URL is already used in another configuration.",
"parameterLocation": "PAYLOAD_BODY",
"location": null
}
]
},
"invalidValue": {
"enabled": true,
"label": "new-foundation",
"apiUrl": "https://api.new-cloud-foundry-foundation.com/",
"loginUrl": "https://login.new-cloud-foundry-foundation.com/",
"username": "new-foundation-admin",
"password": "<PASSWORD>",
"activeGateGroup": "new-group"}
}
]

Create a Cloud Foundry connection

In this example, we create a Cloud Foundry connection.

To create a Cloud Foundry connection, you need the POST an object request. In the request body, set schemaId to builtin:cloud.cloudfoundry and scope to environment. Provide the Cloud Foundry connection configuration in the value object.

The response contains the ID of the object that you need to manage the settings.

Request URL

POST https://mySampleEnv.live.dynatrace.com/api/v2/settings/objects

Request body

[
{
"scope": "environment",
"schemaId": "builtin:cloud.cloudfoundry",
"value": {
"enabled": true,
"label": "new-foundation",
"apiUrl": "https://api.new-cloud-foundry-foundation.com/",
"loginUrl": "https://login.new-cloud-foundry-foundation.com/",
"username": "new-foundation-admin",
"password": "<PASSWORD>",
"activeGateGroup": "new-group"
}
}
]

Response body

[
{
"code": 200,
"objectId": "<OBJECT-ID>"
}
]

Edit a Cloud Foundry connection

In this example, we modify the Cloud Foundry connection created in the previous example. We change the username to foundation-admin.

To edit a Cloud Foundry connection, you need the PUT an object request.

Request URL

PUT https://mySampleEnv.live.dynatrace.com/api/v2/settings/objects/<OBJECT-ID>

Request body

{
"scope": "environment",
"schemaId": "builtin:cloud.cloudfoundry",
"value": {
"enabled": true,
"label": "new-foundation",
"apiUrl": "https://api.new-cloud-foundry-foundation.com/",
"loginUrl": "https://login.new-cloud-foundry-foundation.com/",
"username": "foundation-admin",
"password": "<PASSWORD>",
"activeGateGroup": "new-group"
}
}

Response body

{
"code": 200,
"objectId": "<OBJECT-ID>"
}

Delete a Cloud Foundry connection

In this example, we delete the previously created Cloud Foundry connection again.

To delete a Cloud Foundry connection, you need the DELETE an object request.

Request URL

DELETE https://mySampleEnv.live.dynatrace.com/api/v2/settings/objects/<OBJECT-ID>