From 89a1da5c735d5ef2107488fb5291dc3947cd7f79 Mon Sep 17 00:00:00 2001 From: pansharm-ms <106319348+pansharm-ms@users.noreply.github.com> Date: Tue, 6 Dec 2022 01:50:56 +0530 Subject: [PATCH] [Purview - PDS] - 2021-01-01-preview (#20142) * Add PDS swagger specification. * Use default instead of multiple error codes. * Add desctiptions. * Fix error response model. * Update PDS api specifications as per API guidelines * Pretty. * Correct example. * fix dug property. * Remove from custom words. * Fix linting errors. * Fix errors. * Fix conflict. * Fix examples. * Fix linting errors. * Linting errors. * Linting errors. * Fix operatio Id. * Fix x-ms-pageable. * Add filter description. Co-authored-by: Gaurav Gupta --- custom-words.txt | 1 + .../examples/DatasourcePreferences_Get.json | 46 ++ .../examples/PolicyElements_List.json | 50 ++ .../examples/PolicyEvents_List.json | 60 +++ .../preview/2022-11-01-preview/pds.json | 466 ++++++++++++++++++ specification/purview/data-plane/readme.md | 15 + 6 files changed, 638 insertions(+) create mode 100644 specification/purview/data-plane/Azure.Analytics.Purview.PDS/preview/2022-11-01-preview/examples/DatasourcePreferences_Get.json create mode 100644 specification/purview/data-plane/Azure.Analytics.Purview.PDS/preview/2022-11-01-preview/examples/PolicyElements_List.json create mode 100644 specification/purview/data-plane/Azure.Analytics.Purview.PDS/preview/2022-11-01-preview/examples/PolicyEvents_List.json create mode 100644 specification/purview/data-plane/Azure.Analytics.Purview.PDS/preview/2022-11-01-preview/pds.json diff --git a/custom-words.txt b/custom-words.txt index ad21a1208913..bf38fc2fcadc 100644 --- a/custom-words.txt +++ b/custom-words.txt @@ -2777,6 +2777,7 @@ Sami Santali Sirmauri Skolt +Gondor Thangmi Tuvan Uyghur diff --git a/specification/purview/data-plane/Azure.Analytics.Purview.PDS/preview/2022-11-01-preview/examples/DatasourcePreferences_Get.json b/specification/purview/data-plane/Azure.Analytics.Purview.PDS/preview/2022-11-01-preview/examples/DatasourcePreferences_Get.json new file mode 100644 index 000000000000..8c829e0dfc82 --- /dev/null +++ b/specification/purview/data-plane/Azure.Analytics.Purview.PDS/preview/2022-11-01-preview/examples/DatasourcePreferences_Get.json @@ -0,0 +1,46 @@ +{ + "parameters": { + "scope": "/subscriptions/30d9d527-c409-4507-b861-d60e7fe9e292/resourcegroups/pansharm-rg/providers/microsoft.sql/servers/pansharm-sql", + "api-version": "2022-11-01-preview" + }, + "responses": { + "200": { + "headers": { + "x-ms-correlation-request-id": "f35b289b-7deb-467b-9976-a163926f981f" + }, + "body": { + "consent": { + "properties": { + "scanner": { + "metadata": false, + "classification": false + }, + "dataUseGovernance": true + }, + "excludedScopes": [] + }, + "accountInfo": { + "id": "e11948a3-39b2-4daa-931c-2fca8308920e", + "name": "pansharm2", + "location": "westus", + "tenantId": "f686d426-8d16-42db-81b7-ab578e110ccd", + "gatewayEndpoint": "https://pansharm2.purview.azure-test.com" + }, + "frequency": 5 + } + }, + "default": { + "headers": { + "x-ms-correlation-request-id": "f35b289b-7deb-467b-9976-a163926f981f" + }, + "body": { + "error": { + "code": "1001", + "message": "Simple error message.", + "target": "Detailed message or error trace.", + "details": [] + } + } + } + } +} diff --git a/specification/purview/data-plane/Azure.Analytics.Purview.PDS/preview/2022-11-01-preview/examples/PolicyElements_List.json b/specification/purview/data-plane/Azure.Analytics.Purview.PDS/preview/2022-11-01-preview/examples/PolicyElements_List.json new file mode 100644 index 000000000000..ef9281642c84 --- /dev/null +++ b/specification/purview/data-plane/Azure.Analytics.Purview.PDS/preview/2022-11-01-preview/examples/PolicyElements_List.json @@ -0,0 +1,50 @@ +{ + "parameters": { + "scope": "/subscriptions/30d9d527-c409-4507-b861-d60e7fe9e292/resourcegroups/pansharm-rg/providers/microsoft.sql/servers/pansharm-sql", + "$filter": "atScope", + "api-version": "2022-11-01-preview" + }, + "responses": { + "200": { + "headers": { + "x-ms-correlation-request-id": "f35b289b-7deb-467b-9976-a163926f981f" + }, + "body": { + "count": 2, + "syncToken": "25252:0", + "elements": [ + { + "id": "5f448cc9-33cc-47de-910c-c2de1212cb2f", + "kind": "policy", + "updatedAt": "2022-04-12T09:43:35.4515155Z", + "version": 8, + "elementJson": "{\"id\":\"5f448cc9-33cc-47de-910c-c2de1212cb2f\",\"name\":\"test004\",\"kind\":\"policy\",\"version\":8,\"updatedAt\":\"2022-04-12T09:43:35.4515155Z\",\"decisionRules\":[{\"kind\":\"decisionrule\",\"effect\":\"Permit\",\"updatedAt\":\"04/12/2022 09:43:35\",\"cnfCondition\":[[{\"attributeName\":\"resource.azure.path\",\"attributeValueIncludedIn\":[\"/subscriptions/30d9d527-c409-4507-b861-d60e7fe9e292/resourcegroups/pansharm-rg/providers/Microsoft.AzureArcData/SqlServerInstances/pansharm-sql/**\"]}],[{\"attributeName\":\"principal.microsoft.id\",\"attributeValueIncludedIn\":[\"ca4709b3-1fdd-4032-9844-3039025e8ee0\"]}],[{\"fromRule\":\"purviewdatarole_builtin_sqlperfmonitor\",\"attributeName\":\"derived.purview.role\",\"attributeValueIncludes\":\"purviewdatarole_builtin_sqlperfmonitor\"}]]}]}" + }, + { + "id": "e870dcfa-d89d-4fc1-90a9-ef758d299e15", + "scopes": [ + "/subscriptions/30d9d527-c409-4507-b861-d60e7fe9e292/resourcegroups/pansharm-rg" + ], + "kind": "policyset", + "updatedAt": "2022-03-07T05:21:52.2823168Z", + "version": 1, + "elementJson": "{\"id\":\"e870dcfa-d89d-4fc1-90a9-ef758d299e15\",\"name\":\"e870dcfa-d89d-4fc1-90a9-ef758d299e15\",\"kind\":\"policyset\",\"version\":1,\"updatedAt\":\"2022-03-07T05:21:52.2823168Z\",\"preconditionRules\":[{\"dnfCondition\":[[{\"attributeName\":\"resource.azure.path\",\"attributeValueIncludedIn\":[\"/subscriptions/30d9d527-c409-4507-b861-d60e7fe9e292/resourcegroups/pansharm-rg/**\"]}]]}],\"policyRefs\":[\"5f448cc9-33cc-47de-910c-c2de1212cb2f\"]}" + } + ] + } + }, + "default": { + "headers": { + "x-ms-correlation-request-id": "f35b289b-7deb-467b-9976-a163926f981f" + }, + "body": { + "error": { + "code": "1001", + "message": "Simple error message.", + "target": "Detailed message or error trace.", + "details": [] + } + } + } + } +} diff --git a/specification/purview/data-plane/Azure.Analytics.Purview.PDS/preview/2022-11-01-preview/examples/PolicyEvents_List.json b/specification/purview/data-plane/Azure.Analytics.Purview.PDS/preview/2022-11-01-preview/examples/PolicyEvents_List.json new file mode 100644 index 000000000000..c9ae72550998 --- /dev/null +++ b/specification/purview/data-plane/Azure.Analytics.Purview.PDS/preview/2022-11-01-preview/examples/PolicyEvents_List.json @@ -0,0 +1,60 @@ +{ + "parameters": { + "scope": "/subscriptions/30d9d527-c409-4507-b861-d60e7fe9e292/resourcegroups/pansharm-rg/providers/microsoft.sql/servers/pansharm-sql", + "syncToken": "25251:0", + "api-version": "2022-11-01-preview" + }, + "responses": { + "200": { + "headers": { + "x-ms-correlation-request-id": "f35b289b-7deb-467b-9976-a163926f981f" + }, + "body": { + "count": 2, + "syncToken": "25258:0", + "elements": [ + { + "eventType": "Microsoft.Purview/PolicyElements/Write", + "id": "e870dcfa-d89d-4fc1-90a9-ef758d299e15", + "scopes": [ + "/subscriptions/30d9d527-c409-4507-b861-d60e7fe9e292/resourcegroups/pansharm-rg" + ], + "kind": "policyset", + "updatedAt": "2022-03-07T05:21:52.2823168Z", + "version": 1, + "elementJson": "{\"id\":\"e870dcfa-d89d-4fc1-90a9-ef758d299e15\",\"name\":\"e870dcfa-d89d-4fc1-90a9-ef758d299e15\",\"kind\":\"policyset\",\"version\":1,\"updatedAt\":\"2022-03-07T05:21:52.2823168Z\",\"preconditionRules\":[{\"dnfCondition\":[[{\"attributeName\":\"resource.azure.path\",\"attributeValueIncludedIn\":[\"/subscriptions/30d9d527-c409-4507-b861-d60e7fe9e292/resourcegroups/pansharm-rg/**\"]}]]}],\"policyRefs\":[\"5f448cc9-33cc-47de-910c-c2de1212cb2f\"]}" + }, + { + "eventType": "Microsoft.Purview/PolicyElements/Write", + "id": "5f448cc9-33cc-47de-910c-c2de1212cb2f", + "scopes": [ + "/subscriptions/30d9d527-c409-4507-b861-d60e7fe9e292/resourcegroups/pansharm-rg" + ], + "kind": "policy", + "updatedAt": "2022-06-02T17:05:43.0981228Z", + "version": 9, + "elementJson": "{\"id\":\"5f448cc9-33cc-47de-910c-c2de1212cb2f\",\"name\":\"test004\",\"kind\":\"policy\",\"version\":9,\"updatedAt\":\"2022-06-02T17:05:43.0981228Z\",\"decisionRules\":[{\"kind\":\"decisionrule\",\"effect\":\"Permit\",\"id\":\"3ef47a19-55ab-4c3e-bfe4-b274489555da\",\"updatedAt\":\"06/02/2022 17:05:43\",\"cnfCondition\":[[{\"attributeName\":\"resource.azure.path\",\"attributeValueIncludedIn\":[\"/subscriptions/30d9d527-c409-4507-b861-d60e7fe9e292/resourcegroups/pansharm-rg/providers/Microsoft.AzureArcData/SqlServerInstances/pansharm-sql/**\"]}],[{\"attributeName\":\"principal.microsoft.id\",\"attributeValueIncludedIn\":[\"ca4709b3-1fdd-4032-9844-3039025e8ee0\"]}],[{\"fromRule\":\"purviewdatarole_builtin_sqlperfmonitor\",\"attributeName\":\"derived.purview.role\",\"attributeValueIncludes\":\"purviewdatarole_builtin_sqlperfmonitor\"}]]}]}" + } + ] + } + }, + "304": { + "headers": { + "x-ms-correlation-request-id": "f35b289b-7deb-467b-9976-a163926f981f" + } + }, + "default": { + "headers": { + "x-ms-correlation-request-id": "f35b289b-7deb-467b-9976-a163926f981f" + }, + "body": { + "error": { + "code": "1001", + "message": "Simple error message.", + "target": "Detailed message or error trace.", + "details": [] + } + } + } + } +} diff --git a/specification/purview/data-plane/Azure.Analytics.Purview.PDS/preview/2022-11-01-preview/pds.json b/specification/purview/data-plane/Azure.Analytics.Purview.PDS/preview/2022-11-01-preview/pds.json new file mode 100644 index 000000000000..cd2a0a791ed4 --- /dev/null +++ b/specification/purview/data-plane/Azure.Analytics.Purview.PDS/preview/2022-11-01-preview/pds.json @@ -0,0 +1,466 @@ +{ + "swagger": "2.0", + "info": { + "title": "Purview Distribution Service REST API Document", + "description": "Purview distribution service enables various Azure RPs to fetch the policies and attributes for data governance.", + "version": "2022-11-01-preview" + }, + "paths": { + "/datasource-preferences": { + "get": { + "tags": [ + "DatasourcePreferences" + ], + "description": "Get Datasource Preferences for a given scope.", + "operationId": "DatasourcePreferences_Get", + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "query", + "name": "scope", + "description": "Scope.", + "required": true, + "type": "string" + }, + { + "in": "query", + "name": "isProjectGondor", + "description": "Is call from a Gondor client.", + "type": "boolean" + }, + { + "$ref": "#/parameters/api-version" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/DatasourcePreferencesResponse" + } + }, + "default": { + "description": "An unexpected error occurred", + "schema": { + "$ref": "#/definitions/ErrorResponseModel" + } + } + }, + "x-ms-examples": { + "DatasourcePreferences_Get": { + "$ref": "./examples/DatasourcePreferences_Get.json" + } + } + } + }, + "/policy-elements": { + "get": { + "tags": [ + "PolicyElements" + ], + "description": "Get policies for given scope.", + "operationId": "PolicyElements_List", + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "query", + "name": "scope", + "description": "Scope.", + "required": true, + "type": "string" + }, + { + "in": "query", + "name": "api-version", + "description": "The API Version.", + "required": true, + "type": "string" + }, + { + "in": "query", + "name": "filter", + "description": "Optional value to filter policies based on hierarchy of resources. It is of type enum with possible values: AtScope, ChildrenScope, None, All", + "type": "string" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/PolicyResponse" + } + }, + "default": { + "description": "An unexpected error occurred", + "schema": { + "$ref": "#/definitions/ErrorResponseModel" + } + } + }, + "x-ms-pageable": { + "nextLinkName": "nextLink", + "itemName": "elements" + }, + "x-ms-examples": { + "PolicyElements_List": { + "$ref": "./examples/PolicyElements_List.json" + } + } + } + }, + "/policy-events": { + "get": { + "tags": [ + "PolicyEvents" + ], + "description": "Get policy events for given scope.", + "operationId": "PolicyEvents_List", + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "query", + "name": "scope", + "description": "Scope.", + "required": true, + "type": "string" + }, + { + "in": "query", + "name": "syncToken", + "description": "The sync token.", + "required": true, + "type": "string" + }, + { + "$ref": "#/parameters/api-version" + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/PolicyEventsResponse" + } + }, + "304": { + "description": "Not Modified" + }, + "default": { + "description": "An unexpected error occurred", + "schema": { + "$ref": "#/definitions/ErrorResponseModel" + } + } + }, + "x-ms-examples": { + "PolicyEvents_List": { + "$ref": "./examples/PolicyEvents_List.json" + } + } + } + } + }, + "definitions": { + "AccountModelBase": { + "type": "object", + "description": "Represents a purview account.", + "properties": { + "id": { + "type": "string", + "description": "Id of the purview account." + }, + "name": { + "type": "string", + "description": "Name of the purview account." + }, + "location": { + "type": "string", + "description": "Region where purview account is created." + }, + "tenantId": { + "type": "string", + "description": "Tenant id of the purview account." + }, + "gatewayEndpoint": { + "type": "string", + "description": "Purview account gateway endpoint." + } + } + }, + "Consent": { + "type": "object", + "description": "Consent information related to a resource.", + "properties": { + "properties": { + "$ref": "#/definitions/Properties" + }, + "excludedScopes": { + "type": "array", + "description": "Child scopes that need to be excluded (optional).", + "items": { + "type": "string" + } + } + } + }, + "DatasourcePreferencesResponse": { + "type": "object", + "description": "Provides the consent information for a data source.", + "properties": { + "consent": { + "$ref": "#/definitions/Consent" + }, + "accountInfo": { + "$ref": "#/definitions/AccountModelBase" + }, + "frequency": { + "format": "int32", + "type": "integer", + "description": "This represents the frequency at which the RPs will check for consent information." + } + } + }, + "ErrorModel": { + "type": "object", + "description": "Represents the error model.", + "properties": { + "code": { + "type": "string", + "description": "Service error code." + }, + "message": { + "type": "string", + "description": "Error message." + }, + "target": { + "type": "string", + "description": "Detailed error message." + }, + "details": { + "type": "array", + "description": "Granular errors (if any).", + "items": { + "$ref": "#/definitions/ErrorModel" + } + } + }, + "required": [ + "code", + "message" + ] + }, + "ErrorResponseModel": { + "type": "object", + "description": "Represents the error response model.", + "properties": { + "error": { + "$ref": "#/definitions/ErrorModel" + } + }, + "required": [ + "error" + ] + }, + "PolicyElement": { + "type": "object", + "description": "Represents a policy element.", + "properties": { + "id": { + "type": "string", + "description": "Id of the policy element." + }, + "scopes": { + "type": "array", + "description": "List of scopes included in this policy.", + "items": { + "type": "string" + } + }, + "kind": { + "type": "string", + "description": "Kind of policy element. Possible values: policy/policySet/attributeRule." + }, + "updatedAt": { + "type": "string", + "description": "Time at which this policy element is last updated." + }, + "version": { + "format": "int64", + "type": "integer", + "description": "Current version of policy element. This is auto incremented with each change. Starts with 1." + }, + "elementJson": { + "type": "string", + "description": "Policy element serialized json payload." + } + } + }, + "PolicyElementEventModel": { + "type": "object", + "description": "Represents a policy element event model.", + "properties": { + "id": { + "type": "string", + "description": "Id of the policy element." + }, + "scopes": { + "type": "array", + "description": "List of scopes included in this policy.", + "items": { + "type": "string" + } + }, + "kind": { + "type": "string", + "description": "Kind of policy element. Possible values: policy/policySet/attributeRule." + }, + "updatedAt": { + "type": "string", + "description": "Time at which this policy element is last updated." + }, + "version": { + "format": "int64", + "type": "integer", + "description": "Current version of policy element. This is auto incremented with each change. Starts with 1." + }, + "elementJson": { + "type": "string", + "description": "Policy element serialized json payload." + }, + "eventType": { + "type": "string", + "description": "Type of event. Format: //. For Example: Microsoft.Purview/PolicyElements/Delete." + } + } + }, + "PolicyEventsResponse": { + "type": "object", + "description": "Represents the response for policy events API.", + "properties": { + "count": { + "format": "int32", + "type": "integer", + "description": "Count of elements in payload." + }, + "syncToken": { + "type": "string", + "description": "Sync token represents the checkpoint upto which this policy elements list is updated. Client need to store this value and keep updating if PDS returns a new value. Call this API with the most recent value received." + }, + "elements": { + "type": "array", + "description": "List of created/updated policy elements.", + "items": { + "$ref": "#/definitions/PolicyElementEventModel" + } + } + } + }, + "PolicyResponse": { + "type": "object", + "description": "Represents the response for policy fetch API.", + "properties": { + "count": { + "format": "int32", + "type": "integer", + "description": "Count of elements in payload." + }, + "syncToken": { + "type": "string", + "description": "Sync token represents the checkpoint upto which this policy elements list is updated. Client need to pass this value while fetching records using policyEvents API." + }, + "elements": { + "type": "array", + "description": "List of policy elements.", + "items": { + "$ref": "#/definitions/PolicyElement" + } + }, + "nextLink": { + "type": "string", + "description": "Link with skip token to fetch next set of records. This is used in case of pagination." + } + } + }, + "Properties": { + "type": "object", + "description": "Consent properties.", + "properties": { + "scanner": { + "$ref": "#/definitions/Scanner" + }, + "dataUseGovernance": { + "type": "boolean", + "description": "Consent for data use governance." + } + } + }, + "Scanner": { + "type": "object", + "description": "Represents the collection of consent information for scanning service.", + "properties": { + "metadata": { + "type": "boolean", + "description": "Consent for metadata discovery." + }, + "classification": { + "type": "boolean", + "description": "Consent for classification discovery." + } + } + } + }, + "parameters": { + "endpoint": { + "in": "path", + "name": "endpoint", + "description": "The endpoint of your Purview account. Example: https://{accountName}.purview.azure.com.", + "required": true, + "type": "string", + "format": "url", + "x-ms-parameter-location": "client", + "x-ms-skip-url-encoding": true + }, + "api-version": { + "in": "query", + "name": "api-version", + "description": "The api-version of the service.", + "required": true, + "type": "string", + "x-ms-parameter-location": "client" + } + }, + "securityDefinitions": { + "azure_auth": { + "type": "oauth2", + "flow": "implicit", + "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize", + "scopes": { + "user_impersonation": "impersonate your user account" + }, + "description": "Azure Active Directory OAuth2 Flow." + } + }, + "x-ms-parameterized-host": { + "hostTemplate": "{endpoint}", + "useSchemePrefix": false, + "parameters": [ + { + "$ref": "#/parameters/endpoint" + } + ] + }, + "basePath": "/pds", + "security": [ + { + "azure_auth": [ + "user_impersonation" + ] + } + ] +} diff --git a/specification/purview/data-plane/readme.md b/specification/purview/data-plane/readme.md index e637c8f1f3e4..2e562b28d7a1 100644 --- a/specification/purview/data-plane/readme.md +++ b/specification/purview/data-plane/readme.md @@ -142,6 +142,21 @@ input-file: - Azure.Analytics.Purview.Share/preview/2021-09-01-preview/share.json ``` +``` yaml +openapi-type: data-plane +tag: package-2022-11-01-preview +title: PurviewPDSClient +``` + +### Tag: package-2022-11-01-preview + +These settings apply only when `--tag=package-2022-11-01-preview` is specified on the command line. + +``` yaml $(tag) == 'package-2022-11-01-preview' +input-file: +- Azure.Analytics.Purview.PDS/preview/2022-11-01-preview/pds.json +``` + --- # Code Generation