Chilkat Online Tools

unicodeC / Monitoring API / Get Alarm

Back to Collection Items

#include <C_CkHttpW.h>
#include <C_CkStringBuilderW.h>
#include <C_CkJsonObjectW.h>

void ChilkatSample(void)
    {
    HCkHttpW http;
    BOOL success;
    HCkStringBuilderW sbResponseBody;
    HCkJsonObjectW jResp;
    int respStatusCode;
    const wchar_t *strVal;
    const wchar_t *compartmentId;
    const wchar_t *displayName;
    const wchar_t *id;
    BOOL isEnabled;
    const wchar_t *lifecycleState;
    const wchar_t *metricCompartmentId;
    const wchar_t *namespace;
    const wchar_t *query;
    const wchar_t *severity;
    const wchar_t *timeCreated;
    const wchar_t *timeUpdated;
    const wchar_t *body;
    BOOL metricCompartmentIdInSubtree;
    const wchar_t *pendingDuration;
    const wchar_t *repeatNotificationDuration;
    const wchar_t *resolution;
    const wchar_t *resourceGroup;
    const wchar_t *TimeSuppressFrom;
    const wchar_t *TimeSuppressUntil;
    const wchar_t *Description;
    int i;
    int count_i;

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

    http = CkHttpW_Create();

    CkHttpW_SetRequestHeader(http,L"opc-request-id",L"pariatur nostrud eiusmod");
    CkHttpW_SetRequestHeader(http,L"Authorization",L"{{signature}}");
    CkHttpW_SetRequestHeader(http,L"Date",L"{{date}}");

    sbResponseBody = CkStringBuilderW_Create();
    success = CkHttpW_QuickGetSb(http,L"https://telemetry.{{region}}.oraclecloud.com/20180401/alarms/:alarmId",sbResponseBody);
    if (success == FALSE) {
        wprintf(L"%s\n",CkHttpW_lastErrorText(http));
        CkHttpW_Dispose(http);
        CkStringBuilderW_Dispose(sbResponseBody);
        return;
    }

    jResp = CkJsonObjectW_Create();
    CkJsonObjectW_LoadSb(jResp,sbResponseBody);
    CkJsonObjectW_putEmitCompact(jResp,FALSE);

    wprintf(L"Response Body:\n");
    wprintf(L"%s\n",CkJsonObjectW_emit(jResp));

    respStatusCode = CkHttpW_getLastStatus(http);
    wprintf(L"Response Status Code = %d\n",respStatusCode);
    if (respStatusCode >= 400) {
        wprintf(L"Response Header:\n");
        wprintf(L"%s\n",CkHttpW_lastHeader(http));
        wprintf(L"Failed.\n");
        CkHttpW_Dispose(http);
        CkStringBuilderW_Dispose(sbResponseBody);
        CkJsonObjectW_Dispose(jResp);
        return;
    }

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

    // {
    //   "compartmentId": "veniam",
    //   "destinations": [
    //     "reprehenderit aute in magna"
    //   ],
    //   "displayName": "sit",
    //   "id": "Lorem qui ex veniam proident",
    //   "isEnabled": true,
    //   "lifecycleState": "DELETED",
    //   "metricCompartmentId": "reprehenderit nostrud est",
    //   "namespace": "cupidatat tempor aliquip elit",
    //   "query": "fugiat",
    //   "severity": "INFO",
    //   "timeCreated": "1944-02-22T03:18:34.935Z",
    //   "timeUpdated": "1988-11-03T02:58:13.311Z",
    //   "body": "labore id",
    //   "definedTags": {},
    //   "freeformTags": {},
    //   "metricCompartmentIdInSubtree": true,
    //   "pendingDuration": "nostrud",
    //   "repeatNotificationDuration": "incididunt ea",
    //   "resolution": "in nostrud sed aute",
    //   "resourceGroup": "nulla aliqua commodo sed",
    //   "suppression": {
    //     "timeSuppressFrom": "2004-03-12T05:00:19.371Z",
    //     "timeSuppressUntil": "1953-09-18T23:32:40.152Z",
    //     "description": "sit aute"
    //   }
    // }

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

    // Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat.

    compartmentId = CkJsonObjectW_stringOf(jResp,L"compartmentId");
    displayName = CkJsonObjectW_stringOf(jResp,L"displayName");
    id = CkJsonObjectW_stringOf(jResp,L"id");
    isEnabled = CkJsonObjectW_BoolOf(jResp,L"isEnabled");
    lifecycleState = CkJsonObjectW_stringOf(jResp,L"lifecycleState");
    metricCompartmentId = CkJsonObjectW_stringOf(jResp,L"metricCompartmentId");
    namespace = CkJsonObjectW_stringOf(jResp,L"namespace");
    query = CkJsonObjectW_stringOf(jResp,L"query");
    severity = CkJsonObjectW_stringOf(jResp,L"severity");
    timeCreated = CkJsonObjectW_stringOf(jResp,L"timeCreated");
    timeUpdated = CkJsonObjectW_stringOf(jResp,L"timeUpdated");
    body = CkJsonObjectW_stringOf(jResp,L"body");
    metricCompartmentIdInSubtree = CkJsonObjectW_BoolOf(jResp,L"metricCompartmentIdInSubtree");
    pendingDuration = CkJsonObjectW_stringOf(jResp,L"pendingDuration");
    repeatNotificationDuration = CkJsonObjectW_stringOf(jResp,L"repeatNotificationDuration");
    resolution = CkJsonObjectW_stringOf(jResp,L"resolution");
    resourceGroup = CkJsonObjectW_stringOf(jResp,L"resourceGroup");
    TimeSuppressFrom = CkJsonObjectW_stringOf(jResp,L"suppression.timeSuppressFrom");
    TimeSuppressUntil = CkJsonObjectW_stringOf(jResp,L"suppression.timeSuppressUntil");
    Description = CkJsonObjectW_stringOf(jResp,L"suppression.description");
    i = 0;
    count_i = CkJsonObjectW_SizeOfArray(jResp,L"destinations");
    while (i < count_i) {
        CkJsonObjectW_putI(jResp,i);
        strVal = CkJsonObjectW_stringOf(jResp,L"destinations[i]");
        i = i + 1;
    }



    CkHttpW_Dispose(http);
    CkStringBuilderW_Dispose(sbResponseBody);
    CkJsonObjectW_Dispose(jResp);

    }

Curl Command

curl -X GET
	-H "opc-request-id: pariatur nostrud eiusmod"
	-H "Date: {{date}}"
	-H "Authorization: {{signature}}"
https://telemetry.{{region}}.oraclecloud.com/20180401/alarms/:alarmId

Postman Collection Item JSON

{
  "name": "Get Alarm",
  "request": {
    "method": "GET",
    "header": [
      {
        "description": "Customer part of the request identifier token. If you need to contact Oracle about a particular\nrequest, please provide the complete request ID.\n",
        "key": "opc-request-id",
        "value": "pariatur nostrud eiusmod"
      },
      {
        "key": "Date",
        "value": "{{date}}",
        "description": "(Required) Current Date",
        "type": "text"
      },
      {
        "key": "Authorization",
        "value": "{{signature}}",
        "description": "(Required) Signature Authentication on Authorization header",
        "type": "text"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/alarms/:alarmId",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "alarms",
        ":alarmId"
      ],
      "variable": [
        {
          "key": "alarmId",
          "value": "mollit in Duis enim",
          "description": "(Required) The [OCID](https://docs.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of an alarm.\n"
        }
      ]
    },
    "description": "Gets the specified alarm.\nFor important limits information, see [Limits on Monitoring](https://docs.oracle.com/iaas/Content/Monitoring/Concepts/monitoringoverview.htm#Limits).\n\nThis call is subject to a Monitoring limit that applies to the total number of requests across all alarm operations.\nMonitoring might throttle this call to reject an otherwise valid request when the total rate of alarm operations exceeds 10 requests,\nor transactions, per second (TPS) for a given tenancy.\n"
  },
  "response": [
    {
      "name": "Successfully retrieved alarm.",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Customer part of the request identifier token. If you need to contact Oracle about a particular\nrequest, please provide the complete request ID.\n",
            "key": "opc-request-id",
            "value": "pariatur nostrud eiusmod"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/alarms/:alarmId",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "alarms",
            ":alarmId"
          ],
          "variable": [
            {
              "key": "alarmId"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "etag",
          "value": "pariatur nostrud eiusmod",
          "description": "For optimistic concurrency control. See `if-match`.\n"
        },
        {
          "key": "opc-request-id",
          "value": "pariatur nostrud eiusmod",
          "description": "Unique Oracle-assigned identifier for the request. If you need to contact Oracle about\na particular request, please provide the request ID.\n"
        },
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n \"compartmentId\": \"veniam\",\n \"destinations\": [\n  \"reprehenderit aute in magna\"\n ],\n \"displayName\": \"sit\",\n \"id\": \"Lorem qui ex veniam proident\",\n \"isEnabled\": true,\n \"lifecycleState\": \"DELETED\",\n \"metricCompartmentId\": \"reprehenderit nostrud est\",\n \"namespace\": \"cupidatat tempor aliquip elit\",\n \"query\": \"fugiat\",\n \"severity\": \"INFO\",\n \"timeCreated\": \"1944-02-22T03:18:34.935Z\",\n \"timeUpdated\": \"1988-11-03T02:58:13.311Z\",\n \"body\": \"labore id\",\n \"definedTags\": {},\n \"freeformTags\": {},\n \"metricCompartmentIdInSubtree\": true,\n \"pendingDuration\": \"nostrud\",\n \"repeatNotificationDuration\": \"incididunt ea\",\n \"resolution\": \"in nostrud sed aute\",\n \"resourceGroup\": \"nulla aliqua commodo sed\",\n \"suppression\": {\n  \"timeSuppressFrom\": \"2004-03-12T05:00:19.371Z\",\n  \"timeSuppressUntil\": \"1953-09-18T23:32:40.152Z\",\n  \"description\": \"sit aute\"\n }\n}"
    },
    {
      "name": "Bad Request",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Customer part of the request identifier token. If you need to contact Oracle about a particular\nrequest, please provide the complete request ID.\n",
            "key": "opc-request-id",
            "value": "pariatur nostrud eiusmod"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/alarms/:alarmId",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "alarms",
            ":alarmId"
          ],
          "variable": [
            {
              "key": "alarmId"
            }
          ]
        }
      },
      "status": "Bad Request",
      "code": 400,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "opc-request-id",
          "value": "pariatur nostrud eiusmod",
          "description": "Unique Oracle-assigned identifier for the request. If you need to contact Oracle about\na particular request, please provide the request ID.\n"
        },
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n \"code\": \"qui anim ut\",\n \"message\": \"esse proident\"\n}"
    },
    {
      "name": "Unauthorized",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Customer part of the request identifier token. If you need to contact Oracle about a particular\nrequest, please provide the complete request ID.\n",
            "key": "opc-request-id",
            "value": "pariatur nostrud eiusmod"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/alarms/:alarmId",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "alarms",
            ":alarmId"
          ],
          "variable": [
            {
              "key": "alarmId"
            }
          ]
        }
      },
      "status": "Unauthorized",
      "code": 401,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "opc-request-id",
          "value": "pariatur nostrud eiusmod",
          "description": "Unique Oracle-assigned identifier for the request. If you need to contact Oracle about\na particular request, please provide the request ID.\n"
        },
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n \"code\": \"qui anim ut\",\n \"message\": \"esse proident\"\n}"
    },
    {
      "name": "Not Authorized Or Not Found",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Customer part of the request identifier token. If you need to contact Oracle about a particular\nrequest, please provide the complete request ID.\n",
            "key": "opc-request-id",
            "value": "pariatur nostrud eiusmod"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/alarms/:alarmId",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "alarms",
            ":alarmId"
          ],
          "variable": [
            {
              "key": "alarmId"
            }
          ]
        }
      },
      "status": "Not Found",
      "code": 404,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "opc-request-id",
          "value": "pariatur nostrud eiusmod",
          "description": "Unique Oracle-assigned identifier for the request. If you need to contact Oracle about\na particular request, please provide the request ID.\n"
        },
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n \"code\": \"qui anim ut\",\n \"message\": \"esse proident\"\n}"
    },
    {
      "name": "Client is getting throttled, please retry with backoff.",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Customer part of the request identifier token. If you need to contact Oracle about a particular\nrequest, please provide the complete request ID.\n",
            "key": "opc-request-id",
            "value": "pariatur nostrud eiusmod"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/alarms/:alarmId",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "alarms",
            ":alarmId"
          ],
          "variable": [
            {
              "key": "alarmId"
            }
          ]
        }
      },
      "status": "Too Many Requests",
      "code": 429,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "opc-request-id",
          "value": "pariatur nostrud eiusmod",
          "description": "Unique Oracle-assigned identifier for the request. If you need to contact Oracle about\na particular request, please provide the request ID.\n"
        },
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n \"code\": \"qui anim ut\",\n \"message\": \"esse proident\"\n}"
    },
    {
      "name": "Internal Server Error",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Customer part of the request identifier token. If you need to contact Oracle about a particular\nrequest, please provide the complete request ID.\n",
            "key": "opc-request-id",
            "value": "pariatur nostrud eiusmod"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/alarms/:alarmId",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "alarms",
            ":alarmId"
          ],
          "variable": [
            {
              "key": "alarmId"
            }
          ]
        }
      },
      "status": "Internal Server Error",
      "code": 500,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "opc-request-id",
          "value": "pariatur nostrud eiusmod",
          "description": "Unique Oracle-assigned identifier for the request. If you need to contact Oracle about\na particular request, please provide the request ID.\n"
        },
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n \"code\": \"qui anim ut\",\n \"message\": \"esse proident\"\n}"
    },
    {
      "name": "An error has occurred.",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Customer part of the request identifier token. If you need to contact Oracle about a particular\nrequest, please provide the complete request ID.\n",
            "key": "opc-request-id",
            "value": "pariatur nostrud eiusmod"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/alarms/:alarmId",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "alarms",
            ":alarmId"
          ],
          "variable": [
            {
              "key": "alarmId"
            }
          ]
        }
      },
      "status": "Internal Server Error",
      "code": 500,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "opc-request-id",
          "value": "pariatur nostrud eiusmod",
          "description": "Unique Oracle-assigned identifier for the request. If you need to contact Oracle about\na particular request, please provide the request ID.\n"
        },
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n \"code\": \"qui anim ut\",\n \"message\": \"esse proident\"\n}"
    }
  ]
}