{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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 qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.ECRPublic.Types
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
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]
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
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.
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'
    { $sel:registryId:GetRepositoryCatalogData' :: Maybe Text
registryId =
        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 :: Lens' GetRepositoryCatalogData (Maybe Text)
getRepositoryCatalogData_registryId = 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 :: Lens' GetRepositoryCatalogData Text
getRepositoryCatalogData_repositoryName = 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 :: (Service -> Service)
-> GetRepositoryCatalogData -> Request GetRepositoryCatalogData
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 GetRepositoryCatalogData
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetRepositoryCatalogData)))
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 RepositoryCatalogData
-> Int -> GetRepositoryCatalogDataResponse
GetRepositoryCatalogDataResponse'
            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
"catalogData")
            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 GetRepositoryCatalogData where
  hashWithSalt :: Int -> GetRepositoryCatalogData -> Int
hashWithSalt Int
_salt GetRepositoryCatalogData' {Maybe Text
Text
repositoryName :: Text
registryId :: Maybe Text
$sel:repositoryName:GetRepositoryCatalogData' :: GetRepositoryCatalogData -> Text
$sel:registryId:GetRepositoryCatalogData' :: GetRepositoryCatalogData -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
registryId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
repositoryName

instance Prelude.NFData GetRepositoryCatalogData where
  rnf :: GetRepositoryCatalogData -> ()
rnf GetRepositoryCatalogData' {Maybe Text
Text
repositoryName :: Text
registryId :: Maybe Text
$sel:repositoryName:GetRepositoryCatalogData' :: GetRepositoryCatalogData -> Text
$sel:registryId:GetRepositoryCatalogData' :: GetRepositoryCatalogData -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
registryId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
repositoryName

instance Data.ToHeaders GetRepositoryCatalogData where
  toHeaders :: GetRepositoryCatalogData -> 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
"SpencerFrontendService.GetRepositoryCatalogData" ::
                          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 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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"registryId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
registryId,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"repositoryName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
repositoryName)
          ]
      )

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

instance Data.ToQuery GetRepositoryCatalogData where
  toQuery :: GetRepositoryCatalogData -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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.
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'
    { $sel:catalogData:GetRepositoryCatalogDataResponse' :: Maybe RepositoryCatalogData
catalogData =
        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 :: Lens'
  GetRepositoryCatalogDataResponse (Maybe RepositoryCatalogData)
getRepositoryCatalogDataResponse_catalogData = 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 :: Lens' GetRepositoryCatalogDataResponse Int
getRepositoryCatalogDataResponse_httpStatus = 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
  where
  rnf :: GetRepositoryCatalogDataResponse -> ()
rnf GetRepositoryCatalogDataResponse' {Int
Maybe RepositoryCatalogData
httpStatus :: Int
catalogData :: Maybe RepositoryCatalogData
$sel:httpStatus:GetRepositoryCatalogDataResponse' :: GetRepositoryCatalogDataResponse -> Int
$sel:catalogData:GetRepositoryCatalogDataResponse' :: GetRepositoryCatalogDataResponse -> Maybe RepositoryCatalogData
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe RepositoryCatalogData
catalogData
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus