/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package org.apache.polaris.service.events;

public enum PolarisEventType {
  // Catalog Events
  BEFORE_CREATE_CATALOG(100),
  AFTER_CREATE_CATALOG(101),
  BEFORE_DELETE_CATALOG(102),
  AFTER_DELETE_CATALOG(103),
  BEFORE_GET_CATALOG(104),
  AFTER_GET_CATALOG(105),
  BEFORE_UPDATE_CATALOG(106),
  AFTER_UPDATE_CATALOG(107),
  BEFORE_LIST_CATALOGS(108),
  AFTER_LIST_CATALOGS(109),

  // Catalog Role Events
  BEFORE_CREATE_CATALOG_ROLE(200),
  AFTER_CREATE_CATALOG_ROLE(201),
  BEFORE_DELETE_CATALOG_ROLE(202),
  AFTER_DELETE_CATALOG_ROLE(203),
  BEFORE_GET_CATALOG_ROLE(204),
  AFTER_GET_CATALOG_ROLE(205),
  BEFORE_UPDATE_CATALOG_ROLE(206),
  AFTER_UPDATE_CATALOG_ROLE(207),
  BEFORE_LIST_CATALOG_ROLES(208),
  AFTER_LIST_CATALOG_ROLES(209),
  BEFORE_ADD_GRANT_TO_CATALOG_ROLE(210),
  AFTER_ADD_GRANT_TO_CATALOG_ROLE(211),
  BEFORE_REVOKE_GRANT_FROM_CATALOG_ROLE(212),
  AFTER_REVOKE_GRANT_FROM_CATALOG_ROLE(213),
  BEFORE_LIST_ASSIGNEE_PRINCIPAL_ROLES_FOR_CATALOG_ROLE(214),
  AFTER_LIST_ASSIGNEE_PRINCIPAL_ROLES_FOR_CATALOG_ROLE(215),
  BEFORE_LIST_GRANTS_FOR_CATALOG_ROLE(216),
  AFTER_LIST_GRANTS_FOR_CATALOG_ROLE(217),

  // Principal Events
  BEFORE_CREATE_PRINCIPAL(300),
  AFTER_CREATE_PRINCIPAL(301),
  BEFORE_DELETE_PRINCIPAL(302),
  AFTER_DELETE_PRINCIPAL(303),
  BEFORE_GET_PRINCIPAL(304),
  AFTER_GET_PRINCIPAL(305),
  BEFORE_UPDATE_PRINCIPAL(306),
  AFTER_UPDATE_PRINCIPAL(307),
  BEFORE_ROTATE_CREDENTIALS(308),
  AFTER_ROTATE_CREDENTIALS(309),
  BEFORE_RESET_CREDENTIALS(310),
  AFTER_RESET_CREDENTIALS(311),
  BEFORE_LIST_PRINCIPALS(312),
  AFTER_LIST_PRINCIPALS(313),
  BEFORE_ASSIGN_PRINCIPAL_ROLE(314),
  AFTER_ASSIGN_PRINCIPAL_ROLE(315),
  BEFORE_REVOKE_PRINCIPAL_ROLE(316),
  AFTER_REVOKE_PRINCIPAL_ROLE(317),
  BEFORE_LIST_ASSIGNED_PRINCIPAL_ROLES(318),
  AFTER_LIST_ASSIGNED_PRINCIPAL_ROLES(319),

  // Principal Role Events
  BEFORE_CREATE_PRINCIPAL_ROLE(400),
  AFTER_CREATE_PRINCIPAL_ROLE(401),
  BEFORE_DELETE_PRINCIPAL_ROLE(402),
  AFTER_DELETE_PRINCIPAL_ROLE(403),
  BEFORE_GET_PRINCIPAL_ROLE(404),
  AFTER_GET_PRINCIPAL_ROLE(405),
  BEFORE_UPDATE_PRINCIPAL_ROLE(406),
  AFTER_UPDATE_PRINCIPAL_ROLE(407),
  BEFORE_LIST_PRINCIPAL_ROLES(408),
  AFTER_LIST_PRINCIPAL_ROLES(409),
  BEFORE_ASSIGN_CATALOG_ROLE_TO_PRINCIPAL_ROLE(410),
  AFTER_ASSIGN_CATALOG_ROLE_TO_PRINCIPAL_ROLE(411),
  BEFORE_REVOKE_CATALOG_ROLE_FROM_PRINCIPAL_ROLE(412),
  AFTER_REVOKE_CATALOG_ROLE_FROM_PRINCIPAL_ROLE(413),
  BEFORE_LIST_ASSIGNEE_PRINCIPALS_FOR_PRINCIPAL_ROLE(414),
  AFTER_LIST_ASSIGNEE_PRINCIPALS_FOR_PRINCIPAL_ROLE(415),
  BEFORE_LIST_CATALOG_ROLES_FOR_PRINCIPAL_ROLE(416),
  AFTER_LIST_CATALOG_ROLES_FOR_PRINCIPAL_ROLE(417),

  // Namespace Events
  BEFORE_CREATE_NAMESPACE(500),
  AFTER_CREATE_NAMESPACE(501),
  BEFORE_LIST_NAMESPACES(502),
  AFTER_LIST_NAMESPACES(503),
  BEFORE_LOAD_NAMESPACE_METADATA(504),
  AFTER_LOAD_NAMESPACE_METADATA(505),
  BEFORE_CHECK_EXISTS_NAMESPACE(506),
  AFTER_CHECK_EXISTS_NAMESPACE(507),
  BEFORE_DROP_NAMESPACE(508),
  AFTER_DROP_NAMESPACE(509),
  BEFORE_UPDATE_NAMESPACE_PROPERTIES(510),
  AFTER_UPDATE_NAMESPACE_PROPERTIES(511),

  // Table Events
  BEFORE_CREATE_TABLE(600),
  AFTER_CREATE_TABLE(601),
  BEFORE_LIST_TABLES(602),
  AFTER_LIST_TABLES(603),
  BEFORE_LOAD_TABLE(604),
  AFTER_LOAD_TABLE(605),
  BEFORE_CHECK_EXISTS_TABLE(606),
  AFTER_CHECK_EXISTS_TABLE(607),
  BEFORE_DROP_TABLE(608),
  AFTER_DROP_TABLE(609),
  BEFORE_REGISTER_TABLE(610),
  AFTER_REGISTER_TABLE(611),
  BEFORE_RENAME_TABLE(612),
  AFTER_RENAME_TABLE(613),
  BEFORE_UPDATE_TABLE(614),
  AFTER_UPDATE_TABLE(615),
  BEFORE_REFRESH_TABLE(616),
  AFTER_REFRESH_TABLE(617),

  // View Events
  BEFORE_CREATE_VIEW(700),
  AFTER_CREATE_VIEW(701),
  BEFORE_LIST_VIEWS(702),
  AFTER_LIST_VIEWS(703),
  BEFORE_LOAD_VIEW(704),
  AFTER_LOAD_VIEW(705),
  BEFORE_CHECK_EXISTS_VIEW(706),
  AFTER_CHECK_EXISTS_VIEW(707),
  BEFORE_DROP_VIEW(708),
  AFTER_DROP_VIEW(709),
  BEFORE_RENAME_VIEW(710),
  AFTER_RENAME_VIEW(711),
  BEFORE_REPLACE_VIEW(712),
  AFTER_REPLACE_VIEW(713),
  BEFORE_REFRESH_VIEW(714),
  AFTER_REFRESH_VIEW(715),

  // Credential Events
  BEFORE_LOAD_CREDENTIALS(800),
  AFTER_LOAD_CREDENTIALS(801),
  // Transaction Events
  BEFORE_COMMIT_TRANSACTION(900),
  AFTER_COMMIT_TRANSACTION(901),
  // Notification Events
  BEFORE_SEND_NOTIFICATION(1000),
  AFTER_SEND_NOTIFICATION(1001),

  // Configuration Events
  BEFORE_GET_CONFIG(1100),
  AFTER_GET_CONFIG(1101),

  // Policy Events
  BEFORE_CREATE_POLICY(1200),
  AFTER_CREATE_POLICY(1201),
  BEFORE_LIST_POLICIES(1202),
  AFTER_LIST_POLICIES(1203),
  BEFORE_LOAD_POLICY(1204),
  AFTER_LOAD_POLICY(1205),
  BEFORE_UPDATE_POLICY(1206),
  AFTER_UPDATE_POLICY(1207),
  BEFORE_DROP_POLICY(1208),
  AFTER_DROP_POLICY(1209),
  BEFORE_ATTACH_POLICY(1210),
  AFTER_ATTACH_POLICY(1211),
  BEFORE_DETACH_POLICY(1212),
  AFTER_DETACH_POLICY(1213),
  BEFORE_GET_APPLICABLE_POLICIES(1214),
  AFTER_GET_APPLICABLE_POLICIES(1215),

  // Generic Table Events
  BEFORE_CREATE_GENERIC_TABLE(1300),
  AFTER_CREATE_GENERIC_TABLE(1301),
  BEFORE_DROP_GENERIC_TABLE(1302),
  AFTER_DROP_GENERIC_TABLE(1303),
  BEFORE_LIST_GENERIC_TABLES(1304),
  AFTER_LIST_GENERIC_TABLES(1305),
  BEFORE_LOAD_GENERIC_TABLE(1306),
  AFTER_LOAD_GENERIC_TABLE(1307),

  // Task Execution Events
  BEFORE_ATTEMPT_TASK(1400),
  AFTER_ATTEMPT_TASK(1401),

  // Rate Limiting Events
  BEFORE_LIMIT_REQUEST_RATE(1500);

  private final int code;

  private PolarisEventType(int code) {
    this.code = code;
  }

  public int code() {
    return code;
  }
}
