swagger: "2.0"
schemes:
  - https
host: management.azure.com
info:
  description: APIs for Azure Smart Detector Alert Rules CRUD operations.
  title: Azure Alerts Management Service Resource Provider
  version: 2019-03-01
  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/alertsmanagement/resource-manager/Microsoft.AlertsManagement/stable/2019-03-01/SmartDetectorAlertRulesApi.json
      version: "2.0"
  x-preferred: false
  x-providerName: azure.com
  x-serviceName: alertsmanagement-SmartDetectorAlertRulesApi
  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
security:
  - azure_auth:
      - user_impersonation
parameters:
  AlertRuleNameParameter:
    description: The name of the alert rule.
    in: path
    name: alertRuleName
    required: true
    type: string
    x-ms-parameter-location: method
  ApiVersionParameter:
    description: Client Api Version.
    in: query
    name: api-version
    required: true
    type: string
  ExpandDetectorParameter:
    description: Indicates if Smart Detector should be expanded.
    in: query
    name: expandDetector
    type: boolean
    x-ms-parameter-location: method
  ResourceGroupNameParameter:
    description: The name of the resource group.
    in: path
    name: resourceGroupName
    required: true
    type: string
    x-ms-parameter-location: method
  SubscriptionIdParameter:
    description: The Azure subscription id.
    in: path
    name: subscriptionId
    required: true
    type: string
paths:
  "/subscriptions/{subscriptionId}/providers/microsoft.alertsManagement/smartDetectorAlertRules":
    get:
      description: List all the existing Smart Detector alert rules within the subscription.
      operationId: SmartDetectorAlertRules_List
      parameters:
        - $ref: "#/parameters/SubscriptionIdParameter"
        - $ref: "#/parameters/ApiVersionParameter"
      responses:
        "200":
          description: Successful request to list Smart Detector alert rules.
          schema:
            $ref: "#/definitions/AlertRulesList"
        default:
          description: Error response describing why the operation failed.
          schema:
            $ref: "#/definitions/ErrorResponse"
      tags:
        - SmartDetectorAlertRules
      x-ms-examples:
        List Smart Detector alert rules:
          parameters:
            api-version: 2019-03-01
            resourceGroupName: MyAlertRules
            subscriptionId: b368ca2f-e298-46b7-b0ab-012281956afa
          responses:
            "200":
              body:
                nextLink: null
                value:
                  - id: /subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourceGroups/MyAlertRules/providers/microsoft.alertsManagement/smartDetectorAlertRules/MyAlertRule
                    name: MyAlertRule
                    properties:
                      actionGroups:
                        - actionGroupId: /subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourcegroups/MyActionGroups/providers/microsoft.insights/actionGroups/MyActionGroup
                      description: Sample smart detector alert rule description
                      detector:
                        id: VMMemoryLeak
                      frequency: PT5M
                      scope:
                        - /subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourceGroups/vms/providers/Microsoft.Compute/virtualMachines/vm1
                      severity: Sev3
                      state: Enabled
                      throttling:
                        duration: PT20M
                    type: Microsoft.AlertsManagement/smartDetectorAlertRules
                  - id: /subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourceGroups/MyAlertRules/providers/microsoft.alertsManagement/smartDetectorAlertRules/MySecondAlertRule
                    name: MySecondAlertRule
                    properties:
                      actionGroups:
                        - actionGroupId: /subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourcegroups/MyActionGroups/providers/microsoft.insights/actionGroups/MyActionGroup
                      description: Sample smart detector alert rule description
                      detector:
                        id: VMMemoryLeak
                      frequency: PT15M
                      scope:
                        - /subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourceGroups/vms/providers/Microsoft.Compute/virtualMachines/vm2
                      severity: Sev2
                      state: Disabled
                    type: Microsoft.AlertsManagement/smartDetectorAlertRules
      x-ms-pageable:
        nextLinkName: nextLink
  "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.alertsManagement/smartDetectorAlertRules":
    get:
      description: List all the existing Smart Detector alert rules within the subscription and resource group.
      operationId: SmartDetectorAlertRules_ListByResourceGroup
      parameters:
        - $ref: "#/parameters/SubscriptionIdParameter"
        - $ref: "#/parameters/ResourceGroupNameParameter"
        - $ref: "#/parameters/ApiVersionParameter"
      responses:
        "200":
          description: Successful request to list Smart Detector alert rules.
          schema:
            $ref: "#/definitions/AlertRulesList"
        default:
          description: Error response describing why the operation failed.
          schema:
            $ref: "#/definitions/ErrorResponse"
      tags:
        - SmartDetectorAlertRules
      x-ms-examples:
        List alert rules:
          parameters:
            api-version: 2019-03-01
            resourceGroupName: MyAlertRules
            subscriptionId: b368ca2f-e298-46b7-b0ab-012281956afa
          responses:
            "200":
              body:
                nextLink: null
                value:
                  - id: /subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourceGroups/MyAlertRules/providers/microsoft.alertsManagement/smartDetectorAlertRules/MyAlertRule
                    name: MyAlertRule
                    properties:
                      actionGroups:
                        - actionGroupId: /subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourcegroups/MyActionGroups/providers/microsoft.insights/actionGroups/MyActionGroup
                      description: Sample smart detector alert rule description
                      detector:
                        id: VMMemoryLeak
                      frequency: PT5M
                      scope:
                        - /subscriptions/b324c52b-4073-4807-93af-e07d289c093e/resourceGroups/test/providers/Microsoft.Storage/storageAccounts/larryshoebox/blobServices/default
                      severity: Sev3
                      state: Enabled
                      throttling:
                        duration: PT20M
                    type: Microsoft.AlertsManagement/smartDetectorAlertRules
                  - id: /subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourceGroups/MyAlertRules/providers/microsoft.alertsManagement/smartDetectorAlertRules/MySecondAlertRule
                    name: MySecondAlertRule
                    properties:
                      actionGroups:
                        - actionGroupId: /subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourcegroups/MyActionGroups/providers/microsoft.insights/actionGroups/MyActionGroup
                      description: Sample smart detector alert rule description
                      detector:
                        id: VMMemoryLeak
                      frequency: PT15M
                      scope:
                        - /subscriptions/b324c52b-4073-4807-93af-e07d289c093e/resourceGroups/test/providers/Microsoft.Storage/storageAccounts/larryshoebox/blobServices/default
                      severity: Sev2
                      state: Disabled
                    type: Microsoft.AlertsManagement/smartDetectorAlertRules
      x-ms-pageable:
        nextLinkName: nextLink
  "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.alertsManagement/smartDetectorAlertRules/{alertRuleName}":
    delete:
      description: Delete an existing Smart Detector alert rule.
      operationId: SmartDetectorAlertRules_Delete
      parameters:
        - $ref: "#/parameters/SubscriptionIdParameter"
        - $ref: "#/parameters/ResourceGroupNameParameter"
        - $ref: "#/parameters/AlertRuleNameParameter"
        - $ref: "#/parameters/ApiVersionParameter"
      responses:
        "200":
          description: Successful request to delete a Smart Detector alert rule.
        "204":
          description: The Smart Detector alert rule does not exist. It may have already been deleted.
        default:
          description: Error response describing why the operation failed.
          schema:
            $ref: "#/definitions/ErrorResponse"
      tags:
        - SmartDetectorAlertRules
      x-ms-examples:
        Delete a Smart Detector alert rule:
          parameters:
            alertRuleName: MyAlertRule
            api-version: 2019-03-01
            resourceGroupName: MyAlertRules
            subscriptionId: b368ca2f-e298-46b7-b0ab-012281956afa
          responses:
            "200": {}
            "204": {}
    get:
      description: Get a specific Smart Detector alert rule.
      operationId: SmartDetectorAlertRules_Get
      parameters:
        - $ref: "#/parameters/SubscriptionIdParameter"
        - $ref: "#/parameters/ResourceGroupNameParameter"
        - $ref: "#/parameters/AlertRuleNameParameter"
        - $ref: "#/parameters/ApiVersionParameter"
        - $ref: "#/parameters/ExpandDetectorParameter"
      responses:
        "200":
          description: Successful request to get Smart Detector alert rule.
          schema:
            $ref: "#/definitions/AlertRule"
        default:
          description: Error response describing why the operation failed.
          schema:
            $ref: "#/definitions/ErrorResponse"
      tags:
        - SmartDetectorAlertRules
      x-ms-examples:
        Get a Smart Detector alert rule:
          parameters:
            alertRuleName: MyAlertRule
            api-version: 2019-03-01
            resourceGroupName: MyAlertRules
            subscriptionId: b368ca2f-e298-46b7-b0ab-012281956afa
          responses:
            "200":
              body:
                id: /subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourceGroups/MyAlertRules/providers/microsoft.alertsManagement/smartDetectorAlertRules/MyAlertRule
                name: MyAlertRule
                properties:
                  actionGroups:
                    - actionGroupId: /subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourcegroups/MyActionGroups/providers/microsoft.insights/actionGroups/MyActionGroup
                  description: Sample smart detector alert rule description
                  detector:
                    id: VMMemoryLeak
                  frequency: PT5M
                  scope:
                    - /subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourceGroups/MyVms/providers/Microsoft.Compute/virtualMachines/vm1
                  severity: Sev3
                  state: Enabled
                  throttling:
                    duration: PT20M
                type: Microsoft.AlertsManagement/smartDetectorAlertRules
    put:
      description: Create or update a Smart Detector alert rule.
      operationId: SmartDetectorAlertRules_CreateOrUpdate
      parameters:
        - $ref: "#/parameters/SubscriptionIdParameter"
        - $ref: "#/parameters/ResourceGroupNameParameter"
        - $ref: "#/parameters/AlertRuleNameParameter"
        - $ref: "#/parameters/ApiVersionParameter"
        - description: Parameters supplied to the operation.
          in: body
          name: parameters
          required: true
          schema:
            $ref: "#/definitions/AlertRule"
      responses:
        "200":
          description: Successful request to update a Smart Detector alert rule.
          schema:
            $ref: "#/definitions/AlertRule"
        "201":
          description: Successful request to create a Smart Detector alert rule.
          schema:
            $ref: "#/definitions/AlertRule"
        default:
          description: Error response describing why the operation failed.
          schema:
            $ref: "#/definitions/ErrorResponse"
      tags:
        - SmartDetectorAlertRules
      x-ms-examples:
        Create or update a Smart Detector alert rule:
          parameters:
            alertRuleName: MyAlertRule
            api-version: 2019-03-01
            parameters:
              properties:
                actionGroups:
                  customEmailSubject: My custom email subject
                  customWebhookPayload: '{"AlertRuleName":"#alertrulename"}'
                  groupIds:
                    - /subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourcegroups/actionGroups/providers/microsoft.insights/actiongroups/MyActionGroup
                description: Sample smart detector alert rule description
                detector:
                  id: VMMemoryLeak
                frequency: PT5M
                scope:
                  - /subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourceGroups/MyVms/providers/Microsoft.Compute/virtualMachines/vm1
                severity: Sev3
                state: Enabled
                throttling:
                  duration: PT20M
            resourceGroupName: MyAlertRules
            subscriptionId: b368ca2f-e298-46b7-b0ab-012281956afa
          responses:
            "200":
              body:
                id: /subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourceGroups/MyAlertRules/providers/microsoft.alertsManagement/smartDetectorAlertRules/MyAlertRule
                name: MyAlertRule
                properties:
                  actionGroups:
                    - actionGroupId: /subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourcegroups/actionGroups/providers/microsoft.insights/actiongroups/MyActionGroup
                  description: Sample smart detector alert rule description
                  detector:
                    id: VMMemoryLeak
                  frequency: PT5M
                  scope:
                    - /subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourceGroups/MyVms/providers/Microsoft.Compute/virtualMachines/vm1
                  severity: Sev3
                  state: Enabled
                  throttling:
                    duration: PT20M
                type: Microsoft.AlertsManagement/smartDetectorAlertRules
            "201":
              body:
                id: /subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourceGroups/MyAlertRules/providers/microsoft.alertsManagement/smartDetectorAlertRules/MyAlertRule
                name: MyAlertRule
                properties:
                  actionGroups:
                    - actionGroupId: /subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourcegroups/actionGroups/providers/microsoft.insights/actiongroups/MyActionGroup
                  description: Sample smart detector alert rule description
                  detector:
                    id: VMMemoryLeak
                  frequency: PT5M
                  scope:
                    - /subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourceGroups/MyVms/providers/Microsoft.Compute/virtualMachines/vm1
                  severity: Sev3
                  state: Enabled
                  throttling:
                    duration: PT20M
                type: Microsoft.AlertsManagement/smartDetectorAlertRules
definitions:
  ActionGroupsInformation:
    description: The Action Groups information, used by the alert rule.
    properties:
      customEmailSubject:
        description: An optional custom email subject to use in email notifications.
        type: string
      customWebhookPayload:
        description: An optional custom web-hook payload to use in web-hook notifications.
        type: string
      groupIds:
        description: The Action Group resource IDs.
        items:
          type: string
        type: array
    required:
      - groupIds
  AlertRule:
    allOf:
      - $ref: "#/definitions/AzureResource"
    description: The alert rule information
    properties:
      properties:
        $ref: "#/definitions/AlertRuleProperties"
        description: The properties of the alert rule.
        x-ms-client-flatten: true
  AlertRuleProperties:
    description: The alert rule properties.
    properties:
      actionGroups:
        $ref: "#/definitions/ActionGroupsInformation"
        description: The alert rule actions.
      description:
        description: The alert rule description.
        type: string
      detector:
        $ref: "#/definitions/Detector"
        description: The alert rule's detector.
      frequency:
        description: The alert rule frequency in ISO8601 format. The time granularity must be in minutes and minimum value is 5 minutes.
        format: duration
        type: string
      scope:
        description: The alert rule resources scope.
        items:
          type: string
        type: array
      severity:
        description: The alert rule severity.
        enum:
          - Sev0
          - Sev1
          - Sev2
          - Sev3
          - Sev4
        type: string
        x-ms-enum:
          modelAsString: true
          name: Severity
      state:
        description: The alert rule state.
        enum:
          - Enabled
          - Disabled
        type: string
        x-ms-enum:
          modelAsString: true
          name: AlertRuleState
      throttling:
        $ref: "#/definitions/ThrottlingInformation"
        description: The alert rule throttling information.
    required:
      - state
      - severity
      - frequency
      - detector
      - scope
      - actionGroups
  AlertRulesList:
    description: List of Smart Detector alert rules.
    properties:
      nextLink:
        description: The URL to get the next set of results.
        type: string
      value:
        description: List of Smart Detector alert rules.
        items:
          $ref: "#/definitions/AlertRule"
        type: array
  AzureResource:
    description: An Azure resource object
    properties:
      id:
        description: The resource ID.
        readOnly: true
        type: string
      name:
        description: The resource name.
        readOnly: true
        type: string
      type:
        description: The resource type.
        readOnly: true
        type: string
    type: object
    x-ms-azure-resource: true
  Detector:
    description: The detector information. By default this is not populated, unless it's specified in expandDetector
    properties:
      description:
        description: The Smart Detector description. By default this is not populated, unless it's specified in expandDetector
        type: string
      id:
        description: The detector id.
        type: string
      imagePaths:
        description: The Smart Detector image path. By default this is not populated, unless it's specified in expandDetector
        items:
          type: string
        type: array
      name:
        description: The Smart Detector name. By default this is not populated, unless it's specified in expandDetector
        type: string
      parameters:
        additionalProperties:
          type: object
        description: The detector's parameters.'
        type: object
      supportedResourceTypes:
        description: The Smart Detector supported resource types. By default this is not populated, unless it's specified in expandDetector
        items:
          type: string
        type: array
    required:
      - id
  ErrorResponse:
    description: Describe the format of an Error response.
    properties:
      code:
        description: Error code
        type: string
      message:
        description: Error message indicating why the operation failed.
        type: string
    type: object
  ThrottlingInformation:
    description: Optional throttling information for the alert rule.
    properties:
      duration:
        description: The required duration (in ISO8601 format) to wait before notifying on the alert rule again. The time granularity must be in minutes and minimum value is 0 minutes
        format: duration
        type: string
