Chilkat Online Tools

SQL Server / Monitoring API / Get Alarm

Back to Collection Items

-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    -- Important: Do not use nvarchar(max).  See the warning about using nvarchar(max).
    DECLARE @sTmp0 nvarchar(4000)
    -- This example assumes the Chilkat API to have been previously unlocked.
    -- See Global Unlock Sample for sample code.

    DECLARE @http int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.Http', @http OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    DECLARE @success int

    EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'opc-request-id', 'pariatur nostrud eiusmod'
    EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Authorization', '{{signature}}'
    EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Date', '{{date}}'

    DECLARE @sbResponseBody int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.StringBuilder', @sbResponseBody OUT

    EXEC sp_OAMethod @http, 'QuickGetSb', @success OUT, 'https://telemetry.{{region}}.oraclecloud.com/20180401/alarms/:alarmId', @sbResponseBody
    IF @success = 0
      BEGIN
        EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @http
        EXEC @hr = sp_OADestroy @sbResponseBody
        RETURN
      END

    DECLARE @jResp int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.JsonObject', @jResp OUT

    EXEC sp_OAMethod @jResp, 'LoadSb', @success OUT, @sbResponseBody
    EXEC sp_OASetProperty @jResp, 'EmitCompact', 0


    PRINT 'Response Body:'
    EXEC sp_OAMethod @jResp, 'Emit', @sTmp0 OUT
    PRINT @sTmp0

    DECLARE @respStatusCode int
    EXEC sp_OAGetProperty @http, 'LastStatus', @respStatusCode OUT

    PRINT 'Response Status Code = ' + @respStatusCode
    IF @respStatusCode >= 400
      BEGIN

        PRINT 'Response Header:'
        EXEC sp_OAGetProperty @http, 'LastHeader', @sTmp0 OUT
        PRINT @sTmp0

        PRINT 'Failed.'
        EXEC @hr = sp_OADestroy @http
        EXEC @hr = sp_OADestroy @sbResponseBody
        EXEC @hr = sp_OADestroy @jResp
        RETURN
      END

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

    DECLARE @strVal nvarchar(4000)

    DECLARE @compartmentId nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @compartmentId OUT, 'compartmentId'
    DECLARE @displayName nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @displayName OUT, 'displayName'
    DECLARE @id nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @id OUT, 'id'
    DECLARE @isEnabled int
    EXEC sp_OAMethod @jResp, 'BoolOf', @isEnabled OUT, 'isEnabled'
    DECLARE @lifecycleState nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @lifecycleState OUT, 'lifecycleState'
    DECLARE @metricCompartmentId nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @metricCompartmentId OUT, 'metricCompartmentId'
    DECLARE @namespace nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @namespace OUT, 'namespace'
    DECLARE @query nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @query OUT, 'query'
    DECLARE @severity nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @severity OUT, 'severity'
    DECLARE @timeCreated nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @timeCreated OUT, 'timeCreated'
    DECLARE @timeUpdated nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @timeUpdated OUT, 'timeUpdated'
    DECLARE @body nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @body OUT, 'body'
    DECLARE @metricCompartmentIdInSubtree int
    EXEC sp_OAMethod @jResp, 'BoolOf', @metricCompartmentIdInSubtree OUT, 'metricCompartmentIdInSubtree'
    DECLARE @pendingDuration nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @pendingDuration OUT, 'pendingDuration'
    DECLARE @repeatNotificationDuration nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @repeatNotificationDuration OUT, 'repeatNotificationDuration'
    DECLARE @resolution nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @resolution OUT, 'resolution'
    DECLARE @resourceGroup nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @resourceGroup OUT, 'resourceGroup'
    DECLARE @TimeSuppressFrom nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @TimeSuppressFrom OUT, 'suppression.timeSuppressFrom'
    DECLARE @TimeSuppressUntil nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @TimeSuppressUntil OUT, 'suppression.timeSuppressUntil'
    DECLARE @Description nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @Description OUT, 'suppression.description'
    DECLARE @i int
    SELECT @i = 0
    DECLARE @count_i int
    EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'destinations'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jResp, 'I', @i
        EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'destinations[i]'
        SELECT @i = @i + 1
      END

    EXEC @hr = sp_OADestroy @http
    EXEC @hr = sp_OADestroy @sbResponseBody
    EXEC @hr = sp_OADestroy @jResp


END
GO

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