// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 using System.Collections.Generic; using System.Threading.Tasks; using AWS.Deploy.Common.IO; using AWS.Deploy.Common.Recipes.Validation; namespace AWS.Deploy.Common.Recipes { /// /// This interface defines a contract used to control access to getting an setting values for /// public interface IOptionSettingHandler { /// /// This method runs all the option setting validators for the configurable settings. /// In case of a first time deployment, all settings and validators are run. /// In case of a redeployment, only the updatable settings are considered. /// List RunOptionSettingValidators(Recommendation recommendation, IEnumerable? optionSettings = null); /// /// This method is used to set values for . /// Due to different validations that could be put in place, access to other services may be needed. /// This method is meant to control access to those services and determine the value to be set. /// Task SetOptionSettingValue(Recommendation recommendation, OptionSettingItem optionSettingItem, object value, bool skipValidation = false); /// /// This method is used to set values for bases on the fullyQualifiedId of the option setting. /// Due to different validations that could be put in place, access to other services may be needed. /// This method is meant to control access to those services and determine the value to be set. /// Task SetOptionSettingValue(Recommendation recommendation, string fullyQualifiedId, object value, bool skipValidation = false); /// /// This method retrieves the related to a specific . /// OptionSettingItem GetOptionSetting(Recommendation recommendation, string? jsonPath); /// /// This method retrieves the related to a specific . /// OptionSettingItem GetOptionSetting(RecipeDefinition recipe, string? jsonPath); /// /// Retrieve the value for a specific /// This method retrieves the value in a specified type. /// T? GetOptionSettingValue(Recommendation recommendation, OptionSettingItem optionSetting); /// /// Retrieve the value for a specific /// This method retrieves the value as an object type. /// object GetOptionSettingValue(Recommendation recommendation, OptionSettingItem optionSetting); /// /// Retrieve the default value for a specific /// This method retrieves the default value in a specified type. /// T? GetOptionSettingDefaultValue(Recommendation recommendation, OptionSettingItem optionSetting); /// /// Retrieve the default value for a specific /// This method retrieves the default value as an object type. /// object? GetOptionSettingDefaultValue(Recommendation recommendation, OptionSettingItem optionSetting); /// /// Checks whether all the dependencies are satisfied or not, if there exists an unsatisfied dependency then returns false. /// It allows caller to decide whether we want to display an to configure or not. /// /// Returns true, if all the dependencies are satisfied, else false. bool IsOptionSettingDisplayable(Recommendation recommendation, OptionSettingItem optionSetting); /// /// Checks whether the Option Setting Item can be displayed as part of the settings summary of the previous deployment. /// bool IsSummaryDisplayable(Recommendation recommendation, OptionSettingItem optionSettingItem); /// /// Checks whether the option setting item has been modified by the user. If it has been modified, then it will hold a non-default value /// /// true if the option setting item has been modified or false otherwise bool IsOptionSettingModified(Recommendation recommendation, OptionSettingItem optionSetting); /// /// Returns a Dictionary containing the configurable option settings for the specified recommendation. The returned dictionary can contain specific types of option settings depending on the value of . /// The key in the dictionary is the fully qualified ID of each option setting /// The value in the dictionary is the value of each option setting /// Dictionary GetOptionSettingsMap(Recommendation recommendation, ProjectDefinition projectDefinition, IDirectoryManager directoryManager, OptionSettingsType optionSettingsType = OptionSettingsType.All); } }