{-# 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.Lightsail.DeleteContainerImage
-- 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 a container image that is registered to your Amazon Lightsail
-- container service.
module Amazonka.Lightsail.DeleteContainerImage
  ( -- * Creating a Request
    DeleteContainerImage (..),
    newDeleteContainerImage,

    -- * Request Lenses
    deleteContainerImage_serviceName,
    deleteContainerImage_image,

    -- * Destructuring the Response
    DeleteContainerImageResponse (..),
    newDeleteContainerImageResponse,

    -- * Response Lenses
    deleteContainerImageResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDeleteContainerImage' smart constructor.
data DeleteContainerImage = DeleteContainerImage'
  { -- | The name of the container service for which to delete a registered
    -- container image.
    DeleteContainerImage -> Text
serviceName :: Prelude.Text,
    -- | The name of the container image to delete from the container service.
    --
    -- Use the @GetContainerImages@ action to get the name of the container
    -- images that are registered to a container service.
    --
    -- Container images sourced from your Lightsail container service, that are
    -- registered and stored on your service, start with a colon (@:@). For
    -- example, @:container-service-1.mystaticwebsite.1@. Container images
    -- sourced from a public registry like Docker Hub don\'t start with a
    -- colon. For example, @nginx:latest@ or @nginx@.
    DeleteContainerImage -> Text
image :: Prelude.Text
  }
  deriving (DeleteContainerImage -> DeleteContainerImage -> Bool
(DeleteContainerImage -> DeleteContainerImage -> Bool)
-> (DeleteContainerImage -> DeleteContainerImage -> Bool)
-> Eq DeleteContainerImage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteContainerImage -> DeleteContainerImage -> Bool
$c/= :: DeleteContainerImage -> DeleteContainerImage -> Bool
== :: DeleteContainerImage -> DeleteContainerImage -> Bool
$c== :: DeleteContainerImage -> DeleteContainerImage -> Bool
Prelude.Eq, ReadPrec [DeleteContainerImage]
ReadPrec DeleteContainerImage
Int -> ReadS DeleteContainerImage
ReadS [DeleteContainerImage]
(Int -> ReadS DeleteContainerImage)
-> ReadS [DeleteContainerImage]
-> ReadPrec DeleteContainerImage
-> ReadPrec [DeleteContainerImage]
-> Read DeleteContainerImage
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteContainerImage]
$creadListPrec :: ReadPrec [DeleteContainerImage]
readPrec :: ReadPrec DeleteContainerImage
$creadPrec :: ReadPrec DeleteContainerImage
readList :: ReadS [DeleteContainerImage]
$creadList :: ReadS [DeleteContainerImage]
readsPrec :: Int -> ReadS DeleteContainerImage
$creadsPrec :: Int -> ReadS DeleteContainerImage
Prelude.Read, Int -> DeleteContainerImage -> ShowS
[DeleteContainerImage] -> ShowS
DeleteContainerImage -> String
(Int -> DeleteContainerImage -> ShowS)
-> (DeleteContainerImage -> String)
-> ([DeleteContainerImage] -> ShowS)
-> Show DeleteContainerImage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteContainerImage] -> ShowS
$cshowList :: [DeleteContainerImage] -> ShowS
show :: DeleteContainerImage -> String
$cshow :: DeleteContainerImage -> String
showsPrec :: Int -> DeleteContainerImage -> ShowS
$cshowsPrec :: Int -> DeleteContainerImage -> ShowS
Prelude.Show, (forall x. DeleteContainerImage -> Rep DeleteContainerImage x)
-> (forall x. Rep DeleteContainerImage x -> DeleteContainerImage)
-> Generic DeleteContainerImage
forall x. Rep DeleteContainerImage x -> DeleteContainerImage
forall x. DeleteContainerImage -> Rep DeleteContainerImage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteContainerImage x -> DeleteContainerImage
$cfrom :: forall x. DeleteContainerImage -> Rep DeleteContainerImage x
Prelude.Generic)

-- |
-- Create a value of 'DeleteContainerImage' 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:
--
-- 'serviceName', 'deleteContainerImage_serviceName' - The name of the container service for which to delete a registered
-- container image.
--
-- 'image', 'deleteContainerImage_image' - The name of the container image to delete from the container service.
--
-- Use the @GetContainerImages@ action to get the name of the container
-- images that are registered to a container service.
--
-- Container images sourced from your Lightsail container service, that are
-- registered and stored on your service, start with a colon (@:@). For
-- example, @:container-service-1.mystaticwebsite.1@. Container images
-- sourced from a public registry like Docker Hub don\'t start with a
-- colon. For example, @nginx:latest@ or @nginx@.
newDeleteContainerImage ::
  -- | 'serviceName'
  Prelude.Text ->
  -- | 'image'
  Prelude.Text ->
  DeleteContainerImage
newDeleteContainerImage :: Text -> Text -> DeleteContainerImage
newDeleteContainerImage Text
pServiceName_ Text
pImage_ =
  DeleteContainerImage' :: Text -> Text -> DeleteContainerImage
DeleteContainerImage'
    { $sel:serviceName:DeleteContainerImage' :: Text
serviceName = Text
pServiceName_,
      $sel:image:DeleteContainerImage' :: Text
image = Text
pImage_
    }

-- | The name of the container service for which to delete a registered
-- container image.
deleteContainerImage_serviceName :: Lens.Lens' DeleteContainerImage Prelude.Text
deleteContainerImage_serviceName :: (Text -> f Text) -> DeleteContainerImage -> f DeleteContainerImage
deleteContainerImage_serviceName = (DeleteContainerImage -> Text)
-> (DeleteContainerImage -> Text -> DeleteContainerImage)
-> Lens DeleteContainerImage DeleteContainerImage Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteContainerImage' {Text
serviceName :: Text
$sel:serviceName:DeleteContainerImage' :: DeleteContainerImage -> Text
serviceName} -> Text
serviceName) (\s :: DeleteContainerImage
s@DeleteContainerImage' {} Text
a -> DeleteContainerImage
s {$sel:serviceName:DeleteContainerImage' :: Text
serviceName = Text
a} :: DeleteContainerImage)

-- | The name of the container image to delete from the container service.
--
-- Use the @GetContainerImages@ action to get the name of the container
-- images that are registered to a container service.
--
-- Container images sourced from your Lightsail container service, that are
-- registered and stored on your service, start with a colon (@:@). For
-- example, @:container-service-1.mystaticwebsite.1@. Container images
-- sourced from a public registry like Docker Hub don\'t start with a
-- colon. For example, @nginx:latest@ or @nginx@.
deleteContainerImage_image :: Lens.Lens' DeleteContainerImage Prelude.Text
deleteContainerImage_image :: (Text -> f Text) -> DeleteContainerImage -> f DeleteContainerImage
deleteContainerImage_image = (DeleteContainerImage -> Text)
-> (DeleteContainerImage -> Text -> DeleteContainerImage)
-> Lens DeleteContainerImage DeleteContainerImage Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteContainerImage' {Text
image :: Text
$sel:image:DeleteContainerImage' :: DeleteContainerImage -> Text
image} -> Text
image) (\s :: DeleteContainerImage
s@DeleteContainerImage' {} Text
a -> DeleteContainerImage
s {$sel:image:DeleteContainerImage' :: Text
image = Text
a} :: DeleteContainerImage)

instance Core.AWSRequest DeleteContainerImage where
  type
    AWSResponse DeleteContainerImage =
      DeleteContainerImageResponse
  request :: DeleteContainerImage -> Request DeleteContainerImage
request = Service -> DeleteContainerImage -> Request DeleteContainerImage
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteContainerImage
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteContainerImage)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DeleteContainerImage))
-> Logger
-> Service
-> Proxy DeleteContainerImage
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteContainerImage)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> DeleteContainerImageResponse
DeleteContainerImageResponse'
            (Int -> DeleteContainerImageResponse)
-> Either String Int -> Either String DeleteContainerImageResponse
forall (f :: * -> *) a b. Functor 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 DeleteContainerImage

instance Prelude.NFData DeleteContainerImage

instance Core.ToHeaders DeleteContainerImage where
  toHeaders :: DeleteContainerImage -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteContainerImage -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"Lightsail_20161128.DeleteContainerImage" ::
                          Prelude.ByteString
                      ),
            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.ToJSON DeleteContainerImage where
  toJSON :: DeleteContainerImage -> Value
toJSON DeleteContainerImage' {Text
image :: Text
serviceName :: Text
$sel:image:DeleteContainerImage' :: DeleteContainerImage -> Text
$sel:serviceName:DeleteContainerImage' :: DeleteContainerImage -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"serviceName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
serviceName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"image" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
image)
          ]
      )

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

instance Core.ToQuery DeleteContainerImage where
  toQuery :: DeleteContainerImage -> QueryString
toQuery = QueryString -> DeleteContainerImage -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newDeleteContainerImageResponse' smart constructor.
data DeleteContainerImageResponse = DeleteContainerImageResponse'
  { -- | The response's http status code.
    DeleteContainerImageResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteContainerImageResponse
-> DeleteContainerImageResponse -> Bool
(DeleteContainerImageResponse
 -> DeleteContainerImageResponse -> Bool)
-> (DeleteContainerImageResponse
    -> DeleteContainerImageResponse -> Bool)
-> Eq DeleteContainerImageResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteContainerImageResponse
-> DeleteContainerImageResponse -> Bool
$c/= :: DeleteContainerImageResponse
-> DeleteContainerImageResponse -> Bool
== :: DeleteContainerImageResponse
-> DeleteContainerImageResponse -> Bool
$c== :: DeleteContainerImageResponse
-> DeleteContainerImageResponse -> Bool
Prelude.Eq, ReadPrec [DeleteContainerImageResponse]
ReadPrec DeleteContainerImageResponse
Int -> ReadS DeleteContainerImageResponse
ReadS [DeleteContainerImageResponse]
(Int -> ReadS DeleteContainerImageResponse)
-> ReadS [DeleteContainerImageResponse]
-> ReadPrec DeleteContainerImageResponse
-> ReadPrec [DeleteContainerImageResponse]
-> Read DeleteContainerImageResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteContainerImageResponse]
$creadListPrec :: ReadPrec [DeleteContainerImageResponse]
readPrec :: ReadPrec DeleteContainerImageResponse
$creadPrec :: ReadPrec DeleteContainerImageResponse
readList :: ReadS [DeleteContainerImageResponse]
$creadList :: ReadS [DeleteContainerImageResponse]
readsPrec :: Int -> ReadS DeleteContainerImageResponse
$creadsPrec :: Int -> ReadS DeleteContainerImageResponse
Prelude.Read, Int -> DeleteContainerImageResponse -> ShowS
[DeleteContainerImageResponse] -> ShowS
DeleteContainerImageResponse -> String
(Int -> DeleteContainerImageResponse -> ShowS)
-> (DeleteContainerImageResponse -> String)
-> ([DeleteContainerImageResponse] -> ShowS)
-> Show DeleteContainerImageResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteContainerImageResponse] -> ShowS
$cshowList :: [DeleteContainerImageResponse] -> ShowS
show :: DeleteContainerImageResponse -> String
$cshow :: DeleteContainerImageResponse -> String
showsPrec :: Int -> DeleteContainerImageResponse -> ShowS
$cshowsPrec :: Int -> DeleteContainerImageResponse -> ShowS
Prelude.Show, (forall x.
 DeleteContainerImageResponse -> Rep DeleteContainerImageResponse x)
-> (forall x.
    Rep DeleteContainerImageResponse x -> DeleteContainerImageResponse)
-> Generic DeleteContainerImageResponse
forall x.
Rep DeleteContainerImageResponse x -> DeleteContainerImageResponse
forall x.
DeleteContainerImageResponse -> Rep DeleteContainerImageResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeleteContainerImageResponse x -> DeleteContainerImageResponse
$cfrom :: forall x.
DeleteContainerImageResponse -> Rep DeleteContainerImageResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteContainerImageResponse' 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:
--
-- 'httpStatus', 'deleteContainerImageResponse_httpStatus' - The response's http status code.
newDeleteContainerImageResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteContainerImageResponse
newDeleteContainerImageResponse :: Int -> DeleteContainerImageResponse
newDeleteContainerImageResponse Int
pHttpStatus_ =
  DeleteContainerImageResponse' :: Int -> DeleteContainerImageResponse
DeleteContainerImageResponse'
    { $sel:httpStatus:DeleteContainerImageResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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

instance Prelude.NFData DeleteContainerImageResponse