createAccelerator method

Future<CreateAcceleratorResponse> createAccelerator({
  1. required String name,
  2. bool? enabled,
  3. String? idempotencyToken,
  4. IpAddressType? ipAddressType,
  5. List<String>? ipAddresses,
  6. List<Tag>? tags,
})

Create an accelerator. An accelerator includes one or more listeners that process inbound connections and direct traffic to one or more endpoint groups, each of which includes endpoints, such as Network Load Balancers.

May throw InternalServiceErrorException. May throw InvalidArgumentException. May throw LimitExceededException.

Parameter name : The name of an accelerator. The name can have a maximum of 32 characters, must contain only alphanumeric characters or hyphens (-), and must not begin or end with a hyphen.

Parameter enabled : Indicates whether an accelerator is enabled. The value is true or false. The default value is true.

If the value is set to true, an accelerator cannot be deleted. If set to false, the accelerator can be deleted.

Parameter idempotencyToken : A unique, case-sensitive identifier that you provide to ensure the idempotency—that is, the uniqueness—of an accelerator.

Parameter ipAddressType : The value for the address type must be IPv4.

Parameter ipAddresses : Optionally, if you've added your own IP address pool to Global Accelerator (BYOIP), you can choose IP addresses from your own pool to use for the accelerator's static IP addresses when you create an accelerator. You can specify one or two addresses, separated by a comma. Do not include the /32 suffix.

Only one IP address from each of your IP address ranges can be used for each accelerator. If you specify only one IP address from your IP address range, Global Accelerator assigns a second static IP address for the accelerator from the AWS IP address pool.

Note that you can't update IP addresses for an existing accelerator. To change them, you must create a new accelerator with the new addresses.

For more information, see Bring Your Own IP Addresses (BYOIP) in the AWS Global Accelerator Developer Guide.

Parameter tags : Create tags for an accelerator.

For more information, see Tagging in AWS Global Accelerator in the AWS Global Accelerator Developer Guide.

Implementation

Future<CreateAcceleratorResponse> createAccelerator({
  required String name,
  bool? enabled,
  String? idempotencyToken,
  IpAddressType? ipAddressType,
  List<String>? ipAddresses,
  List<Tag>? tags,
}) async {
  ArgumentError.checkNotNull(name, 'name');
  _s.validateStringLength(
    'name',
    name,
    0,
    255,
    isRequired: true,
  );
  _s.validateStringLength(
    'idempotencyToken',
    idempotencyToken,
    0,
    255,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'GlobalAccelerator_V20180706.CreateAccelerator'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'Name': name,
      if (enabled != null) 'Enabled': enabled,
      'IdempotencyToken': idempotencyToken ?? _s.generateIdempotencyToken(),
      if (ipAddressType != null) 'IpAddressType': ipAddressType.toValue(),
      if (ipAddresses != null) 'IpAddresses': ipAddresses,
      if (tags != null) 'Tags': tags,
    },
  );

  return CreateAcceleratorResponse.fromJson(jsonResponse.body);
}