createVirtualRouter method

Future<CreateVirtualRouterOutput> createVirtualRouter({
  1. required String meshName,
  2. required VirtualRouterSpec spec,
  3. required String virtualRouterName,
  4. String? clientToken,
})

Creates a new virtual router within a service mesh.

Virtual routers handle traffic for one or more service names within your mesh. After you create your virtual router, create and associate routes for your virtual router that direct incoming requests to different virtual nodes.

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

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

Parameter spec : The virtual router specification to apply.

Parameter virtualRouterName : The name to use for the virtual router.

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.

Implementation

Future<CreateVirtualRouterOutput> createVirtualRouter({
  required String meshName,
  required VirtualRouterSpec spec,
  required String virtualRouterName,
  String? clientToken,
}) async {
  ArgumentError.checkNotNull(meshName, 'meshName');
  _s.validateStringLength(
    'meshName',
    meshName,
    1,
    255,
    isRequired: true,
  );
  ArgumentError.checkNotNull(spec, 'spec');
  ArgumentError.checkNotNull(virtualRouterName, 'virtualRouterName');
  _s.validateStringLength(
    'virtualRouterName',
    virtualRouterName,
    1,
    255,
    isRequired: true,
  );
  final $payload = <String, dynamic>{
    'spec': spec,
    'virtualRouterName': virtualRouterName,
    'clientToken': clientToken ?? _s.generateIdempotencyToken(),
  };
  final response = await _protocol.sendRaw(
    payload: $payload,
    method: 'PUT',
    requestUri: '/meshes/${Uri.encodeComponent(meshName)}/virtualRouters',
    exceptionFnMap: _exceptionFns,
  );
  final $json = await _s.jsonFromResponse(response);
  return CreateVirtualRouterOutput(
    virtualRouter: VirtualRouterData.fromJson($json),
  );
}