openapi: 3.0.1
servers:
  - url: https://lgtm.com/api/v1.0
x-hasEquivalentPaths: true
info:
  description: |
    The REST API for LGTM provides data so that you can customize how you integrate LGTM analysis into your workflow. It includes the following resources:
      * `/` ([API root](https://lgtm.com/help/lgtm/api/api-v1#LGTM-API-specification-API-root))&mdash;get version information or download the specification in OpenAPI format.
      * `/projects` ([Projects](https://lgtm.com/help/lgtm/api/api-v1#LGTM-API-specification-Projects))&mdash;list projects, get a summary of the current status for a project, or add new projects.
      * `/analyses` ([Analyses](https://lgtm.com/help/lgtm/api/api-v1#LGTM-API-specification-Analyses))&mdash;get a summary of results, download all the alerts, or trigger analysis for a specific commit.
      * `/codereviews` ([Code reviews](https://lgtm.com/help/lgtm/api/api-v1#LGTM-API-specification-Code-reviews))&mdash;trigger code review for a patch, and view the results.
      * `/operations` ([Operations](https://lgtm.com/help/lgtm/api/api-v1#LGTM-API-specification-Operations))&mdash;get information about long-running tasks, for example, analyses or code reviews that you've requested.
      * `/snapshots` ([Snapshots](https://lgtm.com/help/lgtm/api/api-v1#LGTM-API-specification-Snapshots))&mdash;download and upload databases representing a snapshot of a codebase.
      * `/queryjobs` ([Query jobs](https://lgtm.com/help/lgtm/api/api-v1#LGTM-API-specification-Query-jobs))&mdash;submit queries to evaluate against existing projects, and download their results.
      * `/system` ([System](https://lgtm.com/help/lgtm/api/api-v1#LGTM-API-specification-System))&mdash;get information on the health or usage of the system.

    For an overview and getting started topics, see [API for LGTM](https://lgtm.com/help/lgtm/api/api-for-lgtm).
  title: LGTM API specification
  version: v1.0
  x-apisguru-categories:
    - developer_tools
  x-origin:
    - format: openapi
      url: https://lgtm.com/api/v1.0/openapi
      version: "3.0"
  x-providerName: lgtm.com
tags:
  - description: |
      The `/` endpoints are used to get information about the API:
        * [Get the API version number](https://lgtm.com/help/lgtm/api/api-v1#opIdgetVersion) for the LGTM server.
        * [View the API specification](https://lgtm.com/help/lgtm/api/api-v1#opIdgetSpec) in [OpenAPI format](https://github.com/OAI/OpenAPI-Specification).
    name: API root
  - description: |
      The `/projects` endpoints are used to interact with projects:
        * [List the projects](https://lgtm.com/help/lgtm/api/api-v1#opIdgetProjects) available to the current user.
        * Get the latest summary for a specific project [by identifier](https://lgtm.com/help/lgtm/api/api-v1#opIdgetProject), 
        or by [URL identifier](https://lgtm.com/help/lgtm/api/api-v1#opIdgetProjectByUrlIdentifier).
        * LGTM administrators only, [add projects](https://lgtm.com/help/lgtm/api/api-v1#opIdaddProject) to LGTM.
    name: Projects
  - description: |
      Most of the `/analyses` endpoints are used to retrieve the results of analyzing a commit:
        * [Get the *analysis* identifier and results summary for the latest or a specific commit](https://lgtm.com/help/lgtm/api/api-v1#opIdgetAnalysisForCommit).
        * [Get the *commit* identifier and results summary for a specific analysis](https://lgtm.com/help/lgtm/api/api-v1#opIdgetAnalysis).
        * [Download the full results for a specific analysis](https://lgtm.com/help/lgtm/api/api-v1#opIdgetAlerts).

       You can also use this end point to trigger the analysis of a commit that hasn't previously been analyzed.
       For more information, see [Run analysis of a specific commit](https://lgtm.com/help/lgtm/api/api-v1#opIdrequestAnalysis).
    name: Analyses
  - description: |
      The `/codereviews` endpoint is used to trigger a patch code review and request the results:
        * [Trigger the review of a patch](https://lgtm.com/help/lgtm/api/api-v1#opIdrequestReview).
        * [Get the results of a completed code review](https://lgtm.com/help/lgtm/api/api-v1#opIdgetCodeReview).
    name: Code reviews
  - description: |
      The `/operations` endpoint is used to track the progress of long-running tasks,  for example, code review requests. For more information, see [Get operation status](https://lgtm.com/help/lgtm/api/api-v1#opIdgetOperation).
    name: Operations
  - description: |
      The `/snapshots` endpoint is used to download databases, representing a snapshot of the code, to analyze in your IDE.  LGTM administrators can also use it to upload externally-built databases to LGTM.
    name: Snapshots
  - description: |
      The `/system` endpoint is used to retrieve information about the status of the system: 
        * Get the [system health](https://lgtm.com/help/lgtm/api/api-v1#opIdgetHealth).
        * LGTM administrators only, get the [list of usage metrics](https://lgtm.com/help/lgtm/api/api-v1#opIdgetMetrics).
        * LGTM administrators only, get the [values of a given metric](https://lgtm.com/help/lgtm/api/api-v1#opIdgetMetric)
    name: System
  - description: |
      The `/queryjobs` endpoint is used to run CodeQL queries on LGTM and check their progress.
        * [Create a new query job](https://lgtm.com/help/lgtm/api/api-v1#opIdcreateQueryJob).
        * Get an overview of the [progress of the query job](https://lgtm.com/help/lgtm/api/api-v1#opIdgetQueryJob).
        * Get a [summary of the results](https://lgtm.com/help/lgtm/api/api-v1#opIdgetQueryJobResultsOverview) for the query job.
        * Download the [results for a specific project](https://lgtm.com/help/lgtm/api/api-v1#opIdgetQueryJobResultsForProject).
    name: Query jobs
paths:
  /:
    get:
      description: Get the version information of this API.
      operationId: getVersion
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/version"
          description: Success. Requested data returned.
      security:
        - access-token: []
      summary: Version information
      tags:
        - API root
      x-auth-mode: UNRESTRICTED
  "/analyses/{analysis-id}":
    get:
      description: |
        Get a summary of the analysis results for a specific analysis identifier.

        To find the analysis identifier for a commit, use the `/analyses/{project-id}/commits/{commit-id}` endpoint. For more information, see [Get analysis summary for a specific commit](https://lgtm.com/help/lgtm/api/api-v1#opIdgetAnalysisForCommit).

        This endpoint reports the commit analyzed and a summary of the results for each language. Alternatively, you can use this identifier to download full details  of all the alerts found by the analysis. For more information, see [Get detailed alert information](https://lgtm.com/help/lgtm/api/api-v1#opIdgetAlerts).
      operationId: getAnalysis
      parameters:
        - description: The analysis identifier.
          explode: false
          in: path
          name: analysis-id
          required: true
          schema:
            maxLength: 40
            minLength: 40
            pattern: "[a-f0-9]+"
            type: string
          style: simple
      responses:
        "200":
          content:
            application/json:
              examples:
                analysisExample:
                  $ref: "#/components/examples/analysisExample"
              schema:
                $ref: "#/components/schemas/analysis"
          description: Success. Requested data returned.
      security:
        - access-token: []
      summary: Get analysis summary
      tags:
        - Analyses
      x-auth-mode: BINARY
  "/analyses/{analysis-id}/alerts":
    get:
      description: |
        Download all the alerts found by an analysis.
        Use the `Accept:` request header to specify the output media type as either CSV or [SARIF](https://lgtm.com/help/lgtm/sarif-results-file): 

        - `application/sarif+json`: Alerts in SARIF format. If no version is specified the latest supported SARIF version is used.
        - `application/json`: Alerts in SARIF format (*deprecated*). 
          If no version is specified, [SARIF 2.0.0](http://docs.oasis-open.org/sarif/sarif/v2.0/sarif-v2.0.html) 
          is used for backwards compatibility.

        - `text/csv`: Alerts in CSV format. The `text/csv` media type has two optional parameters:
           - `charset`: determines the character encoding of the text, by default UTF-8.
           - `header`: determines whether a header row with column names is `present` or `absent`.
              The default value for this parameter is `present`.
              For example, an Accept header with value `text/csv; header=absent` 
              would result in CSV output without a header row.
            



        To find the analysis identifier for a commit, use the `/analyses/{project-id}/commits/{commit-id}`  endpoint. For more information, see [Get analysis summary for a specific commit](https://lgtm.com/help/lgtm/api/api-v1#opIdgetAnalysisForCommit). 
      operationId: getAlerts
      parameters:
        - description: The analysis identifier.
          explode: false
          in: path
          name: analysis-id
          required: true
          schema:
            type: string
          style: simple
        - description: The desired version of the SARIF format. Currently supported versions are `1.0.0`, `2.0.0`, and `2.1.0`.
          explode: true
          in: query
          name: sarif-version
          required: false
          schema:
            type: string
          style: form
        - description: Set `true` to include results in files that are excluded from the output by default. This includes results in test code and generated files. For more information, see [File classification](https://lgtm.com/help/lgtm/file-classification).
          explode: true
          in: query
          name: excluded-files
          required: false
          schema:
            default: false
            type: boolean
          style: form
      responses:
        "200":
          content:
            application/json:
              examples: {}
              schema:
                deprecated: true
                type: object
            application/sarif+json:
              examples: {}
              schema:
                type: object
            text/csv:
              examples: {}
              schema:
                type: string
          description: Success. Requested data returned.
      security:
        - access-token: []
      summary: Get detailed alert information
      tags:
        - Analyses
      x-auth-mode: BINARY
  "/analyses/{project-id}":
    post:
      description: |
        Trigger the analysis of a specific commit to a project. If a previous attempt to analyze that commit failed, this triggers a fresh analysis.  This is supported for all LGTM projects, regardless of repository type or host. The commit must be available in the main repository, but can be on a branch that isn't tracked by LGTM. For both LGTM.com and LGTM Enterprise, you must include an access token with the `analyses:write` scope.

        When you request the analysis of a commit, the API returns:
        - `operation-id`: used to track the status of the task using the `/operations` endpoint. For more information, see [Get operation status](https://lgtm.com/help/lgtm/api/api-v1#opIdgetOperation).
        - `status`: initially pending.
        - `task-result`: containing information about the progress and results of the analysis.
      operationId: requestAnalysis
      parameters:
        - description: The numeric project identifier.
          explode: false
          in: path
          name: project-id
          required: true
          schema:
            format: int64
            type: integer
          style: simple
        - description: The identifier of the commit to analyze.
          explode: true
          in: query
          name: commit
          required: true
          schema:
            type: string
          style: form
        - description: |
            The language codes of the languages to analyze.
            For a list of available languages, see [Supported languages](https://lgtm.com/help/lgtm/analysis-faqs#which-languages-are-supported). To specify more than one language, this parameter can be repeated. If no language is specified, all the project's languages will be analyzed.
          explode: true
          in: query
          name: language
          required: false
          schema:
            items:
              type: string
            maxItems: 10
            type: array
          style: form
      responses:
        "202":
          content:
            application/json:
              examples:
                analysisRequestExample:
                  $ref: "#/components/examples/analysisRequestExample"
              schema:
                $ref: "#/components/schemas/operation"
          description: Accepted. Analysis triggered. Tracking data returned.
      security:
        - access-token: []
      summary: Run analysis of a specific commit
      tags:
        - Analyses
      x-auth-mode: BINARY
  "/analyses/{project-id}/commits/{commit-id}":
    get:
      description: |
        Get a summary of the analysis results for a specific commit, or the latest commit, to a project. (For projects configured for sparse or upload analysis, only `latest` is supported.) 

        This endpoint reports a summary of results for each language, and also the analysis identifier. You can use the analysis identifier to download full details of all the alerts  found by the analysis. For more information, see [Get detailed alert information](https://lgtm.com/help/lgtm/api/api-v1#opIdgetAlerts).
      operationId: getAnalysisForCommit
      parameters:
        - description: The numeric project identifier.
          explode: false
          in: path
          name: project-id
          required: true
          schema:
            format: int64
            type: integer
          style: simple
        - description: The identifier of a specific commit. Alternatively, use `latest` for the most recent analyzed commit.
          explode: false
          in: path
          name: commit-id
          required: true
          schema:
            type: string
          style: simple
      responses:
        "200":
          content:
            application/json:
              examples:
                analysisExample:
                  $ref: "#/components/examples/analysisExample"
              schema:
                $ref: "#/components/schemas/analysis"
          description: Success. Data returned.
      security:
        - access-token: []
      summary: Get analysis summary for a specific commit
      tags:
        - Analyses
      x-auth-mode: BINARY
  "/codereviews/{project-id}":
    post:
      description: |
        Trigger the code review of a patch. This is available for projects with Git repositories.

        Your request must include:

          * Identifier for the base commit
          * Patch generated using `git diff --binary` (see [git diff](https://git-scm.com/docs/git-diff))
          * Header `Content-Type: application/octet-stream`
          * For both LGTM.com and LGTM Enterprise, an access token with the `codereviews:write` scope

        Note that if you make a request using Curl, you'll also need to add `--data-binary` to the request to ensure that the patch you supply in the body is sent with newlines unchanged.
        You can track the progress of the review using the task result URL returned on creation of the task, or by calling the `/operations` endpoint with the operations identifier returned by the request. For more information, see [Get operation status](https://lgtm.com/help/lgtm/api/api-v1#opIdgetOperation). Alternatively, if you supply a callback URL you'll get a post-back automatically on completion of the review.

        When the review is complete, you can access the results using the task result URL.
      operationId: requestReview
      parameters:
        - description: The numeric project identifier.
          explode: false
          in: path
          name: project-id
          required: true
          schema:
            format: int64
            type: integer
          style: simple
        - description: The identifier for the base commit.
          explode: true
          in: query
          name: base
          required: true
          schema:
            type: string
          style: form
        - description: Your reference number for the code review.
          example: integer
          explode: true
          in: query
          name: external-id
          required: true
          schema:
            format: int32
            type: integer
          style: form
        - description: An informative back-link to an external system.
          explode: true
          in: query
          name: review-url
          required: false
          schema:
            type: string
          style: form
        - description: |
            The callback URL for LGTM to post to on completion of the review.
            When the code review is complete, the API sends an HTTP POST request to the callback URL with the result of the code review in the request body. The code review results in the request body are identical to the results accessed through the [`/codereviews/{review-id}`](https://lgtm.com/help/lgtm/api/api-v1#opIdgetCodeReview) end-point.
            If you specify a `callback-secret`, the request also includes an `x-lgtm-signature` header with a digital signature of the request's contents.
          explode: true
          in: query
          name: callback-url
          required: false
          schema:
            type: string
          style: form
        - description: |
            The `callback-secret` is used to compute a signature which is included in the `x-lgtm-signature` header of the callback response.
            The receiver of the callback can check the validity of the response by computing the signature using HMAC-SHA1 and verifying that it matches the `x-lgtm-signature` header value.
            The HMAC algorithm requires byte sequences as inputs for both the secret and the message. The callback secret string must be converted to bytes using UTF-8 encoding. The response body should ideally be read as a plain byte sequence. Conversion to, for example a JSON object, and back to a byte sequence might change the formatting, and would invalidate the signature.
          explode: true
          in: query
          name: callback-secret
          required: false
          schema:
            type: string
          style: form
      requestBody:
        content:
          application/octet-stream:
            examples:
              patchFile:
                description: |
                  The request body must contain a patch file generated using `git diff --binary`, see [git diff](https://git-scm.com/docs/git-diff), for example:
                  ```text
                    diff --git a/describe.c b/describe.c
                    index db827ffaba..510eaf4866 100644
                    --- a/describe.c
                    +++ b/describe.c
                    @@ -132,7 +132,8 @@ void describe(char *arg)
                        if (n) {
                          printf("%s-g%s\n", n->path,
                                find(cmit->key, abbrev));
                    -     clear(cmit, SEEN);
                    +     if (!last_one)
                    +       clear(cmit, SEEN);
                          return;
                        }
                      }
                  ```
                value: The contents of a binary patch file
            schema:
              format: binary
              type: string
        description: The patch containing the code changes for review.
        required: true
      responses:
        "202":
          content:
            application/json:
              examples:
                requestcode-reviewExample:
                  $ref: "#/components/examples/requestcode-reviewExample"
              schema:
                $ref: "#/components/schemas/operation"
          description: Accepted. Code review triggered. Tracking data returned.
      security:
        - access-token: []
      summary: Run code review for a patch
      tags:
        - Code reviews
      x-auth-mode: BINARY
  "/codereviews/{review-id}":
    get:
      description: |
        Get the results of a code review using the review identifier for the task.

        When you request a code review, the response includes a task result URL of the form: `/codereviews/{review-id}`.

        This endpoint reports the results of a complete code review, or the status of a review  that's still in progress.
      operationId: getCodeReview
      parameters:
        - description: The identifier for the review (from the `task-result-url`).
          explode: false
          in: path
          name: review-id
          required: true
          schema:
            type: string
          style: simple
      responses:
        "200":
          content:
            application/json:
              examples:
                code-review:
                  description: A successful code review with 1 fixed alert.
                  summary: A successful code review
                  value:
                    id: b45e291e7033460949ec986153c5416d22157d3e
                    languages:
                      - alerts:
                          - fixed: 1
                            new: 0
                            query:
                              id: 3717280014
                              language: javascript
                              name: Duplicate switch case
                              pack: com.lgtm/javascript-queries
                              properties:
                                id: js/duplicate-switch-case
                                name: Duplicate switch case
                                severity: warning
                                tags:
                                  - maintainability
                                  - correctness
                                  - external/cwe/cwe-561
                              url: https://lgtm.example.com/rules/3717280014/
                        fixed: 1
                        language: javascript
                        new: 0
                        status: success
                        status-message: 1 fixed alert
                    results-url: https://lgtm.example.com/projects/g/yarnpkg/yarn/rev/pr-b45e291e7033460949ec986153c5416d22157d3e
                    status: success
                    status-message: Analysis succeeded
              schema:
                items:
                  $ref: "#/components/schemas/code-review"
                type: array
          description: Success. Requested data returned.
      security:
        - access-token: []
      summary: Get results of code review
      tags:
        - Code reviews
      x-auth-mode: BINARY
  "/issues/{project-id}/{alert-key}":
    get:
      description: |
        Fetch the alert information for an issue in [SARIF](https://lgtm.com/help/lgtm/sarif-results-file) format.
      operationId: getIssue
      parameters:
        - description: The numeric project identifier.
          explode: false
          in: path
          name: project-id
          required: true
          schema:
            format: int64
            type: integer
          style: simple
        - description: |
            The alert key is generated by LGTM when it posts an issue `create` webhook request 
             to an external system using the [issue tracker Webhook API](https://lgtm.com/admin/help/issuetracker-webhook-api).
             This key is an opaque identifier that tracks the alert's location over time. For example, if a file containing the alert
             is modified, the SARIF data will reflect the updated location of the alert.
             Note that the key needs to be URL encoded as it may contain characters that are not web-safe.  
          example: +ja0cf6+84AGgat15W1jooeMfUY=
          explode: false
          in: path
          name: alert-key
          required: true
          schema:
            type: string
          style: simple
      responses:
        "200":
          content:
            application/sarif+json:
              examples: {}
              schema:
                type: object
          description: Success. Requested data returned.
      security:
        - access-token: []
      summary: Get detailed alert information for an issue
      tags:
        - Issues
      x-auth-mode: BINARY
  /openapi:
    get:
      description: Get the specification of this API in [OpenAPI](https://github.com/OAI/OpenAPI-Specification) format. This endpoint does not require an access token. This makes it easier for you to use the specification with third-party tools.
      operationId: getSpec
      responses:
        "200":
          content:
            application/json:
              examples: {}
              schema:
                type: object
          description: Success. Requested data returned.
      summary: API specification
      tags:
        - API root
      x-auth-mode: UNRESTRICTED
  "/operations/{operation-id}":
    get:
      description: |
        Track progress of a long-running operation using the operations identifier returned when you  created the operation. For example, by triggering the analysis of a commit, or the code review of a patch. For both LGTM.com and LGTM Enterprise, you must include an access token with the `operations:read` scope.
      operationId: getOperation
      parameters:
        - description: The operation identifier returned on creating the task.
          explode: false
          in: path
          name: operation-id
          required: true
          schema:
            format: int64
            type: integer
          style: simple
      responses:
        "200":
          content:
            application/json:
              examples:
                analysisOperationExample:
                  $ref: "#/components/examples/analysisOperationExample"
              schema:
                $ref: "#/components/schemas/operation"
          description: Success. Requested data returned.
      security:
        - access-token: []
      summary: Get operation status
      tags:
        - Operations
      x-auth-mode: BINARY
  /projects:
    get:
      description: |
        List all the projects the current user has authorization to view. 

        A maximum of 100 projects are returned in each response. When further results are available, the response includes the URL you need to request the next page of results.

        Use the optional parameter, `limit`, to change the number of results reported in each response (range of 1&mdash;100). If you supply an invalid value for this  parameter, the default value of 100 is used.

        When more than one page of results is available, each response includes a `nextPageUrl` response parameter. You can use this URL to request the next page of results. The `nextPageUrl` includes an automatically generated `start` parameter, which specifies the projects to return in the next page of results.
      operationId: getProjects
      parameters:
        - description: The maximum number of projects to return in each response (1-100).
          explode: true
          in: query
          name: limit
          required: false
          schema:
            default: 100
            format: int32
            maximum: 100
            minimum: 1
            type: integer
          style: form
        - description: An opaque identifier generated by the API.
          explode: true
          in: query
          name: start
          required: false
          schema:
            type: string
          style: form
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/project-list"
          description: Success. Requested data returned.
      security:
        - access-token: []
      summary: List projects
      tags:
        - Projects
      x-auth-mode: FILTERING
    post:
      description: |
        LGTM administrators can add a new project to LGTM by providing a repository URL. By default, LGTM tries to build and analyze the project in the same way as for projects added through the user interface. If at least one language is successfully analyzed, and the repository doesn't already exist on LGTM, a new project is created. If the project already exists but your API call triggers a successful analysis  of additional languages, LGTM adds those languages to the project.

        You can configure how LGTM processes the project using query parameters to:
          * Specify the languages to analyze.
          * Create a new project in [sparse mode](https://help.semmle.com/lgtm-enterprise/user/help/analysis-faqs.html#what-is-sparse-analysis).
          * Create a new project in [upload mode](https://help.semmle.com/lgtm-enterprise/user/help/analysis-faqs.html#what-is-upload-analysis) to analyze externally-generated databases. Each database represents a snapshot of the codebase. 
          Use this option when you want to upload databases that were generated by the CodeQL CLI (or the QL command-line tools).
          The version of the command line used to generate the database
          must be the same version as LGTM Enterprise. 

        With any of these options, you can also include an `lgtm.yml` in the body of the request to [customize extraction](https://lgtm.com/help/lgtm/customizing-code-extraction).
      operationId: addProject
      parameters:
        - description: |-
            The URL of the repository to analyze.
            LGTM tests this against the [repository providers](https://lgtm.com/admin/help/adding-repository-providers) defined for the system. If it doesn't match any of them, the request fails.
          explode: true
          in: query
          name: repository
          required: true
          schema:
            format: uri
            type: string
          style: form
        - description: |
            Optional, a [language code](https://lgtm.com/help/lgtm/analysis-faqs#which-languages-are-supported) to specify which language to analyze.
            To request the analysis of more than one language, specify a query parameter for each language. By default, LGTM tries to analyze all supported languages.
          explode: true
          in: query
          name: language
          required: false
          schema:
            items:
              type: string
            type: array
          style: form
        - description: |
            The analysis mode of the new project.
            When set to `full` all commits of the project are analyzed; when set to `sparse` the latest commit of the project is analyzed periodically; when set to `upload`,  no automatic analysis is performed, instead externally-generated databases should be uploaded.
            For new projects the default value is `full`. The `mode` parameter cannot be used to change the analysis mode of existing projects. Therefore, for existing projects, it should either be left blank or set to match the analysis mode of the project.
          explode: true
          in: query
          name: mode
          required: false
          schema:
            enum:
              - full
              - sparse
              - upload
            type: string
          style: form
        - description: Required when `mode=upload`, specify the identifier of the commit used to generate the database.
          explode: true
          in: query
          name: commit
          required: false
          schema:
            type: string
          style: form
        - description: Optional when `mode=upload`, specify the date and time of the commit used to generate the database; defaults to the current time.
          explode: true
          in: query
          name: date
          required: false
          schema:
            format: date-time
            type: string
          style: form
        - description: |
            Optional, any [labels](https://lgtm.com/admin/help/defining-worker-labels) required by workers to analyze this project. 
            To specify more than one label, repeat the query parameter.
          explode: true
          in: query
          name: worker-label
          required: false
          schema:
            items:
              type: string
            type: array
          style: form
      requestBody:
        content:
          application/x-yaml:
            examples:
              lgtm_yml:
                description: |
                  An optional [lgtm.yml project configuration](https://lgtm.com/help/lgtm/lgtm.yml-configuration-file) file to customize the LGTM code analysis and results display for the project.
                value:
                  extraction:
                    java:
                      index:
                        build_command: ./build.sh
            schema:
              type: string
        description: An optional [lgtm.yml project configuration](https://lgtm.com/help/lgtm/lgtm.yml-configuration-file) file to customize the LGTM code analysis and results display for the project.
        required: false
      responses:
        "202":
          content:
            application/json:
              examples:
                externalOperationExample:
                  $ref: "#/components/examples/externalOperationExample"
              schema:
                $ref: "#/components/schemas/operation"
          description: Accepted. Analysis attempts triggered or upload URLs returned.
      security:
        - access-token: []
      summary: Add a project to LGTM
      tags:
        - Projects
      x-auth-mode: BINARY
  "/projects/{project-id}":
    delete:
      description: |
        Delete a project with a particular numeric project identifier.
        In addition to access to the project, administrative access to LGTM or the LGTM Enterprise instance is required to delete projects.
      operationId: deleteProject
      parameters:
        - description: The numeric project identifier
          explode: false
          in: path
          name: project-id
          required: true
          schema:
            format: int64
            minimum: 1
            type: integer
          style: simple
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/project-details"
          description: Success. Details of the deleted project returned.
      security:
        - access-token: []
      summary: Delete project by numeric identifier
      tags:
        - Projects
      x-auth-mode: BINARY
    get:
      description: |
        Get the latest summary for a specific project using the numeric project identifier.

        To find the LGTM identifier for a project, list all projects using the `/projects`  endpoint and look up the project by name. Alternatively, use the `/projects/{provider}/{org}/{name}` endpoint. If you have administration access, the project identifier is also displayed in  the administration page for the project.
      operationId: getProject
      parameters:
        - description: The numeric project identifier
          explode: false
          in: path
          name: project-id
          required: true
          schema:
            format: int64
            minimum: 1
            type: integer
          style: simple
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/project-details"
          description: Success. Requested data returned.
      security:
        - access-token: []
      summary: Get project by numeric identifier
      tags:
        - Projects
      x-auth-mode: BINARY
  "/projects/{project-id}/settings/analysis-configuration":
    get:
      description: Get the latest configuration for a specific project using the numeric project identifier.
      operationId: getProjectConfig
      parameters:
        - description: The numeric project identifier
          explode: false
          in: path
          name: project-id
          required: true
          schema:
            format: int64
            type: integer
          style: simple
        - description: |
            The type of project configuration to retrieve.
            If this parameter isn't specified, the request retrieves the effective configuration. That is, the configuration that is actually applied to the project, which may be from:
            * the repository
            * the administrator-set, project configuration
            * the global configuration.

            If you do specify this value, it must be one of:

             * `repository` to retrieve the configuration specified by a YAML file in the repository. A 404 status is returned if there is no repository configuration. 

             * `administrator` to retrieve the administrator-set, project configuration. A 404 status is returned if there is no administrator configuration.
          explode: true
          in: query
          name: source
          required: false
          schema:
            enum:
              - repository
              - administrator
            type: string
          style: form
      responses:
        "200":
          content:
            application/x-yaml:
              schema:
                type: object
          description: Success. Requested data returned.
        "400":
          content:
            application/json:
              schema:
                type: object
          description: Only YAML is supported.
      security:
        - access-token: []
      summary: Get configuration for a project identified by numeric identifier
      tags:
        - Projects
      x-auth-mode: BINARY
    put:
      description: Set the administrator configuration for a specific project using the numeric project identifier.
      operationId: setProjectConfig
      parameters:
        - description: The numeric project identifier
          explode: false
          in: path
          name: project-id
          required: true
          schema:
            format: int64
            type: integer
          style: simple
      requestBody:
        content:
          application/x-yaml:
            examples:
              snapshotPart:
                $ref: "#/components/examples/projectConfiguration"
            schema:
              type: string
        description: |
          The project configuration to set. Note that this only sets the administrator project configuration. It can be overridden by the repository configuration.
          In addition to access to the project, administrative access to LGTM or the LGTM Enterprise instance is required to set administrator project configurations.
        required: true
      responses:
        "200":
          content:
            application/x-yaml:
              schema:
                type: object
          description: Success. The new effective project configuration is returned.
      security:
        - access-token: []
      summary: Set the administrator configuration for a project identified by numeric identifier
      tags:
        - Projects
      x-auth-mode: BINARY
  "/projects/{provider}/{org}/{name}":
    get:
      description: |
        Get the latest summary for a specific project using the project's URL identifier `{provider}/{org}/{name}`.

        To find the URL identifier for a project, view the project overview page in LGTM. The URL identifier follows after `/projects`. For example, for a project with the URL `https://lgtm.example.com/projects/g/apache/commons-io` the URL identifier is `g/apache/commons-io`. In the example, `g` represents the `provider` (repository host), `apache` is the `organization` and `commons-io` is the `name` of the repository.
      operationId: getProjectByUrlIdentifier
      parameters:
        - description: The first part of the URL identifier of a project, which represents the repository host.
          explode: false
          in: path
          name: provider
          required: true
          schema:
            type: string
          style: simple
        - description: The second part of the URL identifier of a project, the organization.
          explode: false
          in: path
          name: org
          required: true
          schema:
            type: string
          style: simple
        - description: The third part of the URL identifier of a project, the repository name.
          explode: false
          in: path
          name: name
          required: true
          schema:
            type: string
          style: simple
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/project-details"
          description: Success. Requested data returned.
        "307":
          description: |
            Redirect. The project has been renamed. Request redirected to numeric identifier for the project.
      security:
        - access-token: []
      summary: Get project by URL identifier
      tags:
        - Projects
      x-auth-mode: BINARY
  /queryjobs:
    post:
      description: |
        Submit a query to run on one or more projects on LGTM. The query is included in the body of the request.
      operationId: createQueryJob
      parameters:
        - description: |
            The [language](https://lgtm.com/help/lgtm/analysis-faqs#which-languages-are-supported) you want to analyze.
          explode: true
          in: query
          name: language
          required: true
          schema:
            type: string
          style: form
        - description: The identifier of the project to analyze. Either `project-id` or `projects-list` must be specified.
          explode: true
          in: query
          name: project-id
          required: false
          schema:
            items:
              format: int64
              type: integer
            maxItems: 200
            minItems: 0
            type: array
          style: form
        - description: Name of the list containing the projects to analyze. Either `project-id` or `projects-list` must be specified.
          explode: true
          in: query
          name: projects-list
          required: false
          schema:
            type: string
          style: form
      requestBody:
        content:
          text/plain:
            examples:
              HelloWorld:
                description: A CodeQL query
                value: select "hello", "world"
            schema:
              description: The CodeQL query text
              type: string
        description: The query to run.
        required: true
      responses:
        "202":
          content:
            application/json:
              examples:
                runqueryExample:
                  $ref: "#/components/examples/queryjobsRequestExample"
              schema:
                $ref: "#/components/schemas/operation"
          description: Accepted. Query submitted. Tracking data returned.
      security:
        - access-token: []
      summary: Run a CodeQL query on one or more projects
      tags:
        - Query jobs
      x-auth-mode: BINARY
  "/queryjobs/{queryjob-id}":
    get:
      description: |
        Get the status of a query job using the query job identifier for the task.

        When you create a query job, the response includes a task result URL of the form: `/queryjobs/{queryjob-id}`.
      operationId: getQueryJob
      parameters:
        - description: The identifier of the query job, from the `task-result` given in the response to the initial `POST /queryjobs` request.
          explode: false
          in: path
          name: queryjob-id
          required: true
          schema:
            type: string
          style: simple
      responses:
        "200":
          content:
            application/json:
              examples:
                getqueryjobExample:
                  $ref: "#/components/examples/queryjobsResponseExample"
              schema:
                $ref: "#/components/schemas/queryjob"
          description: Success. Requested data returned.
      security:
        - access-token: []
      summary: Get the status of a query job
      tags:
        - Query jobs
      x-auth-mode: BINARY
  "/queryjobs/{queryjob-id}/results":
    get:
      description: |
        This endpoint provides a summary of the results generated by completed query runs for each  project specified in the the POST /queryjobs endpoint.  For completed query jobs, the summary includes:

          * The number of results for successful query runs.
          * Error information for failed query runs.

        No information is included in the response for any project for which the query  run is still in progress.
      operationId: getQueryJobResultsOverview
      parameters:
        - description: The identifier of the query job, from the `task-result` given in the response to the initial `POST /queryjobs` request.
          explode: false
          in: path
          name: queryjob-id
          required: true
          schema:
            type: string
          style: simple
        - description: |
            An opaque identifier generated by the API used for pagination. 
            This identifier will be included as part of the response for this endpoint whenever more than one page of results is available. 
          explode: true
          in: query
          name: start
          required: false
          schema:
            type: string
          style: form
        - description: The number of results to return. Useful for pagination.
          explode: true
          in: query
          name: limit
          required: false
          schema:
            default: 100
            format: int32
            type: integer
          style: form
        - description: Only return a subset of results. Legal values are `w-results`, `wo-results`, `error`.
          explode: true
          in: query
          name: filter
          required: false
          schema:
            type: string
          style: form
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/queryjob-results-overview"
          description: Success. Requested data returned.
      security:
        - access-token: []
      summary: Provide a summary of results for the projects in the query job
      tags:
        - Query jobs
      x-auth-mode: FILTERING
  "/queryjobs/{queryjob-id}/results/{project-id}":
    get:
      description: |
        Fetch the results for a specific project. The endpoint succeeds only if the query was successful,  and returns a `404` error otherwise.  By default, the endpoint provides only results that are within the source tree. To obtain all results, specify the `nofilter` parameter.
      operationId: getQueryJobResultsForProject
      parameters:
        - description: The identifier of the query job, from the `task-result` given in the response to the initial `POST /queryjobs` request.
          explode: false
          in: path
          name: queryjob-id
          required: true
          schema:
            type: string
          style: simple
        - description: The identifier for the project.
          explode: false
          in: path
          name: project-id
          required: true
          schema:
            type: string
          style: simple
        - description: Start point for the page of results.
          explode: true
          in: query
          name: start
          required: false
          schema:
            format: int32
            type: integer
          style: form
        - description: The maximum number of results to display (less than 100).
          explode: true
          in: query
          name: limit
          required: false
          schema:
            default: 100
            format: int32
            type: integer
          style: form
        - description: Include results that are not part of the source tree. These results are filtered out by default.
          explode: true
          in: query
          name: nofilter
          required: false
          schema:
            default: false
            type: boolean
          style: form
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/queryjob-project-results"
          description: "Success. The result contains three items: column headers, data, and pagination information."
      security:
        - access-token: []
      summary: Fetch the results of a query job for a specific project
      tags:
        - Query jobs
      x-auth-mode: BINARY
  "/snapshots/uploads/{session-id}":
    delete:
      description: |
        Aborts the specified upload session and deletes any uploaded parts. After the session is aborted it cannot be restarted.
        If any part uploads are in progress when the session is aborted, their data may not be deleted. To ensure that uploaded parts are deleted correctly, you should only abort an upload session after all part uploads have completed.
      operationId: abortUpload
      parameters:
        - description: The id of the upload session.
          explode: false
          in: path
          name: session-id
          required: true
          schema:
            type: string
          style: simple
      responses:
        "202":
          content:
            application/json:
              examples:
                abortUploadoperation:
                  description: A summary of the aborted upload session. Aborted sessions have an analysis status of `failure` in the API response and in LGTM.
                  summary: An aborted upload session.
                  value:
                    commit-id: 04d7a2300feec9bbcc48185e370e3b5d3ae4da9d
                    id: ec741d71eeb55250ddca33800f0ee06e77ccfd7f
                    languages:
                      - language: java
                        status: failure
                    log-url: https://lgtm.example.com/projects/g/apache/commons-io/logs/analysis/ec741d71eeb55250ddca33800f0ee06e77ccfd7f
                    project:
                      id: 1548859144386
                      name: apache/commons-io
                      url: https://lgtm.example.com/projects/g/apache/commons-io
                      url-identifier: g/apache/commons-io
                    results-url: https://lgtm.example.com/projects/g/apache/commons-io/analysis/ec741d71eeb55250ddca33800f0ee06e77ccfd7f/files
              schema:
                $ref: "#/components/schemas/operation"
          description: Aborted.
      security:
        - access-token: []
      summary: Abort database upload process
      tags:
        - Snapshots
      x-auth-mode: BINARY
    post:
      description: |
        Completes the database upload by closing the upload session, upgrading the database if appropriate, and scheduling analysis of that snapshot of the codebase.

        You can view the analysis progress and access the results using the `task-result-url`.
      operationId: completeUpload
      parameters:
        - description: The id of the upload session.
          explode: false
          in: path
          name: session-id
          required: true
          schema:
            type: string
          style: simple
      responses:
        "202":
          content:
            application/json:
              examples:
                analysisRequestExample:
                  $ref: "#/components/examples/analysisRequestExample"
              schema:
                $ref: "#/components/schemas/operation"
          description: Accepted. Analysis triggered. Tracking data returned.
      security:
        - access-token: []
      summary: Complete snapshot upload session
      tags:
        - Snapshots
      x-auth-mode: BINARY
    put:
      description: |
        Upload a database representing a snapshot of a codebase.  The database is sent in one or more parts. Each part is sent in the request body. 
        Use the [`POST /snapshots/{project-id}/{language}`](https://lgtm.com/help/lgtm/api/api-v1#opIdinitSnapshotUpload) endpoint  to start an upload session before uploading a database part. Database parts must have been generated and prepared for upload using the CodeQL CLI or the QL command-line tools. For further information on exporting externally-built databases,  see [Preparing snapshots to upload to LGTM](https://help.semmle.com/wiki/display/SD/Preparing+snapshots+to+upload+to+LGTM).

        Split large databases into multiple parts. Upload the parts by making a separate request for each part.  Don't upload the next part until you've successfully uploaded the previous part.

        If the upload fails you should retry it with the same data.
      operationId: uploadPart
      parameters:
        - description: The id of the upload session.
          explode: false
          in: path
          name: session-id
          required: true
          schema:
            type: string
          style: simple
      requestBody:
        content:
          application/octet-stream:
            examples:
              snapshotPart:
                $ref: "#/components/examples/snapshotPart"
            schema:
              format: binary
              type: string
          application/zip:
            examples:
              snapshotPart:
                $ref: "#/components/examples/snapshotPart"
            schema:
              format: binary
              type: string
        description: The database or database part to upload.
        required: true
      responses:
        "204":
          description: Success.
      security:
        - access-token: []
      summary: Upload snapshot
      tags:
        - Snapshots
      x-auth-mode: BINARY
  "/snapshots/{project-id}/{language}":
    get:
      description: |
        Download a CodeQL database from LGTM, representing a snapshot of the codebase, to run queries in your IDE.

        This endpoint works for projects that have been successfully analyzed for the language specified in the request.  A successful request redirects you to a URL for downloading a database that represents the code snapshot, as specified in the `Location:` header in the response. Therefore, your HTTP client should be configured to follow redirects. For example, if you are using `curl`, you can add the`-L` flag to the command.

        The database is downloaded as a zip file that can be imported into an IDE equipped with a  CodeQL extension. The extension must be up to date to analyze databases downloaded from LGTM. For more information on running queries locally in your IDE, see [Runnning queries in your IDE](https://lgtm.com/help/lgtm/running-queries-ide). 
      operationId: getSnapshot
      parameters:
        - description: The numeric project identifier.
          explode: false
          in: path
          name: project-id
          required: true
          schema:
            format: int64
            type: integer
          style: simple
        - description: The language of the database to download.
          explode: false
          in: path
          name: language
          required: true
          schema:
            type: string
          style: simple
      responses:
        "303":
          description: Redirects to a URL for downloading the CodeQL database as indicated by the `Location:` header.
          headers:
            Location:
              explode: false
              schema:
                format: uri
                type: string
              style: simple
      security:
        - access-token: []
      summary: Download a snapshot
      tags:
        - Snapshots
      x-auth-mode: BINARY
    post:
      description: |
        Start a session to upload an externally-built database (which represents a snapshot of a codebase) to a project on LGTM. 

        This endpoint works for projects that are already on LGTM, and the selected language of  the database must already be configured. The project must be configured with 'upload' analysis mode. You can upload a "bundled" CodeQL database or a database exported by  the QL command-line tools (`odasa`).

        If your database was generated using a version of the  command line that is older than LGTM,  LGTM will try to upgrade and analyze it when the upload is complete. You can include cached predicates in the upload, but they are ignored as the cache is  repopulated after the database has been upgraded and analyzed. However, if you want to include results with your database, make sure the database is  compatible before you start the upload session.  Incompatible databases with results won't be upgraded and therefore cannot be uploaded.  For further information on externally-built databases,  see [Preparing snapshots to upload to LGTM using the QL command-line tools](https://help.semmle.com/wiki/display/SD/Preparing+snapshots+to+upload+to+LGTM).

            
        When the upload session has been successfully started, upload the database to the  upload URL returned in the response. The database can be uploaded to the upload URL in parts using  the [`PUT /snapshots/uploads/{session-id}`](https://lgtm.com/help/lgtm/api/api-v1#opIduploadPart) endpoint. After uploading all the parts you must call  the [`POST /snapshots/uploads/{session-id}`](https://lgtm.com/help/lgtm/api/api-v1#opIdcompleteUpload) endpoint to complete the upload session.
      operationId: initSnapshotUpload
      parameters:
        - description: The numeric project identifier.
          explode: false
          in: path
          name: project-id
          required: true
          schema:
            format: int64
            type: integer
          style: simple
        - description: The language of the database to upload.
          explode: false
          in: path
          name: language
          required: true
          schema:
            type: string
          style: simple
        - description: The identifier of the analyzed commit.
          explode: true
          in: query
          name: commit
          required: true
          schema:
            type: string
          style: form
        - description: The date and time of the analyzed commit (default the current time).
          explode: true
          in: query
          name: date
          required: false
          schema:
            format: date-time
            type: string
          style: form
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/upload-session"
          description: Success.
      security:
        - access-token: []
      summary: Start snapshot upload session
      tags:
        - Snapshots
      x-auth-mode: BINARY
  /system/health:
    get:
      description: |
        Return an indication of whether the application is working as expected (up) or needs  attention (down). 
        \> The `description` and `details` fields are reported only if the request includes an access token for a user account that has administration rights for this LGTM server.
      operationId: getHealth
      responses:
        "200":
          content:
            application/json:
              examples:
                healthExample:
                  $ref: "#/components/examples/healthExample"
              schema:
                $ref: "#/components/schemas/health"
          description: The application is up.
        "503":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/health"
          description: The application is down.
      security:
        - access-token: []
      summary: Get a summary of the application's health
      tags:
        - System
      x-auth-mode: BINARY
  /system/metrics:
    get:
      description: |
        LGTM administrators can use this endpoint to list the usage metrics that are available to download.
      operationId: getMetrics
      responses:
        "200":
          content:
            application/json:
              examples:
                metricsExample:
                  $ref: "#/components/examples/metricsExample"
              schema:
                $ref: "#/components/schemas/metrics-list"
          description: The metric identifiers and descriptions are returned.
      security:
        - access-token: []
      summary: Get the identifiers and descriptions of the usage metrics
      tags:
        - System
      x-auth-mode: BINARY
  "/system/metrics/{metric-id}":
    get:
      description: |
        LGTM administrators can download usage data using this endpoint. The response includes up to 1000 values for the specified metric and reports the date-time that each value was calculated. There is normally one value per day.
      operationId: getMetric
      parameters:
        - description: The identifier of the metric.
          explode: false
          in: path
          name: metric-id
          required: true
          schema:
            type: string
          style: simple
      responses:
        "200":
          content:
            application/json:
              examples:
                metricExample:
                  $ref: "#/components/examples/metricExample"
              schema:
                $ref: "#/components/schemas/metric"
          description: Success. Requested data returned.
      security:
        - access-token: []
      summary: Get the computed values of the specified metric
      tags:
        - System
      x-auth-mode: BINARY
components:
  examples:
    analysisExample:
      description: A summary of the results of analysis. This includes links to the full results in LGTM and also to the log files generated during analysis.
      summary: A successful analysis
      value:
        commit-id: 04d7a2300feec9bbcc48185e370e3b5d3ae4da9d
        id: 2e65208b2f1872634132566a1a0ce6392407297c
        languages:
          - alerts: 139
            language: java
            lines: 101498
            status: success
          - alerts: 9
            language: javascript
            lines: 773
            status: success
        log-url: https://lgtm.example.com/projects/g/apache/struts/logs/analysis/2e65208b2f1872634132566a1a0ce6392407297c
        project:
          id: 123456789
          name: Apache Struts
          url: https://lgtm.example.com/projects/g/apache/struts
          url-identifier: g/apache/struts
        results-url: https://lgtm.example.com/projects/g/apache/struts/analysis/2e65208b2f1872634132566a1a0ce6392407297c/files
    analysisOperationExample:
      description: Example of the initial response for a request to view the status of an operation. The response includes the task type and a link to the log page for the task.
      summary: A successfully triggered task
      value:
        id: 1548841694385
        status: pending
        task-result:
          languages:
            - language: cpp
              status: pending
            - language: csharp
              status: pending
            - language: java
              status: pending
            - language: javascript
              status: pending
            - language: python
              status: pending
          log-url: https://lgtm.com/logs/29a7017f6000333419dbb9829865e5786b91843d
        task-type: analysis
    analysisRequestExample:
      description: An operation entry tracking a running analysis task.
      summary: A request for an analysis of a commit.
      value:
        id: 1508906426111
        status: pending
        task-result:
          commit-id: 559de2c461e94ab636c959149c775bb27111fb48
          id: 3d5a71d2b87880432aadb8166e79f984b3611fda
          languages:
            - language: javascript
              status: pending
            - language: java
              status: pending
          log-url: https://lgtm.com/projects/g/apache/commons-io/logs/analysis/3d5a71d2b87880432aadb8166e79f984b3611fda
          project:
            id: 38901173
            name: apache/commons-io
            url: https://lgtm.com/projects/g/apache/commons-io
            url-identifier: g/apache/commons-io
          results-url: https://lgtm.com/projects/g/apache/commons-io/analysis/3d5a71d2b87880432aadb8166e79f984b3611fda/files
        task-result-url: https://lgtm.com/api/v1.0/analyses/3d5a71d2b87880432aadb8166e79f984b3611fda
        task-type: analysis
    externalOperationExample:
      description: Example of the initial response for a task triggered by a request to add a project in `upload` mode for a repository with two languages. This includes the URLs where you should upload the two, externally-generated, databases for the project.
      summary: A successfully triggered task to add a project in `upload` mode.
      value:
        id: 1548865134385
        status: pending
        task-result:
          commit-id: c103e89d2151a9f83a1bab59e112a4bc41a8050d
          languages:
            - language: java
              status: pending
            - language: javascript
              status: pending
          log-url: https://lgtm.example.com/logs/a5cfe527b55cecc91c45dba658775d482177495b
        task-type: analysis
        uploads:
          java:
            id: 755e8beb6f33c1e7e6a70f8a30dfc0a2d62bbb70e2912e9668a563f21bbcd9fb
            url: https://lgtm.example.com/api/v1.0/snapshots/uploads/755e8beb6f33c1e7e6a70f8a30dfc0a2d62bbb70e2912e9668a563f21bbcd9fb
          javascript:
            id: a8dcd65757901312f53f55d1cde2461a280309683fe99b0b3982f47e8adb9a49
            url: https://lgtm.example.com/api/v1.0/snapshots/uploads/a8dcd65757901312f53f55d1cde2461a280309683fe99b0b3982f47e8adb9a49
    healthExample:
      description: |
        Example of a response for a system where all the core services are running well. Some of the worker services are not currently available to run tasks because  they are being provisioned or are booting up. The system can run `general` tasks but may not be able to run  `query` tasks that users request through the query console.
      summary: Response to a request that included an access token with the scope `system:read`.
      value:
        details:
          - database:
              status: UP
          - file_storage:
              status: UP
          - queue:
              status: UP
          - search:
              status: UP
          - workers:
              description: The status of the least healthy worker type is UNKNOWN
              details:
                - QUERY:
                    description: The status of the healthiest of these workers is UNKNOWN
                    details:
                      - query-001:
                          description: BOOTING
                          status: UNKNOWN
                    status: UNKNOWN
                - GENERAL:
                    description: The status of the healthiest of these workers is UP
                    details:
                      - general-001:
                          description: EXECUTING
                          status: UP
                      - general-002:
                          description: IDLE
                          status: UP
                      - general-003:
                          description: EXECUTING
                          status: UP
                      - general-004:
                          description: UNKNOWN
                          status: PROVISIONING
                    status: UP
              status: UNKNOWN
        status: UP
    metricExample:
      description: A time series of values for the metric.
      summary: A metric
      value:
        measurements:
          - timestamp: 2019-05-02T12:01:23.000+00:00
            value: 1357
          - timestamp: 2019-05-01T11:35:22.000+00:00
            value: 1234
        metric-id: active-users
    metricsExample:
      description: The list of identifiers (by which the various usage metrics can be referred to in the API), and their corresponding descriptions.
      summary: A list of metric identifiers and descriptions
      value:
        data:
          - description: Users who have used the LGTM web application in the past 180 days
            metric-id: active-users
          - description: Projects with Java analysis
            metric-id: java-projects
    projectConfiguration:
      description: The contents of the LGTM project configuration YAML.
      summary: An LGTM project configuration.
      value: |-
        path_classifiers:
          test:
            - test
    queryjobsRequestExample:
      description: An operation entry tracking a query job task.
      summary: Response to a request to run a query.
      value:
        id: 1508906426111
        status: pending
        task-result:
          $ref: "#/components/examples/queryjobsResponseExample"
        task-result-url: https://lgtm.com/api/v1.0/queryjobs/987654321
        task-type: queryjobs
    queryjobsResponseExample:
      description: |
        Example of the response to a request for the status of a running query job. The `stats` section reports the status for each project included in the query job. Use the `result-url` to see the results.
      summary: Status of a query job.
      value:
        id: b45e291e7033460949ec986153c5416d22157d3e
        result-url: https://lgtm.com/query/b45e291e7033460949ec986153c5416d22157d3e
        stats:
          failed: 1
          pending: 1
          success-with-result: 3
          success-without-result: 5
          successful: 8
    requestcode-reviewExample:
      description: A code review request, pending analysis for JavaScript.
      summary: A code review request.
      value:
        id: 1000013
        status: pending
        task-result:
          id: e866b685a22f5d644a3dc1c9c145f56aab7d4350
          languages:
            - alerts: []
              fixed: 0
              language: javascript
              new: 0
              status: pending
              status-message: Starting up
          results-url: https://lgtm.com/projects/g/Semmle/code/rev/pr-e866b685a22f5d644a3dc1c9c145f56aab7d4350
          status: pending
          status-message: Starting up
        task-result-url: https://lgtm.com/api/v1.0/codereviews/e866b685a22f5d644a3dc1c9c145f56aab7d4350
        task-type: codereview
    snapshotPart:
      description: |
        The request body must contain a database part that was generated and prepared for upload to LGTM using the CodeQL CLI or the QL command-line tools.  For more information, see [Preparing snapshots to upload to LGTM](https://help.semmle.com/wiki/display/SD/Preparing+snapshots+to+upload+to+LGTM). 
      value: The name of database file to upload.
  schemas:
    analysis:
      example:
        commit-id: 04d7a2300feec9bbcc48185e370e3b5d3ae4da9d
        id: 2e65208b2f1872634132566a1a0ce6392407297c
        languages:
          - alerts: 628
            analysis-date: 2000-01-23T04:56:07.000+00:00
            commit-date: 2000-01-23T04:56:07.000+00:00
            commit-id: 04d7a2300feec9bbcc48185e370e3b5d3ae4da9d
            language: javascript
            lines: 133298
            status: success
          - alerts: 628
            analysis-date: 2000-01-23T04:56:07.000+00:00
            commit-date: 2000-01-23T04:56:07.000+00:00
            commit-id: 04d7a2300feec9bbcc48185e370e3b5d3ae4da9d
            language: javascript
            lines: 133298
            status: success
        log-url: https://lgtm.example.com/projects/g/yarnpkg/yarn/logs/analysis/2e65208b2f1872634132566a1a0ce6392407297c
        project:
          id: 1234567
          name: Apache Commons IO
          url: https://lgtm.example.com/projects/g/apache/commons-io
          url-identifier: g/apache/commons-io
        results-url: https://lgtm.example.com/projects/g/yarnpkg/yarn/analysis/2e65208b2f1872634132566a1a0ce6392407297c/files
      properties:
        commit-id:
          description: |
            The commit identifier.
            The commit identifier is included only if the same commit was successfully analyzed for all languages. A detailed breakdown of which commit was analyzed for each language is provided in the `languages` property.
          example: 04d7a2300feec9bbcc48185e370e3b5d3ae4da9d
          type: string
        id:
          description: The analysis identifier.
          example: 2e65208b2f1872634132566a1a0ce6392407297c
          type: string
        languages:
          description: Per-language information.
          items:
            $ref: "#/components/schemas/language-stats"
          type: array
        log-url:
          description: A page on LGTM to view the logs for this analysis.
          example: https://lgtm.example.com/projects/g/yarnpkg/yarn/logs/analysis/2e65208b2f1872634132566a1a0ce6392407297c
          type: string
        project:
          $ref: "#/components/schemas/project"
        results-url:
          description: A page on LGTM to view the results of this analysis.
          example: https://lgtm.example.com/projects/g/yarnpkg/yarn/analysis/2e65208b2f1872634132566a1a0ce6392407297c/files
          type: string
      type: object
    code-review:
      example:
        id: b45e291e7033460949ec986153c5416d22157d3e
        languages:
          - alerts:
              - fixed: 1
                new: 0
                query:
                  name: Incomplete string escaping or encoding
            fixed: 1
            language: javascript
            new: 0
            status: success
            status-message: 1 fixed alert
        results-url: https://lgtm.example.com/projects/g/yarnpkg/yarn/rev/pr-b45e291e7033460949ec986153c5416d22157d3e
        status: success
        status-message: Analysis succeeded
      properties:
        id:
          description: The identifier for the review.
          example: b45e291e7033460949ec986153c5416d22157d3e
          type: string
        languages:
          description: Detailed information for each language analyzed.
          items:
            $ref: "#/components/schemas/codereview_languages"
          type: array
        results-url:
          description: A page on LGTM to view the status and results of this code review.
          example: https://lgtm.example.com/projects/g/yarnpkg/yarn/rev/pr-b45e291e7033460949ec986153c5416d22157d3e
          type: string
        status:
          description: The status of the code review.
          enum:
            - pending
            - failure
            - success
          example: success
          type: string
        status-message:
          description: A summary of the current status of the code review.
          example: Analysis succeeded
          type: string
      type: object
    codereview_alerts:
      properties:
        fixed:
          description: The number of alerts fixed by the patch for this query.
          example: 1
          format: int32
          type: integer
        new:
          description: The number of alerts introduced by the patch for this query.
          example: 0
          format: int32
          type: integer
        query:
          $ref: "#/components/schemas/query"
      type: object
    codereview_languages:
      properties:
        alerts:
          description: The list of added and fixed alerts per query for this language.
          items:
            $ref: "#/components/schemas/codereview_alerts"
          type: array
        fixed:
          description: The total number of alerts fixed by the patch for this language.
          example: 1
          format: int32
          type: integer
        language:
          description: The language analyzed.
          example: javascript
          type: string
        new:
          description: The total number of alerts introduced by the patch for this language.
          example: 0
          format: int32
          type: integer
        status:
          description: The status for analysis of this language.
          enum:
            - pending
            - failure
            - success
          example: success
          type: string
        status-message:
          description: The current state of analysis of this langauge. When available, a summary of analysis results.
          example: 1 fixed alert
          type: string
      type: object
    health:
      example:
        description: description
        details: {}
        status: UP
      properties:
        description:
          description: A description of the status of the service.
          type: string
        details:
          additionalProperties:
            $ref: "#/components/schemas/health"
          description: Details of the health of the service. This contains information about the status of the components on which the service depends.
          type: object
        status:
          description: The status of the service.
          enum:
            - UNKNOWN
            - UP
            - DOWN
          example: UP
          type: string
      type: object
    language-stats:
      example:
        alerts: 628
        analysis-date: 2000-01-23T04:56:07.000+00:00
        commit-date: 2000-01-23T04:56:07.000+00:00
        commit-id: 04d7a2300feec9bbcc48185e370e3b5d3ae4da9d
        language: javascript
        lines: 133298
        status: success
      properties:
        alerts:
          description: The number of alerts for this language.
          example: 628
          format: int32
          type: integer
        analysis-date:
          description: The time the commit was analyzed.
          format: date-time
          type: string
        commit-date:
          description: The time of the commit.
          format: date-time
          type: string
        commit-id:
          description: The latest successfully analyzed commit for the language. All statistics refer to this commit.
          example: 04d7a2300feec9bbcc48185e370e3b5d3ae4da9d
          type: string
        language:
          description: The short name for the language.
          example: javascript
          type: string
        lines:
          description: The number of lines of code for this language.
          example: 133298
          format: int32
          type: integer
        status:
          description: The status of the analysis of this language.
          enum:
            - success
            - failure
            - pending
          example: success
          type: string
      type: object
    measurement:
      example:
        timestamp: 2000-01-23T04:56:07.000+00:00
        value: 0.8008281904610115
      properties:
        timestamp:
          description: The date and time when this metric was computed.
          format: date-time
          type: string
        value:
          description: The value of this metric at the timestamp reported.
          type: number
      type: object
    metric:
      example:
        measurements:
          - timestamp: 2000-01-23T04:56:07.000+00:00
            value: 0.8008281904610115
          - timestamp: 2000-01-23T04:56:07.000+00:00
            value: 0.8008281904610115
        metric-id: metric-id
      properties:
        measurements:
          description: A time series of values taken by the metric at different timestamps.
          items:
            $ref: "#/components/schemas/measurement"
          type: array
        metric-id:
          description: The identifier by which this metric is referenced in the API.
          type: string
      type: object
    metric-name:
      example:
        description: description
        metric-id: metric-id
      properties:
        description:
          description: The name by which the metric is listed in the user interface.
          type: string
        metric-id:
          description: The identifier by which this metric is referenced in the API.
          type: string
      type: object
    metrics-list:
      example:
        data:
          - description: description
            metric-id: metric-id
          - description: description
            metric-id: metric-id
      properties:
        data:
          description: The list of names and identifiers by which the metrics are referenced.
          items:
            $ref: "#/components/schemas/metric-name"
          type: array
      type: object
    operation:
      example:
        id: 7654321
        status: pending
        task-result: ""
        task-result-url: https://lgtm.example.com/api/v1.0/codereviews/b45e291e7033460949ec986153c5416d22157d3e
        task-type: analysis
        uploads:
          key:
            id: 0bc9f13977e364395e8527515da9cbfa0e741cb035fe571197e82e0dd549416d
            url: https://lgtm.example.com/api/v1.0/snapshots/uploads/0bc9f13977e364395e8527515da9cbfa0e741cb035fe571197e82e0dd549416d
      properties:
        id:
          description: The identifier for the operation.
          example: 7654321
          format: int64
          type: integer
        status:
          description: Status of the operation.
          enum:
            - pending
            - done
          example: pending
          type: string
        task-result:
          oneOf:
            - $ref: "#/components/schemas/analysis"
            - $ref: "#/components/schemas/code-review"
            - $ref: "#/components/schemas/queryjob"
        task-result-url:
          description: The URL for the result of the task. For some operations, included only on completion.
          example: https://lgtm.example.com/api/v1.0/codereviews/b45e291e7033460949ec986153c5416d22157d3e
          type: string
        task-type:
          enum:
            - analysis
            - codereview
            - queryjob
          type: string
        uploads:
          additionalProperties:
            $ref: "#/components/schemas/upload-session"
          type: object
      required:
        - task-type
      type: object
    project:
      example:
        id: 1234567
        name: Apache Commons IO
        url: https://lgtm.example.com/projects/g/apache/commons-io
        url-identifier: g/apache/commons-io
      properties:
        id:
          description: The numeric identifier of the project.
          example: 1234567
          format: int64
          type: integer
        name:
          description: The display name of the project.
          example: Apache Commons IO
          type: string
        url:
          description: The full URL of the project on LGTM.
          example: https://lgtm.example.com/projects/g/apache/commons-io
          type: string
        url-identifier:
          description: The URL identifier of the project.
          example: g/apache/commons-io
          type: string
      type: object
    project-details:
      allOf:
        - $ref: "#/components/schemas/project"
        - properties:
            languages:
              description: Per-language information.
              items:
                $ref: "#/components/schemas/project-language-stats"
              type: array
          type: object
    project-language-stats:
      allOf:
        - $ref: "#/components/schemas/language-stats"
        - properties:
            grade:
              description: The grade of the code for this language.
              enum:
                - A+
                - A
                - B
                - C
                - D
                - E
              example: A+
              type: string
          type: object
    project-list:
      example:
        data:
          - id: 1234567
            name: Apache Commons IO
            url: https://lgtm.example.com/projects/g/apache/commons-io
            url-identifier: g/apache/commons-io
          - id: 1234567
            name: Apache Commons IO
            url: https://lgtm.example.com/projects/g/apache/commons-io
            url-identifier: g/apache/commons-io
        nextPageUrl: https://lgtm.example.com/api/v1.0/projects?start=AVAIySnWtmGBpZjIb27kbrqB2uK2HIU0Zk9Sfh19ya8nxzA4GE5bv9LxVPSjQCwHKThqAADNvp17WuWBuBe8901G-ryeA2tLD6JZh8lue2IM0EuqsqB9Wk5BAM6T0lEnXA
      properties:
        data:
          description: A single page of projects.
          items:
            $ref: "#/components/schemas/project"
          type: array
        nextPageUrl:
          description: The URL to retrieve the next page of projects. Omitted if there is no next page.
          example: https://lgtm.example.com/api/v1.0/projects?start=AVAIySnWtmGBpZjIb27kbrqB2uK2HIU0Zk9Sfh19ya8nxzA4GE5bv9LxVPSjQCwHKThqAADNvp17WuWBuBe8901G-ryeA2tLD6JZh8lue2IM0EuqsqB9Wk5BAM6T0lEnXA
          type: string
      type: object
    query:
      properties:
        id:
          description: The numeric identifier of the query.
          example: 10000
          format: int64
          type: integer
        language:
          description: The [language code](https://lgtm.com/help/lgtm/analysis-faqs#which-languages-are-supported) of the query.
          example: javascript
          type: string
        name:
          deprecated: true
          description: The `@name` of the query.
          example: Incomplete string escaping or encoding
          type: string
        pack:
          description: The name of the query pack that contains the query.
          example: com.lgtm/javascript-queries
          type: string
        properties:
          $ref: "#/components/schemas/query_properties"
        url:
          description: A page on LGTM to view the details of the query.
          example: https://lgtm.example.com/rules/1000774/
          type: string
      type: object
    query-result-entry:
      properties:
        file:
          type: string
        line:
          format: int32
          type: integer
        url:
          format: uri
          type: string
        value:
          type: string
      type: object
    query_properties:
      properties:
        id:
          description: The `@id` of the query.
          example: js/incomplete-sanitization
          type: string
        name:
          description: The `@name` of the query.
          example: Incomplete string escaping or encoding
          type: string
        severity:
          description: The severity of the query.
          example: warning
          type: string
        tags:
          description: The `@tags` associated with the query.
          example:
            - correctness
            - security
            - external/cwe/cwe-116
          items:
            type: string
          type: array
      type: object
    queryjob:
      example:
        id: b45e291e7033460949ec986153c5416d22157d3e
        result-url: https://lgtm.com/api/v1.0/query/b45e291e7033460949ec986153c5416d22157d3e
        stats:
          failed: 1
          pending: 1
          success-with-result: 3
          success-without-result: 5
          successful: 8
      properties:
        id:
          description: The identifier for the QueryJob.
          example: b45e291e7033460949ec986153c5416d22157d3e
          type: string
        result-url:
          description: URL to view the result of the query job.
          example: https://lgtm.com/api/v1.0/query/b45e291e7033460949ec986153c5416d22157d3e
          type: string
        stats:
          $ref: "#/components/schemas/queryjob_stats"
      type: object
    queryjob-project-results:
      example:
        columns:
          - Column A
          - Column B
        data:
          - - file: /path/to/file.txt
              line: 100
              url: https://lgtm.example.com/projects/g/apache/commons-io/snapshot/271554d09bb63cb546aa5151916588c320533395/files/path/to/file.txt#L100
              value: Alert 1
            - value: Value B
        next: https://lgtm.example.com/api/v1.0/queryjobs/results/1234567?start=AXBe&limit=100
        project:
          id: 1234567
          name: Apache Commons IO
          url: https://lgtm.example.com/projects/g/apache/commons-io
          url-identifier: g/apache/commons-io
      properties:
        columns:
          description: Columns returned by the query.
          items:
            type: string
          type: array
        data:
          description: Results of the query divided by row.
          items:
            items:
              $ref: "#/components/schemas/query-result-entry"
            type: array
          type: array
        next:
          description: URL for retrieving the next part of the results (if applicable).
          type: string
        project:
          $ref: "#/components/schemas/project"
      type: object
    queryjob-results-overview:
      example:
        data:
          - project:
              id: 1234567
              name: Apache Commons IO
              url: https://lgtm.example.com/projects/g/apache/commons-io
              url-identifier: g/apache/commons-io
            results: 10
            status: success
          - error: Generic Error
            project:
              id: 42530
              name: Apache Maven
              url: https://lgtm.example.com/projects/g/apache/maven
              url-identifier: g/apache/maven
            status: error
        next: https://lgtm.example.com/api/v1.0/queryjobs/2123/results?start=AXBe
      properties:
        data:
          items:
            $ref: "#/components/schemas/queryjob-results-overview-entry"
          type: array
        next:
          type: string
      type: object
    queryjob-results-overview-entry:
      properties:
        error:
          description: Error message. Only applies if `status` is `error`.
          type: string
        external:
          description: Number of results that refer to elements outside the source tree (e.g., libraries). Only applies if `status` is `success`.
          example: 10
          format: int32
          type: integer
        internal:
          description: Number of results that refer to elements within the source tree. Only applies if `status` is `success`.
          example: 1
          format: int32
          type: integer
        project:
          $ref: "#/components/schemas/project"
        status:
          description: Describes whether the query was sucessfully executed against the project.
          enum:
            - success
            - error
          example: success
          type: string
        total:
          description: |
            Number of results returned by the query. This is broken down further into `internal` and `external` results. Only applies if `status` is `success`.
          example: 11
          format: int32
          type: integer
      type: object
    queryjob_stats:
      example:
        failed: 1
        pending: 1
        success-with-result: 3
        success-without-result: 5
        successful: 8
      properties:
        failed:
          description: The number of projects for which the query failed.
          example: 1
          format: int32
          type: integer
        pending:
          description: |
            The number of projects scheduled for execution but pending. For very large jobs, not all projects are scheduled at the same time. Therefore, this number might increase as more projects are scheduled. This means that `successful + failed + pending` might be smaller than the total number of project that will be analyzed.
          example: 1
          format: int32
          type: integer
        success-with-result:
          description: The number of projects for which the query returned results.
          example: 3
          format: int32
          type: integer
        success-without-result:
          description: The number of projects for which the query was successful but returned no results.
          example: 5
          format: int32
          type: integer
        successful:
          description: |
            The number of projects for which the query completed succesfully. These are broken down further between the ones that have results (`success-with-result`) and the ones that do not (`success-without-result`): `successful = success-with-result + success-without-result`.
          example: 8
          format: int32
          type: integer
      type: object
    upload-session:
      example:
        id: 0bc9f13977e364395e8527515da9cbfa0e741cb035fe571197e82e0dd549416d
        url: https://lgtm.example.com/api/v1.0/snapshots/uploads/0bc9f13977e364395e8527515da9cbfa0e741cb035fe571197e82e0dd549416d
      properties:
        id:
          description: The identifier of the upload session
          example: 0bc9f13977e364395e8527515da9cbfa0e741cb035fe571197e82e0dd549416d
          type: string
        url:
          description: The URL for uploading file content.
          example: https://lgtm.example.com/api/v1.0/snapshots/uploads/0bc9f13977e364395e8527515da9cbfa0e741cb035fe571197e82e0dd549416d
          format: uri
          type: string
      type: object
    version:
      example:
        apiVersion: "1.0"
      properties:
        apiVersion:
          description: The version number of the API.
          example: "1.0"
          type: string
      type: object
  securitySchemes:
    access-token:
      description: |
        

        LGTM Enterprise users need to create and use an access token to authenticate with this API. This is optional for LGTM.com users unless they want to submit a CodeQL query for analysis of one or more projects, or to request the analysis of a patch or commit. LGTM.com users also need an access token to  check on the progress of long running tasks using the `/operations` endpoint.
        Log in to LGTM and use the **Create token** option in your Account settings page. For more detailed information, see [Authentication with the API](https://lgtm.com/help/lgtm/api/authentication-api) and [Managing access tokens](https://lgtm.com/help/lgtm/api/managing-access-tokens).
        If you include an access token in the header of a request to the API  for data, it must have the scopes required by that endpoint. Access tokens are shown in the examples as: `Authorization: Bearer {access-token}`
      scheme: bearer
      type: http
