{-# 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.GetContainerImages
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Returns the container images that are registered to your Amazon
-- Lightsail container service.
--
-- If you created a deployment on your Lightsail container service that
-- uses container images from a public registry like Docker Hub, those
-- images are not returned as part of this action. Those images are not
-- registered to your Lightsail container service.
module Amazonka.Lightsail.GetContainerImages
  ( -- * Creating a Request
    GetContainerImages (..),
    newGetContainerImages,

    -- * Request Lenses
    getContainerImages_serviceName,

    -- * Destructuring the Response
    GetContainerImagesResponse (..),
    newGetContainerImagesResponse,

    -- * Response Lenses
    getContainerImagesResponse_containerImages,
    getContainerImagesResponse_httpStatus,
  )
where

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

-- | /See:/ 'newGetContainerImages' smart constructor.
data GetContainerImages = GetContainerImages'
  { -- | The name of the container service for which to return registered
    -- container images.
    GetContainerImages -> Text
serviceName :: Prelude.Text
  }
  deriving (GetContainerImages -> GetContainerImages -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetContainerImages -> GetContainerImages -> Bool
$c/= :: GetContainerImages -> GetContainerImages -> Bool
== :: GetContainerImages -> GetContainerImages -> Bool
$c== :: GetContainerImages -> GetContainerImages -> Bool
Prelude.Eq, ReadPrec [GetContainerImages]
ReadPrec GetContainerImages
Int -> ReadS GetContainerImages
ReadS [GetContainerImages]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetContainerImages]
$creadListPrec :: ReadPrec [GetContainerImages]
readPrec :: ReadPrec GetContainerImages
$creadPrec :: ReadPrec GetContainerImages
readList :: ReadS [GetContainerImages]
$creadList :: ReadS [GetContainerImages]
readsPrec :: Int -> ReadS GetContainerImages
$creadsPrec :: Int -> ReadS GetContainerImages
Prelude.Read, Int -> GetContainerImages -> ShowS
[GetContainerImages] -> ShowS
GetContainerImages -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetContainerImages] -> ShowS
$cshowList :: [GetContainerImages] -> ShowS
show :: GetContainerImages -> String
$cshow :: GetContainerImages -> String
showsPrec :: Int -> GetContainerImages -> ShowS
$cshowsPrec :: Int -> GetContainerImages -> ShowS
Prelude.Show, forall x. Rep GetContainerImages x -> GetContainerImages
forall x. GetContainerImages -> Rep GetContainerImages x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetContainerImages x -> GetContainerImages
$cfrom :: forall x. GetContainerImages -> Rep GetContainerImages x
Prelude.Generic)

-- |
-- Create a value of 'GetContainerImages' 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', 'getContainerImages_serviceName' - The name of the container service for which to return registered
-- container images.
newGetContainerImages ::
  -- | 'serviceName'
  Prelude.Text ->
  GetContainerImages
newGetContainerImages :: Text -> GetContainerImages
newGetContainerImages Text
pServiceName_ =
  GetContainerImages' {$sel:serviceName:GetContainerImages' :: Text
serviceName = Text
pServiceName_}

-- | The name of the container service for which to return registered
-- container images.
getContainerImages_serviceName :: Lens.Lens' GetContainerImages Prelude.Text
getContainerImages_serviceName :: Lens' GetContainerImages Text
getContainerImages_serviceName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetContainerImages' {Text
serviceName :: Text
$sel:serviceName:GetContainerImages' :: GetContainerImages -> Text
serviceName} -> Text
serviceName) (\s :: GetContainerImages
s@GetContainerImages' {} Text
a -> GetContainerImages
s {$sel:serviceName:GetContainerImages' :: Text
serviceName = Text
a} :: GetContainerImages)

instance Core.AWSRequest GetContainerImages where
  type
    AWSResponse GetContainerImages =
      GetContainerImagesResponse
  request :: (Service -> Service)
-> GetContainerImages -> Request GetContainerImages
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetContainerImages
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetContainerImages)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe [ContainerImage] -> Int -> GetContainerImagesResponse
GetContainerImagesResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x
                            forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"containerImages"
                            forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                        )
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable GetContainerImages where
  hashWithSalt :: Int -> GetContainerImages -> Int
hashWithSalt Int
_salt GetContainerImages' {Text
serviceName :: Text
$sel:serviceName:GetContainerImages' :: GetContainerImages -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
serviceName

instance Prelude.NFData GetContainerImages where
  rnf :: GetContainerImages -> ()
rnf GetContainerImages' {Text
serviceName :: Text
$sel:serviceName:GetContainerImages' :: GetContainerImages -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
serviceName

instance Data.ToHeaders GetContainerImages where
  toHeaders :: GetContainerImages -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"Lightsail_20161128.GetContainerImages" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON GetContainerImages where
  toJSON :: GetContainerImages -> Value
toJSON GetContainerImages' {Text
serviceName :: Text
$sel:serviceName:GetContainerImages' :: GetContainerImages -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"serviceName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
serviceName)]
      )

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

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

-- | /See:/ 'newGetContainerImagesResponse' smart constructor.
data GetContainerImagesResponse = GetContainerImagesResponse'
  { -- | An array of objects that describe container images that are registered
    -- to the container service.
    GetContainerImagesResponse -> Maybe [ContainerImage]
containerImages :: Prelude.Maybe [ContainerImage],
    -- | The response's http status code.
    GetContainerImagesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetContainerImagesResponse -> GetContainerImagesResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetContainerImagesResponse -> GetContainerImagesResponse -> Bool
$c/= :: GetContainerImagesResponse -> GetContainerImagesResponse -> Bool
== :: GetContainerImagesResponse -> GetContainerImagesResponse -> Bool
$c== :: GetContainerImagesResponse -> GetContainerImagesResponse -> Bool
Prelude.Eq, ReadPrec [GetContainerImagesResponse]
ReadPrec GetContainerImagesResponse
Int -> ReadS GetContainerImagesResponse
ReadS [GetContainerImagesResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetContainerImagesResponse]
$creadListPrec :: ReadPrec [GetContainerImagesResponse]
readPrec :: ReadPrec GetContainerImagesResponse
$creadPrec :: ReadPrec GetContainerImagesResponse
readList :: ReadS [GetContainerImagesResponse]
$creadList :: ReadS [GetContainerImagesResponse]
readsPrec :: Int -> ReadS GetContainerImagesResponse
$creadsPrec :: Int -> ReadS GetContainerImagesResponse
Prelude.Read, Int -> GetContainerImagesResponse -> ShowS
[GetContainerImagesResponse] -> ShowS
GetContainerImagesResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetContainerImagesResponse] -> ShowS
$cshowList :: [GetContainerImagesResponse] -> ShowS
show :: GetContainerImagesResponse -> String
$cshow :: GetContainerImagesResponse -> String
showsPrec :: Int -> GetContainerImagesResponse -> ShowS
$cshowsPrec :: Int -> GetContainerImagesResponse -> ShowS
Prelude.Show, forall x.
Rep GetContainerImagesResponse x -> GetContainerImagesResponse
forall x.
GetContainerImagesResponse -> Rep GetContainerImagesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetContainerImagesResponse x -> GetContainerImagesResponse
$cfrom :: forall x.
GetContainerImagesResponse -> Rep GetContainerImagesResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetContainerImagesResponse' 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:
--
-- 'containerImages', 'getContainerImagesResponse_containerImages' - An array of objects that describe container images that are registered
-- to the container service.
--
-- 'httpStatus', 'getContainerImagesResponse_httpStatus' - The response's http status code.
newGetContainerImagesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetContainerImagesResponse
newGetContainerImagesResponse :: Int -> GetContainerImagesResponse
newGetContainerImagesResponse Int
pHttpStatus_ =
  GetContainerImagesResponse'
    { $sel:containerImages:GetContainerImagesResponse' :: Maybe [ContainerImage]
containerImages =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetContainerImagesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An array of objects that describe container images that are registered
-- to the container service.
getContainerImagesResponse_containerImages :: Lens.Lens' GetContainerImagesResponse (Prelude.Maybe [ContainerImage])
getContainerImagesResponse_containerImages :: Lens' GetContainerImagesResponse (Maybe [ContainerImage])
getContainerImagesResponse_containerImages = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetContainerImagesResponse' {Maybe [ContainerImage]
containerImages :: Maybe [ContainerImage]
$sel:containerImages:GetContainerImagesResponse' :: GetContainerImagesResponse -> Maybe [ContainerImage]
containerImages} -> Maybe [ContainerImage]
containerImages) (\s :: GetContainerImagesResponse
s@GetContainerImagesResponse' {} Maybe [ContainerImage]
a -> GetContainerImagesResponse
s {$sel:containerImages:GetContainerImagesResponse' :: Maybe [ContainerImage]
containerImages = Maybe [ContainerImage]
a} :: GetContainerImagesResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData GetContainerImagesResponse where
  rnf :: GetContainerImagesResponse -> ()
rnf GetContainerImagesResponse' {Int
Maybe [ContainerImage]
httpStatus :: Int
containerImages :: Maybe [ContainerImage]
$sel:httpStatus:GetContainerImagesResponse' :: GetContainerImagesResponse -> Int
$sel:containerImages:GetContainerImagesResponse' :: GetContainerImagesResponse -> Maybe [ContainerImage]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [ContainerImage]
containerImages
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus