{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.ImageBuilder.DeleteImage
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Deletes an Image Builder image resource. This does not delete any EC2
-- AMIs or ECR container images that are created during the image build
-- process. You must clean those up separately, using the appropriate
-- Amazon EC2 or Amazon ECR console actions, or API or CLI commands.
--
-- -   To deregister an EC2 Linux AMI, see
--     <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/deregister-ami.html Deregister your Linux AMI>
--     in the //Amazon EC2 User Guide// .
--
-- -   To deregister an EC2 Windows AMI, see
--     <https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/deregister-ami.html Deregister your Windows AMI>
--     in the //Amazon EC2 Windows Guide// .
--
-- -   To delete a container image from Amazon ECR, see
--     <https://docs.aws.amazon.com/https:/docs.aws.amazon.comAmazonECR/latest/userguide/delete_image.html Deleting an image>
--     in the /Amazon ECR User Guide/.
module Amazonka.ImageBuilder.DeleteImage
  ( -- * Creating a Request
    DeleteImage (..),
    newDeleteImage,

    -- * Request Lenses
    deleteImage_imageBuildVersionArn,

    -- * Destructuring the Response
    DeleteImageResponse (..),
    newDeleteImageResponse,

    -- * Response Lenses
    deleteImageResponse_requestId,
    deleteImageResponse_imageBuildVersionArn,
    deleteImageResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.ImageBuilder.Types
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newDeleteImage' smart constructor.
data DeleteImage = DeleteImage'
  { -- | The Amazon Resource Name (ARN) of the Image Builder image resource to
    -- delete.
    DeleteImage -> Text
imageBuildVersionArn :: Prelude.Text
  }
  deriving (DeleteImage -> DeleteImage -> Bool
(DeleteImage -> DeleteImage -> Bool)
-> (DeleteImage -> DeleteImage -> Bool) -> Eq DeleteImage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteImage -> DeleteImage -> Bool
$c/= :: DeleteImage -> DeleteImage -> Bool
== :: DeleteImage -> DeleteImage -> Bool
$c== :: DeleteImage -> DeleteImage -> Bool
Prelude.Eq, ReadPrec [DeleteImage]
ReadPrec DeleteImage
Int -> ReadS DeleteImage
ReadS [DeleteImage]
(Int -> ReadS DeleteImage)
-> ReadS [DeleteImage]
-> ReadPrec DeleteImage
-> ReadPrec [DeleteImage]
-> Read DeleteImage
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteImage]
$creadListPrec :: ReadPrec [DeleteImage]
readPrec :: ReadPrec DeleteImage
$creadPrec :: ReadPrec DeleteImage
readList :: ReadS [DeleteImage]
$creadList :: ReadS [DeleteImage]
readsPrec :: Int -> ReadS DeleteImage
$creadsPrec :: Int -> ReadS DeleteImage
Prelude.Read, Int -> DeleteImage -> ShowS
[DeleteImage] -> ShowS
DeleteImage -> String
(Int -> DeleteImage -> ShowS)
-> (DeleteImage -> String)
-> ([DeleteImage] -> ShowS)
-> Show DeleteImage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteImage] -> ShowS
$cshowList :: [DeleteImage] -> ShowS
show :: DeleteImage -> String
$cshow :: DeleteImage -> String
showsPrec :: Int -> DeleteImage -> ShowS
$cshowsPrec :: Int -> DeleteImage -> ShowS
Prelude.Show, (forall x. DeleteImage -> Rep DeleteImage x)
-> (forall x. Rep DeleteImage x -> DeleteImage)
-> Generic DeleteImage
forall x. Rep DeleteImage x -> DeleteImage
forall x. DeleteImage -> Rep DeleteImage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteImage x -> DeleteImage
$cfrom :: forall x. DeleteImage -> Rep DeleteImage x
Prelude.Generic)

-- |
-- Create a value of 'DeleteImage' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'imageBuildVersionArn', 'deleteImage_imageBuildVersionArn' - The Amazon Resource Name (ARN) of the Image Builder image resource to
-- delete.
newDeleteImage ::
  -- | 'imageBuildVersionArn'
  Prelude.Text ->
  DeleteImage
newDeleteImage :: Text -> DeleteImage
newDeleteImage Text
pImageBuildVersionArn_ =
  DeleteImage' :: Text -> DeleteImage
DeleteImage'
    { $sel:imageBuildVersionArn:DeleteImage' :: Text
imageBuildVersionArn =
        Text
pImageBuildVersionArn_
    }

-- | The Amazon Resource Name (ARN) of the Image Builder image resource to
-- delete.
deleteImage_imageBuildVersionArn :: Lens.Lens' DeleteImage Prelude.Text
deleteImage_imageBuildVersionArn :: (Text -> f Text) -> DeleteImage -> f DeleteImage
deleteImage_imageBuildVersionArn = (DeleteImage -> Text)
-> (DeleteImage -> Text -> DeleteImage)
-> Lens DeleteImage DeleteImage Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteImage' {Text
imageBuildVersionArn :: Text
$sel:imageBuildVersionArn:DeleteImage' :: DeleteImage -> Text
imageBuildVersionArn} -> Text
imageBuildVersionArn) (\s :: DeleteImage
s@DeleteImage' {} Text
a -> DeleteImage
s {$sel:imageBuildVersionArn:DeleteImage' :: Text
imageBuildVersionArn = Text
a} :: DeleteImage)

instance Core.AWSRequest DeleteImage where
  type AWSResponse DeleteImage = DeleteImageResponse
  request :: DeleteImage -> Request DeleteImage
request = Service -> DeleteImage -> Request DeleteImage
forall a. ToRequest a => Service -> a -> Request a
Request.delete Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteImage
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteImage)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DeleteImage))
-> Logger
-> Service
-> Proxy DeleteImage
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteImage)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text -> Maybe Text -> Int -> DeleteImageResponse
DeleteImageResponse'
            (Maybe Text -> Maybe Text -> Int -> DeleteImageResponse)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> Int -> DeleteImageResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"requestId")
            Either String (Maybe Text -> Int -> DeleteImageResponse)
-> Either String (Maybe Text)
-> Either String (Int -> DeleteImageResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"imageBuildVersionArn")
            Either String (Int -> DeleteImageResponse)
-> Either String Int -> Either String DeleteImageResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable DeleteImage

instance Prelude.NFData DeleteImage

instance Core.ToHeaders DeleteImage where
  toHeaders :: DeleteImage -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteImage -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToPath DeleteImage where
  toPath :: DeleteImage -> ByteString
toPath = ByteString -> DeleteImage -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/DeleteImage"

instance Core.ToQuery DeleteImage where
  toQuery :: DeleteImage -> QueryString
toQuery DeleteImage' {Text
imageBuildVersionArn :: Text
$sel:imageBuildVersionArn:DeleteImage' :: DeleteImage -> Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"imageBuildVersionArn" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
imageBuildVersionArn]

-- | /See:/ 'newDeleteImageResponse' smart constructor.
data DeleteImageResponse = DeleteImageResponse'
  { -- | The request ID that uniquely identifies this request.
    DeleteImageResponse -> Maybe Text
requestId :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the Image Builder image resource that
    -- was deleted.
    DeleteImageResponse -> Maybe Text
imageBuildVersionArn :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    DeleteImageResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteImageResponse -> DeleteImageResponse -> Bool
(DeleteImageResponse -> DeleteImageResponse -> Bool)
-> (DeleteImageResponse -> DeleteImageResponse -> Bool)
-> Eq DeleteImageResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteImageResponse -> DeleteImageResponse -> Bool
$c/= :: DeleteImageResponse -> DeleteImageResponse -> Bool
== :: DeleteImageResponse -> DeleteImageResponse -> Bool
$c== :: DeleteImageResponse -> DeleteImageResponse -> Bool
Prelude.Eq, ReadPrec [DeleteImageResponse]
ReadPrec DeleteImageResponse
Int -> ReadS DeleteImageResponse
ReadS [DeleteImageResponse]
(Int -> ReadS DeleteImageResponse)
-> ReadS [DeleteImageResponse]
-> ReadPrec DeleteImageResponse
-> ReadPrec [DeleteImageResponse]
-> Read DeleteImageResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteImageResponse]
$creadListPrec :: ReadPrec [DeleteImageResponse]
readPrec :: ReadPrec DeleteImageResponse
$creadPrec :: ReadPrec DeleteImageResponse
readList :: ReadS [DeleteImageResponse]
$creadList :: ReadS [DeleteImageResponse]
readsPrec :: Int -> ReadS DeleteImageResponse
$creadsPrec :: Int -> ReadS DeleteImageResponse
Prelude.Read, Int -> DeleteImageResponse -> ShowS
[DeleteImageResponse] -> ShowS
DeleteImageResponse -> String
(Int -> DeleteImageResponse -> ShowS)
-> (DeleteImageResponse -> String)
-> ([DeleteImageResponse] -> ShowS)
-> Show DeleteImageResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteImageResponse] -> ShowS
$cshowList :: [DeleteImageResponse] -> ShowS
show :: DeleteImageResponse -> String
$cshow :: DeleteImageResponse -> String
showsPrec :: Int -> DeleteImageResponse -> ShowS
$cshowsPrec :: Int -> DeleteImageResponse -> ShowS
Prelude.Show, (forall x. DeleteImageResponse -> Rep DeleteImageResponse x)
-> (forall x. Rep DeleteImageResponse x -> DeleteImageResponse)
-> Generic DeleteImageResponse
forall x. Rep DeleteImageResponse x -> DeleteImageResponse
forall x. DeleteImageResponse -> Rep DeleteImageResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteImageResponse x -> DeleteImageResponse
$cfrom :: forall x. DeleteImageResponse -> Rep DeleteImageResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteImageResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'requestId', 'deleteImageResponse_requestId' - The request ID that uniquely identifies this request.
--
-- 'imageBuildVersionArn', 'deleteImageResponse_imageBuildVersionArn' - The Amazon Resource Name (ARN) of the Image Builder image resource that
-- was deleted.
--
-- 'httpStatus', 'deleteImageResponse_httpStatus' - The response's http status code.
newDeleteImageResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteImageResponse
newDeleteImageResponse :: Int -> DeleteImageResponse
newDeleteImageResponse Int
pHttpStatus_ =
  DeleteImageResponse' :: Maybe Text -> Maybe Text -> Int -> DeleteImageResponse
DeleteImageResponse'
    { $sel:requestId:DeleteImageResponse' :: Maybe Text
requestId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:imageBuildVersionArn:DeleteImageResponse' :: Maybe Text
imageBuildVersionArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteImageResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The request ID that uniquely identifies this request.
deleteImageResponse_requestId :: Lens.Lens' DeleteImageResponse (Prelude.Maybe Prelude.Text)
deleteImageResponse_requestId :: (Maybe Text -> f (Maybe Text))
-> DeleteImageResponse -> f DeleteImageResponse
deleteImageResponse_requestId = (DeleteImageResponse -> Maybe Text)
-> (DeleteImageResponse -> Maybe Text -> DeleteImageResponse)
-> Lens
     DeleteImageResponse DeleteImageResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteImageResponse' {Maybe Text
requestId :: Maybe Text
$sel:requestId:DeleteImageResponse' :: DeleteImageResponse -> Maybe Text
requestId} -> Maybe Text
requestId) (\s :: DeleteImageResponse
s@DeleteImageResponse' {} Maybe Text
a -> DeleteImageResponse
s {$sel:requestId:DeleteImageResponse' :: Maybe Text
requestId = Maybe Text
a} :: DeleteImageResponse)

-- | The Amazon Resource Name (ARN) of the Image Builder image resource that
-- was deleted.
deleteImageResponse_imageBuildVersionArn :: Lens.Lens' DeleteImageResponse (Prelude.Maybe Prelude.Text)
deleteImageResponse_imageBuildVersionArn :: (Maybe Text -> f (Maybe Text))
-> DeleteImageResponse -> f DeleteImageResponse
deleteImageResponse_imageBuildVersionArn = (DeleteImageResponse -> Maybe Text)
-> (DeleteImageResponse -> Maybe Text -> DeleteImageResponse)
-> Lens
     DeleteImageResponse DeleteImageResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteImageResponse' {Maybe Text
imageBuildVersionArn :: Maybe Text
$sel:imageBuildVersionArn:DeleteImageResponse' :: DeleteImageResponse -> Maybe Text
imageBuildVersionArn} -> Maybe Text
imageBuildVersionArn) (\s :: DeleteImageResponse
s@DeleteImageResponse' {} Maybe Text
a -> DeleteImageResponse
s {$sel:imageBuildVersionArn:DeleteImageResponse' :: Maybe Text
imageBuildVersionArn = Maybe Text
a} :: DeleteImageResponse)

-- | The response's http status code.
deleteImageResponse_httpStatus :: Lens.Lens' DeleteImageResponse Prelude.Int
deleteImageResponse_httpStatus :: (Int -> f Int) -> DeleteImageResponse -> f DeleteImageResponse
deleteImageResponse_httpStatus = (DeleteImageResponse -> Int)
-> (DeleteImageResponse -> Int -> DeleteImageResponse)
-> Lens DeleteImageResponse DeleteImageResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteImageResponse' {Int
httpStatus :: Int
$sel:httpStatus:DeleteImageResponse' :: DeleteImageResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: DeleteImageResponse
s@DeleteImageResponse' {} Int
a -> DeleteImageResponse
s {$sel:httpStatus:DeleteImageResponse' :: Int
httpStatus = Int
a} :: DeleteImageResponse)

instance Prelude.NFData DeleteImageResponse