package bio.terra.workspace.common.logging.model;

import bio.terra.workspace.common.exception.UnknownFlightClassNameException;
import bio.terra.workspace.service.resource.controlled.cloud.gcp.ainotebook.UpdateControlledAiNotebookResourceFlight;
import bio.terra.workspace.service.resource.controlled.cloud.gcp.bqdataset.UpdateControlledBigQueryDatasetResourceFlight;
import bio.terra.workspace.service.resource.controlled.cloud.gcp.gcsbucket.UpdateControlledGcsBucketResourceFlight;
import bio.terra.workspace.service.resource.controlled.flight.clone.bucket.CloneControlledGcsBucketResourceFlight;
import bio.terra.workspace.service.resource.controlled.flight.clone.dataset.CloneControlledGcpBigQueryDatasetResourceFlight;
import bio.terra.workspace.service.resource.controlled.flight.clone.workspace.CloneAllResourcesFlight;
import bio.terra.workspace.service.resource.controlled.flight.clone.workspace.CloneGcpWorkspaceFlight;
import bio.terra.workspace.service.resource.controlled.flight.create.CreateControlledResourceFlight;
import bio.terra.workspace.service.resource.controlled.flight.delete.DeleteControlledResourceFlight;
import bio.terra.workspace.service.resource.referenced.flight.create.CreateReferenceResourceFlight;
import bio.terra.workspace.service.resource.referenced.flight.update.UpdateReferenceResourceFlight;
import bio.terra.workspace.service.workspace.flight.CreateGcpContextFlightV2;
import bio.terra.workspace.service.workspace.flight.DeleteAzureContextFlight;
import bio.terra.workspace.service.workspace.flight.DeleteGcpContextFlight;
import bio.terra.workspace.service.workspace.flight.RemoveUserFromWorkspaceFlight;
import bio.terra.workspace.service.workspace.flight.WorkspaceCreateFlight;
import bio.terra.workspace.service.workspace.flight.WorkspaceDeleteFlight;
import bio.terra.workspace.service.workspace.flight.application.able.ApplicationAbleFlight;
import bio.terra.workspace.service.workspace.flight.create.azure.CreateAzureContextFlight;
import java.util.Arrays;

/**
 * All the workspace manager flights, contains the flight class name and the change target of the
 * corresponding flight. When a new flight is added in WSM, a new entry should be added here.
 */
public enum ActivityFlight {
  APPLICATION_ENABLED_FLIGHT(
      ApplicationAbleFlight.class.getName(), ActivityLogChangedTarget.APPLICATION),
  WORKSPACE_CREATE_FLIGHT(
      WorkspaceCreateFlight.class.getName(), ActivityLogChangedTarget.WORKSPACE),
  WORKSPACE_DELETE_FLIGHT(
      WorkspaceDeleteFlight.class.getName(), ActivityLogChangedTarget.WORKSPACE),
  CONTROLLED_RESOURCE_CREATE_FLIGHT(
      CreateControlledResourceFlight.class.getName(), ActivityLogChangedTarget.RESOURCE),
  CONTROLLED_AI_NOTEBOOK_UPDATE_FLIGHT(
      UpdateControlledAiNotebookResourceFlight.class.getName(), ActivityLogChangedTarget.RESOURCE),
  CONTROLLED_GCS_BUCKET_UPDATE_FLIGHT(
      UpdateControlledGcsBucketResourceFlight.class.getName(), ActivityLogChangedTarget.RESOURCE),
  CONTROLLED_GCS_BUCKET_CLONE_FLIGHT(
      CloneControlledGcsBucketResourceFlight.class.getName(), ActivityLogChangedTarget.RESOURCE),
  CONTROLLED_BQ_DATASET_UPDATE_FLIGHT(
      UpdateControlledBigQueryDatasetResourceFlight.class.getName(),
      ActivityLogChangedTarget.RESOURCE),
  CONTROLLED_BQ_DATASET_CLONE_FLIGHT(
      CloneControlledGcpBigQueryDatasetResourceFlight.class.getName(),
      ActivityLogChangedTarget.RESOURCE),
  CONTROLLED_RESOURCE_DELETE_FLIGHT(
      DeleteControlledResourceFlight.class.getName(), ActivityLogChangedTarget.RESOURCE),
  AZURE_CLOUD_CONTEXT_CREATE_FLIGHT(
      CreateAzureContextFlight.class.getName(), ActivityLogChangedTarget.AZURE_CLOUD_CONTEXT),
  AZURE_CLOUD_CONTEXT_DELETE_FLIGHT(
      DeleteAzureContextFlight.class.getName(), ActivityLogChangedTarget.AZURE_CLOUD_CONTEXT),
  GCP_CLOUD_CONTEXT_CREATE_FLIGHT(
      CreateGcpContextFlightV2.class.getName(), ActivityLogChangedTarget.GCP_CLOUD_CONTEXT),
  GCP_CLOUD_CONTEXT_DELETE_FLIGHT(
      DeleteGcpContextFlight.class.getName(), ActivityLogChangedTarget.GCP_CLOUD_CONTEXT),
  REMOVE_USER_FROM_WORKSPACE_FLIGHT(
      RemoveUserFromWorkspaceFlight.class.getName(), ActivityLogChangedTarget.USER),
  REFERENCED_RESOURCE_UPDATE_FLIGHT(
      UpdateReferenceResourceFlight.class.getName(), ActivityLogChangedTarget.RESOURCE),
  REFERENCED_RESOURCE_CREATE_FLIGHT(
      CreateReferenceResourceFlight.class.getName(), ActivityLogChangedTarget.RESOURCE),
  ALL_RESOURCES_CLONE_FLIGHT(
      CloneAllResourcesFlight.class.getName(), ActivityLogChangedTarget.RESOURCE),
  GCP_WORKSPACE_CLONE_FLIGHT(
      CloneGcpWorkspaceFlight.class.getName(), ActivityLogChangedTarget.WORKSPACE);

  private final String flightClassName;
  private final ActivityLogChangedTarget changedTarget;

  ActivityFlight(String flightClassName, ActivityLogChangedTarget changedTarget) {
    this.flightClassName = flightClassName;
    this.changedTarget = changedTarget;
  }

  public static ActivityFlight fromFlightClassName(String flightClassName) {
    return Arrays.stream(values())
        .filter(value -> value.flightClassName.equals(flightClassName))
        .findFirst()
        .orElseThrow(
            () ->
                new UnknownFlightClassNameException(
                    String.format(
                        "Flight class %s is unknown, add another enum to ActivityFlight",
                        flightClassName)));
  }

  public ActivityLogChangedTarget getActivityLogChangedTarget() {
    return changedTarget;
  }
}

@@ -2246,15 +2246,12 @@
 ION_
-EN
 ABLE
-D
 _FLI

Correct the name of this enum (#725)