Objective-C / Datadog API Collection / List all APM retention filters
Back to Collection Items
#import <CkoHttp.h>
#import <CkoStringBuilder.h>
#import <CkoJsonObject.h>
#import <NSString.h>
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkoHttp *http = [[CkoHttp alloc] init];
BOOL success;
[http SetRequestHeader: @"Accept" value: @"application/json"];
CkoStringBuilder *sbResponseBody = [[CkoStringBuilder alloc] init];
success = [http QuickGetSb: @"https://api.app.ddog-gov.com/api/v2/apm/config/retention-filters" sbContent: sbResponseBody];
if (success == NO) {
NSLog(@"%@",http.LastErrorText);
return;
}
CkoJsonObject *jResp = [[CkoJsonObject alloc] init];
[jResp LoadSb: sbResponseBody];
jResp.EmitCompact = NO;
NSLog(@"%@",@"Response Body:");
NSLog(@"%@",[jResp Emit]);
int respStatusCode = [http.LastStatus intValue];
NSLog(@"%@%d",@"Response Status Code = ",respStatusCode);
if (respStatusCode >= 400) {
NSLog(@"%@",@"Response Header:");
NSLog(@"%@",http.LastHeader);
NSLog(@"%@",@"Failed.");
return;
}
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "data": [
// {
// "id": "<string>",
// "type": "apm_retention_filter",
// "attributes": {
// "created_at": "<long>",
// "created_by": "<string>",
// "editable": "<boolean>",
// "enabled": "<boolean>",
// "execution_order": "<long>",
// "filter": {
// "query": "<string>"
// },
// "filter_type": "spans-sampling-processor",
// "modified_at": "<long>",
// "modified_by": "<string>",
// "name": "<string>",
// "rate": "<double>"
// }
// },
// {
// "id": "<string>",
// "type": "apm_retention_filter",
// "attributes": {
// "created_at": "<long>",
// "created_by": "<string>",
// "editable": "<boolean>",
// "enabled": "<boolean>",
// "execution_order": "<long>",
// "filter": {
// "query": "<string>"
// },
// "filter_type": "spans-sampling-processor",
// "modified_at": "<long>",
// "modified_by": "<string>",
// "name": "<string>",
// "rate": "<double>"
// }
// }
// ]
// }
// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
NSString *id = 0;
NSString *v_type = 0;
NSString *Created_at = 0;
NSString *Created_by = 0;
NSString *Editable = 0;
NSString *Enabled = 0;
NSString *Execution_order = 0;
NSString *Query = 0;
NSString *Filter_type = 0;
NSString *Modified_at = 0;
NSString *Modified_by = 0;
NSString *Name = 0;
NSString *Rate = 0;
int i = 0;
int count_i = [[jResp SizeOfArray: @"data"] intValue];
while (i < count_i) {
jResp.I = [NSNumber numberWithInt: i];
id = [jResp StringOf: @"data[i].id"];
v_type = [jResp StringOf: @"data[i].type"];
Created_at = [jResp StringOf: @"data[i].attributes.created_at"];
Created_by = [jResp StringOf: @"data[i].attributes.created_by"];
Editable = [jResp StringOf: @"data[i].attributes.editable"];
Enabled = [jResp StringOf: @"data[i].attributes.enabled"];
Execution_order = [jResp StringOf: @"data[i].attributes.execution_order"];
Query = [jResp StringOf: @"data[i].attributes.filter.query"];
Filter_type = [jResp StringOf: @"data[i].attributes.filter_type"];
Modified_at = [jResp StringOf: @"data[i].attributes.modified_at"];
Modified_by = [jResp StringOf: @"data[i].attributes.modified_by"];
Name = [jResp StringOf: @"data[i].attributes.name"];
Rate = [jResp StringOf: @"data[i].attributes.rate"];
i = i + 1;
}
Curl Command
curl -X GET
-H "Accept: application/json"
https://api.app.ddog-gov.com/api/v2/apm/config/retention-filters
Postman Collection Item JSON
{
"name": "List all APM retention filters",
"request": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
}
],
"url": {
"raw": "{{baseUrl}}/api/v2/apm/config/retention-filters",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"apm",
"config",
"retention-filters"
]
},
"description": "Get the list of APM retention filters."
},
"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/v2/apm/config/retention-filters",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"apm",
"config",
"retention-filters"
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"data\": [\n {\n \"id\": \"<string>\",\n \"type\": \"apm_retention_filter\",\n \"attributes\": {\n \"created_at\": \"<long>\",\n \"created_by\": \"<string>\",\n \"editable\": \"<boolean>\",\n \"enabled\": \"<boolean>\",\n \"execution_order\": \"<long>\",\n \"filter\": {\n \"query\": \"<string>\"\n },\n \"filter_type\": \"spans-sampling-processor\",\n \"modified_at\": \"<long>\",\n \"modified_by\": \"<string>\",\n \"name\": \"<string>\",\n \"rate\": \"<double>\"\n }\n },\n {\n \"id\": \"<string>\",\n \"type\": \"apm_retention_filter\",\n \"attributes\": {\n \"created_at\": \"<long>\",\n \"created_by\": \"<string>\",\n \"editable\": \"<boolean>\",\n \"enabled\": \"<boolean>\",\n \"execution_order\": \"<long>\",\n \"filter\": {\n \"query\": \"<string>\"\n },\n \"filter_type\": \"spans-sampling-processor\",\n \"modified_at\": \"<long>\",\n \"modified_by\": \"<string>\",\n \"name\": \"<string>\",\n \"rate\": \"<double>\"\n }\n }\n ]\n}"
},
{
"name": "Not Authorized",
"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/v2/apm/config/retention-filters",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"apm",
"config",
"retention-filters"
]
}
},
"status": "Forbidden",
"code": 403,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"errors\": [\n \"<string>\",\n \"<string>\"\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/v2/apm/config/retention-filters",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"apm",
"config",
"retention-filters"
]
}
},
"status": "Too Many Requests",
"code": 429,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"errors\": [\n \"<string>\",\n \"<string>\"\n ]\n}"
}
]
}