Skip to content
5 changes: 5 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ This is the complete list of the available commands provided by the CLI.
| [configcat flag-v2 targeting percentage update](configcat-flag-v2-targeting-percentage-update.md) | Update or add the last percentage-only targeting rule |
| [configcat flag-v2 targeting percentage clear](configcat-flag-v2-targeting-percentage-clear.md) | Delete the last percentage-only rule |
| [configcat flag-v2 targeting percentage attribute](configcat-flag-v2-targeting-percentage-attribute.md) | Set the percentage evaluation attribute |
| [configcat flag-v2 variation](configcat-flag-v2-variation.md) | Manage Predefined Variations |
| [configcat flag-v2 variation create](configcat-flag-v2-variation-create.md) | Create a Predefined Variation |
| [configcat flag-v2 variation update](configcat-flag-v2-variation-update.md) | Update a Predefined Variation |
| [configcat flag-v2 variation rm](configcat-flag-v2-variation-rm.md) | Delete a Predefined Variation |
| [configcat flag-v2 variation ls](configcat-flag-v2-variation-ls.md) | List the Predefined Variations of a Feature Flag or Setting |
### configcat segment
| Command | Description |
| ------ | ----------- |
Expand Down
1 change: 1 addition & 0 deletions docs/configcat-flag-create.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ configcat flag create -c <config-id> -n "My awesome flag" -k myAwesomeFlag -t bo
| `--hint`, `-H` | Hint of the new Flag or Setting |
| `--init-value`, `-iv` | Initial value for each Environment |
| `--init-values-per-environment`, `-ive` | Initial value for specific Environments. Format: `<environment-id>:<initial-value>` |
| `--predefined-variations`, `-pv` | Predefined variations of the Feature Flag or Setting. Format: `<value>` or `<name>:<value>`. |
| `--type`, `-t` | Type of the new Flag or Setting<br/><br/>*Possible values*: `boolean`, `double`, `int`, `string` |
| `--tag-ids`, `-g` | Tags to attach |
| `--verbose`, `-v`, `/v` | Print detailed execution information |
Expand Down
1 change: 1 addition & 0 deletions docs/configcat-flag-v2-create.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ configcat flag create -c <config-id> -n "My awesome flag" -k myAwesomeFlag -t bo
| `--hint`, `-H` | Hint of the new Flag or Setting |
| `--init-value`, `-iv` | Initial value for each Environment |
| `--init-values-per-environment`, `-ive` | Initial value for specific Environments. Format: `<environment-id>:<initial-value>` |
| `--predefined-variations`, `-pv` | Predefined variations of the Feature Flag or Setting. Format: `<value>` or `<name>:<value>`. |
| `--type`, `-t` | Type of the new Flag or Setting<br/><br/>*Possible values*: `boolean`, `double`, `int`, `string` |
| `--tag-ids`, `-g` | Tags to attach |
| `--verbose`, `-v`, `/v` | Print detailed execution information |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ configcat flag-v2 targeting condition add prerequisite -i <flag-id> -e <environm
| `--rule-position`, `-rp` | The position of the targeting rule to which the condition is added |
| `--comparator`, `-c` | The operator which defines the relation between the evaluated value of the prerequisite flag and the comparison value<br/><br/>*Possible values*: `doesNotEqual`, `equals` |
| `--prerequisite-id`, `-pi` | ID of the prerequisite flag that the condition is based on |
| `--prerequisite-value`, `-pv` | The evaluated value of the prerequisite flag is compared to. It must respect the prerequisite flag's setting type |
| `--prerequisite-value`, `-pv` | The evaluated value of the prerequisite flag is compared to. It must respect the prerequisite flag's setting type. When the prerequisite flag has Predefined Variations, it must be either the Variation's ID or name |
| `--reason`, `-r` | The reason note for the Audit Log if the Product's 'Config changes require a reason' preference is turned on |
| `--verbose`, `-v`, `/v` | Print detailed execution information |
| `--non-interactive`, `-ni` | Turn off progress rendering and interactive features |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ configcat flag-v2 targeting rule create prerequisite -i <flag-id> -e <environmen
| `--environment-id`, `-e` | ID of the Environment where the rule must be created |
| `--comparator`, `-c` | The operator which defines the relation between the evaluated value of the prerequisite flag and the comparison value<br/><br/>*Possible values*: `doesNotEqual`, `equals` |
| `--prerequisite-id`, `-pi` | ID of the prerequisite flag that the condition is based on |
| `--prerequisite-value`, `-pv` | The evaluated value of the prerequisite flag is compared to. It must respect the prerequisite flag's setting type |
| `--served-value`, `-sv` | The value associated with the targeting rule. Leave it empty if the targeting rule has percentage options. It must respect the setting type |
| `--prerequisite-value`, `-pv` | The evaluated value of the prerequisite flag is compared to. It must respect the prerequisite flag's setting type. When the prerequisite flag has Predefined Variations, it either must be the Variation's ID or name |
| `--served-value`, `-sv` | The value associated with the targeting rule. Leave it empty if the targeting rule has percentage options. It must respect the setting type. When the flag has Predefined Variations, it must be either the Variation's ID or name |
| `-po`, `--percentage-options` | Format: `<percentage>:<value>`, e.g., `30:true 70:false` |
| `--reason`, `-r` | The reason note for the Audit Log if the Product's 'Config changes require a reason' preference is turned on |
| `--verbose`, `-v`, `/v` | Print detailed execution information |
Expand Down
2 changes: 1 addition & 1 deletion docs/configcat-flag-v2-targeting-rule-create-segment.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ configcat flag-v2 targeting rule create segment -i <flag-id> -e <environment-id>
| `--environment-id`, `-e` | ID of the Environment where the rule must be created |
| `--comparator`, `-c` | The operator which defines the expected result of the evaluation of the segment<br/><br/>*Possible values*: `isIn`, `isNotIn` |
| `--segment-id`, `-si` | ID of the segment that the condition is based on |
| `--served-value`, `-sv` | The value associated with the targeting rule. Leave it empty if the targeting rule has percentage options. It must respect the setting type |
| `--served-value`, `-sv` | The value associated with the targeting rule. Leave it empty if the targeting rule has percentage options. It must respect the setting type. When the flag has Predefined Variations, it must be either the Variation's ID or name |
| `-po`, `--percentage-options` | Format: `<percentage>:<value>`, e.g., `30:true 70:false` |
| `--reason`, `-r` | The reason note for the Audit Log if the Product's 'Config changes require a reason' preference is turned on |
| `--verbose`, `-v`, `/v` | Print detailed execution information |
Expand Down
2 changes: 1 addition & 1 deletion docs/configcat-flag-v2-targeting-rule-create-user.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ configcat flag-v2 targeting rule create user -i <flag-id> -e <environment-id> -a
| `--attribute`, `-a` | The User Object attribute that the condition is based on |
| `--comparator`, `-c` | The operator which defines the relation between the comparison attribute and the comparison value<br/><br/>*Possible values*: `arrayContainsAnyOf`, `arrayDoesNotContainAnyOf`, `containsAnyOf`, `dateTimeAfter`, `dateTimeBefore`, `doesNotContainAnyOf`, `isNotOneOf`, `isOneOf`, `numberDoesNotEqual`, `numberEquals`, `numberGreater`, `numberLess`, `numberLessOrEquals`, `semVerGreater`, `semVerGreaterOrEquals`, `semVerIsNotOneOf`, `semVerIsOneOf`, `semVerLess`, `semVerLessOrEquals`, `sensitiveArrayContainsAnyOf`, `sensitiveArrayDoesNotContainAnyOf`, `sensitiveIsNotOneOf`, `sensitiveIsOneOf`, `sensitiveTextDoesNotEqual`, `sensitiveTextEndsWithAnyOf`, `sensitiveTextEquals`, `sensitiveTextNotEndsWithAnyOf`, `sensitiveTextNotStartsWithAnyOf`, `sensitiveTextStartsWithAnyOf`, `textDoesNotEqual`, `textEndsWithAnyOf`, `textEquals`, `textNotEndsWithAnyOf`, `textNotStartsWithAnyOf`, `textStartsWithAnyOf` |
| `--comparison-value`, `-cv` | The value that the User Object attribute is compared to. Can be a double, string, or value-hint list in the format: `<value>:<hint>` |
| `--served-value`, `-sv` | The value associated with the targeting rule. Leave it empty if the targeting rule has percentage options. It must respect the setting type |
| `--served-value`, `-sv` | The value associated with the targeting rule. Leave it empty if the targeting rule has percentage options. It must respect the setting type. When the flag has Predefined Variations, it must be either the Variation's ID or name |
| `-po`, `--percentage-options` | Format: `<percentage>:<value>`, e.g., `30:true 70:false` |
| `--reason`, `-r` | The reason note for the Audit Log if the Product's 'Config changes require a reason' preference is turned on |
| `--verbose`, `-v`, `/v` | Print detailed execution information |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ configcat flag-v2 targeting rule usv -i <flag-id> -e <environment-id> -rp 1 -sv
| `--flag-id`, `-i`, `--setting-id` | ID of the Feature Flag or Setting |
| `--environment-id`, `-e` | ID of the Environment where the rule should be moved |
| `--rule-position`, `-rp` | The position of the targeting rule |
| `--served-value`, `-sv` | The value associated with the targeting rule. Leave it empty if the targeting rule has percentage options. It must respect the setting type |
| `--served-value`, `-sv` | The value associated with the targeting rule. Leave it empty if the targeting rule has percentage options. It must respect the setting type. When the flag has Predefined Variations, it must be either the Variation's ID or name |
| `-po`, `--percentage-options` | Format: `<percentage>:<value>`, e.g., `30:true 70:false` |
| `--reason`, `-r` | The reason note for the Audit Log if the Product's 'Config changes require a reason' preference is turned on |
| `--verbose`, `-v`, `/v` | Print detailed execution information |
Expand Down
26 changes: 26 additions & 0 deletions docs/configcat-flag-v2-variation-create.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# configcat flag-v2 variation create
Create a Predefined Variation
## Aliases
`cr`
## Usage
```
configcat flag-v2 variation create [options]
```
## Example
```
configcat flag-v2 variation create -i <flag-id> -name <variation-name> -sv <served-value>
```
## Options
| Option | Description |
| ------ | ----------- |
| `--flag-id`, `-i`, `--setting-id` | ID of the Feature Flag or Setting |
| `--name`, `-n` | Name of the new Predefined Variation |
| `--hint`, `-H` | Hint of the new Predefined Variation |
| `--served-value`, `-sv` | The value associated with the Predefined Variation. It must respect the setting type |
| `--verbose`, `-v`, `/v` | Print detailed execution information |
| `--non-interactive`, `-ni` | Turn off progress rendering and interactive features |
| `-h`, `/h`, `--help`, `-?`, `/?` | Show help and usage information |
## Parent Command
| Command | Description |
| ------ | ----------- |
| [configcat flag-v2 variation](configcat-flag-v2-variation.md) | Manage Predefined Variations |
21 changes: 21 additions & 0 deletions docs/configcat-flag-v2-variation-ls.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# configcat flag-v2 variation ls
List the Predefined Variations of a Feature Flag or Setting
## Usage
```
configcat flag-v2 variation ls [options]
```
## Example
```
configcat flag-v2 variation ls -i <flag-id>
```
## Options
| Option | Description |
| ------ | ----------- |
| `--flag-id`, `-i`, `--setting-id` | ID of the Feature Flag or Setting |
| `--verbose`, `-v`, `/v` | Print detailed execution information |
| `--non-interactive`, `-ni` | Turn off progress rendering and interactive features |
| `-h`, `/h`, `--help`, `-?`, `/?` | Show help and usage information |
## Parent Command
| Command | Description |
| ------ | ----------- |
| [configcat flag-v2 variation](configcat-flag-v2-variation.md) | Manage Predefined Variations |
22 changes: 22 additions & 0 deletions docs/configcat-flag-v2-variation-rm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# configcat flag-v2 variation rm
Delete a Predefined Variation
## Usage
```
configcat flag-v2 variation rm [options]
```
## Example
```
configcat flag-v2 variation rm -i <flag-id> -pvi <predefined-variation-id>
```
## Options
| Option | Description |
| ------ | ----------- |
| `--flag-id`, `-i`, `--setting-id` | ID of the Feature Flag or Setting |
| `--predefined-variation-id`, `-pvi` | ID of the Predefined Variation to update |
| `--verbose`, `-v`, `/v` | Print detailed execution information |
| `--non-interactive`, `-ni` | Turn off progress rendering and interactive features |
| `-h`, `/h`, `--help`, `-?`, `/?` | Show help and usage information |
## Parent Command
| Command | Description |
| ------ | ----------- |
| [configcat flag-v2 variation](configcat-flag-v2-variation.md) | Manage Predefined Variations |
27 changes: 27 additions & 0 deletions docs/configcat-flag-v2-variation-update.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# configcat flag-v2 variation update
Update a Predefined Variation
## Aliases
`up`
## Usage
```
configcat flag-v2 variation update [options]
```
## Example
```
configcat flag-v2 variation up -i <flag-id> -pvi <predefined-variation-id> -sv <served-value>
```
## Options
| Option | Description |
| ------ | ----------- |
| `--flag-id`, `-i`, `--setting-id` | ID of the Feature Flag or Setting |
| `--predefined-variation-id`, `-pvi` | ID of the Predefined Variation to update |
| `--name`, `-n` | Name of the new Predefined Variation |
| `--hint`, `-H` | Hint of the new Predefined Variation |
| `--served-value`, `-sv` | The value associated with the Predefined Variation. It must respect the setting type |
| `--verbose`, `-v`, `/v` | Print detailed execution information |
| `--non-interactive`, `-ni` | Turn off progress rendering and interactive features |
| `-h`, `/h`, `--help`, `-?`, `/?` | Show help and usage information |
## Parent Command
| Command | Description |
| ------ | ----------- |
| [configcat flag-v2 variation](configcat-flag-v2-variation.md) | Manage Predefined Variations |
25 changes: 25 additions & 0 deletions docs/configcat-flag-v2-variation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# configcat flag-v2 variation
Manage Predefined Variations
## Aliases
`var`
## Usage
```
configcat flag-v2 variation [command]
```
## Options
| Option | Description |
| ------ | ----------- |
| `--verbose`, `-v`, `/v` | Print detailed execution information |
| `--non-interactive`, `-ni` | Turn off progress rendering and interactive features |
| `-h`, `/h`, `--help`, `-?`, `/?` | Show help and usage information |
## Parent Command
| Command | Description |
| ------ | ----------- |
| [configcat flag-v2](configcat-flag-v2.md) | Manage V2 Feature Flags & Settings |
## Subcommands
| Command | Description |
| ------ | ----------- |
| [configcat flag-v2 variation create](configcat-flag-v2-variation-create.md) | Create a Predefined Variation |
| [configcat flag-v2 variation update](configcat-flag-v2-variation-update.md) | Update a Predefined Variation |
| [configcat flag-v2 variation rm](configcat-flag-v2-variation-rm.md) | Delete a Predefined Variation |
| [configcat flag-v2 variation ls](configcat-flag-v2-variation-ls.md) | List the Predefined Variations of a Feature Flag or Setting |
1 change: 1 addition & 0 deletions docs/configcat-flag-v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ configcat flag-v2 [command]
| [configcat flag-v2 detach](configcat-flag-v2-detach.md) | Detach Tag(s) from a Feature Flag or Setting |
| [configcat flag-v2 value](configcat-flag-v2-value.md) | Manage V2 Feature Flag & Setting default values in different Environments |
| [configcat flag-v2 targeting](configcat-flag-v2-targeting.md) | Manage V2 Feature Flag & Setting targeting options |
| [configcat flag-v2 variation](configcat-flag-v2-variation.md) | Manage Predefined Variations |
5 changes: 5 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ This is the complete list of the available commands provided by the CLI.
| [configcat flag-v2 targeting percentage update](configcat-flag-v2-targeting-percentage-update.md) | Update or add the last percentage-only targeting rule |
| [configcat flag-v2 targeting percentage clear](configcat-flag-v2-targeting-percentage-clear.md) | Delete the last percentage-only rule |
| [configcat flag-v2 targeting percentage attribute](configcat-flag-v2-targeting-percentage-attribute.md) | Set the percentage evaluation attribute |
| [configcat flag-v2 variation](configcat-flag-v2-variation.md) | Manage Predefined Variations |
| [configcat flag-v2 variation create](configcat-flag-v2-variation-create.md) | Create a Predefined Variation |
| [configcat flag-v2 variation update](configcat-flag-v2-variation-update.md) | Update a Predefined Variation |
| [configcat flag-v2 variation rm](configcat-flag-v2-variation-rm.md) | Delete a Predefined Variation |
| [configcat flag-v2 variation ls](configcat-flag-v2-variation-ls.md) | List the Predefined Variations of a Feature Flag or Setting |
### configcat segment
| Command | Description |
| ------ | ----------- |
Expand Down
6 changes: 4 additions & 2 deletions src/ConfigCat.Cli.Models/Api/CreateFlagModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ public class CreateFlagModel
public string Type { get; set; }

[JsonPropertyName("tags")]
public IEnumerable<int> TagIds { get; set; }
public List<int> TagIds { get; set; }

public IEnumerable<InitialValue> InitialValues { get; set; }
public List<InitialValue> InitialValues { get; set; }

public List<VariationModel> PredefinedVariations { get; set; }
}

public class InitialValue
Expand Down
20 changes: 19 additions & 1 deletion src/ConfigCat.Cli.Models/Api/FlagModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public class FlagModel

public List<TagModel> Tags { get; set; }

public List<VariationModel> PredefinedVariations { get; set; }

[JsonIgnore]
public List<string> Aliases { get; set; } = [];

Expand All @@ -41,4 +43,20 @@ public UpdateFlagModel ToUpdateModel() =>
};
}

public class DeletedFlagModel : FlagModel { }
public class DeletedFlagModel : FlagModel { }

public class VariationsModel
{
public List<VariationModel> PredefinedVariations { get; set; }
}

public class VariationModel
{
public ValueModel Value { get; set; }

public string Name { get; set; }

public string Hint { get; set; }

public string PredefinedVariationId { get; set; }
}
32 changes: 23 additions & 9 deletions src/ConfigCat.Cli.Models/Api/FlagValueV2Model.cs
Original file line number Diff line number Diff line change
@@ -1,28 +1,42 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;

namespace ConfigCat.Cli.Models.Api;

public class FlagValueV2Model
{
public ValueModel DefaultValue { get; set; }
public ValueWithPredefinedVariationModel DefaultValue { get; set; }
public List<TargetingRuleModel> TargetingRules { get; set; }
public string PercentageEvaluationAttribute { get; set; }
public FlagModel Setting { get; set; }
}

public class ValueModel
{
public bool? BoolValue { get; set; }
public string StringValue { get; set; }
public int? IntValue { get; set; }
public double? DoubleValue { get; set; }
public bool? BoolValue { get; init; }
public string StringValue { get; init; }
public int? IntValue { get; init; }
public double? DoubleValue { get; init; }


public override string ToString() => this.StringValue ?? this.BoolValue?.ToString() ?? this.IntValue?.ToString() ?? this.DoubleValue?.ToString() ?? string.Empty;

public override bool Equals(object obj) =>
obj is ValueModel other && BoolValue == other.BoolValue && StringValue == other.StringValue && IntValue == other.IntValue && Nullable.Equals(DoubleValue, other.DoubleValue);

public override int GetHashCode() => HashCode.Combine(BoolValue, StringValue, IntValue, DoubleValue);
}

public class ValueWithPredefinedVariationModel : ValueModel
{
public string PredefinedVariationId { get; set; }
}

public class TargetingRuleModel
{
public List<ConditionModel> Conditions { get; set; }
public List<PercentageOptionModel> PercentageOptions { get; set; }
public ValueModel Value { get; set; }
public ValueWithPredefinedVariationModel Value { get; set; }
}

public class ConditionModel
Expand All @@ -49,7 +63,7 @@ public class PrerequisiteFlagConditionModel
{
public int PrerequisiteSettingId { get; set; }
public string Comparator { get; set; }
public ValueModel PrerequisiteComparisonValue { get; set; }
public ValueWithPredefinedVariationModel PrerequisiteComparisonValue { get; set; }
}

public class ComparisonValueModel
Expand All @@ -68,5 +82,5 @@ public class ComparisonValueListModel
public class PercentageOptionModel
{
public int Percentage { get; set; }
public ValueModel Value { get; set; }
public ValueWithPredefinedVariationModel Value { get; set; }
}
Loading