From e0fa54fc1c1e9e09af5c4b625e1bf78fd945f211 Mon Sep 17 00:00:00 2001 From: nisha-bhatia <67986960+nisha-bhatia@users.noreply.github.com> Date: Mon, 30 Oct 2023 05:52:36 -0700 Subject: [PATCH] [Monitor.Query] Update Preview Swagger File (#26331) * update swagger * batch update * update old swagger * Update metricBatch.json * Update metricBatch.json * Update metrics_API.json * wip * Update metricBatch.json * wip * update path * Update metricBatch.json * Update metricBatch.json * Update metricBatch.json * Update commonDefinitions.json * Change metricBatch.json endpoint string format from "uri" to "url" Change metricBatch.json endpoint string format from "uri" to "url" * Remove duration format from interval parameter and properties Remove duration format from interval parameter and properties. These were improperly decorated as format: "duration" however now that model validation is actually running against parameters our model validation is failing as "FULL" has been a long time accepted string to this parameter and has a lot of usage. --------- Co-authored-by: gracewilcox Co-authored-by: Todd King <58755170+ToddKingMSFT@users.noreply.github.com> --- specification/monitor/commonDefinitions.json | 178 ++++++++++++++ .../2023-05-01-preview/metricBatch.json | 229 +----------------- .../2018-01-01/metricDefinitions_API.json | 45 +--- .../stable/2018-01-01/metrics_API.json | 177 +------------- 4 files changed, 192 insertions(+), 437 deletions(-) create mode 100644 specification/monitor/commonDefinitions.json diff --git a/specification/monitor/commonDefinitions.json b/specification/monitor/commonDefinitions.json new file mode 100644 index 000000000000..68ba8efc8469 --- /dev/null +++ b/specification/monitor/commonDefinitions.json @@ -0,0 +1,178 @@ +{ + "swagger": "2.0", + "info": { + "version": "2023-11-01", + "title": "Common Monitoring types" + }, + "paths": {}, + "definitions": { + "LocalizableString": { + "type": "object", + "required": [ + "value" + ], + "properties": { + "value": { + "type": "string", + "description": "The invariant value." + }, + "localizedValue": { + "type": "string", + "description": "The display name." + } + }, + "description": "The localizable string class." + }, + "MetricValue": { + "type": "object", + "required": [ + "timeStamp" + ], + "properties": { + "timeStamp": { + "type": "string", + "format": "date-time", + "description": "The timestamp for the metric value in ISO 8601 format." + }, + "average": { + "type": "number", + "format": "double", + "description": "The average value in the time range." + }, + "minimum": { + "type": "number", + "format": "double", + "description": "The least value in the time range." + }, + "maximum": { + "type": "number", + "format": "double", + "description": "The greatest value in the time range." + }, + "total": { + "type": "number", + "format": "double", + "description": "The sum of all of the values in the time range." + }, + "count": { + "type": "number", + "format": "double", + "description": "The number of samples in the time range. Can be used to determine the number of values that contributed to the average value." + } + }, + "description": "Represents a metric value." + }, + "MetadataValue": { + "type": "object", + "properties": { + "name": { + "$ref": "#/definitions/LocalizableString", + "description": "The name of the metadata." + }, + "value": { + "type": "string", + "description": "The value of the metadata." + } + }, + "description": "Represents a metric metadata value." + }, + "Unit": { + "type": "string", + "description": "The unit of the metric.", + "enum": [ + "Count", + "Bytes", + "Seconds", + "CountPerSecond", + "BytesPerSecond", + "Percent", + "MilliSeconds", + "ByteSeconds", + "Unspecified", + "Cores", + "MilliCores", + "NanoCores", + "BitsPerSecond" + ], + "x-ms-enum": { + "name": "MetricUnit", + "modelAsString": true + } + }, + "TimeSeriesElement": { + "type": "object", + "properties": { + "metadatavalues": { + "type": "array", + "items": { + "$ref": "#/definitions/MetadataValue" + }, + "x-ms-identifiers": [ + "name" + ], + "description": "the metadata values returned if $filter was specified in the call." + }, + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/MetricValue" + }, + "x-ms-identifiers": [ + "timeStamp" + ], + "description": "An array of data points representing the metric values. This is only returned if a result type of data is specified." + } + }, + "description": "A time series result type. The discriminator value is always TimeSeries in this case." + }, + "Metric": { + "type": "object", + "properties": { + "id": { + "type": "string", + "description": "the metric Id." + }, + "type": { + "type": "string", + "description": "the resource type of the metric resource." + }, + "name": { + "$ref": "#/definitions/LocalizableString", + "description": "the name and the display name of the metric, i.e. it is localizable string." + }, + "displayDescription": { + "type": "string", + "description": "Detailed description of this metric." + }, + "errorCode": { + "type": "string", + "description": "'Success' or the error details on query failures for this metric." + }, + "errorMessage": { + "type": "string", + "description": "Error message encountered querying this specific metric." + }, + "unit": { + "$ref": "#/definitions/Unit", + "description": "The unit of the metric." + }, + "timeseries": { + "type": "array", + "items": { + "$ref": "#/definitions/TimeSeriesElement" + }, + "x-ms-identifiers": [], + "description": "the time series returned when a data query is performed." + } + }, + "required": [ + "id", + "type", + "name", + "unit", + "timeseries" + ], + "description": "The result data of a query." + } + } +} diff --git a/specification/monitor/data-plane/Microsoft.Insights/preview/2023-05-01-preview/metricBatch.json b/specification/monitor/data-plane/Microsoft.Insights/preview/2023-05-01-preview/metricBatch.json index 0702469e56b5..091598dabad4 100644 --- a/specification/monitor/data-plane/Microsoft.Insights/preview/2023-05-01-preview/metricBatch.json +++ b/specification/monitor/data-plane/Microsoft.Insights/preview/2023-05-01-preview/metricBatch.json @@ -23,17 +23,19 @@ } ], "x-ms-parameterized-host": { - "hostTemplate": "{baseUrl}", + "hostTemplate": "{endpoint}", "useSchemePrefix": false, "positionInOperation": "first", "parameters": [ { - "name": "baseUrl", + "name": "endpoint", "description": "The regional endpoint to use, for example https://eastus.metrics.monitor.azure.com. The region should match the region of the requested resources. For global resources, the region should be 'global'.", "required": true, "type": "string", "in": "path", - "x-ms-skip-url-encoding": true + "format": "url", + "x-ms-skip-url-encoding": true, + "x-ms-parameter-location": "client" } ] }, @@ -49,7 +51,7 @@ "tags": [ "Metrics" ], - "operationId": "Metrics_Batch", + "operationId": "MetricsBatch_Batch", "description": "Lists the metric values for multiple resources.", "parameters": [ { @@ -156,7 +158,6 @@ "in": "query", "required": false, "type": "string", - "format": "duration", "default": "PT1M", "description": "The interval (i.e. timegrain) of the query.\n*Examples: PT15M, PT1H, P1D*", "x-ms-parameter-location": "method" @@ -326,7 +327,7 @@ "value": { "type": "array", "items": { - "$ref": "#/definitions/Metric" + "$ref": "../../../../commonDefinitions.json#/definitions/Metric" }, "description": "The value of the collection." } @@ -339,222 +340,6 @@ } } } - }, - "LocalizableString": { - "type": "object", - "required": [ - "value" - ], - "properties": { - "value": { - "type": "string", - "description": "The invariant value." - }, - "localizedValue": { - "type": "string", - "description": "The display name." - } - }, - "description": "The localizable string class." - }, - "MetricUnit": { - "type": "string", - "description": "The unit of the metric.", - "enum": [ - "Count", - "Bytes", - "Seconds", - "CountPerSecond", - "BytesPerSecond", - "Percent", - "MilliSeconds", - "ByteSeconds", - "Unspecified", - "Cores", - "MilliCores", - "NanoCores", - "BitsPerSecond" - ], - "x-ms-enum": { - "name": "MetricUnit", - "modelAsString": false, - "values": [ - { - "value": "Count", - "description": "Unit of raw quantity." - }, - { - "value": "Bytes", - "description": "Unit of memory in bytes." - }, - { - "value": "Seconds", - "description": "Unit of time in seconds." - }, - { - "value": "CountPerSecond", - "description": "Rate unit of raw quantity per second." - }, - { - "value": "BytesPerSecond", - "description": "Rate unit of memory in bytes per second." - }, - { - "value": "Percent", - "description": "Percentage unit." - }, - { - "value": "MilliSeconds", - "description": "Unit of time in 1/1000th of a second." - }, - { - "value": "ByteSeconds", - "description": "Unit of data transfer or storage. It is the size of the data in bytes multiplied by the time it takes to transfer or store the data in seconds." - }, - { - "value": "Unspecified", - "description": "No specified unit." - }, - { - "value": "Cores", - "description": "Unit of processing power." - }, - { - "value": "MilliCores", - "description": "Unit of processing power in 1/1000th of a CPU core." - }, - { - "value": "NanoCores", - "description": "Unit of processing power in one billionth of a CPU core." - }, - { - "value": "BitsPerSecond", - "description": "Rate unit of binary digits per second." - } - ] - } - }, - "MetricValue": { - "type": "object", - "required": [ - "timeStamp" - ], - "properties": { - "timeStamp": { - "type": "string", - "format": "date-time", - "description": "The timestamp for the metric value in ISO 8601 format." - }, - "average": { - "type": "number", - "format": "double", - "description": "The average value in the time range." - }, - "minimum": { - "type": "number", - "format": "double", - "description": "The least value in the time range." - }, - "maximum": { - "type": "number", - "format": "double", - "description": "The greatest value in the time range." - }, - "total": { - "type": "number", - "format": "double", - "description": "The sum of all of the values in the time range." - }, - "count": { - "type": "number", - "format": "double", - "description": "The number of samples in the time range. Can be used to determine the number of values that contributed to the average value." - } - }, - "description": "Represents a metric value." - }, - "MetadataValue": { - "type": "object", - "properties": { - "name": { - "$ref": "#/definitions/LocalizableString", - "description": "The name of the metadata." - }, - "value": { - "type": "string", - "description": "The value of the metadata." - } - }, - "description": "Represents a metric metadata value." - }, - "Metric": { - "type": "object", - "properties": { - "id": { - "type": "string", - "description": "The metric Id." - }, - "name": { - "$ref": "#/definitions/LocalizableString", - "description": "The name and the display name of the metric, i.e. it is localizable string." - }, - "displayDescription": { - "type": "string", - "description": "Description of this metric" - }, - "type": { - "type": "string", - "description": "The resource type of the metric resource." - }, - "unit": { - "$ref": "#/definitions/MetricUnit", - "description": "The unit of the metric." - }, - "timeseries": { - "type": "array", - "items": { - "$ref": "#/definitions/TimeSeriesElement" - }, - "description": "The time series returned when a data query is performed." - }, - "errorCode": { - "type": "string", - "description": "'Success' or the error details on query failures for this metric." - }, - "errorMessage": { - "type": "string", - "description": "Error message encountered querying this specific metric." - } - }, - "required": [ - "id", - "name", - "displayDescription", - "type", - "unit", - "timeseries" - ], - "description": "The result data of a query." - }, - "TimeSeriesElement": { - "type": "object", - "properties": { - "metadatavalues": { - "type": "array", - "items": { - "$ref": "#/definitions/MetadataValue" - }, - "description": "The metadata values returned if filter was specified in the call." - }, - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/MetricValue" - }, - "description": "An array of data points representing the metric values. This is only returned if a result type of data is specified." - } - }, - "description": "A time series result type. The discriminator value is always TimeSeries in this case." } } } diff --git a/specification/monitor/resource-manager/Microsoft.Insights/stable/2018-01-01/metricDefinitions_API.json b/specification/monitor/resource-manager/Microsoft.Insights/stable/2018-01-01/metricDefinitions_API.json index 5be6305c7682..c6978792544a 100644 --- a/specification/monitor/resource-manager/Microsoft.Insights/stable/2018-01-01/metricDefinitions_API.json +++ b/specification/monitor/resource-manager/Microsoft.Insights/stable/2018-01-01/metricDefinitions_API.json @@ -83,22 +83,6 @@ } }, "definitions": { - "LocalizableString": { - "required": [ - "value" - ], - "properties": { - "value": { - "type": "string", - "description": "the invariant value." - }, - "localizedValue": { - "type": "string", - "description": "the locale specific value." - } - }, - "description": "The localizable string class." - }, "MetricAvailability": { "type": "object", "properties": { @@ -115,29 +99,6 @@ }, "description": "Metric availability specifies the time grain (aggregation interval or frequency) and the retention period for that time grain." }, - "Unit": { - "type": "string", - "description": "The unit of the metric.", - "enum": [ - "Count", - "Bytes", - "Seconds", - "CountPerSecond", - "BytesPerSecond", - "Percent", - "MilliSeconds", - "ByteSeconds", - "Unspecified", - "Cores", - "MilliCores", - "NanoCores", - "BitsPerSecond" - ], - "x-ms-enum": { - "name": "MetricUnit", - "modelAsString": true - } - }, "AggregationType": { "type": "string", "description": "the aggregation type of the metric.", @@ -185,7 +146,7 @@ "description": "the namespace the metric belongs to." }, "name": { - "$ref": "#/definitions/LocalizableString", + "$ref": "../../../../commonDefinitions.json#/definitions/LocalizableString", "description": "the name and the display name of the metric, i.e. it is a localizable string." }, "displayDescription": { @@ -201,7 +162,7 @@ "description": "The class of the metric." }, "unit": { - "$ref": "#/definitions/Unit", + "$ref": "../../../../commonDefinitions.json#/definitions/Unit", "description": "The unit of the metric." }, "primaryAggregationType": { @@ -230,7 +191,7 @@ "dimensions": { "type": "array", "items": { - "$ref": "#/definitions/LocalizableString" + "$ref": "../../../../commonDefinitions.json#/definitions/LocalizableString" }, "x-ms-identifiers": [ "value" diff --git a/specification/monitor/resource-manager/Microsoft.Insights/stable/2018-01-01/metrics_API.json b/specification/monitor/resource-manager/Microsoft.Insights/stable/2018-01-01/metrics_API.json index 9182b3041d0f..65045c35c588 100644 --- a/specification/monitor/resource-manager/Microsoft.Insights/stable/2018-01-01/metrics_API.json +++ b/specification/monitor/resource-manager/Microsoft.Insights/stable/2018-01-01/metrics_API.json @@ -93,7 +93,7 @@ } } }, - "x-ms-odata": "#/definitions/MetadataValue", + "x-ms-odata": "../../../../commonDefinitions.json#/definitions/MetadataValue", "x-ms-examples": { "Get Metric for data": { "$ref": "./examples/GetMetric.json" @@ -109,98 +109,6 @@ } }, "definitions": { - "LocalizableString": { - "required": [ - "value" - ], - "properties": { - "value": { - "type": "string", - "description": "the invariant value." - }, - "localizedValue": { - "type": "string", - "description": "the locale specific value." - } - }, - "description": "The localizable string class." - }, - "Unit": { - "type": "string", - "description": "The unit of the metric.", - "enum": [ - "Count", - "Bytes", - "Seconds", - "CountPerSecond", - "BytesPerSecond", - "Percent", - "MilliSeconds", - "ByteSeconds", - "Unspecified", - "Cores", - "MilliCores", - "NanoCores", - "BitsPerSecond" - ], - "x-ms-enum": { - "name": "MetricUnit", - "modelAsString": true - } - }, - "MetricValue": { - "type": "object", - "required": [ - "timeStamp" - ], - "properties": { - "timeStamp": { - "type": "string", - "format": "date-time", - "description": "the timestamp for the metric value in ISO 8601 format." - }, - "average": { - "type": "number", - "format": "double", - "description": "the average value in the time range." - }, - "minimum": { - "type": "number", - "format": "double", - "description": "the least value in the time range." - }, - "maximum": { - "type": "number", - "format": "double", - "description": "the greatest value in the time range." - }, - "total": { - "type": "number", - "format": "double", - "description": "the sum of all of the values in the time range." - }, - "count": { - "type": "number", - "format": "double", - "description": "the number of samples in the time range. Can be used to determine the number of values that contributed to the average value." - } - }, - "description": "Represents a metric value." - }, - "MetadataValue": { - "type": "object", - "properties": { - "name": { - "$ref": "#/definitions/LocalizableString", - "description": "the name of the metadata." - }, - "value": { - "type": "string", - "description": "the value of the metadata." - } - }, - "description": "Represents a metric metadata value." - }, "Response": { "type": "object", "properties": { @@ -216,8 +124,7 @@ }, "interval": { "type": "string", - "format": "duration", - "description": "The interval (window size) for which the metric data was returned in. This may be adjusted in the future and returned back from what was originally requested. This is not present if a metadata request was made." + "description": "The interval (window size) for which the metric data was returned in ISO 8601 duration format with a special case for 'FULL' value that returns single datapoint for entire time span requested (*Examples: PT15M, PT1H, P1D, FULL*). \nThis may be adjusted and different from what was originally requested if AutoAdjustTimegrain=true is specified. This is not present if a metadata request was made." }, "namespace": { "type": "string", @@ -230,7 +137,7 @@ "value": { "type": "array", "items": { - "$ref": "#/definitions/Metric" + "$ref": "../../../../commonDefinitions.json#/definitions/Metric" }, "description": "the value of the collection." } @@ -241,81 +148,6 @@ ], "description": "The response to a metrics query." }, - "Metric": { - "type": "object", - "properties": { - "id": { - "type": "string", - "description": "the metric Id." - }, - "type": { - "type": "string", - "description": "the resource type of the metric resource." - }, - "name": { - "$ref": "#/definitions/LocalizableString", - "description": "the name and the display name of the metric, i.e. it is localizable string." - }, - "displayDescription": { - "type": "string", - "description": "Detailed description of this metric." - }, - "errorCode": { - "type": "string", - "description": "'Success' or the error details on query failures for this metric." - }, - "errorMessage": { - "type": "string", - "description": "Error message encountered querying this specific metric." - }, - "unit": { - "$ref": "#/definitions/Unit", - "description": "The unit of the metric." - }, - "timeseries": { - "type": "array", - "items": { - "$ref": "#/definitions/TimeSeriesElement" - }, - "x-ms-identifiers": [], - "description": "the time series returned when a data query is performed." - } - }, - "required": [ - "id", - "type", - "name", - "unit", - "timeseries" - ], - "description": "The result data of a query." - }, - "TimeSeriesElement": { - "type": "object", - "properties": { - "metadatavalues": { - "type": "array", - "items": { - "$ref": "#/definitions/MetadataValue" - }, - "x-ms-identifiers": [ - "name" - ], - "description": "the metadata values returned if $filter was specified in the call." - }, - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/MetricValue" - }, - "x-ms-identifiers": [ - "timeStamp" - ], - "description": "An array of data points representing the metric values. This is only returned if a result type of data is specified." - } - }, - "description": "A time series result type. The discriminator value is always TimeSeries in this case." - }, "ErrorResponse": { "description": "Describes the format of Error response.", "type": "object", @@ -354,8 +186,7 @@ "in": "query", "required": false, "type": "string", - "format": "duration", - "description": "The interval (i.e. timegrain) of the query.", + "description": "The interval (i.e. timegrain) of the query in ISO 8601 duration format. Defaults to PT1M. Special case for 'FULL' value that returns single datapoint for entire time span requested.\n*Examples: PT15M, PT1H, P1D, FULL*", "x-ms-parameter-location": "method" }, "MetricNamesParameter": {