private static void AddPolicy() { var client = new AmazonIdentityManagementServiceClient(); var policyRequest = new PutUserPolicyRequest { UserName = "******", PolicyName = "EC2Policy", PolicyDocument = "{\"Version\": \"2012-10-17\",\"Statement\": [ {\"Sid\": \"Stmt1453760589829\",\"Action\": [\"ec2:DescribeInstances\"],\"Effect\": \"Allow\",\"Resource\":\"*\"}]}" }; var policyResponse = client.PutUserPolicy(policyRequest); Console.WriteLine("Policy Added"); }
public object Execute(ExecutorContext context) { var cmdletContext = context as CmdletContext; // create request var request = new Amazon.IdentityManagement.Model.PutUserPolicyRequest(); if (cmdletContext.PolicyDocument != null) { request.PolicyDocument = cmdletContext.PolicyDocument; } if (cmdletContext.PolicyName != null) { request.PolicyName = cmdletContext.PolicyName; } if (cmdletContext.UserName != null) { request.UserName = cmdletContext.UserName; } 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> /// Initiates the asynchronous execution of the PutUserPolicy operation. /// <seealso cref="Amazon.IdentityManagement.IAmazonIdentityManagementService"/> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the PutUserPolicy 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<PutUserPolicyResponse> PutUserPolicyAsync(PutUserPolicyRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new PutUserPolicyRequestMarshaller(); var unmarshaller = PutUserPolicyResponseUnmarshaller.Instance; return InvokeAsync<PutUserPolicyRequest,PutUserPolicyResponse>(request, marshaller, unmarshaller, cancellationToken); }
internal PutUserPolicyResponse PutUserPolicy(PutUserPolicyRequest request) { var marshaller = new PutUserPolicyRequestMarshaller(); var unmarshaller = PutUserPolicyResponseUnmarshaller.Instance; return Invoke<PutUserPolicyRequest,PutUserPolicyResponse>(request, marshaller, unmarshaller); }
IAsyncResult invokePutUserPolicy(PutUserPolicyRequest putUserPolicyRequest, AsyncCallback callback, object state, bool synchronized) { IRequest irequest = new PutUserPolicyRequestMarshaller().Marshall(putUserPolicyRequest); var unmarshaller = PutUserPolicyResponseUnmarshaller.GetInstance(); AsyncResult result = new AsyncResult(irequest, callback, state, synchronized, signer, unmarshaller); Invoke(result); return result; }
/// <summary> /// <para>Adds (or updates) a policy document associated with the specified user. For information about policies, refer to Overview of Policies /// in <i>Using AWS Identity and Access Management</i> .</para> <para>For information about limits on the number of policies you can associate /// with a user, see Limitations on IAM Entities in <i>Using AWS Identity and Access Management</i> .</para> <para><b>NOTE:</b>Because policy /// documents can be large, you should use POST rather than GET when calling PutUserPolicy. For information about setting up signatures and /// authorization through the API, go to Signing AWS API Requests in the AWS General Reference. For general information about using the Query /// API with IAM, go to Making Query Requests in Using IAM.</para> /// </summary> /// /// <param name="putUserPolicyRequest">Container for the necessary parameters to execute the PutUserPolicy service method on /// AmazonIdentityManagementService.</param> /// /// <exception cref="MalformedPolicyDocumentException"/> /// <exception cref="NoSuchEntityException"/> /// <exception cref="LimitExceededException"/> public PutUserPolicyResponse PutUserPolicy(PutUserPolicyRequest putUserPolicyRequest) { IAsyncResult asyncResult = invokePutUserPolicy(putUserPolicyRequest, null, null, true); return EndPutUserPolicy(asyncResult); }
/// <summary> /// Initiates the asynchronous execution of the PutUserPolicy operation. /// <seealso cref="Amazon.IdentityManagement.AmazonIdentityManagementService.PutUserPolicy"/> /// </summary> /// /// <param name="putUserPolicyRequest">Container for the necessary parameters to execute the PutUserPolicy operation on /// AmazonIdentityManagementService.</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 BeginPutUserPolicy(PutUserPolicyRequest putUserPolicyRequest, AsyncCallback callback, object state) { return invokePutUserPolicy(putUserPolicyRequest, callback, state, false); }
/// <summary> /// Initiates the asynchronous execution of the PutUserPolicy operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the PutUserPolicy operation on AmazonIdentityManagementServiceClient.</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 EndPutUserPolicy /// operation.</returns> public IAsyncResult BeginPutUserPolicy(PutUserPolicyRequest request, AsyncCallback callback, object state) { var marshaller = new PutUserPolicyRequestMarshaller(); var unmarshaller = PutUserPolicyResponseUnmarshaller.Instance; return BeginInvoke<PutUserPolicyRequest>(request, marshaller, unmarshaller, callback, state); }
private Amazon.IdentityManagement.Model.PutUserPolicyResponse CallAWSServiceOperation(IAmazonIdentityManagementService client, Amazon.IdentityManagement.Model.PutUserPolicyRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS Identity and Access Management", "PutUserPolicy"); try { #if DESKTOP return(client.PutUserPolicy(request)); #elif CORECLR return(client.PutUserPolicyAsync(request).GetAwaiter().GetResult()); #else #error "Unknown build edition" #endif } catch (AmazonServiceException exc) { var webException = exc.InnerException as System.Net.WebException; if (webException != null) { throw new Exception(Utils.Common.FormatNameResolutionFailureMessage(client.Config, webException.Message), webException); } throw; } }
/// <summary> /// <para>Adds (or updates) a policy document associated with the /// specified User. For information about how to write a policy, refer to /// Using AWS Identity and Access Management.</para> <para>For information /// about limits on the number of policies you can associate with a User, /// see Limitations on IAM Entities in Using AWS Identity and Access /// Management.</para> <para><b>NOTE:</b>Because policy documents can be /// large, you should use POST rather than GET when calling PutUserPolicy. /// For more information, see Using the Query API in Using AWS Identity /// and Access Management.</para> /// </summary> /// /// <param name="putUserPolicyRequest">Container for the necessary /// parameters to execute the PutUserPolicy service method on /// AmazonIdentityManagementService.</param> /// /// <exception cref="MalformedPolicyDocumentException"/> /// <exception cref="NoSuchEntityException"/> /// <exception cref="LimitExceededException"/> public PutUserPolicyResponse PutUserPolicy(PutUserPolicyRequest putUserPolicyRequest) { IRequest<PutUserPolicyRequest> request = new PutUserPolicyRequestMarshaller().Marshall(putUserPolicyRequest); PutUserPolicyResponse response = Invoke<PutUserPolicyRequest, PutUserPolicyResponse> (request, this.signer, PutUserPolicyResponseUnmarshaller.GetInstance()); return response; }
/// <summary> /// Initiates the asynchronous execution of the PutUserPolicy operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the PutUserPolicy operation on AmazonIdentityManagementServiceClient.</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 PutUserPolicyAsync(PutUserPolicyRequest request, AmazonServiceCallback<PutUserPolicyRequest, PutUserPolicyResponse> callback, AsyncOptions options = null) { options = options == null?new AsyncOptions():options; var marshaller = new PutUserPolicyRequestMarshaller(); var unmarshaller = PutUserPolicyResponseUnmarshaller.Instance; Action<AmazonWebServiceRequest, AmazonWebServiceResponse, Exception, AsyncOptions> callbackHelper = null; if(callback !=null ) callbackHelper = (AmazonWebServiceRequest req, AmazonWebServiceResponse res, Exception ex, AsyncOptions ao) => { AmazonServiceResult<PutUserPolicyRequest,PutUserPolicyResponse> responseObject = new AmazonServiceResult<PutUserPolicyRequest,PutUserPolicyResponse>((PutUserPolicyRequest)req, (PutUserPolicyResponse)res, ex , ao.State); callback(responseObject); }; BeginInvoke<PutUserPolicyRequest>(request, marshaller, unmarshaller, options, callbackHelper); }
/// <summary> /// Initiates the asynchronous execution of the PutUserPolicy operation. /// <seealso cref="Amazon.IdentityManagement.IAmazonIdentityManagementService.PutUserPolicy"/> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the PutUserPolicy 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 async Task<PutUserPolicyResponse> PutUserPolicyAsync(PutUserPolicyRequest request, CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new PutUserPolicyRequestMarshaller(); var unmarshaller = PutUserPolicyResponseUnmarshaller.GetInstance(); var response = await Invoke<IRequest, PutUserPolicyRequest, PutUserPolicyResponse>(request, marshaller, unmarshaller, signer, cancellationToken) .ConfigureAwait(continueOnCapturedContext: false); return response; }
/// <summary> /// <para>Adds (or updates) a policy document associated with the specified user. For information about policies, refer to <a href="http://docs.aws.amazon.com/IAM/latest/UserGuide/index.html?PoliciesOverview.html">Overview of Policies</a> in <i>Using AWS Identity /// and Access Management</i> .</para> <para>For information about limits on the number of policies you can associate with a user, see <a href="http://docs.aws.amazon.com/IAM/latest/UserGuide/index.html?LimitationsOnEntities.html">Limitations on IAM Entities</a> in <i>Using /// AWS Identity and Access Management</i> .</para> <para><b>NOTE:</b>Because policy documents can be large, you should use POST rather than GET /// when calling PutUserPolicy. For information about setting up signatures and authorization through the API, go to Signing AWS API Requests in /// the AWS General Reference. For general information about using the Query API with IAM, go to Making Query Requests in Using IAM.</para> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the PutUserPolicy service method on /// AmazonIdentityManagementService.</param> /// /// <exception cref="T:Amazon.IdentityManagement.Model.MalformedPolicyDocumentException" /> /// <exception cref="T:Amazon.IdentityManagement.Model.NoSuchEntityException" /> /// <exception cref="T:Amazon.IdentityManagement.Model.LimitExceededException" /> public PutUserPolicyResponse PutUserPolicy(PutUserPolicyRequest request) { var task = PutUserPolicyAsync(request); try { return task.Result; } catch(AggregateException e) { throw e.InnerException; } }
/// <summary> /// <para>Adds (or updates) a policy document associated with the specified user. For information about policies, refer to <a href="http://docs.aws.amazon.com/IAM/latest/UserGuide/index.html?PoliciesOverview.html">Overview of Policies</a> in <i>Using AWS Identity /// and Access Management</i> .</para> <para>For information about limits on the number of policies you can associate with a user, see <a href="http://docs.aws.amazon.com/IAM/latest/UserGuide/index.html?LimitationsOnEntities.html">Limitations on IAM Entities</a> in <i>Using /// AWS Identity and Access Management</i> .</para> <para><b>NOTE:</b>Because policy documents can be large, you should use POST rather than GET /// when calling PutUserPolicy. For information about setting up signatures and authorization through the API, go to Signing AWS API Requests in /// the AWS General Reference. For general information about using the Query API with IAM, go to Making Query Requests in Using IAM.</para> /// </summary> /// /// <param name="putUserPolicyRequest">Container for the necessary parameters to execute the PutUserPolicy service method on /// AmazonIdentityManagementService.</param> /// /// <exception cref="T:Amazon.IdentityManagement.Model.MalformedPolicyDocumentException" /> /// <exception cref="T:Amazon.IdentityManagement.Model.NoSuchEntityException" /> /// <exception cref="T:Amazon.IdentityManagement.Model.LimitExceededException" /> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> public Task<PutUserPolicyResponse> PutUserPolicyAsync(PutUserPolicyRequest putUserPolicyRequest, CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new PutUserPolicyRequestMarshaller(); var unmarshaller = PutUserPolicyResponseUnmarshaller.GetInstance(); return Invoke<IRequest, PutUserPolicyRequest, PutUserPolicyResponse>(putUserPolicyRequest, marshaller, unmarshaller, signer, cancellationToken); }
internal PutUserPolicyResponse PutUserPolicy(PutUserPolicyRequest request) { var task = PutUserPolicyAsync(request); try { return task.Result; } catch(AggregateException e) { ExceptionDispatchInfo.Capture(e.InnerException).Throw(); return null; } }
IAsyncResult invokePutUserPolicy(PutUserPolicyRequest request, AsyncCallback callback, object state, bool synchronized) { var marshaller = new PutUserPolicyRequestMarshaller(); var unmarshaller = PutUserPolicyResponseUnmarshaller.Instance; return Invoke(request, callback, state, synchronized, marshaller, unmarshaller, signer); }