{
  "openapi": "3.1.0",
  "info": {
    "description": "This API allows managing of machines.",
    "title": "Machines",
    "version": "1.0"
  },
  "externalDocs": {
    "description": "Trackunit Developer Hub",
    "url": "https://developers.trackunit.com/"
  },
  "servers": [
    {
      "url": "https://iris.trackunit.com/public/api/machine/",
      "description": "Production"
    }
  ],
  "security": [
    {
      "authorizationBearer": []
    }
  ],
  "paths": {
    "/brands": {
      "get": {
        "description": "Get available machine brands",
        "operationId": "getBrands",
        "responses": {
          "200": {
            "content": {
              "application/hal+json": {
                "schema": {
                  "$ref": "#/components/schemas/BrandsRepresentation"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BrandsRepresentation"
                }
              }
            },
            "description": "OK"
          },
          "403": {
            "content": {
              "application/hal+json": {
                "schema": {
                  "$ref": "#/components/schemas/BrandsRepresentation"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BrandsRepresentation"
                }
              }
            },
            "description": "Unauthorized request or internal server error"
          }
        },
        "summary": "Get machine brands",
        "tags": ["Machine metadata"]
      }
    },
    "/categories": {
      "get": {
        "description": "Get available machine categories.",
        "operationId": "getCategories",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CategoriesRepresentation"
                }
              }
            },
            "description": "OK"
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CategoriesRepresentation"
                }
              }
            },
            "description": "Unauthorized request or internal server error."
          }
        },
        "summary": "Get machine categories",
        "tags": ["Machine metadata"]
      }
    },
    "/machines": {
      "get": {
        "description": "Get a list of machines",
        "operationId": "getMachines",
        "parameters": [
          {
            "example": "unitSerialNumber::123456|unitSerialNumber::654321",
            "in": "query",
            "name": "select",
            "required": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          },
          {
            "description": "See https://github.com/openapi-tools/api-capabilities for details.",
            "example": "10|30",
            "in": "query",
            "name": "elements",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "See https://github.com/openapi-tools/api-capabilities for details.",
            "example": "brand|model::-",
            "in": "query",
            "name": "sort",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/hal+json": {
                "schema": {
                  "$ref": "#/components/schemas/MachinesRepresentation"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MachinesRepresentation"
                }
              }
            },
            "description": "OK"
          },
          "500": {
            "content": {
              "application/hal+json": {
                "schema": {
                  "$ref": "#/components/schemas/MachinesRepresentation"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MachinesRepresentation"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "summary": "Get machines"
      }
    },
    "/machines-summary": {
      "get": {
        "deprecated": true,
        "description": "Get a summary of machines",
        "operationId": "getMachinesSummary",
        "parameters": [
          {
            "description": "Use 'Unknown' to match unset value. See https://github.com/openapi-tools/api-capabilities for further details.",
            "example": "brand::Mustang|category::Boom lift|productionYear::Unknown",
            "in": "query",
            "name": "select",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/hal+json": {
                "schema": {
                  "$ref": "#/components/schemas/MachinesSummaryRepresentation"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MachinesSummaryRepresentation"
                }
              }
            },
            "description": "OK"
          },
          "500": {
            "content": {
              "application/hal+json": {
                "schema": {
                  "$ref": "#/components/schemas/MachinesSummaryRepresentation"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MachinesSummaryRepresentation"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "summary": "Get machines summary"
      }
    },
    "/machines/query": {
      "post": {
        "description": "Get machines based on json list",
        "operationId": "queryMachines",
        "parameters": [
          {
            "in": "query",
            "name": "elements",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "sort",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "select",
            "required": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MachinesRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/hal+json": {
                "schema": {
                  "$ref": "#/components/schemas/MachinesRepresentation"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MachinesRepresentation"
                }
              }
            },
            "description": "OK"
          },
          "404": {
            "content": {
              "application/hal+json": {
                "schema": {
                  "$ref": "#/components/schemas/MachinesRepresentation"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MachinesRepresentation"
                }
              }
            },
            "description": "Machine not found"
          },
          "500": {
            "content": {
              "application/hal+json": {
                "schema": {
                  "$ref": "#/components/schemas/MachinesRepresentation"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MachinesRepresentation"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "summary": "Query machines"
      }
    },
    "/machines/{machineId}": {
      "get": {
        "description": "Get a single machine",
        "operationId": "getMachine",
        "parameters": [
          {
            "in": "path",
            "name": "machineId",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/hal+json": {
                "schema": {
                  "$ref": "#/components/schemas/MachineRepresentation"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MachineRepresentation"
                }
              }
            },
            "description": "OK"
          },
          "404": {
            "content": {
              "application/hal+json": {
                "schema": {
                  "$ref": "#/components/schemas/MachineRepresentation"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MachineRepresentation"
                }
              }
            },
            "description": "Machine not found"
          },
          "500": {
            "content": {
              "application/hal+json": {
                "schema": {
                  "$ref": "#/components/schemas/MachineRepresentation"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MachineRepresentation"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "summary": "Get machine"
      },
      "put": {
        "description": "Update a single machine",
        "operationId": "updateMachine",
        "parameters": [
          {
            "in": "path",
            "name": "machineId",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MachineUpdateRepresentation"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad request"
          },
          "404": {
            "description": "Machine not found"
          },
          "500": {
            "description": "Internal server error"
          }
        },
        "summary": "Update machine"
      }
    },
    "/machines/{machineId}/extended-information": {
      "get": {
        "description": "Machine extended information",
        "operationId": "getExtendedInformation",
        "parameters": [
          {
            "in": "path",
            "name": "machineId",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/hal+json": {
                "schema": {
                  "$ref": "#/components/schemas/ExtendedInformationRepresentation"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExtendedInformationRepresentation"
                }
              }
            },
            "description": "OK"
          },
          "404": {
            "content": {
              "application/hal+json": {
                "schema": {
                  "$ref": "#/components/schemas/ExtendedInformationRepresentation"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExtendedInformationRepresentation"
                }
              }
            },
            "description": "Machine info not found"
          },
          "500": {
            "content": {
              "application/hal+json": {
                "schema": {
                  "$ref": "#/components/schemas/ExtendedInformationRepresentation"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExtendedInformationRepresentation"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "summary": "Get machine extended information"
      },
      "put": {
        "description": "Update machine extended information",
        "operationId": "updateExtendedInformation",
        "parameters": [
          {
            "in": "path",
            "name": "machineId",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ExtendedInformationUpdateRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK"
          },
          "404": {
            "description": "Machine info not found"
          },
          "500": {
            "description": "Internal server error"
          }
        },
        "summary": "Update machine extended information"
      }
    },
    "/machines/{machineId}/servicedocuments": {
      "get": {
        "description": "Get Service Documents related to a machine",
        "operationId": "getMachineServiceDocuments",
        "parameters": [
          {
            "in": "path",
            "name": "machineId",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "*/*": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceDocumentsRepresentation"
                }
              }
            },
            "description": "OK"
          },
          "404": {
            "content": {
              "*/*": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceDocumentsRepresentation"
                }
              }
            },
            "description": "Machine not found"
          },
          "500": {
            "content": {
              "*/*": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceDocumentsRepresentation"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "summary": "Get Service Documents"
      }
    },
    "/machines/{machineId}/servicedocuments/{serviceDocumentId}/": {
      "get": {
        "description": "Get Service Document related to a machine",
        "operationId": "getMachineServiceDocument",
        "parameters": [
          {
            "in": "path",
            "name": "machineId",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "in": "path",
            "name": "serviceDocumentId",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "*/*": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceDocumentRepresentation"
                }
              }
            },
            "description": "OK"
          },
          "404": {
            "content": {
              "*/*": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceDocumentRepresentation"
                }
              }
            },
            "description": "Machine not found"
          },
          "500": {
            "content": {
              "*/*": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceDocumentRepresentation"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "summary": "Get Service Document"
      }
    },
    "/machines/{machineId}/servicedocuments/{serviceDocumentId}/download": {
      "get": {
        "description": "Download Service Document related to a machine",
        "operationId": "getMachineServiceDocumentFile",
        "parameters": [
          {
            "in": "path",
            "name": "machineId",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "in": "path",
            "name": "serviceDocumentId",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "*/*": {
                "schema": {
                  "type": "string",
                  "format": "byte"
                }
              }
            },
            "description": "OK"
          },
          "404": {
            "content": {
              "*/*": {
                "schema": {
                  "type": "string",
                  "format": "byte"
                }
              }
            },
            "description": "Machine not found"
          },
          "500": {
            "content": {
              "*/*": {
                "schema": {
                  "type": "string",
                  "format": "byte"
                }
              }
            },
            "description": "Internal server error"
          }
        },
        "summary": "Download Service Document"
      }
    },
    "/models": {
      "get": {
        "deprecated": true,
        "description": "Get available machine models",
        "operationId": "getModels",
        "parameters": [
          {
            "description": "All key value pairs will be satisfied by each element in the result",
            "example": "brand::abc| category::digger",
            "in": "query",
            "name": "select",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "example": "weight::-| model",
            "in": "query",
            "name": "sort",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/hal+json": {
                "schema": {
                  "$ref": "#/components/schemas/ModelsRepresentation"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ModelsRepresentation"
                }
              }
            },
            "description": "OK"
          },
          "403": {
            "content": {
              "application/hal+json": {
                "schema": {
                  "$ref": "#/components/schemas/ModelsRepresentation"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ModelsRepresentation"
                }
              }
            },
            "description": "Unauthorized request or internal server error"
          }
        },
        "summary": "Get machine models",
        "tags": ["Machine metadata"]
      }
    }
  },
  "components": {
    "schemas": {
      "BrandRepresentation": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          }
        }
      },
      "BrandsRepresentation": {
        "type": "object",
        "properties": {
          "brands": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BrandRepresentation"
            }
          }
        }
      },
      "CategoriesRepresentation": {
        "type": "object",
        "properties": {
          "categories": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CategoryRepresentation"
            }
          }
        }
      },
      "CategoryRepresentation": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32"
          },
          "name": {
            "type": "string"
          }
        }
      },
      "ExtendedInformationRepresentation": {
        "type": "object",
        "properties": {
          "_links": {
            "$ref": "#/components/schemas/Links"
          },
          "extendedInformation": {
            "type": "object",
            "additionalProperties": {}
          }
        }
      },
      "ExtendedInformationUpdateRequest": {
        "type": "object",
        "properties": {
          "extendedInformation": {
            "type": "object",
            "additionalProperties": {}
          }
        },
        "required": ["extendedInformation"]
      },
      "Link": {
        "type": "object",
        "properties": {
          "deprecation": {
            "type": "string"
          },
          "href": {
            "type": "string"
          },
          "hreflang": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "profile": {
            "type": "string"
          },
          "templated": {
            "type": "boolean"
          },
          "title": {
            "type": "string"
          },
          "type": {
            "type": "string"
          }
        }
      },
      "Links": {
        "type": "object",
        "additionalProperties": {
          "$ref": "#/components/schemas/Link"
        }
      },
      "MachineRepresentation": {
        "type": "object",
        "properties": {
          "_links": {
            "$ref": "#/components/schemas/Links"
          },
          "brand": {
            "type": "string"
          },
          "category": {
            "type": "string"
          },
          "externalReference": {
            "type": "string"
          },
          "machineId": {
            "type": "integer",
            "format": "int32"
          },
          "model": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "ownedBy": {
            "type": "string"
          },
          "productionDate": {
            "type": "string",
            "format": "date"
          },
          "readOnlyFields": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "score": {
            "type": "number",
            "format": "double"
          },
          "unit": {
            "$ref": "#/components/schemas/UnitRepresentation"
          },
          "vin": {
            "type": "string"
          }
        }
      },
      "MachineUpdateRepresentation": {
        "type": "object",
        "properties": {
          "brand": {
            "type": "string"
          },
          "category": {
            "type": "string"
          },
          "externalReference": {
            "type": "string"
          },
          "machineId": {
            "type": "integer",
            "format": "int32"
          },
          "model": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "productionDate": {
            "type": "string",
            "format": "date"
          },
          "unit": {
            "$ref": "#/components/schemas/UnitRepresentation"
          },
          "vin": {
            "type": "string"
          }
        },
        "required": ["machineId"]
      },
      "MachinesRepresentation": {
        "type": "object",
        "properties": {
          "_links": {
            "$ref": "#/components/schemas/Links"
          },
          "machines": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MachineRepresentation"
            }
          }
        }
      },
      "MachinesRequest": {
        "type": "object",
        "properties": {
          "machineIds": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            }
          },
          "select": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "MachinesSummaryRepresentation": {
        "type": "object",
        "properties": {
          "_links": {
            "$ref": "#/components/schemas/Links"
          },
          "averageMachineScore": {
            "type": "number",
            "format": "double"
          },
          "machinesCount": {
            "type": "integer",
            "format": "int32"
          },
          "metadata": {
            "$ref": "#/components/schemas/MetadataSummaryRepresentation"
          }
        }
      },
      "MetadataSummaryRepresentation": {
        "type": "object",
        "description": "Summary of the metadata on the scoped machines",
        "properties": {
          "brandCount": {
            "type": "object",
            "additionalProperties": {
              "type": "integer",
              "format": "int32"
            }
          },
          "categoryCount": {
            "type": "object",
            "additionalProperties": {
              "type": "integer",
              "format": "int32"
            }
          },
          "completedMachinesCount": {
            "type": "integer",
            "format": "int32",
            "description": "Number of machines in scope that has complete metadata, meaning brand, category, model and production date"
          },
          "modelCount": {
            "type": "object",
            "additionalProperties": {
              "type": "integer",
              "format": "int32"
            }
          },
          "productionYearCount": {
            "type": "object",
            "additionalProperties": {
              "type": "integer",
              "format": "int32"
            }
          }
        }
      },
      "ModelRepresentation": {
        "type": "object",
        "properties": {
          "model": {
            "type": "string"
          },
          "weight": {
            "type": "number",
            "format": "double"
          }
        }
      },
      "ModelsRepresentation": {
        "type": "object",
        "properties": {
          "models": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ModelRepresentation"
            }
          }
        }
      },
      "ServiceDocumentRepresentation": {
        "type": "object",
        "properties": {
          "_links": {
            "$ref": "#/components/schemas/Links"
          },
          "fileName": {
            "type": "string"
          },
          "id": {
            "type": "integer",
            "format": "int32"
          },
          "name": {
            "type": "string"
          }
        }
      },
      "ServiceDocumentsRepresentation": {
        "type": "object",
        "properties": {
          "serviceDocuments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ServiceDocumentRepresentation"
            }
          }
        }
      },
      "UnitRepresentation": {
        "type": "object",
        "properties": {
          "serialNumber": {
            "type": "string"
          },
          "unitId": {
            "type": "integer",
            "format": "int32"
          }
        }
      }
    },
    "securitySchemes": {
      "authorizationBearer": {
        "bearerFormat": "JWT",
        "scheme": "bearer",
        "type": "http"
      }
    }
  }
}
