Styra Compile API

The Compile API from Styra — 1 operation(s) for compile.

OpenAPI Specification

styra-compile-api-openapi.yml Raw ↑
openapi: 3.0.3
info:
  title: Enterprise OPA REST Batch Compile API
  version: 0.2.0
  contact:
    name: Styra
    url: https://github.com/StyraInc/enterprise-opa
servers:
- url: http://localhost:8181
  description: Local development server
security:
- {}
- bearerAuth: []
tags:
- name: Compile
paths:
  /v1/compile/{path}:
    post:
      parameters:
      - $ref: '#/components/parameters/policyPath'
      - $ref: '#/components/parameters/GzipAcceptEncoding'
      - $ref: '#/components/parameters/GzipContentEncoding'
      - $ref: '#/components/parameters/pretty'
      - $ref: '#/components/parameters/explain'
      - $ref: '#/components/parameters/metrics'
      - $ref: '#/components/parameters/instrument'
      summary: Partially evaluate a query
      operationId: compileQueryWithPartialEvaluation
      x-speakeasy-usage-example: false
      requestBody:
        description: The query, input, and other settings for partial evaluation.
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - query
              properties:
                options:
                  $ref: '#/components/schemas/CompileOptions'
                unknowns:
                  $ref: '#/components/schemas/CompileUnknowns'
                input:
                  $ref: '#/components/schemas/input'
                  description: The input document to use during partial evaluation.
          application/vnd.styra.multitarget+json:
            schema:
              type: object
              properties:
                options:
                  $ref: '#/components/schemas/CompileOptions'
                unknowns:
                  $ref: '#/components/schemas/CompileUnknowns'
                input:
                  $ref: '#/components/schemas/input'
                  description: The input document to use during partial evaluation.
          application/vnd.styra.ucast.all+json:
            schema:
              type: object
              properties:
                options:
                  $ref: '#/components/schemas/CompileOptions'
                unknowns:
                  $ref: '#/components/schemas/CompileUnknowns'
                input:
                  $ref: '#/components/schemas/input'
                  description: The input document to use during partial evaluation.
          application/vnd.styra.ucast.minimal+json:
            schema:
              type: object
              properties:
                options:
                  $ref: '#/components/schemas/CompileOptions'
                unknowns:
                  $ref: '#/components/schemas/CompileUnknowns'
                input:
                  $ref: '#/components/schemas/input'
                  description: The input document to use during partial evaluation.
          application/vnd.styra.ucast.linq+json:
            schema:
              type: object
              properties:
                options:
                  $ref: '#/components/schemas/CompileOptions'
                unknowns:
                  $ref: '#/components/schemas/CompileUnknowns'
                input:
                  $ref: '#/components/schemas/input'
                  description: The input document to use during partial evaluation.
          application/vnd.styra.ucast.prisma+json:
            schema:
              type: object
              properties:
                options:
                  $ref: '#/components/schemas/CompileOptions'
                unknowns:
                  $ref: '#/components/schemas/CompileUnknowns'
                input:
                  $ref: '#/components/schemas/input'
                  description: The input document to use during partial evaluation.
          application/vnd.styra.sql.sqlserver+json:
            schema:
              type: object
              properties:
                options:
                  $ref: '#/components/schemas/CompileOptions'
                unknowns:
                  $ref: '#/components/schemas/CompileUnknowns'
                input:
                  $ref: '#/components/schemas/input'
                  description: The input document to use during partial evaluation.
          application/vnd.styra.sql.mysql+json:
            schema:
              type: object
              properties:
                options:
                  $ref: '#/components/schemas/CompileOptions'
                unknowns:
                  $ref: '#/components/schemas/CompileUnknowns'
                input:
                  $ref: '#/components/schemas/input'
                  description: The input document to use during partial evaluation.
          application/vnd.styra.sql.postgresql+json:
            schema:
              type: object
              properties:
                options:
                  $ref: '#/components/schemas/CompileOptions'
                unknowns:
                  $ref: '#/components/schemas/CompileUnknowns'
                input:
                  $ref: '#/components/schemas/input'
                  description: The input document to use during partial evaluation.
          application/vnd.styra.sql.sqlite+json:
            schema:
              type: object
              properties:
                options:
                  $ref: '#/components/schemas/CompileOptions'
                unknowns:
                  $ref: '#/components/schemas/CompileUnknowns'
                input:
                  $ref: '#/components/schemas/input'
                  description: The input document to use during partial evaluation.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CompileResultJSON'
            application/vnd.styra.multitarget+json:
              schema:
                $ref: '#/components/schemas/CompileResultMultitarget'
            application/vnd.styra.ucast.all+json:
              schema:
                $ref: '#/components/schemas/CompileResultUCAST'
            application/vnd.styra.ucast.minimal+json:
              schema:
                $ref: '#/components/schemas/CompileResultUCAST'
            application/vnd.styra.ucast.linq+json:
              schema:
                $ref: '#/components/schemas/CompileResultUCAST'
            application/vnd.styra.ucast.prisma+json:
              schema:
                $ref: '#/components/schemas/CompileResultUCAST'
            application/vnd.styra.sql.sqlserver+json:
              schema:
                $ref: '#/components/schemas/CompileResultSQL'
            application/vnd.styra.sql.mysql+json:
              schema:
                $ref: '#/components/schemas/CompileResultSQL'
            application/vnd.styra.sql.postgresql+json:
              schema:
                $ref: '#/components/schemas/CompileResultSQL'
            application/vnd.styra.sql.sqlite+json:
              schema:
                $ref: '#/components/schemas/CompileResultSQL'
        '400':
          $ref: '#/components/responses/BadRequest'
        '500':
          $ref: '#/components/responses/ServerError'
      tags:
      - Compile
components:
  parameters:
    pretty:
      name: pretty
      description: If parameter is `true`, response will formatted for humans.
      in: query
      schema:
        type: boolean
    GzipContentEncoding:
      name: Content-Encoding
      description: Indicates that the request body is gzip encoded
      in: header
      schema:
        type: string
        enum:
        - gzip
    instrument:
      name: instrument
      description: Instrument query evaluation and return a superset of performance metrics in addition to result.
      in: query
      schema:
        type: boolean
    explain:
      name: explain
      description: Return query explanation in addition to result.
      in: query
      schema:
        type: string
        enum:
        - notes
        - fails
        - full
        - debug
    policyPath:
      name: path
      in: path
      description: The path separator is used to access values inside object and array documents. If the path indexes into an array, the server will attempt to convert the array index to an integer. If the path element cannot be converted to an integer, the server will respond with 404.
      required: true
      schema:
        type: string
        default: ''
        format: urlPath
        example: app/rbac
    GzipAcceptEncoding:
      name: Accept-Encoding
      description: Indicates the server should respond with a gzip encoded body. The server will send the compressed response only if its length is above `server.encoding.gzip.min_length` value. See the configuration section
      in: header
      schema:
        type: string
        enum:
        - gzip
    metrics:
      name: metrics
      description: Return query performance metrics in addition to result.
      in: query
      schema:
        type: boolean
  responses:
    BadRequest:
      description: Bad Request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ClientError'
    ServerError:
      description: Server Error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ServerError'
  schemas:
    CompileResultSQL:
      type: object
      description: The partially evaluated result of the query, in SQL format. Result will be empty if the query is never true.
      properties:
        result:
          type: object
          description: The partially evaluated result of the query as SQL.
          additionalProperties: true
          properties:
            query:
              type: string
              description: String representing the SQL equivalent of the conditions under which the query is true.
            masks:
              type: object
              description: Column masking functions, where the key is the column name, and the value describes which masking function to use.
              additionalProperties:
                $ref: '#/components/schemas/MaskingRule'
    CompileResultUCAST:
      type: object
      description: The partially evaluated result of the query, in UCAST format. Result will be empty if the query is never true.
      properties:
        result:
          type: object
          description: The partially evaluated result of the query as UCAST.
          additionalProperties: true
          properties:
            query:
              type: object
              description: UCAST JSON object describing the conditions under which the query is true.
              additionalProperties: true
            masks:
              type: object
              description: Column masking rules, where the key is the column name, and the value describes which masking function to use.
              additionalProperties:
                $ref: '#/components/schemas/MaskingRule'
    CompileUnknowns:
      type: array
      description: The terms to treat as unknown during partial evaluation.
      items:
        type: string
      default:
      - input
    ServerError:
      type: object
      required:
      - code
      - message
      properties:
        code:
          type: string
        message:
          type: string
        errors:
          type: array
          items:
            type: object
            required:
            - code
            - message
            properties:
              code:
                type: string
              message:
                type: string
              location:
                type: object
                required:
                - file
                - row
                - col
                properties:
                  file:
                    type: string
                  row:
                    type: integer
                  col:
                    type: integer
        decision_id:
          type: string
          example: b84cf736-213c-4932-a8e4-bb5c648f1b4d
    MaskingRule:
      type: object
      additionalProperties:
        oneOf:
        - properties:
            replace:
              oneOf:
              - type: boolean
              - type: string
              - type: number
              - type: array
                items: {}
              - type: object
                additionalProperties: true
    CompileOptions:
      type: object
      description: Additional options to use during partial evaluation. Only the disableInlining option is currently supported in OPA. Enterprise OPA may support additional options.
      additionalProperties: true
      properties:
        disableInlining:
          type: array
          description: A list of paths to exclude from partial evaluation inlining.
          items:
            type: string
        targetDialects:
          type: array
          description: The output targets for partial evaluation. Different targets will have different constraints.
          items:
            type: string
            enum:
            - ucast+all
            - ucast+minimal
            - ucast+prisma
            - ucast+linq
            - sql+sqlserver
            - sql+mysql
            - sql+postgresql
            - sql+sqlite
        targetSQLTableMappings:
          type: object
          properties:
            sqlserver:
              type: object
              additionalProperties: true
            mysql:
              type: object
              additionalProperties: true
            postgresql:
              type: object
              additionalProperties: true
            sqlite:
              type: object
              additionalProperties: true
        maskRule:
          type: string
          description: The Rego rule to evaluate for generating column masks.
    ClientError:
      type: object
      required:
      - code
      - message
      properties:
        code:
          type: string
        message:
          type: string
        errors:
          type: array
          items:
            type: object
            required:
            - code
            - message
            properties:
              code:
                type: string
              message:
                type: string
              location:
                type: object
                required:
                - file
                - row
                - col
                properties:
                  file:
                    type: string
                  row:
                    type: integer
                  col:
                    type: integer
    input:
      description: Arbitrary JSON used within your policies by accessing `input`
      oneOf:
      - type: boolean
      - type: string
      - type: number
      - type: array
        items: {}
      - type: object
        additionalProperties: true
        example:
          user: alice
          action: read
          object: id123
          type: dog
    CompileResultMultitarget:
      type: object
      description: The partially evaluated result of the query, for each target dialect. Result will be empty if the query is never true.
      properties:
        result:
          type: object
          description: The partially evaluated result of the query in each target dialect.
          additionalProperties: true
          properties:
            targets:
              type: object
              properties:
                ucast:
                  type: object
                  properties:
                    query:
                      type: object
                      description: UCAST JSON object describing the conditions under which the query is true.
                    masks:
                      type: object
                      description: Column masking rules, where the first two nested keys represent the entity name and the property name, and the value describes which masking function to use.
                      additionalProperties:
                        $ref: '#/components/schemas/MaskingRule'
                sqlserver:
                  type: object
                  properties:
                    query:
                      type: string
                      description: String representing the SQL equivalent of the conditions under which the query is true.
                    masks:
                      type: object
                      description: Column masking rules, where the first two nested keys represent the table name and the column name, and the value describes which masking function to use.
                      additionalProperties:
                        $ref: '#/components/schemas/MaskingRule'
                mysql:
                  type: object
                  properties:
                    query:
                      type: string
                      description: String representing the SQL equivalent of the conditions under which the query is true.
                    masks:
                      type: object
                      description: Column masking rules, where the first two nested keys represent the table name and the column name, and the value describes which masking function to use.
                      additionalProperties:
                        $ref: '#/components/schemas/MaskingRule'
                postgresql:
                  type: object
                  properties:
                    query:
                      type: string
                      description: String representing the SQL equivalent of the conditions under which the query is true
                    masks:
                      type: object
                      description: Column masking rules, where the first two nested keys represent the table name and the column name, and the value describes which masking function to use.
                      additionalProperties:
                        $ref: '#/components/schemas/MaskingRule'
                sqlite:
                  type: object
                  properties:
                    query:
                      type: string
                      description: String representing the SQL equivalent of the conditions under which the query is true
                    masks:
                      type: object
                      description: Column masking rules, where the first two nested keys represent the table name and the column name, and the value describes which masking function to use.
                      additionalProperties:
                        $ref: '#/components/schemas/MaskingRule'
    CompileResultJSON:
      type: object
      description: The partially evaluated result of the query. Result will be empty if the query is never true.
      properties:
        result:
          type: object
          description: The partially evaluated result of the query.
          additionalProperties: true
          properties:
            query:
              type: object
            support:
              type: object
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
externalDocs:
  description: Enterprise OPA documentation
  url: https://docs.styra.com/enterprise-opa
  x-openpolicyagent-documentation-url: https://www.openpolicyagent.org/docs/latest/