{-# 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.MediaStore.PutCorsPolicy
(
PutCorsPolicy (..),
newPutCorsPolicy,
putCorsPolicy_containerName,
putCorsPolicy_corsPolicy,
PutCorsPolicyResponse (..),
newPutCorsPolicyResponse,
putCorsPolicyResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MediaStore.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data PutCorsPolicy = PutCorsPolicy'
{
PutCorsPolicy -> Text
containerName :: Prelude.Text,
PutCorsPolicy -> NonEmpty CorsRule
corsPolicy :: Prelude.NonEmpty CorsRule
}
deriving (PutCorsPolicy -> PutCorsPolicy -> Bool
(PutCorsPolicy -> PutCorsPolicy -> Bool)
-> (PutCorsPolicy -> PutCorsPolicy -> Bool) -> Eq PutCorsPolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutCorsPolicy -> PutCorsPolicy -> Bool
$c/= :: PutCorsPolicy -> PutCorsPolicy -> Bool
== :: PutCorsPolicy -> PutCorsPolicy -> Bool
$c== :: PutCorsPolicy -> PutCorsPolicy -> Bool
Prelude.Eq, ReadPrec [PutCorsPolicy]
ReadPrec PutCorsPolicy
Int -> ReadS PutCorsPolicy
ReadS [PutCorsPolicy]
(Int -> ReadS PutCorsPolicy)
-> ReadS [PutCorsPolicy]
-> ReadPrec PutCorsPolicy
-> ReadPrec [PutCorsPolicy]
-> Read PutCorsPolicy
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutCorsPolicy]
$creadListPrec :: ReadPrec [PutCorsPolicy]
readPrec :: ReadPrec PutCorsPolicy
$creadPrec :: ReadPrec PutCorsPolicy
readList :: ReadS [PutCorsPolicy]
$creadList :: ReadS [PutCorsPolicy]
readsPrec :: Int -> ReadS PutCorsPolicy
$creadsPrec :: Int -> ReadS PutCorsPolicy
Prelude.Read, Int -> PutCorsPolicy -> ShowS
[PutCorsPolicy] -> ShowS
PutCorsPolicy -> String
(Int -> PutCorsPolicy -> ShowS)
-> (PutCorsPolicy -> String)
-> ([PutCorsPolicy] -> ShowS)
-> Show PutCorsPolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutCorsPolicy] -> ShowS
$cshowList :: [PutCorsPolicy] -> ShowS
show :: PutCorsPolicy -> String
$cshow :: PutCorsPolicy -> String
showsPrec :: Int -> PutCorsPolicy -> ShowS
$cshowsPrec :: Int -> PutCorsPolicy -> ShowS
Prelude.Show, (forall x. PutCorsPolicy -> Rep PutCorsPolicy x)
-> (forall x. Rep PutCorsPolicy x -> PutCorsPolicy)
-> Generic PutCorsPolicy
forall x. Rep PutCorsPolicy x -> PutCorsPolicy
forall x. PutCorsPolicy -> Rep PutCorsPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutCorsPolicy x -> PutCorsPolicy
$cfrom :: forall x. PutCorsPolicy -> Rep PutCorsPolicy x
Prelude.Generic)
newPutCorsPolicy ::
Prelude.Text ->
Prelude.NonEmpty CorsRule ->
PutCorsPolicy
newPutCorsPolicy :: Text -> NonEmpty CorsRule -> PutCorsPolicy
newPutCorsPolicy Text
pContainerName_ NonEmpty CorsRule
pCorsPolicy_ =
PutCorsPolicy' :: Text -> NonEmpty CorsRule -> PutCorsPolicy
PutCorsPolicy'
{ $sel:containerName:PutCorsPolicy' :: Text
containerName = Text
pContainerName_,
$sel:corsPolicy:PutCorsPolicy' :: NonEmpty CorsRule
corsPolicy = Tagged (NonEmpty CorsRule) (Identity (NonEmpty CorsRule))
-> Tagged (NonEmpty CorsRule) (Identity (NonEmpty CorsRule))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged (NonEmpty CorsRule) (Identity (NonEmpty CorsRule))
-> Tagged (NonEmpty CorsRule) (Identity (NonEmpty CorsRule)))
-> NonEmpty CorsRule -> NonEmpty CorsRule
forall t b. AReview t b -> b -> t
Lens.# NonEmpty CorsRule
pCorsPolicy_
}
putCorsPolicy_containerName :: Lens.Lens' PutCorsPolicy Prelude.Text
putCorsPolicy_containerName :: (Text -> f Text) -> PutCorsPolicy -> f PutCorsPolicy
putCorsPolicy_containerName = (PutCorsPolicy -> Text)
-> (PutCorsPolicy -> Text -> PutCorsPolicy)
-> Lens PutCorsPolicy PutCorsPolicy Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutCorsPolicy' {Text
containerName :: Text
$sel:containerName:PutCorsPolicy' :: PutCorsPolicy -> Text
containerName} -> Text
containerName) (\s :: PutCorsPolicy
s@PutCorsPolicy' {} Text
a -> PutCorsPolicy
s {$sel:containerName:PutCorsPolicy' :: Text
containerName = Text
a} :: PutCorsPolicy)
putCorsPolicy_corsPolicy :: Lens.Lens' PutCorsPolicy (Prelude.NonEmpty CorsRule)
putCorsPolicy_corsPolicy :: (NonEmpty CorsRule -> f (NonEmpty CorsRule))
-> PutCorsPolicy -> f PutCorsPolicy
putCorsPolicy_corsPolicy = (PutCorsPolicy -> NonEmpty CorsRule)
-> (PutCorsPolicy -> NonEmpty CorsRule -> PutCorsPolicy)
-> Lens
PutCorsPolicy PutCorsPolicy (NonEmpty CorsRule) (NonEmpty CorsRule)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutCorsPolicy' {NonEmpty CorsRule
corsPolicy :: NonEmpty CorsRule
$sel:corsPolicy:PutCorsPolicy' :: PutCorsPolicy -> NonEmpty CorsRule
corsPolicy} -> NonEmpty CorsRule
corsPolicy) (\s :: PutCorsPolicy
s@PutCorsPolicy' {} NonEmpty CorsRule
a -> PutCorsPolicy
s {$sel:corsPolicy:PutCorsPolicy' :: NonEmpty CorsRule
corsPolicy = NonEmpty CorsRule
a} :: PutCorsPolicy) ((NonEmpty CorsRule -> f (NonEmpty CorsRule))
-> PutCorsPolicy -> f PutCorsPolicy)
-> ((NonEmpty CorsRule -> f (NonEmpty CorsRule))
-> NonEmpty CorsRule -> f (NonEmpty CorsRule))
-> (NonEmpty CorsRule -> f (NonEmpty CorsRule))
-> PutCorsPolicy
-> f PutCorsPolicy
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty CorsRule -> f (NonEmpty CorsRule))
-> NonEmpty CorsRule -> f (NonEmpty CorsRule)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Core.AWSRequest PutCorsPolicy where
type
AWSResponse PutCorsPolicy =
PutCorsPolicyResponse
request :: PutCorsPolicy -> Request PutCorsPolicy
request = Service -> PutCorsPolicy -> Request PutCorsPolicy
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy PutCorsPolicy
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutCorsPolicy)))
response =
(Int
-> ResponseHeaders
-> ()
-> Either String (AWSResponse PutCorsPolicy))
-> Logger
-> Service
-> Proxy PutCorsPolicy
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutCorsPolicy)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
( \Int
s ResponseHeaders
h ()
x ->
Int -> PutCorsPolicyResponse
PutCorsPolicyResponse'
(Int -> PutCorsPolicyResponse)
-> Either String Int -> Either String PutCorsPolicyResponse
forall (f :: * -> *) a b. Functor 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 PutCorsPolicy
instance Prelude.NFData PutCorsPolicy
instance Core.ToHeaders PutCorsPolicy where
toHeaders :: PutCorsPolicy -> ResponseHeaders
toHeaders =
ResponseHeaders -> PutCorsPolicy -> 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
"MediaStore_20170901.PutCorsPolicy" ::
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 PutCorsPolicy where
toJSON :: PutCorsPolicy -> Value
toJSON PutCorsPolicy' {NonEmpty CorsRule
Text
corsPolicy :: NonEmpty CorsRule
containerName :: Text
$sel:corsPolicy:PutCorsPolicy' :: PutCorsPolicy -> NonEmpty CorsRule
$sel:containerName:PutCorsPolicy' :: PutCorsPolicy -> 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
"ContainerName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
containerName),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"CorsPolicy" Text -> NonEmpty CorsRule -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty CorsRule
corsPolicy)
]
)
instance Core.ToPath PutCorsPolicy where
toPath :: PutCorsPolicy -> ByteString
toPath = ByteString -> PutCorsPolicy -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery PutCorsPolicy where
toQuery :: PutCorsPolicy -> QueryString
toQuery = QueryString -> PutCorsPolicy -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data PutCorsPolicyResponse = PutCorsPolicyResponse'
{
PutCorsPolicyResponse -> Int
httpStatus :: Prelude.Int
}
deriving (PutCorsPolicyResponse -> PutCorsPolicyResponse -> Bool
(PutCorsPolicyResponse -> PutCorsPolicyResponse -> Bool)
-> (PutCorsPolicyResponse -> PutCorsPolicyResponse -> Bool)
-> Eq PutCorsPolicyResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutCorsPolicyResponse -> PutCorsPolicyResponse -> Bool
$c/= :: PutCorsPolicyResponse -> PutCorsPolicyResponse -> Bool
== :: PutCorsPolicyResponse -> PutCorsPolicyResponse -> Bool
$c== :: PutCorsPolicyResponse -> PutCorsPolicyResponse -> Bool
Prelude.Eq, ReadPrec [PutCorsPolicyResponse]
ReadPrec PutCorsPolicyResponse
Int -> ReadS PutCorsPolicyResponse
ReadS [PutCorsPolicyResponse]
(Int -> ReadS PutCorsPolicyResponse)
-> ReadS [PutCorsPolicyResponse]
-> ReadPrec PutCorsPolicyResponse
-> ReadPrec [PutCorsPolicyResponse]
-> Read PutCorsPolicyResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutCorsPolicyResponse]
$creadListPrec :: ReadPrec [PutCorsPolicyResponse]
readPrec :: ReadPrec PutCorsPolicyResponse
$creadPrec :: ReadPrec PutCorsPolicyResponse
readList :: ReadS [PutCorsPolicyResponse]
$creadList :: ReadS [PutCorsPolicyResponse]
readsPrec :: Int -> ReadS PutCorsPolicyResponse
$creadsPrec :: Int -> ReadS PutCorsPolicyResponse
Prelude.Read, Int -> PutCorsPolicyResponse -> ShowS
[PutCorsPolicyResponse] -> ShowS
PutCorsPolicyResponse -> String
(Int -> PutCorsPolicyResponse -> ShowS)
-> (PutCorsPolicyResponse -> String)
-> ([PutCorsPolicyResponse] -> ShowS)
-> Show PutCorsPolicyResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutCorsPolicyResponse] -> ShowS
$cshowList :: [PutCorsPolicyResponse] -> ShowS
show :: PutCorsPolicyResponse -> String
$cshow :: PutCorsPolicyResponse -> String
showsPrec :: Int -> PutCorsPolicyResponse -> ShowS
$cshowsPrec :: Int -> PutCorsPolicyResponse -> ShowS
Prelude.Show, (forall x. PutCorsPolicyResponse -> Rep PutCorsPolicyResponse x)
-> (forall x. Rep PutCorsPolicyResponse x -> PutCorsPolicyResponse)
-> Generic PutCorsPolicyResponse
forall x. Rep PutCorsPolicyResponse x -> PutCorsPolicyResponse
forall x. PutCorsPolicyResponse -> Rep PutCorsPolicyResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutCorsPolicyResponse x -> PutCorsPolicyResponse
$cfrom :: forall x. PutCorsPolicyResponse -> Rep PutCorsPolicyResponse x
Prelude.Generic)
newPutCorsPolicyResponse ::
Prelude.Int ->
PutCorsPolicyResponse
newPutCorsPolicyResponse :: Int -> PutCorsPolicyResponse
newPutCorsPolicyResponse Int
pHttpStatus_ =
PutCorsPolicyResponse' :: Int -> PutCorsPolicyResponse
PutCorsPolicyResponse' {$sel:httpStatus:PutCorsPolicyResponse' :: Int
httpStatus = Int
pHttpStatus_}
putCorsPolicyResponse_httpStatus :: Lens.Lens' PutCorsPolicyResponse Prelude.Int
putCorsPolicyResponse_httpStatus :: (Int -> f Int) -> PutCorsPolicyResponse -> f PutCorsPolicyResponse
putCorsPolicyResponse_httpStatus = (PutCorsPolicyResponse -> Int)
-> (PutCorsPolicyResponse -> Int -> PutCorsPolicyResponse)
-> Lens PutCorsPolicyResponse PutCorsPolicyResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutCorsPolicyResponse' {Int
httpStatus :: Int
$sel:httpStatus:PutCorsPolicyResponse' :: PutCorsPolicyResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: PutCorsPolicyResponse
s@PutCorsPolicyResponse' {} Int
a -> PutCorsPolicyResponse
s {$sel:httpStatus:PutCorsPolicyResponse' :: Int
httpStatus = Int
a} :: PutCorsPolicyResponse)
instance Prelude.NFData PutCorsPolicyResponse