createChannelNamespace method
Creates a ChannelNamespace for an Api.
May throw BadRequestException.
May throw ConcurrentModificationException.
May throw ConflictException.
May throw InternalFailureException.
May throw NotFoundException.
May throw ServiceQuotaExceededException.
May throw UnauthorizedException.
Parameter apiId :
The Api ID.
Parameter name :
The name of the ChannelNamespace. This name must be unique
within the Api
Parameter codeHandlers :
The event handler functions that run custom business logic to process
published events and subscribe requests.
Parameter handlerConfigs :
The configuration for the OnPublish and
OnSubscribe handlers.
Parameter publishAuthModes :
The authorization mode to use for publishing messages on the channel
namespace. This configuration overrides the default Api
authorization configuration.
Parameter subscribeAuthModes :
The authorization mode to use for subscribing to messages on the channel
namespace. This configuration overrides the default Api
authorization configuration.
Implementation
Future<CreateChannelNamespaceResponse> createChannelNamespace({
required String apiId,
required String name,
String? codeHandlers,
HandlerConfigs? handlerConfigs,
List<AuthMode>? publishAuthModes,
List<AuthMode>? subscribeAuthModes,
Map<String, String>? tags,
}) async {
final $payload = <String, dynamic>{
'name': name,
if (codeHandlers != null) 'codeHandlers': codeHandlers,
if (handlerConfigs != null) 'handlerConfigs': handlerConfigs,
if (publishAuthModes != null) 'publishAuthModes': publishAuthModes,
if (subscribeAuthModes != null) 'subscribeAuthModes': subscribeAuthModes,
if (tags != null) 'tags': tags,
};
final response = await _protocol.send(
payload: $payload,
method: 'POST',
requestUri: '/v2/apis/${Uri.encodeComponent(apiId)}/channelNamespaces',
exceptionFnMap: _exceptionFns,
);
return CreateChannelNamespaceResponse.fromJson(response);
}