mirror of https://github.com/open-feature/cli.git
208 lines
9.3 KiB
C#
208 lines
9.3 KiB
C#
// AUTOMATICALLY GENERATED BY OPENFEATURE CLI, DO NOT EDIT.
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
using OpenFeature;
|
|
using OpenFeature.Model;
|
|
|
|
namespace OpenFeature
|
|
{
|
|
/// <summary>
|
|
/// Generated OpenFeature client for typesafe flag access
|
|
/// </summary>
|
|
public class GeneratedClient
|
|
{
|
|
private readonly IFeatureClient _client;
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="GeneratedClient"/> class.
|
|
/// </summary>
|
|
/// <param name="client">The OpenFeature client to use for flag evaluations.</param>
|
|
public GeneratedClient(IFeatureClient client)
|
|
{
|
|
_client = client ?? throw new ArgumentNullException(nameof(client));
|
|
}
|
|
/// <summary>
|
|
/// Discount percentage applied to purchases.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// <para>Flag key: discountPercentage</para>
|
|
/// <para>Default value: 0.15</para>
|
|
/// <para>Type: float</para>
|
|
/// </remarks>
|
|
/// <param name="evaluationContext">Optional context for the flag evaluation</param>
|
|
/// <returns>The flag value</returns>
|
|
public async Task<float> DiscountPercentageAsync(EvaluationContext evaluationContext = null)
|
|
{
|
|
return await _client.GetFloatValueAsync("discountPercentage", 0.15, evaluationContext);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Discount percentage applied to purchases.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// <para>Flag key: discountPercentage</para>
|
|
/// <para>Default value: 0.15</para>
|
|
/// <para>Type: float</para>
|
|
/// </remarks>
|
|
/// <param name="evaluationContext">Optional context for the flag evaluation</param>
|
|
/// <returns>The evaluation details containing the flag value and metadata</returns>
|
|
public async Task<EvaluationDetails<float>> DiscountPercentageDetailsAsync(EvaluationContext evaluationContext = null)
|
|
{
|
|
return await _client.GetFloatDetailsAsync("discountPercentage", 0.15, evaluationContext);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Controls whether Feature A is enabled.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// <para>Flag key: enableFeatureA</para>
|
|
/// <para>Default value: false</para>
|
|
/// <para>Type: bool</para>
|
|
/// </remarks>
|
|
/// <param name="evaluationContext">Optional context for the flag evaluation</param>
|
|
/// <returns>The flag value</returns>
|
|
public async Task<bool> EnableFeatureAAsync(EvaluationContext evaluationContext = null)
|
|
{
|
|
return await _client.GetBoolValueAsync("enableFeatureA", false, evaluationContext);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Controls whether Feature A is enabled.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// <para>Flag key: enableFeatureA</para>
|
|
/// <para>Default value: false</para>
|
|
/// <para>Type: bool</para>
|
|
/// </remarks>
|
|
/// <param name="evaluationContext">Optional context for the flag evaluation</param>
|
|
/// <returns>The evaluation details containing the flag value and metadata</returns>
|
|
public async Task<EvaluationDetails<bool>> EnableFeatureADetailsAsync(EvaluationContext evaluationContext = null)
|
|
{
|
|
return await _client.GetBoolDetailsAsync("enableFeatureA", false, evaluationContext);
|
|
}
|
|
|
|
/// <summary>
|
|
/// The message to use for greeting users.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// <para>Flag key: greetingMessage</para>
|
|
/// <para>Default value: Hello there!</para>
|
|
/// <para>Type: string</para>
|
|
/// </remarks>
|
|
/// <param name="evaluationContext">Optional context for the flag evaluation</param>
|
|
/// <returns>The flag value</returns>
|
|
public async Task<string> GreetingMessageAsync(EvaluationContext evaluationContext = null)
|
|
{
|
|
return await _client.GetStringValueAsync("greetingMessage", "Hello there!", evaluationContext);
|
|
}
|
|
|
|
/// <summary>
|
|
/// The message to use for greeting users.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// <para>Flag key: greetingMessage</para>
|
|
/// <para>Default value: Hello there!</para>
|
|
/// <para>Type: string</para>
|
|
/// </remarks>
|
|
/// <param name="evaluationContext">Optional context for the flag evaluation</param>
|
|
/// <returns>The evaluation details containing the flag value and metadata</returns>
|
|
public async Task<EvaluationDetails<string>> GreetingMessageDetailsAsync(EvaluationContext evaluationContext = null)
|
|
{
|
|
return await _client.GetStringDetailsAsync("greetingMessage", "Hello there!", evaluationContext);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Allows customization of theme colors.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// <para>Flag key: themeCustomization</para>
|
|
/// <para>Default value: new Value(Structure.Builder().Set("primaryColor", "#007bff").Set("secondaryColor", "#6c757d").Build())</para>
|
|
/// <para>Type: object</para>
|
|
/// </remarks>
|
|
/// <param name="evaluationContext">Optional context for the flag evaluation</param>
|
|
/// <param name="options">Options for flag evaluation</param>
|
|
/// <returns>The flag value</returns>
|
|
public async Task<Value> ThemeCustomizationAsync(EvaluationContext? evaluationContext = null, FlagEvaluationOptions? options = null)
|
|
{
|
|
return await _client.GetObjectValueAsync("themeCustomization", new Value(Structure.Builder().Set("primaryColor", "#007bff").Set("secondaryColor", "#6c757d").Build()), evaluationContext, options);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Allows customization of theme colors.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// <para>Flag key: themeCustomization</para>
|
|
/// <para>Default value: new Value(Structure.Builder().Set("primaryColor", "#007bff").Set("secondaryColor", "#6c757d").Build())</para>
|
|
/// <para>Type: object</para>
|
|
/// </remarks>
|
|
/// <param name="evaluationContext">Optional context for the flag evaluation</param>
|
|
/// <param name="options">Options for flag evaluation</param>
|
|
/// <returns>The evaluation details containing the flag value and metadata</returns>
|
|
public async Task<FlagEvaluationDetails<Value>> ThemeCustomizationDetailsAsync(EvaluationContext? evaluationContext = null, FlagEvaluationOptions? options = null)
|
|
{
|
|
return await _client.GetObjectDetailsAsync("themeCustomization", new Value(Structure.Builder().Set("primaryColor", "#007bff").Set("secondaryColor", "#6c757d").Build()), evaluationContext, options);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Maximum allowed length for usernames.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// <para>Flag key: usernameMaxLength</para>
|
|
/// <para>Default value: 50</para>
|
|
/// <para>Type: int</para>
|
|
/// </remarks>
|
|
/// <param name="evaluationContext">Optional context for the flag evaluation</param>
|
|
/// <returns>The flag value</returns>
|
|
public async Task<int> UsernameMaxLengthAsync(EvaluationContext evaluationContext = null)
|
|
{
|
|
return await _client.GetIntValueAsync("usernameMaxLength", 50, evaluationContext);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Maximum allowed length for usernames.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// <para>Flag key: usernameMaxLength</para>
|
|
/// <para>Default value: 50</para>
|
|
/// <para>Type: int</para>
|
|
/// </remarks>
|
|
/// <param name="evaluationContext">Optional context for the flag evaluation</param>
|
|
/// <returns>The evaluation details containing the flag value and metadata</returns>
|
|
public async Task<EvaluationDetails<int>> UsernameMaxLengthDetailsAsync(EvaluationContext evaluationContext = null)
|
|
{
|
|
return await _client.GetIntDetailsAsync("usernameMaxLength", 50, evaluationContext);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Creates a new GeneratedClient using the default OpenFeature client
|
|
/// </summary>
|
|
/// <returns>A new GeneratedClient instance</returns>
|
|
public static GeneratedClient CreateClient()
|
|
{
|
|
return new GeneratedClient(Api.GetClient());
|
|
}
|
|
|
|
/// <summary>
|
|
/// Creates a new GeneratedClient using a domain-specific OpenFeature client
|
|
/// </summary>
|
|
/// <param name="domain">The domain to get the client for</param>
|
|
/// <returns>A new GeneratedClient instance</returns>
|
|
public static GeneratedClient CreateClient(string domain)
|
|
{
|
|
return new GeneratedClient(Api.GetClient(domain));
|
|
}
|
|
|
|
/// <summary>
|
|
/// Creates a new GeneratedClient using a domain-specific OpenFeature client with context
|
|
/// </summary>
|
|
/// <param name="domain">The domain to get the client for</param>
|
|
/// <param name="evaluationContext">Default context to use for evaluations</param>
|
|
/// <returns>A new GeneratedClient instance</returns>
|
|
public static GeneratedClient CreateClient(string domain, EvaluationContext evaluationContext)
|
|
{
|
|
return new GeneratedClient(Api.GetClient(domain, evaluationContext));
|
|
}
|
|
}
|
|
} |