{-# 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.PutRegistryPolicy
(
PutRegistryPolicy (..),
newPutRegistryPolicy,
putRegistryPolicy_policyText,
PutRegistryPolicyResponse (..),
newPutRegistryPolicyResponse,
putRegistryPolicyResponse_registryId,
putRegistryPolicyResponse_policyText,
putRegistryPolicyResponse_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 PutRegistryPolicy = PutRegistryPolicy'
{
PutRegistryPolicy -> Text
policyText :: Prelude.Text
}
deriving (PutRegistryPolicy -> PutRegistryPolicy -> Bool
(PutRegistryPolicy -> PutRegistryPolicy -> Bool)
-> (PutRegistryPolicy -> PutRegistryPolicy -> Bool)
-> Eq PutRegistryPolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutRegistryPolicy -> PutRegistryPolicy -> Bool
$c/= :: PutRegistryPolicy -> PutRegistryPolicy -> Bool
== :: PutRegistryPolicy -> PutRegistryPolicy -> Bool
$c== :: PutRegistryPolicy -> PutRegistryPolicy -> Bool
Prelude.Eq, ReadPrec [PutRegistryPolicy]
ReadPrec PutRegistryPolicy
Int -> ReadS PutRegistryPolicy
ReadS [PutRegistryPolicy]
(Int -> ReadS PutRegistryPolicy)
-> ReadS [PutRegistryPolicy]
-> ReadPrec PutRegistryPolicy
-> ReadPrec [PutRegistryPolicy]
-> Read PutRegistryPolicy
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutRegistryPolicy]
$creadListPrec :: ReadPrec [PutRegistryPolicy]
readPrec :: ReadPrec PutRegistryPolicy
$creadPrec :: ReadPrec PutRegistryPolicy
readList :: ReadS [PutRegistryPolicy]
$creadList :: ReadS [PutRegistryPolicy]
readsPrec :: Int -> ReadS PutRegistryPolicy
$creadsPrec :: Int -> ReadS PutRegistryPolicy
Prelude.Read, Int -> PutRegistryPolicy -> ShowS
[PutRegistryPolicy] -> ShowS
PutRegistryPolicy -> String
(Int -> PutRegistryPolicy -> ShowS)
-> (PutRegistryPolicy -> String)
-> ([PutRegistryPolicy] -> ShowS)
-> Show PutRegistryPolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutRegistryPolicy] -> ShowS
$cshowList :: [PutRegistryPolicy] -> ShowS
show :: PutRegistryPolicy -> String
$cshow :: PutRegistryPolicy -> String
showsPrec :: Int -> PutRegistryPolicy -> ShowS
$cshowsPrec :: Int -> PutRegistryPolicy -> ShowS
Prelude.Show, (forall x. PutRegistryPolicy -> Rep PutRegistryPolicy x)
-> (forall x. Rep PutRegistryPolicy x -> PutRegistryPolicy)
-> Generic PutRegistryPolicy
forall x. Rep PutRegistryPolicy x -> PutRegistryPolicy
forall x. PutRegistryPolicy -> Rep PutRegistryPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutRegistryPolicy x -> PutRegistryPolicy
$cfrom :: forall x. PutRegistryPolicy -> Rep PutRegistryPolicy x
Prelude.Generic)
newPutRegistryPolicy ::
Prelude.Text ->
PutRegistryPolicy
newPutRegistryPolicy :: Text -> PutRegistryPolicy
newPutRegistryPolicy Text
pPolicyText_ =
PutRegistryPolicy' :: Text -> PutRegistryPolicy
PutRegistryPolicy' {$sel:policyText:PutRegistryPolicy' :: Text
policyText = Text
pPolicyText_}
putRegistryPolicy_policyText :: Lens.Lens' PutRegistryPolicy Prelude.Text
putRegistryPolicy_policyText :: (Text -> f Text) -> PutRegistryPolicy -> f PutRegistryPolicy
putRegistryPolicy_policyText = (PutRegistryPolicy -> Text)
-> (PutRegistryPolicy -> Text -> PutRegistryPolicy)
-> Lens PutRegistryPolicy PutRegistryPolicy Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutRegistryPolicy' {Text
policyText :: Text
$sel:policyText:PutRegistryPolicy' :: PutRegistryPolicy -> Text
policyText} -> Text
policyText) (\s :: PutRegistryPolicy
s@PutRegistryPolicy' {} Text
a -> PutRegistryPolicy
s {$sel:policyText:PutRegistryPolicy' :: Text
policyText = Text
a} :: PutRegistryPolicy)
instance Core.AWSRequest PutRegistryPolicy where
type
AWSResponse PutRegistryPolicy =
PutRegistryPolicyResponse
request :: PutRegistryPolicy -> Request PutRegistryPolicy
request = Service -> PutRegistryPolicy -> Request PutRegistryPolicy
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy PutRegistryPolicy
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse PutRegistryPolicy)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse PutRegistryPolicy))
-> Logger
-> Service
-> Proxy PutRegistryPolicy
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse PutRegistryPolicy)))
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 -> Int -> PutRegistryPolicyResponse
PutRegistryPolicyResponse'
(Maybe Text -> Maybe Text -> Int -> PutRegistryPolicyResponse)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> Int -> PutRegistryPolicyResponse)
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 -> Int -> PutRegistryPolicyResponse)
-> Either String (Maybe Text)
-> Either String (Int -> PutRegistryPolicyResponse)
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 -> PutRegistryPolicyResponse)
-> Either String Int -> Either String PutRegistryPolicyResponse
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 PutRegistryPolicy
instance Prelude.NFData PutRegistryPolicy
instance Core.ToHeaders PutRegistryPolicy where
toHeaders :: PutRegistryPolicy -> ResponseHeaders
toHeaders =
ResponseHeaders -> PutRegistryPolicy -> 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.PutRegistryPolicy" ::
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 PutRegistryPolicy where
toJSON :: PutRegistryPolicy -> Value
toJSON PutRegistryPolicy' {Text
policyText :: Text
$sel:policyText:PutRegistryPolicy' :: PutRegistryPolicy -> Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"policyText" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
policyText)]
)
instance Core.ToPath PutRegistryPolicy where
toPath :: PutRegistryPolicy -> ByteString
toPath = ByteString -> PutRegistryPolicy -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery PutRegistryPolicy where
toQuery :: PutRegistryPolicy -> QueryString
toQuery = QueryString -> PutRegistryPolicy -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data PutRegistryPolicyResponse = PutRegistryPolicyResponse'
{
PutRegistryPolicyResponse -> Maybe Text
registryId :: Prelude.Maybe Prelude.Text,
PutRegistryPolicyResponse -> Maybe Text
policyText :: Prelude.Maybe Prelude.Text,
PutRegistryPolicyResponse -> Int
httpStatus :: Prelude.Int
}
deriving (PutRegistryPolicyResponse -> PutRegistryPolicyResponse -> Bool
(PutRegistryPolicyResponse -> PutRegistryPolicyResponse -> Bool)
-> (PutRegistryPolicyResponse -> PutRegistryPolicyResponse -> Bool)
-> Eq PutRegistryPolicyResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutRegistryPolicyResponse -> PutRegistryPolicyResponse -> Bool
$c/= :: PutRegistryPolicyResponse -> PutRegistryPolicyResponse -> Bool
== :: PutRegistryPolicyResponse -> PutRegistryPolicyResponse -> Bool
$c== :: PutRegistryPolicyResponse -> PutRegistryPolicyResponse -> Bool
Prelude.Eq, ReadPrec [PutRegistryPolicyResponse]
ReadPrec PutRegistryPolicyResponse
Int -> ReadS PutRegistryPolicyResponse
ReadS [PutRegistryPolicyResponse]
(Int -> ReadS PutRegistryPolicyResponse)
-> ReadS [PutRegistryPolicyResponse]
-> ReadPrec PutRegistryPolicyResponse
-> ReadPrec [PutRegistryPolicyResponse]
-> Read PutRegistryPolicyResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutRegistryPolicyResponse]
$creadListPrec :: ReadPrec [PutRegistryPolicyResponse]
readPrec :: ReadPrec PutRegistryPolicyResponse
$creadPrec :: ReadPrec PutRegistryPolicyResponse
readList :: ReadS [PutRegistryPolicyResponse]
$creadList :: ReadS [PutRegistryPolicyResponse]
readsPrec :: Int -> ReadS PutRegistryPolicyResponse
$creadsPrec :: Int -> ReadS PutRegistryPolicyResponse
Prelude.Read, Int -> PutRegistryPolicyResponse -> ShowS
[PutRegistryPolicyResponse] -> ShowS
PutRegistryPolicyResponse -> String
(Int -> PutRegistryPolicyResponse -> ShowS)
-> (PutRegistryPolicyResponse -> String)
-> ([PutRegistryPolicyResponse] -> ShowS)
-> Show PutRegistryPolicyResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutRegistryPolicyResponse] -> ShowS
$cshowList :: [PutRegistryPolicyResponse] -> ShowS
show :: PutRegistryPolicyResponse -> String
$cshow :: PutRegistryPolicyResponse -> String
showsPrec :: Int -> PutRegistryPolicyResponse -> ShowS
$cshowsPrec :: Int -> PutRegistryPolicyResponse -> ShowS
Prelude.Show, (forall x.
PutRegistryPolicyResponse -> Rep PutRegistryPolicyResponse x)
-> (forall x.
Rep PutRegistryPolicyResponse x -> PutRegistryPolicyResponse)
-> Generic PutRegistryPolicyResponse
forall x.
Rep PutRegistryPolicyResponse x -> PutRegistryPolicyResponse
forall x.
PutRegistryPolicyResponse -> Rep PutRegistryPolicyResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PutRegistryPolicyResponse x -> PutRegistryPolicyResponse
$cfrom :: forall x.
PutRegistryPolicyResponse -> Rep PutRegistryPolicyResponse x
Prelude.Generic)
newPutRegistryPolicyResponse ::
Prelude.Int ->
PutRegistryPolicyResponse
newPutRegistryPolicyResponse :: Int -> PutRegistryPolicyResponse
newPutRegistryPolicyResponse Int
pHttpStatus_ =
PutRegistryPolicyResponse' :: Maybe Text -> Maybe Text -> Int -> PutRegistryPolicyResponse
PutRegistryPolicyResponse'
{ $sel:registryId:PutRegistryPolicyResponse' :: Maybe Text
registryId =
Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:policyText:PutRegistryPolicyResponse' :: Maybe Text
policyText = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:PutRegistryPolicyResponse' :: Int
httpStatus = Int
pHttpStatus_
}
putRegistryPolicyResponse_registryId :: Lens.Lens' PutRegistryPolicyResponse (Prelude.Maybe Prelude.Text)
putRegistryPolicyResponse_registryId :: (Maybe Text -> f (Maybe Text))
-> PutRegistryPolicyResponse -> f PutRegistryPolicyResponse
putRegistryPolicyResponse_registryId = (PutRegistryPolicyResponse -> Maybe Text)
-> (PutRegistryPolicyResponse
-> Maybe Text -> PutRegistryPolicyResponse)
-> Lens
PutRegistryPolicyResponse
PutRegistryPolicyResponse
(Maybe Text)
(Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutRegistryPolicyResponse' {Maybe Text
registryId :: Maybe Text
$sel:registryId:PutRegistryPolicyResponse' :: PutRegistryPolicyResponse -> Maybe Text
registryId} -> Maybe Text
registryId) (\s :: PutRegistryPolicyResponse
s@PutRegistryPolicyResponse' {} Maybe Text
a -> PutRegistryPolicyResponse
s {$sel:registryId:PutRegistryPolicyResponse' :: Maybe Text
registryId = Maybe Text
a} :: PutRegistryPolicyResponse)
putRegistryPolicyResponse_policyText :: Lens.Lens' PutRegistryPolicyResponse (Prelude.Maybe Prelude.Text)
putRegistryPolicyResponse_policyText :: (Maybe Text -> f (Maybe Text))
-> PutRegistryPolicyResponse -> f PutRegistryPolicyResponse
putRegistryPolicyResponse_policyText = (PutRegistryPolicyResponse -> Maybe Text)
-> (PutRegistryPolicyResponse
-> Maybe Text -> PutRegistryPolicyResponse)
-> Lens
PutRegistryPolicyResponse
PutRegistryPolicyResponse
(Maybe Text)
(Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutRegistryPolicyResponse' {Maybe Text
policyText :: Maybe Text
$sel:policyText:PutRegistryPolicyResponse' :: PutRegistryPolicyResponse -> Maybe Text
policyText} -> Maybe Text
policyText) (\s :: PutRegistryPolicyResponse
s@PutRegistryPolicyResponse' {} Maybe Text
a -> PutRegistryPolicyResponse
s {$sel:policyText:PutRegistryPolicyResponse' :: Maybe Text
policyText = Maybe Text
a} :: PutRegistryPolicyResponse)
putRegistryPolicyResponse_httpStatus :: Lens.Lens' PutRegistryPolicyResponse Prelude.Int
putRegistryPolicyResponse_httpStatus :: (Int -> f Int)
-> PutRegistryPolicyResponse -> f PutRegistryPolicyResponse
putRegistryPolicyResponse_httpStatus = (PutRegistryPolicyResponse -> Int)
-> (PutRegistryPolicyResponse -> Int -> PutRegistryPolicyResponse)
-> Lens PutRegistryPolicyResponse PutRegistryPolicyResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutRegistryPolicyResponse' {Int
httpStatus :: Int
$sel:httpStatus:PutRegistryPolicyResponse' :: PutRegistryPolicyResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: PutRegistryPolicyResponse
s@PutRegistryPolicyResponse' {} Int
a -> PutRegistryPolicyResponse
s {$sel:httpStatus:PutRegistryPolicyResponse' :: Int
httpStatus = Int
a} :: PutRegistryPolicyResponse)
instance Prelude.NFData PutRegistryPolicyResponse