{-# 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.ECR.DescribeRegistry
-- 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)
--
-- Describes the settings for a registry. The replication configuration for
-- a repository can be created or updated with the
-- PutReplicationConfiguration API action.
module Amazonka.ECR.DescribeRegistry
  ( -- * Creating a Request
    DescribeRegistry (..),
    newDescribeRegistry,

    -- * Destructuring the Response
    DescribeRegistryResponse (..),
    newDescribeRegistryResponse,

    -- * Response Lenses
    describeRegistryResponse_replicationConfiguration,
    describeRegistryResponse_registryId,
    describeRegistryResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.ECR.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:/ 'newDescribeRegistry' smart constructor.
data DescribeRegistry = DescribeRegistry'
  {
  }
  deriving (DescribeRegistry -> DescribeRegistry -> Bool
(DescribeRegistry -> DescribeRegistry -> Bool)
-> (DescribeRegistry -> DescribeRegistry -> Bool)
-> Eq DescribeRegistry
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeRegistry -> DescribeRegistry -> Bool
$c/= :: DescribeRegistry -> DescribeRegistry -> Bool
== :: DescribeRegistry -> DescribeRegistry -> Bool
$c== :: DescribeRegistry -> DescribeRegistry -> Bool
Prelude.Eq, ReadPrec [DescribeRegistry]
ReadPrec DescribeRegistry
Int -> ReadS DescribeRegistry
ReadS [DescribeRegistry]
(Int -> ReadS DescribeRegistry)
-> ReadS [DescribeRegistry]
-> ReadPrec DescribeRegistry
-> ReadPrec [DescribeRegistry]
-> Read DescribeRegistry
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeRegistry]
$creadListPrec :: ReadPrec [DescribeRegistry]
readPrec :: ReadPrec DescribeRegistry
$creadPrec :: ReadPrec DescribeRegistry
readList :: ReadS [DescribeRegistry]
$creadList :: ReadS [DescribeRegistry]
readsPrec :: Int -> ReadS DescribeRegistry
$creadsPrec :: Int -> ReadS DescribeRegistry
Prelude.Read, Int -> DescribeRegistry -> ShowS
[DescribeRegistry] -> ShowS
DescribeRegistry -> String
(Int -> DescribeRegistry -> ShowS)
-> (DescribeRegistry -> String)
-> ([DescribeRegistry] -> ShowS)
-> Show DescribeRegistry
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeRegistry] -> ShowS
$cshowList :: [DescribeRegistry] -> ShowS
show :: DescribeRegistry -> String
$cshow :: DescribeRegistry -> String
showsPrec :: Int -> DescribeRegistry -> ShowS
$cshowsPrec :: Int -> DescribeRegistry -> ShowS
Prelude.Show, (forall x. DescribeRegistry -> Rep DescribeRegistry x)
-> (forall x. Rep DescribeRegistry x -> DescribeRegistry)
-> Generic DescribeRegistry
forall x. Rep DescribeRegistry x -> DescribeRegistry
forall x. DescribeRegistry -> Rep DescribeRegistry x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeRegistry x -> DescribeRegistry
$cfrom :: forall x. DescribeRegistry -> Rep DescribeRegistry x
Prelude.Generic)

-- |
-- Create a value of 'DescribeRegistry' 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.
newDescribeRegistry ::
  DescribeRegistry
newDescribeRegistry :: DescribeRegistry
newDescribeRegistry = DescribeRegistry
DescribeRegistry'

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

instance Prelude.NFData DescribeRegistry

instance Core.ToHeaders DescribeRegistry where
  toHeaders :: DescribeRegistry -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeRegistry -> 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
"AmazonEC2ContainerRegistry_V20150921.DescribeRegistry" ::
                          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 DescribeRegistry where
  toJSON :: DescribeRegistry -> Value
toJSON = Value -> DescribeRegistry -> Value
forall a b. a -> b -> a
Prelude.const (Object -> Value
Core.Object Object
forall a. Monoid a => a
Prelude.mempty)

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

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

-- | /See:/ 'newDescribeRegistryResponse' smart constructor.
data DescribeRegistryResponse = DescribeRegistryResponse'
  { -- | The replication configuration for the registry.
    DescribeRegistryResponse -> Maybe ReplicationConfiguration
replicationConfiguration :: Prelude.Maybe ReplicationConfiguration,
    -- | The ID of the registry.
    DescribeRegistryResponse -> Maybe Text
registryId :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    DescribeRegistryResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeRegistryResponse -> DescribeRegistryResponse -> Bool
(DescribeRegistryResponse -> DescribeRegistryResponse -> Bool)
-> (DescribeRegistryResponse -> DescribeRegistryResponse -> Bool)
-> Eq DescribeRegistryResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeRegistryResponse -> DescribeRegistryResponse -> Bool
$c/= :: DescribeRegistryResponse -> DescribeRegistryResponse -> Bool
== :: DescribeRegistryResponse -> DescribeRegistryResponse -> Bool
$c== :: DescribeRegistryResponse -> DescribeRegistryResponse -> Bool
Prelude.Eq, ReadPrec [DescribeRegistryResponse]
ReadPrec DescribeRegistryResponse
Int -> ReadS DescribeRegistryResponse
ReadS [DescribeRegistryResponse]
(Int -> ReadS DescribeRegistryResponse)
-> ReadS [DescribeRegistryResponse]
-> ReadPrec DescribeRegistryResponse
-> ReadPrec [DescribeRegistryResponse]
-> Read DescribeRegistryResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeRegistryResponse]
$creadListPrec :: ReadPrec [DescribeRegistryResponse]
readPrec :: ReadPrec DescribeRegistryResponse
$creadPrec :: ReadPrec DescribeRegistryResponse
readList :: ReadS [DescribeRegistryResponse]
$creadList :: ReadS [DescribeRegistryResponse]
readsPrec :: Int -> ReadS DescribeRegistryResponse
$creadsPrec :: Int -> ReadS DescribeRegistryResponse
Prelude.Read, Int -> DescribeRegistryResponse -> ShowS
[DescribeRegistryResponse] -> ShowS
DescribeRegistryResponse -> String
(Int -> DescribeRegistryResponse -> ShowS)
-> (DescribeRegistryResponse -> String)
-> ([DescribeRegistryResponse] -> ShowS)
-> Show DescribeRegistryResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeRegistryResponse] -> ShowS
$cshowList :: [DescribeRegistryResponse] -> ShowS
show :: DescribeRegistryResponse -> String
$cshow :: DescribeRegistryResponse -> String
showsPrec :: Int -> DescribeRegistryResponse -> ShowS
$cshowsPrec :: Int -> DescribeRegistryResponse -> ShowS
Prelude.Show, (forall x.
 DescribeRegistryResponse -> Rep DescribeRegistryResponse x)
-> (forall x.
    Rep DescribeRegistryResponse x -> DescribeRegistryResponse)
-> Generic DescribeRegistryResponse
forall x.
Rep DescribeRegistryResponse x -> DescribeRegistryResponse
forall x.
DescribeRegistryResponse -> Rep DescribeRegistryResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeRegistryResponse x -> DescribeRegistryResponse
$cfrom :: forall x.
DescribeRegistryResponse -> Rep DescribeRegistryResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeRegistryResponse' 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:
--
-- 'replicationConfiguration', 'describeRegistryResponse_replicationConfiguration' - The replication configuration for the registry.
--
-- 'registryId', 'describeRegistryResponse_registryId' - The ID of the registry.
--
-- 'httpStatus', 'describeRegistryResponse_httpStatus' - The response's http status code.
newDescribeRegistryResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeRegistryResponse
newDescribeRegistryResponse :: Int -> DescribeRegistryResponse
newDescribeRegistryResponse Int
pHttpStatus_ =
  DescribeRegistryResponse' :: Maybe ReplicationConfiguration
-> Maybe Text -> Int -> DescribeRegistryResponse
DescribeRegistryResponse'
    { $sel:replicationConfiguration:DescribeRegistryResponse' :: Maybe ReplicationConfiguration
replicationConfiguration =
        Maybe ReplicationConfiguration
forall a. Maybe a
Prelude.Nothing,
      $sel:registryId:DescribeRegistryResponse' :: Maybe Text
registryId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeRegistryResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The replication configuration for the registry.
describeRegistryResponse_replicationConfiguration :: Lens.Lens' DescribeRegistryResponse (Prelude.Maybe ReplicationConfiguration)
describeRegistryResponse_replicationConfiguration :: (Maybe ReplicationConfiguration
 -> f (Maybe ReplicationConfiguration))
-> DescribeRegistryResponse -> f DescribeRegistryResponse
describeRegistryResponse_replicationConfiguration = (DescribeRegistryResponse -> Maybe ReplicationConfiguration)
-> (DescribeRegistryResponse
    -> Maybe ReplicationConfiguration -> DescribeRegistryResponse)
-> Lens
     DescribeRegistryResponse
     DescribeRegistryResponse
     (Maybe ReplicationConfiguration)
     (Maybe ReplicationConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeRegistryResponse' {Maybe ReplicationConfiguration
replicationConfiguration :: Maybe ReplicationConfiguration
$sel:replicationConfiguration:DescribeRegistryResponse' :: DescribeRegistryResponse -> Maybe ReplicationConfiguration
replicationConfiguration} -> Maybe ReplicationConfiguration
replicationConfiguration) (\s :: DescribeRegistryResponse
s@DescribeRegistryResponse' {} Maybe ReplicationConfiguration
a -> DescribeRegistryResponse
s {$sel:replicationConfiguration:DescribeRegistryResponse' :: Maybe ReplicationConfiguration
replicationConfiguration = Maybe ReplicationConfiguration
a} :: DescribeRegistryResponse)

-- | The ID of the registry.
describeRegistryResponse_registryId :: Lens.Lens' DescribeRegistryResponse (Prelude.Maybe Prelude.Text)
describeRegistryResponse_registryId :: (Maybe Text -> f (Maybe Text))
-> DescribeRegistryResponse -> f DescribeRegistryResponse
describeRegistryResponse_registryId = (DescribeRegistryResponse -> Maybe Text)
-> (DescribeRegistryResponse
    -> Maybe Text -> DescribeRegistryResponse)
-> Lens
     DescribeRegistryResponse
     DescribeRegistryResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeRegistryResponse' {Maybe Text
registryId :: Maybe Text
$sel:registryId:DescribeRegistryResponse' :: DescribeRegistryResponse -> Maybe Text
registryId} -> Maybe Text
registryId) (\s :: DescribeRegistryResponse
s@DescribeRegistryResponse' {} Maybe Text
a -> DescribeRegistryResponse
s {$sel:registryId:DescribeRegistryResponse' :: Maybe Text
registryId = Maybe Text
a} :: DescribeRegistryResponse)

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

instance Prelude.NFData DescribeRegistryResponse