openapi: "3.0.0"
info:
  version: 1.0.0
  title: Solibri REST API
  description: Solibri Developer Platform
  contact:
    name: Solibri
    url: https://www.solibri.com
    email: support@solibri.com
  license:
    name: Solibri Software License
    url: https://www.solibri.com
servers:
  - url: http://localhost/solibri/v1
    description: 'Start server with argument: --rest-api-server-port=8080'
paths:
  /shutdown:
    post:
      summary: Shutdown the application
      operationId: shutdown
      parameters:
        - in: query
          name: force
          required: true
          description: Forceful shutdown or not
          schema:
           type: boolean
      responses:
        '200':
          description: Closing procedures started successfully
        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"

  /ping:
    get:
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PingResponse"
        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"

  /about:
    get:
      summary: Get information about running product
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AboutResponse"
        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"

  /project:
    post:
      summary: Open a Solibri project
      operationId: openSMCProject
      parameters:
        - in: query
          name: name
          required: true
          description: Name of the project
          schema:
           type: string
      requestBody:
        content:
          application/octet-stream:
            schema:
              type: string
              format: binary
      responses:
        '201':
          description: Information of the project that was opened
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ModelInfo"
        '403':
          description: A new project cannot be opened if another one is open already
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"

  /project/persist:
    post:
      summary: Save a Solibri project
      operationId: saveSMCProject
      parameters:
        - in: query
          name: destination
          required: true
          description: The target filepath for the project
          schema:
           type: string
      responses:
        '201':
          description: Information of the project that was saved.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ModelInfo"
        '403':
          description: Saving the project failed for some reason.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"

  /project/close:
    post:
      summary: Close a Solibri project
      operationId: closeSMCProject
      parameters:
        - in: query
          name : force
          required: true
          description: Forceful close or not
          schema:
           type: boolean
      responses:
        '201':
          description: Successfully closed the project
        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"

  /models:
    get:
      summary: Get current models
      operationId: getModels
      responses:
        '200':
          description: Information of all models currently open
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ModelInfoList"
        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
    post:
      summary: Open IFC Model
      operationId: openIFCModel
      parameters:
        - in: query
          name: name
          required: true
          description: Name of the model
          schema:
           type: string
      requestBody:
        content:
          application/octet-stream:
            schema:
              type: string
              format: binary
      responses:
        '201':
          description: Information of the model that was opened
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ModelInfo"
        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"

  /models/{modelUUID}/update:
    parameters:
      - in: path
        name: modelUUID
        required: true
        description: Solibri internal unique ID (e.g. 66bbc0ca-4496-11e9-b210-d663bd873d93)
        schema:
          type: string
    put:
      summary: Update IFC Model
      operationId: updateIFCModel
      requestBody:
        content:
          application/octet-stream:
            schema:
              type: string
              format: binary
      responses:
        '201':
          description:  Information of the model that was updated
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ModelInfo"
        '404':
          description: Model with the specified UUID not found.
        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"

  /models/{modelUUID}/partialUpdate:
    parameters:
      - in: path
        name: modelUUID
        required: true
        description: Solibri internal unique ID (e.g. 66bbc0ca-4496-11e9-b210-d663bd873d93)
        schema:
          type: string
    put:
      summary: Partial Update IFC Model
      operationId: partialUpdateIFCModel
      requestBody:
        content:
          application/octet-stream:
            schema:
              type: string
              format: binary
      responses:
        '201':
          description: Information of the model that was partially updated
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ModelInfo"
        '404':
          description: Model with the specified UUID not found.
        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"

  /status:
    get:
      summary: Get server status information
      operationId: getStatus
      responses:
        '200':
          description: Information about the server status
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Status"
        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"

  /info/{guid}:
    parameters:
      - in: path
        name: guid
        required: true
        description: Component's IFC Global Unique ID (Guid)
        schema:
          type: string
          example: "3u0r7v0vz86hAS5hbSc21V"
    post:
      summary: Show component's info in the Info view of the user interface.
      operationId: showInfo
      responses:
        '200':
          description: Component's info is shown in the user interface.
        '404':
          description: A component with the specified Guid not found.
        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"

  /information:
    parameters:
      - in: query
        name: informationUniqueId
        required: true
        description: Information unique id
        schema:
          type: string
          example: "Has failed checking"
      - in: query
        name: componentGuid
        required: true
        description: Component's IFC Global Unique ID (Guid)
        schema:
          type: string
          example: "3u0s7v0vz86hAS5hbSc21V"
    get:
      summary: Get the information for given component.
      operationId: getInformation
      responses:
        '200':
          description: Information of the component.
          content:
            text/plain:
              schema:
                type: string
                example: 87.7
        '204':
          description: No content available.
        '404':
          description: Information with the specified informationUniqueId and componentGuid was not found.
        '500':
          description: Unexpected error.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
                
  /parametricInformation:
    parameters:
      - in: query
        name: informationUniqueId
        description: Information unique id
        required: true
        schema:
          type: string
          example: "Rent"
      - in: query
        name: componentGuid
        description: Component's IFC Global Unique ID (Guid)
        required: true
        schema:
          type: string
          example: "3u0s7v0vz86hAS5hbSc21V"
    post:
      summary: Get the parametric information of the component
      operationId: getParametricInformation
      requestBody:
        description: Parameter values as JSON object where parameter values are in String format.
        required: false
        content:
          application/json:
            schema:
              type: object
              example: { "RentableRatio": "0.9", "Rent": "20" }
              additionalProperties:
                type: string
      responses:
        '200':
          description: Parametric information of the component
          content:
            text/plain:
              schema:
                type: string
                example: 87.7
        '204':
          description: No content available.
        '404':
          description: Information with the specified informationUniqueId and componentGuid was not found.
        '500':
          description: Unexpected error.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"       
               

  /models/{modelUUID}/components:
    parameters:
      - in: path
        name: modelUUID
        required: true
        description: Solibri internal unique ID (e.g. 66bbc0ca-4496-11e9-b210-d663bd873d93).
        schema:
          type: string
      - in: query
        name: limit
        required: false
        description: Optional limit for the size of the returned list.
        schema:
          type: integer
          example: 200
      - in: query
        name: offset
        required: false
        description: Optional offset for the starting element of the returned list.
        schema:
          type: integer
          example: 100
    get:
      summary: Get a list of IFC Global Unique ID (Guid) of the components
      operationId: getComponentGuids
      responses:
        '200':
          description: List of IFC GUIDs of the components in the model.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/IfcGuidList"
        '404':
          description: Model with the specified UUID not found.

  /models/{modelUUID}/metadata/{metadataKey}:
    parameters:
      - in: path
        name: modelUUID
        required: true
        description: Solibri internal unique ID (e.g. 66bbc0ca-4496-11e9-b210-d663bd873d93)
        schema:
          type: string
      - in: path
        name: metadataKey
        required: true
        description: Metadata key (e.g. timestamp or version)
        schema:
          type: string
    get:
      summary: Get metadata value of specified key
      operationId: getMetadata
      responses:
        '200':
          description: OK
        '404':
          description: Model with the specified UUID not found.
        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
    put:
      summary: Set metadata value for specified key
      operationId: setMetadata
      parameters:
        - in: query
          name: value
          required: true
          description: Value of the metadata
          schema:
           type: string
      responses:
        '404':
          description: Model with matching UUID not found.
        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"

  /selectionBasket:
    get:
      summary: Get IFC guids of the selected components
      operationId: getSelection
      responses:
        '200':
          description: List of IFC GUIDs of the components that are selected
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/IfcGuidList"
        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
    post:
      summary: Select components matching the given IFC guids
      operationId: setSelection
      requestBody:
        description: List of IFC GUIDs of the components to be selected
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/IfcGuidList"
      responses:
        '200':
           description: OK
        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"

  /models/{modelUUID}/deleteComponents:
    parameters:
      - in: path
        name: modelUUID
        required: true
        description: Solibri internal unique ID (e.g. 66bbc0ca-4496-11e9-b210-d663bd873d93)
        schema:
          type: string
    post:
      summary: Delete components matching the given IFC guids
      operationId: deleteComponents
      requestBody:
        description: List of IFC GUIDs to be deleted
        required: true
        content:
          application/json:
            schema:
                $ref: "#/components/schemas/IfcGuidList"
      responses:
        '200':
          description: OK
        '404':
          description: Model with the specified UUID not found.
        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"

  /bcfxml/{version}:
    parameters:
      - in: path
        name: version
        required: true
        schema:
          type: string
          enum: [one, two, two_one]
      - in: query
        name: scope
        required: false
        schema:
          type: string
          enum: [all, selected, marked]
    get:
      summary: Access to all, selected or marked issues based on the scope. If no scope is set the scope is all issues. Returns content of a BCF file.
      operationId: getBCF
      responses:
        '200':
          description: BFC file content
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/EncodedBinary"
        '204':
          description: No issues available
        default:
          description: No issues
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
      
  /checking:
    post:
       summary: Runs checking and returns checking results
       operationId: runChecking
       parameters:
        - in: query
          name: checkSelected
          required: true
          description: Run in seected mode or not
          schema:
           type: boolean
       responses:
          '200':
             description: Checking results
             content: 
               application/json:
                 schema:
                   $ref: "#/components/schemas/CheckingResultList"
          '400':
             description: Bad Request
             content:
               application/json:
                 schema:
                   $ref: "#/components/schemas/Error"
          '500':
            description: Interruption in checking
            content:
               application/json:
                 schema:
                   $ref: "#/components/schemas/Error"

  /threed/camera:
    get:
      summary: Get Camera State
      operationId: getCameraState
      responses:
        default:
          description: Camera State
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CameraState"
        '500' :
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"  
    post:
      summary: Sets Camera State
      operationId: setCameraState
      requestBody:
        description: Camera State
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CameraState"
      responses:
        default:
           description: OK
        '500':
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
  /presentations:
    post:
      summary: Adds a new presentation
      operationId: addPresentation
      description: "Adds a new presentation to the current project."
      requestBody:
        description: Presentation details
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PresentationRequest'
      responses:
        '201':
          description: Presentation added to the current project
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PresentationResponse'
        '400':
          description: Bad Request
        '424':
          description: No project open
        '500':
          description: unexpected error
  /slides:
    post:
      summary: Adds a new slide to the presentation
      operationId: addSlide
      description: "Adds a new slide to the presentaion identified by presentationId."
      requestBody:
        description: Slide details
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SlideRequest'
      responses:
        '201':
          description: Slide added
        '400':
          description: Bad Request
        '424':
          description: No presentation found with given presentationId
        '500':
          description: unexpected error

components:

  schemas:

    ModelInfo:
      type: object
      properties:
        name:
          description: Name of the model
          type: string
        uuid:
          description: Solibri internal unique ID (e.g. 66bbc0ca-4496-11e9-b210-d663bd873d93)
          type: string
        metadata:
          description: Metata of the model as a map
          type: object
          additionalProperties:
            type: string
          example:
            timestamp: 1553761258
            version: v1.0

    ModelInfoList:
      type: array
      description: A list of model infos
      items:
        $ref: "#/components/schemas/ModelInfo"

    IfcGuidList:
      type: array
      description: A list of IFC GUIDS
      example: ["1$X1v5MXr3Buiox$k6BAhK", "10pglqEGT2cQr8PnzBOj2n", "20naGoyUXDkuMa2t7ZoZUh"]
      items:
        type: string

    Error:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: integer
          format: int32
        message:
          type: string

    PingResponse:
      type: object
      required:
        - answer
      properties:
        answer:
          type: string

    EncodedBinary:
      type: object
      properties:
        content:
          description: Base64-encoded contents of a file
          type: string
          format: byte

    AboutResponse:
      type: object
      properties:
        product:
          description: Name of the running product
          type: string
        version:
          description: Version of the running product
          type: string

    Status:
      type: object
      properties:
        busy:
          description: 'True when server is busy'
          type: boolean
        filename:
          description: Name of saved file
          type: string
        status:
          description: 'Status of saved file. One of: UNSAVED, SAVED, MODIFIED'
          type: string
        timestamp:
          description: 'Time when model was saved. 0 if model is not saved'
          type: string
          format: 'date-time'

    CheckingResult:
       type: object
       properties:
          name:
             description: 'Name of the Checking result'
             type: string
          description:
             description: 'Description of checking result.'
             type: string
          uniqueKey:
             description: 'Unique key for checking result.'
             type: string
          location:
             description: 'Location.'
             type: string
          severity:
             description: 'Severity of the result.'
             type: string
             enum: [CRITICAL,MODERATE,LOW,PASSED]

    CheckingResultList:
       type: array
       description: 'List of checking results.'
       items:
          $ref: "#/components/schemas/CheckingResult"

    Vector3D:
      type: object
      properties:
        x:
          description : 'X Coordinate'
          type: number
          format : double
        y:
          description : 'Y Coordinate'
          type: number
          format : double
        z:
          description : 'Z Coordinate'
          type : number
          format : double

    CameraState:
      type: object
      properties:
        projection:
           description: 'Camera State Projection. Valid values are PERSPECTIVE and ORTHOGONAL'
           type: string
           enum: [PERSPECTIVE,ORTHOGONAL]
        location:
          description : 'Location of the camera in 3D space. Unit of location is in Meters.'  
          $ref : '#/components/schemas/Vector3D'
        upDirection:
          description : 'Up direction of the camera as unit vector in 3D space' 
          $ref : '#/components/schemas/Vector3D'
        direction:
          description : 'Direction of the camera as unit vector in 3D space' 
          $ref : '#/components/schemas/Vector3D'
        fieldOfView:
           description : 'Field of View. Unit is in Radians. This is only valid for Perspective Projection.'
           type: number
           format: double
        viewToWorldScale:
           description : 'View to World Scale. This is only valid for Orthogonal Projection.'
           type: number
           format: double 

    PresentationRequest:
      type: object
      required: [name]
      properties:
        name:
          description: Name of the presentation.
          type: string
          example: "New Presentation"
        prefix:
          description: Tracking ID prefix of the presentation.
          type: string
          example: "PR-"

    PresentationResponse:
      type: object
      properties:
        id:
          description: Unique id of the presentation
          type: string
          example: "66bbc0ca-4496-11e9-b210-d663bd873d93"

    SlideRequest:
      type: object
      required: [title,presentationId]
      properties:
        title:
          description: Title of the slide.
          type: string
          example: "Revolving Door not Accompanied by Swing Door"
        presentationId:
          description: Unique Id of the presentation to add the current slide.
          type: string
          example: "123e4567-e89b-12d3-a456-426614174000"
        type:
          description: Type of the issue.
          type: string
          example: "Error"
        status:
          description: Status of the issue.
          type: string
          example: "Open"
        stage:
          description: Stage of the issue.
          type: string
          example: "Initial"
        priority:
          description: Priority of the issue.
          type: string
          example: "High"
        description:
          description: Description of the issue.
          type: string
          example: "Door swing is hindered."
        responsibilities:
          description: Assignees responsible for the issue resolution.
          type: array
          items:
            type: string
          example: ["SQ", "MK", "JS", "SC"]
        labels:
          description: Labels associated to the issue.
          type: array
          items:
            type: string
          example: ["critical", "teamA", "locA"]
        duedate:
          description: "Due date(YYYY-MM-DD) for the issue resolution."
          type: string
          example: "2021-05-27"
        components:
          description: IFC GUIDs of the components associated to the issue.
          type: array
          items:
            type: string
          example: ["2Nv5yGyGD3KBz3s3UUmiry","3KBz3s3UUmiry2Nv5yGyGD"]
        modifiedTimeInExternalSystem:
          description: Time when the slide was modified in some external system.
          type: string
          example: "2021-05-27T12:05:42.643Z"
