createVirtualService method

Future<CreateVirtualServiceOutput> createVirtualService({
  1. required String meshName,
  2. required VirtualServiceSpec spec,
  3. required String virtualServiceName,
  4. String? clientToken,
  5. String? meshOwner,
  6. List<TagRef>? tags,
})

Creates a virtual service within a service mesh.

A virtual service is an abstraction of a real service that is provided by a virtual node directly or indirectly by means of a virtual router. Dependent services call your virtual service by its virtualServiceName, and those requests are routed to the virtual node or virtual router that is specified as the provider for the virtual service.

For more information about virtual services, see Virtual services.

May throw NotFoundException. May throw BadRequestException. May throw ConflictException. May throw TooManyRequestsException. May throw ForbiddenException. May throw ServiceUnavailableException. May throw InternalServerErrorException. May throw LimitExceededException.

Parameter meshName : The name of the service mesh to create the virtual service in.

Parameter spec : The virtual service specification to apply.

Parameter virtualServiceName : The name to use for the virtual service.

Parameter clientToken : Unique, case-sensitive identifier that you provide to ensure the idempotency of the request. Up to 36 letters, numbers, hyphens, and underscores are allowed.

Parameter meshOwner : The AWS IAM account ID of the service mesh owner. If the account ID is not your own, then the account that you specify must share the mesh with your account before you can create the resource in the service mesh. For more information about mesh sharing, see Working with shared meshes.

Parameter tags : Optional metadata that you can apply to the virtual service to assist with categorization and organization. Each tag consists of a key and an optional value, both of which you define. Tag keys can have a maximum character length of 128 characters, and tag values can have a maximum length of 256 characters.

Implementation

Future<CreateVirtualServiceOutput> createVirtualService({
  required String meshName,
  required VirtualServiceSpec spec,
  required String virtualServiceName,
  String? clientToken,
  String? meshOwner,
  List<TagRef>? tags,
}) async {
  ArgumentError.checkNotNull(meshName, 'meshName');
  _s.validateStringLength(
    'meshName',
    meshName,
    1,
    255,
    isRequired: true,
  );
  ArgumentError.checkNotNull(spec, 'spec');
  ArgumentError.checkNotNull(virtualServiceName, 'virtualServiceName');
  _s.validateStringLength(
    'meshOwner',
    meshOwner,
    12,
    12,
  );
  final $query = <String, List<String>>{
    if (meshOwner != null) 'meshOwner': [meshOwner],
  };
  final $payload = <String, dynamic>{
    'spec': spec,
    'virtualServiceName': virtualServiceName,
    'clientToken': clientToken ?? _s.generateIdempotencyToken(),
    if (tags != null) 'tags': tags,
  };
  final response = await _protocol.sendRaw(
    payload: $payload,
    method: 'PUT',
    requestUri:
        '/v20190125/meshes/${Uri.encodeComponent(meshName)}/virtualServices',
    queryParams: $query,
    exceptionFnMap: _exceptionFns,
  );
  final $json = await _s.jsonFromResponse(response);
  return CreateVirtualServiceOutput(
    virtualService: VirtualServiceData.fromJson($json),
  );
}