openapi: 3.0.3
info:
  title: reporting-api
  version: 0.0.1
  description: Reporting service which aggregates events from dedicated Kafka topics.
paths:
  /query:
    post:
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DeNccloudReportingApiV0ModelsQueryForm'
        required: true
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DeNccloudReportingApiV0ModelsQueryResponse'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/DeNccloudCommonV0ModelsGenericError'
  /topics:
    get:
      parameters:
      - name: offset
        in: query
        required: true
        schema:
          type: integer
          format: int32
      - name: limit
        in: query
        required: true
        schema:
          type: integer
          format: int32
      - name: sort_by
        in: query
        required: true
        schema:
          type: string
      - name: direction
        in: query
        required: true
        schema:
          $ref: '#/components/schemas/DeNccloudCommonV0EnumsSortDirection'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DeNccloudReportingApiV0ModelsTopicResponse'
  /topics/{guid}:
    get:
      parameters:
      - name: guid
        in: path
        required: true
        schema:
          type: string
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DeNccloudReportingApiV0ModelsTopic'
        '404':
          description: Not found
  /views:
    get:
      parameters:
      - name: offset
        in: query
        required: true
        schema:
          type: integer
          format: int32
      - name: limit
        in: query
        required: true
        schema:
          type: integer
          format: int32
      - name: sort_by
        in: query
        required: true
        schema:
          type: string
      - name: direction
        in: query
        required: true
        schema:
          $ref: '#/components/schemas/DeNccloudCommonV0EnumsSortDirection'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DeNccloudReportingApiV0ModelsViewResponse'
    post:
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DeNccloudReportingApiV0ModelsViewForm'
        required: true
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DeNccloudReportingApiV0ModelsView'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/DeNccloudCommonV0ModelsGenericError'
  /views/{guid}:
    get:
      parameters:
      - name: guid
        in: path
        required: true
        schema:
          type: string
          format: uuid
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DeNccloudReportingApiV0ModelsView'
        '404':
          description: Not found
    put:
      parameters:
      - name: guid
        in: path
        required: true
        schema:
          type: string
          format: uuid
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DeNccloudReportingApiV0ModelsViewForm'
        required: true
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DeNccloudReportingApiV0ModelsView'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/DeNccloudCommonV0ModelsGenericError'
        '404':
          description: Not found
    delete:
      parameters:
      - name: guid
        in: path
        required: true
        schema:
          type: string
          format: uuid
      responses:
        '200':
          description: Successful response
        '404':
          description: Not found
components:
  schemas:
    DeNccloudCommonV0ModelsErrorLinks:
      description: Links to further information about the occurred error.
      type: object
      properties:
        about:
          $ref: '#/components/schemas/DeNccloudCommonV0UnionsLink'
          description: A link that leads to further details about this particular
            occurrence of the problem.
        type:
          $ref: '#/components/schemas/DeNccloudCommonV0UnionsLink'
          description: A link that identifies the type of the error that this particular
            error is an instance of.
    DeNccloudCommonV0ModelsGenericError:
      description: An error returned on failed API requests.
      type: object
      required:
      - code
      - title
      - detail
      properties:
        links:
          $ref: '#/components/schemas/DeNccloudCommonV0ModelsErrorLinks'
        code:
          description: An app specific error code.
          type: string
        title:
          description: A short human readable summary of the problem.
          type: string
        detail:
          description: A human readable explanation of the problem.
          type: string
        source:
          $ref: '#/components/schemas/DeNccloudCommonV0ModelsErrorSource'
        meta:
          description: Non-standard meta-information about the error.
          type: object
          additionalProperties: true
    DeNccloudCommonV0ModelsPageResponse:
      description: Paging information returned from a paged request.
      type: object
      required:
      - offset
      - limit
      - sort
      - total_results
      - total_pages
      properties:
        offset:
          type: integer
          format: int32
        limit:
          type: integer
          format: int32
        sort:
          type: array
          items:
            $ref: '#/components/schemas/DeNccloudCommonV0ModelsSort'
        total_results:
          description: Total number of results that can potentially be returned.
          type: integer
          format: int64
        total_pages:
          description: Total number of pages that can potentially be returned.
          type: integer
          format: int64
    DeNccloudCommonV0ModelsErrorSource:
      description: Reference to the primary source of an error.
      type: object
      required:
      - type
      - source
      properties:
        type:
          $ref: '#/components/schemas/DeNccloudCommonV0EnumsErrorSourceType'
        source:
          description: The source of the problem in the form specified by `type`.
          type: string
    DeNccloudCommonV0ModelsSort:
      description: Single property to sort by.
      type: object
      required:
      - property
      - direction
      properties:
        property:
          description: The property by which the results should be sorted.
          type: string
        direction:
          $ref: '#/components/schemas/DeNccloudCommonV0EnumsSortDirection'
          description: The direction in which the results should be sorted.
    DeNccloudCommonV0ModelsAudit:
      description: Basic audit information for a resource.
      type: object
      required:
      - created_at
      - created_by
      - updated_at
      - updated_by
      properties:
        created_at:
          type: string
          format: date-time
        created_by:
          type: string
          format: uuid
        updated_at:
          type: string
          format: date-time
        updated_by:
          type: string
          format: uuid
    DeNccloudCommonV0ModelsLinkObject:
      description: Represents a link with some meta information.
      type: object
      required:
      - href
      properties:
        href:
          description: An URI-reference pointing to the links target.
          type: string
        title:
          description: A human-readable label for the link.
          type: string
        type:
          description: Optional media type of the link's target.
          type: string
    DeNccloudCommonV0ModelsServiceInfo:
      description: Information about a deployed service.
      type: object
      required:
      - name
      - version
      - uri
      properties:
        name:
          type: string
        version:
          type: string
        uri:
          description: URI under which this service is deployed.
          type: string
        title:
          description: A human-readable title of the service.
          type: string
        description:
          description: A human-readable description of the service.
          type: string
    DeNccloudReportingApiV0ModelsProjectionField:
      description: A single field of a projection schema.
      type: object
      properties:
        label:
          description: A human-readable label for the field.
          type: string
        description:
          description: A human-readable description for the field.
          type: string
        source:
          $ref: '#/components/schemas/DeNccloudReportingApiV0ModelsProjectionFieldSource'
          description: The source of the field. Either `source` or `fields` must be
            set.
        fields:
          description: Defines nested fields for this projection. Either `source`
            or `fields` must be set.
          type: object
          additionalProperties:
            $ref: '#/components/schemas/DeNccloudReportingApiV0ModelsProjectionField'
    DeNccloudReportingApiV0ModelsFilter:
      description: Defines a condition for values.
      type: object
      properties:
        expression:
          description: An SQL-like expression.
          type: string
        variables:
          description: A map of values, which can be used in the expression. Variables
            can be access by prepending them with `$`.
          type: object
          additionalProperties:
            type: object
            additionalProperties: true
    DeNccloudReportingApiV0ModelsQueryResponse:
      description: The result of a query, returning data in a projected form.
      type: object
      required:
      - page
      - data
      properties:
        page:
          $ref: '#/components/schemas/DeNccloudCommonV0ModelsPageResponse'
        data:
          description: The returned data in the projected form.
          type: object
          additionalProperties: true
    DeNccloudReportingApiV0ModelsView:
      description: A stored view containing data from one or more topics.
      type: object
      required:
      - guid
      - name
      - projection
      - variables
      properties:
        guid:
          description: Globally unique identifier of the projection.
          type: string
          format: uuid
        name:
          description: Name of this projection used to reference it in a human-friendly
            way. The name must be unique.
          type: string
        projection:
          description: Projected fields of this view.
          type: object
          additionalProperties:
            $ref: '#/components/schemas/DeNccloudReportingApiV0ModelsProjectionField'
        variables:
          description: Definition of variables which can be passed to the view. All
            `scalar_type`s are allowed, except `object`.
          type: object
          additionalProperties:
            $ref: '#/components/schemas/DeNccloudReportingApiV0EnumsScalarType'
    DeNccloudReportingApiV0ModelsQueryForm:
      description: Form for querying and projecting data.
      type: object
      required:
      - variables
      properties:
        view:
          description: The name of a defined `view` used for projecting. If the view
            defines variables, they must be provided as well. Either `view` or `projection`
            must be set.
          type: string
        projection:
          description: Projected fields to return. Either `view` or `projection` must
            be set.
          type: object
          additionalProperties:
            $ref: '#/components/schemas/DeNccloudReportingApiV0ModelsProjectionField'
        variables:
          description: Variables to pass to the projection or the view.
          type: object
          additionalProperties:
            type: object
            additionalProperties: true
        sort:
          description: The defined properties refer to the fields of the projection.
          type: array
          items:
            $ref: '#/components/schemas/DeNccloudCommonV0ModelsSort'
    DeNccloudReportingApiV0ModelsProjectionFieldSource:
      description: Represents the source for a single projection field from a topic's
        schema.
      type: object
      required:
      - topic
      - path
      - filter
      properties:
        topic:
          description: Name of the originating topic.
          type: string
        path:
          description: A slimmed down variant of [JSON Path](https://gregsdennis.github.io/Manatee.Json/usage/path.html)
            to point to a specific field in a topic's schema.
          type: string
        filter:
          description: A conditional filter expression. The expression can contain
            variables, which will be passed in when evaluating the projection.
          type: string
    DeNccloudReportingApiV0ModelsDeleteEvent:
      description: Deletes a reporting entity defined by its `tracking_id`.
      type: object
      required:
      - tracking_id
      - audit
      properties:
        tracking_id:
          description: A unique id, which identifies the association of multiple events.
            This can i.e. be a user guid, for events related to a user. It is important,
            that this id is unique and immutable.
          type: string
        audit:
          $ref: '#/components/schemas/DeNccloudCommonV0ModelsAudit'
          description: Audit information about this event.
    DeNccloudReportingApiV0ModelsTopic:
      description: Represents a single topic, which will be consumed by the reporting
        service.
      type: object
      required:
      - name
      - service
      - schema
      properties:
        name:
          type: string
        service:
          $ref: '#/components/schemas/DeNccloudCommonV0ModelsServiceInfo'
          description: Info about the producing service.
        schema:
          description: The schema of the topics' provided data.
          type: object
          additionalProperties:
            $ref: '#/components/schemas/DeNccloudReportingApiV0ModelsField'
    DeNccloudReportingApiV0ModelsTopicResponse:
      type: object
      required:
      - page
      - data
      properties:
        page:
          $ref: '#/components/schemas/DeNccloudCommonV0ModelsPageResponse'
        data:
          type: array
          items:
            $ref: '#/components/schemas/DeNccloudReportingApiV0ModelsTopic'
    DeNccloudReportingApiV0ModelsField:
      description: Single field of a topic schema. A field can be used for projecting,
        filtering and sorting in reports.
      type: object
      required:
      - type
      - is_array
      properties:
        type:
          $ref: '#/components/schemas/DeNccloudReportingApiV0EnumsScalarType'
          description: The (scalar) type of the field. Fields can only be primitive
            types.
        is_array:
          description: Setting this to `true` means the field is an array of given
            type.
          type: boolean
        fields:
          description: Nested fields for type `object`. When defining fields but not
            having set the type to `object`, the fields will be ignored. When setting
            the type to `object`, the fields need to be defined.
          type: object
          additionalProperties:
            $ref: '#/components/schemas/DeNccloudReportingApiV0ModelsField'
        label:
          description: A human-readable label for the field.
          type: string
        description:
          description: A human-readable description of the field.
          type: string
    DeNccloudReportingApiV0ModelsUpdateEvent:
      description: Updates one or more data fields.
      type: object
      required:
      - tracking_id
      - payload
      - audit
      properties:
        tracking_id:
          description: A unique id, which identifies the association of multiple events.
            This can i.e. be a user guid, for events related to a user. It is important,
            that this id is unique and immutable.
          type: string
        payload:
          description: One or more fields defined in the reporting schema, which will
            be updated.
          type: object
          additionalProperties: true
        audit:
          $ref: '#/components/schemas/DeNccloudCommonV0ModelsAudit'
          description: Audit information about this event.
    DeNccloudReportingApiV0ModelsViewResponse:
      type: object
      required:
      - page
      - data
      properties:
        page:
          $ref: '#/components/schemas/DeNccloudCommonV0ModelsPageResponse'
        data:
          type: array
          items:
            $ref: '#/components/schemas/DeNccloudReportingApiV0ModelsView'
    DeNccloudReportingApiV0ModelsViewForm:
      description: Form for creating a new `view`.
      type: object
      required:
      - name
      - projection
      - variables
      properties:
        name:
          description: Name of the view.
          type: string
        projection:
          description: Projected fields of this view.
          type: object
          additionalProperties:
            $ref: '#/components/schemas/DeNccloudReportingApiV0ModelsProjectionField'
        variables:
          description: Definition of variables which can be passed to the view. All
            `scalar_type`s are allowed, except `object`.
          type: object
          additionalProperties:
            $ref: '#/components/schemas/DeNccloudReportingApiV0EnumsScalarType'
    DeNccloudCommonV0EnumsErrorSourceType:
      description: Type of an error source.
      type: string
      enum:
      - pointer
      - parameter
      - header
    DeNccloudCommonV0EnumsSortDirection:
      description: The direction in which to sort by a property.
      type: string
      enum:
      - asc
      - desc
    DeNccloudReportingApiV0EnumsScalarType:
      description: A type for a topic's schema field.
      type: string
      enum:
      - boolean
      - date-iso8601
      - date-time-iso8601
      - decimal
      - double
      - integer
      - long
      - string
      - uuid
      - object
    DeNccloudCommonV0UnionsLink:
      description: Represents a link to a resource.
      oneOf:
      - $ref: '#/components/schemas/String'
      - $ref: '#/components/schemas/DeNccloudCommonV0ModelsLinkObject'
    DeNccloudReportingApiV0UnionsReportingEvent:
      oneOf:
      - $ref: '#/components/schemas/DeNccloudReportingApiV0ModelsUpdateEvent'
      - $ref: '#/components/schemas/DeNccloudReportingApiV0ModelsDeleteEvent'
