Chilkat Online Tools

autoit / Datadog API Collection / List your managed organizations

Back to Collection Items

; This example assumes the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.

$oHttp = ObjCreate("Chilkat.Http")
Local $bSuccess

$oHttp.SetRequestHeader "Accept","application/json"

$oSbResponseBody = ObjCreate("Chilkat.StringBuilder")
$bSuccess = $oHttp.QuickGetSb("https://api.app.ddog-gov.com/api/v1/org",$oSbResponseBody)
If ($bSuccess = False) Then
    ConsoleWrite($oHttp.LastErrorText & @CRLF)
    Exit
EndIf

$oJResp = ObjCreate("Chilkat.JsonObject")
$oJResp.LoadSb($oSbResponseBody)
$oJResp.EmitCompact = False

ConsoleWrite("Response Body:" & @CRLF)
ConsoleWrite($oJResp.Emit() & @CRLF)

Local $iRespStatusCode = $oHttp.LastStatus
ConsoleWrite("Response Status Code = " & $iRespStatusCode & @CRLF)
If ($iRespStatusCode >= 400) Then
    ConsoleWrite("Response Header:" & @CRLF)
    ConsoleWrite($oHttp.LastHeader & @CRLF)
    ConsoleWrite("Failed." & @CRLF)
    Exit
EndIf

; Sample JSON response:
; (Sample code for parsing the JSON response is shown below)

; {
;   "orgs": [
;     {
;       "billing": {
;         "type": "parent_billing"
;       },
;       "created": "2019-09-26T17:28:28Z",
;       "description": "some description",
;       "name": "New child org",
;       "public_id": "abcdef12345",
;       "settings": {
;         "private_widget_share": false,
;         "saml": {
;           "enabled": false
;         },
;         "saml_autocreate_access_role": "ro",
;         "saml_autocreate_users_domains": {
;           "domains": [
;             "example.com",
;             "example.com"
;           ],
;           "enabled": false
;         },
;         "saml_can_be_enabled": false,
;         "saml_idp_endpoint": "https://my.saml.endpoint",
;         "saml_idp_initiated_login": {
;           "enabled": false
;         },
;         "saml_idp_metadata_uploaded": false,
;         "saml_login_url": "https://my.saml.login.url",
;         "saml_strict_mode": {
;           "enabled": false
;         }
;       },
;       "subscription": {
;         "type": "pro"
;       },
;       "trial": false
;     },
;     {
;       "billing": {
;         "type": "parent_billing"
;       },
;       "created": "2019-09-26T17:28:28Z",
;       "description": "some description",
;       "name": "New child org",
;       "public_id": "abcdef12345",
;       "settings": {
;         "private_widget_share": false,
;         "saml": {
;           "enabled": false
;         },
;         "saml_autocreate_access_role": "ro",
;         "saml_autocreate_users_domains": {
;           "domains": [
;             "example.com",
;             "example.com"
;           ],
;           "enabled": false
;         },
;         "saml_can_be_enabled": false,
;         "saml_idp_endpoint": "https://my.saml.endpoint",
;         "saml_idp_initiated_login": {
;           "enabled": false
;         },
;         "saml_idp_metadata_uploaded": false,
;         "saml_login_url": "https://my.saml.login.url",
;         "saml_strict_mode": {
;           "enabled": false
;         }
;       },
;       "subscription": {
;         "type": "pro"
;       },
;       "trial": false
;     }
;   ]
; }

; Sample code for parsing the JSON response...
; Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code

Local $sV_Type
Local $sCreated
Local $sDescription
Local $sName
Local $sPublic_id
Local $bPrivate_widget_share
Local $bEnabled
Local $sSaml_autocreate_access_role
Local $bSaml_autocreate_users_domainsEnabled
Local $bSaml_can_be_enabled
Local $sSaml_idp_endpoint
Local $bSaml_idp_initiated_loginEnabled
Local $bSaml_idp_metadata_uploaded
Local $sSaml_login_url
Local $bSaml_strict_modeEnabled
Local $subscriptionType
Local $bTrial
Local $iJ
Local $iCount_j
Local $strVal

Local $i = 0
Local $iCount_i = $oJResp.SizeOfArray("orgs")
While $i < $iCount_i
    $oJResp.I = $i
    $sV_Type = $oJResp.StringOf("orgs[i].billing.type")
    $sCreated = $oJResp.StringOf("orgs[i].created")
    $sDescription = $oJResp.StringOf("orgs[i].description")
    $sName = $oJResp.StringOf("orgs[i].name")
    $sPublic_id = $oJResp.StringOf("orgs[i].public_id")
    $bPrivate_widget_share = $oJResp.BoolOf("orgs[i].settings.private_widget_share")
    $bEnabled = $oJResp.BoolOf("orgs[i].settings.saml.enabled")
    $sSaml_autocreate_access_role = $oJResp.StringOf("orgs[i].settings.saml_autocreate_access_role")
    $bSaml_autocreate_users_domainsEnabled = $oJResp.BoolOf("orgs[i].settings.saml_autocreate_users_domains.enabled")
    $bSaml_can_be_enabled = $oJResp.BoolOf("orgs[i].settings.saml_can_be_enabled")
    $sSaml_idp_endpoint = $oJResp.StringOf("orgs[i].settings.saml_idp_endpoint")
    $bSaml_idp_initiated_loginEnabled = $oJResp.BoolOf("orgs[i].settings.saml_idp_initiated_login.enabled")
    $bSaml_idp_metadata_uploaded = $oJResp.BoolOf("orgs[i].settings.saml_idp_metadata_uploaded")
    $sSaml_login_url = $oJResp.StringOf("orgs[i].settings.saml_login_url")
    $bSaml_strict_modeEnabled = $oJResp.BoolOf("orgs[i].settings.saml_strict_mode.enabled")
    $subscriptionType = $oJResp.StringOf("orgs[i].subscription.type")
    $bTrial = $oJResp.BoolOf("orgs[i].trial")
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("orgs[i].settings.saml_autocreate_users_domains.domains")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $strVal = $oJResp.StringOf("orgs[i].settings.saml_autocreate_users_domains.domains[j]")
        $iJ = $iJ + 1
    Wend
    $i = $i + 1
Wend

Curl Command

curl -X GET
	-H "Accept: application/json"
https://api.app.ddog-gov.com/api/v1/org

Postman Collection Item JSON

{
  "name": "List your managed organizations",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/api/v1/org",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "v1",
        "org"
      ]
    },
    "description": "This endpoint returns data on your top-level organization."
  },
  "response": [
    {
      "name": "OK",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "key": "Accept",
            "value": "application/json"
          },
          {
            "description": "Added as a part of security scheme: apikey",
            "key": "DD-API-KEY",
            "value": "<API Key>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/v1/org",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v1",
            "org"
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"orgs\": [\n    {\n      \"billing\": {\n        \"type\": \"parent_billing\"\n      },\n      \"created\": \"2019-09-26T17:28:28Z\",\n      \"description\": \"some description\",\n      \"name\": \"New child org\",\n      \"public_id\": \"abcdef12345\",\n      \"settings\": {\n        \"private_widget_share\": false,\n        \"saml\": {\n          \"enabled\": false\n        },\n        \"saml_autocreate_access_role\": \"ro\",\n        \"saml_autocreate_users_domains\": {\n          \"domains\": [\n            \"example.com\",\n            \"example.com\"\n          ],\n          \"enabled\": false\n        },\n        \"saml_can_be_enabled\": false,\n        \"saml_idp_endpoint\": \"https://my.saml.endpoint\",\n        \"saml_idp_initiated_login\": {\n          \"enabled\": false\n        },\n        \"saml_idp_metadata_uploaded\": false,\n        \"saml_login_url\": \"https://my.saml.login.url\",\n        \"saml_strict_mode\": {\n          \"enabled\": false\n        }\n      },\n      \"subscription\": {\n        \"type\": \"pro\"\n      },\n      \"trial\": false\n    },\n    {\n      \"billing\": {\n        \"type\": \"parent_billing\"\n      },\n      \"created\": \"2019-09-26T17:28:28Z\",\n      \"description\": \"some description\",\n      \"name\": \"New child org\",\n      \"public_id\": \"abcdef12345\",\n      \"settings\": {\n        \"private_widget_share\": false,\n        \"saml\": {\n          \"enabled\": false\n        },\n        \"saml_autocreate_access_role\": \"ro\",\n        \"saml_autocreate_users_domains\": {\n          \"domains\": [\n            \"example.com\",\n            \"example.com\"\n          ],\n          \"enabled\": false\n        },\n        \"saml_can_be_enabled\": false,\n        \"saml_idp_endpoint\": \"https://my.saml.endpoint\",\n        \"saml_idp_initiated_login\": {\n          \"enabled\": false\n        },\n        \"saml_idp_metadata_uploaded\": false,\n        \"saml_login_url\": \"https://my.saml.login.url\",\n        \"saml_strict_mode\": {\n          \"enabled\": false\n        }\n      },\n      \"subscription\": {\n        \"type\": \"pro\"\n      },\n      \"trial\": false\n    }\n  ]\n}"
    },
    {
      "name": "Forbidden",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "key": "Accept",
            "value": "application/json"
          },
          {
            "description": "Added as a part of security scheme: apikey",
            "key": "DD-API-KEY",
            "value": "<API Key>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/v1/org",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v1",
            "org"
          ]
        }
      },
      "status": "Forbidden",
      "code": 403,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"errors\": [\n    \"Bad Request\",\n    \"Bad Request\"\n  ]\n}"
    },
    {
      "name": "Too many requests",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "key": "Accept",
            "value": "application/json"
          },
          {
            "description": "Added as a part of security scheme: apikey",
            "key": "DD-API-KEY",
            "value": "<API Key>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/v1/org",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "v1",
            "org"
          ]
        }
      },
      "status": "Too Many Requests",
      "code": 429,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"errors\": [\n    \"Bad Request\",\n    \"Bad Request\"\n  ]\n}"
    }
  ]
}