package com.airlock.iam.techclientreg.application.configuration.step;

import com.airlock.iam.flow.api.application.configuration.selection.FlowConditionConfig;
import com.airlock.iam.flow.api.application.configuration.step.AbstractFlowStepConfig;
import com.airlock.iam.flow.api.application.configuration.step.NonInteractiveStepConfig;
import com.airlock.iam.flow.api.application.configuration.step.StepIdConfig;
import com.airlock.iam.flow.api.application.configuration.tag.TagConfig;
import com.airlock.iam.flow.api.application.configuration.valueprovider.ValueMapProviderConfig;
import com.airlock.iam.flow.types.api.application.configuration.step.StepConfigForTechClientRegFlows;
import com.airlock.iam.plugin.api.annotation.config.Plugin;
import com.airlock.iam.plugin.api.annotation.license.PluginLicenseRestriction;
import com.airlock.iam.plugin.api.annotation.property.GroupProperty;
import com.airlock.iam.plugin.api.annotation.property.PluginListProperty;
import com.airlock.iam.techclient.api.application.configuration.TechnicalClientInterceptorConfig;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import jakarta.annotation.Nullable;
import java.util.List;
import java.util.Map;

@Plugin(description = "Step for persisting a registered OAuth 2.0 client.", displayName = "OAuth 2.0 Client Persisting Step")
@PluginLicenseRestriction(moduleAffiliation = "TechClientRegistration")
public class OAuth2ClientPersistingStepConfig extends AbstractFlowStepConfig implements StepConfigForTechClientRegFlows, NonInteractiveStepConfig {
   @GroupProperty(groupIdentifier = "Basic Settings")
   @PluginListProperty(
      displayName = "Technical Client Interceptors",
      description = "Defines interceptors that get notified upon changes on technical clients.",
      optional = true
   )
   private List<TechnicalClientInterceptorConfig> interceptors;

   protected OAuth2ClientPersistingStepConfig(
      FlowConditionConfig skipCondition,
      FlowConditionConfig preCondition,
      boolean requiresActivation,
      List<TagConfig> tagsOnSuccess,
      @Nullable StepIdConfig stepId,
      Map<String, StepIdConfig> onFailureGotos,
      List<ValueMapProviderConfig> customResponseAttributes,
      List<ValueMapProviderConfig> customFailureResponseAttributes,
      List<TechnicalClientInterceptorConfig> interceptors
   ) {
      super(skipCondition, preCondition, requiresActivation, tagsOnSuccess, stepId, onFailureGotos, customResponseAttributes, customFailureResponseAttributes);
      this.interceptors = interceptors;
   }

   public List<TechnicalClientInterceptorConfig> getInterceptors() {
      return this.interceptors;
   }

   @SuppressFBWarnings(justification = "generated code")
   public static OAuth2ClientPersistingStepConfig.OAuth2ClientPersistingStepConfigBuilder builder() {
      return new OAuth2ClientPersistingStepConfig.OAuth2ClientPersistingStepConfigBuilder();
   }

   @SuppressFBWarnings(justification = "generated code")
   public OAuth2ClientPersistingStepConfig() {
   }

   @SuppressFBWarnings(justification = "generated code")
   public static class OAuth2ClientPersistingStepConfigBuilder {
      @SuppressFBWarnings(justification = "generated code")
      private FlowConditionConfig skipCondition;
      @SuppressFBWarnings(justification = "generated code")
      private FlowConditionConfig preCondition;
      @SuppressFBWarnings(justification = "generated code")
      private boolean requiresActivation;
      @SuppressFBWarnings(justification = "generated code")
      private List<TagConfig> tagsOnSuccess;
      @SuppressFBWarnings(justification = "generated code")
      private StepIdConfig stepId;
      @SuppressFBWarnings(justification = "generated code")
      private Map<String, StepIdConfig> onFailureGotos;
      @SuppressFBWarnings(justification = "generated code")
      private List<ValueMapProviderConfig> customResponseAttributes;
      @SuppressFBWarnings(justification = "generated code")
      private List<ValueMapProviderConfig> customFailureResponseAttributes;
      @SuppressFBWarnings(justification = "generated code")
      private List<TechnicalClientInterceptorConfig> interceptors;

      @SuppressFBWarnings(justification = "generated code")
      OAuth2ClientPersistingStepConfigBuilder() {
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2ClientPersistingStepConfig.OAuth2ClientPersistingStepConfigBuilder skipCondition(FlowConditionConfig skipCondition) {
         this.skipCondition = skipCondition;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2ClientPersistingStepConfig.OAuth2ClientPersistingStepConfigBuilder preCondition(FlowConditionConfig preCondition) {
         this.preCondition = preCondition;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2ClientPersistingStepConfig.OAuth2ClientPersistingStepConfigBuilder requiresActivation(boolean requiresActivation) {
         this.requiresActivation = requiresActivation;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2ClientPersistingStepConfig.OAuth2ClientPersistingStepConfigBuilder tagsOnSuccess(List<TagConfig> tagsOnSuccess) {
         this.tagsOnSuccess = tagsOnSuccess;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2ClientPersistingStepConfig.OAuth2ClientPersistingStepConfigBuilder stepId(@Nullable StepIdConfig stepId) {
         this.stepId = stepId;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2ClientPersistingStepConfig.OAuth2ClientPersistingStepConfigBuilder onFailureGotos(Map<String, StepIdConfig> onFailureGotos) {
         this.onFailureGotos = onFailureGotos;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2ClientPersistingStepConfig.OAuth2ClientPersistingStepConfigBuilder customResponseAttributes(
         List<ValueMapProviderConfig> customResponseAttributes
      ) {
         this.customResponseAttributes = customResponseAttributes;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2ClientPersistingStepConfig.OAuth2ClientPersistingStepConfigBuilder customFailureResponseAttributes(
         List<ValueMapProviderConfig> customFailureResponseAttributes
      ) {
         this.customFailureResponseAttributes = customFailureResponseAttributes;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2ClientPersistingStepConfig.OAuth2ClientPersistingStepConfigBuilder interceptors(List<TechnicalClientInterceptorConfig> interceptors) {
         this.interceptors = interceptors;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public OAuth2ClientPersistingStepConfig build() {
         return new OAuth2ClientPersistingStepConfig(
            this.skipCondition,
            this.preCondition,
            this.requiresActivation,
            this.tagsOnSuccess,
            this.stepId,
            this.onFailureGotos,
            this.customResponseAttributes,
            this.customFailureResponseAttributes,
            this.interceptors
         );
      }

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public String toString() {
         return "OAuth2ClientPersistingStepConfig.OAuth2ClientPersistingStepConfigBuilder(skipCondition="
            + this.skipCondition
            + ", preCondition="
            + this.preCondition
            + ", requiresActivation="
            + this.requiresActivation
            + ", tagsOnSuccess="
            + this.tagsOnSuccess
            + ", stepId="
            + this.stepId
            + ", onFailureGotos="
            + this.onFailureGotos
            + ", customResponseAttributes="
            + this.customResponseAttributes
            + ", customFailureResponseAttributes="
            + this.customFailureResponseAttributes
            + ", interceptors="
            + this.interceptors
            + ")";
      }
   }
}
