swagger: "2.0"
schemes:
  - https
host: management.azure.com
info:
  description: The Azure SQL Database management API provides a RESTful set of web APIs that interact with Azure SQL Database services to manage your databases. The API enables users to create, retrieve, update, and delete databases, servers, and other entities.
  title: SqlManagementClient
  version: 2017-03-01-preview
  x-apisguru-categories:
    - cloud
  x-logo:
    url: https://api.apis.guru/v2/cache/logo/https_assets.onestore.ms_cdnfiles_onestorerolling-1606-01000_shell_v3_images_logo_microsoft.png
  x-origin:
    - format: swagger
      url: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/sql/resource-manager/Microsoft.Sql/preview/2017-03-01-preview/ManagedServerSecurityAlertPolicy.json
      version: "2.0"
  x-providerName: azure.com
  x-serviceName: sql-ManagedServerSecurityAlertPolicy
  x-tags:
    - Azure
    - Microsoft
consumes:
  - application/json
produces:
  - application/json
securityDefinitions:
  azure_auth:
    authorizationUrl: https://login.microsoftonline.com/common/oauth2/authorize
    description: Azure Active Directory OAuth2 Flow
    flow: implicit
    scopes:
      user_impersonation: impersonate your user account
    type: oauth2
parameters:
  ApiVersionParameter:
    description: The API version to use for the request.
    in: query
    name: api-version
    required: true
    type: string
    x-ms-parameter-location: client
  BlobAuditingPolicyNameParameter:
    description: The name of the blob auditing policy.
    enum:
      - default
    in: path
    name: blobAuditingPolicyName
    required: true
    type: string
    x-ms-parameter-location: method
  DatabaseNameParameter:
    description: The name of the database.
    in: path
    name: databaseName
    required: true
    type: string
    x-ms-parameter-location: method
  ManagedInstanceNameParameter:
    description: The name of the managed instance.
    in: path
    name: managedInstanceName
    required: true
    type: string
    x-ms-parameter-location: method
  ResourceGroupParameter:
    description: The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
    in: path
    name: resourceGroupName
    required: true
    type: string
    x-ms-parameter-location: method
  ServerNameParameter:
    description: The name of the server.
    in: path
    name: serverName
    required: true
    type: string
    x-ms-parameter-location: method
  SqlVirtualMachineContainerNameParameter:
    description: The name of the SqlVirtualMachineContainer.
    in: path
    name: sqlVirtualMachineContainerName
    required: true
    type: string
    x-ms-parameter-location: method
  SqlVirtualMachineInstanceNameParameter:
    description: The name of the SqlVirtualMachineInstance.
    in: path
    name: sqlVirtualMachineInstanceName
    required: true
    type: string
    x-ms-parameter-location: method
  SubscriptionIdParameter:
    description: The subscription ID that identifies an Azure subscription.
    in: path
    name: subscriptionId
    required: true
    type: string
    x-ms-parameter-location: client
  VirtualClusterNameParameter:
    description: The name of the virtual cluster.
    in: path
    name: virtualClusterName
    required: true
    type: string
    x-ms-parameter-location: method
paths:
  "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/securityAlertPolicies":
    get:
      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: ***

             * 400 SecurityAlertPoliciesInvalidStorageAccountName - The provided storage account is not valid or does not exist.

             * 400 SecurityAlertPoliciesInvalidStorageAccountCredentials - The provided storage account access key is not valid.

             * 400 InvalidServerSecurityAlertPolicyCreateRequest - The create server Threat Detection security alert policy request does not exist or has no properties object.

             * 400 DataSecurityInvalidUserSuppliedParameter - An invalid parameter value was provided by the client.

             * 400 UpsertServerSecurityAlertPolicyFailed - An error has occurred while saving Threat detection settings, please try again later

             * 400 UpsertServerSecurityAlertPolicyFailed - An error has occurred while saving Threat detection settings, please try again later

             * 404 SubscriptionDoesNotHaveServer - The requested server was not found

             * 404 UpsertServerSecurityAlertPolicyFailed - An error has occurred while saving Threat detection settings, please try again later

             * 409 ServerSecurityAlertPolicyInProgress - Set server security alert policy is already in progress

             * 409 UpsertServerSecurityAlertPolicyFailed - An error has occurred while saving Threat detection settings, please try again later

             * 500 DatabaseIsUnavailable - Loading failed. Please try again later.

             * 500 UpsertServerSecurityAlertPolicyFailed - An error has occurred while saving Threat detection settings, please try again later

             * 500 GetServerSecurityAlertPolicyFailed - Failed to get Threat Detection settings
      tags:
        - ManagedServerSecurityAlertPolicies
      x-ms-examples:
        Get the managed server's threat detection policies:
          parameters:
            api-version: 2017-03-01-preview
            managedInstanceName: securityalert-6440
            resourceGroupName: securityalert-4799
            subscriptionId: 00000000-1111-2222-3333-444444444444
          responses:
            "200":
              body:
                value:
                  - id: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/securityalert-4799/providers/Microsoft.Sql/managedInstances/securityalert-6440
                    name: Default
                    properties:
                      disabledAlerts:
                        - Access_Anomaly
                      emailAccountAdmins: true
                      emailAddresses:
                        - test@microsoft.com;user@microsoft.com
                      retentionDays: 0
                      state: Disabled
                      storageAccountAccessKey: ""
                      storageEndpoint: ""
                    type: Microsoft.Sql/managedInstances/securityAlertPolicies
      x-ms-pageable:
        nextLinkName: nextLink
  "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/securityAlertPolicies/{securityAlertPolicyName}":
    get:
      description: Get a managed server's threat detection policy.
      operationId: ManagedServerSecurityAlertPolicies_Get
      parameters:
        - $ref: "#/parameters/ResourceGroupParameter"
        - $ref: "#/parameters/ManagedInstanceNameParameter"
        - description: The name of the security alert policy.
          enum:
            - Default
          in: path
          name: securityAlertPolicyName
          required: true
          type: string
          x-ms-enum:
            modelAsString: true
            name: SecurityAlertPolicyName
        - $ref: "#/parameters/SubscriptionIdParameter"
        - $ref: "#/parameters/ApiVersionParameter"
      responses:
        "200":
          description: Successfully retrieved the managed server threat detection policy.
          schema:
            $ref: "#/definitions/ManagedServerSecurityAlertPolicy"
        default:
          description: |-
            *** Error Responses: ***

             * 400 SecurityAlertPoliciesInvalidStorageAccountName - The provided storage account is not valid or does not exist.

             * 400 SecurityAlertPoliciesInvalidStorageAccountCredentials - The provided storage account access key is not valid.

             * 400 InvalidServerSecurityAlertPolicyCreateRequest - The create server Threat Detection security alert policy request does not exist or has no properties object.

             * 400 DataSecurityInvalidUserSuppliedParameter - An invalid parameter value was provided by the client.

             * 400 UpsertServerSecurityAlertPolicyFailed - An error has occurred while saving Threat detection settings, please try again later

             * 400 UpsertServerSecurityAlertPolicyFailed - An error has occurred while saving Threat detection settings, please try again later

             * 404 SubscriptionDoesNotHaveServer - The requested server was not found

             * 404 UpsertServerSecurityAlertPolicyFailed - An error has occurred while saving Threat detection settings, please try again later

             * 409 ServerSecurityAlertPolicyInProgress - Set server security alert policy is already in progress

             * 409 UpsertServerSecurityAlertPolicyFailed - An error has occurred while saving Threat detection settings, please try again later

             * 500 DatabaseIsUnavailable - Loading failed. Please try again later.

             * 500 UpsertServerSecurityAlertPolicyFailed - An error has occurred while saving Threat detection settings, please try again later

             * 500 GetServerSecurityAlertPolicyFailed - Failed to get Threat Detection settings
      tags:
        - ManagedServerSecurityAlertPolicies
      x-ms-examples:
        Get a managed server's threat detection policy:
          parameters:
            api-version: 2017-03-01-preview
            managedInstanceName: securityalert-6440
            resourceGroupName: securityalert-4799
            securityAlertPolicyName: Default
            subscriptionId: 00000000-1111-2222-3333-444444444444
          responses:
            "200":
              body:
                id: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/securityalert-4799/providers/Microsoft.Sql/managedInstances/securityalert-6440
                name: Default
                properties:
                  disabledAlerts:
                    - Access_Anomaly
                  emailAccountAdmins: true
                  emailAddresses:
                    - test@microsoft.com;user@microsoft.com
                  retentionDays: 0
                  state: Disabled
                  storageAccountAccessKey: ""
                  storageEndpoint: ""
                type: Microsoft.Sql/managedInstances/securityAlertPolicies
    put:
      description: Creates or updates a threat detection policy.
      operationId: ManagedServerSecurityAlertPolicies_CreateOrUpdate
      parameters:
        - $ref: "#/parameters/ResourceGroupParameter"
        - $ref: "#/parameters/ManagedInstanceNameParameter"
        - description: The name of the security alert policy.
          enum:
            - Default
          in: path
          name: securityAlertPolicyName
          required: true
          type: string
          x-ms-enum:
            modelAsString: true
            name: SecurityAlertPolicyName
        - description: The managed server security alert policy.
          in: body
          name: parameters
          required: true
          schema:
            $ref: "#/definitions/ManagedServerSecurityAlertPolicy"
        - $ref: "#/parameters/SubscriptionIdParameter"
        - $ref: "#/parameters/ApiVersionParameter"
      responses:
        "200":
          description: Successfully updated the threat detection policy.
          schema:
            $ref: "#/definitions/ManagedServerSecurityAlertPolicy"
        "202":
          description: Created request to set the server threat detection policy.
        default:
          description: |-
            *** Error Responses: ***

             * 400 SecurityAlertPoliciesInvalidStorageAccountName - The provided storage account is not valid or does not exist.

             * 400 SecurityAlertPoliciesInvalidStorageAccountCredentials - The provided storage account access key is not valid.

             * 400 InvalidServerSecurityAlertPolicyCreateRequest - The create server Threat Detection security alert policy request does not exist or has no properties object.

             * 400 DataSecurityInvalidUserSuppliedParameter - An invalid parameter value was provided by the client.

             * 400 UpsertServerSecurityAlertPolicyFailed - An error has occurred while saving Threat detection settings, please try again later

             * 400 UpsertServerSecurityAlertPolicyFailed - An error has occurred while saving Threat detection settings, please try again later

             * 404 SubscriptionDoesNotHaveServer - The requested server was not found

             * 404 UpsertServerSecurityAlertPolicyFailed - An error has occurred while saving Threat detection settings, please try again later

             * 409 ServerSecurityAlertPolicyInProgress - Set server security alert policy is already in progress

             * 409 UpsertServerSecurityAlertPolicyFailed - An error has occurred while saving Threat detection settings, please try again later

             * 500 DatabaseIsUnavailable - Loading failed. Please try again later.

             * 500 UpsertServerSecurityAlertPolicyFailed - An error has occurred while saving Threat detection settings, please try again later

             * 500 UpsertServerSecurityAlertPolicyFailed - An error has occurred while saving Threat detection settings, please try again later
      tags:
        - ManagedServerSecurityAlertPolicies
      x-ms-examples:
        Update a server's threat detection policy with all parameters:
          parameters:
            api-version: 2017-03-01-preview
            managedInstanceName: securityalert-6440
            parameters:
              properties:
                disabledAlerts:
                  - Access_Anomaly
                  - Usage_Anomaly
                emailAccountAdmins: true
                emailAddresses:
                  - testSecurityAlert@microsoft.com
                retentionDays: 5
                state: Enabled
                storageAccountAccessKey: sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==
                storageEndpoint: https://mystorage.blob.core.windows.net
            resourceGroupName: securityalert-4799
            securityAlertPolicyName: Default
            subscriptionId: 00000000-1111-2222-3333-444444444444
          responses:
            "200":
              body:
                id: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/securityalert-4799/providers/Microsoft.Sql/managedInstances/securityalert-6440
                name: Default
                properties:
                  disabledAlerts:
                    - Access_Anomaly
                    - Usage_Anomaly
                  emailAccountAdmins: true
                  emailAddresses:
                    - testSecurityAlert@microsoft.com
                  retentionDays: 5
                  state: Enabled
                  storageAccountAccessKey: ""
                  storageEndpoint: https://mystorage.blob.core.windows.net
                type: Microsoft.Sql/managedInstances/securityAlertPolicies
            "202": {}
        Update a server's threat detection policy with minimal parameters:
          parameters:
            api-version: 2017-03-01-preview
            managedInstanceName: securityalert-6440
            parameters:
              properties:
                state: Enabled
                storageAccountAccessKey: sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==
                storageEndpoint: https://mystorage.blob.core.windows.net
            resourceGroupName: securityalert-4799
            securityAlertPolicyName: Default
            subscriptionId: 00000000-1111-2222-3333-444444444444
          responses:
            "200":
              body:
                id: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/securityalert-4799/providers/Microsoft.Sql/managedInstances/securityalert-6440
                name: Default
                properties:
                  disabledAlerts: []
                  emailAccountAdmins: true
                  emailAddresses: []
                  retentionDays: 0
                  state: Enabled
                  storageAccountAccessKey: ""
                  storageEndpoint: https://mystorage.blob.core.windows.net
                type: Microsoft.Sql/managedInstances/securityAlertPolicies
            "202": {}
      x-ms-long-running-operation: true
definitions:
  ManagedServerSecurityAlertPolicy:
    allOf:
      - allOf:
          - description: ARM resource.
            properties:
              id:
                description: Resource ID.
                readOnly: true
                type: string
              name:
                description: Resource name.
                readOnly: true
                type: string
              type:
                description: Resource type.
                readOnly: true
                type: string
            type: object
            x-ms-azure-resource: true
        description: ARM proxy resource.
        properties: {}
        type: object
    description: A managed server security alert policy.
    properties:
      properties:
        $ref: "#/definitions/SecurityAlertPolicyProperties"
        description: Resource properties.
        x-ms-client-flatten: true
    type: object
  ManagedServerSecurityAlertPolicyListResult:
    description: A list of the managed Server's security alert policies.
    properties:
      nextLink:
        description: Link to retrieve next page of results.
        readOnly: true
        type: string
      value:
        description: Array of results.
        items:
          $ref: "#/definitions/ManagedServerSecurityAlertPolicy"
        readOnly: true
        type: array
    type: object
  SecurityAlertPolicyProperties:
    description: Properties of a security alert policy.
    properties:
      creationTime:
        description: Specifies the UTC creation time of the policy.
        format: date-time
        readOnly: true
        type: string
      disabledAlerts:
        description: "Specifies an array of alerts that are disabled. Allowed values are: Sql_Injection, Sql_Injection_Vulnerability, Access_Anomaly, Data_Exfiltration, Unsafe_Action"
        items:
          type: string
        type: array
      emailAccountAdmins:
        description: Specifies that the alert is sent to the account administrators.
        type: boolean
      emailAddresses:
        description: Specifies an array of e-mail addresses to which the alert is sent.
        items:
          type: string
        type: array
      retentionDays:
        description: Specifies the number of days to keep in the Threat Detection audit logs.
        format: int32
        type: integer
      state:
        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
          - Disabled
        type: string
        x-ms-enum:
          modelAsString: false
          name: SecurityAlertPolicyState
      storageAccountAccessKey:
        description: Specifies the identifier key of the Threat Detection audit storage account.
        type: string
      storageEndpoint:
        description: Specifies the blob storage endpoint (e.g. https://MyAccount.blob.core.windows.net). This blob storage will hold all Threat Detection audit logs.
        type: string
    required:
      - state
    type: object
