{-# 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.ECRPublic.DescribeImages
-- 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)
--
-- Returns metadata about the images in a repository in a public registry.
--
-- Beginning with Docker version 1.9, the Docker client compresses image
-- layers before pushing them to a V2 Docker registry. The output of the
-- @docker images@ command shows the uncompressed image size, so it may
-- return a larger image size than the image sizes returned by
-- DescribeImages.
--
-- This operation returns paginated results.
module Amazonka.ECRPublic.DescribeImages
  ( -- * Creating a Request
    DescribeImages (..),
    newDescribeImages,

    -- * Request Lenses
    describeImages_registryId,
    describeImages_imageIds,
    describeImages_nextToken,
    describeImages_maxResults,
    describeImages_repositoryName,

    -- * Destructuring the Response
    DescribeImagesResponse (..),
    newDescribeImagesResponse,

    -- * Response Lenses
    describeImagesResponse_imageDetails,
    describeImagesResponse_nextToken,
    describeImagesResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.ECRPublic.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:/ 'newDescribeImages' smart constructor.
data DescribeImages = DescribeImages'
  { -- | The AWS account ID associated with the public registry that contains the
    -- repository in which to describe images. If you do not specify a
    -- registry, the default public registry is assumed.
    DescribeImages -> Maybe Text
registryId :: Prelude.Maybe Prelude.Text,
    -- | The list of image IDs for the requested repository.
    DescribeImages -> Maybe (NonEmpty ImageIdentifier)
imageIds :: Prelude.Maybe (Prelude.NonEmpty ImageIdentifier),
    -- | The @nextToken@ value returned from a previous paginated
    -- @DescribeImages@ request where @maxResults@ was used and the results
    -- exceeded the value of that parameter. Pagination continues from the end
    -- of the previous results that returned the @nextToken@ value. This value
    -- is @null@ when there are no more results to return. This option cannot
    -- be used when you specify images with @imageIds@.
    DescribeImages -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of repository results returned by @DescribeImages@ in
    -- paginated output. When this parameter is used, @DescribeImages@ only
    -- returns @maxResults@ results in a single page along with a @nextToken@
    -- response element. The remaining results of the initial request can be
    -- seen by sending another @DescribeImages@ request with the returned
    -- @nextToken@ value. This value can be between 1 and 1000. If this
    -- parameter is not used, then @DescribeImages@ returns up to 100 results
    -- and a @nextToken@ value, if applicable. This option cannot be used when
    -- you specify images with @imageIds@.
    DescribeImages -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The repository that contains the images to describe.
    DescribeImages -> Text
repositoryName :: Prelude.Text
  }
  deriving (DescribeImages -> DescribeImages -> Bool
(DescribeImages -> DescribeImages -> Bool)
-> (DescribeImages -> DescribeImages -> Bool) -> Eq DescribeImages
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeImages -> DescribeImages -> Bool
$c/= :: DescribeImages -> DescribeImages -> Bool
== :: DescribeImages -> DescribeImages -> Bool
$c== :: DescribeImages -> DescribeImages -> Bool
Prelude.Eq, ReadPrec [DescribeImages]
ReadPrec DescribeImages
Int -> ReadS DescribeImages
ReadS [DescribeImages]
(Int -> ReadS DescribeImages)
-> ReadS [DescribeImages]
-> ReadPrec DescribeImages
-> ReadPrec [DescribeImages]
-> Read DescribeImages
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeImages]
$creadListPrec :: ReadPrec [DescribeImages]
readPrec :: ReadPrec DescribeImages
$creadPrec :: ReadPrec DescribeImages
readList :: ReadS [DescribeImages]
$creadList :: ReadS [DescribeImages]
readsPrec :: Int -> ReadS DescribeImages
$creadsPrec :: Int -> ReadS DescribeImages
Prelude.Read, Int -> DescribeImages -> ShowS
[DescribeImages] -> ShowS
DescribeImages -> String
(Int -> DescribeImages -> ShowS)
-> (DescribeImages -> String)
-> ([DescribeImages] -> ShowS)
-> Show DescribeImages
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeImages] -> ShowS
$cshowList :: [DescribeImages] -> ShowS
show :: DescribeImages -> String
$cshow :: DescribeImages -> String
showsPrec :: Int -> DescribeImages -> ShowS
$cshowsPrec :: Int -> DescribeImages -> ShowS
Prelude.Show, (forall x. DescribeImages -> Rep DescribeImages x)
-> (forall x. Rep DescribeImages x -> DescribeImages)
-> Generic DescribeImages
forall x. Rep DescribeImages x -> DescribeImages
forall x. DescribeImages -> Rep DescribeImages x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeImages x -> DescribeImages
$cfrom :: forall x. DescribeImages -> Rep DescribeImages x
Prelude.Generic)

-- |
-- Create a value of 'DescribeImages' 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:
--
-- 'registryId', 'describeImages_registryId' - The AWS account ID associated with the public registry that contains the
-- repository in which to describe images. If you do not specify a
-- registry, the default public registry is assumed.
--
-- 'imageIds', 'describeImages_imageIds' - The list of image IDs for the requested repository.
--
-- 'nextToken', 'describeImages_nextToken' - The @nextToken@ value returned from a previous paginated
-- @DescribeImages@ request where @maxResults@ was used and the results
-- exceeded the value of that parameter. Pagination continues from the end
-- of the previous results that returned the @nextToken@ value. This value
-- is @null@ when there are no more results to return. This option cannot
-- be used when you specify images with @imageIds@.
--
-- 'maxResults', 'describeImages_maxResults' - The maximum number of repository results returned by @DescribeImages@ in
-- paginated output. When this parameter is used, @DescribeImages@ only
-- returns @maxResults@ results in a single page along with a @nextToken@
-- response element. The remaining results of the initial request can be
-- seen by sending another @DescribeImages@ request with the returned
-- @nextToken@ value. This value can be between 1 and 1000. If this
-- parameter is not used, then @DescribeImages@ returns up to 100 results
-- and a @nextToken@ value, if applicable. This option cannot be used when
-- you specify images with @imageIds@.
--
-- 'repositoryName', 'describeImages_repositoryName' - The repository that contains the images to describe.
newDescribeImages ::
  -- | 'repositoryName'
  Prelude.Text ->
  DescribeImages
newDescribeImages :: Text -> DescribeImages
newDescribeImages Text
pRepositoryName_ =
  DescribeImages' :: Maybe Text
-> Maybe (NonEmpty ImageIdentifier)
-> Maybe Text
-> Maybe Natural
-> Text
-> DescribeImages
DescribeImages'
    { $sel:registryId:DescribeImages' :: Maybe Text
registryId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:imageIds:DescribeImages' :: Maybe (NonEmpty ImageIdentifier)
imageIds = Maybe (NonEmpty ImageIdentifier)
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:DescribeImages' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:DescribeImages' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:repositoryName:DescribeImages' :: Text
repositoryName = Text
pRepositoryName_
    }

-- | The AWS account ID associated with the public registry that contains the
-- repository in which to describe images. If you do not specify a
-- registry, the default public registry is assumed.
describeImages_registryId :: Lens.Lens' DescribeImages (Prelude.Maybe Prelude.Text)
describeImages_registryId :: (Maybe Text -> f (Maybe Text))
-> DescribeImages -> f DescribeImages
describeImages_registryId = (DescribeImages -> Maybe Text)
-> (DescribeImages -> Maybe Text -> DescribeImages)
-> Lens DescribeImages DescribeImages (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeImages' {Maybe Text
registryId :: Maybe Text
$sel:registryId:DescribeImages' :: DescribeImages -> Maybe Text
registryId} -> Maybe Text
registryId) (\s :: DescribeImages
s@DescribeImages' {} Maybe Text
a -> DescribeImages
s {$sel:registryId:DescribeImages' :: Maybe Text
registryId = Maybe Text
a} :: DescribeImages)

-- | The list of image IDs for the requested repository.
describeImages_imageIds :: Lens.Lens' DescribeImages (Prelude.Maybe (Prelude.NonEmpty ImageIdentifier))
describeImages_imageIds :: (Maybe (NonEmpty ImageIdentifier)
 -> f (Maybe (NonEmpty ImageIdentifier)))
-> DescribeImages -> f DescribeImages
describeImages_imageIds = (DescribeImages -> Maybe (NonEmpty ImageIdentifier))
-> (DescribeImages
    -> Maybe (NonEmpty ImageIdentifier) -> DescribeImages)
-> Lens
     DescribeImages
     DescribeImages
     (Maybe (NonEmpty ImageIdentifier))
     (Maybe (NonEmpty ImageIdentifier))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeImages' {Maybe (NonEmpty ImageIdentifier)
imageIds :: Maybe (NonEmpty ImageIdentifier)
$sel:imageIds:DescribeImages' :: DescribeImages -> Maybe (NonEmpty ImageIdentifier)
imageIds} -> Maybe (NonEmpty ImageIdentifier)
imageIds) (\s :: DescribeImages
s@DescribeImages' {} Maybe (NonEmpty ImageIdentifier)
a -> DescribeImages
s {$sel:imageIds:DescribeImages' :: Maybe (NonEmpty ImageIdentifier)
imageIds = Maybe (NonEmpty ImageIdentifier)
a} :: DescribeImages) ((Maybe (NonEmpty ImageIdentifier)
  -> f (Maybe (NonEmpty ImageIdentifier)))
 -> DescribeImages -> f DescribeImages)
-> ((Maybe (NonEmpty ImageIdentifier)
     -> f (Maybe (NonEmpty ImageIdentifier)))
    -> Maybe (NonEmpty ImageIdentifier)
    -> f (Maybe (NonEmpty ImageIdentifier)))
-> (Maybe (NonEmpty ImageIdentifier)
    -> f (Maybe (NonEmpty ImageIdentifier)))
-> DescribeImages
-> f DescribeImages
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty ImageIdentifier)
  (NonEmpty ImageIdentifier)
  (NonEmpty ImageIdentifier)
  (NonEmpty ImageIdentifier)
-> Iso
     (Maybe (NonEmpty ImageIdentifier))
     (Maybe (NonEmpty ImageIdentifier))
     (Maybe (NonEmpty ImageIdentifier))
     (Maybe (NonEmpty ImageIdentifier))
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 AnIso
  (NonEmpty ImageIdentifier)
  (NonEmpty ImageIdentifier)
  (NonEmpty ImageIdentifier)
  (NonEmpty ImageIdentifier)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The @nextToken@ value returned from a previous paginated
-- @DescribeImages@ request where @maxResults@ was used and the results
-- exceeded the value of that parameter. Pagination continues from the end
-- of the previous results that returned the @nextToken@ value. This value
-- is @null@ when there are no more results to return. This option cannot
-- be used when you specify images with @imageIds@.
describeImages_nextToken :: Lens.Lens' DescribeImages (Prelude.Maybe Prelude.Text)
describeImages_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribeImages -> f DescribeImages
describeImages_nextToken = (DescribeImages -> Maybe Text)
-> (DescribeImages -> Maybe Text -> DescribeImages)
-> Lens DescribeImages DescribeImages (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeImages' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeImages' :: DescribeImages -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeImages
s@DescribeImages' {} Maybe Text
a -> DescribeImages
s {$sel:nextToken:DescribeImages' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeImages)

-- | The maximum number of repository results returned by @DescribeImages@ in
-- paginated output. When this parameter is used, @DescribeImages@ only
-- returns @maxResults@ results in a single page along with a @nextToken@
-- response element. The remaining results of the initial request can be
-- seen by sending another @DescribeImages@ request with the returned
-- @nextToken@ value. This value can be between 1 and 1000. If this
-- parameter is not used, then @DescribeImages@ returns up to 100 results
-- and a @nextToken@ value, if applicable. This option cannot be used when
-- you specify images with @imageIds@.
describeImages_maxResults :: Lens.Lens' DescribeImages (Prelude.Maybe Prelude.Natural)
describeImages_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> DescribeImages -> f DescribeImages
describeImages_maxResults = (DescribeImages -> Maybe Natural)
-> (DescribeImages -> Maybe Natural -> DescribeImages)
-> Lens
     DescribeImages DescribeImages (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeImages' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:DescribeImages' :: DescribeImages -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: DescribeImages
s@DescribeImages' {} Maybe Natural
a -> DescribeImages
s {$sel:maxResults:DescribeImages' :: Maybe Natural
maxResults = Maybe Natural
a} :: DescribeImages)

-- | The repository that contains the images to describe.
describeImages_repositoryName :: Lens.Lens' DescribeImages Prelude.Text
describeImages_repositoryName :: (Text -> f Text) -> DescribeImages -> f DescribeImages
describeImages_repositoryName = (DescribeImages -> Text)
-> (DescribeImages -> Text -> DescribeImages)
-> Lens DescribeImages DescribeImages Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeImages' {Text
repositoryName :: Text
$sel:repositoryName:DescribeImages' :: DescribeImages -> Text
repositoryName} -> Text
repositoryName) (\s :: DescribeImages
s@DescribeImages' {} Text
a -> DescribeImages
s {$sel:repositoryName:DescribeImages' :: Text
repositoryName = Text
a} :: DescribeImages)

instance Core.AWSPager DescribeImages where
  page :: DescribeImages
-> AWSResponse DescribeImages -> Maybe DescribeImages
page DescribeImages
rq AWSResponse DescribeImages
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeImages
DescribeImagesResponse
rs
            DescribeImagesResponse
-> Getting (First Text) DescribeImagesResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeImagesResponse
-> Const (First Text) DescribeImagesResponse
Lens' DescribeImagesResponse (Maybe Text)
describeImagesResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribeImagesResponse
 -> Const (First Text) DescribeImagesResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) DescribeImagesResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe DescribeImages
forall a. Maybe a
Prelude.Nothing
    | Maybe [ImageDetail] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeImages
DescribeImagesResponse
rs
            DescribeImagesResponse
-> Getting
     (First [ImageDetail]) DescribeImagesResponse [ImageDetail]
-> Maybe [ImageDetail]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [ImageDetail]
 -> Const (First [ImageDetail]) (Maybe [ImageDetail]))
-> DescribeImagesResponse
-> Const (First [ImageDetail]) DescribeImagesResponse
Lens' DescribeImagesResponse (Maybe [ImageDetail])
describeImagesResponse_imageDetails
              ((Maybe [ImageDetail]
  -> Const (First [ImageDetail]) (Maybe [ImageDetail]))
 -> DescribeImagesResponse
 -> Const (First [ImageDetail]) DescribeImagesResponse)
-> (([ImageDetail] -> Const (First [ImageDetail]) [ImageDetail])
    -> Maybe [ImageDetail]
    -> Const (First [ImageDetail]) (Maybe [ImageDetail]))
-> Getting
     (First [ImageDetail]) DescribeImagesResponse [ImageDetail]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([ImageDetail] -> Const (First [ImageDetail]) [ImageDetail])
-> Maybe [ImageDetail]
-> Const (First [ImageDetail]) (Maybe [ImageDetail])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe DescribeImages
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      DescribeImages -> Maybe DescribeImages
forall a. a -> Maybe a
Prelude.Just (DescribeImages -> Maybe DescribeImages)
-> DescribeImages -> Maybe DescribeImages
forall a b. (a -> b) -> a -> b
Prelude.$
        DescribeImages
rq
          DescribeImages
-> (DescribeImages -> DescribeImages) -> DescribeImages
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> DescribeImages -> Identity DescribeImages
Lens DescribeImages DescribeImages (Maybe Text) (Maybe Text)
describeImages_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> DescribeImages -> Identity DescribeImages)
-> Maybe Text -> DescribeImages -> DescribeImages
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse DescribeImages
DescribeImagesResponse
rs
          DescribeImagesResponse
-> Getting (First Text) DescribeImagesResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeImagesResponse
-> Const (First Text) DescribeImagesResponse
Lens' DescribeImagesResponse (Maybe Text)
describeImagesResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribeImagesResponse
 -> Const (First Text) DescribeImagesResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) DescribeImagesResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest DescribeImages where
  type
    AWSResponse DescribeImages =
      DescribeImagesResponse
  request :: DescribeImages -> Request DescribeImages
request = Service -> DescribeImages -> Request DescribeImages
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeImages
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeImages)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeImages))
-> Logger
-> Service
-> Proxy DescribeImages
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeImages)))
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 [ImageDetail] -> Maybe Text -> Int -> DescribeImagesResponse
DescribeImagesResponse'
            (Maybe [ImageDetail]
 -> Maybe Text -> Int -> DescribeImagesResponse)
-> Either String (Maybe [ImageDetail])
-> Either String (Maybe Text -> Int -> DescribeImagesResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [ImageDetail]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"imageDetails" Either String (Maybe (Maybe [ImageDetail]))
-> Maybe [ImageDetail] -> Either String (Maybe [ImageDetail])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [ImageDetail]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Maybe Text -> Int -> DescribeImagesResponse)
-> Either String (Maybe Text)
-> Either String (Int -> DescribeImagesResponse)
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
"nextToken")
            Either String (Int -> DescribeImagesResponse)
-> Either String Int -> Either String DescribeImagesResponse
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 DescribeImages

instance Prelude.NFData DescribeImages

instance Core.ToHeaders DescribeImages where
  toHeaders :: DescribeImages -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeImages -> 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
"SpencerFrontendService.DescribeImages" ::
                          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 DescribeImages where
  toJSON :: DescribeImages -> Value
toJSON DescribeImages' {Maybe Natural
Maybe (NonEmpty ImageIdentifier)
Maybe Text
Text
repositoryName :: Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
imageIds :: Maybe (NonEmpty ImageIdentifier)
registryId :: Maybe Text
$sel:repositoryName:DescribeImages' :: DescribeImages -> Text
$sel:maxResults:DescribeImages' :: DescribeImages -> Maybe Natural
$sel:nextToken:DescribeImages' :: DescribeImages -> Maybe Text
$sel:imageIds:DescribeImages' :: DescribeImages -> Maybe (NonEmpty ImageIdentifier)
$sel:registryId:DescribeImages' :: DescribeImages -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"registryId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
registryId,
            (Text
"imageIds" Text -> NonEmpty ImageIdentifier -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (NonEmpty ImageIdentifier -> Pair)
-> Maybe (NonEmpty ImageIdentifier) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty ImageIdentifier)
imageIds,
            (Text
"nextToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
nextToken,
            (Text
"maxResults" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxResults,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"repositoryName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
repositoryName)
          ]
      )

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

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

-- | /See:/ 'newDescribeImagesResponse' smart constructor.
data DescribeImagesResponse = DescribeImagesResponse'
  { -- | A list of ImageDetail objects that contain data about the image.
    DescribeImagesResponse -> Maybe [ImageDetail]
imageDetails :: Prelude.Maybe [ImageDetail],
    -- | The @nextToken@ value to include in a future @DescribeImages@ request.
    -- When the results of a @DescribeImages@ request exceed @maxResults@, this
    -- value can be used to retrieve the next page of results. This value is
    -- @null@ when there are no more results to return.
    DescribeImagesResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    DescribeImagesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeImagesResponse -> DescribeImagesResponse -> Bool
(DescribeImagesResponse -> DescribeImagesResponse -> Bool)
-> (DescribeImagesResponse -> DescribeImagesResponse -> Bool)
-> Eq DescribeImagesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeImagesResponse -> DescribeImagesResponse -> Bool
$c/= :: DescribeImagesResponse -> DescribeImagesResponse -> Bool
== :: DescribeImagesResponse -> DescribeImagesResponse -> Bool
$c== :: DescribeImagesResponse -> DescribeImagesResponse -> Bool
Prelude.Eq, ReadPrec [DescribeImagesResponse]
ReadPrec DescribeImagesResponse
Int -> ReadS DescribeImagesResponse
ReadS [DescribeImagesResponse]
(Int -> ReadS DescribeImagesResponse)
-> ReadS [DescribeImagesResponse]
-> ReadPrec DescribeImagesResponse
-> ReadPrec [DescribeImagesResponse]
-> Read DescribeImagesResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeImagesResponse]
$creadListPrec :: ReadPrec [DescribeImagesResponse]
readPrec :: ReadPrec DescribeImagesResponse
$creadPrec :: ReadPrec DescribeImagesResponse
readList :: ReadS [DescribeImagesResponse]
$creadList :: ReadS [DescribeImagesResponse]
readsPrec :: Int -> ReadS DescribeImagesResponse
$creadsPrec :: Int -> ReadS DescribeImagesResponse
Prelude.Read, Int -> DescribeImagesResponse -> ShowS
[DescribeImagesResponse] -> ShowS
DescribeImagesResponse -> String
(Int -> DescribeImagesResponse -> ShowS)
-> (DescribeImagesResponse -> String)
-> ([DescribeImagesResponse] -> ShowS)
-> Show DescribeImagesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeImagesResponse] -> ShowS
$cshowList :: [DescribeImagesResponse] -> ShowS
show :: DescribeImagesResponse -> String
$cshow :: DescribeImagesResponse -> String
showsPrec :: Int -> DescribeImagesResponse -> ShowS
$cshowsPrec :: Int -> DescribeImagesResponse -> ShowS
Prelude.Show, (forall x. DescribeImagesResponse -> Rep DescribeImagesResponse x)
-> (forall x.
    Rep DescribeImagesResponse x -> DescribeImagesResponse)
-> Generic DescribeImagesResponse
forall x. Rep DescribeImagesResponse x -> DescribeImagesResponse
forall x. DescribeImagesResponse -> Rep DescribeImagesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeImagesResponse x -> DescribeImagesResponse
$cfrom :: forall x. DescribeImagesResponse -> Rep DescribeImagesResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeImagesResponse' 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:
--
-- 'imageDetails', 'describeImagesResponse_imageDetails' - A list of ImageDetail objects that contain data about the image.
--
-- 'nextToken', 'describeImagesResponse_nextToken' - The @nextToken@ value to include in a future @DescribeImages@ request.
-- When the results of a @DescribeImages@ request exceed @maxResults@, this
-- value can be used to retrieve the next page of results. This value is
-- @null@ when there are no more results to return.
--
-- 'httpStatus', 'describeImagesResponse_httpStatus' - The response's http status code.
newDescribeImagesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeImagesResponse
newDescribeImagesResponse :: Int -> DescribeImagesResponse
newDescribeImagesResponse Int
pHttpStatus_ =
  DescribeImagesResponse' :: Maybe [ImageDetail] -> Maybe Text -> Int -> DescribeImagesResponse
DescribeImagesResponse'
    { $sel:imageDetails:DescribeImagesResponse' :: Maybe [ImageDetail]
imageDetails =
        Maybe [ImageDetail]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:DescribeImagesResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeImagesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A list of ImageDetail objects that contain data about the image.
describeImagesResponse_imageDetails :: Lens.Lens' DescribeImagesResponse (Prelude.Maybe [ImageDetail])
describeImagesResponse_imageDetails :: (Maybe [ImageDetail] -> f (Maybe [ImageDetail]))
-> DescribeImagesResponse -> f DescribeImagesResponse
describeImagesResponse_imageDetails = (DescribeImagesResponse -> Maybe [ImageDetail])
-> (DescribeImagesResponse
    -> Maybe [ImageDetail] -> DescribeImagesResponse)
-> Lens' DescribeImagesResponse (Maybe [ImageDetail])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeImagesResponse' {Maybe [ImageDetail]
imageDetails :: Maybe [ImageDetail]
$sel:imageDetails:DescribeImagesResponse' :: DescribeImagesResponse -> Maybe [ImageDetail]
imageDetails} -> Maybe [ImageDetail]
imageDetails) (\s :: DescribeImagesResponse
s@DescribeImagesResponse' {} Maybe [ImageDetail]
a -> DescribeImagesResponse
s {$sel:imageDetails:DescribeImagesResponse' :: Maybe [ImageDetail]
imageDetails = Maybe [ImageDetail]
a} :: DescribeImagesResponse) ((Maybe [ImageDetail] -> f (Maybe [ImageDetail]))
 -> DescribeImagesResponse -> f DescribeImagesResponse)
-> ((Maybe [ImageDetail] -> f (Maybe [ImageDetail]))
    -> Maybe [ImageDetail] -> f (Maybe [ImageDetail]))
-> (Maybe [ImageDetail] -> f (Maybe [ImageDetail]))
-> DescribeImagesResponse
-> f DescribeImagesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [ImageDetail] [ImageDetail] [ImageDetail] [ImageDetail]
-> Iso
     (Maybe [ImageDetail])
     (Maybe [ImageDetail])
     (Maybe [ImageDetail])
     (Maybe [ImageDetail])
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 AnIso [ImageDetail] [ImageDetail] [ImageDetail] [ImageDetail]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The @nextToken@ value to include in a future @DescribeImages@ request.
-- When the results of a @DescribeImages@ request exceed @maxResults@, this
-- value can be used to retrieve the next page of results. This value is
-- @null@ when there are no more results to return.
describeImagesResponse_nextToken :: Lens.Lens' DescribeImagesResponse (Prelude.Maybe Prelude.Text)
describeImagesResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> DescribeImagesResponse -> f DescribeImagesResponse
describeImagesResponse_nextToken = (DescribeImagesResponse -> Maybe Text)
-> (DescribeImagesResponse -> Maybe Text -> DescribeImagesResponse)
-> Lens' DescribeImagesResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeImagesResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeImagesResponse' :: DescribeImagesResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeImagesResponse
s@DescribeImagesResponse' {} Maybe Text
a -> DescribeImagesResponse
s {$sel:nextToken:DescribeImagesResponse' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeImagesResponse)

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

instance Prelude.NFData DescribeImagesResponse