{
  "openapi": "3.0.0",
  "info": {
    "version": "1.0.0",
    "title": "Tusk Analytics API"
  },
  "servers": [
    {
      "url": "https://use-tusk.uc.r.appspot.com/api/v1/analytics"
    }
  ],
  "components": {
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key"
      }
    },
    "schemas": {},
    "parameters": {}
  },
  "paths": {
    "/totals": {
      "get": {
        "summary": "Get client totals",
        "tags": [
          "Analytics"
        ],
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "description": "Start date to filter by (inclusive)",
              "format": "date-time"
            },
            "required": false,
            "name": "startDate",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "description": "End date to filter by (inclusive)",
              "format": "date-time"
            },
            "required": false,
            "name": "endDate",
            "in": "query"
          },
          {
            "schema": {
              "type": "array",
              "description": "Repo IDs to filter by",
              "items": {
                "type": "number"
              }
            },
            "required": false,
            "name": "repoIds",
            "in": "query"
          },
          {
            "schema": {
              "type": "array",
              "description": "GitHub/GitLab usernames to filter by",
              "items": {
                "type": "string"
              }
            },
            "required": false,
            "name": "usernames",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "clientId": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "totalUniquePrs": {
                      "type": "number",
                      "description": "Number of PRs processed by Tusk"
                    },
                    "uniquePrsWithCreatedTests": {
                      "type": "number",
                      "description": "Number of PRs with Tusk tests generated"
                    },
                    "uniquePrsWithPartiallyIncorporatedTests": {
                      "type": "number",
                      "description": "Number of PRs with some of Tusk tests incorporated"
                    },
                    "uniquePrsWithFullyIncorporatedTests": {
                      "type": "number",
                      "description": "Number of PRs with all of Tusk tests incorporated"
                    },
                    "uniquePrsWithAnyIncorporatedTests": {
                      "type": "number",
                      "description": "Number of PRs with any of Tusk tests incorporated"
                    },
                    "numTestsIncorporated": {
                      "type": "number",
                      "description": "Number of individual tests incorporated"
                    },
                    "numFailedTestsIncorporated": {
                      "type": "number",
                      "description": "Number of individual failing tests incorporated (i.e. potential bugs Tusk detected)"
                    },
                    "totalViews": {
                      "type": "number",
                      "description": "Total number of views of Tusk output in GitHub/GitLab or Tusk UI"
                    },
                    "numCoverbotPrs": {
                      "type": "number",
                      "description": "Number of PRs created by Coverbot"
                    },
                    "numMergedCoverbotPrs": {
                      "type": "number",
                      "description": "Number of merged Coverbot PRs merged"
                    },
                    "numCoverbotTestsCreated": {
                      "type": "number",
                      "description": "Number of individual tests created by Coverbot"
                    },
                    "numCoverbotTestsIncorporated": {
                      "type": "number",
                      "description": "Number of individual tests in merged Coverbot PRs"
                    },
                    "numCoverbotPotentialFailingTests": {
                      "type": "number",
                      "description": "Number of potential failing tests surfaced in Coverbot PRs"
                    }
                  },
                  "required": [
                    "clientId",
                    "totalUniquePrs",
                    "uniquePrsWithCreatedTests",
                    "uniquePrsWithPartiallyIncorporatedTests",
                    "uniquePrsWithFullyIncorporatedTests",
                    "uniquePrsWithAnyIncorporatedTests",
                    "numTestsIncorporated",
                    "numFailedTestsIncorporated",
                    "totalViews",
                    "numCoverbotPrs",
                    "numMergedCoverbotPrs",
                    "numCoverbotTestsCreated",
                    "numCoverbotTestsIncorporated",
                    "numCoverbotPotentialFailingTests"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/repos": {
      "get": {
        "summary": "Get repos",
        "tags": [
          "Analytics"
        ],
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "description": "Start date to filter by (inclusive)",
              "format": "date-time"
            },
            "required": false,
            "name": "startDate",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "description": "End date to filter by (inclusive)",
              "format": "date-time"
            },
            "required": false,
            "name": "endDate",
            "in": "query"
          },
          {
            "schema": {
              "type": "array",
              "description": "Repo IDs to filter by",
              "items": {
                "type": "number"
              }
            },
            "required": false,
            "name": "repoIds",
            "in": "query"
          },
          {
            "schema": {
              "type": "array",
              "description": "GitHub/GitLab usernames to filter by",
              "items": {
                "type": "string"
              }
            },
            "required": false,
            "name": "usernames",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "clientId": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "repoId": {
                        "type": "number",
                        "description": "Unique ID for repo"
                      },
                      "repoName": {
                        "type": "string",
                        "description": "Name of repo"
                      },
                      "isRepoEnabled": {
                        "type": "boolean",
                        "description": "Whether the repo is enabled for Tusk (i.e. counts towards repo limits)"
                      },
                      "numActiveTestingEnvironments": {
                        "type": "number",
                        "description": "Number of active testing environments for the repo"
                      },
                      "numCoverbotConfigs": {
                        "type": "number",
                        "description": "Number of Coverbot configs for the repo"
                      },
                      "totalUniquePrs": {
                        "type": "number",
                        "description": "Number of PRs processed by Tusk"
                      },
                      "prsWithTests": {
                        "type": "number",
                        "description": "Number of PRs with Tusk tests generated"
                      },
                      "prsWithFullyIncorporatedTests": {
                        "type": "number",
                        "description": "Number of PRs with all of Tusk tests incorporated"
                      },
                      "prsWithPartiallyIncorporatedTests": {
                        "type": "number",
                        "description": "Number of PRs with some of Tusk tests incorporated"
                      },
                      "prsWithAnyIncorporatedTests": {
                        "type": "number",
                        "description": "Number of PRs with any of Tusk tests incorporated"
                      },
                      "numTestsIncorporated": {
                        "type": "number",
                        "description": "Number of individual tests incorporated"
                      },
                      "numFailedTestsIncorporated": {
                        "type": "number",
                        "description": "Number of individual failing tests incorporated (i.e. potential bugs Tusk detected)"
                      },
                      "totalViews": {
                        "type": "number",
                        "description": "Total number of views of Tusk output in GitHub/GitLab or Tusk UI"
                      },
                      "numCoverbotPrs": {
                        "type": "number",
                        "description": "Number of PRs created by Coverbot"
                      },
                      "numMergedCoverbotPrs": {
                        "type": "number",
                        "description": "Number of merged Coverbot PRs merged"
                      },
                      "numCoverbotTestsCreated": {
                        "type": "number",
                        "description": "Number of individual tests created by Coverbot"
                      },
                      "numCoverbotTestsIncorporated": {
                        "type": "number",
                        "description": "Number of individual tests in merged Coverbot PRs"
                      },
                      "numCoverbotPotentialFailingTests": {
                        "type": "number",
                        "description": "Number of potential failing tests surfaced in Coverbot PRs"
                      }
                    },
                    "required": [
                      "clientId",
                      "repoId",
                      "repoName",
                      "isRepoEnabled",
                      "numActiveTestingEnvironments",
                      "numCoverbotConfigs",
                      "totalUniquePrs",
                      "prsWithTests",
                      "prsWithFullyIncorporatedTests",
                      "prsWithPartiallyIncorporatedTests",
                      "prsWithAnyIncorporatedTests",
                      "numTestsIncorporated",
                      "numFailedTestsIncorporated",
                      "totalViews",
                      "numCoverbotPrs",
                      "numMergedCoverbotPrs",
                      "numCoverbotTestsCreated",
                      "numCoverbotTestsIncorporated",
                      "numCoverbotPotentialFailingTests"
                    ]
                  }
                }
              }
            }
          }
        }
      }
    },
    "/users": {
      "get": {
        "summary": "Get users",
        "tags": [
          "Analytics"
        ],
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "description": "Start date to filter by (inclusive)",
              "format": "date-time"
            },
            "required": false,
            "name": "startDate",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "description": "End date to filter by (inclusive)",
              "format": "date-time"
            },
            "required": false,
            "name": "endDate",
            "in": "query"
          },
          {
            "schema": {
              "type": "array",
              "description": "Repo IDs to filter by",
              "items": {
                "type": "number"
              }
            },
            "required": false,
            "name": "repoIds",
            "in": "query"
          },
          {
            "schema": {
              "type": "array",
              "description": "GitHub/GitLab usernames to filter by",
              "items": {
                "type": "string"
              }
            },
            "required": false,
            "name": "usernames",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "clientId": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "prExternalCreatorId": {
                        "type": "string",
                        "description": "GitHub/GitLab username of PR creator"
                      },
                      "hasActiveSeat": {
                        "type": "boolean",
                        "description": "Whether the user has an active seat"
                      },
                      "totalUniquePrs": {
                        "type": "number",
                        "description": "Number of PRs processed by Tusk"
                      },
                      "prsWithTests": {
                        "type": "number",
                        "description": "Number of PRs with Tusk tests generated"
                      },
                      "prsWithFullyIncorporatedTests": {
                        "type": "number",
                        "description": "Number of PRs with all of Tusk tests incorporated"
                      },
                      "prsWithPartiallyIncorporatedTests": {
                        "type": "number",
                        "description": "Number of PRs with some of Tusk tests incorporated"
                      },
                      "prsWithAnyIncorporatedTests": {
                        "type": "number",
                        "description": "Number of PRs with any of Tusk tests incorporated"
                      },
                      "numTestsIncorporated": {
                        "type": "number",
                        "description": "Number of individual tests incorporated"
                      },
                      "numFailedTestsIncorporated": {
                        "type": "number",
                        "description": "Number of individual failing tests incorporated (i.e. potential bugs Tusk detected)"
                      },
                      "totalViews": {
                        "type": "number",
                        "description": "Total number of views of Tusk output in GitHub/GitLab or Tusk UI"
                      }
                    },
                    "required": [
                      "clientId",
                      "prExternalCreatorId",
                      "hasActiveSeat",
                      "totalUniquePrs",
                      "prsWithTests",
                      "prsWithFullyIncorporatedTests",
                      "prsWithPartiallyIncorporatedTests",
                      "prsWithAnyIncorporatedTests",
                      "numTestsIncorporated",
                      "numFailedTestsIncorporated",
                      "totalViews"
                    ]
                  }
                }
              }
            }
          }
        }
      }
    },
    "/prs": {
      "get": {
        "summary": "Get PRs",
        "tags": [
          "Analytics"
        ],
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "description": "Start date to filter by (inclusive)",
              "format": "date-time"
            },
            "required": false,
            "name": "startDate",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "description": "End date to filter by (inclusive)",
              "format": "date-time"
            },
            "required": false,
            "name": "endDate",
            "in": "query"
          },
          {
            "schema": {
              "type": "array",
              "description": "Repo IDs to filter by",
              "items": {
                "type": "number"
              }
            },
            "required": false,
            "name": "repoIds",
            "in": "query"
          },
          {
            "schema": {
              "type": "array",
              "description": "GitHub/GitLab usernames to filter by",
              "items": {
                "type": "string"
              }
            },
            "required": false,
            "name": "usernames",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "clientId": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "repoId": {
                        "type": "number",
                        "description": "Unique ID for repo"
                      },
                      "repoName": {
                        "type": "string",
                        "description": "Name of repo"
                      },
                      "prNumber": {
                        "type": "number",
                        "description": "PR number"
                      },
                      "prTitle": {
                        "type": "string",
                        "description": "Title of PR"
                      },
                      "prStatus": {
                        "type": "string",
                        "description": "Status of PR"
                      },
                      "prExternalCreatorId": {
                        "type": "string",
                        "description": "GitHub/GitLab username of PR creator"
                      },
                      "latestTestingCommitCheckRunCreatedAt": {
                        "type": "string",
                        "description": "Date and time of latest Tusk run",
                        "format": "date-time"
                      },
                      "latestTestingCommitCheckRunId": {
                        "type": "string",
                        "description": "ID of latest Tusk run"
                      },
                      "hasTests": {
                        "type": "boolean",
                        "description": "Whether the PR had Tusk tests generated on any commit"
                      },
                      "hasFailedTests": {
                        "type": "boolean",
                        "description": "Whether the PR had failing Tusk tests (i.e. potential bugs Tusk detected) generated on any commit"
                      },
                      "numTestsIncorporated": {
                        "type": "number",
                        "description": "Number of individual tests incorporated"
                      },
                      "numFailedTestsIncorporated": {
                        "type": "number",
                        "description": "Number of individual failing tests incorporated (i.e. potential bugs Tusk detected)"
                      },
                      "totalViews": {
                        "type": "number",
                        "description": "Total number of views of Tusk output in GitHub/GitLab or Tusk UI"
                      }
                    },
                    "required": [
                      "clientId",
                      "repoId",
                      "repoName",
                      "prNumber",
                      "prTitle",
                      "prStatus",
                      "prExternalCreatorId",
                      "latestTestingCommitCheckRunCreatedAt",
                      "latestTestingCommitCheckRunId",
                      "hasTests",
                      "hasFailedTests",
                      "numTestsIncorporated",
                      "numFailedTestsIncorporated",
                      "totalViews"
                    ]
                  }
                }
              }
            }
          }
        }
      }
    },
    "/coverbot-prs": {
      "get": {
        "summary": "Get CoverBot PRs",
        "tags": [
          "Analytics"
        ],
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "description": "Start date to filter by (inclusive)",
              "format": "date-time"
            },
            "required": false,
            "name": "startDate",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "description": "End date to filter by (inclusive)",
              "format": "date-time"
            },
            "required": false,
            "name": "endDate",
            "in": "query"
          },
          {
            "schema": {
              "type": "array",
              "description": "Repo IDs to filter by",
              "items": {
                "type": "number"
              }
            },
            "required": false,
            "name": "repoIds",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "clientId": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "repoId": {
                        "type": "number",
                        "description": "Unique ID for repo"
                      },
                      "repoName": {
                        "type": "string",
                        "description": "Name of repo"
                      },
                      "prNumber": {
                        "type": "number",
                        "description": "PR number"
                      },
                      "prCreatedAt": {
                        "type": "string",
                        "description": "Date and time PR was created",
                        "format": "date-time"
                      },
                      "prStatus": {
                        "type": "string",
                        "description": "Status of PR"
                      },
                      "numTestsCreated": {
                        "type": "number",
                        "description": "Number of individual tests created by Coverbot"
                      },
                      "numTestsIncorporated": {
                        "type": "number",
                        "description": "Number of individual tests in merged Coverbot PRs"
                      },
                      "numPotentialFailingTests": {
                        "type": "number",
                        "description": "Number of potential failing tests surfaced in Coverbot PRs"
                      }
                    },
                    "required": [
                      "clientId",
                      "repoId",
                      "repoName",
                      "prNumber",
                      "prCreatedAt",
                      "prStatus",
                      "numTestsCreated",
                      "numTestsIncorporated",
                      "numPotentialFailingTests"
                    ]
                  }
                }
              }
            }
          }
        }
      }
    },
    "/coverbot-coverage-gains": {
      "get": {
        "summary": "Get CoverBot coverage gains",
        "tags": [
          "Analytics"
        ],
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "description": "Start date to filter by (inclusive)",
              "format": "date-time"
            },
            "required": false,
            "name": "startDate",
            "in": "query"
          },
          {
            "schema": {
              "type": "string",
              "description": "End date to filter by (inclusive)",
              "format": "date-time"
            },
            "required": false,
            "name": "endDate",
            "in": "query"
          },
          {
            "schema": {
              "type": "array",
              "description": "Repo IDs to filter by",
              "items": {
                "type": "number"
              }
            },
            "required": false,
            "name": "repoIds",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "clientId": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "repoId": {
                            "type": "number",
                            "nullable": true
                          },
                          "repoName": {
                            "type": "string"
                          },
                          "scheduledTestRunId": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "prNumber": {
                            "type": "number",
                            "nullable": true
                          },
                          "prTitle": {
                            "type": "string",
                            "nullable": true
                          },
                          "prStatus": {
                            "type": "string"
                          },
                          "prCreatedAt": {
                            "type": "string",
                            "nullable": true
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "pending",
                              "running",
                              "completed",
                              "failed",
                              "internal_failure"
                            ]
                          },
                          "runType": {
                            "type": "string",
                            "enum": [
                              "scheduled",
                              "manual_trigger",
                              "dry_run"
                            ]
                          },
                          "strategy": {
                            "type": "string",
                            "enum": [
                              "files_with_low_coverage",
                              "intelligent_grouping"
                            ]
                          },
                          "createdAt": {
                            "type": "string",
                            "nullable": true
                          },
                          "updatedAt": {
                            "type": "string",
                            "nullable": true
                          },
                          "runAverageLineCoverageGain": {
                            "type": "number",
                            "nullable": true
                          },
                          "runAverageBranchCoverageGain": {
                            "type": "number",
                            "nullable": true
                          },
                          "requestedPrReviewers": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "filePath": {
                            "type": "string",
                            "nullable": true
                          },
                          "lineCoverageBefore": {
                            "type": "number",
                            "nullable": true
                          },
                          "lineCoverageAfter": {
                            "type": "number",
                            "nullable": true
                          },
                          "lineCoverageGain": {
                            "type": "number",
                            "nullable": true
                          },
                          "branchCoverageBefore": {
                            "type": "number",
                            "nullable": true
                          },
                          "branchCoverageAfter": {
                            "type": "number",
                            "nullable": true
                          },
                          "branchCoverageGain": {
                            "type": "number",
                            "nullable": true
                          },
                          "externalPullRequestUrl": {
                            "type": "string",
                            "nullable": true
                          }
                        },
                        "required": [
                          "clientId",
                          "repoId",
                          "repoName",
                          "scheduledTestRunId",
                          "prNumber",
                          "prTitle",
                          "prStatus",
                          "prCreatedAt",
                          "status",
                          "runType",
                          "strategy",
                          "createdAt",
                          "updatedAt",
                          "runAverageLineCoverageGain",
                          "runAverageBranchCoverageGain",
                          "requestedPrReviewers",
                          "filePath",
                          "lineCoverageBefore",
                          "lineCoverageAfter",
                          "lineCoverageGain",
                          "branchCoverageBefore",
                          "branchCoverageAfter",
                          "branchCoverageGain",
                          "externalPullRequestUrl"
                        ]
                      }
                    },
                    "count": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "data",
                    "count"
                  ]
                }
              }
            }
          }
        }
      }
    }
  }
}