{-# 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.GetCorsPolicy
(
GetCorsPolicy (..),
newGetCorsPolicy,
getCorsPolicy_containerName,
GetCorsPolicyResponse (..),
newGetCorsPolicyResponse,
getCorsPolicyResponse_httpStatus,
getCorsPolicyResponse_corsPolicy,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.MediaStore.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data GetCorsPolicy = GetCorsPolicy'
{
GetCorsPolicy -> Text
containerName :: Prelude.Text
}
deriving (GetCorsPolicy -> GetCorsPolicy -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetCorsPolicy -> GetCorsPolicy -> Bool
$c/= :: GetCorsPolicy -> GetCorsPolicy -> Bool
== :: GetCorsPolicy -> GetCorsPolicy -> Bool
$c== :: GetCorsPolicy -> GetCorsPolicy -> Bool
Prelude.Eq, ReadPrec [GetCorsPolicy]
ReadPrec GetCorsPolicy
Int -> ReadS GetCorsPolicy
ReadS [GetCorsPolicy]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetCorsPolicy]
$creadListPrec :: ReadPrec [GetCorsPolicy]
readPrec :: ReadPrec GetCorsPolicy
$creadPrec :: ReadPrec GetCorsPolicy
readList :: ReadS [GetCorsPolicy]
$creadList :: ReadS [GetCorsPolicy]
readsPrec :: Int -> ReadS GetCorsPolicy
$creadsPrec :: Int -> ReadS GetCorsPolicy
Prelude.Read, Int -> GetCorsPolicy -> ShowS
[GetCorsPolicy] -> ShowS
GetCorsPolicy -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetCorsPolicy] -> ShowS
$cshowList :: [GetCorsPolicy] -> ShowS
show :: GetCorsPolicy -> String
$cshow :: GetCorsPolicy -> String
showsPrec :: Int -> GetCorsPolicy -> ShowS
$cshowsPrec :: Int -> GetCorsPolicy -> ShowS
Prelude.Show, forall x. Rep GetCorsPolicy x -> GetCorsPolicy
forall x. GetCorsPolicy -> Rep GetCorsPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetCorsPolicy x -> GetCorsPolicy
$cfrom :: forall x. GetCorsPolicy -> Rep GetCorsPolicy x
Prelude.Generic)
newGetCorsPolicy ::
Prelude.Text ->
GetCorsPolicy
newGetCorsPolicy :: Text -> GetCorsPolicy
newGetCorsPolicy Text
pContainerName_ =
GetCorsPolicy' {$sel:containerName:GetCorsPolicy' :: Text
containerName = Text
pContainerName_}
getCorsPolicy_containerName :: Lens.Lens' GetCorsPolicy Prelude.Text
getCorsPolicy_containerName :: Lens' GetCorsPolicy Text
getCorsPolicy_containerName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCorsPolicy' {Text
containerName :: Text
$sel:containerName:GetCorsPolicy' :: GetCorsPolicy -> Text
containerName} -> Text
containerName) (\s :: GetCorsPolicy
s@GetCorsPolicy' {} Text
a -> GetCorsPolicy
s {$sel:containerName:GetCorsPolicy' :: Text
containerName = Text
a} :: GetCorsPolicy)
instance Core.AWSRequest GetCorsPolicy where
type
AWSResponse GetCorsPolicy =
GetCorsPolicyResponse
request :: (Service -> Service) -> GetCorsPolicy -> Request GetCorsPolicy
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 GetCorsPolicy
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetCorsPolicy)))
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 ->
Int -> NonEmpty CorsRule -> GetCorsPolicyResponse
GetCorsPolicyResponse'
forall (f :: * -> *) a b. Functor 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))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"CorsPolicy")
)
instance Prelude.Hashable GetCorsPolicy where
hashWithSalt :: Int -> GetCorsPolicy -> Int
hashWithSalt Int
_salt GetCorsPolicy' {Text
containerName :: Text
$sel:containerName:GetCorsPolicy' :: GetCorsPolicy -> Text
..} =
Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
containerName
instance Prelude.NFData GetCorsPolicy where
rnf :: GetCorsPolicy -> ()
rnf GetCorsPolicy' {Text
containerName :: Text
$sel:containerName:GetCorsPolicy' :: GetCorsPolicy -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
containerName
instance Data.ToHeaders GetCorsPolicy where
toHeaders :: GetCorsPolicy -> 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
"MediaStore_20170901.GetCorsPolicy" ::
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 GetCorsPolicy where
toJSON :: GetCorsPolicy -> Value
toJSON GetCorsPolicy' {Text
containerName :: Text
$sel:containerName:GetCorsPolicy' :: GetCorsPolicy -> Text
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ forall a. a -> Maybe a
Prelude.Just
(Key
"ContainerName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
containerName)
]
)
instance Data.ToPath GetCorsPolicy where
toPath :: GetCorsPolicy -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Data.ToQuery GetCorsPolicy where
toQuery :: GetCorsPolicy -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty
data GetCorsPolicyResponse = GetCorsPolicyResponse'
{
GetCorsPolicyResponse -> Int
httpStatus :: Prelude.Int,
GetCorsPolicyResponse -> NonEmpty CorsRule
corsPolicy :: Prelude.NonEmpty CorsRule
}
deriving (GetCorsPolicyResponse -> GetCorsPolicyResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetCorsPolicyResponse -> GetCorsPolicyResponse -> Bool
$c/= :: GetCorsPolicyResponse -> GetCorsPolicyResponse -> Bool
== :: GetCorsPolicyResponse -> GetCorsPolicyResponse -> Bool
$c== :: GetCorsPolicyResponse -> GetCorsPolicyResponse -> Bool
Prelude.Eq, ReadPrec [GetCorsPolicyResponse]
ReadPrec GetCorsPolicyResponse
Int -> ReadS GetCorsPolicyResponse
ReadS [GetCorsPolicyResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetCorsPolicyResponse]
$creadListPrec :: ReadPrec [GetCorsPolicyResponse]
readPrec :: ReadPrec GetCorsPolicyResponse
$creadPrec :: ReadPrec GetCorsPolicyResponse
readList :: ReadS [GetCorsPolicyResponse]
$creadList :: ReadS [GetCorsPolicyResponse]
readsPrec :: Int -> ReadS GetCorsPolicyResponse
$creadsPrec :: Int -> ReadS GetCorsPolicyResponse
Prelude.Read, Int -> GetCorsPolicyResponse -> ShowS
[GetCorsPolicyResponse] -> ShowS
GetCorsPolicyResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetCorsPolicyResponse] -> ShowS
$cshowList :: [GetCorsPolicyResponse] -> ShowS
show :: GetCorsPolicyResponse -> String
$cshow :: GetCorsPolicyResponse -> String
showsPrec :: Int -> GetCorsPolicyResponse -> ShowS
$cshowsPrec :: Int -> GetCorsPolicyResponse -> ShowS
Prelude.Show, forall x. Rep GetCorsPolicyResponse x -> GetCorsPolicyResponse
forall x. GetCorsPolicyResponse -> Rep GetCorsPolicyResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetCorsPolicyResponse x -> GetCorsPolicyResponse
$cfrom :: forall x. GetCorsPolicyResponse -> Rep GetCorsPolicyResponse x
Prelude.Generic)
newGetCorsPolicyResponse ::
Prelude.Int ->
Prelude.NonEmpty CorsRule ->
GetCorsPolicyResponse
newGetCorsPolicyResponse :: Int -> NonEmpty CorsRule -> GetCorsPolicyResponse
newGetCorsPolicyResponse Int
pHttpStatus_ NonEmpty CorsRule
pCorsPolicy_ =
GetCorsPolicyResponse'
{ $sel:httpStatus:GetCorsPolicyResponse' :: Int
httpStatus = Int
pHttpStatus_,
$sel:corsPolicy:GetCorsPolicyResponse' :: NonEmpty CorsRule
corsPolicy = forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced forall t b. AReview t b -> b -> t
Lens.# NonEmpty CorsRule
pCorsPolicy_
}
getCorsPolicyResponse_httpStatus :: Lens.Lens' GetCorsPolicyResponse Prelude.Int
getCorsPolicyResponse_httpStatus :: Lens' GetCorsPolicyResponse Int
getCorsPolicyResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCorsPolicyResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetCorsPolicyResponse' :: GetCorsPolicyResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetCorsPolicyResponse
s@GetCorsPolicyResponse' {} Int
a -> GetCorsPolicyResponse
s {$sel:httpStatus:GetCorsPolicyResponse' :: Int
httpStatus = Int
a} :: GetCorsPolicyResponse)
getCorsPolicyResponse_corsPolicy :: Lens.Lens' GetCorsPolicyResponse (Prelude.NonEmpty CorsRule)
getCorsPolicyResponse_corsPolicy :: Lens' GetCorsPolicyResponse (NonEmpty CorsRule)
getCorsPolicyResponse_corsPolicy = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCorsPolicyResponse' {NonEmpty CorsRule
corsPolicy :: NonEmpty CorsRule
$sel:corsPolicy:GetCorsPolicyResponse' :: GetCorsPolicyResponse -> NonEmpty CorsRule
corsPolicy} -> NonEmpty CorsRule
corsPolicy) (\s :: GetCorsPolicyResponse
s@GetCorsPolicyResponse' {} NonEmpty CorsRule
a -> GetCorsPolicyResponse
s {$sel:corsPolicy:GetCorsPolicyResponse' :: NonEmpty CorsRule
corsPolicy = NonEmpty CorsRule
a} :: GetCorsPolicyResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Prelude.NFData GetCorsPolicyResponse where
rnf :: GetCorsPolicyResponse -> ()
rnf GetCorsPolicyResponse' {Int
NonEmpty CorsRule
corsPolicy :: NonEmpty CorsRule
httpStatus :: Int
$sel:corsPolicy:GetCorsPolicyResponse' :: GetCorsPolicyResponse -> NonEmpty CorsRule
$sel:httpStatus:GetCorsPolicyResponse' :: GetCorsPolicyResponse -> Int
..} =
forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf NonEmpty CorsRule
corsPolicy