openapi: 3.0.1
info:
  title: QuickLink API
  description: >-
    This API functions as a proxy to the Artifactory API. It provides endpoints
    to query and download artifacts from Artifactory.
  version: 1.0.0
servers:
  - url: https://quicklink-api.milwaukeetool.com/v1/artifactory
tags:
  - name: Artifactory API
    description: Endpoints to query and download artifacts from Artifactory
paths:
  /artifacts:
    get:
      tags:
        - Artifactory API
      summary: Get Artifacts
      description: >-
        This endpoint uses the Artifactory API to query both the FW_Releases and
        cluster-releases repositories for all the released artifacts for a given
        Part Number and Product ID combination.
      parameters:
        - name: productId
          in: query
          required: true
          schema:
            type: string
          description: The product ID to filter artifacts.
        - name: partNumber
          in: query
          required: false
          schema:
            type: string
          description: The part number to filter artifacts.
        - name: production
          in: query
          required: false
          schema:
            type: boolean
          description: >-
            Filter for production artifacts, useful if trying to search for
            non-released artifacts.
        - name: hardwareVersion
          in: query
          required: false
          schema:
            type: string
          description: Filter artifacts by bootloader hardware version.
      responses:
        '200':
          description: Returns a list of artifacts.
          content:
            application/json:
              schema:
                type: array
                items:
                  type: object
                  properties:
                    repo:
                      type: string
                    path:
                      type: string
                    name:
                      type: string
                    size:
                      type: number
                    created:
                      type: string
                      description: Formatted as a date string in ISO 8601.
                    modified:
                      type: string
                      description: Formatted as a date string in ISO 8601.
                    version:
                      type: string
                      description: >-
                        The version of the artifact is formatted as
                        revision.major.minor.sub-minor.
                    firmwareMatchSet:
                      type: array
                      items:
                        type: object
                        properties:
                          productId:
                            type: string
                            nullable: true
                          nodeId:
                            type: integer
                          softwarePartNumber:
                            type: integer
                          version:
                            type: string
                    nodeId:
                      type: integer
                      nullable: true
                      description: The CANopen node ID associated with the artifact.
                    changeNoteSummary:
                      type: string
                      nullable: true
                      description: A summary of changes included in this artifact version.
                    compatibleProductIds:
                      type: array
                      items:
                        type: string
        '400':
          description: Invalid request parameters.
        '500':
          description: An error occurred while processing the request.
      security:
        - auth0-authorizer: []
  /artifact/download:
    get:
      tags:
        - Artifactory API
      summary: Download Artifact
      description: >-
        This endpoint uses the Artifactory API to query for the details of an
        artifact and downloads it. If the artifact is a zip file, it extracts
        and returns the binary (*.bin) file from the bundle. Non-zip artifacts
        are returned as raw binary data without extraction.
      parameters:
        - name: artifact
          in: query
          required: true
          schema:
            type: string
          description: The name of the artifact to download.
        - name: path
          in: query
          required: true
          schema:
            type: string
          description: The path of the repository where the artifact is located.
        - name: isBle
          in: query
          required: false
          schema:
            type: boolean
          description: >-
            When true, extracts BLE-specific firmware from the zip bundle
            instead of the standard .bin file.
        - name: imageType
          in: query
          required: false
          schema:
            type: integer
            enum:
              - 0
              - 1
          description: >-
            Required when isBle is true. 0 for apploader-signed-encrypted, 1 for
            application-signed-encrypted.
        - name: repo
          in: query
          required: false
          schema:
            type: string
          description: >-
            Overrides the default repository (FW_Releases) used for the
            download.
      responses:
        '200':
          description: Returns the binary file of the artifact.
          content:
            application/octet-stream:
              schema:
                type: string
                format: binary
        '400':
          description: Invalid request parameters.
        '404':
          description: Artifact not found.
        '500':
          description: An error occurred while processing the request.
      security:
        - auth0-authorizer: []
  /latest:
    get:
      tags:
        - Artifactory API
      summary: Get Most Recent Artifact
      description: >-
        This endpoint uses the Artifactory API to query the repository for the
        most recently released artifact for a given Part Number and Product ID
        combination. It only returns artifacts with release type "production
        candidate" and filters by the @firmware_part Artifactory property
        specifically (not @raw_firmware_part or @part_number). This endpoint
        uses an environment-specific repository and connects via the Artifactory
        edge server.
      parameters:
        - name: productId
          in: query
          required: true
          schema:
            type: string
          description: The product ID to filter artifacts.
        - name: partNumber
          in: query
          required: true
          schema:
            type: string
          description: The part number to filter artifacts.
      responses:
        '200':
          description: Returns a list of artifacts.
          content:
            application/json:
              schema:
                type: object
                properties:
                  url:
                    type: string
                  size:
                    type: number
                  created:
                    type: string
                    description: Formatted as a date string in ISO 8601.
                  modified:
                    type: string
                    description: Formatted as a date string in ISO 8601.
                  version:
                    type: string
                    description: >-
                      The version of the artifact is formatted as
                      revision.major.minor.sub-minor.
              examples:
                'Example: Get Latest Artifact Response':
                  $ref: '#/components/examples/getLatestArtifactory'
        '400':
          description: Invalid request parameters.
        '404':
          description: No artifactory package found.
        '500':
          description: An error occurred while processing the request.
components:
  securitySchemes:
    auth0-authorizer:
      type: oauth2
      flows: {}
      x-amazon-apigateway-authorizer:
        identitySource: $request.header.Authorization
        jwtConfiguration:
          audience:
            - https://tooldata-api-test.milwaukeetool.com/
            - onekeyapi.milwaukeetool.com
          issuer: https://idtest.milwaukeetool.com/
        type: jwt
  examples:
    getLatestArtifactory:
      value:
        url: https://example.com/artifact/12345
        size: 124929
        created: '2023-02-17T00:09:53.421Z'
        modified: '2023-02-17T00:09:53.196Z'
        version: 37.2.1.24
