public static IEnumerable<Subscription> ListSubscriptions(string topicArn) { using (var client = new AmazonSimpleNotificationServiceClient(Settings.AccessKey, Settings.Secret)) { var request = new ListSubscriptionsByTopicRequest(topicArn); return client.ListSubscriptionsByTopic(request).Subscriptions; } }
/// <summary> /// Returns a list of the subscriptions to a specific topic. Each call returns a /// limited list of subscriptions, up to 100. If there are more subscriptions, a <code>NextToken</code> /// is also returned. Use the <code>NextToken</code> parameter in a new <code>ListSubscriptionsByTopic</code> /// call to get further results. /// </summary> /// <param name="topicArn">The ARN of the topic for which you wish to find subscriptions.</param> /// /// <returns>The response from the ListSubscriptionsByTopic 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> public ListSubscriptionsByTopicResponse ListSubscriptionsByTopic(string topicArn) { var request = new ListSubscriptionsByTopicRequest(); request.TopicArn = topicArn; return ListSubscriptionsByTopic(request); }
/// <summary> /// <para>The <c>ListSubscriptionsByTopic</c> action returns a list of the subscriptions to a specific topic. Each call returns a limited list /// of subscriptions, up to 100. If there are more subscriptions, a <c>NextToken</c> is also returned. Use the <c>NextToken</c> parameter in a /// new <c>ListSubscriptionsByTopic</c> call to get further results.</para> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the ListSubscriptionsByTopic service method /// on AmazonSimpleNotificationService.</param> /// /// <returns>The response from the ListSubscriptionsByTopic 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.InvalidParameterException" /> public ListSubscriptionsByTopicResponse ListSubscriptionsByTopic(ListSubscriptionsByTopicRequest request) { var task = ListSubscriptionsByTopicAsync(request); try { return task.Result; } catch(AggregateException e) { ExceptionDispatchInfo.Capture(e.InnerException).Throw(); return null; } }
/// <summary> /// Initiates the asynchronous execution of the ListSubscriptionsByTopic operation. /// <seealso cref="Amazon.SimpleNotificationService.IAmazonSimpleNotificationService"/> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the ListSubscriptionsByTopic 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<ListSubscriptionsByTopicResponse> ListSubscriptionsByTopicAsync(ListSubscriptionsByTopicRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new ListSubscriptionsByTopicRequestMarshaller(); var unmarshaller = ListSubscriptionsByTopicResponseUnmarshaller.Instance; return InvokeAsync<ListSubscriptionsByTopicRequest,ListSubscriptionsByTopicResponse>(request, marshaller, unmarshaller, cancellationToken); }
public virtual void DeleteSubscriptions(AmazonSimpleNotificationServiceClient snsClient, string topicArn) { var listSubscriptionsByTopicRequest = new ListSubscriptionsByTopicRequest { TopicArn = topicArn }; ListSubscriptionsByTopicResponse listSubscriptionsByTopicResponse = snsClient.ListSubscriptionsByTopic(listSubscriptionsByTopicRequest); foreach ( Subscription subscription in listSubscriptionsByTopicResponse.Subscriptions) { var unsubscribeRequest = new UnsubscribeRequest { SubscriptionArn = subscription.SubscriptionArn }; snsClient.Unsubscribe(unsubscribeRequest); } }
IAsyncResult invokeListSubscriptionsByTopic(ListSubscriptionsByTopicRequest listSubscriptionsByTopicRequest, AsyncCallback callback, object state, bool synchronized) { IRequest irequest = new ListSubscriptionsByTopicRequestMarshaller().Marshall(listSubscriptionsByTopicRequest); var unmarshaller = ListSubscriptionsByTopicResponseUnmarshaller.GetInstance(); AsyncResult result = new AsyncResult(irequest, callback, state, synchronized, signer, unmarshaller); Invoke(result); return result; }
public static bool List_All_listeners(String topic_name, out List<Subscription> listeners) { bool topic_found; listeners = null; String topic_arn; if (!UtilsDLL.SNS_Utils.Find_Topic_By_Name(topic_name, out topic_found, out topic_arn)) { Console.WriteLine("UtilsDLL.SNS_Utils.Find_Topic_By_Name() failed!!!"); return false; } if (!topic_found) { Console.WriteLine("UtilsDLL.SNS_Utils.Find_Topic_By_Name() did not find topic_name="+topic_name +"!!!"); return false; } ListSubscriptionsByTopicRequest request = new ListSubscriptionsByTopicRequest(); request.TopicArn = topic_arn; ListSubscriptionsByTopicResponse response = sns_client.ListSubscriptionsByTopic(request); listeners = response.ListSubscriptionsByTopicResult.Subscriptions; return true; }
/// <summary> /// <para>The <c>ListSubscriptionsByTopic</c> action returns a list of the subscriptions to a specific topic. Each call returns a limited list /// of subscriptions, up to 100. If there are more subscriptions, a <c>NextToken</c> is also returned. Use the <c>NextToken</c> parameter in a /// new <c>ListSubscriptionsByTopic</c> call to get further results.</para> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the ListSubscriptionsByTopic service method /// on AmazonSimpleNotificationService.</param> /// /// <returns>The response from the ListSubscriptionsByTopic 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.InvalidParameterException" /> public ListSubscriptionsByTopicResponse ListSubscriptionsByTopic(ListSubscriptionsByTopicRequest request) { var task = ListSubscriptionsByTopicAsync(request); try { return task.Result; } catch(AggregateException e) { throw e.InnerException; } }
/// <summary> /// <para>The <c>ListSubscriptionsByTopic</c> action returns a list of the subscriptions to a specific topic. Each call returns a limited list /// of subscriptions, up to 100. If there are more subscriptions, a <c>NextToken</c> is also returned. Use the <c>NextToken</c> parameter in a /// new <c>ListSubscriptionsByTopic</c> call to get further results.</para> /// </summary> /// /// <param name="listSubscriptionsByTopicRequest">Container for the necessary parameters to execute the ListSubscriptionsByTopic service method /// on AmazonSimpleNotificationService.</param> /// /// <returns>The response from the ListSubscriptionsByTopic 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.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<ListSubscriptionsByTopicResponse> ListSubscriptionsByTopicAsync(ListSubscriptionsByTopicRequest listSubscriptionsByTopicRequest, CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new ListSubscriptionsByTopicRequestMarshaller(); var unmarshaller = ListSubscriptionsByTopicResponseUnmarshaller.GetInstance(); var response = await Invoke<IRequest, ListSubscriptionsByTopicRequest, ListSubscriptionsByTopicResponse>(listSubscriptionsByTopicRequest, marshaller, unmarshaller, signer, cancellationToken) .ConfigureAwait(continueOnCapturedContext: false); return response; }
/// <summary> /// Returns a list of the subscriptions to a specific topic. Each call returns a /// limited list of subscriptions, up to 100. If there are more subscriptions, a <code>NextToken</code> /// is also returned. Use the <code>NextToken</code> parameter in a new <code>ListSubscriptionsByTopic</code> /// call to get further results. /// </summary> /// <param name="topicArn">The ARN of the topic for which you wish to find subscriptions.</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 ListSubscriptionsByTopic 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> public Task<ListSubscriptionsByTopicResponse> ListSubscriptionsByTopicAsync(string topicArn, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var request = new ListSubscriptionsByTopicRequest(); request.TopicArn = topicArn; return ListSubscriptionsByTopicAsync(request, cancellationToken); }
/// <summary> /// Initiates the asynchronous execution of the ListSubscriptionsByTopic operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the ListSubscriptionsByTopic 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 ListSubscriptionsByTopicAsync(ListSubscriptionsByTopicRequest request, AmazonServiceCallback<ListSubscriptionsByTopicRequest, ListSubscriptionsByTopicResponse> callback, AsyncOptions options = null) { options = options == null?new AsyncOptions():options; var marshaller = new ListSubscriptionsByTopicRequestMarshaller(); var unmarshaller = ListSubscriptionsByTopicResponseUnmarshaller.Instance; Action<AmazonWebServiceRequest, AmazonWebServiceResponse, Exception, AsyncOptions> callbackHelper = null; if(callback !=null ) callbackHelper = (AmazonWebServiceRequest req, AmazonWebServiceResponse res, Exception ex, AsyncOptions ao) => { AmazonServiceResult<ListSubscriptionsByTopicRequest,ListSubscriptionsByTopicResponse> responseObject = new AmazonServiceResult<ListSubscriptionsByTopicRequest,ListSubscriptionsByTopicResponse>((ListSubscriptionsByTopicRequest)req, (ListSubscriptionsByTopicResponse)res, ex , ao.State); callback(responseObject); }; BeginInvoke<ListSubscriptionsByTopicRequest>(request, marshaller, unmarshaller, options, callbackHelper); }
/// <summary> /// Returns a list of the subscriptions to a specific topic. Each call returns a limited /// list of subscriptions, up to 100. If there are more subscriptions, a <code>NextToken</code> /// is also returned. Use the <code>NextToken</code> parameter in a new <code>ListSubscriptionsByTopic</code> /// call to get further results. /// </summary> /// <param name="topicArn">The ARN of the topic for which you wish to find subscriptions.</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 ListSubscriptionsByTopic 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> public void ListSubscriptionsByTopicAsync(string topicArn, AmazonServiceCallback<ListSubscriptionsByTopicRequest, ListSubscriptionsByTopicResponse> callback, AsyncOptions options = null) { var request = new ListSubscriptionsByTopicRequest(); request.TopicArn = topicArn; ListSubscriptionsByTopicAsync(request, callback, options); }
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 }
public static void SNSListSubscriptionsByTopic() { #region SNSListSubscriptionsByTopic var snsClient = new AmazonSimpleNotificationServiceClient(); var request = new ListSubscriptionsByTopicRequest(); var response = new ListSubscriptionsByTopicResponse(); request.TopicArn = "arn:aws:sns:us-east-1:80398EXAMPLE:CodingTestResults"; do { response = snsClient.ListSubscriptionsByTopic(request); foreach (var sub in response.Subscriptions) { Console.WriteLine("Subscription: {0}", sub.SubscriptionArn); var subAttrs = snsClient.GetSubscriptionAttributes( new GetSubscriptionAttributesRequest { SubscriptionArn = sub.SubscriptionArn }).Attributes; if (subAttrs.Count > 0) { foreach (var subAttr in subAttrs) { Console.WriteLine(" -{0} : {1}", subAttr.Key, subAttr.Value); } } Console.WriteLine(); } request.NextToken = response.NextToken; } while (!string.IsNullOrEmpty(response.NextToken)); #endregion Console.ReadLine(); }
IAsyncResult invokeListSubscriptionsByTopic(ListSubscriptionsByTopicRequest request, AsyncCallback callback, object state, bool synchronized) { var marshaller = new ListSubscriptionsByTopicRequestMarshaller(); var unmarshaller = ListSubscriptionsByTopicResponseUnmarshaller.Instance; return Invoke(request, callback, state, synchronized, marshaller, unmarshaller, signer); }
/// <summary> /// Returns a list of the subscriptions to a specific topic. Each call returns a /// limited list of subscriptions, up to 100. If there are more subscriptions, a <code>NextToken</code> /// is also returned. Use the <code>NextToken</code> parameter in a new <code>ListSubscriptionsByTopic</code> /// call to get further results. /// </summary> /// <param name="request">Container for the necessary parameters to execute the ListSubscriptionsByTopic service method.</param> /// /// <returns>The response from the ListSubscriptionsByTopic 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> public ListSubscriptionsByTopicResponse ListSubscriptionsByTopic(ListSubscriptionsByTopicRequest request) { var marshaller = new ListSubscriptionsByTopicRequestMarshaller(); var unmarshaller = ListSubscriptionsByTopicResponseUnmarshaller.Instance; return Invoke<ListSubscriptionsByTopicRequest,ListSubscriptionsByTopicResponse>(request, marshaller, unmarshaller); }
/// <summary> /// Initiates the asynchronous execution of the ListSubscriptionsByTopic operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the ListSubscriptionsByTopic 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 EndListSubscriptionsByTopic /// operation.</returns> public IAsyncResult BeginListSubscriptionsByTopic(ListSubscriptionsByTopicRequest request, AsyncCallback callback, object state) { var marshaller = new ListSubscriptionsByTopicRequestMarshaller(); var unmarshaller = ListSubscriptionsByTopicResponseUnmarshaller.Instance; return BeginInvoke<ListSubscriptionsByTopicRequest>(request, marshaller, unmarshaller, callback, state); }
/// <summary> /// <para>The <c>ListSubscriptionsByTopic</c> action returns a list of the subscriptions to a specific topic. Each call returns a limited list /// of subscriptions, up to 100. If there are more subscriptions, a <c>NextToken</c> is also returned. Use the <c>NextToken</c> parameter in a /// new <c>ListSubscriptionsByTopic</c> call to get further results.</para> /// </summary> /// /// <param name="listSubscriptionsByTopicRequest">Container for the necessary parameters to execute the ListSubscriptionsByTopic service method /// on AmazonSimpleNotificationService.</param> /// /// <returns>The response from the ListSubscriptionsByTopic service method, as returned by AmazonSimpleNotificationService.</returns> /// /// <exception cref="NotFoundException"/> /// <exception cref="AuthorizationErrorException"/> /// <exception cref="InternalErrorException"/> /// <exception cref="InvalidParameterException"/> public ListSubscriptionsByTopicResponse ListSubscriptionsByTopic(ListSubscriptionsByTopicRequest listSubscriptionsByTopicRequest) { IAsyncResult asyncResult = invokeListSubscriptionsByTopic(listSubscriptionsByTopicRequest, null, null, true); return EndListSubscriptionsByTopic(asyncResult); }
/// <summary> /// Initiates the asynchronous execution of the ListSubscriptionsByTopic operation. /// <seealso cref="Amazon.SimpleNotificationService.IAmazonSimpleNotificationService.ListSubscriptionsByTopic"/> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the ListSubscriptionsByTopic 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<ListSubscriptionsByTopicResponse> ListSubscriptionsByTopicAsync(ListSubscriptionsByTopicRequest request, CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new ListSubscriptionsByTopicRequestMarshaller(); var unmarshaller = ListSubscriptionsByTopicResponseUnmarshaller.GetInstance(); return Invoke<IRequest, ListSubscriptionsByTopicRequest, ListSubscriptionsByTopicResponse>(request, marshaller, unmarshaller, signer, cancellationToken); }
/// <summary> /// Initiates the asynchronous execution of the ListSubscriptionsByTopic operation. /// <seealso cref="Amazon.SimpleNotificationService.IAmazonSimpleNotificationService.ListSubscriptionsByTopic"/> /// </summary> /// /// <param name="listSubscriptionsByTopicRequest">Container for the necessary parameters to execute the ListSubscriptionsByTopic 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 /// EndListSubscriptionsByTopic operation.</returns> public IAsyncResult BeginListSubscriptionsByTopic(ListSubscriptionsByTopicRequest listSubscriptionsByTopicRequest, AsyncCallback callback, object state) { return invokeListSubscriptionsByTopic(listSubscriptionsByTopicRequest, callback, state, false); }