Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added List Policies API to SecurityAlerts #5070

Merged
merged 12 commits into from
Mar 13, 2019
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,59 @@
}
}
}
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason for not supporting PATCH ? (for ex to allow email info to be updated )

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The policy is updated through PUT, so PATCH is not necessary.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PATCH is not strictly required for proxy resources.

"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/securityAlertPolicies": {
"get": {
"tags": [
"ManagedDatabaseSecurityAlertPolicies"
],
"description": "Gets a list of managed database's security alert policies.",
"operationId": "ManagedDatabaseSecurityAlertPolicies_ListByDatabase",
"parameters": [
{
"$ref": "#/parameters/ResourceGroupParameter"
},
{
"name": "managedInstanceName",
"in": "path",
"description": "The name of the managed instance.",
"required": true,
"type": "string"
},
{
"name": "databaseName",
"in": "path",
"description": "The name of the managed database for which the security alert policies are defined.",
"required": true,
"type": "string"
},
{
"$ref": "#/parameters/SubscriptionIdParameter"
},
{
"$ref": "#/parameters/ApiVersionParameter"
}
],
"responses": {
"200": {
"description": "Successfully retrieved the managed database security alert policies.",
"schema": {
"$ref": "#/definitions/ManagedDatabaseSecurityAlertPolicyListResult"
}
},
"default": {
"description": "*** Error Responses: ***\n\n * 400 SecurityAlertPoliciesInvalidStorageAccountName - The provided storage account is not valid or does not exist.\n\n * 400 SecurityAlertPoliciesInvalidStorageAccountCredentials - The provided storage account access key is not valid.\n\n * 400 InvalidServerSecurityAlertPolicyCreateRequest - The create server Threat Detection security alert policy request does not exist or has no properties object.\n\n * 400 DataSecurityInvalidUserSuppliedParameter - An invalid parameter value was provided by the client.\n\n * 400 UpsertServerSecurityAlertPolicyFailed - An error has occurred while saving Threat detection settings, please try again later\n\n * 400 UpsertServerSecurityAlertPolicyFailed - An error has occurred while saving Threat detection settings, please try again later\n\n * 404 SubscriptionDoesNotHaveServer - The requested server was not found\n\n * 404 UpsertServerSecurityAlertPolicyFailed - An error has occurred while saving Threat detection settings, please try again later\n\n * 409 ServerSecurityAlertPolicyInProgress - Set server security alert policy is already in progress\n\n * 409 UpsertServerSecurityAlertPolicyFailed - An error has occurred while saving Threat detection settings, please try again later\n\n * 500 DatabaseIsUnavailable - Loading failed. Please try again later.\n\n * 500 UpsertServerSecurityAlertPolicyFailed - An error has occurred while saving Threat detection settings, please try again later\n\n * 500 GetServerSecurityAlertPolicyFailed - Failed to get Threat Detection settings"
}
},
"x-ms-pageable": {
"nextLinkName": "nextLink"
},
"x-ms-examples": {
"Get a list of the database's threat detection policies.": {
"$ref": "./examples/ManagedDatabaseSecurityAlertListByDatabase.json"
}
}
}
}
},
"definitions": {
Expand All @@ -170,7 +223,7 @@
"type": "object",
"properties": {
"state": {
"description": "Specifies the state of the policy, whether it is enabled or disabled.",
"description": "Specifies the state of the policy, whether it is enabled or disabled or a policy has not been applied yet on the specific database.",
"enum": [
"New",
"Enabled",
Expand Down Expand Up @@ -236,6 +289,25 @@
"x-ms-client-flatten": true
}
}
},
"ManagedDatabaseSecurityAlertPolicyListResult": {
"description": "A list of the managed database's security alert policies.",
"type": "object",
"properties": {
"value": {
"description": "Array of results.",
"type": "array",
"items": {
"$ref": "#/definitions/ManagedDatabaseSecurityAlertPolicy"
},
"readOnly": true
},
"nextLink": {
"description": "Link to retrieve next page of results.",
"type": "string",
"readOnly": true
}
}
}
},
"parameters": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,48 @@
}
}
}
},
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/securityAlertPolicies": {
"get": {
"tags": [
"ManagedServerSecurityAlertPolicies"
],
"description": "Get the managed server's threat detection policies.",
"operationId": "ManagedServerSecurityAlertPolicies_ListByInstance",
"parameters": [
{
"$ref": "#/parameters/ResourceGroupParameter"
},
{
"$ref": "#/parameters/ManagedInstanceNameParameter"
},
{
"$ref": "#/parameters/SubscriptionIdParameter"
},
{
"$ref": "#/parameters/ApiVersionParameter"
}
],
"responses": {
"200": {
"description": "Successfully retrieved the managed server threat detection policies.",
"schema": {
"$ref": "#/definitions/ManagedServerSecurityAlertPolicyListResult"
}
},
"default": {
"description": "*** Error Responses: ***\n\n * 400 SecurityAlertPoliciesInvalidStorageAccountName - The provided storage account is not valid or does not exist.\n\n * 400 SecurityAlertPoliciesInvalidStorageAccountCredentials - The provided storage account access key is not valid.\n\n * 400 InvalidServerSecurityAlertPolicyCreateRequest - The create server Threat Detection security alert policy request does not exist or has no properties object.\n\n * 400 DataSecurityInvalidUserSuppliedParameter - An invalid parameter value was provided by the client.\n\n * 400 UpsertServerSecurityAlertPolicyFailed - An error has occurred while saving Threat detection settings, please try again later\n\n * 400 UpsertServerSecurityAlertPolicyFailed - An error has occurred while saving Threat detection settings, please try again later\n\n * 404 SubscriptionDoesNotHaveServer - The requested server was not found\n\n * 404 UpsertServerSecurityAlertPolicyFailed - An error has occurred while saving Threat detection settings, please try again later\n\n * 409 ServerSecurityAlertPolicyInProgress - Set server security alert policy is already in progress\n\n * 409 UpsertServerSecurityAlertPolicyFailed - An error has occurred while saving Threat detection settings, please try again later\n\n * 500 DatabaseIsUnavailable - Loading failed. Please try again later.\n\n * 500 UpsertServerSecurityAlertPolicyFailed - An error has occurred while saving Threat detection settings, please try again later\n\n * 500 GetServerSecurityAlertPolicyFailed - Failed to get Threat Detection settings"
}
},
"x-ms-pageable": {
"nextLinkName": "nextLink"
},
"x-ms-examples": {
"Get the managed server's threat detection policies": {
"$ref": "./examples/ManagedServerSecurityAlertListByInstance.json"
}
}
}
}
},
"definitions": {
Expand All @@ -146,7 +188,7 @@
"type": "object",
"properties": {
"state": {
"description": "Specifies the state of the policy, whether it is enabled or disabled.",
"description": "Specifies the state of the policy, whether it is enabled or disabled or a policy has not been applied yet on the specific database.",
"enum": [
"New",
"Enabled",
Expand Down Expand Up @@ -212,6 +254,25 @@
"x-ms-client-flatten": true
}
}
},
"ManagedServerSecurityAlertPolicyListResult": {
"description": "A list of the managed Server's security alert policies.",
"type": "object",
"properties": {
"value": {
"description": "Array of results.",
"type": "array",
"items": {
"$ref": "#/definitions/ManagedServerSecurityAlertPolicy"
},
"readOnly": true
},
"nextLink": {
"description": "Link to retrieve next page of results.",
"type": "string",
"readOnly": true
}
}
}
},
"parameters": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"parameters": {
"subscriptionId": "00000000-1111-2222-3333-444444444444",
"resourceGroupName": "securityalert-6852",
"managedInstanceName": "securityalert-2080",
"databaseName": "testdb",
"api-version": "2017-03-01=preview"
},
"responses": {
"200": {
"body": {
"value": [
{
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/securityalert-6852/providers/Microsoft.Sql/managedInstances/securityalert-2080/databases/testdb",
"name": "default",
"type": "Microsoft.Sql/managedInstances/databases/securityAlertPolicies",
"location": "Japan East",
"kind": "V12",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  			 [](start = 0, length = 5)

tabs -to--> spaces

"properties": {
"state": "Enabled",
"emailAccountAdmins": "true",
"emailAddresses": ["test@microsoft.com","user@microsoft.com"],
"disabledAlerts": ["Usage_Anomaly"],
"retentionDays": 0,
"storageAccountAccessKey": "",
"storageEndpoint": ""
}
}
]
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"parameters": {
"subscriptionId": "00000000-1111-2222-3333-444444444444",
"resourceGroupName": "securityalert-4799",
"managedInstanceName": "securityalert-6440",
"api-version": "2017-03-01-preview"
},
"responses": {
"200": {
"body": {
"value": [
{
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/securityalert-4799/providers/Microsoft.Sql/managedInstances/securityalert-6440",
"name": "Default",
"type": "Microsoft.Sql/managedInstances/securityAlertPolicies",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"type": [](start = 6, length = 7)

add location, kind

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added only location for server.
"kind" is not relevant.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the churn, but location is spurious in this case. This is a nested proxy resource that does not have "location" in its definition. Location is not required and is not in the response definition in the swagger spec.

"properties": {
"state": "Disabled",
"emailAccountAdmins": true,
"emailAddresses": [ "test@microsoft.com;user@microsoft.com" ],
"disabledAlerts": ["Access_Anomaly"],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

convert tabs to (4) spaces

"retentionDays": 0,
"storageAccountAccessKey": "",
"storageEndpoint": ""
}
}
]
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"parameters": {
"subscriptionId": "00000000-1111-2222-3333-444444444444",
"resourceGroupName": "securityalert-4799",
"serverName": "securityalert-6440",
"api-version": "2017-03-01-preview"
},
"responses": {
"200": {
"body": {
"value": [
{
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/securityalert-4799/providers/Microsoft.Sql/servers/securityalert-6440/securityAlertPolicies",
"name": "Default",
"type": "Microsoft.Sql/servers/securityAlertPolicies",
"properties": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add location, kind

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added only location for server.
"kind" is not relevant.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above. Adding location here makes the example not align to the definition. please remove.

"state": "Disabled",
"emailAccountAdmins": true,
"emailAddresses": [ "test@microsoft.com;user@microsoft.com" ],
"disabledAlerts": ["Access_Anomaly"],
"retentionDays": 0,
"storageAccountAccessKey": "",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

convert tabs to (4) spaces

"storageEndpoint": "https://mystorage.blob.core.windows.net"
}
}
]
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,48 @@
}
}
}
},
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/securityAlertPolicies": {
"get": {
"tags": [
"ServerSecurityAlertPolicies"
],
"description": "Get the server's threat detection policies.",
"operationId": "ServerSecurityAlertPolicies_ListByServer",
"parameters": [
{
"$ref": "#/parameters/ResourceGroupParameter"
},
{
"$ref": "#/parameters/ServerNameParameter"
},
{
"$ref": "#/parameters/SubscriptionIdParameter"
},
{
"$ref": "#/parameters/ApiVersionParameter"
}
],
"responses": {
"200": {
"description": "Successfully retrieved the server threat detection policies.",
"schema": {
"$ref": "#/definitions/LogicalServerSecurityAlertPolicyListResult"
}
},
"default": {
"description": "*** Error Responses: ***\n\n * 400 SecurityAlertPoliciesInvalidStorageAccountName - The provided storage account is not valid or does not exist.\n\n * 400 SecurityAlertPoliciesInvalidStorageAccountCredentials - The provided storage account access key is not valid.\n\n * 400 InvalidServerSecurityAlertPolicyCreateRequest - The create server Threat Detection security alert policy request does not exist or has no properties object.\n\n * 400 DataSecurityInvalidUserSuppliedParameter - An invalid parameter value was provided by the client.\n\n * 400 UpsertServerSecurityAlertPolicyFailed - An error has occurred while saving Threat detection settings, please try again later\n\n * 400 UpsertServerSecurityAlertPolicyFailed - An error has occurred while saving Threat detection settings, please try again later\n\n * 404 SubscriptionDoesNotHaveServer - The requested server was not found\n\n * 404 UpsertServerSecurityAlertPolicyFailed - An error has occurred while saving Threat detection settings, please try again later\n\n * 409 ServerSecurityAlertPolicyInProgress - Set server security alert policy is already in progress\n\n * 409 UpsertServerSecurityAlertPolicyFailed - An error has occurred while saving Threat detection settings, please try again later\n\n * 500 DatabaseIsUnavailable - Loading failed. Please try again later.\n\n * 500 UpsertServerSecurityAlertPolicyFailed - An error has occurred while saving Threat detection settings, please try again later\n\n * 500 GetServerSecurityAlertPolicyFailed - Failed to get Threat Detection settings"
}
},
"x-ms-pageable": {
"nextLinkName": "nextLink"
},
"x-ms-examples": {
"List the server's threat detection policies": {
"$ref": "./examples/ServerSecurityAlertsListByServer.json"
}
}
}
}
},
"definitions": {
Expand All @@ -146,7 +188,7 @@
"type": "object",
"properties": {
"state": {
"description": "Specifies the state of the policy, whether it is enabled or disabled.",
"description": "Specifies the state of the policy, whether it is enabled or disabled or a policy has not been applied yet on the specific database.",
"enum": [
"New",
"Enabled",
Expand Down Expand Up @@ -188,6 +230,12 @@
"format": "int32",
"description": "Specifies the number of days to keep in the Threat Detection audit logs.",
"type": "integer"
},
"creationTime": {
"format": "date-time",
"description": "Specifies the UTC creation time of the policy.",
"type": "string",
"readOnly": true
}
}
},
Expand All @@ -206,6 +254,25 @@
"x-ms-client-flatten": true
}
}
},
"LogicalServerSecurityAlertPolicyListResult": {
"description": "A list of the server's security alert policies.",
"type": "object",
"properties": {
"value": {
"description": "Array of results.",
"type": "array",
"items": {
"$ref": "#/definitions/ServerSecurityAlertPolicy"
},
"readOnly": true
},
"nextLink": {
"description": "Link to retrieve next page of results.",
"type": "string",
"readOnly": true
}
}
}
},
"parameters": {
Expand Down
Loading