Skip to content

reset_image_attribute

reset_image_attribute(
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    attribute: Optional[ResetImageAttributeName] = None,
    image_id: Optional[ImageId] = None,
    dry_run: Optional[Boolean] = None,
) -> None

Resets an attribute of an AMI to its default value.

Parameters:

  • attribute (Optional[ResetImageAttributeName], default: None ) –

    The attribute to reset (currently you can only reset the launch permission attribute).

  • image_id (Optional[ImageId], default: None ) –

    The ID of the AMI.

  • dry_run (Optional[Boolean], default: None ) –

    Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.

Raises:

Examples:

To reset the launchPermission attribute This example resets the launchPermission attribute for the specified AMI. By default, AMIs are private.

>>> client.reset_image_attribute(attribute='launchPermission', image_id='ami-5731123e')
Source code in docs_src/capo_ec2/_services/ec2.py
def reset_image_attribute(
    self,
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    attribute: Optional[
        "capo_ec2.types.reset_image_attribute_name.ResetImageAttributeName"
    ] = None,
    image_id: Optional["capo_ec2.types.image_id.ImageId"] = None,
    dry_run: Optional["capo_ec2.types.boolean.Boolean"] = None,
) -> None:
    """<p>Resets an attribute of an AMI to its default value.</p>

    Args:
        attribute: <p>The attribute to reset (currently you can only reset the launch permission attribute).</p>
        image_id: <p>The ID of the AMI.</p>
        dry_run: <p>Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is <code>DryRunOperation</code>. Otherwise, it is <code>UnauthorizedOperation</code>.</p>

    Raises:
        capo_ec2.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To reset the launchPermission attribute
        This example resets the launchPermission attribute for the specified AMI. By default, AMIs are private.

        >>> client.reset_image_attribute(attribute='launchPermission', image_id='ami-5731123e')
    """

    def _handler(
        req: "OperationRequest[capo_ec2.types.reset_image_attribute_request.ResetImageAttributeRequest]",
    ) -> OperationResponse[None]:
        import capo_ec2._operations.amazon_ec2.reset_image_attribute

        output, http_response = (
            capo_ec2._operations.amazon_ec2.reset_image_attribute.reset_image_attribute(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("ResetImageAttribute")
    )
    input_: capo_ec2.types.reset_image_attribute_request.ResetImageAttributeRequest = {}
    if attribute is not None:
        input_["attribute"] = attribute
    if image_id is not None:
        input_["image_id"] = image_id
    if dry_run is not None:
        input_["dry_run"] = dry_run

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output