Container for the parameters to the Subscribe operation. Prepares to subscribe an endpoint by sending the endpoint a confirmation message. To actually create a subscription, the endpoint owner must call the ConfirmSubscription action with the token from the confirmation message. Confirmation tokens are valid for three days.
Inheritance: AmazonSimpleNotificationServiceRequest
Ejemplo n.º 1
0
 public IHttpActionResult GetSubscription()
 {
     try
     {
         ConfigureNLog();
         NLog.LogManager.GetLogger("aws").Info("GetSubscription Entered");
         var endpoint = ConfigurationManager.AppSettings["SnsEndpoint"];
         var topicarn = ConfigurationManager.AppSettings["SnsEventsTopicArn"];
         var client   = new Amazon.SimpleNotificationService.AmazonSimpleNotificationServiceClient();
         var request  = new AM.SubscribeRequest
         {
             Protocol = "https",
             Endpoint = endpoint,
             TopicArn = topicarn
         };
         var response = client.Subscribe(request);
         NLog.LogManager.GetLogger("aws").Info("GetSubscription returned response SubscriptionArn=" + response.SubscriptionArn);
         return(Ok(response.SubscriptionArn)); //TODO - stuff this in database, on PostConfirmation verify response topic is pending
     }
     catch (Exception ex)
     {
         string msg = ex.ToString();
         try
         {
             NLog.LogManager.GetLogger("aws").Info("GetSubscription got error " + ex.ToString());
         } catch (Exception ex2)
         {
         }
         return(BadRequest("AN ERROR HAPEPNED: " + msg));
     }
 }
Ejemplo n.º 2
0
 public static bool Add_SQS_Subscription(String topic_arn, String sqs_Q_listener_arn)
 {
     SubscribeRequest request = new SubscribeRequest();
     request.Protocol = "SQS";
     request.Endpoint = sqs_Q_listener_arn;
     request.TopicArn = topic_arn;
     SubscribeResponse response = sns_client.Subscribe(request);
     return true;
 }
Ejemplo n.º 3
0
        public static void CreateEmailSubscription(string topicArn, string emailAddress)
        {
            using (var client = new AmazonSimpleNotificationServiceClient(Settings.AccessKey, Settings.Secret))
            {
                var request = new SubscribeRequest(topicArn, "email", emailAddress);

                client.Subscribe(request);
            }
        }
Ejemplo n.º 4
0
        public string SubscribeQueueToTopic(string queueArn, string topicArn)
        {
            queueArn.Requires("queueArn").IsNotNullOrWhiteSpace();
            topicArn.Requires("topicArn").IsNotNullOrWhiteSpace();

            var subScribeRequest = new SubscribeRequest(topicArn, SqsProtocol, queueArn);
            using (var sns = amazonSnsFactory())
            {
                var response = sns.Subscribe(subScribeRequest);
                return response?.SubscriptionArn;
            }
        }
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.SimpleNotificationService.Model.SubscribeRequest();

            if (cmdletContext.Attribute != null)
            {
                request.Attributes = cmdletContext.Attribute;
            }
            if (cmdletContext.Endpoint != null)
            {
                request.Endpoint = cmdletContext.Endpoint;
            }
            if (cmdletContext.Protocol != null)
            {
                request.Protocol = cmdletContext.Protocol;
            }
            if (cmdletContext.ReturnSubscriptionArn != null)
            {
                request.ReturnSubscriptionArn = cmdletContext.ReturnSubscriptionArn.Value;
            }
            if (cmdletContext.TopicArn != null)
            {
                request.TopicArn = cmdletContext.TopicArn;
            }

            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);
        }
Ejemplo n.º 6
0
        public string SubscribeQueueToTopic(string queueArn, string topicArn)
        {
            Validate.That(queueArn).IsNotNullOrEmpty();
            Validate.That(topicArn).IsNotNullOrEmpty();

            var subScribeRequest =
                new SubscribeRequest().WithEndpoint(queueArn).WithProtocol(sqsProtocol).WithTopicArn(topicArn);
            using (var sns = amazonSnsFactory())
            {
                var response = sns.Subscribe(subScribeRequest);
                return response.SubscribeResult.SubscriptionArn;
            }
        }
Ejemplo n.º 7
0
 public virtual void CreateSubscription(AmazonSimpleNotificationServiceClient snsClient, string queueArn,
     string topicArn)
 {
     // Create the request
     var subscriptionRequest = new SubscribeRequest
     {
         Endpoint = queueArn,
         Protocol = "sqs",
         TopicArn = topicArn
     };
     // Create the subscription
     snsClient.Subscribe(subscriptionRequest);
 }
        public void subscribe_to_topic()
        {
            var getArnRequest = new GetQueueAttributesRequest().WithQueueUrl(_queueUrl).WithAttributeName("QueueArn");
            var clientArn = _client.GetQueueAttributes(getArnRequest).GetQueueAttributesResult.Attribute[0].Value;

            var sns = Amazon.AWSClientFactory.CreateAmazonSNSClient("AKIAIN2KJH4QJIUV7CGQ",
                                                                    "18ypN0y7SGA+L0XDVMHm9lBVmQ2oF2bdm7CGIijA");

            var subscriptionRequest = new SubscribeRequest()
                .WithEndpoint(clientArn)
                .WithProtocol("sqs")
                .WithTopicArn("arn:aws:sns:us-east-1:451419498740:EventMessage");
            
            var response = sns.Subscribe(subscriptionRequest);
            Console.WriteLine(response.SubscribeResult.SubscriptionArn);
        }
Ejemplo n.º 9
0
        public void Subscribe()
        {
            SetPermissions();
            var getArnRequest = new GetQueueAttributesRequest().WithQueueUrl(_config.SqsQueueUrl).WithAttributeName("QueueArn");
            var clientArn = _client.GetQueueAttributes(getArnRequest).GetQueueAttributesResult.Attribute[0].Value;

            var sns = AWSClientFactory.CreateAmazonSNSClient(_config.AccessKeyId,
                                                                    _config.SecretKey);

            var subscriptionRequest = new SubscribeRequest()
                .WithEndpoint(clientArn)
                .WithProtocol("sqs")
                .WithTopicArn(_config.TopicAccessResourceName);

            sns.Subscribe(subscriptionRequest);
        }
Ejemplo n.º 10
0
        public void create_sqs_queue()
        {
            GetUserNameAndPassword();
            var sqsClient = Amazon.AWSClientFactory.CreateAmazonSQSClient(_key, _secret);
            var snsTopic = Amazon.AWSClientFactory.CreateAmazonSNSClient(_key, _secret);
            var topicArn = "arn:aws:sns:us-east-1:451419498740:Elliott-has-an-awesome-blog";
            //Create a new SQS queue
            var createQueueRequest = new CreateQueueRequest().WithQueueName("elliotts-blog");
            var createQueueResponse = sqsClient.CreateQueue(createQueueRequest);
            // keep the queueUrl handy
            var queueUrl = createQueueResponse.CreateQueueResult.QueueUrl;
            // get the Access Resource Name so we can allow the SNS to put messages on it
            var getQueueArnRequest = new GetQueueAttributesRequest()
                .WithQueueUrl(queueUrl)
                .WithAttributeName("QueueArn");
            var getQueueArnResponse = sqsClient.GetQueueAttributes(getQueueArnRequest);
            var queueArn = getQueueArnResponse.GetQueueAttributesResult.Attribute[0].Value;

            //create a Policy for the SQS queue that allows SNS to publish to it
            var allowSnsStatement = new Statement(Statement.StatementEffect.Allow)
                .WithPrincipals(Principal.AllUsers)
                .WithResources(new Resource(queueArn))
                .WithConditions(ConditionFactory.NewSourceArnCondition(topicArn))
                .WithActionIdentifiers(SQSActionIdentifiers.SendMessage);
            var policy = new Policy("allow sns").WithStatements(new[] {allowSnsStatement});
            var attribute = new Attribute().WithName("Policy").WithValue(policy.ToJson());
            var setQueueAttributesRequest =
                new SetQueueAttributesRequest().WithQueueUrl(queueUrl).WithAttribute(attribute);
            sqsClient.SetQueueAttributes(setQueueAttributesRequest);

            // ok, now lets create the subscription for sqs with the queueArn we created
            var subscribeRequest = new SubscribeRequest()
                .WithEndpoint(queueArn)
                .WithTopicArn(topicArn)
                .WithProtocol("sqs");

            snsTopic.Subscribe(subscribeRequest);
        }
Ejemplo n.º 11
0
        /// <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);
            }
        }
Ejemplo n.º 12
0
		/// <summary>
		/// By subscribe your email account should get a message confirming the topic
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		async void subscribe_Click(object sender, EventArgs ex)
		{
			try
			{
				var request = new SubscribeRequest()
				{
					TopicArn = _topicArn,
					Protocol = "email",
					Endpoint = _emailTextView.Text
				};

				await snsClient.SubscribeAsync(request);
				_statusTextView.Text = "Subscription successful";
			}
			catch (Exception e)
			{
				_statusTextView.Text = string.Format("Error subscribing to topic: {0}", e.Message);
			}
		}
Ejemplo n.º 13
0
        /// <summary>
        /// Subscribe to a SNS Topic
        /// </summary>
        /// <param name="topicArn"></param>
        /// <param name="protocol"></param>
        /// <param name="endpoint"></param>
        /// <returns></returns>
        public string Subscribe(string topicArn, string protocol, string endpoint)
        {
            var request = new SubscribeRequest { TopicArn = topicArn, Protocol = protocol, Endpoint = endpoint };

            SubscribeResponse response = Client.Subscribe(request);

            Trace.WriteLine(response.SubscribeResult.SubscriptionArn, "SubscriptionArn");

            return response.SubscribeResult.SubscriptionArn;
        }
        IAsyncResult invokeSubscribe(SubscribeRequest request, AsyncCallback callback, object state, bool synchronized)
        {
            var marshaller = new SubscribeRequestMarshaller();
            var unmarshaller = SubscribeResponseUnmarshaller.Instance;

            return Invoke(request, callback, state, synchronized, marshaller, unmarshaller, signer);
        }
        /// <summary>
        /// <para>The <c>Subscribe</c> action prepares to subscribe an endpoint by sending the endpoint a confirmation message. To actually create a
        /// subscription, the endpoint owner must call the <c>ConfirmSubscription</c> action with the token from the confirmation message. Confirmation
        /// tokens are valid for three days.</para>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the Subscribe service method on
        /// AmazonSimpleNotificationService.</param>
        /// 
        /// <returns>The response from the Subscribe service method, as returned by AmazonSimpleNotificationService.</returns>
        /// 
        /// <exception cref="T:Amazon.SimpleNotificationService.Model.NotFoundException" />
        /// <exception cref="T:Amazon.SimpleNotificationService.Model.AuthorizationErrorException" />
        /// <exception cref="T:Amazon.SimpleNotificationService.Model.InternalErrorException" />
        /// <exception cref="T:Amazon.SimpleNotificationService.Model.SubscriptionLimitExceededException" />
        /// <exception cref="T:Amazon.SimpleNotificationService.Model.InvalidParameterException" />
		public SubscribeResponse Subscribe(SubscribeRequest request)
        {
            var task = SubscribeAsync(request);
            try
            {
                return task.Result;
            }
            catch(AggregateException e)
            {
                throw e.InnerException;
            }
        }
        /// <summary>
        /// Prepares to subscribe an endpoint by sending the endpoint a confirmation message.
        /// To actually create a      subscription, the endpoint owner must call the <code>ConfirmSubscription</code>
        ///      action with the token from the confirmation message. Confirmation tokens are
        ///      valid for three days.
        /// </summary>
        /// <param name="request">Container for the necessary parameters to execute the Subscribe service method.</param>
        /// 
        /// <returns>The response from the Subscribe 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.NotFoundException">
        /// Indicates that the requested resource does not exist.
        /// </exception>
        /// <exception cref="Amazon.SimpleNotificationService.Model.SubscriptionLimitExceededException">
        /// Indicates that the customer already owns the maximum allowed number of subscriptions.
        /// </exception>
        public SubscribeResponse Subscribe(SubscribeRequest request)
        {
            var marshaller = new SubscribeRequestMarshaller();
            var unmarshaller = SubscribeResponseUnmarshaller.Instance;

            return Invoke<SubscribeRequest,SubscribeResponse>(request, marshaller, unmarshaller);
        }
        /// <summary>
        /// <para>The <c>Subscribe</c> action prepares to subscribe an endpoint by sending the endpoint a confirmation message. To actually create a
        /// subscription, the endpoint owner must call the <c>ConfirmSubscription</c> action with the token from the confirmation message. Confirmation
        /// tokens are valid for three days.</para>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the Subscribe service method on
        /// AmazonSimpleNotificationService.</param>
        /// 
        /// <returns>The response from the Subscribe service method, as returned by AmazonSimpleNotificationService.</returns>
        /// 
        /// <exception cref="T:Amazon.SimpleNotificationService.Model.NotFoundException" />
        /// <exception cref="T:Amazon.SimpleNotificationService.Model.AuthorizationErrorException" />
        /// <exception cref="T:Amazon.SimpleNotificationService.Model.InternalErrorException" />
        /// <exception cref="T:Amazon.SimpleNotificationService.Model.SubscriptionLimitExceededException" />
        /// <exception cref="T:Amazon.SimpleNotificationService.Model.InvalidParameterException" />
		public SubscribeResponse Subscribe(SubscribeRequest request)
        {
            var task = SubscribeAsync(request);
            try
            {
                return task.Result;
            }
            catch(AggregateException e)
            {
                ExceptionDispatchInfo.Capture(e.InnerException).Throw();
                return null;
            }
        }
 /// <summary>
 /// Prepares to subscribe an endpoint by sending the endpoint a confirmation message.
 /// To actually create a subscription, the endpoint owner must call the <code>ConfirmSubscription</code>
 /// action with the token from the confirmation message. Confirmation tokens are valid
 /// for three days.
 /// </summary>
 /// <param name="topicArn">The ARN of the topic you want to subscribe to.</param>
 /// <param name="protocol">The protocol you want to use. Supported protocols include: <ul> <li>  <code>http</code> -- delivery of JSON-encoded message via HTTP POST </li> <li>  <code>https</code> -- delivery of JSON-encoded message via HTTPS POST </li> <li>  <code>email</code> -- delivery of message via SMTP </li> <li>  <code>email-json</code> -- delivery of JSON-encoded message via SMTP </li> <li>  <code>sms</code> -- delivery of message via SMS </li> <li>  <code>sqs</code> -- delivery of JSON-encoded message to an Amazon SQS queue </li> <li>  <code>application</code> -- delivery of JSON-encoded message to an EndpointArn for a mobile app and device. </li> <li>  <code>lambda</code> -- delivery of JSON-encoded message to an AWS Lambda function. </li> </ul></param>
 /// <param name="endpoint">The endpoint that you want to receive notifications. Endpoints vary by protocol: <ul> <li> For the <code>http</code> protocol, the endpoint is an URL beginning with "http://" </li> <li> For the <code>https</code> protocol, the endpoint is a URL beginning with "https://" </li> <li> For the <code>email</code> protocol, the endpoint is an email address </li> <li> For the <code>email-json</code> protocol, the endpoint is an email address </li> <li> For the <code>sms</code> protocol, the endpoint is a phone number of an SMS-enabled device </li> <li> For the <code>sqs</code> protocol, the endpoint is the ARN of an Amazon SQS queue </li> <li> For the <code>application</code> protocol, the endpoint is the EndpointArn of a mobile app and device. </li> <li> For the <code>lambda</code> protocol, the endpoint is the ARN of an AWS Lambda function. </li> </ul></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 Subscribe 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.NotFoundException">
 /// Indicates that the requested resource does not exist.
 /// </exception>
 /// <exception cref="Amazon.SimpleNotificationService.Model.SubscriptionLimitExceededException">
 /// Indicates that the customer already owns the maximum allowed number of subscriptions.
 /// </exception>
 public void SubscribeAsync(string topicArn, string protocol, string endpoint,  AmazonServiceCallback<SubscribeRequest, SubscribeResponse> callback, AsyncOptions options = null)
 {
     var request = new SubscribeRequest();
     request.TopicArn = topicArn;
     request.Protocol = protocol;
     request.Endpoint = endpoint;
     SubscribeAsync(request, callback, options);
 }
 /// <summary>
 /// Initiates the asynchronous execution of the Subscribe operation.
 /// </summary>
 /// 
 /// <param name="request">Container for the necessary parameters to execute the Subscribe 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 SubscribeAsync(SubscribeRequest request, AmazonServiceCallback<SubscribeRequest, SubscribeResponse> callback, AsyncOptions options = null)
 {
     options = options == null?new AsyncOptions():options;
     var marshaller = new SubscribeRequestMarshaller();
     var unmarshaller = SubscribeResponseUnmarshaller.Instance;
     Action<AmazonWebServiceRequest, AmazonWebServiceResponse, Exception, AsyncOptions> callbackHelper = null;
     if(callback !=null )
         callbackHelper = (AmazonWebServiceRequest req, AmazonWebServiceResponse res, Exception ex, AsyncOptions ao) => { 
             AmazonServiceResult<SubscribeRequest,SubscribeResponse> responseObject 
                     = new AmazonServiceResult<SubscribeRequest,SubscribeResponse>((SubscribeRequest)req, (SubscribeResponse)res, ex , ao.State);    
                 callback(responseObject); 
         };
     BeginInvoke<SubscribeRequest>(request, marshaller, unmarshaller, options, callbackHelper);
 }
        /// <summary>
        /// Initiates the asynchronous execution of the Subscribe operation.
        /// <seealso cref="Amazon.SimpleNotificationService.IAmazonSimpleNotificationService"/>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the Subscribe 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<SubscribeResponse> SubscribeAsync(SubscribeRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new SubscribeRequestMarshaller();
            var unmarshaller = SubscribeResponseUnmarshaller.Instance;

            return InvokeAsync<SubscribeRequest,SubscribeResponse>(request, marshaller,
                unmarshaller, cancellationToken);
        }
 /// <summary>
 /// Prepares to subscribe an endpoint by sending the endpoint a confirmation message.
 /// To actually create a      subscription, the endpoint owner must call the <code>ConfirmSubscription</code>
 ///      action with the token from the confirmation message. Confirmation tokens are
 ///      valid for three days.
 /// </summary>
 /// <param name="topicArn">The ARN of the topic you want to subscribe to.</param>
 /// <param name="protocol">The protocol you want to use. Supported protocols include: <ul>   <li><code>http</code> -- delivery of JSON-encoded message via HTTP POST</li>   <li><code>https</code> -- delivery of JSON-encoded message via HTTPS POST</li>   <li><code>email</code> -- delivery of message via SMTP</li>   <li><code>email-json</code> -- delivery of JSON-encoded message via SMTP</li>   <li><code>sms</code> -- delivery of message via SMS</li>   <li><code>sqs</code> -- delivery of JSON-encoded message to an Amazon SQS queue</li>   <li><code>application</code> -- delivery of JSON-encoded message to an EndpointArn for a mobile app and device.</li> </ul></param>
 /// <param name="endpoint">The endpoint that you want to receive notifications. Endpoints vary by protocol: <ul>   <li>For the <code>http</code> protocol, the endpoint is an URL beginning with "http://"</li>   <li>For the <code>https</code> protocol, the endpoint is a URL beginning with "https://"</li>   <li>For the <code>email</code> protocol, the endpoint is an email address</li>   <li>For the <code>email-json</code> protocol, the endpoint is an email address</li>   <li>For the <code>sms</code> protocol, the endpoint is a phone number of an SMS-enabled device</li>   <li>For the <code>sqs</code> protocol, the endpoint is the ARN of an Amazon SQS queue</li>   <li>For the <code>application</code> protocol, the endpoint is the EndpointArn of a mobile app and device.</li> </ul></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 Subscribe 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.NotFoundException">
 /// Indicates that the requested resource does not exist.
 /// </exception>
 /// <exception cref="Amazon.SimpleNotificationService.Model.SubscriptionLimitExceededException">
 /// Indicates that the customer already owns the maximum allowed number of subscriptions.
 /// </exception>
 public Task<SubscribeResponse> SubscribeAsync(string topicArn, string protocol, string endpoint, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
 {
     var request = new SubscribeRequest();
     request.TopicArn = topicArn;
     request.Protocol = protocol;
     request.Endpoint = endpoint;
     return SubscribeAsync(request, cancellationToken);
 }
 /// <summary>
 /// Prepares to subscribe an endpoint by sending the endpoint a confirmation message.
 /// To actually create a      subscription, the endpoint owner must call the <code>ConfirmSubscription</code>
 ///      action with the token from the confirmation message. Confirmation tokens are
 ///      valid for three days.
 /// </summary>
 /// <param name="topicArn">The ARN of the topic you want to subscribe to.</param>
 /// <param name="protocol">The protocol you want to use. Supported protocols include: <ul>   <li><code>http</code> -- delivery of JSON-encoded message via HTTP POST</li>   <li><code>https</code> -- delivery of JSON-encoded message via HTTPS POST</li>   <li><code>email</code> -- delivery of message via SMTP</li>   <li><code>email-json</code> -- delivery of JSON-encoded message via SMTP</li>   <li><code>sms</code> -- delivery of message via SMS</li>   <li><code>sqs</code> -- delivery of JSON-encoded message to an Amazon SQS queue</li>   <li><code>application</code> -- delivery of JSON-encoded message to an EndpointArn for a mobile app and device.</li> </ul></param>
 /// <param name="endpoint">The endpoint that you want to receive notifications. Endpoints vary by protocol: <ul>   <li>For the <code>http</code> protocol, the endpoint is an URL beginning with "http://"</li>   <li>For the <code>https</code> protocol, the endpoint is a URL beginning with "https://"</li>   <li>For the <code>email</code> protocol, the endpoint is an email address</li>   <li>For the <code>email-json</code> protocol, the endpoint is an email address</li>   <li>For the <code>sms</code> protocol, the endpoint is a phone number of an SMS-enabled device</li>   <li>For the <code>sqs</code> protocol, the endpoint is the ARN of an Amazon SQS queue</li>   <li>For the <code>application</code> protocol, the endpoint is the EndpointArn of a mobile app and device.</li> </ul></param>
 /// 
 /// <returns>The response from the Subscribe 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.NotFoundException">
 /// Indicates that the requested resource does not exist.
 /// </exception>
 /// <exception cref="Amazon.SimpleNotificationService.Model.SubscriptionLimitExceededException">
 /// Indicates that the customer already owns the maximum allowed number of subscriptions.
 /// </exception>
 public SubscribeResponse Subscribe(string topicArn, string protocol, string endpoint)
 {
     var request = new SubscribeRequest();
     request.TopicArn = topicArn;
     request.Protocol = protocol;
     request.Endpoint = endpoint;
     return Subscribe(request);
 }
        /// <summary>
        /// <para>The <c>Subscribe</c> action prepares to subscribe an endpoint by sending the endpoint a confirmation message. To actually create a
        /// subscription, the endpoint owner must call the <c>ConfirmSubscription</c> action with the token from the confirmation message. Confirmation
        /// tokens are valid for three days.</para>
        /// </summary>
        /// 
        /// <param name="subscribeRequest">Container for the necessary parameters to execute the Subscribe service method on
        /// AmazonSimpleNotificationService.</param>
        /// 
        /// <returns>The response from the Subscribe service method, as returned by AmazonSimpleNotificationService.</returns>
        /// 
        /// <exception cref="T:Amazon.SimpleNotificationService.Model.NotFoundException" />
        /// <exception cref="T:Amazon.SimpleNotificationService.Model.AuthorizationErrorException" />
        /// <exception cref="T:Amazon.SimpleNotificationService.Model.InternalErrorException" />
        /// <exception cref="T:Amazon.SimpleNotificationService.Model.SubscriptionLimitExceededException" />
        /// <exception cref="T:Amazon.SimpleNotificationService.Model.InvalidParameterException" />
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
		public async Task<SubscribeResponse> SubscribeAsync(SubscribeRequest subscribeRequest, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new SubscribeRequestMarshaller();
            var unmarshaller = SubscribeResponseUnmarshaller.GetInstance();
            var response = await Invoke<IRequest, SubscribeRequest, SubscribeResponse>(subscribeRequest, marshaller, unmarshaller, signer, cancellationToken)
                .ConfigureAwait(continueOnCapturedContext: false);
            return response;
        }
        /// <summary>
        /// Initiates the asynchronous execution of the Subscribe operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the Subscribe 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 EndSubscribe
        ///         operation.</returns>
        public IAsyncResult BeginSubscribe(SubscribeRequest request, AsyncCallback callback, object state)
        {
            var marshaller = new SubscribeRequestMarshaller();
            var unmarshaller = SubscribeResponseUnmarshaller.Instance;

            return BeginInvoke<SubscribeRequest>(request, marshaller, unmarshaller,
                callback, state);
        }
 /// <summary>
 /// <para>The <c>Subscribe</c> action prepares to subscribe an endpoint by sending the endpoint a confirmation message. To actually create a
 /// subscription, the endpoint owner must call the <c>ConfirmSubscription</c> action with the token from the confirmation message. Confirmation
 /// tokens are valid for three days.</para>
 /// </summary>
 /// 
 /// <param name="subscribeRequest">Container for the necessary parameters to execute the Subscribe service method on
 ///          AmazonSimpleNotificationService.</param>
 /// 
 /// <returns>The response from the Subscribe service method, as returned by AmazonSimpleNotificationService.</returns>
 /// 
 /// <exception cref="NotFoundException"/>
 /// <exception cref="AuthorizationErrorException"/>
 /// <exception cref="InternalErrorException"/>
 /// <exception cref="SubscriptionLimitExceededException"/>
 /// <exception cref="InvalidParameterException"/>
 public SubscribeResponse Subscribe(SubscribeRequest subscribeRequest)
 {
     IAsyncResult asyncResult = invokeSubscribe(subscribeRequest, null, null, true);
     return EndSubscribe(asyncResult);
 }
        /// <summary>
        /// Initiates the asynchronous execution of the Subscribe operation.
        /// <seealso cref="Amazon.SimpleNotificationService.IAmazonSimpleNotificationService.Subscribe"/>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the Subscribe 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<SubscribeResponse> SubscribeAsync(SubscribeRequest request, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new SubscribeRequestMarshaller();
            var unmarshaller = SubscribeResponseUnmarshaller.GetInstance();
            return Invoke<IRequest, SubscribeRequest, SubscribeResponse>(request, marshaller, unmarshaller, signer, cancellationToken);
        }
 /// <summary>
 /// Initiates the asynchronous execution of the Subscribe operation.
 /// <seealso cref="Amazon.SimpleNotificationService.IAmazonSimpleNotificationService.Subscribe"/>
 /// </summary>
 /// 
 /// <param name="subscribeRequest">Container for the necessary parameters to execute the Subscribe 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 EndSubscribe
 ///         operation.</returns>
 public IAsyncResult BeginSubscribe(SubscribeRequest subscribeRequest, AsyncCallback callback, object state)
 {
     return invokeSubscribe(subscribeRequest, callback, state, false);
 }
 private Amazon.SimpleNotificationService.Model.SubscribeResponse CallAWSServiceOperation(IAmazonSimpleNotificationService client, Amazon.SimpleNotificationService.Model.SubscribeRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Simple Notification Service (SNS)", "Subscribe");
     try
     {
         #if DESKTOP
         return(client.Subscribe(request));
         #elif CORECLR
         return(client.SubscribeAsync(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;
     }
 }
 IAsyncResult invokeSubscribe(SubscribeRequest subscribeRequest, AsyncCallback callback, object state, bool synchronized)
 {
     IRequest irequest = new SubscribeRequestMarshaller().Marshall(subscribeRequest);
     var unmarshaller = SubscribeResponseUnmarshaller.GetInstance();
     AsyncResult result = new AsyncResult(irequest, callback, state, synchronized, signer, unmarshaller);
     Invoke(result);
     return result;
 }