Container for the parameters to the DeletePolicy operation. Deletes the specified policy.

A policy cannot be deleted if it has non-default versions or it is attached to any certificate.

To delete a policy, use the DeletePolicyVersion API to delete all non-default versions of the policy; use the DetachPrincipalPolicy API to detach the policy from any certificate; and then use the DeletePolicy API to delete the policy.

When a policy is deleted using DeletePolicy, its default version is deleted with it.

Inheritance: AmazonIoTRequest
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.IoT.Model.DeletePolicyRequest();

            if (cmdletContext.PolicyName != null)
            {
                request.PolicyName = cmdletContext.PolicyName;
            }

            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);
        }
Exemple #2
0
        /// <summary>
        /// Initiates the asynchronous execution of the DeletePolicy operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the DeletePolicy 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<DeletePolicyResponse> DeletePolicyAsync(DeletePolicyRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new DeletePolicyRequestMarshaller();
            var unmarshaller = DeletePolicyResponseUnmarshaller.Instance;

            return InvokeAsync<DeletePolicyRequest,DeletePolicyResponse>(request, marshaller, 
                unmarshaller, cancellationToken);
        }
Exemple #3
0
 /// <summary>
 /// Deletes the specified policy.
 /// 
 ///  
 /// <para>
 /// A policy cannot be deleted if it has non-default versions and/or it is attached to
 /// any certificate.
 /// </para>
 ///  
 /// <para>
 /// To delete a policy, delete all non-default versions of the policy using the DeletePolicyVersion
 /// API, detach the policy from any certificate using the DetachPrincipalPolicy API, and
 /// then use the DeletePolicy API to delete the policy.
 /// </para>
 ///  
 /// <para>
 /// When a policy is deleted using DeletePolicy, its default version is deleted with it.
 /// </para>
 /// </summary>
 /// <param name="policyName">The name of the policy to delete.</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 DeletePolicy service method, as returned by IoT.</returns>
 /// <exception cref="Amazon.IoT.Model.DeleteConflictException">
 /// You can't delete the resource because it is attached to one or more resources.
 /// </exception>
 /// <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.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>
 public Task<DeletePolicyResponse> DeletePolicyAsync(string policyName, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
 {
     var request = new DeletePolicyRequest();
     request.PolicyName = policyName;
     return DeletePolicyAsync(request, cancellationToken);
 }
Exemple #4
0
        /// <summary>
        /// Deletes the specified policy.
        /// 
        ///  
        /// <para>
        /// A policy cannot be deleted if it has non-default versions and/or it is attached to
        /// any certificate.
        /// </para>
        ///  
        /// <para>
        /// To delete a policy, delete all non-default versions of the policy using the DeletePolicyVersion
        /// API, detach the policy from any certificate using the DetachPrincipalPolicy API, and
        /// then use the DeletePolicy API to delete the policy.
        /// </para>
        ///  
        /// <para>
        /// When a policy is deleted using DeletePolicy, its default version is deleted with it.
        /// </para>
        /// </summary>
        /// <param name="request">Container for the necessary parameters to execute the DeletePolicy service method.</param>
        /// 
        /// <returns>The response from the DeletePolicy service method, as returned by IoT.</returns>
        /// <exception cref="Amazon.IoT.Model.DeleteConflictException">
        /// You can't delete the resource because it is attached to one or more resources.
        /// </exception>
        /// <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.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>
        public DeletePolicyResponse DeletePolicy(DeletePolicyRequest request)
        {
            var marshaller = new DeletePolicyRequestMarshaller();
            var unmarshaller = DeletePolicyResponseUnmarshaller.Instance;

            return Invoke<DeletePolicyRequest,DeletePolicyResponse>(request, marshaller, unmarshaller);
        }
Exemple #5
0
 /// <summary>
 /// Deletes the specified policy.
 /// 
 ///  
 /// <para>
 /// A policy cannot be deleted if it has non-default versions and/or it is attached to
 /// any certificate.
 /// </para>
 ///  
 /// <para>
 /// To delete a policy, delete all non-default versions of the policy using the DeletePolicyVersion
 /// API, detach the policy from any certificate using the DetachPrincipalPolicy API, and
 /// then use the DeletePolicy API to delete the policy.
 /// </para>
 ///  
 /// <para>
 /// When a policy is deleted using DeletePolicy, its default version is deleted with it.
 /// </para>
 /// </summary>
 /// <param name="policyName">The name of the policy to delete.</param>
 /// 
 /// <returns>The response from the DeletePolicy service method, as returned by IoT.</returns>
 /// <exception cref="Amazon.IoT.Model.DeleteConflictException">
 /// You can't delete the resource because it is attached to one or more resources.
 /// </exception>
 /// <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.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>
 public DeletePolicyResponse DeletePolicy(string policyName)
 {
     var request = new DeletePolicyRequest();
     request.PolicyName = policyName;
     return DeletePolicy(request);
 }
        /// <summary>
        /// Initiates the asynchronous execution of the DeletePolicy operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the DeletePolicy 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 EndDeletePolicy
        ///         operation.</returns>
        public IAsyncResult BeginDeletePolicy(DeletePolicyRequest request, AsyncCallback callback, object state)
        {
            var marshaller = new DeletePolicyRequestMarshaller();
            var unmarshaller = DeletePolicyResponseUnmarshaller.Instance;

            return BeginInvoke<DeletePolicyRequest>(request, marshaller, unmarshaller,
                callback, state);
        }
 private Amazon.IoT.Model.DeletePolicyResponse CallAWSServiceOperation(IAmazonIoT client, Amazon.IoT.Model.DeletePolicyRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS IoT", "DeletePolicy");
     try
     {
         #if DESKTOP
         return(client.DeletePolicy(request));
         #elif CORECLR
         return(client.DeletePolicyAsync(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;
     }
 }