gcloud beta app-lifecycle-manager flags create

NAME
gcloud beta app-lifecycle-manager flags create - create Flag
SYNOPSIS
gcloud beta app-lifecycle-manager flags create FLAG --flag-value-type=FLAG_VALUE_TYPE --key=KEY --unit-kind=UNIT_KIND [--annotations=[ANNOTATIONS,…]] [--description=DESCRIPTION] [--evaluation-spec=[allocations=ALLOCATIONS],[attributes=ATTRIBUTES],[defaultTarget=DEFAULTTARGET],[rules=RULES]] [--flag-set=FLAG_SET] [--labels=[LABELS,…]] [--location=LOCATION] [--state=STATE] [--variants=[booleanValue=BOOLEANVALUE],[description=DESCRIPTION],[doubleValue=DOUBLEVALUE],[id=ID],[integerValue=INTEGERVALUE],[stringValue=STRINGVALUE]] [GCLOUD_WIDE_FLAG]
DESCRIPTION
(BETA) Create a new feature flag resource. Flags define toggleable features or configurations that can be evaluated at runtime by applications.
EXAMPLES
To create a simple boolean flag with a default Disabled state, run:
gcloud beta app-lifecycle-manager flags create my-feature-flag --key=enable_new_feature --flag-value-type=bool --unit-kind=my-service-unit --variants='[{"id": "Enabled", "booleanValue": true}, {"id":
"Disabled", "booleanValue": false}]' \
   --evaluation-spec='{"defaultTarget": "Disabled"}' \
   --location=global

To create a percentage rollout (10% Enabled) using a userID attribute, run:

gcloud beta app-lifecycle-manager flags create beta-feature --key=beta_rollout --flag-value-type=bool --unit-kind=my-service-unit --variants='[{"id": "Enabled", "booleanValue": true}, {"id":
"Disabled", "booleanValue": false}]' \
   --evaluation-spec='{"allocations": [{"id": "p10",
"randomizedOn": "userID", "slots": [{"variant": "Disabled",
"weight": 90}, {"variant": "Enabled", "weight": 10}]}],
"defaultTarget": "p10", "attributes":
["projects/my-project/locations/global/flagAttributes/id-attr"]}' \
   --location=global
POSITIONAL ARGUMENTS
Flag resource - ID of the Flag:
"projects/{project}/locations/{location}/flags/{flag_id}"

This follows the standard Google Cloud naming scheme (URI). This represents a Cloud resource. (NOTE) Some attributes are not given arguments in this group but can be set in other ways.

To set the project attribute:

  • provide the argument flag on the command line with a fully specified name;
  • provide the argument --project on the command line;
  • set the property core/project.

To set the location attribute:

  • provide the argument flag on the command line with a fully specified name;
  • provide the argument --location on the command line.

This must be specified.

FLAG
ID of the flag or fully qualified identifier for the flag.

To set the flag attribute:

  • provide the argument flag on the command line.
REQUIRED FLAGS
--flag-value-type=FLAG_VALUE_TYPE
The type of the flag's value, e.g. BOOLEAN (required). FLAG_VALUE_TYPE must be one of:
bool
The flag's value type is a boolean.
double
The flag's value type is a double.
int
The flag's value type is an integer.
string
The flag's value type is a string.
--key=KEY
Flag key used in client runtime evaluation (required). Max length: 256 bytes.
UnitKind resource - Reference to the UnitKind that can consume this Flag. This represents a Cloud resource. (NOTE) Some attributes are not given arguments in this group but can be set in other ways.

To set the project attribute:

  • provide the argument --unit-kind on the command line with a fully specified name;
  • provide the argument --project on the command line;
  • set the property core/project.

To set the location attribute:

  • provide the argument --unit-kind on the command line with a fully specified name;
  • provide the argument --location on the command line.

This must be specified.

--unit-kind=UNIT_KIND
ID of the unitKind or fully qualified identifier for the unitKind.

To set the unit-kind attribute:

  • provide the argument --unit-kind on the command line.
OPTIONAL FLAGS
--annotations=[ANNOTATIONS,…]
Unstructured key-value map stored with a resource that may be set by external tools to store and retrieve arbitrary metadata. Annotations are not queryable and should be preserved when modifying objects.
KEY
Sets KEY value.
VALUE
Sets VALUE value.
Shorthand Example:
--annotations=string=string

JSON Example:

--annotations='{"string": "string"}'

File Example:

--annotations=path_to_file.(yaml|json)
--description=DESCRIPTION
A description of the flag. Max length: 500 bytes.
--evaluation-spec=[allocations=ALLOCATIONS],[attributes=ATTRIBUTES],[defaultTarget=DEFAULTTARGET],[rules=RULES]
Specification of how the Flag value should be evaluated.
allocations
A list of allocations.
description
A description of the allocation. Max length: 500 bytes.
id
Id of the allocation. Max length: 128 bytes.
randomizedOn
Key of the context attribute that is used for traffic splitting.
slots
Slots defines the weighted distribution of variants.
variant
Variant of the allocation slot.
weight
Weight defines the proportion of traffic to allocate to the variant, relative to other slots in the same allocation.
attributes
Names of the context attributes that are used in the evaluation rules and allocations.
defaultTarget
Default variant for the flag.
rules
Define the logic for evaluating the flag against a given context. The rules are evaluated sequentially in their specified order.
condition
A Common Expression Language (CEL cel.dev) expression evaluated against the evaluation context. For example: plan == "premium" && country == "DE".
id
A unique identifier for the rule.
target
The ID of the variant to return if the condition evaluates to true.
Shorthand Example:
--evaluation-spec=allocations=[{description=string,id=string,randomizedOn=string,slots=[{variant=string,weight=int}]}],attributes=[string],defaultTarget=string,rules=[{condition=string,id=string,target=string}]

JSON Example:

--evaluation-spec='{"allocations": [{"description": "string", "id": "string", "randomizedOn": "string", "slots": [{"variant": "string", "weight": int}]}], "attributes": ["string"], "defaultTarget": "string", "rules": [{"condition": "string", "id": "string", "target": "string"}]}'

File Example:

--evaluation-spec=path_to_file.(yaml|json)
--flag-set=FLAG_SET
Flag set this flag belongs to.
--labels=[LABELS,…]
The labels on the resource, which can be used for categorization.
KEY
Keys must start with a lowercase character and contain only hyphens (-), underscores (_), lowercase characters, and numbers.
VALUE
Values must contain only hyphens (-), underscores (_), lowercase characters, and numbers.
Shorthand Example:
--labels=string=string

JSON Example:

--labels='{"string": "string"}'

File Example:

--labels=path_to_file.(yaml|json)
--location=LOCATION
For resources [flag, unit-kind], provides fallback value for resource location attribute. When the resource's full URI path is not provided, location will fallback to this flag value.
--state=STATE
Current state of the flag. STATE must be one of:
active
The flag is in the active state.
cleanup
The flag is in the cleanup state and ready to be deleted.
in-development
The flag is currently in development.
sunsetting
The flag is in the sunsetting state, indicating it is being phased out.
--variants=[booleanValue=BOOLEANVALUE],[description=DESCRIPTION],[doubleValue=DOUBLEVALUE],[id=ID],[integerValue=INTEGERVALUE],[stringValue=STRINGVALUE]
A list of variants. Variant is an identifier for a value (name assigned to a value).
booleanValue
Value is a single boolean flag value for the variant.
description
A description of the variant. Max length: 500 bytes.
doubleValue
Value is a single double flag value for the variant.
id
Id of the variant. Max length: 128 bytes.
integerValue
Value is a single integer flag value for the variant.
stringValue
Value is a single string flag value for the variant. Max length: 500 bytes.
Shorthand Example:
--variants=booleanValue=boolean,description=string,doubleValue=float,id=string,integerValue=int,stringValue=string --variants=booleanValue=boolean,description=string,doubleValue=float,id=string,integerValue=int,stringValue=string

JSON Example:

--variants='[{"booleanValue": boolean, "description": "string", "doubleValue": float, "id": "string", "integerValue": int, "stringValue": "string"}]'

File Example:

--variants=path_to_file.(yaml|json)
GCLOUD WIDE FLAGS
These flags are available to all commands: --access-token-file, --account, --billing-project, --configuration, --flags-file, --flatten, --format, --help, --impersonate-service-account, --log-http, --project, --quiet, --trace-token, --user-output-enabled, --verbosity.

Run $ gcloud help for details.

API REFERENCE
This command uses the saasservicemgmt/v1beta1 API. The full documentation for this API can be found at: https://cloud.google.com/saas-runtime/docs
NOTES
This command is currently in beta and might change without notice.