protected override void ProcessRecord() { AmazonSimpleNotificationService client = base.GetClient(); Amazon.SimpleNotificationService.Model.CreateTopicRequest request = new Amazon.SimpleNotificationService.Model.CreateTopicRequest(); request.Name = this._Name; Amazon.SimpleNotificationService.Model.CreateTopicResponse response = client.CreateTopic(request); base.WriteObject(response.CreateTopicResult, true); }
public void create_a_topic() { GetUserNameAndPassword(); var snsClient = Amazon.AWSClientFactory.CreateAmazonSNSClient(_key, _secret); var createTopicRequest = new CreateTopicRequest() .WithName("Elliott-has-an-awesome-blog"); var response = snsClient.CreateTopic(createTopicRequest); Trace.WriteLine(response.CreateTopicResult.TopicArn); }
public static string CreateTopic(string topicName) { using (var client = new AmazonSimpleNotificationServiceClient(Settings.AccessKey, Settings.Secret)) { var request = new CreateTopicRequest(topicName); return client.CreateTopic(request).TopicArn; } }
public string CreateOrRetrieveTopic(string name) { Validate.That(name).IsNotNullOrEmpty(); var topicRequest = new CreateTopicRequest().WithName(name); using (var sns = amazonSnsFactory()) { var topicResponse = sns.CreateTopic(topicRequest); return topicResponse.CreateTopicResult.TopicArn; } }
public string CreateOrRetrieveTopic(string name) { name.Requires("name").IsNotNullOrWhiteSpace(); var topicRequest = new CreateTopicRequest(name); using (var sns = amazonSnsFactory()) { var topicResponse = sns.CreateTopic(topicRequest); return topicResponse?.TopicArn; } }
public virtual string CreateTopic(AmazonSimpleNotificationServiceClient snsClient, string topicName) { string topicArn; // Create the request var createTopicRequest = new CreateTopicRequest { Name = topicName }; // Submit the request CreateTopicResponse topicResponse = snsClient.CreateTopic(createTopicRequest); // Return the ARN topicArn = topicResponse.TopicArn; return topicArn; }
public object Execute(ExecutorContext context) { var cmdletContext = context as CmdletContext; // create request var request = new Amazon.SimpleNotificationService.Model.CreateTopicRequest(); if (cmdletContext.Attribute != null) { request.Attributes = cmdletContext.Attribute; } if (cmdletContext.Name != null) { request.Name = cmdletContext.Name; } if (cmdletContext.Tag != null) { request.Tags = cmdletContext.Tag; } CmdletOutput output; // issue call var client = Client ?? CreateClient(_CurrentCredentials, _RegionEndpoint); try { var response = CallAWSServiceOperation(client, request); object pipelineOutput = null; pipelineOutput = cmdletContext.Select(response, this); output = new CmdletOutput { PipelineOutput = pipelineOutput, ServiceResponse = response }; } catch (Exception e) { output = new CmdletOutput { ErrorResponse = e }; } return(output); }
/// <summary> /// Creates a user account for SNS /// </summary> /// <param name="userName">The user to create a SNS account for</param> /// <param name="number">The user's phone number</param> private void CreateSNSAccount(String userName, String number) { AmazonSimpleNotificationServiceClient client = new AmazonSimpleNotificationServiceClient(); //Create topic first. CreateTopicRequest request = new CreateTopicRequest { Name = userName }; try { CreateTopicResponse response = client.CreateTopic(request); CreateTopicResult result = response.CreateTopicResult; String[] strings = new String[1]; strings[0] = "Success! Assigned ARN is: " + result.TopicArn + "\n"; TempData["result"] = strings; } catch (Exception e) { TempData["error"] = e.Message; } String arn = "arn:aws:sns:us-east-1:727060774285:" + userName; SetTopicAttributesRequest request2 = new SetTopicAttributesRequest { AttributeName = "DisplayName", AttributeValue = "Cookbook", TopicArn = arn }; try { SetTopicAttributesResponse response = client.SetTopicAttributes(request2); ResponseMetadata result = response.ResponseMetadata; Console.WriteLine(result.RequestId); } catch (Exception e) { Console.WriteLine(e.Message); } //Add SMS number to topic. SubscribeRequest request3 = new SubscribeRequest { TopicArn = arn, Endpoint = number, Protocol = "sms" }; try { SubscribeResponse response = client.Subscribe(request3); SubscribeResult result = response.SubscribeResult; string resultSubscribe = "Success! Subscription Arn is: " + result.SubscriptionArn + "\n"; Console.WriteLine(resultSubscribe); } catch (Exception e) { Console.WriteLine(e.Message); } }
private CreateTopicRequest CreateTopicRequest(DeveloperOptions devOptions) { var request = new CreateTopicRequest() { // TODO - need to determine where defaults are used, and then not create the constructor where value is null (to use default) Name = devOptions.TopicName // These are required values. }; return request; }
/// <summary> /// Creates a topic. Should only be needed to be used once. /// </summary> /// <param name="topicName"></param> /// <returns></returns> public string CreateTopic(string topicName) { var request = new CreateTopicRequest { Name = topicName }; CreateTopicResponse response = Client.CreateTopic(request); return response.CreateTopicResult.TopicArn; }
IAsyncResult invokeCreateTopic(CreateTopicRequest request, AsyncCallback callback, object state, bool synchronized) { var marshaller = new CreateTopicRequestMarshaller(); var unmarshaller = CreateTopicResponseUnmarshaller.Instance; return Invoke(request, callback, state, synchronized, marshaller, unmarshaller, signer); }
/// <summary> /// Initiates the asynchronous execution of the CreateTopic operation. /// <seealso cref="Amazon.SimpleNotificationService.IAmazonSimpleNotificationService.CreateTopic"/> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the CreateTopic operation.</param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// <returns>The task object representing the asynchronous operation.</returns> public Task<CreateTopicResponse> CreateTopicAsync(CreateTopicRequest request, CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new CreateTopicRequestMarshaller(); var unmarshaller = CreateTopicResponseUnmarshaller.GetInstance(); return Invoke<IRequest, CreateTopicRequest, CreateTopicResponse>(request, marshaller, unmarshaller, signer, cancellationToken); }
/// <summary> /// Initiates the asynchronous execution of the CreateTopic operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the CreateTopic operation on AmazonSimpleNotificationServiceClient.</param> /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param> /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback /// procedure using the AsyncState property.</param> /// /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndCreateTopic /// operation.</returns> public IAsyncResult BeginCreateTopic(CreateTopicRequest request, AsyncCallback callback, object state) { var marshaller = new CreateTopicRequestMarshaller(); var unmarshaller = CreateTopicResponseUnmarshaller.Instance; return BeginInvoke<CreateTopicRequest>(request, marshaller, unmarshaller, callback, state); }
/// <summary> /// Creates a topic to which notifications can be published. Users can create at most /// 100,000 topics. For more information, see <a href="http://aws.amazon.com/sns/">http://aws.amazon.com/sns</a>. /// 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. /// </summary> /// <param name="name">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.</param> /// <param name="callback">An Action delegate that is invoked when the operation completes.</param> /// <param name="options"> /// A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback /// procedure using the AsyncState property. /// </param> /// /// <returns>The response from the CreateTopic service method, as returned by SimpleNotificationService.</returns> /// <exception cref="Amazon.SimpleNotificationService.Model.AuthorizationErrorException"> /// Indicates that the user has been denied access to the requested resource. /// </exception> /// <exception cref="Amazon.SimpleNotificationService.Model.InternalErrorException"> /// Indicates an internal service error. /// </exception> /// <exception cref="Amazon.SimpleNotificationService.Model.InvalidParameterException"> /// Indicates that a request parameter does not comply with the associated constraints. /// </exception> /// <exception cref="Amazon.SimpleNotificationService.Model.TopicLimitExceededException"> /// Indicates that the customer already owns the maximum allowed number of topics. /// </exception> public void CreateTopicAsync(string name, AmazonServiceCallback<CreateTopicRequest, CreateTopicResponse> callback, AsyncOptions options = null) { var request = new CreateTopicRequest(); request.Name = name; CreateTopicAsync(request, callback, options); }
/// <summary> /// Initiates the asynchronous execution of the CreateTopic operation. /// <seealso cref="Amazon.SimpleNotificationService.IAmazonSimpleNotificationService"/> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the CreateTopic operation.</param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// <returns>The task object representing the asynchronous operation.</returns> public Task<CreateTopicResponse> CreateTopicAsync(CreateTopicRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new CreateTopicRequestMarshaller(); var unmarshaller = CreateTopicResponseUnmarshaller.Instance; return InvokeAsync<CreateTopicRequest,CreateTopicResponse>(request, marshaller, unmarshaller, cancellationToken); }
private Amazon.SimpleNotificationService.Model.CreateTopicResponse CallAWSServiceOperation(IAmazonSimpleNotificationService client, Amazon.SimpleNotificationService.Model.CreateTopicRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Simple Notification Service (SNS)", "CreateTopic"); try { #if DESKTOP return(client.CreateTopic(request)); #elif CORECLR return(client.CreateTopicAsync(request).GetAwaiter().GetResult()); #else #error "Unknown build edition" #endif } catch (AmazonServiceException exc) { var webException = exc.InnerException as System.Net.WebException; if (webException != null) { throw new Exception(Utils.Common.FormatNameResolutionFailureMessage(client.Config, webException.Message), webException); } throw; } }
/// <summary> /// Initiates the asynchronous execution of the CreateTopic operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the CreateTopic operation on AmazonSimpleNotificationServiceClient.</param> /// <param name="callback">An Action delegate that is invoked when the operation completes.</param> /// <param name="options">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback /// procedure using the AsyncState property.</param> public void CreateTopicAsync(CreateTopicRequest request, AmazonServiceCallback<CreateTopicRequest, CreateTopicResponse> callback, AsyncOptions options = null) { options = options == null?new AsyncOptions():options; var marshaller = new CreateTopicRequestMarshaller(); var unmarshaller = CreateTopicResponseUnmarshaller.Instance; Action<AmazonWebServiceRequest, AmazonWebServiceResponse, Exception, AsyncOptions> callbackHelper = null; if(callback !=null ) callbackHelper = (AmazonWebServiceRequest req, AmazonWebServiceResponse res, Exception ex, AsyncOptions ao) => { AmazonServiceResult<CreateTopicRequest,CreateTopicResponse> responseObject = new AmazonServiceResult<CreateTopicRequest,CreateTopicResponse>((CreateTopicRequest)req, (CreateTopicResponse)res, ex , ao.State); callback(responseObject); }; BeginInvoke<CreateTopicRequest>(request, marshaller, unmarshaller, options, callbackHelper); }
/// <summary> /// Creates a topic to which notifications can be published. Users can create at most /// 3000 topics. For more information, see <a href="http://aws.amazon.com/sns/">http://aws.amazon.com/sns</a>. /// 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. /// </summary> /// <param name="name">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. </param> /// /// <returns>The response from the CreateTopic service method, as returned by SimpleNotificationService.</returns> /// <exception cref="Amazon.SimpleNotificationService.Model.AuthorizationErrorException"> /// Indicates that the user has been denied access to the requested resource. /// </exception> /// <exception cref="Amazon.SimpleNotificationService.Model.InternalErrorException"> /// Indicates an internal service error. /// </exception> /// <exception cref="Amazon.SimpleNotificationService.Model.InvalidParameterException"> /// Indicates that a request parameter does not comply with the associated constraints. /// </exception> /// <exception cref="Amazon.SimpleNotificationService.Model.TopicLimitExceededException"> /// Indicates that the customer already owns the maximum allowed number of topics. /// </exception> public CreateTopicResponse CreateTopic(string name) { var request = new CreateTopicRequest(); request.Name = name; return CreateTopic(request); }
/// <summary> /// Creates a topic to which notifications can be published. Users can create at most /// 3000 topics. For more information, see <a href="http://aws.amazon.com/sns/">http://aws.amazon.com/sns</a>. /// 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. /// </summary> /// <param name="name">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. </param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// /// <returns>The response from the CreateTopic service method, as returned by SimpleNotificationService.</returns> /// <exception cref="Amazon.SimpleNotificationService.Model.AuthorizationErrorException"> /// Indicates that the user has been denied access to the requested resource. /// </exception> /// <exception cref="Amazon.SimpleNotificationService.Model.InternalErrorException"> /// Indicates an internal service error. /// </exception> /// <exception cref="Amazon.SimpleNotificationService.Model.InvalidParameterException"> /// Indicates that a request parameter does not comply with the associated constraints. /// </exception> /// <exception cref="Amazon.SimpleNotificationService.Model.TopicLimitExceededException"> /// Indicates that the customer already owns the maximum allowed number of topics. /// </exception> public Task<CreateTopicResponse> CreateTopicAsync(string name, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var request = new CreateTopicRequest(); request.Name = name; return CreateTopicAsync(request, cancellationToken); }
public static void SNSCreateSubscribePublish() { #region SNSCreateSubscribePublish var snsClient = new AmazonSimpleNotificationServiceClient(); var topicRequest = new CreateTopicRequest { Name = "CodingTestResults" }; var topicResponse = snsClient.CreateTopic(topicRequest); var topicAttrRequest = new SetTopicAttributesRequest { TopicArn = topicResponse.TopicArn, AttributeName = "DisplayName", AttributeValue = "Coding Test Results" }; snsClient.SetTopicAttributes(topicAttrRequest); snsClient.Subscribe(new SubscribeRequest { Endpoint = "*****@*****.**", Protocol = "email", TopicArn = topicResponse.TopicArn }); // Wait for up to 2 minutes for the user to confirm the subscription. DateTime latest = DateTime.Now + TimeSpan.FromMinutes(2); while (DateTime.Now < latest) { var subsRequest = new ListSubscriptionsByTopicRequest { TopicArn = topicResponse.TopicArn }; var subs = snsClient.ListSubscriptionsByTopic(subsRequest).Subscriptions; var sub = subs[0]; if (!string.Equals(sub.SubscriptionArn, "PendingConfirmation", StringComparison.Ordinal)) { break; } // Wait 15 seconds before trying again. System.Threading.Thread.Sleep(TimeSpan.FromSeconds(15)); } snsClient.Publish(new PublishRequest { Subject = "Coding Test Results for " + DateTime.Today.ToShortDateString(), Message = "All of today's coding tests passed.", TopicArn = topicResponse.TopicArn }); #endregion }
/// <summary> /// <para>The <c>CreateTopic</c> action creates a topic to which notifications can be published. Users can create at most 3000 topics. For more /// information, see <a href="http://aws.amazon.com/sns/">http://aws.amazon.com/sns</a> . /// 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.</para> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the CreateTopic service method on /// AmazonSimpleNotificationService.</param> /// /// <returns>The response from the CreateTopic service method, as returned by AmazonSimpleNotificationService.</returns> /// /// <exception cref="T:Amazon.SimpleNotificationService.Model.AuthorizationErrorException" /> /// <exception cref="T:Amazon.SimpleNotificationService.Model.InternalErrorException" /> /// <exception cref="T:Amazon.SimpleNotificationService.Model.InvalidParameterException" /> /// <exception cref="T:Amazon.SimpleNotificationService.Model.TopicLimitExceededException" /> public CreateTopicResponse CreateTopic(CreateTopicRequest request) { var task = CreateTopicAsync(request); try { return task.Result; } catch(AggregateException e) { ExceptionDispatchInfo.Capture(e.InnerException).Throw(); return null; } }
/// <summary> /// <para>The <c>CreateTopic</c> action creates a topic to which notifications can be published. Users can create at most 100 topics. For more /// information, see <a href="http://aws.amazon.com/sns/">http://aws.amazon.com/sns</a> . /// 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.</para> /// </summary> /// /// <param name="createTopicRequest">Container for the necessary parameters to execute the CreateTopic service method on /// AmazonSimpleNotificationService.</param> /// /// <returns>The response from the CreateTopic service method, as returned by AmazonSimpleNotificationService.</returns> /// /// <exception cref="T:Amazon.SimpleNotificationService.Model.AuthorizationErrorException" /> /// <exception cref="T:Amazon.SimpleNotificationService.Model.InternalErrorException" /> /// <exception cref="T:Amazon.SimpleNotificationService.Model.InvalidParameterException" /> /// <exception cref="T:Amazon.SimpleNotificationService.Model.TopicLimitExceededException" /> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> public async Task<CreateTopicResponse> CreateTopicAsync(CreateTopicRequest createTopicRequest, CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new CreateTopicRequestMarshaller(); var unmarshaller = CreateTopicResponseUnmarshaller.GetInstance(); var response = await Invoke<IRequest, CreateTopicRequest, CreateTopicResponse>(createTopicRequest, marshaller, unmarshaller, signer, cancellationToken) .ConfigureAwait(continueOnCapturedContext: false); return response; }
/// <summary> /// Creates a topic to which notifications can be published. Users can create at most /// 3000 topics. For more information, see <a href="http://aws.amazon.com/sns/">http://aws.amazon.com/sns</a>. /// 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. /// </summary> /// <param name="request">Container for the necessary parameters to execute the CreateTopic service method.</param> /// /// <returns>The response from the CreateTopic service method, as returned by SimpleNotificationService.</returns> /// <exception cref="Amazon.SimpleNotificationService.Model.AuthorizationErrorException"> /// Indicates that the user has been denied access to the requested resource. /// </exception> /// <exception cref="Amazon.SimpleNotificationService.Model.InternalErrorException"> /// Indicates an internal service error. /// </exception> /// <exception cref="Amazon.SimpleNotificationService.Model.InvalidParameterException"> /// Indicates that a request parameter does not comply with the associated constraints. /// </exception> /// <exception cref="Amazon.SimpleNotificationService.Model.TopicLimitExceededException"> /// Indicates that the customer already owns the maximum allowed number of topics. /// </exception> public CreateTopicResponse CreateTopic(CreateTopicRequest request) { var marshaller = new CreateTopicRequestMarshaller(); var unmarshaller = CreateTopicResponseUnmarshaller.Instance; return Invoke<CreateTopicRequest,CreateTopicResponse>(request, marshaller, unmarshaller); }
/// <summary> /// <para>The <c>CreateTopic</c> action creates a topic to which notifications can be published. Users can create at most 3000 topics. For more /// information, see <a href="http://aws.amazon.com/sns/" >http://aws.amazon.com/sns</a> . /// 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.</para> /// </summary> /// /// <param name="createTopicRequest">Container for the necessary parameters to execute the CreateTopic service method on /// AmazonSimpleNotificationService.</param> /// /// <returns>The response from the CreateTopic service method, as returned by AmazonSimpleNotificationService.</returns> /// /// <exception cref="AuthorizationErrorException"/> /// <exception cref="InternalErrorException"/> /// <exception cref="InvalidParameterException"/> /// <exception cref="TopicLimitExceededException"/> public CreateTopicResponse CreateTopic(CreateTopicRequest createTopicRequest) { IAsyncResult asyncResult = invokeCreateTopic(createTopicRequest, null, null, true); return EndCreateTopic(asyncResult); }
/// <summary> /// <para>The <c>CreateTopic</c> action creates a topic to which notifications can be published. Users can create at most 3000 topics. For more /// information, see <a href="http://aws.amazon.com/sns/">http://aws.amazon.com/sns</a> . /// 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.</para> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the CreateTopic service method on /// AmazonSimpleNotificationService.</param> /// /// <returns>The response from the CreateTopic service method, as returned by AmazonSimpleNotificationService.</returns> /// /// <exception cref="T:Amazon.SimpleNotificationService.Model.AuthorizationErrorException" /> /// <exception cref="T:Amazon.SimpleNotificationService.Model.InternalErrorException" /> /// <exception cref="T:Amazon.SimpleNotificationService.Model.InvalidParameterException" /> /// <exception cref="T:Amazon.SimpleNotificationService.Model.TopicLimitExceededException" /> public CreateTopicResponse CreateTopic(CreateTopicRequest request) { var task = CreateTopicAsync(request); try { return task.Result; } catch(AggregateException e) { throw e.InnerException; } }
/// <summary> /// Initiates the asynchronous execution of the CreateTopic operation. /// <seealso cref="Amazon.SimpleNotificationService.IAmazonSimpleNotificationService.CreateTopic"/> /// </summary> /// /// <param name="createTopicRequest">Container for the necessary parameters to execute the CreateTopic operation on /// AmazonSimpleNotificationService.</param> /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param> /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback /// procedure using the AsyncState property.</param> /// /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndCreateTopic /// operation.</returns> public IAsyncResult BeginCreateTopic(CreateTopicRequest createTopicRequest, AsyncCallback callback, object state) { return invokeCreateTopic(createTopicRequest, callback, state, false); }
/// <summary>Create our desired SNS topic</summary> private void CreateTopic() { using (Client) { try { var request = new CreateTopicRequest { Name = Topic }; var response = Client.CreateTopic(request); if (response.IsSetCreateTopicResult()) { var result = response.CreateTopicResult; Project.Log(Level.Info, "SNS topic '{0}' created with ARN: {1}", Topic, result.TopicArn); return; } Project.Log(Level.Info, "Could not create SNS topic. Please check the name: {0}", Topic); } catch (AmazonS3Exception ex) { ShowError(ex); } } }
IAsyncResult invokeCreateTopic(CreateTopicRequest createTopicRequest, AsyncCallback callback, object state, bool synchronized) { IRequest irequest = new CreateTopicRequestMarshaller().Marshall(createTopicRequest); var unmarshaller = CreateTopicResponseUnmarshaller.GetInstance(); AsyncResult result = new AsyncResult(irequest, callback, state, synchronized, signer, unmarshaller); Invoke(result); return result; }