createServerlessCache method

Future<CreateServerlessCacheResponse> createServerlessCache({
  1. required String engine,
  2. required String serverlessCacheName,
  3. CacheUsageLimits? cacheUsageLimits,
  4. String? dailySnapshotTime,
  5. String? description,
  6. String? kmsKeyId,
  7. String? majorEngineVersion,
  8. NetworkType? networkType,
  9. List<String>? securityGroupIds,
  10. List<String>? snapshotArnsToRestore,
  11. int? snapshotRetentionLimit,
  12. List<String>? subnetIds,
  13. List<Tag>? tags,
  14. String? userGroupId,
})

Creates a serverless cache.

May throw InvalidCredentialsException. May throw InvalidParameterCombinationException. May throw InvalidParameterValueException. May throw InvalidServerlessCacheStateFault. May throw InvalidUserGroupStateFault. May throw ServerlessCacheAlreadyExistsFault. May throw ServerlessCacheNotFoundFault. May throw ServerlessCacheQuotaForCustomerExceededFault. May throw ServiceLinkedRoleNotFoundFault. May throw TagQuotaPerResourceExceeded. May throw UserGroupNotFoundFault.

Parameter engine : The name of the cache engine to be used for creating the serverless cache.

Parameter serverlessCacheName : User-provided identifier for the serverless cache. This parameter is stored as a lowercase string.

Parameter cacheUsageLimits : Sets the cache usage limits for storage and ElastiCache Processing Units for the cache.

Parameter dailySnapshotTime : The daily time that snapshots will be created from the new serverless cache. By default this number is populated with 0, i.e. no snapshots will be created on an automatic daily basis. Available for Valkey, Redis OSS and Serverless Memcached only.

Parameter description : User-provided description for the serverless cache. The default is NULL, i.e. if no description is provided then an empty string will be returned. The maximum length is 255 characters.

Parameter kmsKeyId : ARN of the customer managed key for encrypting the data at rest. If no KMS key is provided, a default service key is used.

Parameter majorEngineVersion : The version of the cache engine that will be used to create the serverless cache.

Parameter networkType : The IP protocol version used by the serverless cache. Must be either ipv4 | ipv6 | dual_stack. ipv6 is only supported with IPv6-only subnets. If not specified, defaults to ipv4, unless all provided subnets are IPv6-only, in which case it defaults to ipv6.

Parameter securityGroupIds : A list of the one or more VPC security groups to be associated with the serverless cache. The security group will authorize traffic access for the VPC end-point (private-link). If no other information is given this will be the VPC’s Default Security Group that is associated with the cluster VPC end-point.

Parameter snapshotArnsToRestore : The ARN(s) of the snapshot that the new serverless cache will be created from. Available for Valkey, Redis OSS and Serverless Memcached only.

Parameter snapshotRetentionLimit : The number of days for which ElastiCache retains automatic snapshots before deleting them. Available for Valkey, Redis OSS and Serverless Memcached only. The maximum value allowed is 35 days.

Parameter subnetIds : A list of the identifiers of the subnets where the VPC endpoint for the serverless cache will be deployed. All the subnetIds must belong to the same VPC.

Parameter tags : The list of tags (key, value) pairs to be added to the serverless cache resource. Default is NULL.

Parameter userGroupId : The identifier of the UserGroup to be associated with the serverless cache. Available for Valkey and Redis OSS only. Default is NULL.

Implementation

Future<CreateServerlessCacheResponse> createServerlessCache({
  required String engine,
  required String serverlessCacheName,
  CacheUsageLimits? cacheUsageLimits,
  String? dailySnapshotTime,
  String? description,
  String? kmsKeyId,
  String? majorEngineVersion,
  NetworkType? networkType,
  List<String>? securityGroupIds,
  List<String>? snapshotArnsToRestore,
  int? snapshotRetentionLimit,
  List<String>? subnetIds,
  List<Tag>? tags,
  String? userGroupId,
}) async {
  final $request = <String, String>{
    'Engine': engine,
    'ServerlessCacheName': serverlessCacheName,
    if (cacheUsageLimits != null)
      for (var e1 in cacheUsageLimits.toQueryMap().entries)
        'CacheUsageLimits.${e1.key}': e1.value,
    if (dailySnapshotTime != null) 'DailySnapshotTime': dailySnapshotTime,
    if (description != null) 'Description': description,
    if (kmsKeyId != null) 'KmsKeyId': kmsKeyId,
    if (majorEngineVersion != null) 'MajorEngineVersion': majorEngineVersion,
    if (networkType != null) 'NetworkType': networkType.value,
    if (securityGroupIds != null)
      if (securityGroupIds.isEmpty)
        'SecurityGroupIds': ''
      else
        for (var i1 = 0; i1 < securityGroupIds.length; i1++)
          'SecurityGroupIds.SecurityGroupId.${i1 + 1}': securityGroupIds[i1],
    if (snapshotArnsToRestore != null)
      if (snapshotArnsToRestore.isEmpty)
        'SnapshotArnsToRestore': ''
      else
        for (var i1 = 0; i1 < snapshotArnsToRestore.length; i1++)
          'SnapshotArnsToRestore.SnapshotArn.${i1 + 1}':
              snapshotArnsToRestore[i1],
    if (snapshotRetentionLimit != null)
      'SnapshotRetentionLimit': snapshotRetentionLimit.toString(),
    if (subnetIds != null)
      if (subnetIds.isEmpty)
        'SubnetIds': ''
      else
        for (var i1 = 0; i1 < subnetIds.length; i1++)
          'SubnetIds.SubnetId.${i1 + 1}': subnetIds[i1],
    if (tags != null)
      if (tags.isEmpty)
        'Tags': ''
      else
        for (var i1 = 0; i1 < tags.length; i1++)
          for (var e3 in tags[i1].toQueryMap().entries)
            'Tags.Tag.${i1 + 1}.${e3.key}': e3.value,
    if (userGroupId != null) 'UserGroupId': userGroupId,
  };
  final $result = await _protocol.send(
    $request,
    action: 'CreateServerlessCache',
    version: '2015-02-02',
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    resultWrapper: 'CreateServerlessCacheResult',
  );
  return CreateServerlessCacheResponse.fromXml($result);
}