using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ServiceClientGenerator { public class OperationPaginatorConfigOption { /// /// String name of the option /// public string Name { get; } /// /// If the response wraps a member containing /// the config option, set this to the name of /// that member. This is a workaround for /// SimpleWorkFlow /// public string WrappedResultMember { get; } /// /// Whether or not the provided option /// is a jmespath expression /// public bool IsJmesPath { get; } /// /// The member associated with the option /// public Member Member { get; } /// /// The property name of the member /// or the full name containing "." /// if jmespath /// public string PropertyName { get { if (IsJmesPath) { return Name; } if (WrappedResultMember != null) { return $"{WrappedResultMember}.{Member.PropertyName}"; } return Member.PropertyName; } } /// /// Support only result keys which are of type List /// public string ListItemType { get { var type = this.Member.DetermineType(); var pattern = "^List\\<[a-zA-Z0-9]+\\>$"; if (System.Text.RegularExpressions.Regex.IsMatch(type, pattern)) { return type.Substring(5, type.Length - 6); } return null; } } /// /// Whether or not this option is a list or a /// dictionary. Mostly used for input/output token- checking /// if it is null or if it is empty if list or dictionary /// public bool IsListOrDict { get { return this.Member.IsList || this.Member.IsMap; } } /// /// Create a new OperationPaginatorConfigOption object /// and set whether or not it is a jmespath expression /// /// Whether or not it is a jmespath expression /// Member associated with the option public OperationPaginatorConfigOption(bool isJmesPath, Member member) { IsJmesPath = isJmesPath; Member = member; } /// /// Create a new OperationPaginatorConfigOption object /// and set whether or not it is a jmespath expression /// /// Whether or not it is a jmespath expression /// Member associated with the option /// String name of the option as found in paginator config public OperationPaginatorConfigOption(bool isJmesPath, Member member, string name) : this(isJmesPath, member) { Name = name; } /// /// Create a new OperationPaginatorConfigOption object /// and set whether or not it is a jmespath expression /// /// Whether or not it is a jmespath expression /// Member associated with the option /// If the result of this operation is wrapped in a response /// object. (workaround for SimpleWorkFlow) public OperationPaginatorConfigOption(bool isJmesPath, string wrappedResultMember, Member member) : this(isJmesPath, member) { WrappedResultMember = wrappedResultMember; } } }