{-# 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.StorageGateway.AddCache
(
AddCache (..),
newAddCache,
addCache_gatewayARN,
addCache_diskIds,
AddCacheResponse (..),
newAddCacheResponse,
addCacheResponse_gatewayARN,
addCacheResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.StorageGateway.Types
data AddCache = AddCache'
{ AddCache -> Text
gatewayARN :: Prelude.Text,
AddCache -> [Text]
diskIds :: [Prelude.Text]
}
deriving (AddCache -> AddCache -> Bool
(AddCache -> AddCache -> Bool)
-> (AddCache -> AddCache -> Bool) -> Eq AddCache
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AddCache -> AddCache -> Bool
$c/= :: AddCache -> AddCache -> Bool
== :: AddCache -> AddCache -> Bool
$c== :: AddCache -> AddCache -> Bool
Prelude.Eq, ReadPrec [AddCache]
ReadPrec AddCache
Int -> ReadS AddCache
ReadS [AddCache]
(Int -> ReadS AddCache)
-> ReadS [AddCache]
-> ReadPrec AddCache
-> ReadPrec [AddCache]
-> Read AddCache
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AddCache]
$creadListPrec :: ReadPrec [AddCache]
readPrec :: ReadPrec AddCache
$creadPrec :: ReadPrec AddCache
readList :: ReadS [AddCache]
$creadList :: ReadS [AddCache]
readsPrec :: Int -> ReadS AddCache
$creadsPrec :: Int -> ReadS AddCache
Prelude.Read, Int -> AddCache -> ShowS
[AddCache] -> ShowS
AddCache -> String
(Int -> AddCache -> ShowS)
-> (AddCache -> String) -> ([AddCache] -> ShowS) -> Show AddCache
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AddCache] -> ShowS
$cshowList :: [AddCache] -> ShowS
show :: AddCache -> String
$cshow :: AddCache -> String
showsPrec :: Int -> AddCache -> ShowS
$cshowsPrec :: Int -> AddCache -> ShowS
Prelude.Show, (forall x. AddCache -> Rep AddCache x)
-> (forall x. Rep AddCache x -> AddCache) -> Generic AddCache
forall x. Rep AddCache x -> AddCache
forall x. AddCache -> Rep AddCache x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AddCache x -> AddCache
$cfrom :: forall x. AddCache -> Rep AddCache x
Prelude.Generic)
newAddCache ::
Prelude.Text ->
AddCache
newAddCache :: Text -> AddCache
newAddCache Text
pGatewayARN_ =
AddCache' :: Text -> [Text] -> AddCache
AddCache'
{ $sel:gatewayARN:AddCache' :: Text
gatewayARN = Text
pGatewayARN_,
$sel:diskIds:AddCache' :: [Text]
diskIds = [Text]
forall a. Monoid a => a
Prelude.mempty
}
addCache_gatewayARN :: Lens.Lens' AddCache Prelude.Text
addCache_gatewayARN :: (Text -> f Text) -> AddCache -> f AddCache
addCache_gatewayARN = (AddCache -> Text)
-> (AddCache -> Text -> AddCache)
-> Lens AddCache AddCache Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AddCache' {Text
gatewayARN :: Text
$sel:gatewayARN:AddCache' :: AddCache -> Text
gatewayARN} -> Text
gatewayARN) (\s :: AddCache
s@AddCache' {} Text
a -> AddCache
s {$sel:gatewayARN:AddCache' :: Text
gatewayARN = Text
a} :: AddCache)
addCache_diskIds :: Lens.Lens' AddCache [Prelude.Text]
addCache_diskIds :: ([Text] -> f [Text]) -> AddCache -> f AddCache
addCache_diskIds = (AddCache -> [Text])
-> (AddCache -> [Text] -> AddCache)
-> Lens AddCache AddCache [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AddCache' {[Text]
diskIds :: [Text]
$sel:diskIds:AddCache' :: AddCache -> [Text]
diskIds} -> [Text]
diskIds) (\s :: AddCache
s@AddCache' {} [Text]
a -> AddCache
s {$sel:diskIds:AddCache' :: [Text]
diskIds = [Text]
a} :: AddCache) (([Text] -> f [Text]) -> AddCache -> f AddCache)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> AddCache
-> f AddCache
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Core.AWSRequest AddCache where
type AWSResponse AddCache = AddCacheResponse
request :: AddCache -> Request AddCache
request = Service -> AddCache -> Request AddCache
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy AddCache
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse AddCache)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse AddCache))
-> Logger
-> Service
-> Proxy AddCache
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse AddCache)))
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 -> Int -> AddCacheResponse
AddCacheResponse'
(Maybe Text -> Int -> AddCacheResponse)
-> Either String (Maybe Text)
-> Either String (Int -> AddCacheResponse)
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
"GatewayARN")
Either String (Int -> AddCacheResponse)
-> Either String Int -> Either String AddCacheResponse
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 AddCache
instance Prelude.NFData AddCache
instance Core.ToHeaders AddCache where
toHeaders :: AddCache -> ResponseHeaders
toHeaders =
ResponseHeaders -> AddCache -> 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
"StorageGateway_20130630.AddCache" ::
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 AddCache where
toJSON :: AddCache -> Value
toJSON AddCache' {[Text]
Text
diskIds :: [Text]
gatewayARN :: Text
$sel:diskIds:AddCache' :: AddCache -> [Text]
$sel:gatewayARN:AddCache' :: AddCache -> 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
"GatewayARN" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
gatewayARN),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"DiskIds" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Text]
diskIds)
]
)
instance Core.ToPath AddCache where
toPath :: AddCache -> ByteString
toPath = ByteString -> AddCache -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery AddCache where
toQuery :: AddCache -> QueryString
toQuery = QueryString -> AddCache -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data AddCacheResponse = AddCacheResponse'
{ AddCacheResponse -> Maybe Text
gatewayARN :: Prelude.Maybe Prelude.Text,
AddCacheResponse -> Int
httpStatus :: Prelude.Int
}
deriving (AddCacheResponse -> AddCacheResponse -> Bool
(AddCacheResponse -> AddCacheResponse -> Bool)
-> (AddCacheResponse -> AddCacheResponse -> Bool)
-> Eq AddCacheResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AddCacheResponse -> AddCacheResponse -> Bool
$c/= :: AddCacheResponse -> AddCacheResponse -> Bool
== :: AddCacheResponse -> AddCacheResponse -> Bool
$c== :: AddCacheResponse -> AddCacheResponse -> Bool
Prelude.Eq, ReadPrec [AddCacheResponse]
ReadPrec AddCacheResponse
Int -> ReadS AddCacheResponse
ReadS [AddCacheResponse]
(Int -> ReadS AddCacheResponse)
-> ReadS [AddCacheResponse]
-> ReadPrec AddCacheResponse
-> ReadPrec [AddCacheResponse]
-> Read AddCacheResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AddCacheResponse]
$creadListPrec :: ReadPrec [AddCacheResponse]
readPrec :: ReadPrec AddCacheResponse
$creadPrec :: ReadPrec AddCacheResponse
readList :: ReadS [AddCacheResponse]
$creadList :: ReadS [AddCacheResponse]
readsPrec :: Int -> ReadS AddCacheResponse
$creadsPrec :: Int -> ReadS AddCacheResponse
Prelude.Read, Int -> AddCacheResponse -> ShowS
[AddCacheResponse] -> ShowS
AddCacheResponse -> String
(Int -> AddCacheResponse -> ShowS)
-> (AddCacheResponse -> String)
-> ([AddCacheResponse] -> ShowS)
-> Show AddCacheResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AddCacheResponse] -> ShowS
$cshowList :: [AddCacheResponse] -> ShowS
show :: AddCacheResponse -> String
$cshow :: AddCacheResponse -> String
showsPrec :: Int -> AddCacheResponse -> ShowS
$cshowsPrec :: Int -> AddCacheResponse -> ShowS
Prelude.Show, (forall x. AddCacheResponse -> Rep AddCacheResponse x)
-> (forall x. Rep AddCacheResponse x -> AddCacheResponse)
-> Generic AddCacheResponse
forall x. Rep AddCacheResponse x -> AddCacheResponse
forall x. AddCacheResponse -> Rep AddCacheResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AddCacheResponse x -> AddCacheResponse
$cfrom :: forall x. AddCacheResponse -> Rep AddCacheResponse x
Prelude.Generic)
newAddCacheResponse ::
Prelude.Int ->
AddCacheResponse
newAddCacheResponse :: Int -> AddCacheResponse
newAddCacheResponse Int
pHttpStatus_ =
AddCacheResponse' :: Maybe Text -> Int -> AddCacheResponse
AddCacheResponse'
{ $sel:gatewayARN:AddCacheResponse' :: Maybe Text
gatewayARN = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:AddCacheResponse' :: Int
httpStatus = Int
pHttpStatus_
}
addCacheResponse_gatewayARN :: Lens.Lens' AddCacheResponse (Prelude.Maybe Prelude.Text)
addCacheResponse_gatewayARN :: (Maybe Text -> f (Maybe Text))
-> AddCacheResponse -> f AddCacheResponse
addCacheResponse_gatewayARN = (AddCacheResponse -> Maybe Text)
-> (AddCacheResponse -> Maybe Text -> AddCacheResponse)
-> Lens AddCacheResponse AddCacheResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AddCacheResponse' {Maybe Text
gatewayARN :: Maybe Text
$sel:gatewayARN:AddCacheResponse' :: AddCacheResponse -> Maybe Text
gatewayARN} -> Maybe Text
gatewayARN) (\s :: AddCacheResponse
s@AddCacheResponse' {} Maybe Text
a -> AddCacheResponse
s {$sel:gatewayARN:AddCacheResponse' :: Maybe Text
gatewayARN = Maybe Text
a} :: AddCacheResponse)
addCacheResponse_httpStatus :: Lens.Lens' AddCacheResponse Prelude.Int
addCacheResponse_httpStatus :: (Int -> f Int) -> AddCacheResponse -> f AddCacheResponse
addCacheResponse_httpStatus = (AddCacheResponse -> Int)
-> (AddCacheResponse -> Int -> AddCacheResponse)
-> Lens AddCacheResponse AddCacheResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AddCacheResponse' {Int
httpStatus :: Int
$sel:httpStatus:AddCacheResponse' :: AddCacheResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: AddCacheResponse
s@AddCacheResponse' {} Int
a -> AddCacheResponse
s {$sel:httpStatus:AddCacheResponse' :: Int
httpStatus = Int
a} :: AddCacheResponse)
instance Prelude.NFData AddCacheResponse