Values Class
A class for providing values for use with {@link VariableInputType.SELECT} and {@link VariableInputType.RADIO} dashboard variables.
Example
ts
import * as cw from 'aws-cdk-lib/aws-cloudwatch';
const dashboard = new cw.Dashboard(this, 'Dash', {
defaultInterval: Duration.days(7),
variables: [new cw.DashboardVariable({
id: 'region',
type: cw.VariableType.PROPERTY,
label: 'Region',
inputType: cw.VariableInputType.RADIO,
value: 'region',
values: cw.Values.fromValues({ label: 'IAD', value: 'us-east-1' }, { label: 'DUB', value: 'us-west-2' }),
defaultValue: cw.DefaultValue.value('us-east-1'),
visible: true,
})],
});
python
import aws_cdk.aws_cloudwatch as cw
dashboard = cw.Dashboard(self, "Dash",
default_interval=Duration.days(7),
variables=[cw.DashboardVariable(
id="region",
type=cw.VariableType.PROPERTY,
label="Region",
input_type=cw.VariableInputType.RADIO,
value="region",
values=cw.Values.from_values(cw.VariableValue(label="IAD", value="us-east-1"), label="DUB", value="us-west-2"),
default_value=cw.DefaultValue.value("us-east-1"),
visible=True
)]
)
java
import software.amazon.awscdk.services.cloudwatch.*;
Dashboard dashboard = Dashboard.Builder.create(this, "Dash")
.defaultInterval(Duration.days(7))
.variables(List.of(DashboardVariable.Builder.create()
.id("region")
.type(VariableType.PROPERTY)
.label("Region")
.inputType(VariableInputType.RADIO)
.value("region")
.values(Values.fromValues(VariableValue.builder().label("IAD").value("us-east-1").build(), VariableValue.builder().label("DUB").value("us-west-2").build()))
.defaultValue(DefaultValue.value("us-east-1"))
.visible(true)
.build()))
.build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK.AWS.CloudWatch;
var dashboard = new Dashboard(this, "Dash", new DashboardProps {
DefaultInterval = Duration.Days(7),
Variables = new [] { new DashboardVariable(new DashboardVariableOptions {
Id = "region",
Type = VariableType.PROPERTY,
Label = "Region",
InputType = VariableInputType.RADIO,
Value = "region",
Values = Values.FromValues(new VariableValue { Label = "IAD", Value = "us-east-1" }, new VariableValue { Label = "DUB", Value = "us-west-2" }),
DefaultValue = DefaultValue.Value("us-east-1"),
Visible = true
}) }
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import "github.com/aws/aws-cdk-go/awscdk"
dashboard := cw.NewDashboard(this, jsii.String("Dash"), &DashboardProps{
DefaultInterval: awscdk.Duration_Days(jsii.Number(7)),
Variables: []IVariable{
cw.NewDashboardVariable(&DashboardVariableOptions{
Id: jsii.String("region"),
Type: cw.VariableType_PROPERTY,
Label: jsii.String("Region"),
InputType: cw.VariableInputType_RADIO,
Value: jsii.String("region"),
Values: cw.Values_FromValues(&VariableValue{
Label: jsii.String("IAD"),
Value: jsii.String("us-east-1"),
}, &VariableValue{
Label: jsii.String("DUB"),
Value: jsii.String("us-west-2"),
}),
DefaultValue: cw.DefaultValue_Value(jsii.String("us-east-1")),
Visible: jsii.Boolean(true),
}),
},
})
Initializer
ts
new Values()
python
Values()
java
new Values()
csharp
new Values()
go
NewValues()
Methods
fromSearch(expression: string, populateFrom: string): Values // chainable@staticmethod def from_search(expression: str, populate_from: str) -> Valuespublic static Values fromSearch(String expression, String populateFrom)public static Values FromSearch(string expression, string populateFrom)func FromSearch(Expression *string, PopulateFrom *string) Valuesstatic#Create values from a search expression.
2 parameters
Parameters
expressionexpressionexpressionexpressionExpression— search expression that specifies a namespace, dimension name(s) and a metric name.populateFrompopulate_frompopulateFrompopulateFromPopulateFrom— dimension the dimension name, that the search expression retrieves, whose values will be used to populate the values to choose from.
fromSearchComponents(components: SearchComponents): Values // chainable@staticmethod def from_search_components(components: SearchComponents) -> Valuespublic static Values fromSearchComponents(SearchComponents components)public static Values FromSearchComponents(SearchComponents components)func FromSearchComponents(Components SearchComponents) Valuesstatic#Create values from the components of search expression.
fromValues(...values: VariableValue[]): Values // chainable@staticmethod def from_values(values: VariableValue) -> Valuespublic static Values fromValues(VariableValue values)public static Values FromValues(VariableValue values)func FromValues(Values VariableValue) Valuesstatic#Create values from an array of possible variable values.
toJson(): anydef to_json(self, ) -> Anypublic Object toJson()public object ToJson()func ToJson() interface{}#