{-# 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 #-}
module Amazonka.ECR.GetRepositoryPolicy
(
GetRepositoryPolicy (..),
newGetRepositoryPolicy,
getRepositoryPolicy_registryId,
getRepositoryPolicy_repositoryName,
GetRepositoryPolicyResponse (..),
newGetRepositoryPolicyResponse,
getRepositoryPolicyResponse_registryId,
getRepositoryPolicyResponse_repositoryName,
getRepositoryPolicyResponse_policyText,
getRepositoryPolicyResponse_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
data GetRepositoryPolicy = GetRepositoryPolicy'
{
GetRepositoryPolicy -> Maybe Text
registryId :: Prelude.Maybe Prelude.Text,
GetRepositoryPolicy -> Text
repositoryName :: Prelude.Text
}
deriving (GetRepositoryPolicy -> GetRepositoryPolicy -> Bool
(GetRepositoryPolicy -> GetRepositoryPolicy -> Bool)
-> (GetRepositoryPolicy -> GetRepositoryPolicy -> Bool)
-> Eq GetRepositoryPolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetRepositoryPolicy -> GetRepositoryPolicy -> Bool
$c/= :: GetRepositoryPolicy -> GetRepositoryPolicy -> Bool
== :: GetRepositoryPolicy -> GetRepositoryPolicy -> Bool
$c== :: GetRepositoryPolicy -> GetRepositoryPolicy -> Bool
Prelude.Eq, ReadPrec [GetRepositoryPolicy]
ReadPrec GetRepositoryPolicy
Int -> ReadS GetRepositoryPolicy
ReadS [GetRepositoryPolicy]
(Int -> ReadS GetRepositoryPolicy)
-> ReadS [GetRepositoryPolicy]
-> ReadPrec GetRepositoryPolicy
-> ReadPrec [GetRepositoryPolicy]
-> Read GetRepositoryPolicy
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetRepositoryPolicy]
$creadListPrec :: ReadPrec [GetRepositoryPolicy]
readPrec :: ReadPrec GetRepositoryPolicy
$creadPrec :: ReadPrec GetRepositoryPolicy
readList :: ReadS [GetRepositoryPolicy]
$creadList :: ReadS [GetRepositoryPolicy]
readsPrec :: Int -> ReadS GetRepositoryPolicy
$creadsPrec :: Int -> ReadS GetRepositoryPolicy
Prelude.Read, Int -> GetRepositoryPolicy -> ShowS
[GetRepositoryPolicy] -> ShowS
GetRepositoryPolicy -> String
(Int -> GetRepositoryPolicy -> ShowS)
-> (GetRepositoryPolicy -> String)
-> ([GetRepositoryPolicy] -> ShowS)
-> Show GetRepositoryPolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetRepositoryPolicy] -> ShowS
$cshowList :: [GetRepositoryPolicy] -> ShowS
show :: GetRepositoryPolicy -> String
$cshow :: GetRepositoryPolicy -> String
showsPrec :: Int -> GetRepositoryPolicy -> ShowS
$cshowsPrec :: Int -> GetRepositoryPolicy -> ShowS
Prelude.Show, (forall x. GetRepositoryPolicy -> Rep GetRepositoryPolicy x)
-> (forall x. Rep GetRepositoryPolicy x -> GetRepositoryPolicy)
-> Generic GetRepositoryPolicy
forall x. Rep GetRepositoryPolicy x -> GetRepositoryPolicy
forall x. GetRepositoryPolicy -> Rep GetRepositoryPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetRepositoryPolicy x -> GetRepositoryPolicy
$cfrom :: forall x. GetRepositoryPolicy -> Rep GetRepositoryPolicy x
Prelude.Generic)
newGetRepositoryPolicy ::
Prelude.Text ->
GetRepositoryPolicy
newGetRepositoryPolicy :: Text -> GetRepositoryPolicy
newGetRepositoryPolicy Text
pRepositoryName_ =
GetRepositoryPolicy' :: Maybe Text -> Text -> GetRepositoryPolicy
GetRepositoryPolicy'
{ $sel:registryId:GetRepositoryPolicy' :: Maybe Text
registryId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:repositoryName:GetRepositoryPolicy' :: Text
repositoryName = Text
pRepositoryName_
}
getRepositoryPolicy_registryId :: Lens.Lens' GetRepositoryPolicy (Prelude.Maybe Prelude.Text)
getRepositoryPolicy_registryId :: (Maybe Text -> f (Maybe Text))
-> GetRepositoryPolicy -> f GetRepositoryPolicy
getRepositoryPolicy_registryId = (GetRepositoryPolicy -> Maybe Text)
-> (GetRepositoryPolicy -> Maybe Text -> GetRepositoryPolicy)
-> Lens
GetRepositoryPolicy GetRepositoryPolicy (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRepositoryPolicy' {Maybe Text
registryId :: Maybe Text
$sel:registryId:GetRepositoryPolicy' :: GetRepositoryPolicy -> Maybe Text
registryId} -> Maybe Text
registryId) (\s :: GetRepositoryPolicy
s@GetRepositoryPolicy' {} Maybe Text
a -> GetRepositoryPolicy
s {$sel:registryId:GetRepositoryPolicy' :: Maybe Text
registryId = Maybe Text
a} :: GetRepositoryPolicy)
getRepositoryPolicy_repositoryName :: Lens.Lens' GetRepositoryPolicy Prelude.Text
getRepositoryPolicy_repositoryName :: (Text -> f Text) -> GetRepositoryPolicy -> f GetRepositoryPolicy
getRepositoryPolicy_repositoryName = (GetRepositoryPolicy -> Text)
-> (GetRepositoryPolicy -> Text -> GetRepositoryPolicy)
-> Lens GetRepositoryPolicy GetRepositoryPolicy Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRepositoryPolicy' {Text
repositoryName :: Text
$sel:repositoryName:GetRepositoryPolicy' :: GetRepositoryPolicy -> Text
repositoryName} -> Text
repositoryName) (\s :: GetRepositoryPolicy
s@GetRepositoryPolicy' {} Text
a -> GetRepositoryPolicy
s {$sel:repositoryName:GetRepositoryPolicy' :: Text
repositoryName = Text
a} :: GetRepositoryPolicy)
instance Core.AWSRequest GetRepositoryPolicy where
type
AWSResponse GetRepositoryPolicy =
GetRepositoryPolicyResponse
request :: GetRepositoryPolicy -> Request GetRepositoryPolicy
request = Service -> GetRepositoryPolicy -> Request GetRepositoryPolicy
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy GetRepositoryPolicy
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse GetRepositoryPolicy)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse GetRepositoryPolicy))
-> Logger
-> Service
-> Proxy GetRepositoryPolicy
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse GetRepositoryPolicy)))
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 Text
-> Maybe Text -> Maybe Text -> Int -> GetRepositoryPolicyResponse
GetRepositoryPolicyResponse'
(Maybe Text
-> Maybe Text -> Maybe Text -> Int -> GetRepositoryPolicyResponse)
-> Either String (Maybe Text)
-> Either
String
(Maybe Text -> Maybe Text -> Int -> GetRepositoryPolicyResponse)
forall (f :: * -> *) a b. Functor 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
(Maybe Text -> Maybe Text -> Int -> GetRepositoryPolicyResponse)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> Int -> GetRepositoryPolicyResponse)
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
"repositoryName")
Either String (Maybe Text -> Int -> GetRepositoryPolicyResponse)
-> Either String (Maybe Text)
-> Either String (Int -> GetRepositoryPolicyResponse)
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
"policyText")
Either String (Int -> GetRepositoryPolicyResponse)
-> Either String Int -> Either String GetRepositoryPolicyResponse
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 GetRepositoryPolicy
instance Prelude.NFData GetRepositoryPolicy
instance Core.ToHeaders GetRepositoryPolicy where
toHeaders :: GetRepositoryPolicy -> ResponseHeaders
toHeaders =
ResponseHeaders -> GetRepositoryPolicy -> 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.GetRepositoryPolicy" ::
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 GetRepositoryPolicy where
toJSON :: GetRepositoryPolicy -> Value
toJSON GetRepositoryPolicy' {Maybe Text
Text
repositoryName :: Text
registryId :: Maybe Text
$sel:repositoryName:GetRepositoryPolicy' :: GetRepositoryPolicy -> Text
$sel:registryId:GetRepositoryPolicy' :: GetRepositoryPolicy -> 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 GetRepositoryPolicy where
toPath :: GetRepositoryPolicy -> ByteString
toPath = ByteString -> GetRepositoryPolicy -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery GetRepositoryPolicy where
toQuery :: GetRepositoryPolicy -> QueryString
toQuery = QueryString -> GetRepositoryPolicy -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data GetRepositoryPolicyResponse = GetRepositoryPolicyResponse'
{
GetRepositoryPolicyResponse -> Maybe Text
registryId :: Prelude.Maybe Prelude.Text,
GetRepositoryPolicyResponse -> Maybe Text
repositoryName :: Prelude.Maybe Prelude.Text,
GetRepositoryPolicyResponse -> Maybe Text
policyText :: Prelude.Maybe Prelude.Text,
GetRepositoryPolicyResponse -> Int
httpStatus :: Prelude.Int
}
deriving (GetRepositoryPolicyResponse -> GetRepositoryPolicyResponse -> Bool
(GetRepositoryPolicyResponse
-> GetRepositoryPolicyResponse -> Bool)
-> (GetRepositoryPolicyResponse
-> GetRepositoryPolicyResponse -> Bool)
-> Eq GetRepositoryPolicyResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetRepositoryPolicyResponse -> GetRepositoryPolicyResponse -> Bool
$c/= :: GetRepositoryPolicyResponse -> GetRepositoryPolicyResponse -> Bool
== :: GetRepositoryPolicyResponse -> GetRepositoryPolicyResponse -> Bool
$c== :: GetRepositoryPolicyResponse -> GetRepositoryPolicyResponse -> Bool
Prelude.Eq, ReadPrec [GetRepositoryPolicyResponse]
ReadPrec GetRepositoryPolicyResponse
Int -> ReadS GetRepositoryPolicyResponse
ReadS [GetRepositoryPolicyResponse]
(Int -> ReadS GetRepositoryPolicyResponse)
-> ReadS [GetRepositoryPolicyResponse]
-> ReadPrec GetRepositoryPolicyResponse
-> ReadPrec [GetRepositoryPolicyResponse]
-> Read GetRepositoryPolicyResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetRepositoryPolicyResponse]
$creadListPrec :: ReadPrec [GetRepositoryPolicyResponse]
readPrec :: ReadPrec GetRepositoryPolicyResponse
$creadPrec :: ReadPrec GetRepositoryPolicyResponse
readList :: ReadS [GetRepositoryPolicyResponse]
$creadList :: ReadS [GetRepositoryPolicyResponse]
readsPrec :: Int -> ReadS GetRepositoryPolicyResponse
$creadsPrec :: Int -> ReadS GetRepositoryPolicyResponse
Prelude.Read, Int -> GetRepositoryPolicyResponse -> ShowS
[GetRepositoryPolicyResponse] -> ShowS
GetRepositoryPolicyResponse -> String
(Int -> GetRepositoryPolicyResponse -> ShowS)
-> (GetRepositoryPolicyResponse -> String)
-> ([GetRepositoryPolicyResponse] -> ShowS)
-> Show GetRepositoryPolicyResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetRepositoryPolicyResponse] -> ShowS
$cshowList :: [GetRepositoryPolicyResponse] -> ShowS
show :: GetRepositoryPolicyResponse -> String
$cshow :: GetRepositoryPolicyResponse -> String
showsPrec :: Int -> GetRepositoryPolicyResponse -> ShowS
$cshowsPrec :: Int -> GetRepositoryPolicyResponse -> ShowS
Prelude.Show, (forall x.
GetRepositoryPolicyResponse -> Rep GetRepositoryPolicyResponse x)
-> (forall x.
Rep GetRepositoryPolicyResponse x -> GetRepositoryPolicyResponse)
-> Generic GetRepositoryPolicyResponse
forall x.
Rep GetRepositoryPolicyResponse x -> GetRepositoryPolicyResponse
forall x.
GetRepositoryPolicyResponse -> Rep GetRepositoryPolicyResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetRepositoryPolicyResponse x -> GetRepositoryPolicyResponse
$cfrom :: forall x.
GetRepositoryPolicyResponse -> Rep GetRepositoryPolicyResponse x
Prelude.Generic)
newGetRepositoryPolicyResponse ::
Prelude.Int ->
GetRepositoryPolicyResponse
newGetRepositoryPolicyResponse :: Int -> GetRepositoryPolicyResponse
newGetRepositoryPolicyResponse Int
pHttpStatus_ =
GetRepositoryPolicyResponse' :: Maybe Text
-> Maybe Text -> Maybe Text -> Int -> GetRepositoryPolicyResponse
GetRepositoryPolicyResponse'
{ $sel:registryId:GetRepositoryPolicyResponse' :: Maybe Text
registryId =
Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:repositoryName:GetRepositoryPolicyResponse' :: Maybe Text
repositoryName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:policyText:GetRepositoryPolicyResponse' :: Maybe Text
policyText = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:GetRepositoryPolicyResponse' :: Int
httpStatus = Int
pHttpStatus_
}
getRepositoryPolicyResponse_registryId :: Lens.Lens' GetRepositoryPolicyResponse (Prelude.Maybe Prelude.Text)
getRepositoryPolicyResponse_registryId :: (Maybe Text -> f (Maybe Text))
-> GetRepositoryPolicyResponse -> f GetRepositoryPolicyResponse
getRepositoryPolicyResponse_registryId = (GetRepositoryPolicyResponse -> Maybe Text)
-> (GetRepositoryPolicyResponse
-> Maybe Text -> GetRepositoryPolicyResponse)
-> Lens
GetRepositoryPolicyResponse
GetRepositoryPolicyResponse
(Maybe Text)
(Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRepositoryPolicyResponse' {Maybe Text
registryId :: Maybe Text
$sel:registryId:GetRepositoryPolicyResponse' :: GetRepositoryPolicyResponse -> Maybe Text
registryId} -> Maybe Text
registryId) (\s :: GetRepositoryPolicyResponse
s@GetRepositoryPolicyResponse' {} Maybe Text
a -> GetRepositoryPolicyResponse
s {$sel:registryId:GetRepositoryPolicyResponse' :: Maybe Text
registryId = Maybe Text
a} :: GetRepositoryPolicyResponse)
getRepositoryPolicyResponse_repositoryName :: Lens.Lens' GetRepositoryPolicyResponse (Prelude.Maybe Prelude.Text)
getRepositoryPolicyResponse_repositoryName :: (Maybe Text -> f (Maybe Text))
-> GetRepositoryPolicyResponse -> f GetRepositoryPolicyResponse
getRepositoryPolicyResponse_repositoryName = (GetRepositoryPolicyResponse -> Maybe Text)
-> (GetRepositoryPolicyResponse
-> Maybe Text -> GetRepositoryPolicyResponse)
-> Lens
GetRepositoryPolicyResponse
GetRepositoryPolicyResponse
(Maybe Text)
(Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRepositoryPolicyResponse' {Maybe Text
repositoryName :: Maybe Text
$sel:repositoryName:GetRepositoryPolicyResponse' :: GetRepositoryPolicyResponse -> Maybe Text
repositoryName} -> Maybe Text
repositoryName) (\s :: GetRepositoryPolicyResponse
s@GetRepositoryPolicyResponse' {} Maybe Text
a -> GetRepositoryPolicyResponse
s {$sel:repositoryName:GetRepositoryPolicyResponse' :: Maybe Text
repositoryName = Maybe Text
a} :: GetRepositoryPolicyResponse)
getRepositoryPolicyResponse_policyText :: Lens.Lens' GetRepositoryPolicyResponse (Prelude.Maybe Prelude.Text)
getRepositoryPolicyResponse_policyText :: (Maybe Text -> f (Maybe Text))
-> GetRepositoryPolicyResponse -> f GetRepositoryPolicyResponse
getRepositoryPolicyResponse_policyText = (GetRepositoryPolicyResponse -> Maybe Text)
-> (GetRepositoryPolicyResponse
-> Maybe Text -> GetRepositoryPolicyResponse)
-> Lens
GetRepositoryPolicyResponse
GetRepositoryPolicyResponse
(Maybe Text)
(Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRepositoryPolicyResponse' {Maybe Text
policyText :: Maybe Text
$sel:policyText:GetRepositoryPolicyResponse' :: GetRepositoryPolicyResponse -> Maybe Text
policyText} -> Maybe Text
policyText) (\s :: GetRepositoryPolicyResponse
s@GetRepositoryPolicyResponse' {} Maybe Text
a -> GetRepositoryPolicyResponse
s {$sel:policyText:GetRepositoryPolicyResponse' :: Maybe Text
policyText = Maybe Text
a} :: GetRepositoryPolicyResponse)
getRepositoryPolicyResponse_httpStatus :: Lens.Lens' GetRepositoryPolicyResponse Prelude.Int
getRepositoryPolicyResponse_httpStatus :: (Int -> f Int)
-> GetRepositoryPolicyResponse -> f GetRepositoryPolicyResponse
getRepositoryPolicyResponse_httpStatus = (GetRepositoryPolicyResponse -> Int)
-> (GetRepositoryPolicyResponse
-> Int -> GetRepositoryPolicyResponse)
-> Lens
GetRepositoryPolicyResponse GetRepositoryPolicyResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRepositoryPolicyResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetRepositoryPolicyResponse' :: GetRepositoryPolicyResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetRepositoryPolicyResponse
s@GetRepositoryPolicyResponse' {} Int
a -> GetRepositoryPolicyResponse
s {$sel:httpStatus:GetRepositoryPolicyResponse' :: Int
httpStatus = Int
a} :: GetRepositoryPolicyResponse)
instance Prelude.NFData GetRepositoryPolicyResponse