package com.l7tech.gateway.common.cluster;

import com.l7tech.common.io.failover.FailoverStrategy;
import com.l7tech.gateway.common.AsyncAdminMethods;
import com.l7tech.gateway.common.InvalidLicenseException;
import com.l7tech.gateway.common.admin.Administrative;
import com.l7tech.gateway.common.licensing.CompositeLicense;
import com.l7tech.gateway.common.licensing.FeatureLicense;
import com.l7tech.gateway.common.licensing.LicenseDocument;
import com.l7tech.gateway.common.module.AssertionModuleInfo;
import com.l7tech.gateway.common.module.ServerModuleConfig;
import com.l7tech.gateway.common.module.ServerModuleFile;
import com.l7tech.gateway.common.security.rbac.MethodStereotype;
import com.l7tech.gateway.common.security.rbac.Secured;
import com.l7tech.gateway.common.service.MetricsSummaryBin;
import com.l7tech.objectmodel.DeleteException;
import com.l7tech.objectmodel.EntityType;
import com.l7tech.objectmodel.FindException;
import com.l7tech.objectmodel.Goid;
import com.l7tech.objectmodel.SaveException;
import com.l7tech.objectmodel.UpdateException;
import com.l7tech.util.CollectionUpdate;
import com.l7tech.util.Either;
import com.l7tech.util.Option;
import com.l7tech.util.Pair;
import java.io.Serializable;
import java.security.KeyStoreException;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Secured
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
@Administrative
public interface ClusterStatusAdmin extends AsyncAdminMethods {
   String CAPABILITY_LUNACLIENT = "keystore.luna";
   String CAPABILITY_PROPERTY_LUNAPIN = "keystore.luna.clientPin";
   String CAPABILITY_FIREWALL = "appliance.firewall";
   String CAPABILITY_SITEMINDER = "siteminder";

   @Transactional(readOnly = true)
   @Secured(types = EntityType.CLUSTER_INFO, stereotype = MethodStereotype.FIND_ENTITIES)
   @Administrative(licensed = false)
   boolean isCluster();

   @Transactional(readOnly = true)
   @Secured(types = EntityType.CLUSTER_INFO, stereotype = MethodStereotype.FIND_ENTITIES)
   @Administrative(licensed = false, background = true)
   ClusterNodeInfo[] getClusterStatus() throws FindException;

   @Transactional(readOnly = true)
   @Secured(types = EntityType.CLUSTER_INFO, stereotype = MethodStereotype.FIND_ENTITIES)
   @Administrative(licensed = false, background = true)
   CollectionUpdate<ClusterNodeInfo> getClusterNodesUpdate(int var1) throws FindException;

   @Transactional(readOnly = true)
   @Secured(types = EntityType.SERVICE_USAGE, stereotype = MethodStereotype.FIND_ENTITIES)
   @Administrative(background = true)
   ServiceUsage[] getServiceUsage() throws FindException;

   @Secured(types = EntityType.CLUSTER_INFO, stereotype = MethodStereotype.SET_PROPERTY_BY_UNIQUE_ATTRIBUTE)
   void changeNodeName(String var1, String var2) throws UpdateException;

   @Secured(types = EntityType.CLUSTER_INFO, stereotype = MethodStereotype.DELETE_BY_UNIQUE_ATTRIBUTE)
   void removeStaleNode(String var1) throws DeleteException;

   @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
   @Administrative(licensed = false, background = true)
   @Secured(stereotype = MethodStereotype.UNCHECKED_WIDE_OPEN)
   Date getCurrentClusterSystemTime();

   @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
   @Administrative(licensed = false)
   @Secured(stereotype = MethodStereotype.UNCHECKED_WIDE_OPEN)
   String getCurrentClusterTimeZone();

   @Administrative(licensed = false)
   @Secured(stereotype = MethodStereotype.UNCHECKED_WIDE_OPEN)
   String getSelfNodeName();

   @Transactional(readOnly = true)
   @Secured(types = EntityType.CLUSTER_INFO, stereotype = MethodStereotype.FIND_ENTITY)
   @Administrative(licensed = false)
   ClusterNodeInfo getSelfNode();

   @Transactional(readOnly = true)
   @Secured(types = EntityType.CLUSTER_PROPERTY, stereotype = MethodStereotype.FIND_ENTITIES)
   @Administrative(licensed = false)
   Collection<ClusterProperty> getAllProperties() throws FindException;

   @Deprecated
   @Transactional(readOnly = true)
   @Administrative(licensed = false)
   @Secured(stereotype = MethodStereotype.UNCHECKED_WIDE_OPEN)
   Map getKnownProperties();

   @Transactional(readOnly = true)
   @Administrative(licensed = false)
   @Secured(stereotype = MethodStereotype.UNCHECKED_WIDE_OPEN)
   Set<String> getRegisteredPropertyNames();

   @Transactional(readOnly = true)
   @Administrative(licensed = false)
   @Secured(stereotype = MethodStereotype.UNCHECKED_WIDE_OPEN)
   Collection<ClusterPropertyDescriptor> getAllPropertyDescriptors();

   @Transactional(readOnly = true)
   @Administrative(licensed = false)
   @Secured(stereotype = MethodStereotype.UNCHECKED_WIDE_OPEN)
   ClusterPropertyDescriptor getPropertyDescriptorByName(String var1);

   @Transactional(readOnly = true)
   @Secured(types = EntityType.CLUSTER_PROPERTY, stereotype = MethodStereotype.FIND_ENTITY)
   @Administrative(licensed = false)
   ClusterProperty findPropertyByName(String var1) throws FindException;

   @Secured(types = EntityType.CLUSTER_PROPERTY, stereotype = MethodStereotype.SAVE_OR_UPDATE)
   @Administrative(licensed = false)
   Goid saveProperty(ClusterProperty var1) throws SaveException, UpdateException, DeleteException;

   @Secured(types = EntityType.CLUSTER_PROPERTY, stereotype = MethodStereotype.DELETE_ENTITY)
   @Administrative(licensed = false)
   void deleteProperty(ClusterProperty var1) throws DeleteException;

   @Secured(types = EntityType.CLUSTER_PROPERTY, stereotype = MethodStereotype.DELETE_MULTI)
   @Administrative(licensed = false)
   void deleteBulkProperties(Collection<ClusterProperty> var1) throws DeleteException;

   @Transactional(readOnly = true)
   @Administrative(licensed = false)
   @Secured(stereotype = MethodStereotype.UNCHECKED_WIDE_OPEN)
   CompositeLicense getCompositeLicense();

   @Administrative(licensed = false)
   @Secured(stereotype = MethodStereotype.UNCHECKED_WIDE_OPEN)
   long getLicenseExpiryWarningPeriod();

   @Transactional(readOnly = true)
   @Administrative(licensed = false)
   @Secured(stereotype = MethodStereotype.UNCHECKED_WIDE_OPEN)
   FeatureLicense createLicense(LicenseDocument var1) throws InvalidLicenseException;

   @Transactional(readOnly = true)
   @Administrative(licensed = false)
   @Secured(stereotype = MethodStereotype.UNCHECKED_WIDE_OPEN)
   void validateLicense(FeatureLicense var1) throws InvalidLicenseException;

   @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
   @Secured(types = EntityType.LICENSE_DOCUMENT, stereotype = MethodStereotype.SAVE)
   @Administrative(licensed = false)
   AsyncAdminMethods.JobId<Boolean> installLicense(FeatureLicense var1);

   @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
   @Secured(types = EntityType.LICENSE_DOCUMENT, stereotype = MethodStereotype.DELETE_MULTI)
   @Administrative(licensed = false)
   AsyncAdminMethods.JobId<Boolean> uninstallLicense(LicenseDocument var1);

   @Transactional(readOnly = true)
   @Administrative(licensed = false)
   @Secured(stereotype = MethodStereotype.UNCHECKED_WIDE_OPEN)
   Map<String, Long> getGoidUpgradeMap();

   @Transactional(readOnly = true)
   @Administrative(background = true)
   @Secured(stereotype = MethodStereotype.UNCHECKED_WIDE_OPEN)
   boolean isMetricsEnabled();

   @Administrative(background = true)
   @Secured(stereotype = MethodStereotype.UNCHECKED_WIDE_OPEN)
   boolean isServiceUsageEnabled();

   @Transactional(readOnly = true)
   @Administrative
   @Secured(stereotype = MethodStereotype.UNCHECKED_WIDE_OPEN)
   int getMetricsFineInterval();

   @Transactional(readOnly = true)
   @Administrative(background = true)
   @Secured(stereotype = MethodStereotype.UNCHECKED_WIDE_OPEN)
   Collection<MetricsSummaryBin> summarizeByPeriod(String var1, Goid[] var2, Integer var3, Long var4, Long var5, boolean var6) throws FindException;

   @Transactional(readOnly = true)
   @Administrative(background = true)
   @Secured(stereotype = MethodStereotype.UNCHECKED_WIDE_OPEN)
   Collection<MetricsSummaryBin> summarizeLatestByPeriod(String var1, Goid[] var2, Integer var3, long var4, boolean var6) throws FindException;

   @Transactional(readOnly = true)
   @Administrative(background = true)
   @Secured(stereotype = MethodStereotype.UNCHECKED_WIDE_OPEN)
   MetricsSummaryBin summarizeLatest(String var1, Goid[] var2, int var3, int var4, boolean var5) throws FindException;

   @Transactional(readOnly = true)
   @Secured(stereotype = MethodStereotype.UNCHECKED_WIDE_OPEN)
   @NotNull
   List<String> getConfiguredDateFormats();

   @Transactional(readOnly = true)
   @Secured(stereotype = MethodStereotype.UNCHECKED_WIDE_OPEN)
   @NotNull
   List<Pair<String, Pattern>> getAutoDateFormats();

   @Transactional(propagation = Propagation.SUPPORTS)
   @Secured(stereotype = MethodStereotype.UNCHECKED_WIDE_OPEN)
   Collection<AssertionModuleInfo> getAssertionModuleInfo();

   @Transactional(propagation = Propagation.SUPPORTS)
   @Secured(stereotype = MethodStereotype.UNCHECKED_WIDE_OPEN)
   @Nullable
   AssertionModuleInfo getModuleInfoForAssertionClass(@NotNull String var1) throws ClusterStatusAdmin.ModuleNotFoundException;

   @Transactional(propagation = Propagation.SUPPORTS)
   @Secured(stereotype = MethodStereotype.UNCHECKED_WIDE_OPEN)
   Collection<Pair<String, String>> getExtensionInterfaceInstances();

   @Transactional(propagation = Propagation.SUPPORTS)
   @Secured(stereotype = MethodStereotype.UNCHECKED_WIDE_OPEN)
   boolean isExtensionInterfaceAvailable(String var1, String var2);

   @Transactional(propagation = Propagation.SUPPORTS)
   @Secured(stereotype = MethodStereotype.UNCHECKED_WIDE_OPEN)
   Either<Throwable, Option<Object>> invokeExtensionMethod(String var1, String var2, String var3, Class[] var4, Object[] var5) throws ClassNotFoundException, NoSuchMethodException;

   @Transactional(propagation = Propagation.SUPPORTS)
   @Administrative(licensed = false)
   @Secured(stereotype = MethodStereotype.UNCHECKED_WIDE_OPEN)
   String getHardwareCapability(String var1);

   @Transactional(propagation = Propagation.SUPPORTS)
   @Secured(stereotype = MethodStereotype.UNCHECKED_WIDE_OPEN)
   Serializable getHardwareCapabilityProperty(String var1, String var2) throws ClusterStatusAdmin.NoSuchCapabilityException, ClusterStatusAdmin.NoSuchPropertyException;

   @Secured(stereotype = MethodStereotype.DELETE_MULTI, types = EntityType.SSG_KEY_ENTRY)
   void putHardwareCapabilityProperty(String var1, String var2, Serializable var3) throws ClusterStatusAdmin.NoSuchCapabilityException, ClusterStatusAdmin.NoSuchPropertyException, ClassCastException, IllegalArgumentException;

   @Secured(stereotype = MethodStereotype.UNCHECKED_WIDE_OPEN)
   void testHardwareTokenAvailability(String var1, String var2, char[] var3) throws ClusterStatusAdmin.NoSuchCapabilityException, KeyStoreException;

   @Secured(stereotype = MethodStereotype.UNCHECKED_WIDE_OPEN)
   FailoverStrategy[] getAllFailoverStrategies();

   @Transactional(readOnly = true)
   @Secured(types = EntityType.SERVER_MODULE_FILE, stereotype = MethodStereotype.FIND_ENTITIES)
   @NotNull
   List<ServerModuleFile> findAllServerModuleFiles() throws FindException;

   @Transactional(readOnly = true)
   @Secured(types = EntityType.CLUSTER_INFO, stereotype = MethodStereotype.FIND_ENTITIES)
   @Administrative(licensed = false, background = true)
   CollectionUpdate<ServerModuleFile> getServerModuleFileUpdate(int var1) throws FindException;

   @Transactional(readOnly = true)
   @Secured(types = EntityType.SERVER_MODULE_FILE, stereotype = MethodStereotype.FIND_ENTITY)
   @Nullable
   ServerModuleFile findServerModuleFileById(@NotNull Goid var1, boolean var2) throws FindException;

   @Secured(types = EntityType.SERVER_MODULE_FILE, stereotype = MethodStereotype.SAVE)
   @NotNull
   Goid saveServerModuleFile(@NotNull byte[] var1, @NotNull String var2, @Nullable String var3) throws SaveException;

   @Secured(types = EntityType.SERVER_MODULE_FILE, stereotype = MethodStereotype.UPDATE)
   void updateServerModuleFileName(@NotNull Goid var1, @NotNull String var2) throws FindException, UpdateException;

   @Secured(types = EntityType.SERVER_MODULE_FILE, stereotype = MethodStereotype.DELETE_BY_ID)
   void deleteServerModuleFile(@NotNull Goid var1) throws DeleteException;

   @Transactional(propagation = Propagation.SUPPORTS)
   @Secured(stereotype = MethodStereotype.UNCHECKED_WIDE_OPEN)
   @NotNull
   ServerModuleConfig getServerModuleConfig();

   final class ModuleNotFoundException extends Exception {
      private static final long serialVersionUID = 982374277812732928L;
   }

   final class NoSuchCapabilityException extends Exception {
      private static final long serialVersionUID = 682345724356023459L;
   }

   final class NoSuchPropertyException extends Exception {
      private static final long serialVersionUID = 356702534346778195L;
   }
}
