Amazon.SimpleNotificationService.AmazonSimpleNotificationServiceClient.CreateTopicAsync C# (CSharp) Метод

CreateTopicAsync() публичный Метод

Creates a topic to which notifications can be published. Users can create at most 100,000 topics. For more information, see http://aws.amazon.com/sns. This action is idempotent, so if the requester already owns a topic with the specified name, that topic's ARN is returned without creating a new topic.
/// Indicates that the user has been denied access to the requested resource. /// /// Indicates an internal service error. /// /// Indicates that a request parameter does not comply with the associated constraints. /// /// Indicates that the customer already owns the maximum allowed number of topics. ///
public CreateTopicAsync ( string name, System cancellationToken = default(CancellationToken) ) : Task
name string The name of the topic you want to create. Constraints: Topic names must be made up of only uppercase and lowercase ASCII letters, numbers, underscores, and hyphens, and must be between 1 and 256 characters long.
cancellationToken System /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. ///
Результат Task
        public Task<CreateTopicResponse> CreateTopicAsync(string name, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var request = new CreateTopicRequest();
            request.Name = name;
            return CreateTopicAsync(request, cancellationToken);
        }

Same methods

AmazonSimpleNotificationServiceClient::CreateTopicAsync ( CreateTopicRequest request, System cancellationToken = default(CancellationToken) ) : Task
AmazonSimpleNotificationServiceClient::CreateTopicAsync ( CreateTopicRequest request, CreateTopicResponse>.AmazonServiceCallback callback, AsyncOptions options = null ) : void
AmazonSimpleNotificationServiceClient::CreateTopicAsync ( string name, CreateTopicResponse>.AmazonServiceCallback callback, AsyncOptions options = null ) : void

Usage Example

Пример #1
0
 /// <summary>
 /// Ensures the topic. The call to create topic is idempotent and just returns the arn if it already exists. Therefore there is 
 /// no nee to check then create if it does not exist, as this would be extral calls
 /// </summary>
 /// <param name="topicName">Name of the topic.</param>
 /// <param name="client">The client.</param>
 /// <returns>System.String.</returns>
 private string EnsureTopic(string topicName, AmazonSimpleNotificationServiceClient client)
 {
     _logger.Value.DebugFormat("Topic with name {0} does not exist. Creating new topic", topicName);
     var topicResult = client.CreateTopicAsync(new CreateTopicRequest(topicName)).Result;
     return topicResult.HttpStatusCode == HttpStatusCode.OK ? topicResult.TopicArn : string.Empty;
 }
AmazonSimpleNotificationServiceClient