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: 2015-05-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/2015-05-01-preview/serverKeys.json
      version: "2.0"
  x-providerName: azure.com
  x-serviceName: sql-serverKeys
  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
  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
  SubscriptionIdParameter:
    description: The subscription ID that identifies an Azure subscription.
    in: path
    name: subscriptionId
    required: true
    type: string
    x-ms-parameter-location: client
paths:
  "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/keys":
    get:
      description: Gets a list of server keys.
      operationId: ServerKeys_ListByServer
      parameters:
        - $ref: "#/parameters/ResourceGroupParameter"
        - $ref: "#/parameters/ServerNameParameter"
        - $ref: "#/parameters/SubscriptionIdParameter"
        - $ref: "#/parameters/ApiVersionParameter"
      responses:
        "200":
          description: Successfully retrieved the list of server keys.
          schema:
            $ref: "#/definitions/ServerKeyListResult"
        default:
          description: |-
            *** Error Responses: ***

             * 400 InvalidKeyName - An invalid value was given for the server key name.

             * 400 InvalidKeyType - The create server key type is not supported.

             * 400 InvalidKeyUpsertRequest - The create server key request does not exist or has no properties object.

             * 404 SubscriptionDoesNotHaveServer - The requested server was not found
      tags:
        - ServerKeys
      x-ms-examples:
        List the server keys by server:
          parameters:
            api-version: 2015-05-01-preview
            resourceGroupName: sqlcrudtest-7398
            serverName: sqlcrudtest-4645
            subscriptionId: 00000000-1111-2222-3333-444444444444
          responses:
            "200":
              body:
                value:
                  - id: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/sqlcrudtest-7398/providers/Microsoft.Sql/servers/sqlcrudtest-4645/keys/someVault_someKey_01234567890123456789012345678901
                    kind: azurekeyvault
                    location: Japan East
                    name: someVault_someKey_01234567890123456789012345678901
                    properties:
                      creationDate: 2017-05-01T00:00:00.0Z
                      serverKeyType: AzureKeyVault
                      thumbprint: 00112233445566778899AABBCCDDEEFFAABBCCDD
                      uri: https://someVault.vault.azure.net/keys/someKey/01234567890123456789012345678901
                    type: Microsoft.Sql/servers/keys
                  - id: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/sqlcrudtest-7398/providers/Microsoft.Sql/servers/sqlcrudtest-4645/keys/myVault_myKey_11111111111111111111111111111111
                    kind: azurekeyvault
                    location: Japan East
                    name: myVault_myKey_11111111111111111111111111111111
                    properties:
                      creationDate: 2017-05-01T00:00:00.0Z
                      serverKeyType: AzureKeyVault
                      thumbprint: AAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBB
                      uri: https://myVault.vault.azure.net/keys/myKey/11111111111111111111111111111111
                    type: Microsoft.Sql/servers/keys
                  - id: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/sqlcrudtest-7398/providers/Microsoft.Sql/servers/sqlcrudtest-4645/keys/ServiceManaged
                    kind: servicemanaged
                    location: Japan East
                    name: ServiceManaged
                    properties:
                      serverKeyType: ServiceManaged
                    type: Microsoft.Sql/servers/keys
      x-ms-pageable:
        nextLinkName: nextLink
  "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/keys/{keyName}":
    delete:
      description: Deletes the server key with the given name.
      operationId: ServerKeys_Delete
      parameters:
        - $ref: "#/parameters/ResourceGroupParameter"
        - $ref: "#/parameters/ServerNameParameter"
        - description: The name of the server key to be deleted.
          in: path
          name: keyName
          required: true
          type: string
        - $ref: "#/parameters/SubscriptionIdParameter"
        - $ref: "#/parameters/ApiVersionParameter"
      responses:
        "200":
          description: Successfully deleted the server key.
        "202":
          description: Accepted
        "204":
          description: The specified server key does not exist.
        default:
          description: |-
            *** Error Responses: ***

             * 400 InvalidKeyName - An invalid value was given for the server key name.

             * 400 InvalidKeyType - The create server key type is not supported.

             * 400 InvalidKeyUpsertRequest - The create server key request does not exist or has no properties object.

             * 400 AzureKeyVaultInvalidExpirationDate - The operation could not be completed because the Azure Key Vault key expiration date is invalid.

             * 400 AzureKeyVaultInvalidUri - An invalid response from Azure Key Vault. Please use a valid Azure Key Vault URI.

             * 400 AzureKeyVaultMalformedVaultUri - The provided Key Vault uri is not valid.

             * 401 AzureKeyVaultKeyDisabled - The operation could not be completed on the server because the Azure Key Vault key is disabled.

             * 401 AzureKeyVaultNoServerIdentity - The server identity is not correctly configured on server. Please contact support.

             * 401 AzureKeyVaultMissingPermissions - The server is missing required permissions on the Azure Key Vault. 

             * 401 AdalGenericError - The operation could not be completed because an Azure Active Directory error was encountered.

             * 401 AdalServicePrincipalNotFound - The operation could not be completed because an Azure Active Directory library Service Principal not found error was encountered.

             * 404 SubscriptionDoesNotHaveServer - The requested server was not found

             * 404 ResourceNotFound - The requested resource was not found.

             * 409 ServerKeyUriAlreadyExists - The server key URI already exists on the server.

             * 409 ServerKeyDoesNotExists - The server key does not exist.

             * 409 AzureKeyVaultKeyNameNotFound - The operation could not be completed because the Azure Key Vault Key name does not exist.

             * 409 AzureKeyVaultKeyInUse - The key is currently being used by the server.

             * 409 ServerKeyNameAlreadyExists - The server key already exists on the server.

             * 503 AzureKeyVaultConnectionFailed - The operation could not be completed on the server because attempts to connect to Azure Key Vault have failed

             * 503 AzureKeyVaultGenericConnectionError - The operation could not be completed because an error was encountered when attempting to retrieve Key Vault information .
      tags:
        - ServerKeys
      x-ms-examples:
        Delete the server key:
          parameters:
            api-version: 2015-05-01-preview
            keyName: someVault_someKey_01234567890123456789012345678901
            resourceGroupName: sqlcrudtest-7398
            serverName: sqlcrudtest-4645
            subscriptionId: 00000000-1111-2222-3333-444444444444
          responses:
            "200": {}
            "202": {}
            "204": {}
      x-ms-long-running-operation: true
    get:
      description: Gets a server key.
      operationId: ServerKeys_Get
      parameters:
        - $ref: "#/parameters/ResourceGroupParameter"
        - $ref: "#/parameters/ServerNameParameter"
        - description: The name of the server key to be retrieved.
          in: path
          name: keyName
          required: true
          type: string
        - $ref: "#/parameters/SubscriptionIdParameter"
        - $ref: "#/parameters/ApiVersionParameter"
      responses:
        "200":
          description: Successfully retrieved the specified server key.
          schema:
            $ref: "#/definitions/ServerKey"
        default:
          description: |-
            *** Error Responses: ***

             * 400 InvalidKeyName - An invalid value was given for the server key name.

             * 400 InvalidKeyType - The create server key type is not supported.

             * 400 InvalidKeyUpsertRequest - The create server key request does not exist or has no properties object.

             * 404 SubscriptionDoesNotHaveServer - The requested server was not found

             * 404 ResourceNotFound - The requested resource was not found.
      tags:
        - ServerKeys
      x-ms-examples:
        Get the server key:
          parameters:
            api-version: 2015-05-01-preview
            keyName: someVault_someKey_01234567890123456789012345678901
            resourceGroupName: sqlcrudtest-7398
            serverName: sqlcrudtest-4645
            subscriptionId: 00000000-1111-2222-3333-444444444444
          responses:
            "200":
              body:
                id: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/sqlcrudtest-7398/providers/Microsoft.Sql/servers/sqlcrudtest-4645/keys/someVault_someKey_01234567890123456789012345678901
                kind: azurekeyvault
                location: Japan East
                name: sqlcrudtest-4645
                properties:
                  creationDate: 2017-05-01T00:00:00.0Z
                  serverKeyType: AzureKeyVault
                  thumbprint: 00112233445566778899AABBCCDDEEFFAABBCCDD
                  uri: https://someVault.vault.azure.net/keys/someKey/01234567890123456789012345678901
                type: Microsoft.Sql/servers/keys
    put:
      description: Creates or updates a server key.
      operationId: ServerKeys_CreateOrUpdate
      parameters:
        - $ref: "#/parameters/ResourceGroupParameter"
        - $ref: "#/parameters/ServerNameParameter"
        - description: "The name of the server key to be operated on (updated or created). The key name is required to be in the format of 'vault_key_version'. For example, if the keyId is https://YourVaultName.vault.azure.net/keys/YourKeyName/01234567890123456789012345678901, then the server key name should be formatted as: YourVaultName_YourKeyName_01234567890123456789012345678901"
          in: path
          name: keyName
          required: true
          type: string
        - description: The requested server key resource state.
          in: body
          name: parameters
          required: true
          schema:
            $ref: "#/definitions/ServerKey"
        - $ref: "#/parameters/SubscriptionIdParameter"
        - $ref: "#/parameters/ApiVersionParameter"
      responses:
        "200":
          description: Successfully updated the server key.
          schema:
            $ref: "#/definitions/ServerKey"
        "201":
          description: Successfully created the server key.
          schema:
            $ref: "#/definitions/ServerKey"
        "202":
          description: Accepted
        default:
          description: |-
            *** Error Responses: ***

             * 400 InvalidKeyName - An invalid value was given for the server key name.

             * 400 InvalidKeyType - The create server key type is not supported.

             * 400 InvalidKeyUpsertRequest - The create server key request does not exist or has no properties object.

             * 400 AzureKeyVaultInvalidExpirationDate - The operation could not be completed because the Azure Key Vault key expiration date is invalid.

             * 400 AzureKeyVaultInvalidUri - An invalid response from Azure Key Vault. Please use a valid Azure Key Vault URI.

             * 400 AzureKeyVaultMalformedVaultUri - The provided Key Vault uri is not valid.

             * 400 AzureKeyVaultInvalidExpirationDate - The operation could not be completed because the Azure Key Vault key expiration date is invalid.

             * 400 AzureKeyVaultInvalidUri - An invalid response from Azure Key Vault. Please use a valid Azure Key Vault URI.

             * 400 AzureKeyVaultMalformedVaultUri - The provided Key Vault uri is not valid.

             * 401 AzureKeyVaultKeyDisabled - The operation could not be completed on the server because the Azure Key Vault key is disabled.

             * 401 AzureKeyVaultNoServerIdentity - The server identity is not correctly configured on server. Please contact support.

             * 401 AzureKeyVaultMissingPermissions - The server is missing required permissions on the Azure Key Vault. 

             * 401 AdalGenericError - The operation could not be completed because an Azure Active Directory error was encountered.

             * 401 AdalServicePrincipalNotFound - The operation could not be completed because an Azure Active Directory library Service Principal not found error was encountered.

             * 401 AzureKeyVaultKeyDisabled - The operation could not be completed on the server because the Azure Key Vault key is disabled.

             * 401 AzureKeyVaultNoServerIdentity - The server identity is not correctly configured on server. Please contact support.

             * 401 AzureKeyVaultMissingPermissions - The server is missing required permissions on the Azure Key Vault. 

             * 401 AdalGenericError - The operation could not be completed because an Azure Active Directory error was encountered.

             * 401 AdalServicePrincipalNotFound - The operation could not be completed because an Azure Active Directory library Service Principal not found error was encountered.

             * 404 SubscriptionDoesNotHaveServer - The requested server was not found

             * 404 ResourceNotFound - The requested resource was not found.

             * 409 ServerKeyUriAlreadyExists - The server key URI already exists on the server.

             * 409 ServerKeyDoesNotExists - The server key does not exist.

             * 409 AzureKeyVaultKeyNameNotFound - The operation could not be completed because the Azure Key Vault Key name does not exist.

             * 409 AzureKeyVaultKeyInUse - The key is currently being used by the server.

             * 409 ServerKeyNameAlreadyExists - The server key already exists on the server.

             * 409 ServerKeyUriAlreadyExists - The server key URI already exists on the server.

             * 409 ServerKeyDoesNotExists - The server key does not exist.

             * 409 AzureKeyVaultKeyNameNotFound - The operation could not be completed because the Azure Key Vault Key name does not exist.

             * 409 AzureKeyVaultKeyInUse - The key is currently being used by the server.

             * 409 ServerKeyNameAlreadyExists - The server key already exists on the server.

             * 503 AzureKeyVaultConnectionFailed - The operation could not be completed on the server because attempts to connect to Azure Key Vault have failed

             * 503 AzureKeyVaultGenericConnectionError - The operation could not be completed because an error was encountered when attempting to retrieve Key Vault information .

             * 503 AzureKeyVaultConnectionFailed - The operation could not be completed on the server because attempts to connect to Azure Key Vault have failed

             * 503 AzureKeyVaultGenericConnectionError - The operation could not be completed because an error was encountered when attempting to retrieve Key Vault information .
      tags:
        - ServerKeys
      x-ms-examples:
        Creates or updates a server key:
          parameters:
            api-version: 2015-05-01-preview
            keyName: someVault_someKey_01234567890123456789012345678901
            parameters:
              properties:
                serverKeyType: AzureKeyVault
                uri: https://someVault.vault.azure.net/keys/someKey/01234567890123456789012345678901
            resourceGroupName: sqlcrudtest-7398
            serverName: sqlcrudtest-4645
            subscriptionId: 00000000-1111-2222-3333-444444444444
          responses:
            "200":
              body:
                id: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/sqlcrudtest-7398/providers/Microsoft.Sql/servers/sqlcrudtest-4645/keys/someVault_someKey_01234567890123456789012345678901
                kind: azurekeyvault
                location: Japan East
                name: sqlcrudtest-4645
                properties:
                  creationDate: 2017-05-01T00:00:00.0Z
                  serverKeyType: AzureKeyVault
                  thumbprint: 00112233445566778899AABBCCDDEEFFAABBCCDD
                  uri: https://someVault.vault.azure.net/keys/someKey/01234567890123456789012345678901
                type: Microsoft.Sql/servers/keys
            "201":
              body:
                id: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/sqlcrudtest-7398/providers/Microsoft.Sql/servers/sqlcrudtest-4645/keys/someVault_someKey_01234567890123456789012345678901
                kind: azurekeyvault
                location: Japan East
                name: sqlcrudtest-4645
                properties:
                  creationDate: 2017-05-01T00:00:00.0Z
                  serverKeyType: AzureKeyVault
                  thumbprint: 00112233445566778899AABBCCDDEEFFAABBCCDD
                  uri: https://someVault.vault.azure.net/keys/someKey/01234567890123456789012345678901
                type: Microsoft.Sql/servers/keys
            "202": {}
      x-ms-long-running-operation: true
definitions:
  ServerKey:
    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 server key.
    properties:
      kind:
        description: Kind of encryption protector. This is metadata used for the Azure portal experience.
        type: string
      location:
        description: Resource location.
        readOnly: true
        type: string
      properties:
        $ref: "#/definitions/ServerKeyProperties"
        description: Resource properties.
        x-ms-client-flatten: true
    type: object
  ServerKeyListResult:
    description: A list of server keys.
    properties:
      nextLink:
        description: Link to retrieve next page of results.
        readOnly: true
        type: string
      value:
        description: Array of results.
        items:
          $ref: "#/definitions/ServerKey"
        readOnly: true
        type: array
    type: object
  ServerKeyProperties:
    description: Properties for a server key execution.
    properties:
      creationDate:
        description: The server key creation date.
        format: date-time
        type: string
      serverKeyType:
        description: The server key type like 'ServiceManaged', 'AzureKeyVault'.
        enum:
          - ServiceManaged
          - AzureKeyVault
        type: string
        x-ms-enum:
          modelAsString: true
          name: ServerKeyType
      subregion:
        description: Subregion of the server key.
        readOnly: true
        type: string
      thumbprint:
        description: Thumbprint of the server key.
        type: string
      uri:
        description: The URI of the server key.
        type: string
    required:
      - serverKeyType
    type: object
