From 3637c60dd5e09598ac08256d4e15b5c599de0320 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Mielowski?= Date: Tue, 16 May 2023 04:03:21 +0200 Subject: [PATCH] feat(apim): Add new tracing API (#23800) * Add new tracing api * Remove TODOs descriptions * Improve descriptions * Fix dot * Add missing examples * prettier fixes * Fix model and semantic problems * Remove get prefix in post operations * Use list prefix * Fix PR comments --- .../2023-03-01-preview/apimgateways.json | 148 ++++++++++++++++++ .../2023-03-01-preview/definitions.json | 78 +++++++++ ...mentGatewayInvalidateDebugCredentials.json | 12 ++ ...ManagementGatewayListDebugCredentials.json | 23 +++ .../ApiManagementGatewayListTrace.json | 112 +++++++++++++ 5 files changed, 373 insertions(+) create mode 100644 specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGatewayInvalidateDebugCredentials.json create mode 100644 specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGatewayListDebugCredentials.json create mode 100644 specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGatewayListTrace.json diff --git a/specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/apimgateways.json b/specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/apimgateways.json index b6e3526d57f8..c7a436533c45 100644 --- a/specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/apimgateways.json +++ b/specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/apimgateways.json @@ -1318,6 +1318,154 @@ } } } + }, + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/invalidateDebugCredentials": { + "post": { + "tags": [ + "GatewayInvalidateDebugCredentials" + ], + "operationId": "Gateway_InvalidateDebugCredentials", + "description": "Action is invalidating all debug credentials issued for gateway.", + "x-ms-examples": { + "ApiManagementGatewayInvalidateDebugCredentials": { + "$ref": "./examples/ApiManagementGatewayInvalidateDebugCredentials.json" + } + }, + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/SubscriptionIdParameter" + }, + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ResourceGroupNameParameter" + }, + { + "$ref": "./apimanagement.json#/parameters/ServiceNameParameter" + }, + { + "$ref": "./apimanagement.json#/parameters/GatewayIdParameter" + }, + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + } + ], + "responses": { + "204": { + "description": "All debug credentials for gateway are now invalidated." + }, + "default": { + "description": "Error response describing why the operation failed.", + "schema": { + "$ref": "./apimanagement.json#/definitions/ErrorResponse" + } + } + } + } + }, + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/listDebugCredentials": { + "post": { + "tags": [ + "GatewayListDebugCredentials" + ], + "operationId": "Gateway_ListDebugCredentials", + "description": "Create new debug credentials for gateway.", + "x-ms-examples": { + "ApiManagementGatewayListDebugCredentials": { + "$ref": "./examples/ApiManagementGatewayListDebugCredentials.json" + } + }, + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/SubscriptionIdParameter" + }, + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ResourceGroupNameParameter" + }, + { + "$ref": "./apimanagement.json#/parameters/ServiceNameParameter" + }, + { + "$ref": "./apimanagement.json#/parameters/GatewayIdParameter" + }, + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "name": "parameters", + "in": "body", + "required": true, + "schema": { + "$ref": "./definitions.json#/definitions/GatewayListDebugCredentialsContract" + } + } + ], + "responses": { + "200": { + "description": "The response body contains debug credentials to use in gateway.", + "schema": { + "$ref": "./definitions.json#/definitions/GatewayDebugCredentialsContract" + } + }, + "default": { + "description": "Error response describing why the operation failed.", + "schema": { + "$ref": "./apimanagement.json#/definitions/ErrorResponse" + } + } + } + } + }, + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/listTrace": { + "post": { + "tags": [ + "GatewayListTrace" + ], + "operationId": "Gateway_ListTrace", + "description": "Fetches trace collected by gateway.", + "x-ms-examples": { + "ApiManagementGatewayListTrace": { + "$ref": "./examples/ApiManagementGatewayListTrace.json" + } + }, + "parameters": [ + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/SubscriptionIdParameter" + }, + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ResourceGroupNameParameter" + }, + { + "$ref": "./apimanagement.json#/parameters/ServiceNameParameter" + }, + { + "$ref": "./apimanagement.json#/parameters/GatewayIdParameter" + }, + { + "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" + }, + { + "name": "parameters", + "in": "body", + "required": true, + "schema": { + "$ref": "./definitions.json#/definitions/GatewayListTraceContract" + } + } + ], + "responses": { + "200": { + "description": "The response body contains trace collected by gateway.", + "schema": { + "$ref": "./definitions.json#/definitions/GatewayTraceContract" + } + }, + "default": { + "description": "Error response describing why the operation failed.", + "schema": { + "$ref": "./apimanagement.json#/definitions/ErrorResponse" + } + } + } + } } }, "definitions": {}, diff --git a/specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/definitions.json b/specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/definitions.json index 14a9013c9c40..851cb6b99c2d 100644 --- a/specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/definitions.json +++ b/specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/definitions.json @@ -8761,6 +8761,84 @@ "productId" ], "description": "Tag-product link entity properties." + }, + "GatewayListDebugCredentialsContract": { + "type": "object", + "properties": { + "credentialsExpireAfter": { + "type": "string", + "format": "duration", + "description": "Credentials expiration in ISO8601 format. Maximum duration of the credentials is PT1H. When property is not specified, them value PT1H is used." + }, + "purposes": { + "type": "array", + "description": "Purposes of debug credential.", + "items": { + "type": "string", + "description": "Purpose of debug credential.", + "enum": [ + "tracing" + ], + "x-ms-enum": { + "name": "GatewayListDebugCredentialsContractPurpose", + "modelAsString": true, + "values": [ + { + "value": "tracing", + "description": "The tracing purpose." + } + ] + } + } + }, + "apiId": { + "type": "string", + "format": "arm-id", + "x-ms-arm-id-details": { + "allowedResources": [ + { + "type": "Microsoft.ApiManagement/service/apis" + }, + { + "type": "Microsoft.ApiManagement/service/workspaces/apis" + } + ] + }, + "description": "Full resource Id of an API." + } + }, + "required": [ + "purposes", + "apiId" + ], + "description": "List debug credentials properties." + }, + "GatewayDebugCredentialsContract": { + "type": "object", + "properties": { + "token": { + "type": "string", + "x-ms-secret": true, + "description": "Gateway debug token." + } + }, + "description": "Gateway debug credentials." + }, + "GatewayListTraceContract": { + "type": "object", + "properties": { + "traceId": { + "type": "string", + "description": "Trace id." + } + }, + "description": "List trace properties." + }, + "GatewayTraceContract": { + "type": "object", + "properties": {}, + "additionalProperties": true, + "description": "Trace collected in gateway." } }, "parameters": {} diff --git a/specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGatewayInvalidateDebugCredentials.json b/specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGatewayInvalidateDebugCredentials.json new file mode 100644 index 000000000000..8c1eaf059732 --- /dev/null +++ b/specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGatewayInvalidateDebugCredentials.json @@ -0,0 +1,12 @@ +{ + "parameters": { + "serviceName": "apimService1", + "resourceGroupName": "rg1", + "api-version": "2023-03-01-preview", + "subscriptionId": "subid", + "gatewayId": "gw1" + }, + "responses": { + "204": {} + } +} diff --git a/specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGatewayListDebugCredentials.json b/specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGatewayListDebugCredentials.json new file mode 100644 index 000000000000..c9c7400e8d0d --- /dev/null +++ b/specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGatewayListDebugCredentials.json @@ -0,0 +1,23 @@ +{ + "parameters": { + "serviceName": "apimService1", + "resourceGroupName": "rg1", + "api-version": "2023-03-01-preview", + "subscriptionId": "subid", + "gatewayId": "gw1", + "parameters": { + "credentialsExpireAfter": "PT1H", + "apiId": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/a1", + "purposes": [ + "tracing" + ] + } + }, + "responses": { + "200": { + "body": { + "token": "p=tracing&aid=a1&ex=20230504000000&sn=ZdfxSJoCsOJE0/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/8LchGl7gu/Q==" + } + } + } +} diff --git a/specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGatewayListTrace.json b/specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGatewayListTrace.json new file mode 100644 index 000000000000..001f01dc3b1b --- /dev/null +++ b/specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGatewayListTrace.json @@ -0,0 +1,112 @@ +{ + "parameters": { + "serviceName": "apimService1", + "resourceGroupName": "rg1", + "api-version": "2023-03-01-preview", + "subscriptionId": "subid", + "gatewayId": "gw1", + "parameters": { + "traceId": "CrDvXXXXXXXXXXXXXVU3ZA2-1" + } + }, + "responses": { + "200": { + "body": { + "serviceName": "apimService1", + "traceId": "1e0447d4-XXXX-XXXX-XXXX-dbdb8098a0d3", + "traceEntries": { + "inbound": [ + { + "source": "api-inspector", + "timestamp": "2023-05-03T12:03:04.6899436Z", + "elapsed": "00:00:00.2983315", + "data": { + "request": { + "method": "GET", + "url": "https://proxy.msitesting.net/6452XXXXXXXXXXXX9c2facb1/64524dXXXXXXXXXXXX2facb3?subscription-key=117313e70XXXXXXXXXXXX38ba4658ca3", + "headers": [ + { + "name": "Host", + "value": "proxy.msitesting.net" + } + ] + } + } + }, + { + "source": "api-inspector", + "timestamp": "2023-05-03T12:03:04.6969650Z", + "elapsed": "00:00:00.3046329", + "data": { + "configuration": { + "api": { + "from": "/6452XXXXXXXXXXXX9c2facb1", + "to": { + "scheme": "http", + "host": "msitesting.net", + "port": 80, + "path": "/", + "queryString": "", + "query": {}, + "isDefaultPort": true + }, + "version": null, + "revision": "1" + }, + "operation": { + "method": "GET", + "uriTemplate": "/64524dXXXXXXXXXXXX2facb3" + }, + "user": "-", + "product": "-" + } + } + }, + { + "source": "cors", + "timestamp": "2023-05-03T12:03:04.9901631Z", + "elapsed": "00:00:00.5972352", + "data": "Origin header was missing or empty and the request was classified as not cross-domain. CORS policy was not applied." + }, + { + "source": "set-status", + "timestamp": "2023-05-03T12:03:05.0031202Z", + "elapsed": "00:00:00.6107970", + "data": { + "message": [ + "Response status code was set to 200", + "Response status reason was set to 'OK'" + ] + } + }, + { + "source": "return-response", + "timestamp": "2023-05-03T12:03:05.0086543Z", + "elapsed": "00:00:00.6164228", + "data": { + "message": "Return response was applied", + "response": { + "status": { + "code": "OK", + "reason": "OK" + }, + "headers": [] + } + } + } + ], + "outbound": [ + { + "source": "transfer-response", + "timestamp": "2023-05-03T12:03:05.0438287Z", + "elapsed": "00:00:00.6510195", + "data": { + "message": "Response has been sent to the caller in full" + } + } + ] + } + } + } + } +}