createDimension method
Create a dimension that you can use to limit the scope of a metric used in
a security profile for AWS IoT Device Defender. For example, using a
TOPIC_FILTER
dimension, you can narrow down the scope of the
metric only to MQTT topics whose name match the pattern specified in the
dimension.
May throw InternalFailureException. May throw InvalidRequestException. May throw LimitExceededException. May throw ResourceAlreadyExistsException. May throw ThrottlingException.
Parameter name
:
A unique identifier for the dimension. Choose something that describes the
type and value to make it easy to remember what it does.
Parameter stringValues
:
Specifies the value or list of values for the dimension. For
TOPIC_FILTER
dimensions, this is a pattern used to match the
MQTT topic (for example, "admin/#").
Parameter type
:
Specifies the type of dimension. Supported types:
TOPIC_FILTER.
Parameter clientRequestToken
:
Each dimension must have a unique client request token. If you try to
create a new dimension with the same token as a dimension that already
exists, an exception occurs. If you omit this value, AWS SDKs will
automatically generate a unique client request.
Parameter tags
:
Metadata that can be used to manage the dimension.
Implementation
Future<CreateDimensionResponse> createDimension({
required String name,
required List<String> stringValues,
required DimensionType type,
String? clientRequestToken,
List<Tag>? tags,
}) async {
ArgumentError.checkNotNull(name, 'name');
_s.validateStringLength(
'name',
name,
1,
128,
isRequired: true,
);
ArgumentError.checkNotNull(stringValues, 'stringValues');
ArgumentError.checkNotNull(type, 'type');
_s.validateStringLength(
'clientRequestToken',
clientRequestToken,
1,
64,
);
final $payload = <String, dynamic>{
'stringValues': stringValues,
'type': type.toValue(),
'clientRequestToken': clientRequestToken ?? _s.generateIdempotencyToken(),
if (tags != null) 'tags': tags,
};
final response = await _protocol.send(
payload: $payload,
method: 'POST',
requestUri: '/dimensions/${Uri.encodeComponent(name)}',
exceptionFnMap: _exceptionFns,
);
return CreateDimensionResponse.fromJson(response);
}