{-# 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.GetRepositoryCatalogData
-- 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)
--
-- Retrieve catalog metadata for a repository in a public registry. This
-- metadata is displayed publicly in the Amazon ECR Public Gallery.
module Amazonka.ECRPublic.GetRepositoryCatalogData
  ( -- * Creating a Request
    GetRepositoryCatalogData (..),
    newGetRepositoryCatalogData,

    -- * Request Lenses
    getRepositoryCatalogData_registryId,
    getRepositoryCatalogData_repositoryName,

    -- * Destructuring the Response
    GetRepositoryCatalogDataResponse (..),
    newGetRepositoryCatalogDataResponse,

    -- * Response Lenses
    getRepositoryCatalogDataResponse_catalogData,
    getRepositoryCatalogDataResponse_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:/ 'newGetRepositoryCatalogData' smart constructor.
data GetRepositoryCatalogData = GetRepositoryCatalogData'
  { -- | The AWS account ID associated with the registry that contains the
    -- repositories to be described. If you do not specify a registry, the
    -- default public registry is assumed.
    GetRepositoryCatalogData -> Maybe Text
registryId :: Prelude.Maybe Prelude.Text,
    -- | The name of the repository to retrieve the catalog metadata for.
    GetRepositoryCatalogData -> Text
repositoryName :: Prelude.Text
  }
  deriving (GetRepositoryCatalogData -> GetRepositoryCatalogData -> Bool
(GetRepositoryCatalogData -> GetRepositoryCatalogData -> Bool)
-> (GetRepositoryCatalogData -> GetRepositoryCatalogData -> Bool)
-> Eq GetRepositoryCatalogData
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetRepositoryCatalogData -> GetRepositoryCatalogData -> Bool
$c/= :: GetRepositoryCatalogData -> GetRepositoryCatalogData -> Bool
== :: GetRepositoryCatalogData -> GetRepositoryCatalogData -> Bool
$c== :: GetRepositoryCatalogData -> GetRepositoryCatalogData -> Bool
Prelude.Eq, ReadPrec [GetRepositoryCatalogData]
ReadPrec GetRepositoryCatalogData
Int -> ReadS GetRepositoryCatalogData
ReadS [GetRepositoryCatalogData]
(Int -> ReadS GetRepositoryCatalogData)
-> ReadS [GetRepositoryCatalogData]
-> ReadPrec GetRepositoryCatalogData
-> ReadPrec [GetRepositoryCatalogData]
-> Read GetRepositoryCatalogData
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetRepositoryCatalogData]
$creadListPrec :: ReadPrec [GetRepositoryCatalogData]
readPrec :: ReadPrec GetRepositoryCatalogData
$creadPrec :: ReadPrec GetRepositoryCatalogData
readList :: ReadS [GetRepositoryCatalogData]
$creadList :: ReadS [GetRepositoryCatalogData]
readsPrec :: Int -> ReadS GetRepositoryCatalogData
$creadsPrec :: Int -> ReadS GetRepositoryCatalogData
Prelude.Read, Int -> GetRepositoryCatalogData -> ShowS
[GetRepositoryCatalogData] -> ShowS
GetRepositoryCatalogData -> String
(Int -> GetRepositoryCatalogData -> ShowS)
-> (GetRepositoryCatalogData -> String)
-> ([GetRepositoryCatalogData] -> ShowS)
-> Show GetRepositoryCatalogData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetRepositoryCatalogData] -> ShowS
$cshowList :: [GetRepositoryCatalogData] -> ShowS
show :: GetRepositoryCatalogData -> String
$cshow :: GetRepositoryCatalogData -> String
showsPrec :: Int -> GetRepositoryCatalogData -> ShowS
$cshowsPrec :: Int -> GetRepositoryCatalogData -> ShowS
Prelude.Show, (forall x.
 GetRepositoryCatalogData -> Rep GetRepositoryCatalogData x)
-> (forall x.
    Rep GetRepositoryCatalogData x -> GetRepositoryCatalogData)
-> Generic GetRepositoryCatalogData
forall x.
Rep GetRepositoryCatalogData x -> GetRepositoryCatalogData
forall x.
GetRepositoryCatalogData -> Rep GetRepositoryCatalogData x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetRepositoryCatalogData x -> GetRepositoryCatalogData
$cfrom :: forall x.
GetRepositoryCatalogData -> Rep GetRepositoryCatalogData x
Prelude.Generic)

-- |
-- Create a value of 'GetRepositoryCatalogData' 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', 'getRepositoryCatalogData_registryId' - The AWS account ID associated with the registry that contains the
-- repositories to be described. If you do not specify a registry, the
-- default public registry is assumed.
--
-- 'repositoryName', 'getRepositoryCatalogData_repositoryName' - The name of the repository to retrieve the catalog metadata for.
newGetRepositoryCatalogData ::
  -- | 'repositoryName'
  Prelude.Text ->
  GetRepositoryCatalogData
newGetRepositoryCatalogData :: Text -> GetRepositoryCatalogData
newGetRepositoryCatalogData Text
pRepositoryName_ =
  GetRepositoryCatalogData' :: Maybe Text -> Text -> GetRepositoryCatalogData
GetRepositoryCatalogData'
    { $sel:registryId:GetRepositoryCatalogData' :: Maybe Text
registryId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:repositoryName:GetRepositoryCatalogData' :: Text
repositoryName = Text
pRepositoryName_
    }

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

-- | The name of the repository to retrieve the catalog metadata for.
getRepositoryCatalogData_repositoryName :: Lens.Lens' GetRepositoryCatalogData Prelude.Text
getRepositoryCatalogData_repositoryName :: (Text -> f Text)
-> GetRepositoryCatalogData -> f GetRepositoryCatalogData
getRepositoryCatalogData_repositoryName = (GetRepositoryCatalogData -> Text)
-> (GetRepositoryCatalogData -> Text -> GetRepositoryCatalogData)
-> Lens GetRepositoryCatalogData GetRepositoryCatalogData Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRepositoryCatalogData' {Text
repositoryName :: Text
$sel:repositoryName:GetRepositoryCatalogData' :: GetRepositoryCatalogData -> Text
repositoryName} -> Text
repositoryName) (\s :: GetRepositoryCatalogData
s@GetRepositoryCatalogData' {} Text
a -> GetRepositoryCatalogData
s {$sel:repositoryName:GetRepositoryCatalogData' :: Text
repositoryName = Text
a} :: GetRepositoryCatalogData)

instance Core.AWSRequest GetRepositoryCatalogData where
  type
    AWSResponse GetRepositoryCatalogData =
      GetRepositoryCatalogDataResponse
  request :: GetRepositoryCatalogData -> Request GetRepositoryCatalogData
request = Service
-> GetRepositoryCatalogData -> Request GetRepositoryCatalogData
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetRepositoryCatalogData
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetRepositoryCatalogData)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetRepositoryCatalogData))
-> Logger
-> Service
-> Proxy GetRepositoryCatalogData
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetRepositoryCatalogData)))
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 RepositoryCatalogData
-> Int -> GetRepositoryCatalogDataResponse
GetRepositoryCatalogDataResponse'
            (Maybe RepositoryCatalogData
 -> Int -> GetRepositoryCatalogDataResponse)
-> Either String (Maybe RepositoryCatalogData)
-> Either String (Int -> GetRepositoryCatalogDataResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe RepositoryCatalogData)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"catalogData")
            Either String (Int -> GetRepositoryCatalogDataResponse)
-> Either String Int
-> Either String GetRepositoryCatalogDataResponse
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 GetRepositoryCatalogData

instance Prelude.NFData GetRepositoryCatalogData

instance Core.ToHeaders GetRepositoryCatalogData where
  toHeaders :: GetRepositoryCatalogData -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetRepositoryCatalogData -> 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.GetRepositoryCatalogData" ::
                          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 GetRepositoryCatalogData where
  toJSON :: GetRepositoryCatalogData -> Value
toJSON GetRepositoryCatalogData' {Maybe Text
Text
repositoryName :: Text
registryId :: Maybe Text
$sel:repositoryName:GetRepositoryCatalogData' :: GetRepositoryCatalogData -> Text
$sel:registryId:GetRepositoryCatalogData' :: GetRepositoryCatalogData -> 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,
            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 GetRepositoryCatalogData where
  toPath :: GetRepositoryCatalogData -> ByteString
toPath = ByteString -> GetRepositoryCatalogData -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

-- |
-- Create a value of 'GetRepositoryCatalogDataResponse' 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:
--
-- 'catalogData', 'getRepositoryCatalogDataResponse_catalogData' - The catalog metadata for the repository.
--
-- 'httpStatus', 'getRepositoryCatalogDataResponse_httpStatus' - The response's http status code.
newGetRepositoryCatalogDataResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetRepositoryCatalogDataResponse
newGetRepositoryCatalogDataResponse :: Int -> GetRepositoryCatalogDataResponse
newGetRepositoryCatalogDataResponse Int
pHttpStatus_ =
  GetRepositoryCatalogDataResponse' :: Maybe RepositoryCatalogData
-> Int -> GetRepositoryCatalogDataResponse
GetRepositoryCatalogDataResponse'
    { $sel:catalogData:GetRepositoryCatalogDataResponse' :: Maybe RepositoryCatalogData
catalogData =
        Maybe RepositoryCatalogData
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetRepositoryCatalogDataResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The catalog metadata for the repository.
getRepositoryCatalogDataResponse_catalogData :: Lens.Lens' GetRepositoryCatalogDataResponse (Prelude.Maybe RepositoryCatalogData)
getRepositoryCatalogDataResponse_catalogData :: (Maybe RepositoryCatalogData -> f (Maybe RepositoryCatalogData))
-> GetRepositoryCatalogDataResponse
-> f GetRepositoryCatalogDataResponse
getRepositoryCatalogDataResponse_catalogData = (GetRepositoryCatalogDataResponse -> Maybe RepositoryCatalogData)
-> (GetRepositoryCatalogDataResponse
    -> Maybe RepositoryCatalogData -> GetRepositoryCatalogDataResponse)
-> Lens
     GetRepositoryCatalogDataResponse
     GetRepositoryCatalogDataResponse
     (Maybe RepositoryCatalogData)
     (Maybe RepositoryCatalogData)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRepositoryCatalogDataResponse' {Maybe RepositoryCatalogData
catalogData :: Maybe RepositoryCatalogData
$sel:catalogData:GetRepositoryCatalogDataResponse' :: GetRepositoryCatalogDataResponse -> Maybe RepositoryCatalogData
catalogData} -> Maybe RepositoryCatalogData
catalogData) (\s :: GetRepositoryCatalogDataResponse
s@GetRepositoryCatalogDataResponse' {} Maybe RepositoryCatalogData
a -> GetRepositoryCatalogDataResponse
s {$sel:catalogData:GetRepositoryCatalogDataResponse' :: Maybe RepositoryCatalogData
catalogData = Maybe RepositoryCatalogData
a} :: GetRepositoryCatalogDataResponse)

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

instance
  Prelude.NFData
    GetRepositoryCatalogDataResponse