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/serverAutomaticTuning.json
      version: "2.0"
  x-providerName: azure.com
  x-serviceName: sql-serverAutomaticTuning
  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
  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/servers/{serverName}/automaticTuning/current":
    get:
      description: Retrieves server automatic tuning options.
      operationId: ServerAutomaticTuning_Get
      parameters:
        - $ref: "#/parameters/ResourceGroupParameter"
        - $ref: "#/parameters/ServerNameParameter"
        - $ref: "#/parameters/SubscriptionIdParameter"
        - $ref: "#/parameters/ApiVersionParameter"
      responses:
        "200":
          description: Successfully retrieved server automatic tuning properties.
          schema:
            $ref: "#/definitions/ServerAutomaticTuning"
        default:
          description: |-
            *** Error Responses: ***

             * 400 InvalidIdentifier - The identifier contains NULL or an invalid unicode character.

             * 404 SubscriptionDoesNotHaveServer - The requested server was not found

             * 404 DatabaseDoesNotExist - The requested database was not found

             * 404 SubscriptionDoesNotHaveElasticPool - The requested elastic pool was not found

             * 404 OperationIdNotFound - The operation with Id does not exist.

             * 405 NotSupported - This functionality is not supported.

             * 409 Conflict - Request could not be processed because of conflict in the request.

             * 409 OperationCancelled - The operation has been cancelled by user.

             * 409 OperationInterrupted - The operation on the resource could not be completed because it was interrupted by another operation on the same resource.

             * 500 OperationTimedOut - The operation timed out and automatically rolled back. Please retry the operation.

             * 503 ServiceTemporarilyUnavailable - Feature temporarily unavailable.
      tags:
        - ServerAutomaticTuning
      x-ms-examples:
        Get a server's automatic tuning settings:
          parameters:
            api-version: 2017-03-01-preview
            resourceGroupName: default-sql-onebox
            serverName: testsvr11
            subscriptionId: c3aa9078-0000-0000-0000-e36f151182d7
          responses:
            "200":
              body:
                id: /subscriptions/c3aa9078-0000-0000-0000-e36f151182d7/resourceGroups/default-sql-onebox/providers/Microsoft.Sql/servers/testsvr11/automaticTuning/current
                name: current
                properties:
                  actualState: Auto
                  desiredState: Auto
                  options:
                    createIndex:
                      actualState: On
                      desiredState: Default
                      reasonCode: 2
                      reasonDesc: AutoConfigured
                    dropIndex:
                      actualState: Off
                      desiredState: Default
                      reasonCode: 2
                      reasonDesc: AutoConfigured
                    forceLastGoodPlan:
                      actualState: On
                      desiredState: Default
                      reasonCode: 2
                      reasonDesc: AutoConfigured
                    maintainIndex:
                      actualState: Off
                      desiredState: Default
                      reasonCode: 2
                      reasonDesc: AutoConfigured
                type: Microsoft.Sql/servers/automaticTuning
    patch:
      description: Update automatic tuning options on server.
      operationId: ServerAutomaticTuning_Update
      parameters:
        - $ref: "#/parameters/ResourceGroupParameter"
        - $ref: "#/parameters/ServerNameParameter"
        - description: The requested automatic tuning resource state.
          in: body
          name: parameters
          required: true
          schema:
            $ref: "#/definitions/ServerAutomaticTuning"
        - $ref: "#/parameters/SubscriptionIdParameter"
        - $ref: "#/parameters/ApiVersionParameter"
      responses:
        "200":
          description: Successfully updated the server-level automatic tuning options.
          schema:
            $ref: "#/definitions/ServerAutomaticTuning"
        default:
          description: |-
            *** Error Responses: ***

             * 400 InvalidIdentifier - The identifier contains NULL or an invalid unicode character.

             * 400 InvalidAutomaticTuningUpsertRequest - The update automatic tuning request body does not exist or has no properties object.

             * 400 InvalidAdvisorAutoExecuteStatus - Specified auto-execute status for the advisor is not allowed.

             * 404 SubscriptionDoesNotHaveServer - The requested server was not found

             * 404 DatabaseDoesNotExist - The requested database was not found

             * 404 SubscriptionDoesNotHaveElasticPool - The requested elastic pool was not found

             * 404 OperationIdNotFound - The operation with Id does not exist.

             * 405 NotSupported - This functionality is not supported.

             * 409 Conflict - Request could not be processed because of conflict in the request.

             * 409 OperationCancelled - The operation has been cancelled by user.

             * 409 OperationInterrupted - The operation on the resource could not be completed because it was interrupted by another operation on the same resource.

             * 500 OperationTimedOut - The operation timed out and automatically rolled back. Please retry the operation.

             * 503 ServiceTemporarilyUnavailable - Feature temporarily unavailable.
      tags:
        - ServerAutomaticTuning
      x-ms-examples:
        Updates server automatic tuning settings with all properties:
          parameters:
            api-version: 2017-03-01-preview
            parameters:
              properties:
                desiredState: Auto
                options:
                  createIndex:
                    desiredState: Off
                  dropIndex:
                    desiredState: On
                  forceLastGoodPlan:
                    desiredState: Default
            resourceGroupName: default-sql-onebox
            serverName: testsvr11
            subscriptionId: c3aa9078-0000-0000-0000-e36f151182d7
          responses:
            "200":
              body:
                id: /subscriptions/c3aa9078-0000-0000-0000-e36f151182d7/resourceGroups/default-sql-onebox/providers/Microsoft.Sql/servers/testsvr11/automaticTuning/current
                name: current
                properties:
                  actualState: Auto
                  desiredState: Auto
                  options:
                    createIndex:
                      actualState: Off
                      desiredState: Off
                    dropIndex:
                      actualState: On
                      desiredState: On
                    forceLastGoodPlan:
                      actualState: On
                      desiredState: Default
                      reasonCode: 2
                      reasonDesc: AutoConfigured
                    maintainIndex:
                      actualState: Off
                      desiredState: Default
                      reasonCode: 2
                      reasonDesc: AutoConfigured
                type: Microsoft.Sql/servers/automaticTuning
        Updates server automatic tuning settings with minimal properties:
          parameters:
            api-version: 2017-03-01-preview
            parameters:
              properties:
                desiredState: Auto
            resourceGroupName: default-sql-onebox
            serverName: testsvr11
            subscriptionId: c3aa9078-0000-0000-0000-e36f151182d7
          responses:
            "200":
              body:
                id: /subscriptions/c3aa9078-0000-0000-0000-e36f151182d7/resourceGroups/default-sql-onebox/providers/Microsoft.Sql/servers/testsvr11/automaticTuning/current
                name: current
                properties:
                  actualState: Auto
                  desiredState: Auto
                  options:
                    createIndex:
                      actualState: On
                      desiredState: Default
                      reasonCode: 2
                      reasonDesc: AutoConfigured
                    dropIndex:
                      actualState: Off
                      desiredState: Default
                      reasonCode: 2
                      reasonDesc: AutoConfigured
                    forceLastGoodPlan:
                      actualState: On
                      desiredState: Default
                      reasonCode: 2
                      reasonDesc: AutoConfigured
                    maintainIndex:
                      actualState: Off
                      desiredState: Default
                      reasonCode: 2
                      reasonDesc: AutoConfigured
                type: Microsoft.Sql/servers/automaticTuning
definitions:
  AutomaticTuningServerOptions:
    description: Automatic tuning properties for individual advisors.
    properties:
      actualState:
        description: Automatic tuning option actual state.
        enum:
          - Off
          - On
        readOnly: true
        type: string
        x-ms-enum:
          modelAsString: false
          name: AutomaticTuningOptionModeActual
      desiredState:
        description: Automatic tuning option desired state.
        enum:
          - Off
          - On
          - Default
        type: string
        x-ms-enum:
          modelAsString: false
          name: AutomaticTuningOptionModeDesired
      reasonCode:
        description: Reason code if desired and actual state are different.
        format: int32
        readOnly: true
        type: integer
      reasonDesc:
        description: Reason description if desired and actual state are different.
        enum:
          - Default
          - Disabled
          - AutoConfigured
        readOnly: true
        type: string
        x-ms-enum:
          modelAsString: false
          name: AutomaticTuningServerReason
    type: object
  AutomaticTuningServerProperties:
    description: Server-level Automatic Tuning properties.
    properties:
      actualState:
        description: Automatic tuning actual state.
        enum:
          - Custom
          - Auto
          - Unspecified
        readOnly: true
        type: string
        x-ms-enum:
          modelAsString: false
          name: AutomaticTuningServerMode
      desiredState:
        description: Automatic tuning desired state.
        enum:
          - Custom
          - Auto
          - Unspecified
        type: string
        x-ms-enum:
          modelAsString: false
          name: AutomaticTuningServerMode
      options:
        additionalProperties:
          $ref: "#/definitions/AutomaticTuningServerOptions"
        description: Automatic tuning options definition.
        type: object
    type: object
  ServerAutomaticTuning:
    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: Server-level Automatic Tuning.
    properties:
      properties:
        $ref: "#/definitions/AutomaticTuningServerProperties"
        description: Resource properties.
        x-ms-client-flatten: true
    type: object
