swagger: "2.0"
schemes:
  - https
host: management.azure.com
info:
  description: Provides create, read, update and delete functionality for Azure SQL Database datamasking policies and rules.
  title: Azure SQL Database Datamasking Policies and Rules
  version: 2014-04-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/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/dataMasking.json
      version: "2.0"
  x-providerName: azure.com
  x-serviceName: sql-dataMasking
  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:
  DataMaskingPolicyNameParameter:
    description: The name of the database for which the data masking rule applies.
    enum:
      - Default
    in: path
    name: dataMaskingPolicyName
    required: true
    type: string
    x-ms-enum:
      modelAsString: false
      name: DataMaskingPolicyName
    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
  ServerNameParameter:
    description: The name of the server.
    in: path
    name: serverName
    required: true
    type: string
    x-ms-parameter-location: method
paths:
  "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataMaskingPolicies/{dataMaskingPolicyName}":
    get:
      description: Gets a database data masking policy.
      operationId: DataMaskingPolicies_Get
      parameters:
        - description: The API version to use for the request.
          in: query
          name: api-version
          required: true
          type: string
          x-ms-parameter-location: client
        - description: The subscription ID that identifies an Azure subscription.
          in: path
          name: subscriptionId
          required: true
          type: string
          x-ms-parameter-location: client
        - 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
        - $ref: "#/parameters/ServerNameParameter"
        - $ref: "#/parameters/DatabaseNameParameter"
        - $ref: "#/parameters/DataMaskingPolicyNameParameter"
      responses:
        "200":
          description: OK
          schema:
            $ref: "#/definitions/DataMaskingPolicy"
      tags:
        - DataMaskingPolicies
      x-ms-examples:
        Get data masking policy:
          parameters:
            api-version: 2014-04-01
            dataMaskingPolicyName: Default
            databaseName: sqlcrudtest-331
            resourceGroupName: sqlcrudtest-6852
            serverName: sqlcrudtest-2080
            subscriptionId: 00000000-1111-2222-3333-444444444444
          responses:
            "200":
              body:
                id: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/sqlcrudtest-6852/providers/Microsoft.Sql/servers/sqlcrudtest-2080/databases/sqlcrudtest-331/dataMaskingPolicies/Default
                kind: null
                location: Central US
                name: Default
                properties:
                  applicationPrincipals: ""
                  dataMaskingState: Enabled
                  exemptPrincipals: ""
                  maskingLevel: ""
                type: Microsoft.Sql/servers/databases/dataMaskingPolicies
    put:
      description: Creates or updates a database data masking policy
      operationId: DataMaskingPolicies_CreateOrUpdate
      parameters:
        - description: The API version to use for the request.
          in: query
          name: api-version
          required: true
          type: string
          x-ms-parameter-location: client
        - description: The subscription ID that identifies an Azure subscription.
          in: path
          name: subscriptionId
          required: true
          type: string
          x-ms-parameter-location: client
        - 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
        - $ref: "#/parameters/ServerNameParameter"
        - $ref: "#/parameters/DatabaseNameParameter"
        - $ref: "#/parameters/DataMaskingPolicyNameParameter"
        - description: Parameters for creating or updating a data masking policy.
          in: body
          name: parameters
          required: true
          schema:
            $ref: "#/definitions/DataMaskingPolicy"
      responses:
        "200":
          description: OK
          schema:
            $ref: "#/definitions/DataMaskingPolicy"
      tags:
        - DataMaskingPolicies
      x-ms-examples:
        Create or update data masking policy max:
          parameters:
            api-version: 2014-04-01
            dataMaskingPolicyName: Default
            databaseName: sqlcrudtest-331
            parameters:
              properties:
                dataMaskingState: Enabled
                exemptPrincipals: testuser;
            resourceGroupName: sqlcrudtest-6852
            serverName: sqlcrudtest-2080
            subscriptionId: 00000000-1111-2222-3333-444444444444
          responses:
            "200":
              body:
                id: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/sqlcrudtest-6852/providers/Microsoft.Sql/servers/sqlcrudtest-2080/databases/sqlcrudtest-331/dataMaskingPolicies/Default
                kind: null
                location: Central US
                name: Default
                properties:
                  applicationPrincipals: ""
                  dataMaskingState: Enabled
                  exemptPrincipals: testuser;
                  maskingLevel: ""
                type: Microsoft.Sql/servers/databases/dataMaskingPolicies
        Create or update data masking policy min:
          parameters:
            api-version: 2014-04-01
            dataMaskingPolicyName: Default
            databaseName: sqlcrudtest-331
            parameters:
              properties:
                dataMaskingState: Enabled
            resourceGroupName: sqlcrudtest-6852
            serverName: sqlcrudtest-2080
            subscriptionId: 00000000-1111-2222-3333-444444444444
          responses:
            "200":
              body:
                id: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/sqlcrudtest-6852/providers/Microsoft.Sql/servers/sqlcrudtest-2080/databases/sqlcrudtest-331/dataMaskingPolicies/Default
                kind: null
                location: Central US
                name: Default
                properties:
                  applicationPrincipals: ""
                  dataMaskingState: Enabled
                  exemptPrincipals: ""
                  maskingLevel: ""
                type: Microsoft.Sql/servers/databases/dataMaskingPolicies
  "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataMaskingPolicies/{dataMaskingPolicyName}/rules":
    get:
      description: Gets a list of database data masking rules.
      operationId: DataMaskingRules_ListByDatabase
      parameters:
        - description: The API version to use for the request.
          in: query
          name: api-version
          required: true
          type: string
          x-ms-parameter-location: client
        - description: The subscription ID that identifies an Azure subscription.
          in: path
          name: subscriptionId
          required: true
          type: string
          x-ms-parameter-location: client
        - 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
        - $ref: "#/parameters/ServerNameParameter"
        - $ref: "#/parameters/DatabaseNameParameter"
        - $ref: "#/parameters/DataMaskingPolicyNameParameter"
      responses:
        "200":
          description: OK
          schema:
            $ref: "#/definitions/DataMaskingRuleListResult"
      tags:
        - DataMaskingRules
      x-ms-examples:
        List data masking rules:
          parameters:
            api-version: 2014-04-01
            dataMaskingPolicyName: Default
            databaseName: sqlcrudtest-331
            resourceGroupName: sqlcrudtest-6852
            serverName: sqlcrudtest-2080
            subscriptionId: 00000000-1111-2222-3333-444444444444
          responses:
            "200":
              body:
                value:
                  - id: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/sqlcrudtest-6852/providers/Microsoft.Sql/servers/sqlcrudtest-6852/databases/sqlcrudtest-331/dataMaskingPolicies/Default/rules/
                    kind: null
                    location: Central US
                    name: null
                    properties:
                      aliasName: null
                      columnName: test1
                      id: dbo_Table_1_test1
                      maskingFunction: Text
                      numberFrom: null
                      numberTo: null
                      prefixSize: "1"
                      replacementString: asdf
                      ruleState: Enabled
                      schemaName: dbo
                      suffixSize: "0"
                      tableName: Table_1
                    type: Microsoft.Sql/servers/databases/dataMaskingPolicies/rules
                  - id: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/sqlcrudtest-6852/providers/Microsoft.Sql/servers/sqlcrudtest-6852/databases/sqlcrudtest-331/dataMaskingPolicies/Default/rules/
                    kind: null
                    location: Central US
                    name: null
                    properties:
                      aliasName: null
                      columnName: test1
                      id: dbo_Table_1_test1
                      maskingFunction: Number
                      numberFrom: "0"
                      numberTo: "2"
                      prefixSize: null
                      replacementString: null
                      ruleState: Enabled
                      schemaName: dbo
                      suffixSize: null
                      tableName: Table_1
                    type: Microsoft.Sql/servers/databases/dataMaskingPolicies/rules
      x-ms-pageable:
        nextLinkName: null
  "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/dataMaskingPolicies/{dataMaskingPolicyName}/rules/{dataMaskingRuleName}":
    put:
      description: Creates or updates a database data masking rule.
      operationId: DataMaskingRules_CreateOrUpdate
      parameters:
        - description: The API version to use for the request.
          in: query
          name: api-version
          required: true
          type: string
          x-ms-parameter-location: client
        - description: The subscription ID that identifies an Azure subscription.
          in: path
          name: subscriptionId
          required: true
          type: string
          x-ms-parameter-location: client
        - 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
        - $ref: "#/parameters/ServerNameParameter"
        - $ref: "#/parameters/DatabaseNameParameter"
        - $ref: "#/parameters/DataMaskingPolicyNameParameter"
        - description: The name of the data masking rule.
          in: path
          name: dataMaskingRuleName
          required: true
          type: string
        - description: The required parameters for creating or updating a data masking rule.
          in: body
          name: parameters
          required: true
          schema:
            $ref: "#/definitions/DataMaskingRule"
      responses:
        "200":
          description: OK
          schema:
            $ref: "#/definitions/DataMaskingRule"
        "201":
          description: Created
          schema:
            $ref: "#/definitions/DataMaskingRule"
      tags:
        - DataMaskingRules
      x-ms-examples:
        Create/Update data masking rule for default max:
          parameters:
            api-version: 2014-04-01
            dataMaskingPolicyName: Default
            dataMaskingRuleName: rule1
            databaseName: sqlcrudtest-331
            parameters:
              properties:
                aliasName: nickname
                columnName: test1
                maskingFunction: Default
                ruleState: Enabled
                schemaName: dbo
                tableName: Table_1
            resourceGroupName: sqlcrudtest-6852
            serverName: sqlcrudtest-2080
            subscriptionId: 00000000-1111-2222-3333-444444444444
          responses:
            "200":
              body:
                id: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/sqlcrudtest-6852/providers/Microsoft.Sql/servers/sqlcrudtest-6852/databases/sqlcrudtest-331/dataMaskingPolicies/Default/rules/
                kind: null
                location: Central US
                name: null
                properties:
                  aliasName: nickname
                  columnName: test1
                  id: dbo_Table_1_test1
                  maskingFunction: Default
                  numberFrom: null
                  numberTo: null
                  prefixSize: null
                  replacementString: null
                  ruleState: Enabled
                  schemaName: dbo
                  suffixSize: null
                  tableName: Table_1
                type: Microsoft.Sql/servers/databases/dataMaskingPolicies/rules
            "201":
              body:
                id: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/sqlcrudtest-6852/providers/Microsoft.Sql/servers/sqlcrudtest-6852/databases/sqlcrudtest-331/dataMaskingPolicies/Default/rules/
                kind: null
                location: Central US
                name: null
                properties:
                  aliasName: nickname
                  columnName: test1
                  id: dbo_Table_1_test1
                  maskingFunction: Default
                  numberFrom: null
                  numberTo: null
                  prefixSize: null
                  replacementString: null
                  ruleState: Enabled
                  schemaName: dbo
                  suffixSize: null
                  tableName: Table_1
                type: Microsoft.Sql/servers/databases/dataMaskingPolicies/rules
        Create/Update data masking rule for default min:
          parameters:
            api-version: 2014-04-01
            dataMaskingPolicyName: Default
            dataMaskingRuleName: rule1
            databaseName: sqlcrudtest-331
            parameters:
              properties:
                columnName: test1
                maskingFunction: Default
                schemaName: dbo
                tableName: Table_1
            resourceGroupName: sqlcrudtest-6852
            serverName: sqlcrudtest-2080
            subscriptionId: 00000000-1111-2222-3333-444444444444
          responses:
            "200":
              body:
                id: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/sqlcrudtest-6852/providers/Microsoft.Sql/servers/sqlcrudtest-6852/databases/sqlcrudtest-331/dataMaskingPolicies/Default/rules/
                kind: null
                location: Central US
                name: null
                properties:
                  aliasName: null
                  columnName: test1
                  id: dbo_Table_1_test1
                  maskingFunction: Default
                  numberFrom: null
                  numberTo: null
                  prefixSize: null
                  replacementString: null
                  ruleState: Enabled
                  schemaName: dbo
                  suffixSize: null
                  tableName: Table_1
                type: Microsoft.Sql/servers/databases/dataMaskingPolicies/rules
            "201":
              body:
                id: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/sqlcrudtest-6852/providers/Microsoft.Sql/servers/sqlcrudtest-6852/databases/sqlcrudtest-331/dataMaskingPolicies/Default/rules/
                kind: null
                location: Central US
                name: null
                properties:
                  aliasName: null
                  columnName: test1
                  id: dbo_Table_1_test1
                  maskingFunction: Default
                  numberFrom: null
                  numberTo: null
                  prefixSize: null
                  replacementString: null
                  ruleState: Enabled
                  schemaName: dbo
                  suffixSize: null
                  tableName: Table_1
                type: Microsoft.Sql/servers/databases/dataMaskingPolicies/rules
        Create/Update data masking rule for numbers:
          parameters:
            api-version: 2014-04-01
            dataMaskingPolicyName: Default
            dataMaskingRuleName: rule1
            databaseName: sqlcrudtest-331
            parameters:
              properties:
                columnName: test1
                maskingFunction: Number
                numberFrom: "0"
                numberTo: "2"
                schemaName: dbo
                tableName: Table_1
            resourceGroupName: sqlcrudtest-6852
            serverName: sqlcrudtest-2080
            subscriptionId: 00000000-1111-2222-3333-444444444444
          responses:
            "200":
              body:
                id: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/sqlcrudtest-6852/providers/Microsoft.Sql/servers/sqlcrudtest-6852/databases/sqlcrudtest-331/dataMaskingPolicies/Default/rules/
                kind: null
                location: Central US
                name: null
                properties:
                  aliasName: null
                  columnName: test1
                  id: dbo_Table_1_test1
                  maskingFunction: Number
                  numberFrom: "0"
                  numberTo: "2"
                  prefixSize: null
                  replacementString: null
                  ruleState: Enabled
                  schemaName: dbo
                  suffixSize: null
                  tableName: Table_1
                type: Microsoft.Sql/servers/databases/dataMaskingPolicies/rules
            "201":
              body:
                id: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/sqlcrudtest-6852/providers/Microsoft.Sql/servers/sqlcrudtest-6852/databases/sqlcrudtest-331/dataMaskingPolicies/Default/rules/
                kind: null
                location: Central US
                name: null
                properties:
                  aliasName: null
                  columnName: test1
                  id: dbo_Table_1_test1
                  maskingFunction: Number
                  numberFrom: "0"
                  numberTo: "2"
                  prefixSize: null
                  replacementString: null
                  ruleState: Enabled
                  schemaName: dbo
                  suffixSize: null
                  tableName: Table_1
                type: Microsoft.Sql/servers/databases/dataMaskingPolicies/rules
        Create/Update data masking rule for text:
          parameters:
            api-version: 2014-04-01
            dataMaskingPolicyName: Default
            dataMaskingRuleName: rule1
            databaseName: sqlcrudtest-331
            parameters:
              properties:
                columnName: test1
                maskingFunction: Text
                prefixSize: "1"
                replacementString: asdf
                schemaName: dbo
                suffixSize: "0"
                tableName: Table_1
            resourceGroupName: sqlcrudtest-6852
            serverName: sqlcrudtest-2080
            subscriptionId: 00000000-1111-2222-3333-444444444444
          responses:
            "200":
              body:
                id: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/sqlcrudtest-6852/providers/Microsoft.Sql/servers/sqlcrudtest-6852/databases/sqlcrudtest-331/dataMaskingPolicies/Default/rules/
                kind: null
                location: Central US
                name: null
                properties:
                  aliasName: null
                  columnName: test1
                  id: dbo_Table_1_test1
                  maskingFunction: Text
                  numberFrom: null
                  numberTo: null
                  prefixSize: "1"
                  replacementString: asdf
                  ruleState: Enabled
                  schemaName: dbo
                  suffixSize: "0"
                  tableName: Table_1
                type: Microsoft.Sql/servers/databases/dataMaskingPolicies/rules
            "201":
              body:
                id: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/sqlcrudtest-6852/providers/Microsoft.Sql/servers/sqlcrudtest-6852/databases/sqlcrudtest-331/dataMaskingPolicies/Default/rules/
                kind: null
                location: Central US
                name: null
                properties:
                  aliasName: null
                  columnName: test1
                  id: dbo_Table_1_test1
                  maskingFunction: Text
                  numberFrom: null
                  numberTo: null
                  prefixSize: "1"
                  replacementString: asdf
                  ruleState: Enabled
                  schemaName: dbo
                  suffixSize: "0"
                  tableName: Table_1
                type: Microsoft.Sql/servers/databases/dataMaskingPolicies/rules
definitions:
  DataMaskingPolicy:
    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: Represents a database data masking policy.
    properties:
      kind:
        description: The kind of data masking policy. Metadata, used for Azure portal.
        readOnly: true
        type: string
      location:
        description: The location of the data masking policy.
        readOnly: true
        type: string
      properties:
        $ref: "#/definitions/DataMaskingPolicyProperties"
        description: The properties of the data masking policy.
        x-ms-client-flatten: true
  DataMaskingPolicyProperties:
    description: The properties of a database data masking policy.
    properties:
      applicationPrincipals:
        description: The list of the application principals. This is a legacy parameter and is no longer used.
        readOnly: true
        type: string
      dataMaskingState:
        description: The state of the data masking policy.
        enum:
          - Disabled
          - Enabled
        type: string
        x-ms-enum:
          modelAsString: false
          name: DataMaskingState
      exemptPrincipals:
        description: The list of the exempt principals. Specifies the semicolon-separated list of database users for which the data masking policy does not apply. The specified users receive data results without masking for all of the database queries.
        type: string
      maskingLevel:
        description: The masking level. This is a legacy parameter and is no longer used.
        readOnly: true
        type: string
    required:
      - dataMaskingState
  DataMaskingRule:
    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: Represents a database data masking rule.
    properties:
      kind:
        description: The kind of Data Masking Rule. Metadata, used for Azure portal.
        readOnly: true
        type: string
      location:
        description: The location of the data masking rule.
        readOnly: true
        type: string
      properties:
        $ref: "#/definitions/DataMaskingRuleProperties"
        description: The properties of the resource.
        x-ms-client-flatten: true
  DataMaskingRuleListResult:
    description: The response to a list data masking rules request.
    properties:
      value:
        description: The list of database data masking rules.
        items:
          $ref: "#/definitions/DataMaskingRule"
        type: array
  DataMaskingRuleProperties:
    description: The properties of a database data masking rule.
    properties:
      aliasName:
        description: The alias name. This is a legacy parameter and is no longer used.
        type: string
      columnName:
        description: The column name on which the data masking rule is applied.
        type: string
      id:
        description: The rule Id.
        readOnly: true
        type: string
      maskingFunction:
        description: The masking function that is used for the data masking rule.
        enum:
          - Default
          - CCN
          - Email
          - Number
          - SSN
          - Text
        type: string
        x-ms-enum:
          modelAsString: false
          name: DataMaskingFunction
      numberFrom:
        description: The numberFrom property of the masking rule. Required if maskingFunction is set to Number, otherwise this parameter will be ignored.
        type: string
      numberTo:
        description: The numberTo property of the data masking rule. Required if maskingFunction is set to Number, otherwise this parameter will be ignored.
        type: string
      prefixSize:
        description: If maskingFunction is set to Text, the number of characters to show unmasked in the beginning of the string. Otherwise, this parameter will be ignored.
        type: string
      replacementString:
        description: If maskingFunction is set to Text, the character to use for masking the unexposed part of the string. Otherwise, this parameter will be ignored.
        type: string
      ruleState:
        description: The rule state. Used to delete a rule. To delete an existing rule, specify the schemaName, tableName, columnName, maskingFunction, and specify ruleState as disabled. However, if the rule doesn't already exist, the rule will be created with ruleState set to enabled, regardless of the provided value of ruleState.
        enum:
          - Disabled
          - Enabled
        type: string
        x-ms-enum:
          modelAsString: false
          name: DataMaskingRuleState
      schemaName:
        description: The schema name on which the data masking rule is applied.
        type: string
      suffixSize:
        description: If maskingFunction is set to Text, the number of characters to show unmasked at the end of the string. Otherwise, this parameter will be ignored.
        type: string
      tableName:
        description: The table name on which the data masking rule is applied.
        type: string
    required:
      - maskingFunction
      - schemaName
      - tableName
      - columnName
