openapi: 3.1.0
info:
  title: relations
  contact: {}
  license:
    name: MIT License
    url: https://opensource.org/licenses/MIT
  version: "1.1"
servers:
- url: http://localhost:60209
  description: Generated server url
tags:
- name: Relation Type
  description: 'CRUD for relation types '
- name: Relation
  description: Relations between objects
paths:
  /{municipalityId}/relations/{id}:
    get:
      tags:
      - Relation
      summary: Get relation
      description: Get relation with matching id.
      operationId: getRelation
      parameters:
      - name: municipalityId
        in: path
        description: Municipality id
        required: true
        schema:
          type: string
        example: 2281
      - name: id
        in: path
        description: id of relation
        required: true
        schema:
          type: string
        example: b9702590-1a65-4b78-9de5-44e46e25b62c
      responses:
        "200":
          description: Successful Operation
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Relation"
        "400":
          description: Bad Request
          content:
            application/problem+json:
              schema:
                oneOf:
                - $ref: "#/components/schemas/Problem"
                - $ref: "#/components/schemas/ConstraintViolationProblem"
        "500":
          description: Internal Server Error
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
    put:
      tags:
      - Relation
      summary: Save relation
      description: Replace relation by saving new values
      operationId: saveRelation
      parameters:
      - name: municipalityId
        in: path
        description: Municipality id
        required: true
        schema:
          type: string
        example: 2281
      - name: id
        in: path
        description: id of relation
        required: true
        schema:
          type: string
        example: b9702590-1a65-4b78-9de5-44e46e25b62c
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/Relation"
        required: true
      responses:
        "200":
          description: Successful operation
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Relation"
        "404":
          description: Not found
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
        "400":
          description: Bad Request
          content:
            application/problem+json:
              schema:
                oneOf:
                - $ref: "#/components/schemas/Problem"
                - $ref: "#/components/schemas/ConstraintViolationProblem"
        "500":
          description: Internal Server Error
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
    delete:
      tags:
      - Relation
      summary: Delete relation
      description: Deletes relation with matching id
      operationId: deleteRelation
      parameters:
      - name: municipalityId
        in: path
        description: Municipality id
        required: true
        schema:
          type: string
        example: 2281
      - name: id
        in: path
        description: id of relation
        required: true
        schema:
          type: string
        example: b9702590-1a65-4b78-9de5-44e46e25b62c
      responses:
        "204":
          description: Successful operation
        "404":
          description: Not Found
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
        "400":
          description: Bad Request
          content:
            application/problem+json:
              schema:
                oneOf:
                - $ref: "#/components/schemas/Problem"
                - $ref: "#/components/schemas/ConstraintViolationProblem"
        "500":
          description: Internal Server Error
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
  /relation-types/{type}:
    get:
      tags:
      - Relation Type
      summary: Get relation type
      description: Get relation type with RelationType.type as key.
      operationId: getType
      parameters:
      - name: type
        in: path
        description: relation type name
        required: true
        schema:
          type: string
        example: BLOCKS
      responses:
        "200":
          description: Successful Operation
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/RelationType"
        "404":
          description: Not found
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
        "400":
          description: Bad Request
          content:
            application/problem+json:
              schema:
                oneOf:
                - $ref: "#/components/schemas/Problem"
                - $ref: "#/components/schemas/ConstraintViolationProblem"
        "500":
          description: Internal Server Error
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
    put:
      tags:
      - Relation Type
      summary: Save relation type
      description: Replace relation type by saving new values
      operationId: saveRelationType
      parameters:
      - name: type
        in: path
        description: name of relation type
        required: true
        schema:
          type: string
        example: DUPLICATE
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/RelationType"
        required: true
      responses:
        "200":
          description: Successful operation
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/RelationType"
        "404":
          description: Not found
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
        "409":
          description: Conflict
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
        "400":
          description: Bad Request
          content:
            application/problem+json:
              schema:
                oneOf:
                - $ref: "#/components/schemas/Problem"
                - $ref: "#/components/schemas/ConstraintViolationProblem"
        "500":
          description: Internal Server Error
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
    delete:
      tags:
      - Relation Type
      summary: Delete relation type
      description: Deletes relation type and possible counterType
      operationId: deleteRelationType
      parameters:
      - name: type
        in: path
        description: name of relation type
        required: true
        schema:
          type: string
        example: DUPLICATE
      responses:
        "204":
          description: Successful operation
        "404":
          description: Not Found
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
        "400":
          description: Bad Request
          content:
            application/problem+json:
              schema:
                oneOf:
                - $ref: "#/components/schemas/Problem"
                - $ref: "#/components/schemas/ConstraintViolationProblem"
        "500":
          description: Internal Server Error
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
  /{municipalityId}/relations:
    get:
      tags:
      - Relation
      summary: Find matching relations
      description: Query for relations with or without filters.
      operationId: findRelations
      parameters:
      - name: municipalityId
        in: path
        description: Municipality id
        required: true
        schema:
          type: string
        example: 2281
      - name: filter
        in: query
        description: "Syntax description: [spring-filter](https://github.com/turkraft/spring-filter/blob/85730f950a5f8623159cc0eb4d737555f9382bb7/README.md#syntax)"
        required: false
        schema:
          type: string
        example: sourceId:'SUPPORT-CASE-ID' or targetId:'SUPPORT-CASE-ID'
      - name: sortBy
        in: query
        required: false
        schema:
          type: array
          items:
            type: string
            description: The properties to sort on
            examples:
            - propertyName
      - name: sortDirection
        in: query
        description: The sort order direction
        required: false
        schema:
          $ref: "#/components/schemas/Direction"
      - name: page
        in: query
        description: Page number
        required: false
        schema:
          type: integer
          format: int32
          default: 1
          description: Page number
          examples:
          - 1
          minimum: 1
      - name: limit
        in: query
        description: Result size per page. Maximum allowed value is dynamically configured
        required: false
        schema:
          type: integer
          format: int32
          description: Result size per page. Maximum allowed value is dynamically
            configured
          examples:
          - 15
          minimum: 1
      responses:
        "200":
          description: Successful Operation
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/RelationPagedResponse"
        "400":
          description: Bad Request
          content:
            application/problem+json:
              schema:
                oneOf:
                - $ref: "#/components/schemas/Problem"
                - $ref: "#/components/schemas/ConstraintViolationProblem"
        "500":
          description: Internal Server Error
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
    post:
      tags:
      - Relation
      summary: Create relation
      description: Creates a new relation between to objects
      operationId: createRelation
      parameters:
      - name: municipalityId
        in: path
        description: Municipality id
        required: true
        schema:
          type: string
        example: 2281
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/Relation"
        required: true
      responses:
        "201":
          description: Successful operation
          headers:
            Location:
              style: simple
              schema:
                type: string
        "400":
          description: Bad Request
          content:
            application/problem+json:
              schema:
                oneOf:
                - $ref: "#/components/schemas/Problem"
                - $ref: "#/components/schemas/ConstraintViolationProblem"
        "500":
          description: Internal Server Error
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
  /relation-types:
    get:
      tags:
      - Relation Type
      summary: Get relation types
      description: Get all relation types.
      operationId: getAllTypes
      responses:
        "200":
          description: Successful Operation
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/RelationType"
        "400":
          description: Bad Request
          content:
            application/problem+json:
              schema:
                oneOf:
                - $ref: "#/components/schemas/Problem"
                - $ref: "#/components/schemas/ConstraintViolationProblem"
        "500":
          description: Internal Server Error
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
    post:
      tags:
      - Relation Type
      summary: Create type
      description: Creates a new relation type
      operationId: createType
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/RelationType"
        required: true
      responses:
        "201":
          description: Successful operation
          headers:
            Location:
              style: simple
              schema:
                type: string
        "409":
          description: Conflict
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
        "400":
          description: Bad Request
          content:
            application/problem+json:
              schema:
                oneOf:
                - $ref: "#/components/schemas/Problem"
                - $ref: "#/components/schemas/ConstraintViolationProblem"
        "500":
          description: Internal Server Error
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
  /api-docs:
    get:
      tags:
      - API
      summary: OpenAPI
      operationId: getApiDocs
      responses:
        "200":
          description: OK
          content:
            application/yaml:
              schema:
                type: string
      x-auth-type: None
      x-throttling-tier: Unlimited
      x-wso2-mutual-ssl: Optional
components:
  schemas:
    Problem:
      type: object
      properties:
        title:
          type: string
        detail:
          type: string
        instance:
          type: string
          format: uri
        type:
          type: string
          format: uri
        status:
          type: integer
          format: int32
    Relation:
      type: object
      description: Relation between objects
      properties:
        id:
          type: string
          description: Unique id for the relation
          examples:
          - f4de6b8b-f727-4ed1-9959-b9d5bde1922f
          readOnly: true
        type:
          type: string
          description: Type of relation. Valid types can be fetch via /relation-types
          minLength: 1
        created:
          type: string
          format: date-time
          description: Timestamp when relations was created
          examples:
          - 2000-10-31T01:30:00.000+02:00
          readOnly: true
        modified:
          type: string
          format: date-time
          description: Timestamp when relations was last modified
          examples:
          - 2000-10-31T01:30:00.000+02:00
          readOnly: true
        source:
          $ref: "#/components/schemas/ResourceIdentifier"
          description: Source identifiers
        target:
          $ref: "#/components/schemas/ResourceIdentifier"
          description: Target identifiers
      required:
      - source
      - target
      - type
    ResourceIdentifier:
      type: object
      description: Resource identifier for source and target
      properties:
        resourceId:
          type: string
          description: Unique id for the object
          examples:
          - some-id
          minLength: 1
        type:
          type: string
          description: Type of object
          examples:
          - case
          minLength: 1
        service:
          type: string
          description: Name of service where object exists
          minLength: 1
        namespace:
          type: string
          description: Namespace of object
      required:
      - resourceId
      - service
      - type
    ConstraintViolationProblem:
      type: object
      properties:
        type:
          type: string
          format: uri
        status:
          type: integer
          format: int32
        violations:
          type: array
          items:
            $ref: "#/components/schemas/Violation"
        title:
          type: string
        causeAsProblem:
          $ref: "#/components/schemas/ThrowableProblem"
        detail:
          type: string
        instance:
          type: string
          format: uri
    ThrowableProblem:
      type: object
      properties:
        type:
          type: string
          format: uri
        title:
          type: string
        status:
          type: integer
          format: int32
        detail:
          type: string
        instance:
          type: string
          format: uri
        causeAsProblem: {}
    Violation:
      type: object
      properties:
        field:
          type: string
        message:
          type: string
    RelationType:
      type: object
      description: Type of relation
      properties:
        name:
          type: string
          description: Name of type
          examples:
          - DUPLICATES
          minLength: 1
        displayName:
          type: string
          description: Display value
          examples:
          - Duplicates
        counterName:
          type: string
          description: Inverse value of type (if applicable)
          examples:
          - IS DUPLICATED BY
        counterDisplayName:
          type: string
          description: Display value
          examples:
          - Is duplicated by
      required:
      - name
    Direction:
      type: string
      description: The sort order direction
      enum:
      - ASC
      - DESC
      examples:
      - ASC
    PagingAndSortingMetaData:
      type: object
      description: PagingAndSortingMetaData model
      properties:
        page:
          type: integer
          format: int32
          description: Current page
          examples:
          - 5
          readOnly: true
        limit:
          type: integer
          format: int32
          description: Displayed objects per page
          examples:
          - 20
          readOnly: true
        count:
          type: integer
          format: int32
          description: Displayed objects on current page
          examples:
          - 13
          readOnly: true
        totalRecords:
          type: integer
          format: int64
          description: Total amount of hits based on provided search parameters
          examples:
          - 98
          readOnly: true
        totalPages:
          type: integer
          format: int32
          description: Total amount of pages based on provided search parameters
          examples:
          - 23
          readOnly: true
        sortBy:
          type: array
          items:
            type: string
            description: The properties to sort by
            examples:
            - property
            readOnly: true
        sortDirection:
          $ref: "#/components/schemas/Direction"
          description: The sort order direction
          examples:
          - ASC
    RelationPagedResponse:
      type: object
      description: Paged relation response
      properties:
        relations:
          type: array
          items:
            $ref: "#/components/schemas/Relation"
            readOnly: true
        _meta:
          $ref: "#/components/schemas/PagingAndSortingMetaData"
          readOnly: true
  securitySchemes: {}
