All Downloads are FREE. Search and download functionalities are using the official Maven repository.

codacy.events.systemEvents.scala Maven / Gradle / Ivy

The newest version!
package codacy.events

import java.util.UUID

private[events] trait systemEvents {
  self: PathPart =>

  case object project extends PathPart {

    /** Indicates that the project was deleted.
      */
    @eventDef case class deleted(projectId: ProjectId)

    /** Deprecated, use `selectiveUpdate` instead.
      */
    @eventDef case class selectiveUpdateRepository(
        projectId: ProjectId,
        prs: Option[Seq[PullRequestNumber]],
        branches: Option[Seq[BranchName]]
    )

    /** Triggers project update (detect changed commits, branches, PRs) and analysis of the changed entities for the
      * project. Only selected branches and PRs will be considered.
      */
    @eventDef case class selectiveUpdate(
        projectId: ProjectId,
        prs: Option[Seq[PullRequestNumber]],
        branches: Option[Seq[BranchName]]
    )

    /** Deprecated, use `fullScan` instead.
      */
    @eventDef case class fullScanRepository(projectId: ProjectId, forced: Boolean)

    /** Triggers project update (detect changed commits, branches, PRs) and analysis of the changed entities for the
      * project. All branches and PRs will be considered.
      */
    @eventDef case class fullScan(projectId: ProjectId, forced: Boolean)

    /** Triggers SCA (Software Composition Analysis) for the given project.
      */
    @eventDef case class sca(projectId: ProjectId)

    /** Deprecated, use `bulkUpdate` instead.
      */
    @eventDef case class bulkUpdateRepositories(
        projectIds: Seq[ProjectId],
        forced: Boolean
    )

    /** Triggers project update (detect changed commits, branches, PRs) and analysis of the changed entities for the
      * selected projects. All branches and PRs will be considered.
      */
    @eventDef case class bulkUpdate(
        projectIds: Seq[ProjectId],
        forced: Boolean
    )

    case object commit extends PathPart {

      @eventDef case class requestedRetry(projectId: ProjectId, commitUuid: CommitUUId, cleanCache: Boolean)

      /*
       * After detecting (and registering it the codacy system) a new commit
       * Originally introduced to show the information in project / account activities
       * */
      @eventDef case class detected(
          projectId: ProjectId,
          accountId: Option[AccountId],
          organizationId: Option[OrganizationId],
          commitId: CommitId
      )

      @eventDef case class pushed(sender: RemoteUser, organizationId: OrganizationId)

      /** When commits are deleted from a repository.
        *
        * @param commits
        *   the deleted commits
        */
      @eventDef case class deleted(commits: Set[Commit])

      /** A [[Set]] of commits that were attached to a branch.
        *
        * @param commits
        *   The newly attached commits.
        */
      @eventDef case class attached(commits: Set[Commit])

      /** A [[Set]] of commits that disappeared from the repository, i.e. it's not attached to a branch or no longer
        * considered given the retention policies.
        *
        * @param commits
        *   The commits that were detached from a repository.
        */
      @eventDef case class detached(commits: Set[Commit])

      case object coverage extends PathPart {

        /*
         * After receiving and storing a new coverage report for a commit
         */
        @eventDef case class receivedNew(
            projectId: ProjectId,
            commitUUId: CommitUUId,
            language: Option[Language],
            storageLocation: StorageLocation,
            partial: Boolean
        )

        /*
         * After receiving a notification that all partial coverage reports for a commit were sent
         */
        @eventDef case class receivedFinal(projectId: ProjectId, commitUUId: CommitUUId)

        @eventDef case class pullRequestCoverageSummaryReady(
            projectId: ProjectId,
            pullRequestId: PullRequestId,
            destinationCommitId: CommitId,
            destinationCommitSummary: Option[CoverageSummary],
            sourceCommitId: CommitId,
            sourceCommitSummary: CoverageSummary,
            variation: Option[CoverageSummary],
            variationGateSetting: Option[GateSetting],
            diff: CoverageSummary,
            diffGateSetting: Option[GateSetting]
        )

        @eventDef case class pullRequestDiffCoverageReady(
            repositoryId: ProjectId,
            pullRequestNumber: Long,
            sourceCommitSha: CommitUUId,
            targetCommitSha: CommitUUId,
            diffCoverage: Option[CoveragePercentage],
            diffThreshold: Option[CoveragePercentage],
            grade: CoverageGrade.Value
        )

        @eventDef case class pullRequestVariationCoverageReady(
            repositoryId: ProjectId,
            pullRequestNumber: Long,
            sourceCommitSha: CommitUUId,
            targetCommitSha: CommitUUId,
            variationCoverage: Option[CoveragePercentage],
            variationThreshold: Option[CoveragePercentage],
            grade: CoverageGrade.Value
        )

        @eventDef case class analysed(
            repositoryId: ProjectId,
            commit: CommitUUId,
            parentCommit: CommitUUId,
            coverage: CoveragePercentage,
            variation: Option[CoveragePercentage],
            coverableLinesVariation: Option[NumberOfLines],
            coveredLinesVariation: Option[NumberOfLines],
            variationThreshold: Option[CoveragePercentage],
            affectedFiles: Option[AffectedFiles]
        )
      }

      case object results extends PathPart {

        /*
         * After receiving a notification that all partial results from the CLI were sent
         */
        @eventDef case class receivedFinal(projectId: ProjectId, commitUUId: CommitUUId)

      }

    }

    case object pullRequest extends PathPart {

      @eventDef case class requestedRetry(projectId: ProjectId, pullRequestId: PullRequestId)

      @eventDef case class notificationReceived(
          provider: Provider.Value,
          repositoryProviderId: ProjectId,
          pullRequestProviderNumber: PullRequestId,
          sourceCommitSha: CommitUUId,
          targetRef: RepositoryRef
      )

      @eventDef case class discovered(
          provider: Provider.Value,
          repositoryProviderId: ProjectId,
          pullRequestProviderNumber: PullRequestNumber,
          sourceCommitSha: CommitUUId,
          targetRef: RepositoryRef
      )

      @eventDef case class analysisStarted(projectId: ProjectId, pullRequestId: PullRequestId, sourceCommitId: CommitId)

      @eventDef case class deltaCreated(
          projectId: ProjectId,
          pullRequestId: PullRequestId,
          latestCommitId: CommitId,
          detectionTime: Long,
          analysisEndTime: Long
      )

      @eventDef case class forceSuccessStatus(
          projectId: ProjectId,
          pullRequestId: PullRequestId,
          sourceCommitId: CommitId
      )

      case object coverage extends PathPart {

        @eventDef case class requirementsMissing(projectId: ProjectId, pullRequestId: PullRequestId)

        /*
         * After calculating pull request coverage and creating the grade for it
         */
        @eventDef case class gradeCreated(
            projectId: ProjectId,
            pullRequestId: PullRequestId,
            latestCommitId: CommitId,
            grade: MetricQualityGrade.Value
        )

        @eventDef case class summaryReady(
            repositoryId: ProjectId,
            pullRequestNumber: Long,
            sourceCommitSha: CommitUUId,
            sourceCommitSummary: CoverageResult,
            targetCommitSha: CommitUUId,
            targetCommitSummary: Option[CoverageResult],
            variation: Option[CoverageResult],
            variationGateSetting: Option[GateSetting],
            diff: Option[CoverageResult],
            diffGateSetting: Option[GateSetting]
        )
      }

    }

    case object branch extends PathPart {

      /** When the branches with the given ids are deleted from git.
        *
        * @param branchIds
        *   A [[Set]] with the [[BranchId]]s that were deleted.
        */
      @eventDef case class deleted(branchIds: Set[BranchId])

      /** When the branches with the given is are enabled.
        *
        * @param branchIds
        *   A [[Set]] with the [[BranchId]]s that were disabled.
        */
      @eventDef case class enabled(branchIds: Set[BranchId])

      /** When the branches with the given is are disabled.
        *
        * @param branchIds
        *   A [[Set]] with the [[BranchId]]s that were disabled.
        */
      @eventDef case class disabled(branchIds: Set[BranchId])

      /** When the branch with the given Id is updated.
        *
        * @param branchId
        *   the id of the updated branch
        * @param addedCommitIds
        *   the commit ids added to the branch
        * @param deletedCommitIds
        *   the commit ids deleted from the branch
        */
      @eventDef case class updated(branchId: BranchId, addedCommitIds: Set[CommitId], deletedCommitIds: Set[CommitId])
    }

    case object engine extends PathPart {

      /*
       * After successfully disabling an engine
       * Originally introduced to show the information in project / account activities
       * */
      @eventDef case class engineDisabled(accountId: AccountId, engineId: EngineId, projectId: ProjectId)
    }

    case object hotspot extends PathPart {

      /*
       * When fetching hotspots, this event is published for each project that does not have hotspots yet
       * */
      @eventDef case class missing(projectId: ProjectId)

      /*
       * After successfully scheduled the creation of hotspots for a project
       * */
      @eventDef case class scheduled(projectId: ProjectId)

      /*
       * The hotspot with prs that are breaking the build for a project (there is also the owner of each PR)
       * */
      @eventDef case class prsForProject(
          projectId: ProjectId,
          prsBreaking: Seq[PrBreakingBuild],
          uniqueFieldsHash: String
      )

      /*
       * The hotspot with the quality variation for a project in the last 7 days
       *
       * @param projectId         a reference to the project
       * @param percentage        the amount of quality variation in percent
       * @param uniqueFieldsHash  static identifier for the hotspot type
       * */
      @eventDef case class qualityVariationForProject(projectId: ProjectId, variation: Int, uniqueFieldsHash: String)

      /*
       * The hotspot showing how many times a security pattern occurrence has been detected in a Project
       *
       * @param projectId         a reference to the project
       * @param patternId         the reference to the security pattern
       * @param count             the number of occurrences of the pattern
       * @param uniqueFieldsHash  static identifier for the hotspot type
       * */
      @eventDef case class securityPatternOccurrence(
          projectId: ProjectId,
          patternId: PatternId,
          count: Int,
          uniqueFieldsHash: String
      )

      /*
       * The hotspot showing how many occurrences of security related patterns have been detected in a Project
       *
       * @param projectId         a reference to the project
       * @param count             the number of occurrences of security patterns
       * @param uniqueFieldsHash  static identifier for the hotspot type
       * */
      @eventDef case class allSecurityPatternOccurrences(projectId: ProjectId, count: Int, uniqueFieldsHash: String)

      /*
       * A hotspot about pull requests that are open for more than 4 days
       *
       * @param projectId         a reference to the project
       * @param pullRequestId     a reference to the abandoned PullRequest
       * @param uniqueFieldsHash  static identifier for the hotspot type
       * */
      @eventDef case class abandonedPullRequest(
          projectId: ProjectId,
          pullRequestId: PullRequestId,
          uniqueFieldsHash: String
      )

    }

    case object dashboard extends PathPart {
      /*
       * After press share button on project dashboard
       * */
      @eventDef case class shared(userId: AccountId, projectId: ProjectId, invitees: Seq[String], projectUrl: String)
    }

    /** Events related to Software Bill of Materials capability. */
    case object sbom extends PathPart {

      /** Notifies that a new SBOM was created and uploaded to S3.
        *
        * @param id
        *   The event id.
        * @param organizationId
        *   Identifier of the organization for which the SBOM was created.
        * @param projectId
        *   Identifier for the repository for which the SBOM was created.
        * @param commitUUId
        *   Identifier for the commit for which the SBOM was created.
        * @param s3Path
        *   The S3 path where the SBOM was uploaded to.
        */
      @eventDef case class created(
          id: UUID,
          organizationId: OrganizationId,
          projectId: ProjectId,
          commitUUId: CommitUUId,
          s3Path: String
      )
    }

  }

  case object analysis extends PathPart {

    case object project extends PathPart {

      @eventDef case class configurationDetected(
          projectId: ProjectId,
          engineId: EngineId,
          hasConfigFile: Boolean,
          shouldUseConfigFile: Boolean
      )

      /** A job from a project got assigned to a worker
        *
        * @param projectId
        *   the project assigned
        * @param jobId
        *   the job assigned
        */
      @eventDef case class assigned(projectId: ProjectId, jobId: JobId)

      /** A job from a project got completed from a worker. Does not mark success.
        *
        * @param projectId
        *   the project assigned
        * @param jobId
        *   the job assigned
        */
      @eventDef case class completed(projectId: ProjectId, jobId: JobId)

    }

    case object commit extends PathPart {

      @eventDef case class createdNewIssue(commitId: CommitId, patternId: PatternId)

      @eventDef case class createdFixedIssue(commitId: CommitId, patternId: PatternId)

      @eventDef case class createdDelta(
          projectId: ProjectId,
          commitId: CommitId,
          detectionTime: Long,
          analysisEndTime: Long
      )

      /** A Job for a specific project commit has been created
        *
        * @param projectId
        *   the project being analysed
        * @param jobId
        *   the job identifier
        * @param jobType
        *   the type of job (Commit, RetryCommit, etc)
        * @param commitId
        *   the commit id
        * @param commitTimestamp
        *   the commit timestamp
        * @param authorTimestamp
        *   the author timestamp
        * @param authorEmail
        *   the author email
        * @param organizationId
        *   the organization id
        * @param planModel
        *   the type of Plan, either "Auto" or "Manual"
        * @param isPrivateRepository
        *   is the project private?
        * @param isTrialPlan
        *   is the organization on trial?
        * @param commitSha
        *   the commit's sha
        * @param subscriptions
        *   list of subscriptions associated to organization
        */
      @eventDef case class queued(
          projectId: ProjectId,
          jobId: JobId,
          jobType: String,
          commitId: CommitId,
          commitTimestamp: Timestamp,
          authorTimestamp: Timestamp,
          authorEmail: String,
          organizationId: OrganizationId,
          planModel: String,
          isPrivateRepository: Boolean,
          isTrialPlan: Option[Boolean],
          commitSha: Option[String] = None,
          subscriptions: Option[Seq[Subscription]] = None
      )

    }

    case object repository extends PathPart {

      @eventDef case class issuesSnapshot(
          organizationId: OrganizationId,
          repositoryId: ProjectId,
          repositoryName: String,
          branchId: BranchId,
          commitId: CommitId,
          commitUuid: String,
          commitCreatedTimestamp: Timestamp,
          isDefaultBranch: Boolean,
          jobType: JobType.Value
      )

    }

    case object pullRequest extends PathPart {

      /** A Job for a specific project pull request has been created
        *
        * @param projectId
        *   the project being analysed
        * @param jobId
        *   the job id
        * @param jobType
        *   the job type (PullRequest, RetryPullRequest, etc)
        * @param pullRequestId
        *   the pull request id
        */
      @eventDef case class queued(projectId: ProjectId, jobId: JobId, jobType: String, pullRequestId: PullRequestId)

      /** The beginning of the PR analysis pipeline - Pull request hook received
        *
        * @param projectId
        *   the project being analysed
        * @param pullRequestNumber
        *   the number of the PR on the remote provider
        * @param commitUuid
        *   the commitUuid of the head commit of the branch to be merged (source commit)
        * @param provider
        *   the name of the git provider of that PR
        */
      @eventDef case class hookReceived(
          projectId: ProjectId,
          pullRequestNumber: Long,
          commitUuid: String,
          provider: String
      )

      /** The end of the PR analysis pipeline - After last steps (Ex: after sending PR status to the git provider)
        *
        * @param projectId
        *   the project being analysed
        * @param pullRequestNumber
        *   the number of the PR on the remote provider
        * @param commitUuid
        *   the commitUuid of the head commit of the branch to be merged (source commit)
        * @param provider
        *   the name of the git provider of that PR
        */
      @eventDef case class completed(
          projectId: ProjectId,
          pullRequestNumber: Long,
          commitUuid: String,
          provider: String
      )
    }

  }

  case object organization extends PathPart {

    case object plan extends PathPart {

      @eventDef case class changed(
          organizationId: OrganizationId,
          accountId: AccountId,
          plan: String,
          parameters: Map[String, String]
      )

      @eventDef case class cancelled(
          organizationId: OrganizationId,
          accountId: AccountId,
          plan: String,
          parameters: Map[String, String]
      )

    }

    case object project extends PathPart {

      case object commit extends PathPart {

        @eventDef case class rejected(
            commitUUId: CommitUUId,
            commitTimestamp: Timestamp,
            email: String,
            projectId: ProjectId,
            organizationId: OrganizationId
        )
      }

      /** Used to mark when a project is added to an organization
        *
        * @param projectId
        *   the project added
        * @param organizationId
        *   the organization that the project was added to
        * @param accountId
        *   the account that added the project
        */
      @eventDef case class added(projectId: ProjectId, organizationId: OrganizationId, accountId: AccountId)

      @eventDef case class transferred(
          projectId: ProjectId,
          organizationId: OrganizationId,
          accountId: Option[AccountId] = None
      )

      /*
       * After successfully removing a project from an organization
       * Originally introduced to show the information in project / account / org activities
       * */
      @eventDef case class removed(accountId: Option[AccountId], projectId: ProjectId, organizationId: OrganizationId)

    }

    case object account extends PathPart {

      @eventDef case class added(accountId: AccountId, collaboratorId: AccountId, organizationId: OrganizationId)

      @eventDef case class removed(accountId: AccountId, collaboratorId: AccountId, organizationId: OrganizationId)

      @eventDef case class removedMultiple(
          accountId: AccountId,
          collaboratorIds: Set[AccountId],
          organizationId: OrganizationId
      )
    }

    case object organization extends PathPart {

      @eventDef case class removed(accountId: Option[AccountId], organizationId: OrganizationId)

    }

    case object collaborator {

      @eventDef case class added(accountId: AccountId, projectId: ProjectId, organizationId: OrganizationId)

    }

    case object member extends PathPart {
      @eventDef case class added(accountId: AccountId, organizationId: OrganizationId, emails: Seq[String])
      @eventDef case class removed(accountId: AccountId, organizationId: OrganizationId, emails: Seq[String])
    }

    case object srm extends PathPart {

      /** Event sent after a Codacy admin uploads a CSV with penetration testing report to Codacy.
        *
        * @param organizationId
        *   The organization for which the report were updated.
        * @param s3Bucket
        *   The S3 bucket name where the report is stored.
        * @param s3Key
        *   The S3 key for the report object. The key contains information about the tool that provided the report.
        */
      @eventDef case class penTestReport(organizationId: OrganizationId, s3Bucket: String, s3Key: String)

      /** Event sent after users upload a DAST report to Codacy.
        *
        * @param organizationId
        *   The organization that uploaded the report.
        * @param reportId
        *   The id of the uploaded report, generated by Codacy.
        * @param s3Bucket
        *   The S3 bucket name where the report is stored.
        * @param s3Key
        *   The S3 key for the report object. The key contains information about the tool that provided the report and
        *   the report format.
        */
      @eventDef case class dastReport(organizationId: OrganizationId, reportId: UUID, s3Bucket: String, s3Key: String)
    }
  }

  case object account extends PathPart {

    case object plan extends PathPart {

      @eventDef case class changed(accountId: AccountId, plan: String, parameters: Map[String, String])

      @eventDef case class cancelled(accountId: AccountId, plan: String, parameters: Map[String, String])

    }

    case object account extends PathPart {

      @eventDef case class updated(accountId: AccountId)

      @eventDef case class removed(accountId: AccountId)

      @eventDef case class signedUp(accountId: AccountId)

      @eventDef case class signedIn(accountId: AccountId)

      @eventDef case class lastLoginUpdated(accountId: AccountId, lastLoginTimestamp: Timestamp, mainEmail: String)

      case object emails extends PathPart {
        @eventDef case class updated(accountId: AccountId, organizationIds: Seq[OrganizationId], emails: Seq[String])
      }
    }

    case object project extends PathPart {

      @eventDef case class added(projectId: ProjectId, accountId: AccountId)

      @eventDef case class transferred(projectId: ProjectId, accountId: AccountId)

      /** Used to mark when a new project is created
        *
        * @param projectId
        *   the project being created
        * @param accountId
        *   the account id that creates the project
        * @param name
        *   the project name
        * @param access
        *   the type of access this project has, private or public
        */
      @eventDef case class registered(
          projectId: ProjectId,
          accountId: AccountId,
          name: ProjectName,
          access: ProjectAccess.Value
      )

      // TODO i'm not happy about this name but it's a copy of algorithms_applied in website
      @eventDef case class appliedAlgorithm(accountId: AccountId, projectId: ProjectId)

      @eventDef case class deleted(
          accountId: AccountId,
          projectUrl: Option[ProjectUrl],
          projectId: Option[ProjectId] = None
      )

    }

  }

  case object tracking extends PathPart {

    /** Whenever an item is added to the Repository Listener queue or updated in the queue.
      */
    @eventDef case class discoveryRequested(
        eventId: UUID,
        startTimestamp: Timestamp,
        organizationId: OrganizationId,
        organizationName: Option[String],
        repositoryId: ProjectId,
        repositoryName: Option[String],
        queueItemId: QueueItemId,
        itemType: RequestType.Value,
        planValue: PlanValue,
        retryCount: Int,
        requestMetadata: DiscoveryRequestMetadata,
        analysisDetectionTimestamp: Timestamp
    )

    /** Whenever an item is deleted from the Repository Listener queue (with success or failure status) */
    @eventDef case class discoveryEnded(
        eventId: UUID,
        startTimestamp: Timestamp,
        endTimestamp: Timestamp,
        organizationId: OrganizationId,
        organizationName: Option[String],
        repositoryId: ProjectId,
        repositoryName: Option[String],
        errorType: Option[String],
        generatedJobs: Option[Seq[JobId]],
        status: RequestStatus.Value,
        queueItemId: QueueItemId,
        requestType: RequestType.Value,
        planValue: PlanValue,
        retryCount: Int,
        analysisDetectionTimestamp: Timestamp
    )

    case object commit extends PathPart {

      /** Marks the creation of a commit analysis job, indicating the start of the Queue phase.
        */
      @eventDef case class jobCreated(
          eventId: UUID,
          jobId: JobId,
          organizationId: OrganizationId,
          organizationName: String,
          repositoryId: ProjectId,
          repositoryName: String,
          paymentPlan: Option[PaymentPlanType.Value],
          numberOfSeats: Option[Int],
          commitUUID: CommitUUId,
          analysisDetectionTimestamp: Timestamp,
          analyseMoreCommits: Boolean,
          discoveryPhase: Option[DiscoveryPhase],
          retryRequestTimestamp: Option[Timestamp],
          jobType: Option[JobType.Value]
      )

      /** Marks the start of executing a commit analysis job, indicating the start of the Change Processing phase.
        */
      @eventDef case class jobExecuted(
          eventId: UUID,
          jobId: JobId,
          organizationId: OrganizationId,
          repositoryId: ProjectId,
          commitUUID: CommitUUId,
          retryAttemptNumber: Int,
          analysisDetectionTimestamp: Timestamp,
          jobType: Option[JobType.Value]
      )

      /** Marks the completion of a commit analysis job, concluding the Change Processing phase.
        */
      @eventDef case class jobCompleted(
          eventId: UUID,
          jobId: JobId,
          organizationId: OrganizationId,
          repositoryId: ProjectId,
          commitUUID: CommitUUId,
          retryAttemptNumber: Int,
          analysisDetectionTimestamp: Timestamp,
          terminationCause: TerminationType.Value,
          jobType: Option[JobType.Value]
      )

      /** Marks the start of preparation for a commit analysis job by a worker, indicating the start of task creation.
        */
      @eventDef case class preparationStarted(
          eventId: UUID,
          jobId: JobId,
          repositoryId: ProjectId,
          organizationId: OrganizationId,
          commitUUID: CommitUUId,
          analysisDetectionTimestamp: Timestamp,
          jobCreationTimestamp: Timestamp,
          isRetry: Boolean,
          analysisRetryAttemptNumber: Int,
          numberOfBranches: Int,
          numberOfPrs: Int
      )

      /** Marks the start of tasks execution for a commit analysis job, indicating the start of the Running Tools phase.
        */
      @eventDef case class runningTasksStarted(
          eventId: UUID,
          jobId: JobId,
          repositoryId: ProjectId,
          organizationId: OrganizationId,
          commitUUID: Option[CommitUUId],
          commitId: Option[CommitId],
          analysisRetryAttemptNumber: Int,
          analysisDetectionTimestamp: Timestamp
      )

      /** Marks the end of task execution for a commit analysis job.
        */
      @eventDef case class runningTasksEnded(
          eventId: UUID,
          jobId: JobId,
          repositoryId: ProjectId,
          organizationId: OrganizationId,
          commitUUID: CommitUUId,
          commitId: CommitId,
          analysisRetryAttemptNumber: Int,
          analysisDetectionTimestamp: Timestamp
      )

      /** Details a commit analysis job, providing an in-depth view of the analysis process.
        */
      @eventDef case class analysisDetails(
          eventId: UUID,
          jobId: JobId,
          organizationId: OrganizationId,
          repositoryId: ProjectId,
          commitUUID: CommitUUId,
          commitId: CommitId,
          retryAttemptNumber: Int,
          numFiles: Int,
          filesSizeBytes: Long,
          numAlgorithmTools: Option[Int],
          numAllTasks: Option[Int],
          analysisDetectionTimestamp: Timestamp
      )

      /** Marks the initiation of a task as part of a commit analysis process.
        *
        * @param retryAttemptNumber
        *   how many times the analysis job was retried
        * @param attempt
        *   how many times the current task was retried
        */
      @eventDef case class taskStarted(
          eventId: UUID,
          jobId: JobId,
          organizationId: OrganizationId,
          repositoryId: ProjectId,
          commitUUID: CommitUUId,
          commitId: CommitId,
          retryAttemptNumber: Int,
          taskId: TaskId,
          taskType: TaskType.Value,
          language: Option[Language],
          filesCount: Option[Int],
          cachedFilesCount: Option[Int],
          toolName: Option[String],
          toolUUID: Option[String],
          attempt: Int,
          analysisDetectionTimestamp: Timestamp
      )

      /** Marks the completion of a task within a commit analysis process, detailing the outcome and status.
        *
        * @param retryAttemptNumber
        *   how many times the analysis job was retried
        * @param attempt
        *   how many times the current task was retried
        */
      @eventDef case class taskEnded(
          eventId: UUID,
          jobId: JobId,
          organizationId: OrganizationId,
          repositoryId: ProjectId,
          commitUUID: CommitUUId,
          commitId: CommitId,
          retryAttemptNumber: Int,
          taskId: TaskId,
          taskType: TaskType.Value,
          language: Option[Language],
          filesCount: Option[Int],
          cachedFilesCount: Option[Int],
          toolName: Option[String],
          toolUUID: Option[String],
          attempt: Int,
          taskStatus: String,
          failureReason: Option[String],
          analysisDetectionTimestamp: Timestamp
      )
    }

    case object pullRequest extends PathPart {

      /** Marks the creation of a PR analysis job, indicating the start of the Queue phase.
        */
      @eventDef case class jobCreated(
          eventId: UUID,
          jobId: JobId,
          organizationId: OrganizationId,
          organizationName: String,
          repositoryId: ProjectId,
          repositoryName: String,
          paymentPlan: Option[PaymentPlanType.Value],
          numberOfSeats: Option[Int],
          pullRequestId: PullRequestId,
          pullRequestNumber: PullRequestNumber,
          sourceBranchName: String,
          sourceCommitUUID: CommitUUId,
          sourceCommitJobId: Option[JobId],
          destinationBranchName: String,
          commonAncestorCommitUUID: CommitUUId,
          commonAncestorCommitJobId: Option[JobId],
          analysisDetectionTimestamp: Timestamp,
          discoveryPhase: Option[DiscoveryPhase],
          retryRequestTimestamp: Option[Timestamp],
          jobType: Option[JobType.Value]
      )

      /** Marks the start of executing a PR analysis job, indicating the start of the Change Processing phase.
        */
      @eventDef case class jobExecuted(
          eventId: UUID,
          jobId: JobId,
          organizationId: OrganizationId,
          repositoryId: ProjectId,
          pullRequestId: PullRequestId,
          sourceCommitUUID: CommitUUId,
          commonAncestorCommitUUID: CommitUUId,
          retryAttemptNumber: Int,
          analysisDetectionTimestamp: Timestamp,
          jobType: Option[JobType.Value]
      )

      /** Marks the completion of a PR analysis job, concluding the Change Processing phase.
        */
      @eventDef case class jobCompleted(
          eventId: UUID,
          jobId: JobId,
          organizationId: OrganizationId,
          repositoryId: ProjectId,
          pullRequestId: PullRequestId,
          sourceCommitUUID: CommitUUId,
          commonAncestorCommitUUID: CommitUUId,
          retryAttemptNumber: Int,
          analysisDetectionTimestamp: Timestamp,
          terminationCause: TerminationType.Value,
          jobType: Option[JobType.Value]
      )

      /** Marks the start of preparation for a PR analysis job by a worker, indicating the start of task creation.
        */
      @eventDef case class preparationStarted(
          eventId: UUID,
          jobId: JobId,
          repositoryId: ProjectId,
          pullRequestId: PullRequestId,
          organizationId: OrganizationId,
          sourceCommitUUID: CommitUUId,
          commonAncestorCommitUUID: CommitUUId,
          analysisDetectionTimestamp: Timestamp,
          jobCreationTimestamp: Timestamp,
          jobScope: JobScope.Value,
          isRetry: Boolean,
          analysisRetryAttemptNumber: Int,
          numberOfBranches: Int,
          numberOfPrs: Int
      )

      /** Marks the start of tasks execution for a PR analysis job, indicating the start of the Running Tasks phase.
        */
      @eventDef case class runningTasksStarted(
          eventId: UUID,
          jobId: JobId,
          repositoryId: ProjectId,
          organizationId: OrganizationId,
          pullRequestId: PullRequestId,
          srcCommitUUID: CommitUUId,
          srcCommitId: CommitId,
          commonAncestorCommitUUID: CommitUUId,
          commonAncestorCommitId: CommitId,
          analysisRetryAttemptNumber: Int,
          analysisDetectionTimestamp: Timestamp
      )

      /** Marks the end of tasks execution for a PR analysis job, indicating the start of the Running Tasks phase.
        */
      @eventDef case class runningTasksEnded(
          eventId: UUID,
          jobId: JobId,
          repositoryId: ProjectId,
          organizationId: OrganizationId,
          pullRequestId: PullRequestId,
          srcCommitUUID: CommitUUId,
          srcCommitId: CommitId,
          commonAncestorCommitUUID: CommitUUId,
          commonAncestorCommitId: CommitId,
          analysisRetryAttemptNumber: Int,
          analysisDetectionTimestamp: Timestamp
      )

      /** Details a PR analysis job, providing an in-depth view of the analysis process.
        */
      @eventDef case class analysisDetails(
          eventId: UUID,
          jobId: JobId,
          organizationId: OrganizationId,
          repositoryId: ProjectId,
          pullRequestId: PullRequestId,
          sourceCommitUUID: CommitUUId,
          sourceCommitId: CommitId,
          commonAncestorCommitUUID: CommitUUId,
          commonAncestorCommitId: CommitId,
          retryAttemptNumber: Int,
          numChangedFiles: Int,
          analysisDetectionTimestamp: Timestamp
      )

      /** Marks the start of a task as part of a PR analysis process.
        *
        * @param retryAttemptNumber
        *   how many times the analysis job was retried
        * @param attempt
        *   how many times the current task was retried
        */
      @eventDef case class taskStarted(
          eventId: UUID,
          jobId: JobId,
          organizationId: OrganizationId,
          projectId: ProjectId,
          pullRequestId: PullRequestId,
          sourceBranchId: BranchId,
          destBranchId: BranchId,
          srcCommitId: CommitId,
          srcCommitUuid: CommitUUId,
          destCommitId: CommitId,
          destCommitUuid: CommitUUId,
          taskId: TaskId,
          taskType: TaskType.Value,
          retryAttemptNumber: Int,
          pullRequestState: PullRequestState.Value,
          attempt: Int,
          analysisDetectionTimestamp: Timestamp
      )

      /** Marks the completion of a task within a PR analysis process, detailing the outcome and status.
        *
        * @param retryAttemptNumber
        *   how many times the analysis job was retried
        * @param attempt
        *   how many times the current task was retried
        */
      @eventDef case class taskEnded(
          eventId: UUID,
          jobId: JobId,
          organizationId: OrganizationId,
          repositoryId: ProjectId,
          pullRequestId: PullRequestId,
          sourceBranchId: BranchId,
          destBranchId: BranchId,
          srcCommitId: CommitId,
          srcCommitUuid: CommitUUId,
          destCommitId: CommitId,
          destCommitUuid: CommitUUId,
          taskId: TaskId,
          taskType: TaskType.Value,
          retryAttemptNumber: Int,
          pullRequestState: PullRequestState.Value,
          attempt: Int,
          taskStatus: String,
          failureReason: Option[String],
          analysisDetectionTimestamp: Timestamp
      )
    }
  }

  case object audit extends PathPart {

    @eventDef case class eventCreated(
        orgId: OrganizationId,
        orgAuditId: UUID,
        actor: Actor,
        action: String,
        result: ActionResult.Value,
        source: Option[EventSource.Value],
        description: Option[String],
        repositoryName: Option[ProjectName],
        details: Option[String],
        entityId: Option[String]
    )
  }

  case object metric extends PathPart {

    @eventDef case class metricEntry(
        organizationId: Long,
        repositoryId: Option[Long],
        metric: String,
        value: Int,
        dimensions: Map[String, String]
    )
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy