createVpcEndpoint method

Future<CreateVpcEndpointResponse> createVpcEndpoint({
  1. required String name,
  2. required List<String> subnetIds,
  3. required String vpcId,
  4. String? clientToken,
  5. List<String>? securityGroupIds,
})

Creates an OpenSearch Serverless-managed interface VPC endpoint. For more information, see Access Amazon OpenSearch Serverless using an interface endpoint.

May throw ConflictException. May throw InternalServerException. May throw ServiceQuotaExceededException. May throw ValidationException.

Parameter name : The name of the interface endpoint.

Parameter subnetIds : The ID of one or more subnets from which you'll access OpenSearch Serverless.

Parameter vpcId : The ID of the VPC from which you'll access OpenSearch Serverless.

Parameter clientToken : Unique, case-sensitive identifier to ensure idempotency of the request.

Parameter securityGroupIds : The unique identifiers of the security groups that define the ports, protocols, and sources for inbound traffic that you are authorizing into your endpoint.

Implementation

Future<CreateVpcEndpointResponse> createVpcEndpoint({
  required String name,
  required List<String> subnetIds,
  required String vpcId,
  String? clientToken,
  List<String>? securityGroupIds,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.0',
    'X-Amz-Target': 'OpenSearchServerless.CreateVpcEndpoint'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'name': name,
      'subnetIds': subnetIds,
      'vpcId': vpcId,
      'clientToken': clientToken ?? _s.generateIdempotencyToken(),
      if (securityGroupIds != null) 'securityGroupIds': securityGroupIds,
    },
  );

  return CreateVpcEndpointResponse.fromJson(jsonResponse.body);
}