/// <summary> /// Adds permission to the Topic for Aws Accounts to performe the actions named. /// </summary> /// <param name="actionNames"></param> /// <param name="awsAccountIds"></param> /// <param name="label"></param> /// <param name="topicArn"></param> public void AddPermission(IEnumerable<string> actionNames, IEnumerable<string> awsAccountIds, string label, string topicArn) { var request = new AddPermissionRequest { ActionNames = new List<string>(actionNames), AWSAccountIds = new List<string>(awsAccountIds), Label = label, TopicArn = topicArn }; // NB: As of version 1.0.8.1 of AWS SDK there appears to be a problem with action names and aws account Id's // validations and these fail whilst apparently having valid values. Client.AddPermission(request); }
public object Execute(ExecutorContext context) { var cmdletContext = context as CmdletContext; // create request var request = new Amazon.SimpleNotificationService.Model.AddPermissionRequest(); if (cmdletContext.ActionName != null) { request.ActionName = cmdletContext.ActionName; } if (cmdletContext.AWSAccountId != null) { request.AWSAccountId = cmdletContext.AWSAccountId; } if (cmdletContext.Label != null) { request.Label = cmdletContext.Label; } 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); }
/// <summary> /// Adds a statement to a topic's access control policy, granting access for the specified /// AWS accounts to the specified actions. /// </summary> /// <param name="topicArn">The ARN of the topic whose access control policy you wish to modify.</param> /// <param name="label">A unique identifier for the new policy statement.</param> /// <param name="awsAccountId">The AWS account IDs of the users (principals) who will be given access to the specified actions. The users must have AWS accounts, but do not need to be signed up for this service. </param> /// <param name="actionName">The action you want to allow for the specified principal(s). Valid values: any Amazon SNS action name.</param> /// /// <returns>The response from the AddPermission 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 AddPermissionResponse AddPermission(string topicArn, string label, List<string> awsAccountId, List<string> actionName) { var request = new AddPermissionRequest(); request.TopicArn = topicArn; request.Label = label; request.AWSAccountId = awsAccountId; request.ActionName = actionName; return AddPermission(request); }
/// <summary> /// <para>The <c>AddPermission</c> action adds a statement to a topic's access control policy, granting access for the specified AWS accounts to /// the specified actions.</para> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the AddPermission 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 AddPermissionResponse AddPermission(AddPermissionRequest request) { var task = AddPermissionAsync(request); try { return task.Result; } catch(AggregateException e) { ExceptionDispatchInfo.Capture(e.InnerException).Throw(); return null; } }
/// <summary> /// Initiates the asynchronous execution of the AddPermission operation. /// <seealso cref="Amazon.SimpleNotificationService.IAmazonSimpleNotificationService"/> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the AddPermission 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<AddPermissionResponse> AddPermissionAsync(AddPermissionRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new AddPermissionRequestMarshaller(); var unmarshaller = AddPermissionResponseUnmarshaller.Instance; return InvokeAsync<AddPermissionRequest,AddPermissionResponse>(request, marshaller, unmarshaller, cancellationToken); }
private Amazon.SimpleNotificationService.Model.AddPermissionResponse CallAWSServiceOperation(IAmazonSimpleNotificationService client, Amazon.SimpleNotificationService.Model.AddPermissionRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Simple Notification Service (SNS)", "AddPermission"); try { #if DESKTOP return(client.AddPermission(request)); #elif CORECLR return(client.AddPermissionAsync(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; } }
public static void SNSAddPermission() { #region SNSAddPermission var snsClient = new AmazonSimpleNotificationServiceClient(); var request = new AddPermissionRequest { TopicArn = "arn:aws:sns:us-east-1:80398EXAMPLE:CodingTestResults", ActionName = new List<string>() { "Subscribe" }, AWSAccountId = new List<string>() { "80398EXAMPLE" }, Label = "SubscribePolicy" }; snsClient.AddPermission(request); #endregion }
/// <summary> /// <para>The <c>AddPermission</c> action adds a statement to a topic's access control policy, granting access for the specified AWS accounts to /// the specified actions.</para> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the AddPermission 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 AddPermissionResponse AddPermission(AddPermissionRequest request) { var task = AddPermissionAsync(request); try { return task.Result; } catch(AggregateException e) { throw e.InnerException; } }
/// <summary> /// Initiates the asynchronous execution of the AddPermission operation. /// <seealso cref="Amazon.SimpleNotificationService.IAmazonSimpleNotificationService.AddPermission"/> /// </summary> /// /// <param name="addPermissionRequest">Container for the necessary parameters to execute the AddPermission 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 BeginAddPermission(AddPermissionRequest addPermissionRequest, AsyncCallback callback, object state) { return invokeAddPermission(addPermissionRequest, callback, state, false); }
/// <summary> /// <para>The <c>AddPermission</c> action adds a statement to a topic's access control policy, granting access for the specified AWS accounts to /// the specified actions.</para> /// </summary> /// /// <param name="addPermissionRequest">Container for the necessary parameters to execute the AddPermission service method on /// AmazonSimpleNotificationService.</param> /// /// <exception cref="NotFoundException"/> /// <exception cref="AuthorizationErrorException"/> /// <exception cref="InternalErrorException"/> /// <exception cref="InvalidParameterException"/> public AddPermissionResponse AddPermission(AddPermissionRequest addPermissionRequest) { IAsyncResult asyncResult = invokeAddPermission(addPermissionRequest, null, null, true); return EndAddPermission(asyncResult); }
/// <summary> /// <para>The <c>AddPermission</c> action adds a statement to a topic's access control policy, granting access for the specified AWS accounts to /// the specified actions.</para> /// </summary> /// /// <param name="addPermissionRequest">Container for the necessary parameters to execute the AddPermission 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<AddPermissionResponse> AddPermissionAsync(AddPermissionRequest addPermissionRequest, CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new AddPermissionRequestMarshaller(); var unmarshaller = AddPermissionResponseUnmarshaller.GetInstance(); var response = await Invoke<IRequest, AddPermissionRequest, AddPermissionResponse>(addPermissionRequest, marshaller, unmarshaller, signer, cancellationToken) .ConfigureAwait(continueOnCapturedContext: false); return response; }
/// <summary> /// Adds a statement to a topic's access control policy, granting access for the specified /// AWS accounts to the specified actions. /// </summary> /// <param name="topicArn">The ARN of the topic whose access control policy you wish to modify.</param> /// <param name="label">A unique identifier for the new policy statement.</param> /// <param name="awsAccountId">The AWS account IDs of the users (principals) who will be given access to the specified actions. The users must have AWS accounts, but do not need to be signed up for this service. </param> /// <param name="actionName">The action you want to allow for the specified principal(s). Valid values: any Amazon SNS action name.</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 AddPermission 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<AddPermissionResponse> AddPermissionAsync(string topicArn, string label, List<string> awsAccountId, List<string> actionName, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var request = new AddPermissionRequest(); request.TopicArn = topicArn; request.Label = label; request.AWSAccountId = awsAccountId; request.ActionName = actionName; return AddPermissionAsync(request, cancellationToken); }
/// <summary> /// Initiates the asynchronous execution of the AddPermission operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the AddPermission 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 AddPermissionAsync(AddPermissionRequest request, AmazonServiceCallback<AddPermissionRequest, AddPermissionResponse> callback, AsyncOptions options = null) { options = options == null?new AsyncOptions():options; var marshaller = new AddPermissionRequestMarshaller(); var unmarshaller = AddPermissionResponseUnmarshaller.Instance; Action<AmazonWebServiceRequest, AmazonWebServiceResponse, Exception, AsyncOptions> callbackHelper = null; if(callback !=null ) callbackHelper = (AmazonWebServiceRequest req, AmazonWebServiceResponse res, Exception ex, AsyncOptions ao) => { AmazonServiceResult<AddPermissionRequest,AddPermissionResponse> responseObject = new AmazonServiceResult<AddPermissionRequest,AddPermissionResponse>((AddPermissionRequest)req, (AddPermissionResponse)res, ex , ao.State); callback(responseObject); }; BeginInvoke<AddPermissionRequest>(request, marshaller, unmarshaller, options, callbackHelper); }
/// <summary> /// Adds a statement to a topic's access control policy, granting access for the specified /// AWS accounts to the specified actions. /// </summary> /// <param name="topicArn">The ARN of the topic whose access control policy you wish to modify.</param> /// <param name="label">A unique identifier for the new policy statement.</param> /// <param name="awsAccountId">The AWS account IDs of the users (principals) who will be given access to the specified actions. The users must have AWS accounts, but do not need to be signed up for this service.</param> /// <param name="actionName">The action you want to allow for the specified principal(s). Valid values: any Amazon SNS action name.</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 AddPermission 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 AddPermissionAsync(string topicArn, string label, List<string> awsAccountId, List<string> actionName, AmazonServiceCallback<AddPermissionRequest, AddPermissionResponse> callback, AsyncOptions options = null) { var request = new AddPermissionRequest(); request.TopicArn = topicArn; request.Label = label; request.AWSAccountId = awsAccountId; request.ActionName = actionName; AddPermissionAsync(request, callback, options); }
/// <summary> /// Adds a statement to a topic's access control policy, granting access for the specified /// AWS accounts to the specified actions. /// </summary> /// <param name="request">Container for the necessary parameters to execute the AddPermission service method.</param> /// /// <returns>The response from the AddPermission 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 AddPermissionResponse AddPermission(AddPermissionRequest request) { var marshaller = new AddPermissionRequestMarshaller(); var unmarshaller = AddPermissionResponseUnmarshaller.Instance; return Invoke<AddPermissionRequest,AddPermissionResponse>(request, marshaller, unmarshaller); }
/// <summary> /// Initiates the asynchronous execution of the AddPermission operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the AddPermission 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 EndAddPermission /// operation.</returns> public IAsyncResult BeginAddPermission(AddPermissionRequest request, AsyncCallback callback, object state) { var marshaller = new AddPermissionRequestMarshaller(); var unmarshaller = AddPermissionResponseUnmarshaller.Instance; return BeginInvoke<AddPermissionRequest>(request, marshaller, unmarshaller, callback, state); }
IAsyncResult invokeAddPermission(AddPermissionRequest addPermissionRequest, AsyncCallback callback, object state, bool synchronized) { IRequest irequest = new AddPermissionRequestMarshaller().Marshall(addPermissionRequest); var unmarshaller = AddPermissionResponseUnmarshaller.GetInstance(); AsyncResult result = new AsyncResult(irequest, callback, state, synchronized, signer, unmarshaller); Invoke(result); return result; }
/// <summary> /// Initiates the asynchronous execution of the AddPermission operation. /// <seealso cref="Amazon.SimpleNotificationService.IAmazonSimpleNotificationService.AddPermission"/> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the AddPermission 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<AddPermissionResponse> AddPermissionAsync(AddPermissionRequest request, CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new AddPermissionRequestMarshaller(); var unmarshaller = AddPermissionResponseUnmarshaller.GetInstance(); return Invoke<IRequest, AddPermissionRequest, AddPermissionResponse>(request, marshaller, unmarshaller, signer, cancellationToken); }
IAsyncResult invokeAddPermission(AddPermissionRequest request, AsyncCallback callback, object state, bool synchronized) { var marshaller = new AddPermissionRequestMarshaller(); var unmarshaller = AddPermissionResponseUnmarshaller.Instance; return Invoke(request, callback, state, synchronized, marshaller, unmarshaller, signer); }