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: 2019-06-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/2019-06-01-preview/WorkloadGroups.json
      version: "2.0"
  x-providerName: azure.com
  x-serviceName: sql-WorkloadGroups
  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/servers/{serverName}/databases/{databaseName}/workloadGroups":
    get:
      description: Gets the list of workload groups
      operationId: WorkloadGroups_ListByDatabase
      parameters:
        - $ref: "#/parameters/ResourceGroupParameter"
        - $ref: "#/parameters/ServerNameParameter"
        - $ref: "#/parameters/DatabaseNameParameter"
        - $ref: "#/parameters/SubscriptionIdParameter"
        - $ref: "#/parameters/ApiVersionParameter"
      responses:
        "200":
          description: Successfully retrieved the list of workload groups.
          schema:
            $ref: "#/definitions/WorkloadGroupListResult"
        default:
          description: |-
            *** Error Responses: ***

             * 400 FeatureDisabledOnSelectedEdition - User attempted to use a feature which is disabled on current database edition.

             * 400 OperationNotAllowedOnPausedDatabase - Operation is not allowed on a paused database.

             * 404 ServerNotInSubscriptionResourceGroup - Specified server does not exist in the specified resource group and subscription.

             * 404 SubscriptionDoesNotHaveServer - The requested server was not found

             * 404 DatabaseDoesNotExist - User has specified a database name that does not exist on this server instance.

             * 404 ResourceNotFound - The requested resource was not found.

             * 409 ConflictingSystemOperationInProgress - A system maintenance operation is in progress on the database and further operations need to wait until it is completed.

             * 409 ConflictingDatabaseOperation - There is already some operation on the database and the current operation should wait till it is done.

             * 503 DatabaseUnavailable - The operation failed because the database is unavailable.

             * 503 TooManyRequests - Requests beyond max requests that can be processed by available resources.

             * 504 RequestTimeout - Service request exceeded the allowed timeout.
      tags:
        - WorkloadGroups
      x-ms-examples:
        Get the list of workload groups for a data warehouse:
          parameters:
            api-version: 2019-06-01-preview
            databaseName: testdb
            resourceGroupName: Default-SQL-SouthEastAsia
            serverName: testsvr
            subscriptionId: 00000000-1111-2222-3333-444444444444
          responses:
            "200":
              body:
                value:
                  - id: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb/workloadGroups/smallrc
                    name: smallrc
                    properties:
                      importance: normal
                      maxResourcePercent: 100
                      maxResourcePercentPerRequest: 5
                      minResourcePercent: 0
                      minResourcePercentPerRequest: 5
                      queryExecutionTimeout: 0
                    type: Microsoft.Sql/servers/databases/workloadGroups
                  - id: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb/workloadGroups/mediumrc
                    name: mediumrc
                    properties:
                      importance: normal
                      maxResourcePercent: 100
                      maxResourcePercentPerRequest: 10
                      minResourcePercent: 0
                      minResourcePercentPerRequest: 10
                      queryExecutionTimeout: 0
                    type: Microsoft.Sql/servers/databases/workloadGroups
                  - id: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb/workloadGroups/largerc
                    name: largerc
                    properties:
                      importance: high
                      maxResourcePercent: 100
                      maxResourcePercentPerRequest: 20
                      minResourcePercent: 0
                      minResourcePercentPerRequest: 20
                      queryExecutionTimeout: 0
                    type: Microsoft.Sql/servers/databases/workloadGroups
      x-ms-pageable:
        nextLinkName: nextLink
  "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}":
    delete:
      description: Deletes a workload group.
      operationId: WorkloadGroups_Delete
      parameters:
        - $ref: "#/parameters/ResourceGroupParameter"
        - $ref: "#/parameters/ServerNameParameter"
        - $ref: "#/parameters/DatabaseNameParameter"
        - description: The name of the workload group to delete.
          in: path
          name: workloadGroupName
          required: true
          type: string
        - $ref: "#/parameters/SubscriptionIdParameter"
        - $ref: "#/parameters/ApiVersionParameter"
      responses:
        "200":
          description: Successfully deleted the workload group.
        "202":
          description: Deleting the workload group is in progress.
        "204":
          description: The specified workload group does not exist.
        default:
          description: |-
            *** Error Responses: ***

             * 400 FeatureDisabledOnSelectedEdition - User attempted to use a feature which is disabled on current database edition.

             * 400 OperationNotAllowedOnPausedDatabase - Operation is not allowed on a paused database.

             * 404 ServerNotInSubscriptionResourceGroup - Specified server does not exist in the specified resource group and subscription.

             * 404 SubscriptionDoesNotHaveServer - The requested server was not found

             * 404 DatabaseDoesNotExist - User has specified a database name that does not exist on this server instance.

             * 404 ResourceNotFound - The requested resource was not found.

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

             * 409 ConflictingSystemOperationInProgress - A system maintenance operation is in progress on the database and further operations need to wait until it is completed.

             * 409 ConflictingDatabaseOperation - There is already some operation on the database and the current operation should wait till it is done.

             * 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 DatabaseUnavailable - The operation failed because the database is unavailable.

             * 503 TooManyRequests - Requests beyond max requests that can be processed by available resources.

             * 504 RequestTimeout - Service request exceeded the allowed timeout.
      tags:
        - WorkloadGroups
      x-ms-examples:
        Delete a workload group:
          parameters:
            api-version: 2019-06-01-preview
            databaseName: testdb
            resourceGroupName: Default-SQL-SouthEastAsia
            serverName: testsvr
            subscriptionId: 00000000-1111-2222-3333-444444444444
            workloadGroupName: wlm_workloadgroup
          responses:
            "200": {}
            "202": {}
            "204": {}
      x-ms-long-running-operation: true
    get:
      description: Gets a workload group
      operationId: WorkloadGroups_Get
      parameters:
        - $ref: "#/parameters/ResourceGroupParameter"
        - $ref: "#/parameters/ServerNameParameter"
        - $ref: "#/parameters/DatabaseNameParameter"
        - description: The name of the workload group.
          in: path
          name: workloadGroupName
          required: true
          type: string
        - $ref: "#/parameters/SubscriptionIdParameter"
        - $ref: "#/parameters/ApiVersionParameter"
      responses:
        "200":
          description: Successfully retrieved the specifies workload group.
          schema:
            $ref: "#/definitions/WorkloadGroup"
        default:
          description: |-
            *** Error Responses: ***

             * 400 FeatureDisabledOnSelectedEdition - User attempted to use a feature which is disabled on current database edition.

             * 400 OperationNotAllowedOnPausedDatabase - Operation is not allowed on a paused database.

             * 404 ServerNotInSubscriptionResourceGroup - Specified server does not exist in the specified resource group and subscription.

             * 404 SubscriptionDoesNotHaveServer - The requested server was not found

             * 404 DatabaseDoesNotExist - User has specified a database name that does not exist on this server instance.

             * 404 ResourceNotFound - The requested resource was not found.

             * 409 ConflictingSystemOperationInProgress - A system maintenance operation is in progress on the database and further operations need to wait until it is completed.

             * 409 ConflictingDatabaseOperation - There is already some operation on the database and the current operation should wait till it is done.

             * 503 DatabaseUnavailable - The operation failed because the database is unavailable.

             * 503 TooManyRequests - Requests beyond max requests that can be processed by available resources.

             * 504 RequestTimeout - Service request exceeded the allowed timeout.
      tags:
        - WorkloadGroups
      x-ms-examples:
        Gets a workload group for a data warehouse:
          parameters:
            api-version: 2019-06-01-preview
            databaseName: testdb
            resourceGroupName: Default-SQL-SouthEastAsia
            serverName: testsvr
            subscriptionId: 00000000-1111-2222-3333-444444444444
            workloadGroupName: smallrc
          responses:
            "200":
              body:
                id: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb/workloadGroups/smallrc
                name: smallrc
                properties:
                  importance: normal
                  maxResourcePercent: 100
                  maxResourcePercentPerRequest: 3
                  minResourcePercent: 0
                  minResourcePercentPerRequest: 3
                  queryExecutionTimeout: 0
                type: Microsoft.Sql/servers/databases/workloadGroups
    put:
      description: Creates or updates a workload group.
      operationId: WorkloadGroups_CreateOrUpdate
      parameters:
        - $ref: "#/parameters/ResourceGroupParameter"
        - $ref: "#/parameters/ServerNameParameter"
        - $ref: "#/parameters/DatabaseNameParameter"
        - description: The name of the workload group.
          in: path
          name: workloadGroupName
          required: true
          type: string
        - description: The requested workload group state.
          in: body
          name: parameters
          required: true
          schema:
            $ref: "#/definitions/WorkloadGroup"
        - $ref: "#/parameters/SubscriptionIdParameter"
        - $ref: "#/parameters/ApiVersionParameter"
      responses:
        "200":
          description: Successfully updated the workload group.
          schema:
            $ref: "#/definitions/WorkloadGroup"
        "201":
          description: Successfully created the workload group.
          schema:
            $ref: "#/definitions/WorkloadGroup"
        "202":
          description: Create or update for the workload group accepted.
        default:
          description: |-
            *** Error Responses: ***

             * 400 FeatureDisabledOnSelectedEdition - User attempted to use a feature which is disabled on current database edition.

             * 400 OperationNotAllowedOnPausedDatabase - Operation is not allowed on a paused database.

             * 400 InvalidWorkloadGroupNameParameter - Invalid workload group name

             * 400 InvalidMinResourcePercentParameter - Invalid min resource percent for this workload group.

             * 400 InvalidMinResourcePercentPerRequestParameter - Invalid min resource percent per query for this workload group.

             * 400 InvalidMaxResourcePercentParameter - Invalid max resource percent to allocate for this workload group.

             * 400 InvalidMaxResourcePercentPerRequestParameter - Invalid max resource percent per query for this workload group.

             * 400 InvalidImportanceParameter - Importance must be one of the following strings: Low, Below_Normal, Normal, Above_Normal, High.

             * 400 InvalidQueryExecutionTimeoutParameter - Invalid query execution timeout value for this workload group.

             * 400 InvalidResourceRequestBody - The resource or resource properties in the request body is empty or invalid.

             * 404 ServerNotInSubscriptionResourceGroup - Specified server does not exist in the specified resource group and subscription.

             * 404 SubscriptionDoesNotHaveServer - The requested server was not found

             * 404 DatabaseDoesNotExist - User has specified a database name that does not exist on this server instance.

             * 404 ResourceNotFound - The requested resource was not found.

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

             * 409 ConflictingSystemOperationInProgress - A system maintenance operation is in progress on the database and further operations need to wait until it is completed.

             * 409 ConflictingDatabaseOperation - There is already some operation on the database and the current operation should wait till it is done.

             * 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 DatabaseUnavailable - The operation failed because the database is unavailable.

             * 503 TooManyRequests - Requests beyond max requests that can be processed by available resources.

             * 504 RequestTimeout - Service request exceeded the allowed timeout.
      tags:
        - WorkloadGroups
      x-ms-examples:
        Create a workload group with all properties specified.:
          parameters:
            api-version: 2019-06-01-preview
            databaseName: testdb
            parameters:
              properties:
                importance: normal
                maxResourcePercent: 100
                maxResourcePercentPerRequest: 3
                minResourcePercent: 0
                minResourcePercentPerRequest: 3
                queryExecutionTimeout: 0
            resourceGroupName: Default-SQL-SouthEastAsia
            serverName: testsvr
            subscriptionId: 00000000-1111-2222-3333-444444444444
            workloadGroupName: smallrc
          responses:
            "200":
              body:
                id: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb/workloadGroups/smallrc
                name: smallrc
                properties:
                  importance: normal
                  maxResourcePercent: 100
                  maxResourcePercentPerRequest: 3
                  minResourcePercent: 0
                  minResourcePercentPerRequest: 3
                  queryExecutionTimeout: 0
                type: Microsoft.Sql/servers/databases/workloadGroups
            "201":
              body:
                id: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb/workloadGroups/smallrc
                name: smallrc
                properties:
                  importance: normal
                  maxResourcePercent: 100
                  maxResourcePercentPerRequest: 3
                  minResourcePercent: 0
                  minResourcePercentPerRequest: 3
                  queryExecutionTimeout: 0
                type: Microsoft.Sql/servers/databases/workloadGroups
            "202": {}
        Create a workload group with the required properties specified.:
          parameters:
            api-version: 2019-06-01-preview
            databaseName: testdb
            parameters:
              properties:
                maxResourcePercent: 100
                minResourcePercent: 0
                minResourcePercentPerRequest: 3
            resourceGroupName: Default-SQL-SouthEastAsia
            serverName: testsvr
            subscriptionId: 00000000-1111-2222-3333-444444444444
            workloadGroupName: smallrc
          responses:
            "200":
              body:
                id: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb/workloadGroups/smallrc
                name: smallrc
                properties:
                  importance: normal
                  maxResourcePercent: 100
                  maxResourcePercentPerRequest: 3
                  minResourcePercent: 0
                  minResourcePercentPerRequest: 3
                  queryExecutionTimeout: 0
                type: Microsoft.Sql/servers/databases/workloadGroups
            "201":
              body:
                id: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb/workloadGroups/smallrc
                name: smallrc
                properties:
                  importance: normal
                  maxResourcePercent: 100
                  maxResourcePercentPerRequest: 3
                  minResourcePercent: 0
                  minResourcePercentPerRequest: 3
                  queryExecutionTimeout: 0
                type: Microsoft.Sql/servers/databases/workloadGroups
            "202": {}
      x-ms-long-running-operation: true
definitions:
  ProxyResource:
    allOf:
      - $ref: "#/definitions/Resource"
    description: ARM proxy resource.
    properties: {}
    type: object
  Resource:
    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
  WorkloadGroup:
    allOf:
      - $ref: "#/definitions/ProxyResource"
    description: Workload group operations for a data warehouse
    properties:
      properties:
        $ref: "#/definitions/WorkloadGroupProperties"
        description: Resource properties.
        x-ms-client-flatten: true
    type: object
  WorkloadGroupListResult:
    description: A list of workload groups.
    properties:
      nextLink:
        description: Link to retrieve next page of results.
        readOnly: true
        type: string
      value:
        description: Array of results.
        items:
          $ref: "#/definitions/WorkloadGroup"
        readOnly: true
        type: array
    type: object
  WorkloadGroupProperties:
    description: Workload group definition. For more information look at sys.workload_management_workload_groups (DMV).
    properties:
      importance:
        description: The workload group importance level.
        type: string
      maxResourcePercent:
        description: The workload group cap percentage resource.
        format: int32
        type: integer
      maxResourcePercentPerRequest:
        description: The workload group request maximum grant percentage.
        format: double
        type: number
      minResourcePercent:
        description: The workload group minimum percentage resource.
        format: int32
        type: integer
      minResourcePercentPerRequest:
        description: The workload group request minimum grant percentage.
        format: double
        type: number
      queryExecutionTimeout:
        description: The workload group query execution timeout.
        format: int32
        type: integer
    required:
      - minResourcePercent
      - maxResourcePercent
      - minResourcePercentPerRequest
    type: object
