createNotificationRule method Null safety

Future<CreateNotificationRuleResult> createNotificationRule(
  1. {required DetailType detailType,
  2. required List<String> eventTypeIds,
  3. required String name,
  4. required String resource,
  5. required List<Target> targets,
  6. String? clientRequestToken,
  7. NotificationRuleStatus? status,
  8. Map<String, String>? tags}
)

Creates a notification rule for a resource. The rule specifies the events you want notifications about and the targets (such as SNS topics) where you want to receive them.

May throw ResourceAlreadyExistsException. May throw ValidationException. May throw LimitExceededException. May throw ConfigurationException. May throw ConcurrentModificationException. May throw AccessDeniedException.

Parameter detailType : The level of detail to include in the notifications for this resource. BASIC will include only the contents of the event as it would appear in AWS CloudWatch. FULL will include any supplemental information provided by AWS CodeStar Notifications and/or the service for the resource for which the notification is created.

Parameter eventTypeIds : A list of event types associated with this notification rule. For a list of allowed events, see EventTypeSummary.

Parameter name : The name for the notification rule. Notifictaion rule names must be unique in your AWS account.

Parameter resource : The Amazon Resource Name (ARN) of the resource to associate with the notification rule. Supported resources include pipelines in AWS CodePipeline, repositories in AWS CodeCommit, and build projects in AWS CodeBuild.

Parameter targets : A list of Amazon Resource Names (ARNs) of SNS topics to associate with the notification rule.

Parameter clientRequestToken : A unique, client-generated idempotency token that, when provided in a request, ensures the request cannot be repeated with a changed parameter. If a request with the same parameters is received and a token is included, the request returns information about the initial request that used that token.

Parameter status : The status of the notification rule. The default value is ENABLED. If the status is set to DISABLED, notifications aren't sent for the notification rule.

Parameter tags : A list of tags to apply to this notification rule. Key names cannot start with "aws".

Implementation

Future<CreateNotificationRuleResult> createNotificationRule({
  required DetailType detailType,
  required List<String> eventTypeIds,
  required String name,
  required String resource,
  required List<Target> targets,
  String? clientRequestToken,
  NotificationRuleStatus? status,
  Map<String, String>? tags,
}) async {
  ArgumentError.checkNotNull(detailType, 'detailType');
  ArgumentError.checkNotNull(eventTypeIds, 'eventTypeIds');
  ArgumentError.checkNotNull(name, 'name');
  _s.validateStringLength(
    'name',
    name,
    1,
    64,
    isRequired: true,
  );
  ArgumentError.checkNotNull(resource, 'resource');
  ArgumentError.checkNotNull(targets, 'targets');
  _s.validateStringLength(
    'clientRequestToken',
    clientRequestToken,
    1,
    256,
  );
  final $payload = <String, dynamic>{
    'DetailType': detailType.toValue(),
    'EventTypeIds': eventTypeIds,
    'Name': name,
    'Resource': resource,
    'Targets': targets,
    'ClientRequestToken': clientRequestToken ?? _s.generateIdempotencyToken(),
    if (status != null) 'Status': status.toValue(),
    if (tags != null) 'Tags': tags,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/createNotificationRule',
    exceptionFnMap: _exceptionFns,
  );
  return CreateNotificationRuleResult.fromJson(response);
}