createMobileDeviceAccessRule method

Future<CreateMobileDeviceAccessRuleResponse> createMobileDeviceAccessRule({
  1. required MobileDeviceAccessRuleEffect effect,
  2. required String name,
  3. required String organizationId,
  4. String? clientToken,
  5. String? description,
  6. List<String>? deviceModels,
  7. List<String>? deviceOperatingSystems,
  8. List<String>? deviceTypes,
  9. List<String>? deviceUserAgents,
  10. List<String>? notDeviceModels,
  11. List<String>? notDeviceOperatingSystems,
  12. List<String>? notDeviceTypes,
  13. List<String>? notDeviceUserAgents,
})

Creates a new mobile device access rule for the specified WorkMail organization.

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

Parameter effect : The effect of the rule when it matches. Allowed values are ALLOW or DENY.

Parameter name : The rule name.

Parameter organizationId : The WorkMail organization under which the rule will be created.

Parameter clientToken : The idempotency token for the client request.

Parameter description : The rule description.

Parameter deviceModels : Device models that the rule will match.

Parameter deviceOperatingSystems : Device operating systems that the rule will match.

Parameter deviceTypes : Device types that the rule will match.

Parameter deviceUserAgents : Device user agents that the rule will match.

Parameter notDeviceModels : Device models that the rule will not match. All other device models will match.

Parameter notDeviceOperatingSystems : Device operating systems that the rule will not match. All other device operating systems will match.

Parameter notDeviceTypes : Device types that the rule will not match. All other device types will match.

Parameter notDeviceUserAgents : Device user agents that the rule will not match. All other device user agents will match.

Implementation

Future<CreateMobileDeviceAccessRuleResponse> createMobileDeviceAccessRule({
  required MobileDeviceAccessRuleEffect effect,
  required String name,
  required String organizationId,
  String? clientToken,
  String? description,
  List<String>? deviceModels,
  List<String>? deviceOperatingSystems,
  List<String>? deviceTypes,
  List<String>? deviceUserAgents,
  List<String>? notDeviceModels,
  List<String>? notDeviceOperatingSystems,
  List<String>? notDeviceTypes,
  List<String>? notDeviceUserAgents,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'WorkMailService.CreateMobileDeviceAccessRule'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'Effect': effect.value,
      'Name': name,
      'OrganizationId': organizationId,
      'ClientToken': clientToken ?? _s.generateIdempotencyToken(),
      if (description != null) 'Description': description,
      if (deviceModels != null) 'DeviceModels': deviceModels,
      if (deviceOperatingSystems != null)
        'DeviceOperatingSystems': deviceOperatingSystems,
      if (deviceTypes != null) 'DeviceTypes': deviceTypes,
      if (deviceUserAgents != null) 'DeviceUserAgents': deviceUserAgents,
      if (notDeviceModels != null) 'NotDeviceModels': notDeviceModels,
      if (notDeviceOperatingSystems != null)
        'NotDeviceOperatingSystems': notDeviceOperatingSystems,
      if (notDeviceTypes != null) 'NotDeviceTypes': notDeviceTypes,
      if (notDeviceUserAgents != null)
        'NotDeviceUserAgents': notDeviceUserAgents,
    },
  );

  return CreateMobileDeviceAccessRuleResponse.fromJson(jsonResponse.body);
}