createService method

Future<CreateServiceResponse> createService({
  1. required String applicationIdentifier,
  2. required ServiceEndpointType endpointType,
  3. required String environmentIdentifier,
  4. required String name,
  5. String? clientToken,
  6. String? description,
  7. LambdaEndpointInput? lambdaEndpoint,
  8. Map<String, String>? tags,
  9. UrlEndpointInput? urlEndpoint,
  10. String? vpcId,
})

Creates an Amazon Web Services Migration Hub Refactor Spaces service. The account owner of the service is always the environment owner, regardless of which account in the environment creates the service. Services have either a URL endpoint in a virtual private cloud (VPC), or a Lambda function endpoint.

May throw AccessDeniedException. May throw ConflictException. May throw InternalServerException. May throw ResourceNotFoundException. May throw ServiceQuotaExceededException. May throw ThrottlingException. May throw ValidationException.

Parameter applicationIdentifier : The ID of the application which the service is created.

Parameter endpointType : The type of endpoint to use for the service. The type can be a URL in a VPC or an Lambda function.

Parameter environmentIdentifier : The ID of the environment in which the service is created.

Parameter name : The name of the service.

Parameter clientToken : A unique, case-sensitive identifier that you provide to ensure the idempotency of the request.

Parameter description : The description of the service.

Parameter lambdaEndpoint : The configuration for the Lambda endpoint type.

Parameter tags : The tags to assign to the service. A tag is a label that you assign to an Amazon Web Services resource. Each tag consists of a key-value pair..

Parameter urlEndpoint : The configuration for the URL endpoint type. When creating a route to a service, Refactor Spaces automatically resolves the address in the UrlEndpointInput object URL when the Domain Name System (DNS) time-to-live (TTL) expires, or every 60 seconds for TTLs less than 60 seconds.

Parameter vpcId : The ID of the VPC.

Implementation

Future<CreateServiceResponse> createService({
  required String applicationIdentifier,
  required ServiceEndpointType endpointType,
  required String environmentIdentifier,
  required String name,
  String? clientToken,
  String? description,
  LambdaEndpointInput? lambdaEndpoint,
  Map<String, String>? tags,
  UrlEndpointInput? urlEndpoint,
  String? vpcId,
}) async {
  final $payload = <String, dynamic>{
    'EndpointType': endpointType.value,
    'Name': name,
    'ClientToken': clientToken ?? _s.generateIdempotencyToken(),
    if (description != null) 'Description': description,
    if (lambdaEndpoint != null) 'LambdaEndpoint': lambdaEndpoint,
    if (tags != null) 'Tags': tags,
    if (urlEndpoint != null) 'UrlEndpoint': urlEndpoint,
    if (vpcId != null) 'VpcId': vpcId,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri:
        '/environments/${Uri.encodeComponent(environmentIdentifier)}/applications/${Uri.encodeComponent(applicationIdentifier)}/services',
    exceptionFnMap: _exceptionFns,
  );
  return CreateServiceResponse.fromJson(response);
}