putAccessControlRule method

Future<void> putAccessControlRule({
  1. required String description,
  2. required AccessControlRuleEffect effect,
  3. required String name,
  4. required String organizationId,
  5. List<String>? actions,
  6. List<String>? ipRanges,
  7. List<String>? notActions,
  8. List<String>? notIpRanges,
  9. List<String>? notUserIds,
  10. List<String>? userIds,
})

Adds a new access control rule for the specified organization. The rule allows or denies access to the organization for the specified IPv4 addresses, access protocol actions, and user IDs. Adding a new rule with the same name as an existing rule replaces the older rule.

May throw LimitExceededException. May throw InvalidParameterException. May throw EntityNotFoundException. May throw OrganizationNotFoundException. May throw OrganizationStateException.

Parameter description : The rule description.

Parameter effect : The rule effect.

Parameter name : The rule name.

Parameter organizationId : The identifier of the organization.

Parameter actions : Access protocol actions to include in the rule. Valid values include ActiveSync, AutoDiscover, EWS, IMAP, SMTP, WindowsOutlook, and WebMail.

Parameter ipRanges : IPv4 CIDR ranges to include in the rule.

Parameter notActions : Access protocol actions to exclude from the rule. Valid values include ActiveSync, AutoDiscover, EWS, IMAP, SMTP, WindowsOutlook, and WebMail.

Parameter notIpRanges : IPv4 CIDR ranges to exclude from the rule.

Parameter notUserIds : User IDs to exclude from the rule.

Parameter userIds : User IDs to include in the rule.

Implementation

Future<void> putAccessControlRule({
  required String description,
  required AccessControlRuleEffect effect,
  required String name,
  required String organizationId,
  List<String>? actions,
  List<String>? ipRanges,
  List<String>? notActions,
  List<String>? notIpRanges,
  List<String>? notUserIds,
  List<String>? userIds,
}) async {
  ArgumentError.checkNotNull(description, 'description');
  _s.validateStringLength(
    'description',
    description,
    0,
    255,
    isRequired: true,
  );
  ArgumentError.checkNotNull(effect, 'effect');
  ArgumentError.checkNotNull(name, 'name');
  _s.validateStringLength(
    'name',
    name,
    1,
    64,
    isRequired: true,
  );
  ArgumentError.checkNotNull(organizationId, 'organizationId');
  _s.validateStringLength(
    'organizationId',
    organizationId,
    34,
    34,
    isRequired: true,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'WorkMailService.PutAccessControlRule'
  };
  await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'Description': description,
      'Effect': effect.toValue(),
      'Name': name,
      'OrganizationId': organizationId,
      if (actions != null) 'Actions': actions,
      if (ipRanges != null) 'IpRanges': ipRanges,
      if (notActions != null) 'NotActions': notActions,
      if (notIpRanges != null) 'NotIpRanges': notIpRanges,
      if (notUserIds != null) 'NotUserIds': notUserIds,
      if (userIds != null) 'UserIds': userIds,
    },
  );
}