Chilkat Online Tools

Java / Datadog API Collection / List your managed organizations

Back to Collection Items

import com.chilkatsoft.*;

public class ChilkatExample {

  static {
    try {
        System.loadLibrary("chilkat");
    } catch (UnsatisfiedLinkError e) {
      System.err.println("Native code library failed to load.\n" + e);
      System.exit(1);
    }
  }

  public static void main(String argv[])
  {
    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    CkHttp http = new CkHttp();
    boolean success;

    http.SetRequestHeader("Accept","application/json");

    CkStringBuilder sbResponseBody = new CkStringBuilder();
    success = http.QuickGetSb("https://api.app.ddog-gov.com/api/v1/org",sbResponseBody);
    if (success == false) {
        System.out.println(http.lastErrorText());
        return;
        }

    CkJsonObject jResp = new CkJsonObject();
    jResp.LoadSb(sbResponseBody);
    jResp.put_EmitCompact(false);

    System.out.println("Response Body:");
    System.out.println(jResp.emit());

    int respStatusCode = http.get_LastStatus();
    System.out.println("Response Status Code = " + respStatusCode);
    if (respStatusCode >= 400) {
        System.out.println("Response Header:");
        System.out.println(http.lastHeader());
        System.out.println("Failed.");
        return;
        }

    // 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

    String v_Type;
    String created;
    String description;
    String name;
    String public_id;
    boolean Private_widget_share;
    boolean Enabled;
    String Saml_autocreate_access_role;
    boolean Saml_autocreate_users_domainsEnabled;
    boolean Saml_can_be_enabled;
    String Saml_idp_endpoint;
    boolean Saml_idp_initiated_loginEnabled;
    boolean Saml_idp_metadata_uploaded;
    String Saml_login_url;
    boolean Saml_strict_modeEnabled;
    String subscriptionType;
    boolean trial;
    int j;
    int count_j;
    String strVal;

    int i = 0;
    int count_i = jResp.SizeOfArray("orgs");
    while (i < count_i) {
        jResp.put_I(i);
        v_Type = jResp.stringOf("orgs[i].billing.type");
        created = jResp.stringOf("orgs[i].created");
        description = jResp.stringOf("orgs[i].description");
        name = jResp.stringOf("orgs[i].name");
        public_id = jResp.stringOf("orgs[i].public_id");
        Private_widget_share = jResp.BoolOf("orgs[i].settings.private_widget_share");
        Enabled = jResp.BoolOf("orgs[i].settings.saml.enabled");
        Saml_autocreate_access_role = jResp.stringOf("orgs[i].settings.saml_autocreate_access_role");
        Saml_autocreate_users_domainsEnabled = jResp.BoolOf("orgs[i].settings.saml_autocreate_users_domains.enabled");
        Saml_can_be_enabled = jResp.BoolOf("orgs[i].settings.saml_can_be_enabled");
        Saml_idp_endpoint = jResp.stringOf("orgs[i].settings.saml_idp_endpoint");
        Saml_idp_initiated_loginEnabled = jResp.BoolOf("orgs[i].settings.saml_idp_initiated_login.enabled");
        Saml_idp_metadata_uploaded = jResp.BoolOf("orgs[i].settings.saml_idp_metadata_uploaded");
        Saml_login_url = jResp.stringOf("orgs[i].settings.saml_login_url");
        Saml_strict_modeEnabled = jResp.BoolOf("orgs[i].settings.saml_strict_mode.enabled");
        subscriptionType = jResp.stringOf("orgs[i].subscription.type");
        trial = jResp.BoolOf("orgs[i].trial");
        j = 0;
        count_j = jResp.SizeOfArray("orgs[i].settings.saml_autocreate_users_domains.domains");
        while (j < count_j) {
            jResp.put_J(j);
            strVal = jResp.stringOf("orgs[i].settings.saml_autocreate_users_domains.domains[j]");
            j = j+1;
            }

        i = i+1;
        }
  }
}

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