public string UnsubscribeQueueFromTopic(string subscriptionArn) { subscriptionArn.Requires("subscriptionArn").IsNotNullOrWhiteSpace(); var unsubscribeRequest = new UnsubscribeRequest(subscriptionArn); using (var sns = amazonSnsFactory()) { var response = sns.Unsubscribe(unsubscribeRequest); return response.ResponseMetadata.RequestId; } }
public object Execute(ExecutorContext context) { var cmdletContext = context as CmdletContext; // create request var request = new Amazon.SimpleNotificationService.Model.UnsubscribeRequest(); if (cmdletContext.SubscriptionArn != null) { request.SubscriptionArn = cmdletContext.SubscriptionArn; } 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> /// Deletes a subscription. If the subscription requires authentication for deletion, /// only the owner of the subscription or the topic's owner can unsubscribe, and /// an AWS signature is required. If the <code>Unsubscribe</code> call does not /// require authentication and the requester is not the subscription owner, a final /// cancellation message is delivered to the endpoint, so that the endpoint owner /// can easily resubscribe to the topic if the <code>Unsubscribe</code> request /// was unintended. /// </summary> /// <param name="subscriptionArn">The ARN of the subscription to be deleted.</param> /// /// <returns>The response from the Unsubscribe 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 UnsubscribeResponse Unsubscribe(string subscriptionArn) { var request = new UnsubscribeRequest(); request.SubscriptionArn = subscriptionArn; return Unsubscribe(request); }
/// <summary> /// <para>The <c>Unsubscribe</c> action deletes a subscription. If the subscription requires authentication for deletion, only the owner of the /// subscription or the topic's owner can unsubscribe, and an AWS signature is required. If the <c>Unsubscribe</c> call does not require /// authentication and the requester is not the subscription owner, a final cancellation message is delivered to the endpoint, so that the /// endpoint owner can easily resubscribe to the topic if the <c>Unsubscribe</c> request was unintended.</para> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the Unsubscribe service method on /// AmazonSimpleNotificationService.</param> /// /// <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 UnsubscribeResponse Unsubscribe(UnsubscribeRequest request) { var task = UnsubscribeAsync(request); try { return task.Result; } catch(AggregateException e) { ExceptionDispatchInfo.Capture(e.InnerException).Throw(); return null; } }
/// <summary> /// Initiates the asynchronous execution of the Unsubscribe operation. /// <seealso cref="Amazon.SimpleNotificationService.IAmazonSimpleNotificationService"/> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the Unsubscribe 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<UnsubscribeResponse> UnsubscribeAsync(UnsubscribeRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new UnsubscribeRequestMarshaller(); var unmarshaller = UnsubscribeResponseUnmarshaller.Instance; return InvokeAsync<UnsubscribeRequest,UnsubscribeResponse>(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); } }
public string UnsubscribeQueueFromTopic(string subscriptionArn) { Validate.That(subscriptionArn).IsNotNullOrEmpty(); var unsubscribeRequest = new UnsubscribeRequest().WithSubscriptionArn(subscriptionArn); using (var sns = amazonSnsFactory()) { var response = sns.Unsubscribe(unsubscribeRequest); return response.ResponseMetadata.RequestId; } }
/// <summary> /// <para>The <c>Unsubscribe</c> action deletes a subscription. If the subscription requires authentication for deletion, only the owner of the /// subscription or the topic's owner can unsubscribe, and an AWS signature is required. If the <c>Unsubscribe</c> call does not require /// authentication and the requester is not the subscription owner, a final cancellation message is delivered to the endpoint, so that the /// endpoint owner can easily resubscribe to the topic if the <c>Unsubscribe</c> request was unintended.</para> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the Unsubscribe service method on /// AmazonSimpleNotificationService.</param> /// /// <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 UnsubscribeResponse Unsubscribe(UnsubscribeRequest request) { var task = UnsubscribeAsync(request); try { return task.Result; } catch(AggregateException e) { throw e.InnerException; } }
/// <summary> /// <para>The <c>Unsubscribe</c> action deletes a subscription. If the subscription requires authentication for deletion, only the owner of the /// subscription or the topic's owner can unsubscribe, and an AWS signature is required. If the <c>Unsubscribe</c> call does not require /// authentication and the requester is not the subscription owner, a final cancellation message is delivered to the endpoint, so that the /// endpoint owner can easily resubscribe to the topic if the <c>Unsubscribe</c> request was unintended.</para> /// </summary> /// /// <param name="unsubscribeRequest">Container for the necessary parameters to execute the Unsubscribe service method on /// AmazonSimpleNotificationService.</param> /// /// <exception cref="NotFoundException"/> /// <exception cref="AuthorizationErrorException"/> /// <exception cref="InternalErrorException"/> /// <exception cref="InvalidParameterException"/> public UnsubscribeResponse Unsubscribe(UnsubscribeRequest unsubscribeRequest) { IAsyncResult asyncResult = invokeUnsubscribe(unsubscribeRequest, null, null, true); return EndUnsubscribe(asyncResult); }
/// <summary> /// <para>The <c>Unsubscribe</c> action deletes a subscription. If the subscription requires authentication for deletion, only the owner of the /// subscription or the topic's owner can unsubscribe, and an AWS signature is required. If the <c>Unsubscribe</c> call does not require /// authentication and the requester is not the subscription owner, a final cancellation message is delivered to the endpoint, so that the /// endpoint owner can easily resubscribe to the topic if the <c>Unsubscribe</c> request was unintended.</para> /// </summary> /// /// <param name="unsubscribeRequest">Container for the necessary parameters to execute the Unsubscribe service method on /// AmazonSimpleNotificationService.</param> /// /// <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<UnsubscribeResponse> UnsubscribeAsync(UnsubscribeRequest unsubscribeRequest, CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new UnsubscribeRequestMarshaller(); var unmarshaller = UnsubscribeResponseUnmarshaller.GetInstance(); var response = await Invoke<IRequest, UnsubscribeRequest, UnsubscribeResponse>(unsubscribeRequest, marshaller, unmarshaller, signer, cancellationToken) .ConfigureAwait(continueOnCapturedContext: false); return response; }
/// <summary> /// Deletes a subscription. If the subscription requires authentication for deletion, /// only the owner of the subscription or the topic's owner can unsubscribe, and /// an AWS signature is required. If the <code>Unsubscribe</code> call does not /// require authentication and the requester is not the subscription owner, a final /// cancellation message is delivered to the endpoint, so that the endpoint owner /// can easily resubscribe to the topic if the <code>Unsubscribe</code> request /// was unintended. /// </summary> /// <param name="subscriptionArn">The ARN of the subscription to be deleted.</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 Unsubscribe 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<UnsubscribeResponse> UnsubscribeAsync(string subscriptionArn, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var request = new UnsubscribeRequest(); request.SubscriptionArn = subscriptionArn; return UnsubscribeAsync(request, cancellationToken); }
/// <summary> /// Initiates the asynchronous execution of the Unsubscribe operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the Unsubscribe 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 UnsubscribeAsync(UnsubscribeRequest request, AmazonServiceCallback<UnsubscribeRequest, UnsubscribeResponse> callback, AsyncOptions options = null) { options = options == null?new AsyncOptions():options; var marshaller = new UnsubscribeRequestMarshaller(); var unmarshaller = UnsubscribeResponseUnmarshaller.Instance; Action<AmazonWebServiceRequest, AmazonWebServiceResponse, Exception, AsyncOptions> callbackHelper = null; if(callback !=null ) callbackHelper = (AmazonWebServiceRequest req, AmazonWebServiceResponse res, Exception ex, AsyncOptions ao) => { AmazonServiceResult<UnsubscribeRequest,UnsubscribeResponse> responseObject = new AmazonServiceResult<UnsubscribeRequest,UnsubscribeResponse>((UnsubscribeRequest)req, (UnsubscribeResponse)res, ex , ao.State); callback(responseObject); }; BeginInvoke<UnsubscribeRequest>(request, marshaller, unmarshaller, options, callbackHelper); }
/// <summary> /// Deletes a subscription. If the subscription requires authentication for deletion, /// only the owner of the subscription or the topic's owner can unsubscribe, and an AWS /// signature is required. If the <code>Unsubscribe</code> call does not require authentication /// and the requester is not the subscription owner, a final cancellation message is delivered /// to the endpoint, so that the endpoint owner can easily resubscribe to the topic if /// the <code>Unsubscribe</code> request was unintended. /// </summary> /// <param name="subscriptionArn">The ARN of the subscription to be deleted.</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 Unsubscribe 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 UnsubscribeAsync(string subscriptionArn, AmazonServiceCallback<UnsubscribeRequest, UnsubscribeResponse> callback, AsyncOptions options = null) { var request = new UnsubscribeRequest(); request.SubscriptionArn = subscriptionArn; UnsubscribeAsync(request, callback, options); }
public static void SNSUnsubscribe() { #region SNSUnsubscribe var snsClient = new AmazonSimpleNotificationServiceClient(); var request = new UnsubscribeRequest(); request.SubscriptionArn = "arn:aws:sns:us-east-1:80398EXAMPLE:CodingTestResults:" + "2f5671ba-c68e-4231-a94a-e82d3EXAMPLE"; snsClient.Unsubscribe(request); #endregion }
/// <summary> /// Deletes a subscription. If the subscription requires authentication for deletion, /// only the owner of the subscription or the topic's owner can unsubscribe, and /// an AWS signature is required. If the <code>Unsubscribe</code> call does not /// require authentication and the requester is not the subscription owner, a final /// cancellation message is delivered to the endpoint, so that the endpoint owner /// can easily resubscribe to the topic if the <code>Unsubscribe</code> request /// was unintended. /// </summary> /// <param name="request">Container for the necessary parameters to execute the Unsubscribe service method.</param> /// /// <returns>The response from the Unsubscribe 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 UnsubscribeResponse Unsubscribe(UnsubscribeRequest request) { var marshaller = new UnsubscribeRequestMarshaller(); var unmarshaller = UnsubscribeResponseUnmarshaller.Instance; return Invoke<UnsubscribeRequest,UnsubscribeResponse>(request, marshaller, unmarshaller); }
/// <summary> /// Initiates the asynchronous execution of the Unsubscribe operation. /// <seealso cref="Amazon.SimpleNotificationService.IAmazonSimpleNotificationService.Unsubscribe"/> /// </summary> /// /// <param name="unsubscribeRequest">Container for the necessary parameters to execute the Unsubscribe 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> public IAsyncResult BeginUnsubscribe(UnsubscribeRequest unsubscribeRequest, AsyncCallback callback, object state) { return invokeUnsubscribe(unsubscribeRequest, callback, state, false); }
/// <summary> /// Initiates the asynchronous execution of the Unsubscribe operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the Unsubscribe 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 EndUnsubscribe /// operation.</returns> public IAsyncResult BeginUnsubscribe(UnsubscribeRequest request, AsyncCallback callback, object state) { var marshaller = new UnsubscribeRequestMarshaller(); var unmarshaller = UnsubscribeResponseUnmarshaller.Instance; return BeginInvoke<UnsubscribeRequest>(request, marshaller, unmarshaller, callback, state); }
IAsyncResult invokeUnsubscribe(UnsubscribeRequest unsubscribeRequest, AsyncCallback callback, object state, bool synchronized) { IRequest irequest = new UnsubscribeRequestMarshaller().Marshall(unsubscribeRequest); var unmarshaller = UnsubscribeResponseUnmarshaller.GetInstance(); AsyncResult result = new AsyncResult(irequest, callback, state, synchronized, signer, unmarshaller); Invoke(result); return result; }
/// <summary> /// Initiates the asynchronous execution of the Unsubscribe operation. /// <seealso cref="Amazon.SimpleNotificationService.IAmazonSimpleNotificationService.Unsubscribe"/> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the Unsubscribe 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<UnsubscribeResponse> UnsubscribeAsync(UnsubscribeRequest request, CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new UnsubscribeRequestMarshaller(); var unmarshaller = UnsubscribeResponseUnmarshaller.GetInstance(); return Invoke<IRequest, UnsubscribeRequest, UnsubscribeResponse>(request, marshaller, unmarshaller, signer, cancellationToken); }
/// <summary> /// Unsubscribe from a SNS Topic /// </summary> /// <param name="subscriptionArn"></param> public void Unsubscribe(string subscriptionArn) { var request = new UnsubscribeRequest {SubscriptionArn = subscriptionArn}; Client.Unsubscribe(request); }
private Amazon.SimpleNotificationService.Model.UnsubscribeResponse CallAWSServiceOperation(IAmazonSimpleNotificationService client, Amazon.SimpleNotificationService.Model.UnsubscribeRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Simple Notification Service (SNS)", "Unsubscribe"); try { #if DESKTOP return(client.Unsubscribe(request)); #elif CORECLR return(client.UnsubscribeAsync(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 invokeUnsubscribe(UnsubscribeRequest request, AsyncCallback callback, object state, bool synchronized) { var marshaller = new UnsubscribeRequestMarshaller(); var unmarshaller = UnsubscribeResponseUnmarshaller.Instance; return Invoke(request, callback, state, synchronized, marshaller, unmarshaller, signer); }