openapi: 3.0.0
info:
  license:
    name: MIT
    url: https://github.com/aziontech/azionapi-openapi/blob/main/LICENSE.md
  title: Edge Function API
  version: 2.0.0
servers:
- description: Production
  url: https://api.azionapi.net
security:
- tokenAuth: []
paths:
  /edge_functions:
    get:
      parameters:
      - explode: true
        in: query
        name: page
        required: false
        schema:
          format: int64
          type: integer
        style: form
      - explode: true
        in: query
        name: page_size
        required: false
        schema:
          format: int64
          type: integer
        style: form
      - explode: true
        in: query
        name: sort
        required: false
        schema:
          type: string
        style: form
      - explode: true
        in: query
        name: order_by
        required: false
        schema:
          type: string
        style: form
      responses:
        "200":
          content:
            application/json; version=3:
              example:
                count: 1
                total_pages: 1
                schema_version: 3
                links:
                  previous: previous
                  next: next
                results:
                - id: 4184
                  name: Teste
                  language: javascript
                  code: "async function handleRequest(request) {\r\n     return new\
                    \ Response(\"Hello World!\",\r\n       {\r\n           status:200\r\
                    \n       })\r\n    }\r\n    addEventListener(\"fetch\", event\
                    \ => {\r\n     event.respondWith(handleRequest(event.request))\r\
                    \n    })"
                  json_args: {}
                  function_to_run: ""
                  initiator_type: edge_application
                  active: true
                  last_editor: teste@gmail.com
                  modified: 2021-12-27T19:44:04.427738Z
                  reference_count: 0
              schema:
                $ref: '#/components/schemas/ListEdgeFunctionResponse'
          description: Success
        "404":
          content:
            application/json:
              example:
                detail: Sorry unable to perform operation.
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Not found
        default:
          content:
            application/json:
              example:
                detail: Sorry unable to perform operation.
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Unexpected error
      summary: edge_functions
      tags:
      - edge_functions
    post:
      parameters: []
      requestBody:
        $ref: '#/components/requestBodies/CreateEdgeFunctionRequest'
      responses:
        "201":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EdgeFunctionResponse'
          description: Success
        "400":
          content:
            application/json:
              example:
                name:
                - This field may not be blank
                active:
                - This field is required.
                code:
                - This field is required.
                language:
                - This field is required.
              schema:
                $ref: '#/components/schemas/BadRequestResponse'
          description: Invalid request
        default:
          content:
            application/json:
              example:
                message: Sorry unable to perform operation.
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Unexpected error
      summary: edge_functions
      tags:
      - edge_functions
  /edge_functions/{id}:
    delete:
      parameters:
      - explode: false
        in: path
        name: id
        required: true
        schema:
          format: int64
          type: integer
        style: simple
      responses:
        "204":
          description: Success
        default:
          content:
            application/json:
              example:
                message: Sorry unable to perform operation.
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Unexpected error
      summary: edge_functions
      tags:
      - edge_functions
    get:
      parameters:
      - explode: false
        in: path
        name: id
        required: true
        schema:
          format: int64
          type: integer
        style: simple
      responses:
        "200":
          content:
            application/json:
              example:
                results:
                  id: 4184
                  name: Teste
                  language: javascript
                  code: "async function handleRequest(request) {\r\n     return new\
                    \ Response(\"Hello World!\",\r\n       {\r\n           status:200\r\
                    \n       })\r\n    }\r\n    addEventListener(\"fetch\", event\
                    \ => {\r\n     event.respondWith(handleRequest(event.request))\r\
                    \n    })"
                  json_args: {}
                  function_to_run: ""
                  initiator_type: edge_application
                  active: true
                  last_editor: lehdermann@gmail.com
                  modified: 2021-12-27T20:49:25.373356Z
                  reference_count: 0
                schema_version: 3
              schema:
                $ref: '#/components/schemas/EdgeFunctionResponse'
          description: Success
        "404":
          content:
            application/json:
              example:
                detail: Sorry unable to perform operation.
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Not found
        default:
          content:
            application/json:
              example:
                message: Sorry unable to perform operation.
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Unexpected error
      summary: edge_functions
      tags:
      - edge_functions
    patch:
      parameters:
      - explode: false
        in: path
        name: id
        required: true
        schema:
          format: int64
          type: integer
        style: simple
      requestBody:
        $ref: '#/components/requestBodies/PatchEdgeFunctionRequest'
      responses:
        "200":
          content:
            application/json:
              example:
                results:
                  id: 4184
                  name: Teste
                  language: javascript
                  code: "async function handleRequest(request) {\r\n     return new\
                    \ Response(\"Hello World!\",\r\n       {\r\n           status:200\r\
                    \n       })\r\n    }\r\n    addEventListener(\"fetch\", event\
                    \ => {\r\n     event.respondWith(handleRequest(event.request))\r\
                    \n    })"
                  json_args: {}
                  function_to_run: ""
                  initiator_type: edge_application
                  active: true
                  last_editor: lehdermann@gmail.com
                  modified: 2021-12-27T20:49:25.373356Z
                  reference_count: 0
                schema_version: 3
              schema:
                $ref: '#/components/schemas/EdgeFunctionResponse'
          description: Success
        "400":
          content:
            application/json:
              example:
                name:
                - This field may not be blank
                active:
                - This field is required.
                code:
                - This field is required.
                language:
                - This field is required.
              schema:
                $ref: '#/components/schemas/BadRequestResponse'
          description: Invalid request
        default:
          content:
            application/json:
              example:
                message: Sorry unable to perform operation.
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Unexpected error
      summary: edge_functions
      tags:
      - edge_functions
    put:
      parameters:
      - explode: false
        in: path
        name: id
        required: true
        schema:
          format: int64
          type: integer
        style: simple
      requestBody:
        $ref: '#/components/requestBodies/PutEdgeFunctionRequest'
      responses:
        "200":
          content:
            application/json:
              example:
                results:
                  id: 4184
                  name: Teste
                  language: javascript
                  code: "async function handleRequest(request) {\r\n     return new\
                    \ Response(\"Hello World!\",\r\n       {\r\n           status:200\r\
                    \n       })\r\n    }\r\n    addEventListener(\"fetch\", event\
                    \ => {\r\n     event.respondWith(handleRequest(event.request))\r\
                    \n    })"
                  json_args: {}
                  function_to_run: ""
                  initiator_type: edge_application
                  active: true
                  last_editor: lehdermann@gmail.com
                  modified: 2021-12-27T20:49:25.373356Z
                  reference_count: 0
                schema_version: 3
              schema:
                $ref: '#/components/schemas/EdgeFunctionResponse'
          description: Success
        "400":
          content:
            application/json:
              example:
                name:
                - This field may not be blank
                active:
                - This field is required.
                code:
                - This field is required.
                language:
                - This field is required.
              schema:
                $ref: '#/components/schemas/BadRequestResponse'
          description: Invalid request
        default:
          content:
            application/json:
              example:
                message: Sorry unable to perform operation.
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Unexpected error
      summary: edge_functions
      tags:
      - edge_functions
components:
  requestBodies:
    PutEdgeFunctionRequest:
      content:
        application/json; version=3:
          schema:
            $ref: '#/components/schemas/PutEdgeFunctionRequest'
      required: true
    PatchEdgeFunctionRequest:
      content:
        application/json; version=3:
          schema:
            $ref: '#/components/schemas/PatchEdgeFunctionRequest'
      required: true
    CreateEdgeFunctionRequest:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/CreateEdgeFunctionRequest'
      required: true
  schemas:
    ErrorResponse:
      example:
        detail: detail
      properties:
        detail:
          type: string
      type: object
    Links:
      example:
        next: next
        previous: previous
      properties:
        previous:
          nullable: true
          type: string
        next:
          nullable: true
          type: string
      type: object
    Results:
      example:
        code: "function foo() { console.log('hello world');"
        last_editor: user@azion.com
        name: MyFunction
        active: true
        modified: modified
        language: javascript
        json_args: "{\"a\": 1, \"b\": 2}"
        id: 5
        function_to_run: function_to_run
        reference_count: 5
        initiator_type: edge_application
      properties:
        id:
          format: int64
          type: integer
        name:
          type: string
        language:
          type: string
        code:
          type: string
        json_args: {}
        function_to_run:
          type: string
        initiator_type:
          type: string
        active:
          type: boolean
        last_editor:
          type: string
        modified:
          type: string
        reference_count:
          format: int64
          type: integer
        is_proprietary_code:
          type: boolean
      type: object
    ListEdgeFunctionResponse:
      example:
        schema_version: 1
        count: 1
        links:
          next: next
          previous: previous
        total_pages: 6
        results:
        - code: code
          last_editor: last_editor
          name: name
          active: true
          modified: modified
          language: language
          json_args: "{}"
          id: 5
          function_to_run: function_to_run
          reference_count: 5
          initiator_type: initiator_type
        - code: code
          last_editor: last_editor
          name: name
          active: true
          modified: modified
          language: language
          json_args: "{}"
          id: 5
          function_to_run: function_to_run
          reference_count: 5
          initiator_type: initiator_type
      properties:
        count:
          format: int64
          type: integer
        total_pages:
          format: int64
          type: integer
        schema_version:
          format: int64
          type: integer
        links:
          $ref: '#/components/schemas/Links'
        results:
          items:
            $ref: '#/components/schemas/Results'
          type: array
      type: object
    CreateEdgeFunctionRequest:
      example:
        code: code
        name: name
        active: true
        language: language
        json_args: ""
        initiator_type: edge_application
      properties:
        name:
          type: string
        language:
          type: string
        code:
          type: string
        json_args: {}
        initiator_type:
          enum:
          - edge_application
          - edge_firewall
          type: string
        active:
          type: boolean
        is_proprietary_code:
          type: boolean
      type: object
    BadRequestResponse:
      example:
        code:
        - code
        - code
        name:
        - name
        - name
        active:
        - active
        - active
        language:
        - language
        - language
      properties:
        name:
          items:
            type: string
          type: array
        active:
          items:
            type: string
          type: array
        code:
          items:
            type: string
          type: array
        language:
          items:
            type: string
          type: array
      type: object
    EdgeFunctionResponse:
      example:
        schema_version: 1
        results:
          code: code
          last_editor: last_editor
          name: name
          active: true
          modified: modified
          language: language
          json_args: "{}"
          id: 5
          function_to_run: function_to_run
          reference_count: 5
          initiator_type: initiator_type
      properties:
        results:
          $ref: '#/components/schemas/Results'
        schema_version:
          type: number
      type: object
    PutEdgeFunctionRequest:
      example:
        code: code
        name: name
        active: true
        json_args: ""
        language: language
        initiator_type: edge_application
      properties:
        name:
          type: string
        code:
          type: string
        json_args: {}
        active:
          type: boolean
        initiator_type:
          enum:
          - edge_application
          - edge_firewall
          type: string
        language:
          type: string
        is_proprietary_code:
          type: boolean
      type: object
    PatchEdgeFunctionRequest:
      example:
        code: code
        name: name
        active: true
        json_args: ""
      properties:
        name:
          type: string
        code:
          type: string
        json_args: {}
        active:
          type: boolean
        is_proprietary_code:
          type: boolean
      type: object
  securitySchemes:
    tokenAuth:
      description: |-
        You must inform a token to auth.
        Usage format: `Token <TOKEN>`
      in: header
      name: Authorization
      type: apiKey
