public object Execute(ExecutorContext context) { var cmdletContext = context as CmdletContext; // create request var request = new Amazon.IoT.Model.CreatePolicyVersionRequest(); if (cmdletContext.PolicyDocument != null) { request.PolicyDocument = cmdletContext.PolicyDocument; } if (cmdletContext.PolicyName != null) { request.PolicyName = cmdletContext.PolicyName; } if (cmdletContext.SetAsDefault != null) { request.SetAsDefault = cmdletContext.SetAsDefault.Value; } 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 CreatePolicyVersion operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the CreatePolicyVersion 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<CreatePolicyVersionResponse> CreatePolicyVersionAsync(CreatePolicyVersionRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new CreatePolicyVersionRequestMarshaller(); var unmarshaller = CreatePolicyVersionResponseUnmarshaller.Instance; return InvokeAsync<CreatePolicyVersionRequest,CreatePolicyVersionResponse>(request, marshaller, unmarshaller, cancellationToken); }
/// <summary> /// Creates a new version of the specified AWS IoT policy. To update a policy, create /// a new policy version. A managed policy can have up to five versions. If the policy /// has five versions, you must delete an existing version using <a>DeletePolicyVersion</a> /// before you create a new version. /// /// /// <para> /// Optionally, you can set the new version as the policy's default version. The default /// version is the operative version; that is, the version that is in effect for the certificates /// that the policy is attached to. /// </para> /// </summary> /// <param name="policyName">The policy name.</param> /// <param name="policyDocument">The JSON document that describes the policy. Minimum length of 1. Maximum length of 2048 excluding whitespaces</param> /// <param name="setAsDefault">Specifies whether the policy version is set as the default. When this parameter is true, the new policy version becomes the operative version; that is, the version that is in effect for the certificates that the policy is attached to.</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 CreatePolicyVersion service method, as returned by IoT.</returns> /// <exception cref="Amazon.IoT.Model.InternalFailureException"> /// An unexpected error has occurred. /// </exception> /// <exception cref="Amazon.IoT.Model.InvalidRequestException"> /// The request is not valid. /// </exception> /// <exception cref="Amazon.IoT.Model.MalformedPolicyException"> /// The policy documentation is not valid. /// </exception> /// <exception cref="Amazon.IoT.Model.ResourceNotFoundException"> /// The specified resource does not exist. /// </exception> /// <exception cref="Amazon.IoT.Model.ServiceUnavailableException"> /// The service is temporarily unavailable. /// </exception> /// <exception cref="Amazon.IoT.Model.ThrottlingException"> /// The rate exceeds the limit. /// </exception> /// <exception cref="Amazon.IoT.Model.UnauthorizedException"> /// You are not authorized to perform this operation. /// </exception> /// <exception cref="Amazon.IoT.Model.VersionsLimitExceededException"> /// The number of policy versions exceeds the limit. /// </exception> public Task<CreatePolicyVersionResponse> CreatePolicyVersionAsync(string policyName, string policyDocument, bool setAsDefault, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var request = new CreatePolicyVersionRequest(); request.PolicyName = policyName; request.PolicyDocument = policyDocument; request.SetAsDefault = setAsDefault; return CreatePolicyVersionAsync(request, cancellationToken); }
/// <summary> /// Creates a new version of the specified AWS IoT policy. To update a policy, create /// a new policy version. A managed policy can have up to five versions. If the policy /// has five versions, you must delete an existing version using <a>DeletePolicyVersion</a> /// before you create a new version. /// /// /// <para> /// Optionally, you can set the new version as the policy's default version. The default /// version is the operative version; that is, the version that is in effect for the certificates /// that the policy is attached to. /// </para> /// </summary> /// <param name="request">Container for the necessary parameters to execute the CreatePolicyVersion service method.</param> /// /// <returns>The response from the CreatePolicyVersion service method, as returned by IoT.</returns> /// <exception cref="Amazon.IoT.Model.InternalFailureException"> /// An unexpected error has occurred. /// </exception> /// <exception cref="Amazon.IoT.Model.InvalidRequestException"> /// The request is not valid. /// </exception> /// <exception cref="Amazon.IoT.Model.MalformedPolicyException"> /// The policy documentation is not valid. /// </exception> /// <exception cref="Amazon.IoT.Model.ResourceNotFoundException"> /// The specified resource does not exist. /// </exception> /// <exception cref="Amazon.IoT.Model.ServiceUnavailableException"> /// The service is temporarily unavailable. /// </exception> /// <exception cref="Amazon.IoT.Model.ThrottlingException"> /// The rate exceeds the limit. /// </exception> /// <exception cref="Amazon.IoT.Model.UnauthorizedException"> /// You are not authorized to perform this operation. /// </exception> /// <exception cref="Amazon.IoT.Model.VersionsLimitExceededException"> /// The number of policy versions exceeds the limit. /// </exception> public CreatePolicyVersionResponse CreatePolicyVersion(CreatePolicyVersionRequest request) { var marshaller = new CreatePolicyVersionRequestMarshaller(); var unmarshaller = CreatePolicyVersionResponseUnmarshaller.Instance; return Invoke<CreatePolicyVersionRequest,CreatePolicyVersionResponse>(request, marshaller, unmarshaller); }
/// <summary> /// Creates a new version of the specified AWS IoT policy. To update a policy, create /// a new policy version. A managed policy can have up to five versions. If the policy /// has five versions, you must delete an existing version using <a>DeletePolicyVersion</a> /// before you create a new version. /// /// /// <para> /// Optionally, you can set the new version as the policy's default version. The default /// version is the operative version; that is, the version that is in effect for the certificates /// that the policy is attached to. /// </para> /// </summary> /// <param name="policyName">The policy name.</param> /// <param name="policyDocument">The JSON document that describes the policy. Minimum length of 1. Maximum length of 2048 excluding whitespaces</param> /// <param name="setAsDefault">Specifies whether the policy version is set as the default. When this parameter is true, the new policy version becomes the operative version; that is, the version that is in effect for the certificates that the policy is attached to.</param> /// /// <returns>The response from the CreatePolicyVersion service method, as returned by IoT.</returns> /// <exception cref="Amazon.IoT.Model.InternalFailureException"> /// An unexpected error has occurred. /// </exception> /// <exception cref="Amazon.IoT.Model.InvalidRequestException"> /// The request is not valid. /// </exception> /// <exception cref="Amazon.IoT.Model.MalformedPolicyException"> /// The policy documentation is not valid. /// </exception> /// <exception cref="Amazon.IoT.Model.ResourceNotFoundException"> /// The specified resource does not exist. /// </exception> /// <exception cref="Amazon.IoT.Model.ServiceUnavailableException"> /// The service is temporarily unavailable. /// </exception> /// <exception cref="Amazon.IoT.Model.ThrottlingException"> /// The rate exceeds the limit. /// </exception> /// <exception cref="Amazon.IoT.Model.UnauthorizedException"> /// You are not authorized to perform this operation. /// </exception> /// <exception cref="Amazon.IoT.Model.VersionsLimitExceededException"> /// The number of policy versions exceeds the limit. /// </exception> public CreatePolicyVersionResponse CreatePolicyVersion(string policyName, string policyDocument, bool setAsDefault) { var request = new CreatePolicyVersionRequest(); request.PolicyName = policyName; request.PolicyDocument = policyDocument; request.SetAsDefault = setAsDefault; return CreatePolicyVersion(request); }
/// <summary> /// Creates a new version of the specified AWS IoT policy. To update a policy, create /// a new policy version. A managed policy can have up to five versions. If the policy /// has five versions, you must delete an existing version using <a>DeletePolicyVersion</a> /// before you create a new version. /// /// /// <para> /// Optionally, you can set the new version as the policy's default version. The default /// version is the operative version; that is, the version that is in effect for the certificates /// that the policy is attached to. /// </para> /// </summary> /// <param name="policyName">The policy name.</param> /// <param name="policyDocument">The JSON document that describes the policy. Minimum length of 1. Maximum length of 2048 excluding whitespaces</param> /// /// <returns>The response from the CreatePolicyVersion service method, as returned by IoT.</returns> /// <exception cref="Amazon.IoT.Model.InternalFailureException"> /// An unexpected error has occurred. /// </exception> /// <exception cref="Amazon.IoT.Model.InvalidRequestException"> /// The request is not valid. /// </exception> /// <exception cref="Amazon.IoT.Model.MalformedPolicyException"> /// The policy documentation is not valid. /// </exception> /// <exception cref="Amazon.IoT.Model.ResourceNotFoundException"> /// The specified resource does not exist. /// </exception> /// <exception cref="Amazon.IoT.Model.ServiceUnavailableException"> /// The service is temporarily unavailable. /// </exception> /// <exception cref="Amazon.IoT.Model.ThrottlingException"> /// The rate exceeds the limit. /// </exception> /// <exception cref="Amazon.IoT.Model.UnauthorizedException"> /// You are not authorized to perform this operation. /// </exception> /// <exception cref="Amazon.IoT.Model.VersionsLimitExceededException"> /// The number of policy versions exceeds the limit. /// </exception> public CreatePolicyVersionResponse CreatePolicyVersion(string policyName, string policyDocument) { var request = new CreatePolicyVersionRequest(); request.PolicyName = policyName; request.PolicyDocument = policyDocument; return CreatePolicyVersion(request); }
/// <summary> /// Initiates the asynchronous execution of the CreatePolicyVersion operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the CreatePolicyVersion operation on AmazonIoTClient.</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 EndCreatePolicyVersion /// operation.</returns> public IAsyncResult BeginCreatePolicyVersion(CreatePolicyVersionRequest request, AsyncCallback callback, object state) { var marshaller = new CreatePolicyVersionRequestMarshaller(); var unmarshaller = CreatePolicyVersionResponseUnmarshaller.Instance; return BeginInvoke<CreatePolicyVersionRequest>(request, marshaller, unmarshaller, callback, state); }
private Amazon.IoT.Model.CreatePolicyVersionResponse CallAWSServiceOperation(IAmazonIoT client, Amazon.IoT.Model.CreatePolicyVersionRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS IoT", "CreatePolicyVersion"); try { #if DESKTOP return(client.CreatePolicyVersion(request)); #elif CORECLR return(client.CreatePolicyVersionAsync(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; } }