---
openapi: 3.0.0
info:
  title: Stream_connection
  version: '2.0'
servers:
- url: https://wappsto.com/services/2.0
  description: Server to connect to the API
components:
  schemas:
    Deletelist:
      title: Deletelist
      type: object
      properties:
        deleted:
          type: array
          items:
            type: string
          description: List of deleted objects
        child_deleted:
          type: array
          items:
            type: string
          description: List of deleted children object related to the chosen objects
            to delete
        shared_deleted:
          type: array
          items:
            type: string
          description: List of removed objects previosly shared and accepted by the
            user
        shared_child_deleted:
          type: array
          items:
            type: string
          description: List of removed children objects previosly shared and accepted
            by the user related to the chosen objects to delete
        not_deleted:
          type: array
          items:
            type: string
          description: List of not deleted objects
        child_not_deleted:
          type: array
          items:
            type: string
          description: List of not deleted children object related to the chosen objects
            to delete
        shared_not_deleted:
          type: array
          items:
            type: string
          description: List of not removed objects previosly shared and accepted by
            the user
        shared_child_not_deleted:
          type: array
          items:
            type: string
          description: List of not removed children objects previosly shared and accepted
            by the user related to the chosen objects to delete
        pending:
          type: array
          items:
            type: string
          description: List of objects that will be deleted eventually
        child_pending:
          type: array
          items:
            type: string
          description: List of children objects that will be deleted eventually
        owned_not_deleted_because_it_has_parent:
          type: array
          items:
            type: string
          description: List of owned object not deleted since they have a parent
        shared_not_deleted_because_it_has_parent:
          type: array
          items:
            type: string
          description: List of shared object not deleted since they have a parent
        code:
          type: integer
          description: Code of the deletion
        message:
          type: string
          description: Final status of the deletion
        error:
          type: string
          description: Possible incurred errors
        meta:
          type: object
          description: Meta data of the object
        unsuccessful:
          type: array
          items:
            type: object
            properties:
              id:
                type: string
              message:
                type: string
              data:
                type: object
          description: An array that includes a more deep description about the reason
            of unsuccessful deletions
      additionalProperties: false
      description: Output obtained when one or multiple objects are deleted with a
        DELETE request
    Httpresponse:
      title: Httpresponse
      type: object
      properties:
        message:
          type: string
          description: Message of the error
        data:
          type: object
          description: More information about the error
        code:
          type: integer
          description: Identifier code of the error
        service:
          type: string
          description: Service that sent the error
        meta:
          type: object
          description: Meta data of the object
      additionalProperties: false
      description: Output obtain when a fast communication is returned (usually an
        error)
    Idlist:
      title: Idlist
      type: object
      properties:
        id:
          items:
            type: string
            pattern: "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"
          type: array
          description: Ids found
        more:
          type: boolean
          description: If true, it means that using offset it is possible to retrieve
            other values
        limit:
          type: integer
          multipleOf: 1
          minimum: 1
          description: Limit used to retrieve the ids
        count:
          type: integer
          multipleOf: 1
          minimum: 0
          description: Number of ids returned
        data:
          type: object
          description: Further information in relation of the service
        child:
          type: array
          items:
            type: object
            properties:
              type:
                type: string
              version:
                type: string
                pattern: "(\\d+)\\.(\\d+)"
          description: It is an array that gives a brief description of the type and
            the version of the retrieved objects
        meta:
          type: object
      additionalProperties: false
      description: Output obtain when a list is returned
    Fetch:
      title: Fetch
      type: object
      properties:
        filter:
          type: object
        return:
          type: string
          description: A graphQL string that describes the format it needs to be returned
        table:
          type: boolean
          description: If true, use iot table to fetch the data
        data:
          type: object
          description: The output obtained after filtering and parsing the results
            with the GraphQL request
        meta:
          type: object
          description: Meta data of the object
      additionalProperties: false
      description: Output obtained when the input is a fetch request
    Extsync:
      title: Extsync
      type: object
      properties:
        meta:
          type: object
          description: Meta data of the object
      additionalProperties: true
      description: Service to send direct stream to a selected installation
    Stream:
      title: Stream
      type: object
      properties:
        name:
          type: string
          description: Name of the stream
        subscription:
          items:
            type: string
          type: array
          minItems: 1
          description: Subscription made by the stream
          example:
          - "/2.0/network"
        ignore:
          items:
            type: string
          type: array
          description: List of stream that should be ignored
          example:
          - "/2.0/value"
        full:
          type: boolean
          description: If full is true (default), a subscription that regards object
            with children will returns the stream concerning its children too
          example: true
        meta:
          type: object
          description: Meta data of the object
          example:
            id: 7e538256-e591-4848-8461-df6ac7806de6
            type: stream
            version: '2.0'
      required:
      - subscription
      additionalProperties: false
      description: A Stream is used to create a continue connection between the user
        and the API. The connection can be estabilished with a websocket or eventstream.
    Stream_internal:
      title: Stream_internal
      type: object
      properties:
        name:
          type: string
          description: Name of the stream internal
        object:
          type: array
          items:
            type: string
            pattern: "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"
          description: A series of ids where the stream needs to be prompted
          example:
          - 56d9e720-5833-4622-9fc2-5886f1346c08
          - eb1e2553-2d44-4600-9ad1-ea66d8b9f893
          - 20ea466e-761a-49e8-906c-7631bb141dec
          - d4fb9e65-e927-4a2f-aed2-539db8324869
        service:
          type: string
          enum:
          - azure_service_bus
          - mqtt
          - test_service
          description: Which stream needs to be called when any modification happens
            to the objects
          example: azure_service_bus
        data:
          type: object
          description: Data used for sending the data with the external service
          example:
            name: test
        secure:
          type: object
          description: Like data, but these attributes are encrypted and not returned
            to the user
        full:
          type: boolean
          description: If true (default), then also the children stream will be sent
          example: true
        status:
          type: object
          properties:
            connection_established:
              type: boolean
            timestamp:
              type: string
            message:
              type: string
            code:
              type: integer
            data:
              type: object
          description: Hash that describes the status of the stream internal
          example:
            connection_estabilished: false
            timestamp: '2021-03-23T11:45:53.027031Z'
            message: No message sent to endpoint
            code: 10004
        meta:
          type: object
          description: Meta data of the object
          example:
            id: 336a1ff0-05cb-4a25-b493-f3d617650528
            type: stream_internal
            version: '2.0'
      required:
      - service
      - object
      additionalProperties: false
      description: Service used to handle streaming between internal and external
        services
  parameters:
    url_id:
      name: :id
      in: path
      required: true
      description: Id of the given object
      schema:
        type: string
        pattern: "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"
    url_hex:
      name: :token
      in: path
      required: true
      description: Token used for some operation
      schema:
        type: string
        pattern: "^[0-9a-fA-F]{64}$"
tags:
- name: Stream
  description: A Stream is used to create a continue connection between the user and
    the API. The connection can be estabilished with a websocket or eventstream.
- name: Extsync
  description: Service to send direct stream to a selected installation
- name: Stream_internal
  description: Service used to handle streaming between internal and external services
paths:
  "/extsync/test":
    patch:
      tags:
      - Extsync
      summary: Basic extsync
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              "$ref": "#/components/schemas/Extsync"
            example:
              test:
              - 1
              - 2
              - 3
      responses:
        '200':
          description: Extsync successfully sent
  "/extsync/response/:id":
    patch:
      tags:
      - Extsync
      summary: Response extsync
      parameters:
      - "$ref": "#/components/parameters/url_id"
      requestBody:
        content:
          application/json:
            schema:
              "$ref": "#/components/schemas/Extsync"
            example:
              code: 200
              body: OK
              headers:
                test: ok
      responses:
        '200':
          description: Extsync successfully sent
  "/extsync/request/test":
    patch:
      tags:
      - Extsync
      summary: Request extsync
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              "$ref": "#/components/schemas/Extsync"
            example:
              test:
              - 1
              - 2
              - 3
      responses:
        '200':
          description: OK
  "/stream":
    post:
      tags:
      - Stream
      summary: Fetch request of stream
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              "$ref": "#/components/schemas/Stream"
            example:
              filter:
                id:
                - 7e538256-e591-4848-8461-df6ac7806de6
                - 902bf3c7-afca-4a5b-ad3f-eaf97ce91304
              return: "{ stream {meta {id}}}"
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/Fetch"
              example:
                meta:
                  type: fetch
                  version: '2.0'
                data:
                  stream:
                  - meta:
                      id: 7e538256-e591-4848-8461-df6ac7806de6
                  - meta:
                      id: 902bf3c7-afca-4a5b-ad3f-eaf97ce91304
    get:
      tags:
      - Stream
      summary: Retrieve list of stream
      parameters: []
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/Idlist"
              example:
                child:
                - type: stream
                  version: '2.0'
                id:
                - 7e538256-e591-4848-8461-df6ac7806de6
                - 902bf3c7-afca-4a5b-ad3f-eaf97ce91304
                - 49914663-9435-4c92-927c-18254c0a5619
                - 149ae042-746d-4db4-ab94-4373d32a63ec
                more: false
                limit: 1000
                count: 4
                meta:
                  type: idlist
                  version: '2.0'
    head:
      tags:
      - Stream
      summary: Check if list of stream is retrievable
      parameters: []
      responses:
        '200':
          description: OK
    patch:
      tags:
      - Stream
      summary: Update multiple streams
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              "$ref": "#/components/schemas/Stream"
            example:
              full: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/Stream"
              example:
              - subscription:
                - "/2.0/network"
                ignore:
                - "/2.0/value"
                full: true
                meta:
                  id: 7e538256-e591-4848-8461-df6ac7806de6
                  type: stream
                  version: '2.0'
              - subscription:
                - "/2.0/device"
                ignore: []
                full: true
                meta:
                  id: 902bf3c7-afca-4a5b-ad3f-eaf97ce91304
                  type: stream
                  version: '2.0'
    delete:
      tags:
      - Stream
      summary: Delete all stream
      parameters: []
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/Deletelist"
              example:
                deleted:
                - 902bf3c7-afca-4a5b-ad3f-eaf97ce91304
                - 49914663-9435-4c92-927c-18254c0a5619
                - 149ae042-746d-4db4-ab94-4373d32a63ec
                code: 105000004
                message: Cleared
                internal_code: documentstore_cleared
                meta:
                  type: deletelist
                  version: '2.0'
  "/stream/:id":
    get:
      tags:
      - Stream
      summary: Retrieve stream by ID
      parameters:
      - "$ref": "#/components/parameters/url_id"
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/Stream"
              example:
                subscription:
                - "/2.0/network"
                ignore:
                - "/2.0/value"
                full: true
                meta:
                  id: 7e538256-e591-4848-8461-df6ac7806de6
                  type: stream
                  version: '2.0'
    head:
      tags:
      - Stream
      summary: Check if stream by ID is retrievable
      parameters:
      - "$ref": "#/components/parameters/url_id"
      responses:
        '200':
          description: OK
    post:
      tags:
      - Stream
      summary: Accept shared stream
      parameters:
      - "$ref": "#/components/parameters/url_id"
      requestBody:
        content:
          application/json:
            schema:
              "$ref": "#/components/schemas/Stream"
            example: {}
      responses:
        '201':
          description: OK
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/Stream"
              example:
                subscription:
                - "/2.0/network"
                ignore: []
                full: true
                meta:
                  id: 67e4d637-7091-4b72-a918-b503a5c34c7c
                  type: stream
                  version: '2.0'
    patch:
      tags:
      - Stream
      summary: Update an stream by ID
      parameters:
      - "$ref": "#/components/parameters/url_id"
      requestBody:
        content:
          application/json:
            schema:
              "$ref": "#/components/schemas/Stream"
            example:
              full: false
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/Stream"
              example:
                subscription:
                - "/2.0/network"
                ignore:
                - "/2.0/value"
                full: false
                meta:
                  id: 7e538256-e591-4848-8461-df6ac7806de6
                  type: stream
                  version: '2.0'
    put:
      tags:
      - Stream
      summary: Replace an stream by ID
      parameters:
      - "$ref": "#/components/parameters/url_id"
      requestBody:
        content:
          application/json:
            schema:
              "$ref": "#/components/schemas/Stream"
            example:
              subscription:
              - "/2.0/network"
              ignore:
              - "/2.0/value"
              full: false
              meta:
                id: 7e538256-e591-4848-8461-df6ac7806de6
                type: stream
                version: '2.0'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/Stream"
              example:
                subscription:
                - "/2.0/network"
                ignore:
                - "/2.0/value"
                full: false
                meta:
                  id: 7e538256-e591-4848-8461-df6ac7806de6
                  type: stream
                  version: '2.0'
    delete:
      tags:
      - Stream
      summary: Delete an stream by ID
      parameters:
      - "$ref": "#/components/parameters/url_id"
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/Deletelist"
              example:
                deleted:
                - 7e538256-e591-4848-8461-df6ac7806de6
                code: 105000003
                message: Deleted
                internal_code: documentstore_deleted
                meta:
                  type: deletelist
                  version: '2.0'
  "/stream_internal":
    post:
      tags:
      - Stream_internal
      summary: Fetch request of stream_internal
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              "$ref": "#/components/schemas/Stream_internal"
            example:
              filter:
                id:
                - 336a1ff0-05cb-4a25-b493-f3d617650528
                - e635fdb6-8f21-49ae-9873-d87b088fa636
              return: "{ stream_internal {meta {id}}}"
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/Fetch"
              example:
                meta:
                  type: fetch
                  version: '2.0'
                data:
                  stream_internal:
                  - meta:
                      id: 336a1ff0-05cb-4a25-b493-f3d617650528
                  - meta:
                      id: e635fdb6-8f21-49ae-9873-d87b088fa636
    get:
      tags:
      - Stream_internal
      summary: Retrieve list of stream_internal
      parameters: []
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/Idlist"
              example:
                child:
                - type: stream_internal
                  version: '2.0'
                id:
                - 336a1ff0-05cb-4a25-b493-f3d617650528
                - e635fdb6-8f21-49ae-9873-d87b088fa636
                - 9292e031-5e96-4151-b7e2-1c8457e25277
                - 0d292636-2cff-4849-9986-6141e5b75c5e
                more: false
                limit: 1000
                count: 4
                meta:
                  type: idlist
                  version: '2.0'
    head:
      tags:
      - Stream_internal
      summary: Check if list of stream_internal is retrievable
      parameters: []
      responses:
        '200':
          description: OK
    patch:
      tags:
      - Stream_internal
      summary: Update multiple stream_internals
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              "$ref": "#/components/schemas/Stream_internal"
            example:
              object:
              - 1d45dcb5-6772-4e38-a2d0-9fe0bc9c1001
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/Stream_internal"
              example:
              - object:
                - 1d45dcb5-6772-4e38-a2d0-9fe0bc9c1001
                service: azure_service_bus
                data:
                  name: test
                full: true
                status:
                  connection_established: false
                  timestamp: '2021-03-23T11:45:53.099879Z'
                  message: Attribute is missing in data/secure
                  code: 10001
                meta:
                  id: 336a1ff0-05cb-4a25-b493-f3d617650528
                  type: stream_internal
                  version: '2.0'
              - object:
                - 1d45dcb5-6772-4e38-a2d0-9fe0bc9c1001
                service: azure_service_bus
                data:
                  name: testAAA
                full: true
                status:
                  connection_estabilished: false
                  timestamp: '2021-03-23T11:45:53.095448Z'
                  message: No message sent to endpoint
                  code: 10004
                meta:
                  id: e635fdb6-8f21-49ae-9873-d87b088fa636
                  type: stream_internal
                  version: '2.0'
    delete:
      tags:
      - Stream_internal
      summary: Delete all stream_internal
      parameters: []
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/Deletelist"
              example:
                deleted:
                - e635fdb6-8f21-49ae-9873-d87b088fa636
                - 9292e031-5e96-4151-b7e2-1c8457e25277
                - 0d292636-2cff-4849-9986-6141e5b75c5e
                code: 105000004
                message: Cleared
                internal_code: documentstore_cleared
                meta:
                  type: deletelist
                  version: '2.0'
  "/stream_internal/:id":
    get:
      tags:
      - Stream_internal
      summary: Retrieve stream_internal by ID
      parameters:
      - "$ref": "#/components/parameters/url_id"
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/Stream_internal"
              example:
                object:
                - 56d9e720-5833-4622-9fc2-5886f1346c08
                - eb1e2553-2d44-4600-9ad1-ea66d8b9f893
                - 20ea466e-761a-49e8-906c-7631bb141dec
                - d4fb9e65-e927-4a2f-aed2-539db8324869
                service: azure_service_bus
                data:
                  name: test
                meta:
                  id: 336a1ff0-05cb-4a25-b493-f3d617650528
                  type: stream_internal
                  version: '2.0'
    head:
      tags:
      - Stream_internal
      summary: Check if stream_internal by ID is retrievable
      parameters:
      - "$ref": "#/components/parameters/url_id"
      responses:
        '200':
          description: OK
    post:
      tags:
      - Stream_internal
      summary: Fetch request of stream_internal
      parameters:
      - "$ref": "#/components/parameters/url_id"
      requestBody:
        content:
          application/json:
            schema:
              "$ref": "#/components/schemas/Stream_internal"
            example:
              return: "{ object: stream_internal {meta {id} service}}"
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/Fetch"
              example:
                meta:
                  type: fetch
                  version: '2.0'
                data:
                  object:
                  - meta:
                      id: 336a1ff0-05cb-4a25-b493-f3d617650528
                    service: azure_service_bus
    patch:
      tags:
      - Stream_internal
      summary: Update an stream_internal by ID
      parameters:
      - "$ref": "#/components/parameters/url_id"
      requestBody:
        content:
          application/json:
            schema:
              "$ref": "#/components/schemas/Stream_internal"
            example:
              object:
              - 1d45dcb5-6772-4e38-a2d0-9fe0bc9c1001
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/Stream_internal"
              example:
                object:
                - 1d45dcb5-6772-4e38-a2d0-9fe0bc9c1001
                service: azure_service_bus
                data:
                  name: test
                full: true
                status:
                  connection_established: false
                  timestamp: '2021-03-23T11:45:53.099879Z'
                  message: Attribute is missing in data/secure
                  code: 10001
                meta:
                  id: 336a1ff0-05cb-4a25-b493-f3d617650528
                  type: stream_internal
                  version: '2.0'
    put:
      tags:
      - Stream_internal
      summary: Replace an stream_internal by ID
      parameters:
      - "$ref": "#/components/parameters/url_id"
      requestBody:
        content:
          application/json:
            schema:
              "$ref": "#/components/schemas/Stream_internal"
            example:
              object:
              - 1d45dcb5-6772-4e38-a2d0-9fe0bc9c1001
              service: azure_service_bus
              data:
                name: test
              full: true
              status:
                connection_established: false
                timestamp: '2021-03-23T11:45:53.099879Z'
                message: Attribute is missing in data/secure
                code: 10001
              meta:
                id: 336a1ff0-05cb-4a25-b493-f3d617650528
                type: stream_internal
                version: '2.0'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/Stream_internal"
              example:
                object:
                - 1d45dcb5-6772-4e38-a2d0-9fe0bc9c1001
                service: azure_service_bus
                data:
                  name: test
                full: true
                status:
                  connection_established: false
                  timestamp: '2021-03-23T11:45:53.099879Z'
                  message: Attribute is missing in data/secure
                  code: 10001
                meta:
                  id: 336a1ff0-05cb-4a25-b493-f3d617650528
                  type: stream_internal
                  version: '2.0'
    delete:
      tags:
      - Stream_internal
      summary: Delete an stream_internal by ID
      parameters:
      - "$ref": "#/components/parameters/url_id"
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/Deletelist"
              example:
                deleted:
                - 336a1ff0-05cb-4a25-b493-f3d617650528
                code: 105000003
                message: Deleted
                internal_code: documentstore_deleted
                meta:
                  type: deletelist
                  version: '2.0'
