ListAnomaliesForInsight SQL Server Example
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @iTmp0 int
DECLARE @sTmp0 nvarchar(max)
-- This example requires the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
DECLARE @rest int
EXEC @hr = sp_OACreate 'Chilkat_9_5_0.Rest', @rest OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
DECLARE @success int
DECLARE @authAws int
EXEC @hr = sp_OACreate 'Chilkat_9_5_0.AuthAws', @authAws OUT
EXEC sp_OASetProperty @authAws, 'AccessKey', 'AWS_ACCESS_KEY'
EXEC sp_OASetProperty @authAws, 'SecretKey', 'AWS_SECRET_KEY'
-- Don't forget to change the region to your particular region. (Also make the same change in the call to Connect below.)
EXEC sp_OASetProperty @authAws, 'Region', 'us-west-2'
EXEC sp_OASetProperty @authAws, 'ServiceName', 'devops-guru'
-- SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
EXEC sp_OAMethod @rest, 'SetAuthAws', @success OUT, @authAws
-- URL: https://devops-guru.us-west-2.amazonaws.com/
-- Use the same region as specified above.
EXEC sp_OAMethod @rest, 'Connect', @success OUT, 'devops-guru.us-west-2.amazonaws.com', 443, 1, 1
IF @success <> 1
BEGIN
EXEC sp_OAGetProperty @rest, 'ConnectFailReason', @iTmp0 OUT
PRINT 'ConnectFailReason: ' + @iTmp0
EXEC sp_OAGetProperty @rest, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @rest
EXEC @hr = sp_OADestroy @authAws
RETURN
END
-- The following code creates the JSON request body.
-- The JSON created by this code is shown below.
-- Use this online tool to generate code from sample JSON:
-- Generate Code to Create JSON
DECLARE @json int
EXEC @hr = sp_OACreate 'Chilkat_9_5_0.JsonObject', @json OUT
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'AccountId', 'string'
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'MaxResults', 123
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'NextToken', 'string'
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'StartTimeRange.FromTime', 123
EXEC sp_OAMethod @json, 'UpdateInt', @success OUT, 'StartTimeRange.ToTime', 123
-- The JSON request body created by the above code:
-- {
-- "AccountId": "string",
-- "MaxResults": number,
-- "NextToken": "string",
-- "StartTimeRange": {
-- "FromTime": number,
-- "ToTime": number
-- }
-- }
EXEC sp_OAMethod @rest, 'AddHeader', @success OUT, 'Content-Type', 'application/x-amz-json-1.1'
EXEC sp_OAMethod @rest, 'AddHeader', @success OUT, 'X-Amz-Target', 'ListAnomaliesForInsight'
DECLARE @sbRequestBody int
EXEC @hr = sp_OACreate 'Chilkat_9_5_0.StringBuilder', @sbRequestBody OUT
EXEC sp_OAMethod @json, 'EmitSb', @success OUT, @sbRequestBody
DECLARE @sbResponseBody int
EXEC @hr = sp_OACreate 'Chilkat_9_5_0.StringBuilder', @sbResponseBody OUT
EXEC sp_OAMethod @rest, 'FullRequestSb', @success OUT, 'POST', '/anomalies/insight/{InsightId}', @sbRequestBody, @sbResponseBody
IF @success <> 1
BEGIN
EXEC sp_OAGetProperty @rest, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @rest
EXEC @hr = sp_OADestroy @authAws
EXEC @hr = sp_OADestroy @json
EXEC @hr = sp_OADestroy @sbRequestBody
EXEC @hr = sp_OADestroy @sbResponseBody
RETURN
END
DECLARE @respStatusCode int
EXEC sp_OAGetProperty @rest, 'ResponseStatusCode', @respStatusCode OUT
PRINT 'response status code = ' + @respStatusCode
IF @respStatusCode <> 200
BEGIN
PRINT 'Response Header:'
EXEC sp_OAGetProperty @rest, 'ResponseHeader', @sTmp0 OUT
PRINT @sTmp0
PRINT 'Response Body:'
EXEC sp_OAMethod @sbResponseBody, 'GetAsString', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @rest
EXEC @hr = sp_OADestroy @authAws
EXEC @hr = sp_OADestroy @json
EXEC @hr = sp_OADestroy @sbRequestBody
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
-- The following code parses the JSON response.
-- A sample JSON response is shown below the sample code.
-- Use this online tool to generate parsing code from sample JSON:
-- Generate Parsing Code from JSON
DECLARE @CloseTime int
DECLARE @OpenTime int
DECLARE @EndTime int
DECLARE @StartTime int
DECLARE @AssociatedInsightId nvarchar(max)
DECLARE @Id nvarchar(max)
DECLARE @Limit int
DECLARE @PredictionTimeRangeEndTime int
DECLARE @PredictionTimeRangeStartTime int
DECLARE @Severity nvarchar(max)
DECLARE @Source nvarchar(max)
DECLARE @SourceResourceName nvarchar(max)
DECLARE @SourceResourceType nvarchar(max)
DECLARE @Status nvarchar(max)
DECLARE @UpdateTime int
DECLARE @j int
DECLARE @count_j int
DECLARE @Name nvarchar(max)
DECLARE @v_Type nvarchar(max)
DECLARE @strVal nvarchar(max)
DECLARE @AppBoundaryKey nvarchar(max)
DECLARE @k int
DECLARE @count_k int
DECLARE @StatusCode nvarchar(max)
DECLARE @MetricName nvarchar(max)
DECLARE @Namespace nvarchar(max)
DECLARE @Period int
DECLARE @Stat nvarchar(max)
DECLARE @Unit nvarchar(max)
DECLARE @Value nvarchar(max)
DECLARE @MetricValue int
DECLARE @Timestamp int
DECLARE @MetricDisplayName nvarchar(max)
DECLARE @v_String nvarchar(max)
DECLARE @Group nvarchar(max)
DECLARE @GroupByLimit int
DECLARE @Metric nvarchar(max)
DECLARE @FilterString nvarchar(max)
DECLARE @GroupByGroup nvarchar(max)
DECLARE @MetricQueryMetric nvarchar(max)
DECLARE @ReferenceScalarValue int
DECLARE @json1 int
DECLARE @i1 int
DECLARE @count_i1 int
DECLARE @Value_int int
DECLARE @AnomalyReportedTimeRangeCloseTime int
DECLARE @AnomalyReportedTimeRangeOpenTime int
DECLARE @AnomalyTimeRangeEndTime int
DECLARE @AnomalyTimeRangeStartTime int
DECLARE @CausalAnomalyId nvarchar(max)
DECLARE @Description nvarchar(max)
DECLARE @MetricDataSummaryStatusCode nvarchar(max)
DECLARE @NextToken nvarchar(max)
EXEC sp_OAMethod @jResp, 'StringOf', @NextToken OUT, 'NextToken'
DECLARE @i int
SELECT @i = 0
DECLARE @count_i int
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'ProactiveAnomalies'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'IntOf', @CloseTime OUT, 'ProactiveAnomalies[i].AnomalyReportedTimeRange.CloseTime'
EXEC sp_OAMethod @jResp, 'IntOf', @OpenTime OUT, 'ProactiveAnomalies[i].AnomalyReportedTimeRange.OpenTime'
EXEC sp_OAMethod @jResp, 'IntOf', @EndTime OUT, 'ProactiveAnomalies[i].AnomalyTimeRange.EndTime'
EXEC sp_OAMethod @jResp, 'IntOf', @StartTime OUT, 'ProactiveAnomalies[i].AnomalyTimeRange.StartTime'
EXEC sp_OAMethod @jResp, 'StringOf', @AssociatedInsightId OUT, 'ProactiveAnomalies[i].AssociatedInsightId'
EXEC sp_OAMethod @jResp, 'StringOf', @Id OUT, 'ProactiveAnomalies[i].Id'
EXEC sp_OAMethod @jResp, 'IntOf', @Limit OUT, 'ProactiveAnomalies[i].Limit'
EXEC sp_OAMethod @jResp, 'IntOf', @PredictionTimeRangeEndTime OUT, 'ProactiveAnomalies[i].PredictionTimeRange.EndTime'
EXEC sp_OAMethod @jResp, 'IntOf', @PredictionTimeRangeStartTime OUT, 'ProactiveAnomalies[i].PredictionTimeRange.StartTime'
EXEC sp_OAMethod @jResp, 'StringOf', @Severity OUT, 'ProactiveAnomalies[i].Severity'
EXEC sp_OAMethod @jResp, 'StringOf', @Source OUT, 'ProactiveAnomalies[i].SourceMetadata.Source'
EXEC sp_OAMethod @jResp, 'StringOf', @SourceResourceName OUT, 'ProactiveAnomalies[i].SourceMetadata.SourceResourceName'
EXEC sp_OAMethod @jResp, 'StringOf', @SourceResourceType OUT, 'ProactiveAnomalies[i].SourceMetadata.SourceResourceType'
EXEC sp_OAMethod @jResp, 'StringOf', @Status OUT, 'ProactiveAnomalies[i].Status'
EXEC sp_OAMethod @jResp, 'IntOf', @UpdateTime OUT, 'ProactiveAnomalies[i].UpdateTime'
SELECT @j = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'ProactiveAnomalies[i].AnomalyResources'
WHILE @j < @count_j
BEGIN
EXEC sp_OASetProperty @jResp, 'J', @j
EXEC sp_OAMethod @jResp, 'StringOf', @Name OUT, 'ProactiveAnomalies[i].AnomalyResources[j].Name'
EXEC sp_OAMethod @jResp, 'StringOf', @v_Type OUT, 'ProactiveAnomalies[i].AnomalyResources[j].Type'
SELECT @j = @j + 1
END
SELECT @j = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'ProactiveAnomalies[i].ResourceCollection.CloudFormation.StackNames'
WHILE @j < @count_j
BEGIN
EXEC sp_OASetProperty @jResp, 'J', @j
EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'ProactiveAnomalies[i].ResourceCollection.CloudFormation.StackNames[j]'
SELECT @j = @j + 1
END
SELECT @j = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'ProactiveAnomalies[i].ResourceCollection.Tags'
WHILE @j < @count_j
BEGIN
EXEC sp_OASetProperty @jResp, 'J', @j
EXEC sp_OAMethod @jResp, 'StringOf', @AppBoundaryKey OUT, 'ProactiveAnomalies[i].ResourceCollection.Tags[j].AppBoundaryKey'
SELECT @k = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_k OUT, 'ProactiveAnomalies[i].ResourceCollection.Tags[j].TagValues'
WHILE @k < @count_k
BEGIN
EXEC sp_OASetProperty @jResp, 'K', @k
EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'ProactiveAnomalies[i].ResourceCollection.Tags[j].TagValues[k]'
SELECT @k = @k + 1
END
SELECT @j = @j + 1
END
SELECT @j = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'ProactiveAnomalies[i].SourceDetails.CloudWatchMetrics'
WHILE @j < @count_j
BEGIN
EXEC sp_OASetProperty @jResp, 'J', @j
EXEC sp_OAMethod @jResp, 'StringOf', @StatusCode OUT, 'ProactiveAnomalies[i].SourceDetails.CloudWatchMetrics[j].MetricDataSummary.StatusCode'
EXEC sp_OAMethod @jResp, 'StringOf', @MetricName OUT, 'ProactiveAnomalies[i].SourceDetails.CloudWatchMetrics[j].MetricName'
EXEC sp_OAMethod @jResp, 'StringOf', @Namespace OUT, 'ProactiveAnomalies[i].SourceDetails.CloudWatchMetrics[j].Namespace'
EXEC sp_OAMethod @jResp, 'IntOf', @Period OUT, 'ProactiveAnomalies[i].SourceDetails.CloudWatchMetrics[j].Period'
EXEC sp_OAMethod @jResp, 'StringOf', @Stat OUT, 'ProactiveAnomalies[i].SourceDetails.CloudWatchMetrics[j].Stat'
EXEC sp_OAMethod @jResp, 'StringOf', @Unit OUT, 'ProactiveAnomalies[i].SourceDetails.CloudWatchMetrics[j].Unit'
SELECT @k = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_k OUT, 'ProactiveAnomalies[i].SourceDetails.CloudWatchMetrics[j].Dimensions'
WHILE @k < @count_k
BEGIN
EXEC sp_OASetProperty @jResp, 'K', @k
EXEC sp_OAMethod @jResp, 'StringOf', @Name OUT, 'ProactiveAnomalies[i].SourceDetails.CloudWatchMetrics[j].Dimensions[k].Name'
EXEC sp_OAMethod @jResp, 'StringOf', @Value OUT, 'ProactiveAnomalies[i].SourceDetails.CloudWatchMetrics[j].Dimensions[k].Value'
SELECT @k = @k + 1
END
SELECT @k = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_k OUT, 'ProactiveAnomalies[i].SourceDetails.CloudWatchMetrics[j].MetricDataSummary.TimestampMetricValuePairList'
WHILE @k < @count_k
BEGIN
EXEC sp_OASetProperty @jResp, 'K', @k
EXEC sp_OAMethod @jResp, 'IntOf', @MetricValue OUT, 'ProactiveAnomalies[i].SourceDetails.CloudWatchMetrics[j].MetricDataSummary.TimestampMetricValuePairList[k].MetricValue'
EXEC sp_OAMethod @jResp, 'IntOf', @Timestamp OUT, 'ProactiveAnomalies[i].SourceDetails.CloudWatchMetrics[j].MetricDataSummary.TimestampMetricValuePairList[k].Timestamp'
SELECT @k = @k + 1
END
SELECT @j = @j + 1
END
SELECT @j = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'ProactiveAnomalies[i].SourceDetails.PerformanceInsightsMetrics'
WHILE @j < @count_j
BEGIN
EXEC sp_OASetProperty @jResp, 'J', @j
EXEC sp_OAMethod @jResp, 'StringOf', @MetricDisplayName OUT, 'ProactiveAnomalies[i].SourceDetails.PerformanceInsightsMetrics[j].MetricDisplayName'
EXEC sp_OAMethod @jResp, 'StringOf', @v_String OUT, 'ProactiveAnomalies[i].SourceDetails.PerformanceInsightsMetrics[j].MetricQuery.Filter.string'
EXEC sp_OAMethod @jResp, 'StringOf', @Group OUT, 'ProactiveAnomalies[i].SourceDetails.PerformanceInsightsMetrics[j].MetricQuery.GroupBy.Group'
EXEC sp_OAMethod @jResp, 'IntOf', @GroupByLimit OUT, 'ProactiveAnomalies[i].SourceDetails.PerformanceInsightsMetrics[j].MetricQuery.GroupBy.Limit'
EXEC sp_OAMethod @jResp, 'StringOf', @Metric OUT, 'ProactiveAnomalies[i].SourceDetails.PerformanceInsightsMetrics[j].MetricQuery.Metric'
EXEC sp_OAMethod @jResp, 'StringOf', @Unit OUT, 'ProactiveAnomalies[i].SourceDetails.PerformanceInsightsMetrics[j].Unit'
SELECT @k = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_k OUT, 'ProactiveAnomalies[i].SourceDetails.PerformanceInsightsMetrics[j].MetricQuery.GroupBy.Dimensions'
WHILE @k < @count_k
BEGIN
EXEC sp_OASetProperty @jResp, 'K', @k
EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'ProactiveAnomalies[i].SourceDetails.PerformanceInsightsMetrics[j].MetricQuery.GroupBy.Dimensions[k]'
SELECT @k = @k + 1
END
SELECT @k = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_k OUT, 'ProactiveAnomalies[i].SourceDetails.PerformanceInsightsMetrics[j].ReferenceData'
WHILE @k < @count_k
BEGIN
EXEC sp_OASetProperty @jResp, 'K', @k
EXEC sp_OAMethod @jResp, 'StringOf', @FilterString OUT, 'ProactiveAnomalies[i].SourceDetails.PerformanceInsightsMetrics[j].ReferenceData[k].ComparisonValues.ReferenceMetric.MetricQuery.Filter.string'
EXEC sp_OAMethod @jResp, 'StringOf', @GroupByGroup OUT, 'ProactiveAnomalies[i].SourceDetails.PerformanceInsightsMetrics[j].ReferenceData[k].ComparisonValues.ReferenceMetric.MetricQuery.GroupBy.Group'
EXEC sp_OAMethod @jResp, 'IntOf', @GroupByLimit OUT, 'ProactiveAnomalies[i].SourceDetails.PerformanceInsightsMetrics[j].ReferenceData[k].ComparisonValues.ReferenceMetric.MetricQuery.GroupBy.Limit'
EXEC sp_OAMethod @jResp, 'StringOf', @MetricQueryMetric OUT, 'ProactiveAnomalies[i].SourceDetails.PerformanceInsightsMetrics[j].ReferenceData[k].ComparisonValues.ReferenceMetric.MetricQuery.Metric'
EXEC sp_OAMethod @jResp, 'IntOf', @ReferenceScalarValue OUT, 'ProactiveAnomalies[i].SourceDetails.PerformanceInsightsMetrics[j].ReferenceData[k].ComparisonValues.ReferenceScalar.Value'
EXEC sp_OAMethod @jResp, 'StringOf', @Name OUT, 'ProactiveAnomalies[i].SourceDetails.PerformanceInsightsMetrics[j].ReferenceData[k].Name'
EXEC sp_OAMethod @jResp, 'ObjectOf', @json1 OUT, 'ProactiveAnomalies[i].SourceDetails.PerformanceInsightsMetrics[j].ReferenceData[k]'
SELECT @i1 = 0
EXEC sp_OAMethod @json1, 'SizeOfArray', @count_i1 OUT, 'ComparisonValues.ReferenceMetric.MetricQuery.GroupBy.Dimensions'
WHILE @i1 < @count_i1
BEGIN
EXEC sp_OASetProperty @json1, 'I', @i1
EXEC sp_OAMethod @json1, 'StringOf', @strVal OUT, 'ComparisonValues.ReferenceMetric.MetricQuery.GroupBy.Dimensions[i]'
SELECT @i1 = @i1 + 1
END
EXEC @hr = sp_OADestroy @json1
SELECT @k = @k + 1
END
SELECT @k = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_k OUT, 'ProactiveAnomalies[i].SourceDetails.PerformanceInsightsMetrics[j].StatsAtAnomaly'
WHILE @k < @count_k
BEGIN
EXEC sp_OASetProperty @jResp, 'K', @k
EXEC sp_OAMethod @jResp, 'StringOf', @v_Type OUT, 'ProactiveAnomalies[i].SourceDetails.PerformanceInsightsMetrics[j].StatsAtAnomaly[k].Type'
EXEC sp_OAMethod @jResp, 'IntOf', @Value_int OUT, 'ProactiveAnomalies[i].SourceDetails.PerformanceInsightsMetrics[j].StatsAtAnomaly[k].Value'
SELECT @k = @k + 1
END
SELECT @k = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_k OUT, 'ProactiveAnomalies[i].SourceDetails.PerformanceInsightsMetrics[j].StatsAtBaseline'
WHILE @k < @count_k
BEGIN
EXEC sp_OASetProperty @jResp, 'K', @k
EXEC sp_OAMethod @jResp, 'StringOf', @v_Type OUT, 'ProactiveAnomalies[i].SourceDetails.PerformanceInsightsMetrics[j].StatsAtBaseline[k].Type'
EXEC sp_OAMethod @jResp, 'IntOf', @Value_int OUT, 'ProactiveAnomalies[i].SourceDetails.PerformanceInsightsMetrics[j].StatsAtBaseline[k].Value'
SELECT @k = @k + 1
END
SELECT @j = @j + 1
END
SELECT @i = @i + 1
END
SELECT @i = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'ReactiveAnomalies'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'IntOf', @AnomalyReportedTimeRangeCloseTime OUT, 'ReactiveAnomalies[i].AnomalyReportedTimeRange.CloseTime'
EXEC sp_OAMethod @jResp, 'IntOf', @AnomalyReportedTimeRangeOpenTime OUT, 'ReactiveAnomalies[i].AnomalyReportedTimeRange.OpenTime'
EXEC sp_OAMethod @jResp, 'IntOf', @AnomalyTimeRangeEndTime OUT, 'ReactiveAnomalies[i].AnomalyTimeRange.EndTime'
EXEC sp_OAMethod @jResp, 'IntOf', @AnomalyTimeRangeStartTime OUT, 'ReactiveAnomalies[i].AnomalyTimeRange.StartTime'
EXEC sp_OAMethod @jResp, 'StringOf', @AssociatedInsightId OUT, 'ReactiveAnomalies[i].AssociatedInsightId'
EXEC sp_OAMethod @jResp, 'StringOf', @CausalAnomalyId OUT, 'ReactiveAnomalies[i].CausalAnomalyId'
EXEC sp_OAMethod @jResp, 'StringOf', @Description OUT, 'ReactiveAnomalies[i].Description'
EXEC sp_OAMethod @jResp, 'StringOf', @Id OUT, 'ReactiveAnomalies[i].Id'
EXEC sp_OAMethod @jResp, 'StringOf', @Name OUT, 'ReactiveAnomalies[i].Name'
EXEC sp_OAMethod @jResp, 'StringOf', @Severity OUT, 'ReactiveAnomalies[i].Severity'
EXEC sp_OAMethod @jResp, 'StringOf', @Status OUT, 'ReactiveAnomalies[i].Status'
EXEC sp_OAMethod @jResp, 'StringOf', @v_Type OUT, 'ReactiveAnomalies[i].Type'
SELECT @j = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'ReactiveAnomalies[i].AnomalyResources'
WHILE @j < @count_j
BEGIN
EXEC sp_OASetProperty @jResp, 'J', @j
EXEC sp_OAMethod @jResp, 'StringOf', @Name OUT, 'ReactiveAnomalies[i].AnomalyResources[j].Name'
EXEC sp_OAMethod @jResp, 'StringOf', @v_Type OUT, 'ReactiveAnomalies[i].AnomalyResources[j].Type'
SELECT @j = @j + 1
END
SELECT @j = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'ReactiveAnomalies[i].ResourceCollection.CloudFormation.StackNames'
WHILE @j < @count_j
BEGIN
EXEC sp_OASetProperty @jResp, 'J', @j
EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'ReactiveAnomalies[i].ResourceCollection.CloudFormation.StackNames[j]'
SELECT @j = @j + 1
END
SELECT @j = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'ReactiveAnomalies[i].ResourceCollection.Tags'
WHILE @j < @count_j
BEGIN
EXEC sp_OASetProperty @jResp, 'J', @j
EXEC sp_OAMethod @jResp, 'StringOf', @AppBoundaryKey OUT, 'ReactiveAnomalies[i].ResourceCollection.Tags[j].AppBoundaryKey'
SELECT @k = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_k OUT, 'ReactiveAnomalies[i].ResourceCollection.Tags[j].TagValues'
WHILE @k < @count_k
BEGIN
EXEC sp_OASetProperty @jResp, 'K', @k
EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'ReactiveAnomalies[i].ResourceCollection.Tags[j].TagValues[k]'
SELECT @k = @k + 1
END
SELECT @j = @j + 1
END
SELECT @j = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'ReactiveAnomalies[i].SourceDetails.CloudWatchMetrics'
WHILE @j < @count_j
BEGIN
EXEC sp_OASetProperty @jResp, 'J', @j
EXEC sp_OAMethod @jResp, 'StringOf', @MetricDataSummaryStatusCode OUT, 'ReactiveAnomalies[i].SourceDetails.CloudWatchMetrics[j].MetricDataSummary.StatusCode'
EXEC sp_OAMethod @jResp, 'StringOf', @MetricName OUT, 'ReactiveAnomalies[i].SourceDetails.CloudWatchMetrics[j].MetricName'
EXEC sp_OAMethod @jResp, 'StringOf', @Namespace OUT, 'ReactiveAnomalies[i].SourceDetails.CloudWatchMetrics[j].Namespace'
EXEC sp_OAMethod @jResp, 'IntOf', @Period OUT, 'ReactiveAnomalies[i].SourceDetails.CloudWatchMetrics[j].Period'
EXEC sp_OAMethod @jResp, 'StringOf', @Stat OUT, 'ReactiveAnomalies[i].SourceDetails.CloudWatchMetrics[j].Stat'
EXEC sp_OAMethod @jResp, 'StringOf', @Unit OUT, 'ReactiveAnomalies[i].SourceDetails.CloudWatchMetrics[j].Unit'
SELECT @k = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_k OUT, 'ReactiveAnomalies[i].SourceDetails.CloudWatchMetrics[j].Dimensions'
WHILE @k < @count_k
BEGIN
EXEC sp_OASetProperty @jResp, 'K', @k
EXEC sp_OAMethod @jResp, 'StringOf', @Name OUT, 'ReactiveAnomalies[i].SourceDetails.CloudWatchMetrics[j].Dimensions[k].Name'
EXEC sp_OAMethod @jResp, 'StringOf', @Value OUT, 'ReactiveAnomalies[i].SourceDetails.CloudWatchMetrics[j].Dimensions[k].Value'
SELECT @k = @k + 1
END
SELECT @k = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_k OUT, 'ReactiveAnomalies[i].SourceDetails.CloudWatchMetrics[j].MetricDataSummary.TimestampMetricValuePairList'
WHILE @k < @count_k
BEGIN
EXEC sp_OASetProperty @jResp, 'K', @k
EXEC sp_OAMethod @jResp, 'IntOf', @MetricValue OUT, 'ReactiveAnomalies[i].SourceDetails.CloudWatchMetrics[j].MetricDataSummary.TimestampMetricValuePairList[k].MetricValue'
EXEC sp_OAMethod @jResp, 'IntOf', @Timestamp OUT, 'ReactiveAnomalies[i].SourceDetails.CloudWatchMetrics[j].MetricDataSummary.TimestampMetricValuePairList[k].Timestamp'
SELECT @k = @k + 1
END
SELECT @j = @j + 1
END
SELECT @j = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_j OUT, 'ReactiveAnomalies[i].SourceDetails.PerformanceInsightsMetrics'
WHILE @j < @count_j
BEGIN
EXEC sp_OASetProperty @jResp, 'J', @j
EXEC sp_OAMethod @jResp, 'StringOf', @MetricDisplayName OUT, 'ReactiveAnomalies[i].SourceDetails.PerformanceInsightsMetrics[j].MetricDisplayName'
EXEC sp_OAMethod @jResp, 'StringOf', @FilterString OUT, 'ReactiveAnomalies[i].SourceDetails.PerformanceInsightsMetrics[j].MetricQuery.Filter.string'
EXEC sp_OAMethod @jResp, 'StringOf', @GroupByGroup OUT, 'ReactiveAnomalies[i].SourceDetails.PerformanceInsightsMetrics[j].MetricQuery.GroupBy.Group'
EXEC sp_OAMethod @jResp, 'IntOf', @GroupByLimit OUT, 'ReactiveAnomalies[i].SourceDetails.PerformanceInsightsMetrics[j].MetricQuery.GroupBy.Limit'
EXEC sp_OAMethod @jResp, 'StringOf', @MetricQueryMetric OUT, 'ReactiveAnomalies[i].SourceDetails.PerformanceInsightsMetrics[j].MetricQuery.Metric'
EXEC sp_OAMethod @jResp, 'StringOf', @Unit OUT, 'ReactiveAnomalies[i].SourceDetails.PerformanceInsightsMetrics[j].Unit'
SELECT @k = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_k OUT, 'ReactiveAnomalies[i].SourceDetails.PerformanceInsightsMetrics[j].MetricQuery.GroupBy.Dimensions'
WHILE @k < @count_k
BEGIN
EXEC sp_OASetProperty @jResp, 'K', @k
EXEC sp_OAMethod @jResp, 'StringOf', @strVal OUT, 'ReactiveAnomalies[i].SourceDetails.PerformanceInsightsMetrics[j].MetricQuery.GroupBy.Dimensions[k]'
SELECT @k = @k + 1
END
SELECT @k = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_k OUT, 'ReactiveAnomalies[i].SourceDetails.PerformanceInsightsMetrics[j].ReferenceData'
WHILE @k < @count_k
BEGIN
EXEC sp_OASetProperty @jResp, 'K', @k
EXEC sp_OAMethod @jResp, 'StringOf', @FilterString OUT, 'ReactiveAnomalies[i].SourceDetails.PerformanceInsightsMetrics[j].ReferenceData[k].ComparisonValues.ReferenceMetric.MetricQuery.Filter.string'
EXEC sp_OAMethod @jResp, 'StringOf', @GroupByGroup OUT, 'ReactiveAnomalies[i].SourceDetails.PerformanceInsightsMetrics[j].ReferenceData[k].ComparisonValues.ReferenceMetric.MetricQuery.GroupBy.Group'
EXEC sp_OAMethod @jResp, 'IntOf', @GroupByLimit OUT, 'ReactiveAnomalies[i].SourceDetails.PerformanceInsightsMetrics[j].ReferenceData[k].ComparisonValues.ReferenceMetric.MetricQuery.GroupBy.Limit'
EXEC sp_OAMethod @jResp, 'StringOf', @MetricQueryMetric OUT, 'ReactiveAnomalies[i].SourceDetails.PerformanceInsightsMetrics[j].ReferenceData[k].ComparisonValues.ReferenceMetric.MetricQuery.Metric'
EXEC sp_OAMethod @jResp, 'IntOf', @ReferenceScalarValue OUT, 'ReactiveAnomalies[i].SourceDetails.PerformanceInsightsMetrics[j].ReferenceData[k].ComparisonValues.ReferenceScalar.Value'
EXEC sp_OAMethod @jResp, 'StringOf', @Name OUT, 'ReactiveAnomalies[i].SourceDetails.PerformanceInsightsMetrics[j].ReferenceData[k].Name'
EXEC sp_OAMethod @jResp, 'ObjectOf', @json1 OUT, 'ReactiveAnomalies[i].SourceDetails.PerformanceInsightsMetrics[j].ReferenceData[k]'
SELECT @i1 = 0
EXEC sp_OAMethod @json1, 'SizeOfArray', @count_i1 OUT, 'ComparisonValues.ReferenceMetric.MetricQuery.GroupBy.Dimensions'
WHILE @i1 < @count_i1
BEGIN
EXEC sp_OASetProperty @json1, 'I', @i1
EXEC sp_OAMethod @json1, 'StringOf', @strVal OUT, 'ComparisonValues.ReferenceMetric.MetricQuery.GroupBy.Dimensions[i]'
SELECT @i1 = @i1 + 1
END
EXEC @hr = sp_OADestroy @json1
SELECT @k = @k + 1
END
SELECT @k = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_k OUT, 'ReactiveAnomalies[i].SourceDetails.PerformanceInsightsMetrics[j].StatsAtAnomaly'
WHILE @k < @count_k
BEGIN
EXEC sp_OASetProperty @jResp, 'K', @k
EXEC sp_OAMethod @jResp, 'StringOf', @v_Type OUT, 'ReactiveAnomalies[i].SourceDetails.PerformanceInsightsMetrics[j].StatsAtAnomaly[k].Type'
EXEC sp_OAMethod @jResp, 'IntOf', @Value_int OUT, 'ReactiveAnomalies[i].SourceDetails.PerformanceInsightsMetrics[j].StatsAtAnomaly[k].Value'
SELECT @k = @k + 1
END
SELECT @k = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_k OUT, 'ReactiveAnomalies[i].SourceDetails.PerformanceInsightsMetrics[j].StatsAtBaseline'
WHILE @k < @count_k
BEGIN
EXEC sp_OASetProperty @jResp, 'K', @k
EXEC sp_OAMethod @jResp, 'StringOf', @v_Type OUT, 'ReactiveAnomalies[i].SourceDetails.PerformanceInsightsMetrics[j].StatsAtBaseline[k].Type'
EXEC sp_OAMethod @jResp, 'IntOf', @Value_int OUT, 'ReactiveAnomalies[i].SourceDetails.PerformanceInsightsMetrics[j].StatsAtBaseline[k].Value'
SELECT @k = @k + 1
END
SELECT @j = @j + 1
END
SELECT @i = @i + 1
END
-- A sample JSON response body parsed by the above code:
-- {
-- "NextToken": "string",
-- "ProactiveAnomalies": [
-- {
-- "AnomalyReportedTimeRange": {
-- "CloseTime": number,
-- "OpenTime": number
-- },
-- "AnomalyResources": [
-- {
-- "Name": "string",
-- "Type": "string"
-- }
-- ],
-- "AnomalyTimeRange": {
-- "EndTime": number,
-- "StartTime": number
-- },
-- "AssociatedInsightId": "string",
-- "Id": "string",
-- "Limit": number,
-- "PredictionTimeRange": {
-- "EndTime": number,
-- "StartTime": number
-- },
-- "ResourceCollection": {
-- "CloudFormation": {
-- "StackNames": [
-- "string"
-- ]
-- },
-- "Tags": [
-- {
-- "AppBoundaryKey": "string",
-- "TagValues": [
-- "string"
-- ]
-- }
-- ]
-- },
-- "Severity": "string",
-- "SourceDetails": {
-- "CloudWatchMetrics": [
-- {
-- "Dimensions": [
-- {
-- "Name": "string",
-- "Value": "string"
-- }
-- ],
-- "MetricDataSummary": {
-- "StatusCode": "string",
-- "TimestampMetricValuePairList": [
-- {
-- "MetricValue": number,
-- "Timestamp": number
-- }
-- ]
-- },
-- "MetricName": "string",
-- "Namespace": "string",
-- "Period": number,
-- "Stat": "string",
-- "Unit": "string"
-- }
-- ],
-- "PerformanceInsightsMetrics": [
-- {
-- "MetricDisplayName": "string",
-- "MetricQuery": {
-- "Filter": {
-- "string": "string"
-- },
-- "GroupBy": {
-- "Dimensions": [
-- "string"
-- ],
-- "Group": "string",
-- "Limit": number
-- },
-- "Metric": "string"
-- },
-- "ReferenceData": [
-- {
-- "ComparisonValues": {
-- "ReferenceMetric": {
-- "MetricQuery": {
-- "Filter": {
-- "string": "string"
-- },
-- "GroupBy": {
-- "Dimensions": [
-- "string"
-- ],
-- "Group": "string",
-- "Limit": number
-- },
-- "Metric": "string"
-- }
-- },
-- "ReferenceScalar": {
-- "Value": number
-- }
-- },
-- "Name": "string"
-- }
-- ],
-- "StatsAtAnomaly": [
-- {
-- "Type": "string",
-- "Value": number
-- }
-- ],
-- "StatsAtBaseline": [
-- {
-- "Type": "string",
-- "Value": number
-- }
-- ],
-- "Unit": "string"
-- }
-- ]
-- },
-- "SourceMetadata": {
-- "Source": "string",
-- "SourceResourceName": "string",
-- "SourceResourceType": "string"
-- },
-- "Status": "string",
-- "UpdateTime": number
-- }
-- ],
-- "ReactiveAnomalies": [
-- {
-- "AnomalyReportedTimeRange": {
-- "CloseTime": number,
-- "OpenTime": number
-- },
-- "AnomalyResources": [
-- {
-- "Name": "string",
-- "Type": "string"
-- }
-- ],
-- "AnomalyTimeRange": {
-- "EndTime": number,
-- "StartTime": number
-- },
-- "AssociatedInsightId": "string",
-- "CausalAnomalyId": "string",
-- "Description": "string",
-- "Id": "string",
-- "Name": "string",
-- "ResourceCollection": {
-- "CloudFormation": {
-- "StackNames": [
-- "string"
-- ]
-- },
-- "Tags": [
-- {
-- "AppBoundaryKey": "string",
-- "TagValues": [
-- "string"
-- ]
-- }
-- ]
-- },
-- "Severity": "string",
-- "SourceDetails": {
-- "CloudWatchMetrics": [
-- {
-- "Dimensions": [
-- {
-- "Name": "string",
-- "Value": "string"
-- }
-- ],
-- "MetricDataSummary": {
-- "StatusCode": "string",
-- "TimestampMetricValuePairList": [
-- {
-- "MetricValue": number,
-- "Timestamp": number
-- }
-- ]
-- },
-- "MetricName": "string",
-- "Namespace": "string",
-- "Period": number,
-- "Stat": "string",
-- "Unit": "string"
-- }
-- ],
-- "PerformanceInsightsMetrics": [
-- {
-- "MetricDisplayName": "string",
-- "MetricQuery": {
-- "Filter": {
-- "string": "string"
-- },
-- "GroupBy": {
-- "Dimensions": [
-- "string"
-- ],
-- "Group": "string",
-- "Limit": number
-- },
-- "Metric": "string"
-- },
-- "ReferenceData": [
-- {
-- "ComparisonValues": {
-- "ReferenceMetric": {
-- "MetricQuery": {
-- "Filter": {
-- "string": "string"
-- },
-- "GroupBy": {
-- "Dimensions": [
-- "string"
-- ],
-- "Group": "string",
-- "Limit": number
-- },
-- "Metric": "string"
-- }
-- },
-- "ReferenceScalar": {
-- "Value": number
-- }
-- },
-- "Name": "string"
-- }
-- ],
-- "StatsAtAnomaly": [
-- {
-- "Type": "string",
-- "Value": number
-- }
-- ],
-- "StatsAtBaseline": [
-- {
-- "Type": "string",
-- "Value": number
-- }
-- ],
-- "Unit": "string"
-- }
-- ]
-- },
-- "Status": "string",
-- "Type": "string"
-- }
-- ]
-- }
EXEC @hr = sp_OADestroy @rest
EXEC @hr = sp_OADestroy @authAws
EXEC @hr = sp_OADestroy @json
EXEC @hr = sp_OADestroy @sbRequestBody
EXEC @hr = sp_OADestroy @sbResponseBody
EXEC @hr = sp_OADestroy @jResp
END
GO