From 691a0882d3105c4a02b9945b50a49af539a04a8c Mon Sep 17 00:00:00 2001 From: Oleh Formaniuk Date: Wed, 24 May 2023 13:06:30 -0700 Subject: [PATCH 1/7] SourceControls 2023-06-01-preview --- .../2023-06-01-preview/SourceControls.json | 243 ++++++++++++++---- .../sourcecontrols/CreateSourceControl.json | 48 ++-- .../sourcecontrols/DeleteSourceControl.json | 8 +- .../sourcecontrols/GetSourceControlById.json | 12 +- .../sourcecontrols/GetSourceControls.json | 9 + 5 files changed, 241 insertions(+), 79 deletions(-) diff --git a/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/SourceControls.json b/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/SourceControls.json index 247cb3fb95e2..3108c59eccef 100644 --- a/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/SourceControls.json +++ b/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/SourceControls.json @@ -163,6 +163,9 @@ "$ref": "#/definitions/SourceControl" } }, + "404": { + "description": "Not Found" + }, "default": { "description": "Error response describing why the operation failed.", "schema": { @@ -171,17 +174,17 @@ } } }, - "delete": { + "put": { "x-ms-examples": { - "Delete a source control.": { - "$ref": "./examples/sourcecontrols/DeleteSourceControl.json" + "Creates a source control.": { + "$ref": "./examples/sourcecontrols/CreateSourceControl.json" } }, "tags": [ "SourceControls" ], - "description": "Delete a source control.", - "operationId": "SourceControls_Delete", + "description": "Creates a source control.", + "operationId": "SourceControls_Create", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" @@ -197,14 +200,23 @@ }, { "$ref": "#/parameters/SourceControlIdParameter" + }, + { + "$ref": "#/parameters/SourceControl" } ], "responses": { "200": { - "description": "OK" + "description": "OK", + "schema": { + "$ref": "#/definitions/SourceControl" + } }, - "204": { - "description": "No Content" + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/SourceControl" + } }, "default": { "description": "Error response describing why the operation failed.", @@ -213,18 +225,20 @@ } } } - }, - "put": { + } + }, + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/sourcecontrols/{sourceControlId}/delete": { + "post": { "x-ms-examples": { - "Creates a source control.": { - "$ref": "./examples/sourcecontrols/CreateSourceControl.json" + "Delete a source control.": { + "$ref": "./examples/sourcecontrols/DeleteSourceControl.json" } }, "tags": [ "SourceControls" ], - "description": "Creates a source control.", - "operationId": "SourceControls_Create", + "description": "Delete a source control.", + "operationId": "SourceControls_Delete", "parameters": [ { "$ref": "../../../../../common-types/resource-management/v3/types.json#/parameters/ApiVersionParameter" @@ -240,23 +254,14 @@ }, { "$ref": "#/parameters/SourceControlIdParameter" - }, - { - "$ref": "#/parameters/SourceControl" } ], "responses": { "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/SourceControl" - } + "description": "OK" }, - "201": { - "description": "Created", - "schema": { - "$ref": "#/definitions/SourceControl" - } + "204": { + "description": "No Content" }, "default": { "description": "Error response describing why the operation failed.", @@ -356,7 +361,8 @@ "properties": { "id": { "description": "The id (a Guid) of the source control", - "type": "string" + "type": "string", + "readOnly": true }, "version": { "$ref": "#/definitions/Version", @@ -387,6 +393,14 @@ "description": "Repository metadata.", "$ref": "#/definitions/Repository" }, + "servicePrincipal": { + "description": "Service principal metadata.", + "$ref": "#/definitions/ServicePrincipal" + }, + "repositoryAccess": { + "description": "Repository access credentials.", + "$ref": "#/definitions/RepositoryAccess" + }, "repositoryResourceInfo": { "description": "Information regarding the resources created in user's repository.", "$ref": "#/definitions/RepositoryResourceInfo" @@ -394,6 +408,10 @@ "lastDeploymentInfo": { "description": "Information regarding the latest deployment for the source control.", "$ref": "#/definitions/DeploymentInfo" + }, + "pullRequest": { + "description": "Information regarding the pull request of the source control.", + "$ref": "#/definitions/PullRequest" } }, "required": [ @@ -404,8 +422,41 @@ ], "type": "object" }, + "RepositoryAccess": { + "type": "object", + "properties": { + "kind": { + "description": "The kind of repository access credentials", + "$ref": "#/definitions/RepositoryAccessKind" + }, + "code": { + "type": "string", + "description": "OAuth Code. Required when `kind` is `OAuth`" + }, + "state": { + "type": "string", + "description": "OAuth State. Required when `kind` is `OAuth`" + }, + "clientId": { + "type": "string", + "description": "OAuth ClientId. Required when `kind` is `OAuth`" + }, + "token": { + "type": "string", + "description": "Personal Access Token. Required when `kind` is `PAT`" + }, + "installationId": { + "type": "string", + "description": "Application installation ID. Required when `kind` is `App`. Supported by `GitHub` only." + } + } + }, "Repository": { "type": "object", + "required":[ + "url", + "branch" + ], "description": "metadata of a repository.", "properties": { "url": { @@ -422,15 +473,29 @@ }, "deploymentLogsUrl": { "description": "Url to access repository action logs.", - "type": "string" - }, - "pathMapping": { - "description": "Dictionary of source control content type and path mapping.", - "items": { - "$ref": "#/definitions/ContentPathMap" - }, - "type": "array", - "x-ms-identifiers": [] + "type": "string", + "readOnly": true + } + } + }, + "ServicePrincipal": { + "type": "object", + "description": "Service principal metadata.", + "properties": { + "id": { + "description": "Id of service principal.", + "type": "string", + "readOnly": true + }, + "tenantId": { + "description": "Tenant id of service principal.", + "type": "string", + "readOnly": true + }, + "appId": { + "description": "App id of service principal.", + "type": "string", + "readOnly": true } } }, @@ -461,15 +526,18 @@ "properties": { "webhookId": { "description": "Unique identifier for the webhook.", - "type": "string" + "type": "string", + "readOnly": true }, "webhookUrl": { "description": "URL that gets invoked by the webhook.", - "type": "string" + "type": "string", + "readOnly": true }, "webhookSecretUpdateTime": { "description": "Time when the webhook secret was updated.", - "type": "string" + "type": "string", + "readOnly": true }, "rotateWebhookSecret": { "description": "A flag to instruct the backend service to rotate webhook secret.", @@ -478,6 +546,7 @@ } }, "GitHubResourceInfo": { + "readOnly": true, "description": "Resources created in GitHub repository.", "type": "object", "properties": { @@ -488,6 +557,7 @@ } }, "AzureDevOpsResourceInfo": { + "readOnly": true, "description": "Resources created in Azure DevOps repository.", "type": "object", "properties": { @@ -502,6 +572,7 @@ } }, "DeploymentInfo": { + "readOnly": true, "description": "Information regarding a deployment.", "type": "object", "properties": { @@ -550,25 +621,14 @@ } } }, - "ContentPathMap": { - "description": "The mapping of content type to a repo path.", - "properties": { - "contentType": { - "$ref": "#/definitions/ContentType", - "description": "Content type.", - "type": "string" - }, - "path": { - "description": "The path to the content.", - "type": "string" - } - }, - "type": "object" - }, "ContentType": { "description": "The content type of a source control path.", "enum": [ "AnalyticRule", + "AutomationRule", + "HuntingQuery", + "Parser", + "Playbook", "Workbook" ], "type": "string", @@ -579,6 +639,18 @@ { "value": "AnalyticRule" }, + { + "value": "AutomationRule" + }, + { + "value": "HuntingQuery" + }, + { + "value": "Parser" + }, + { + "value": "Playbook" + }, { "value": "Workbook" } @@ -600,12 +672,37 @@ "value": "Github" }, { - "value": "DevOps" + "value": "AzureDevOps" + } + ] + } + }, + "RepositoryAccessKind": { + "description": "The kind of repository access credentials", + "enum": [ + "OAuth", + "PAT", + "App" + ], + "type": "string", + "x-ms-enum": { + "modelAsString": true, + "name": "RepositoryAccessKind", + "values": [ + { + "value": "OAuth" + }, + { + "value": "PAT" + }, + { + "value": "App" } ] } }, "Version": { + "readOnly": true, "description": "The version of the source control.", "enum": [ "V1", @@ -700,6 +797,42 @@ } ] } + }, + "PullRequest": { + "readOnly": true, + "description": "Information regarding pull request for protected branches.", + "type": "object", + "properties": { + "url": { + "description": "URL of pull request", + "type": "string" + }, + "state": { + "$ref": "#/definitions/PullRequestState", + "description": "State of the pull request", + "type": "object" + } + } + }, + "PullRequestState": { + "description": "Status of the pull request.", + "enum": [ + "Open", + "Closed" + ], + "type": "string", + "x-ms-enum": { + "modelAsString": true, + "name": "state", + "values": [ + { + "value": "Open" + }, + { + "value": "Closed" + } + ] + } } }, "parameters": { diff --git a/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/examples/sourcecontrols/CreateSourceControl.json b/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/examples/sourcecontrols/CreateSourceControl.json index 5c1d31ec23fe..10020f03c864 100644 --- a/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/examples/sourcecontrols/CreateSourceControl.json +++ b/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/examples/sourcecontrols/CreateSourceControl.json @@ -18,17 +18,13 @@ "repository": { "url": "https://github.com/user/repo", "branch": "master", - "displayUrl": "https://github.com/user/repo", - "pathMapping": [ - { - "contentType": "AnalyticRules", - "path": "path/to/rules" - }, - { - "contentType": "Workbook", - "path": "path/to/workbooks" - } - ] + "displayUrl": "https://github.com/user/repo" + }, + "repositoryAccess": { + "kind": "OAuth", + "code": "939fd7c6caf754f4f41f", + "state": "state", + "clientId": "54b3c2c0-1f48-4a1c-af9f-6399c3240b73" } } } @@ -66,6 +62,11 @@ } ] }, + "servicePrincipal": { + "id": "2d297bee-cb45-444a-a9ce-904484f0bcd6", + "tenantId": "72f988bf-86f1-41af-91ab-2d7cd011db47", + "appId": "42a43de2-b712-4408-9680-2514fed984e6" + }, "repositoryResourceInfo": { "webhook": { "webhookId": "342768323", @@ -87,6 +88,10 @@ "deploymentLogsUrl": "https://github.com/user/repo/actions" }, "message": "Successful deployment" + }, + "pullRequest": { + "url": "https://github.com/user/repo/pull/123", + "state": "open" } }, "systemData": { @@ -119,17 +124,12 @@ "url": "https://github.com/user/repo", "branch": "master", "displayUrl": "https://github.com/user/repo", - "deploymentLogsUrl": "https://github.com/user/repo/actions", - "pathMapping": [ - { - "contentType": "AnalyticRules", - "path": "path/to/rules" - }, - { - "contentType": "Workbook", - "path": "path/to/workbooks" - } - ] + "deploymentLogsUrl": "https://github.com/user/repo/actions" + }, + "servicePrincipal": { + "id": "2d297bee-cb45-444a-a9ce-904484f0bcd6", + "tenantId": "72f988bf-86f1-41af-91ab-2d7cd011db47", + "appId": "42a43de2-b712-4408-9680-2514fed984e6" }, "repositoryResourceInfo": { "webhook": { @@ -152,6 +152,10 @@ "deploymentLogsUrl": "https://github.com/user/repo/actions" }, "message": "Successful deployment" + }, + "pullRequest": { + "url": "https://github.com/user/repo/pull/123", + "state": "open" } }, "systemData": { diff --git a/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/examples/sourcecontrols/DeleteSourceControl.json b/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/examples/sourcecontrols/DeleteSourceControl.json index 8a30c1e991c8..287e3ee7c7fa 100644 --- a/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/examples/sourcecontrols/DeleteSourceControl.json +++ b/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/examples/sourcecontrols/DeleteSourceControl.json @@ -4,7 +4,13 @@ "subscriptionId": "d0cfe6b2-9ac0-4464-9919-dccaee2e48c0", "resourceGroupName": "myRg", "workspaceName": "myWorkspace", - "sourceControlId": "789e0c1f-4a3d-43ad-809c-e713b677b04a" + "sourceControlId": "789e0c1f-4a3d-43ad-809c-e713b677b04a", + "repositoryAccess": { + "kind": "OAuth", + "code": "939fd7c6caf754f4f41f", + "state": "state", + "clientId": "54b3c2c0-1f48-4a1c-af9f-6399c3240b73" + } }, "responses": { "200": {}, diff --git a/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/examples/sourcecontrols/GetSourceControlById.json b/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/examples/sourcecontrols/GetSourceControlById.json index 4a014f407ef8..9e9d0290d93e 100644 --- a/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/examples/sourcecontrols/GetSourceControlById.json +++ b/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/examples/sourcecontrols/GetSourceControlById.json @@ -39,6 +39,11 @@ } ] }, + "servicePrincipal": { + "id": "2d297bee-cb45-444a-a9ce-904484f0bcd6", + "tenantId": "72f988bf-86f1-41af-91ab-2d7cd011db47", + "appId": "42a43de2-b712-4408-9680-2514fed984e6" + }, "repositoryResourceInfo": { "webhook": { "webhookId": "342768323", @@ -60,6 +65,10 @@ "deploymentLogsUrl": "https://github.com/user/repo/actions" }, "message": "Successful deployment" + }, + "pullRequest": { + "url": "https://github.com/user/repo/pull/123", + "state": "open" } }, "systemData": { @@ -71,6 +80,7 @@ "lastModifiedAt": "2021-01-02T17:18:19.1234567Z" } } - } + }, + "404": {} } } diff --git a/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/examples/sourcecontrols/GetSourceControls.json b/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/examples/sourcecontrols/GetSourceControls.json index 87ed7b03634c..827c3d9f2e84 100644 --- a/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/examples/sourcecontrols/GetSourceControls.json +++ b/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/examples/sourcecontrols/GetSourceControls.json @@ -40,6 +40,11 @@ } ] }, + "servicePrincipal": { + "id": "2d297bee-cb45-444a-a9ce-904484f0bcd6", + "tenantId": "72f988bf-86f1-41af-91ab-2d7cd011db47", + "appId": "42a43de2-b712-4408-9680-2514fed984e6" + }, "repositoryResourceInfo": { "webhook": { "webhookId": "342768323", @@ -61,6 +66,10 @@ "deploymentLogsUrl": "https://github.com/user/repo/actions" }, "message": "Successful deployment" + }, + "pullRequest": { + "url": "https://github.com/user/repo/pull/123", + "state": "open" } }, "systemData": { From 4c0f20ebc2cc2fc0f4b5536881c35a3efcf42f8a Mon Sep 17 00:00:00 2001 From: Oleh Formaniuk Date: Wed, 24 May 2023 15:07:01 -0700 Subject: [PATCH 2/7] Fix linter complains --- .../preview/2023-06-01-preview/SourceControls.json | 11 +++-------- .../examples/sourcecontrols/CreateSourceControl.json | 4 ++-- .../examples/sourcecontrols/GetSourceControlById.json | 5 ++--- .../examples/sourcecontrols/GetSourceControls.json | 2 +- 4 files changed, 8 insertions(+), 14 deletions(-) diff --git a/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/SourceControls.json b/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/SourceControls.json index 3108c59eccef..8cd1f56086ec 100644 --- a/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/SourceControls.json +++ b/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/SourceControls.json @@ -164,7 +164,8 @@ } }, "404": { - "description": "Not Found" + "description": "Not Found", + "x-ms-error-response": true }, "default": { "description": "Error response describing why the operation failed.", @@ -262,12 +263,6 @@ }, "204": { "description": "No Content" - }, - "default": { - "description": "Error response describing why the operation failed.", - "schema": { - "$ref": "../../../common/2.0/types.json#/definitions/CloudError" - } } } } @@ -453,7 +448,7 @@ }, "Repository": { "type": "object", - "required":[ + "required": [ "url", "branch" ], diff --git a/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/examples/sourcecontrols/CreateSourceControl.json b/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/examples/sourcecontrols/CreateSourceControl.json index 10020f03c864..10c1751816b6 100644 --- a/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/examples/sourcecontrols/CreateSourceControl.json +++ b/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/examples/sourcecontrols/CreateSourceControl.json @@ -91,7 +91,7 @@ }, "pullRequest": { "url": "https://github.com/user/repo/pull/123", - "state": "open" + "state": "Open" } }, "systemData": { @@ -155,7 +155,7 @@ }, "pullRequest": { "url": "https://github.com/user/repo/pull/123", - "state": "open" + "state": "Open" } }, "systemData": { diff --git a/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/examples/sourcecontrols/GetSourceControlById.json b/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/examples/sourcecontrols/GetSourceControlById.json index 9e9d0290d93e..6854aa4f5be7 100644 --- a/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/examples/sourcecontrols/GetSourceControlById.json +++ b/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/examples/sourcecontrols/GetSourceControlById.json @@ -68,7 +68,7 @@ }, "pullRequest": { "url": "https://github.com/user/repo/pull/123", - "state": "open" + "state": "Open" } }, "systemData": { @@ -80,7 +80,6 @@ "lastModifiedAt": "2021-01-02T17:18:19.1234567Z" } } - }, - "404": {} + } } } diff --git a/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/examples/sourcecontrols/GetSourceControls.json b/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/examples/sourcecontrols/GetSourceControls.json index 827c3d9f2e84..91f16e03b885 100644 --- a/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/examples/sourcecontrols/GetSourceControls.json +++ b/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/examples/sourcecontrols/GetSourceControls.json @@ -69,7 +69,7 @@ }, "pullRequest": { "url": "https://github.com/user/repo/pull/123", - "state": "open" + "state": "Open" } }, "systemData": { From fcbfff1198e801a0e3fa2f60f20e095447004244 Mon Sep 17 00:00:00 2001 From: Oleh Formaniuk Date: Wed, 24 May 2023 16:21:44 -0700 Subject: [PATCH 3/7] Resolve PR comments --- .../2023-06-01-preview/SourceControls.json | 50 ++++++++++++++++--- 1 file changed, 44 insertions(+), 6 deletions(-) diff --git a/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/SourceControls.json b/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/SourceControls.json index 8cd1f56086ec..36759ada3f56 100644 --- a/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/SourceControls.json +++ b/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/SourceControls.json @@ -163,10 +163,6 @@ "$ref": "#/definitions/SourceControl" } }, - "404": { - "description": "Not Found", - "x-ms-error-response": true - }, "default": { "description": "Error response describing why the operation failed.", "schema": { @@ -259,10 +255,19 @@ ], "responses": { "200": { - "description": "OK" + "description": "Operation succeeded with warnings.", + "schema": { + "$ref": "#/definitions/Warning" + } }, "204": { - "description": "No Content" + "description": "Operation succeeded without warnings." + }, + "default": { + "description": "Error response describing why the operation failed.", + "schema": { + "$ref": "../../../common/2.0/types.json#/definitions/CloudError" + } } } } @@ -419,16 +424,19 @@ }, "RepositoryAccess": { "type": "object", + "description": "Credentials to access repository.", "properties": { "kind": { "description": "The kind of repository access credentials", "$ref": "#/definitions/RepositoryAccessKind" }, "code": { + "x-ms-secret": true, "type": "string", "description": "OAuth Code. Required when `kind` is `OAuth`" }, "state": { + "x-ms-secret": true, "type": "string", "description": "OAuth State. Required when `kind` is `OAuth`" }, @@ -437,6 +445,7 @@ "description": "OAuth ClientId. Required when `kind` is `OAuth`" }, "token": { + "x-ms-secret": true, "type": "string", "description": "Personal Access Token. Required when `kind` is `PAT`" }, @@ -530,6 +539,7 @@ "readOnly": true }, "webhookSecretUpdateTime": { + "format": "date-time", "description": "Time when the webhook secret was updated.", "type": "string", "readOnly": true @@ -828,6 +838,34 @@ } ] } + }, + "Warning": { + "description": "Warning response structure.", + "x-ms-external": true, + "properties": { + "warning": { + "$ref": "#/definitions/WarningBody", + "description": "Warning data" + } + }, + "type": "object" + }, + "WarningBody": { + "x-ms-external": true, + "description": "Warning details.", + "properties": { + "code": { + "description": "An identifier for the warning. Codes are invariant and are intended to be consumed programmatically.", + "readOnly": true, + "type": "string" + }, + "message": { + "description": "A message describing the warning, intended to be suitable for display in a user interface.", + "readOnly": true, + "type": "string" + } + }, + "type": "object" } }, "parameters": { From fd48d9b03369d10c31d215980e92fabd0a501e08 Mon Sep 17 00:00:00 2001 From: Oleh Formaniuk Date: Wed, 24 May 2023 16:38:25 -0700 Subject: [PATCH 4/7] Add warning example --- .../examples/sourcecontrols/DeleteSourceControl.json | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/examples/sourcecontrols/DeleteSourceControl.json b/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/examples/sourcecontrols/DeleteSourceControl.json index 287e3ee7c7fa..91e143c075fd 100644 --- a/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/examples/sourcecontrols/DeleteSourceControl.json +++ b/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/examples/sourcecontrols/DeleteSourceControl.json @@ -13,7 +13,14 @@ } }, "responses": { - "200": {}, + "200": { + "body": { + "warning": { + "code": "SourceControls_DeleteServicePrincipal", + "message": "ServicePrincipal has not been removed due to insufficient permissions." + } + } + }, "204": {} } } From 470a9bbab919f7af68ae72c08a9831757ba295e2 Mon Sep 17 00:00:00 2001 From: Oleh Formaniuk Date: Thu, 25 May 2023 12:46:47 -0700 Subject: [PATCH 5/7] Improve `Warning` struct definition --- .../2023-06-01-preview/SourceControls.json | 87 ++++++++++++++++--- .../sourcecontrols/CreateSourceControl.json | 12 +-- .../sourcecontrols/DeleteSourceControl.json | 5 +- .../sourcecontrols/GetSourceControlById.json | 12 +-- .../sourcecontrols/GetSourceControls.json | 12 +-- 5 files changed, 79 insertions(+), 49 deletions(-) diff --git a/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/SourceControls.json b/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/SourceControls.json index 36759ada3f56..5c5cb9ffb4dc 100644 --- a/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/SourceControls.json +++ b/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/SourceControls.json @@ -173,7 +173,7 @@ }, "put": { "x-ms-examples": { - "Creates a source control.": { + "Creates or updates a source control.": { "$ref": "./examples/sourcecontrols/CreateSourceControl.json" } }, @@ -204,7 +204,7 @@ ], "responses": { "200": { - "description": "OK", + "description": "Updated", "schema": { "$ref": "#/definitions/SourceControl" } @@ -255,14 +255,11 @@ ], "responses": { "200": { - "description": "Operation succeeded with warnings.", + "description": "Source control deleted.", "schema": { "$ref": "#/definitions/Warning" } }, - "204": { - "description": "Operation succeeded without warnings." - }, "default": { "description": "Error response describing why the operation failed.", "schema": { @@ -398,7 +395,8 @@ "$ref": "#/definitions/ServicePrincipal" }, "repositoryAccess": { - "description": "Repository access credentials.", + "description": "Repository access credentials. This is write-only object and it never returns back to a user.", + "x-ms-mutability": ["create", "update"], "$ref": "#/definitions/RepositoryAccess" }, "repositoryResourceInfo": { @@ -418,13 +416,17 @@ "displayName", "repoType", "contentTypes", - "repository" + "repository", + "repositoryAccess" ], "type": "object" }, "RepositoryAccess": { "type": "object", "description": "Credentials to access repository.", + "required": [ + "kind" + ], "properties": { "kind": { "description": "The kind of repository access credentials", @@ -483,7 +485,13 @@ } }, "ServicePrincipal": { + "readOnly": true, "type": "object", + "required": [ + "id", + "tenantId", + "appId" + ], "description": "Service principal metadata.", "properties": { "id": { @@ -666,7 +674,7 @@ "description": "The type of repository.", "enum": [ "Github", - "DevOps" + "AzureDevOps" ], "type": "string", "x-ms-enum": { @@ -807,15 +815,21 @@ "readOnly": true, "description": "Information regarding pull request for protected branches.", "type": "object", + "required": [ + "url", + "state" + ], "properties": { "url": { "description": "URL of pull request", - "type": "string" + "type": "string", + "readOnly": true }, "state": { "$ref": "#/definitions/PullRequestState", "description": "State of the pull request", - "type": "object" + "type": "object", + "readOnly": true } } }, @@ -845,27 +859,74 @@ "properties": { "warning": { "$ref": "#/definitions/WarningBody", - "description": "Warning data" + "description": "Warning data." } }, "type": "object" }, "WarningBody": { + "readOnly": true, "x-ms-external": true, "description": "Warning details.", + "required": [ + "code", + "message" + ], "properties": { "code": { "description": "An identifier for the warning. Codes are invariant and are intended to be consumed programmatically.", "readOnly": true, - "type": "string" + "type": "object", + "$ref": "#/definitions/WarningCode" }, "message": { "description": "A message describing the warning, intended to be suitable for display in a user interface.", "readOnly": true, "type": "string" + }, + "details": { + "readOnly": true, + "type": "array", + "items": { + "$ref": "#/definitions/WarningBody" + }, + "x-ms-identifiers": [] } }, "type": "object" + }, + "WarningCode": { + "readOnly": true, + "description": "The type of repository.", + "enum": [ + "SourceControlWarning_DeleteServicePrincipal", + "SourceControlWarning_DeletePipelineFromAzureDevOps", + "SourceControlWarning_DeleteWorkflowAndSecretFromGitHub", + "SourceControlWarning_DeleteRoleAssignment", + "SourceControl_DeletedWithWarnings" + ], + "type": "string", + "x-ms-enum": { + "modelAsString": true, + "name": "WarningCode", + "values": [ + { + "value": "SourceControlWarning_DeleteServicePrincipal" + }, + { + "value": "SourceControlWarning_DeletePipelineFromAzureDevOps" + }, + { + "value": "SourceControlWarning_DeleteWorkflowAndSecretFromGitHub" + }, + { + "value": "SourceControlWarning_DeleteRoleAssignment" + }, + { + "value": "SourceControl_DeletedWithWarnings" + } + ] + } } }, "parameters": { diff --git a/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/examples/sourcecontrols/CreateSourceControl.json b/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/examples/sourcecontrols/CreateSourceControl.json index 10c1751816b6..a9dd66f41914 100644 --- a/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/examples/sourcecontrols/CreateSourceControl.json +++ b/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/examples/sourcecontrols/CreateSourceControl.json @@ -50,17 +50,7 @@ "url": "https://github.com/user/repo", "branch": "master", "displayUrl": "https://github.com/user/repo", - "deploymentLogsUrl": "https://github.com/user/repo/actions", - "pathMapping": [ - { - "contentType": "AnalyticRules", - "path": "path/to/rules" - }, - { - "contentType": "Workbook", - "path": "path/to/workbooks" - } - ] + "deploymentLogsUrl": "https://github.com/user/repo/actions" }, "servicePrincipal": { "id": "2d297bee-cb45-444a-a9ce-904484f0bcd6", diff --git a/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/examples/sourcecontrols/DeleteSourceControl.json b/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/examples/sourcecontrols/DeleteSourceControl.json index 91e143c075fd..21ecd2952d3d 100644 --- a/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/examples/sourcecontrols/DeleteSourceControl.json +++ b/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/examples/sourcecontrols/DeleteSourceControl.json @@ -16,11 +16,10 @@ "200": { "body": { "warning": { - "code": "SourceControls_DeleteServicePrincipal", + "code": "SourceControlWarning_DeleteServicePrincipal", "message": "ServicePrincipal has not been removed due to insufficient permissions." } } - }, - "204": {} + } } } diff --git a/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/examples/sourcecontrols/GetSourceControlById.json b/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/examples/sourcecontrols/GetSourceControlById.json index 6854aa4f5be7..083ed4fa81d4 100644 --- a/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/examples/sourcecontrols/GetSourceControlById.json +++ b/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/examples/sourcecontrols/GetSourceControlById.json @@ -27,17 +27,7 @@ "url": "https://github.com/user/repo", "branch": "master", "displayUrl": "https://github.com/user/repo", - "deploymentLogsUrl": "https://github.com/user/repo/actions", - "pathMapping": [ - { - "contentType": "AnalyticRules", - "path": "path/to/rules" - }, - { - "contentType": "Workbook", - "path": "path/to/workbooks" - } - ] + "deploymentLogsUrl": "https://github.com/user/repo/actions" }, "servicePrincipal": { "id": "2d297bee-cb45-444a-a9ce-904484f0bcd6", diff --git a/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/examples/sourcecontrols/GetSourceControls.json b/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/examples/sourcecontrols/GetSourceControls.json index 91f16e03b885..5d0209868d1c 100644 --- a/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/examples/sourcecontrols/GetSourceControls.json +++ b/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/examples/sourcecontrols/GetSourceControls.json @@ -28,17 +28,7 @@ "url": "https://github.com/user/repo", "branch": "master", "displayUrl": "https://github.com/user/repo", - "deploymentLogsUrl": "https://github.com/user/repo/actions", - "pathMapping": [ - { - "contentType": "AnalyticRules", - "path": "path/to/rules" - }, - { - "contentType": "Workbook", - "path": "path/to/workbooks" - } - ] + "deploymentLogsUrl": "https://github.com/user/repo/actions" }, "servicePrincipal": { "id": "2d297bee-cb45-444a-a9ce-904484f0bcd6", From da789c37164beb489bd7a28ed846f00ba6cfaed6 Mon Sep 17 00:00:00 2001 From: Oleh Formaniuk Date: Fri, 26 May 2023 15:32:58 -0700 Subject: [PATCH 6/7] Fix Model problems --- .../2023-06-01-preview/SourceControls.json | 21 +++++-------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/SourceControls.json b/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/SourceControls.json index 5c5cb9ffb4dc..db1b1b4c6038 100644 --- a/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/SourceControls.json +++ b/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/SourceControls.json @@ -396,7 +396,10 @@ }, "repositoryAccess": { "description": "Repository access credentials. This is write-only object and it never returns back to a user.", - "x-ms-mutability": ["create", "update"], + "x-ms-mutability": [ + "create", + "update" + ], "$ref": "#/definitions/RepositoryAccess" }, "repositoryResourceInfo": { @@ -416,8 +419,7 @@ "displayName", "repoType", "contentTypes", - "repository", - "repositoryAccess" + "repository" ], "type": "object" }, @@ -487,11 +489,6 @@ "ServicePrincipal": { "readOnly": true, "type": "object", - "required": [ - "id", - "tenantId", - "appId" - ], "description": "Service principal metadata.", "properties": { "id": { @@ -815,10 +812,6 @@ "readOnly": true, "description": "Information regarding pull request for protected branches.", "type": "object", - "required": [ - "url", - "state" - ], "properties": { "url": { "description": "URL of pull request", @@ -868,10 +861,6 @@ "readOnly": true, "x-ms-external": true, "description": "Warning details.", - "required": [ - "code", - "message" - ], "properties": { "code": { "description": "An identifier for the warning. Codes are invariant and are intended to be consumed programmatically.", From 0c353f12cdab17571625c4682a65f0a98ee6d81a Mon Sep 17 00:00:00 2001 From: Oleh Formaniuk Date: Mon, 29 May 2023 15:56:46 -0700 Subject: [PATCH 7/7] Add `repositoryAccess` to delete action body --- .../2023-06-01-preview/SourceControls.json | 20 +++++++++++++++++++ .../sourcecontrols/DeleteSourceControl.json | 10 ++++++---- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/SourceControls.json b/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/SourceControls.json index db1b1b4c6038..76301c5a4524 100644 --- a/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/SourceControls.json +++ b/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/SourceControls.json @@ -251,6 +251,9 @@ }, { "$ref": "#/parameters/SourceControlIdParameter" + }, + { + "$ref": "#/parameters/RepositoryAccess" } ], "responses": { @@ -946,6 +949,23 @@ "$ref": "#/definitions/SourceControl" }, "x-ms-parameter-location": "method" + }, + "RepositoryAccess": { + "description": "The repository access credentials.", + "in": "body", + "name": "repositoryAccess", + "required": true, + "schema": { + "required": [ + "repositoryAccess" + ], + "properties": { + "repositoryAccess": { + "$ref": "#/definitions/RepositoryAccess" + } + } + }, + "x-ms-parameter-location": "method" } } } diff --git a/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/examples/sourcecontrols/DeleteSourceControl.json b/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/examples/sourcecontrols/DeleteSourceControl.json index 21ecd2952d3d..2a4ad35f7138 100644 --- a/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/examples/sourcecontrols/DeleteSourceControl.json +++ b/specification/securityinsights/resource-manager/Microsoft.SecurityInsights/preview/2023-06-01-preview/examples/sourcecontrols/DeleteSourceControl.json @@ -6,10 +6,12 @@ "workspaceName": "myWorkspace", "sourceControlId": "789e0c1f-4a3d-43ad-809c-e713b677b04a", "repositoryAccess": { - "kind": "OAuth", - "code": "939fd7c6caf754f4f41f", - "state": "state", - "clientId": "54b3c2c0-1f48-4a1c-af9f-6399c3240b73" + "repositoryAccess": { + "kind": "OAuth", + "code": "939fd7c6caf754f4f41f", + "state": "state", + "clientId": "54b3c2c0-1f48-4a1c-af9f-6399c3240b73" + } } }, "responses": {