Chilkat Online Tools

Android / Monitoring API / List Alarms Status

Back to Collection Items

// Important: Don't forget to include the call to System.loadLibrary
// as shown at the bottom of this code sample.
package com.test;

import android.app.Activity;
import com.chilkatsoft.*;

import android.widget.TextView;
import android.os.Bundle;

public class SimpleActivity extends Activity {

  private static final String TAG = "Chilkat";

  // Called when the activity is first created.
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

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

    CkHttp http = new CkHttp();
    boolean success;

    CkJsonObject queryParams = new CkJsonObject();
    queryParams.UpdateString("compartmentId","{{compartment_ocid}}");
    queryParams.UpdateString("compartmentIdInSubtree","false");
    queryParams.UpdateString("page","");
    queryParams.UpdateInt("limit",576);
    queryParams.UpdateString("sortBy","displayName");
    queryParams.UpdateString("sortOrder","ASC");

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

    CkHttpResponse resp = http.QuickRequestParams("GET","https://telemetry.{{region}}.oraclecloud.com/20180401/alarms/status",queryParams);
    if (http.get_LastMethodSuccess() == false) {
        Log.i(TAG, http.lastErrorText());
        return;
        }

    CkStringBuilder sbResponseBody = new CkStringBuilder();
    resp.GetBodySb(sbResponseBody);

    CkJsonArray jarrResp = new CkJsonArray();
    jarrResp.LoadSb(sbResponseBody);
    jarrResp.put_EmitCompact(false);

    Log.i(TAG, "Response Body:");
    Log.i(TAG, jarrResp.emit());

    int respStatusCode = resp.get_StatusCode();
    Log.i(TAG, "Response Status Code = " + String.valueOf(respStatusCode));
    if (respStatusCode >= 400) {
        Log.i(TAG, "Response Header:");
        Log.i(TAG, resp.header());
        Log.i(TAG, "Failed.");

        return;
        }

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

    // [
    //   {
    //     "displayName": "Duis commodo",
    //     "id": "elit ex dolore dolor",
    //     "severity": "CRITICAL",
    //     "status": "OK",
    //     "timestampTriggered": "2014-10-26T06:31:02.895Z",
    //     "suppression": {
    //       "timeSuppressFrom": "1987-07-20T15:37:05.051Z",
    //       "timeSuppressUntil": "1968-03-29T00:30:10.046Z",
    //       "description": "deserunt minim esse"
    //     }
    //   },
    //   {
    //     "displayName": "ipsum irure",
    //     "id": "laboris",
    //     "severity": "CRITICAL",
    //     "status": "OK",
    //     "timestampTriggered": "1998-10-11T06:23:01.124Z",
    //     "suppression": {
    //       "timeSuppressFrom": "1997-07-01T12:35:24.780Z",
    //       "timeSuppressUntil": "2008-02-16T23:07:36.114Z",
    //       "description": "non minim dolor culpa est"
    //     }
    //   }
    // ]

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

    CkJsonObject json;
    String displayName;
    String id;
    String severity;
    String status;
    String timestampTriggered;
    String TimeSuppressFrom;
    String TimeSuppressUntil;
    String Description;

    int i = 0;
    int count_i = jarrResp.get_Size();
    while (i < count_i) {
        json = jarrResp.ObjectAt(i);
        displayName = json.stringOf("displayName");
        id = json.stringOf("id");
        severity = json.stringOf("severity");
        status = json.stringOf("status");
        timestampTriggered = json.stringOf("timestampTriggered");
        TimeSuppressFrom = json.stringOf("suppression.timeSuppressFrom");
        TimeSuppressUntil = json.stringOf("suppression.timeSuppressUntil");
        Description = json.stringOf("suppression.description");

        i = i + 1;
        }


  }

  static {
      System.loadLibrary("chilkat");

      // Note: If the incorrect library name is passed to System.loadLibrary,
      // then you will see the following error message at application startup:
      //"The application <your-application-name> has stopped unexpectedly. Please try again."
  }
}

Curl Command

curl -G -d "compartmentId=%7B%7Bcompartment_ocid%7D%7D"
	-d "compartmentIdInSubtree=false"
	-d "page="
	-d "limit=576"
	-d "sortBy=displayName"
	-d "sortOrder=ASC"
	-H "opc-request-id: pariatur nostrud eiusmod"
	-H "Date: {{date}}"
	-H "Authorization: {{signature}}"
https://telemetry.{{region}}.oraclecloud.com/20180401/alarms/status

Postman Collection Item JSON

{
  "name": "List Alarms Status",
  "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/status?compartmentId={{compartment_ocid}}&compartmentIdInSubtree=false&page=&limit=576&sortBy=displayName&sortOrder=ASC",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "alarms",
        "status"
      ],
      "query": [
        {
          "key": "compartmentId",
          "value": "{{compartment_ocid}}",
          "description": "(Required) The [OCID](https://docs.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the compartment containing the\nresources monitored by the metric that you are searching for. Use tenancyId to search in\nthe root compartment.\n\nExample: `ocid1.compartment.oc1..exampleuniqueID`\n"
        },
        {
          "key": "compartmentIdInSubtree",
          "value": "false",
          "description": "When true, returns resources from all compartments and subcompartments. The parameter can\nonly be set to true when compartmentId is the tenancy OCID (the tenancy is the root compartment).\nA true value requires the user to have tenancy-level permissions. If this requirement is not met,\nthen the call is rejected. When false, returns resources from only the compartment specified in\ncompartmentId. Default is false.\n"
        },
        {
          "key": "page",
          "value": "",
          "description": "For list pagination. The value of the `opc-next-page` response header from the previous \"List\" call.\nFor important details about how pagination works, see [List Pagination](https://docs.oracle.com/iaas/Content/API/Concepts/usingapi.htm#nine).\n"
        },
        {
          "key": "limit",
          "value": "576",
          "description": "For list pagination. The maximum number of results per page, or items to return in a paginated \"List\" call.\nFor important details about how pagination works, see [List Pagination](https://docs.oracle.com/iaas/Content/API/Concepts/usingapi.htm#nine).\n\nDefault: 1000\n\nExample: 500\n"
        },
        {
          "key": "displayName",
          "value": "laboris veniam quis",
          "description": "A filter to return only resources that match the given display name exactly.\nUse this filter to list an alarm by name. Alternatively, when you know the alarm OCID, use the GetAlarm operation.\n",
          "disabled": true
        },
        {
          "key": "sortBy",
          "value": "displayName",
          "description": "The field to use when sorting returned alarm definitions. Only one sorting level is provided.\n\nExample: `severity`\n"
        },
        {
          "key": "sortOrder",
          "value": "ASC",
          "description": "The sort order to use when sorting returned alarm definitions. Ascending (ASC) or descending (DESC).\n\nExample: `ASC`\n"
        }
      ]
    },
    "description": "List the status of each alarm in the specified compartment.\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 alarms status for listing.\n",
      "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/status?compartmentId=mollit in Duis enim&compartmentIdInSubtree=true&page=do ipsum&limit=576&displayName=laboris veniam quis&sortBy=displayName&sortOrder=ASC",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "alarms",
            "status"
          ],
          "query": [
            {
              "key": "compartmentId",
              "value": "mollit in Duis enim"
            },
            {
              "key": "compartmentIdInSubtree",
              "value": "true"
            },
            {
              "key": "page",
              "value": "do ipsum"
            },
            {
              "key": "limit",
              "value": "576"
            },
            {
              "key": "displayName",
              "value": "laboris veniam quis"
            },
            {
              "key": "sortBy",
              "value": "displayName"
            },
            {
              "key": "sortOrder",
              "value": "ASC"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "opc-next-page",
          "value": "pariatur nostrud eiusmod",
          "description": "For list pagination. When this header appears in the response, additional pages of results remain.\nFor important details about how pagination works, see [List Pagination](https://docs.oracle.com/iaas/Content/API/Concepts/usingapi.htm#nine).\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 {\n  \"displayName\": \"Duis commodo\",\n  \"id\": \"elit ex dolore dolor\",\n  \"severity\": \"CRITICAL\",\n  \"status\": \"OK\",\n  \"timestampTriggered\": \"2014-10-26T06:31:02.895Z\",\n  \"suppression\": {\n   \"timeSuppressFrom\": \"1987-07-20T15:37:05.051Z\",\n   \"timeSuppressUntil\": \"1968-03-29T00:30:10.046Z\",\n   \"description\": \"deserunt minim esse\"\n  }\n },\n {\n  \"displayName\": \"ipsum irure\",\n  \"id\": \"laboris\",\n  \"severity\": \"CRITICAL\",\n  \"status\": \"OK\",\n  \"timestampTriggered\": \"1998-10-11T06:23:01.124Z\",\n  \"suppression\": {\n   \"timeSuppressFrom\": \"1997-07-01T12:35:24.780Z\",\n   \"timeSuppressUntil\": \"2008-02-16T23:07:36.114Z\",\n   \"description\": \"non minim dolor culpa est\"\n  }\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/status?compartmentId=mollit in Duis enim&compartmentIdInSubtree=true&page=do ipsum&limit=576&displayName=laboris veniam quis&sortBy=displayName&sortOrder=ASC",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "alarms",
            "status"
          ],
          "query": [
            {
              "key": "compartmentId",
              "value": "mollit in Duis enim"
            },
            {
              "key": "compartmentIdInSubtree",
              "value": "true"
            },
            {
              "key": "page",
              "value": "do ipsum"
            },
            {
              "key": "limit",
              "value": "576"
            },
            {
              "key": "displayName",
              "value": "laboris veniam quis"
            },
            {
              "key": "sortBy",
              "value": "displayName"
            },
            {
              "key": "sortOrder",
              "value": "ASC"
            }
          ]
        }
      },
      "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/status?compartmentId=mollit in Duis enim&compartmentIdInSubtree=true&page=do ipsum&limit=576&displayName=laboris veniam quis&sortBy=displayName&sortOrder=ASC",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "alarms",
            "status"
          ],
          "query": [
            {
              "key": "compartmentId",
              "value": "mollit in Duis enim"
            },
            {
              "key": "compartmentIdInSubtree",
              "value": "true"
            },
            {
              "key": "page",
              "value": "do ipsum"
            },
            {
              "key": "limit",
              "value": "576"
            },
            {
              "key": "displayName",
              "value": "laboris veniam quis"
            },
            {
              "key": "sortBy",
              "value": "displayName"
            },
            {
              "key": "sortOrder",
              "value": "ASC"
            }
          ]
        }
      },
      "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/status?compartmentId=mollit in Duis enim&compartmentIdInSubtree=true&page=do ipsum&limit=576&displayName=laboris veniam quis&sortBy=displayName&sortOrder=ASC",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "alarms",
            "status"
          ],
          "query": [
            {
              "key": "compartmentId",
              "value": "mollit in Duis enim"
            },
            {
              "key": "compartmentIdInSubtree",
              "value": "true"
            },
            {
              "key": "page",
              "value": "do ipsum"
            },
            {
              "key": "limit",
              "value": "576"
            },
            {
              "key": "displayName",
              "value": "laboris veniam quis"
            },
            {
              "key": "sortBy",
              "value": "displayName"
            },
            {
              "key": "sortOrder",
              "value": "ASC"
            }
          ]
        }
      },
      "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/status?compartmentId=mollit in Duis enim&compartmentIdInSubtree=true&page=do ipsum&limit=576&displayName=laboris veniam quis&sortBy=displayName&sortOrder=ASC",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "alarms",
            "status"
          ],
          "query": [
            {
              "key": "compartmentId",
              "value": "mollit in Duis enim"
            },
            {
              "key": "compartmentIdInSubtree",
              "value": "true"
            },
            {
              "key": "page",
              "value": "do ipsum"
            },
            {
              "key": "limit",
              "value": "576"
            },
            {
              "key": "displayName",
              "value": "laboris veniam quis"
            },
            {
              "key": "sortBy",
              "value": "displayName"
            },
            {
              "key": "sortOrder",
              "value": "ASC"
            }
          ]
        }
      },
      "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/status?compartmentId=mollit in Duis enim&compartmentIdInSubtree=true&page=do ipsum&limit=576&displayName=laboris veniam quis&sortBy=displayName&sortOrder=ASC",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "alarms",
            "status"
          ],
          "query": [
            {
              "key": "compartmentId",
              "value": "mollit in Duis enim"
            },
            {
              "key": "compartmentIdInSubtree",
              "value": "true"
            },
            {
              "key": "page",
              "value": "do ipsum"
            },
            {
              "key": "limit",
              "value": "576"
            },
            {
              "key": "displayName",
              "value": "laboris veniam quis"
            },
            {
              "key": "sortBy",
              "value": "displayName"
            },
            {
              "key": "sortOrder",
              "value": "ASC"
            }
          ]
        }
      },
      "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/status?compartmentId=mollit in Duis enim&compartmentIdInSubtree=true&page=do ipsum&limit=576&displayName=laboris veniam quis&sortBy=displayName&sortOrder=ASC",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "alarms",
            "status"
          ],
          "query": [
            {
              "key": "compartmentId",
              "value": "mollit in Duis enim"
            },
            {
              "key": "compartmentIdInSubtree",
              "value": "true"
            },
            {
              "key": "page",
              "value": "do ipsum"
            },
            {
              "key": "limit",
              "value": "576"
            },
            {
              "key": "displayName",
              "value": "laboris veniam quis"
            },
            {
              "key": "sortBy",
              "value": "displayName"
            },
            {
              "key": "sortOrder",
              "value": "ASC"
            }
          ]
        }
      },
      "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}"
    }
  ]
}