{-# 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 #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.StorageGateway.AddUploadBuffer
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Configures one or more gateway local disks as upload buffer for a
-- specified gateway. This operation is supported for the stored volume,
-- cached volume, and tape gateway types.
--
-- In the request, you specify the gateway Amazon Resource Name (ARN) to
-- which you want to add upload buffer, and one or more disk IDs that you
-- want to configure as upload buffer.
module Amazonka.StorageGateway.AddUploadBuffer
  ( -- * Creating a Request
    AddUploadBuffer (..),
    newAddUploadBuffer,

    -- * Request Lenses
    addUploadBuffer_gatewayARN,
    addUploadBuffer_diskIds,

    -- * Destructuring the Response
    AddUploadBufferResponse (..),
    newAddUploadBufferResponse,

    -- * Response Lenses
    addUploadBufferResponse_gatewayARN,
    addUploadBufferResponse_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

-- | /See:/ 'newAddUploadBuffer' smart constructor.
data AddUploadBuffer = AddUploadBuffer'
  { AddUploadBuffer -> Text
gatewayARN :: Prelude.Text,
    -- | An array of strings that identify disks that are to be configured as
    -- working storage. Each string has a minimum length of 1 and maximum
    -- length of 300. You can get the disk IDs from the ListLocalDisks API.
    AddUploadBuffer -> [Text]
diskIds :: [Prelude.Text]
  }
  deriving (AddUploadBuffer -> AddUploadBuffer -> Bool
(AddUploadBuffer -> AddUploadBuffer -> Bool)
-> (AddUploadBuffer -> AddUploadBuffer -> Bool)
-> Eq AddUploadBuffer
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AddUploadBuffer -> AddUploadBuffer -> Bool
$c/= :: AddUploadBuffer -> AddUploadBuffer -> Bool
== :: AddUploadBuffer -> AddUploadBuffer -> Bool
$c== :: AddUploadBuffer -> AddUploadBuffer -> Bool
Prelude.Eq, ReadPrec [AddUploadBuffer]
ReadPrec AddUploadBuffer
Int -> ReadS AddUploadBuffer
ReadS [AddUploadBuffer]
(Int -> ReadS AddUploadBuffer)
-> ReadS [AddUploadBuffer]
-> ReadPrec AddUploadBuffer
-> ReadPrec [AddUploadBuffer]
-> Read AddUploadBuffer
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AddUploadBuffer]
$creadListPrec :: ReadPrec [AddUploadBuffer]
readPrec :: ReadPrec AddUploadBuffer
$creadPrec :: ReadPrec AddUploadBuffer
readList :: ReadS [AddUploadBuffer]
$creadList :: ReadS [AddUploadBuffer]
readsPrec :: Int -> ReadS AddUploadBuffer
$creadsPrec :: Int -> ReadS AddUploadBuffer
Prelude.Read, Int -> AddUploadBuffer -> ShowS
[AddUploadBuffer] -> ShowS
AddUploadBuffer -> String
(Int -> AddUploadBuffer -> ShowS)
-> (AddUploadBuffer -> String)
-> ([AddUploadBuffer] -> ShowS)
-> Show AddUploadBuffer
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AddUploadBuffer] -> ShowS
$cshowList :: [AddUploadBuffer] -> ShowS
show :: AddUploadBuffer -> String
$cshow :: AddUploadBuffer -> String
showsPrec :: Int -> AddUploadBuffer -> ShowS
$cshowsPrec :: Int -> AddUploadBuffer -> ShowS
Prelude.Show, (forall x. AddUploadBuffer -> Rep AddUploadBuffer x)
-> (forall x. Rep AddUploadBuffer x -> AddUploadBuffer)
-> Generic AddUploadBuffer
forall x. Rep AddUploadBuffer x -> AddUploadBuffer
forall x. AddUploadBuffer -> Rep AddUploadBuffer x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AddUploadBuffer x -> AddUploadBuffer
$cfrom :: forall x. AddUploadBuffer -> Rep AddUploadBuffer x
Prelude.Generic)

-- |
-- Create a value of 'AddUploadBuffer' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'gatewayARN', 'addUploadBuffer_gatewayARN' - Undocumented member.
--
-- 'diskIds', 'addUploadBuffer_diskIds' - An array of strings that identify disks that are to be configured as
-- working storage. Each string has a minimum length of 1 and maximum
-- length of 300. You can get the disk IDs from the ListLocalDisks API.
newAddUploadBuffer ::
  -- | 'gatewayARN'
  Prelude.Text ->
  AddUploadBuffer
newAddUploadBuffer :: Text -> AddUploadBuffer
newAddUploadBuffer Text
pGatewayARN_ =
  AddUploadBuffer' :: Text -> [Text] -> AddUploadBuffer
AddUploadBuffer'
    { $sel:gatewayARN:AddUploadBuffer' :: Text
gatewayARN = Text
pGatewayARN_,
      $sel:diskIds:AddUploadBuffer' :: [Text]
diskIds = [Text]
forall a. Monoid a => a
Prelude.mempty
    }

-- | Undocumented member.
addUploadBuffer_gatewayARN :: Lens.Lens' AddUploadBuffer Prelude.Text
addUploadBuffer_gatewayARN :: (Text -> f Text) -> AddUploadBuffer -> f AddUploadBuffer
addUploadBuffer_gatewayARN = (AddUploadBuffer -> Text)
-> (AddUploadBuffer -> Text -> AddUploadBuffer)
-> Lens AddUploadBuffer AddUploadBuffer Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AddUploadBuffer' {Text
gatewayARN :: Text
$sel:gatewayARN:AddUploadBuffer' :: AddUploadBuffer -> Text
gatewayARN} -> Text
gatewayARN) (\s :: AddUploadBuffer
s@AddUploadBuffer' {} Text
a -> AddUploadBuffer
s {$sel:gatewayARN:AddUploadBuffer' :: Text
gatewayARN = Text
a} :: AddUploadBuffer)

-- | An array of strings that identify disks that are to be configured as
-- working storage. Each string has a minimum length of 1 and maximum
-- length of 300. You can get the disk IDs from the ListLocalDisks API.
addUploadBuffer_diskIds :: Lens.Lens' AddUploadBuffer [Prelude.Text]
addUploadBuffer_diskIds :: ([Text] -> f [Text]) -> AddUploadBuffer -> f AddUploadBuffer
addUploadBuffer_diskIds = (AddUploadBuffer -> [Text])
-> (AddUploadBuffer -> [Text] -> AddUploadBuffer)
-> Lens AddUploadBuffer AddUploadBuffer [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AddUploadBuffer' {[Text]
diskIds :: [Text]
$sel:diskIds:AddUploadBuffer' :: AddUploadBuffer -> [Text]
diskIds} -> [Text]
diskIds) (\s :: AddUploadBuffer
s@AddUploadBuffer' {} [Text]
a -> AddUploadBuffer
s {$sel:diskIds:AddUploadBuffer' :: [Text]
diskIds = [Text]
a} :: AddUploadBuffer) (([Text] -> f [Text]) -> AddUploadBuffer -> f AddUploadBuffer)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> AddUploadBuffer
-> f AddUploadBuffer
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 AddUploadBuffer where
  type
    AWSResponse AddUploadBuffer =
      AddUploadBufferResponse
  request :: AddUploadBuffer -> Request AddUploadBuffer
request = Service -> AddUploadBuffer -> Request AddUploadBuffer
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy AddUploadBuffer
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse AddUploadBuffer)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse AddUploadBuffer))
-> Logger
-> Service
-> Proxy AddUploadBuffer
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse AddUploadBuffer)))
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 -> AddUploadBufferResponse
AddUploadBufferResponse'
            (Maybe Text -> Int -> AddUploadBufferResponse)
-> Either String (Maybe Text)
-> Either String (Int -> AddUploadBufferResponse)
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 -> AddUploadBufferResponse)
-> Either String Int -> Either String AddUploadBufferResponse
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 AddUploadBuffer

instance Prelude.NFData AddUploadBuffer

instance Core.ToHeaders AddUploadBuffer where
  toHeaders :: AddUploadBuffer -> ResponseHeaders
toHeaders =
    ResponseHeaders -> AddUploadBuffer -> 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.AddUploadBuffer" ::
                          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 AddUploadBuffer where
  toJSON :: AddUploadBuffer -> Value
toJSON AddUploadBuffer' {[Text]
Text
diskIds :: [Text]
gatewayARN :: Text
$sel:diskIds:AddUploadBuffer' :: AddUploadBuffer -> [Text]
$sel:gatewayARN:AddUploadBuffer' :: AddUploadBuffer -> 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 AddUploadBuffer where
  toPath :: AddUploadBuffer -> ByteString
toPath = ByteString -> AddUploadBuffer -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery AddUploadBuffer where
  toQuery :: AddUploadBuffer -> QueryString
toQuery = QueryString -> AddUploadBuffer -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newAddUploadBufferResponse' smart constructor.
data AddUploadBufferResponse = AddUploadBufferResponse'
  { AddUploadBufferResponse -> Maybe Text
gatewayARN :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    AddUploadBufferResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (AddUploadBufferResponse -> AddUploadBufferResponse -> Bool
(AddUploadBufferResponse -> AddUploadBufferResponse -> Bool)
-> (AddUploadBufferResponse -> AddUploadBufferResponse -> Bool)
-> Eq AddUploadBufferResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AddUploadBufferResponse -> AddUploadBufferResponse -> Bool
$c/= :: AddUploadBufferResponse -> AddUploadBufferResponse -> Bool
== :: AddUploadBufferResponse -> AddUploadBufferResponse -> Bool
$c== :: AddUploadBufferResponse -> AddUploadBufferResponse -> Bool
Prelude.Eq, ReadPrec [AddUploadBufferResponse]
ReadPrec AddUploadBufferResponse
Int -> ReadS AddUploadBufferResponse
ReadS [AddUploadBufferResponse]
(Int -> ReadS AddUploadBufferResponse)
-> ReadS [AddUploadBufferResponse]
-> ReadPrec AddUploadBufferResponse
-> ReadPrec [AddUploadBufferResponse]
-> Read AddUploadBufferResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AddUploadBufferResponse]
$creadListPrec :: ReadPrec [AddUploadBufferResponse]
readPrec :: ReadPrec AddUploadBufferResponse
$creadPrec :: ReadPrec AddUploadBufferResponse
readList :: ReadS [AddUploadBufferResponse]
$creadList :: ReadS [AddUploadBufferResponse]
readsPrec :: Int -> ReadS AddUploadBufferResponse
$creadsPrec :: Int -> ReadS AddUploadBufferResponse
Prelude.Read, Int -> AddUploadBufferResponse -> ShowS
[AddUploadBufferResponse] -> ShowS
AddUploadBufferResponse -> String
(Int -> AddUploadBufferResponse -> ShowS)
-> (AddUploadBufferResponse -> String)
-> ([AddUploadBufferResponse] -> ShowS)
-> Show AddUploadBufferResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AddUploadBufferResponse] -> ShowS
$cshowList :: [AddUploadBufferResponse] -> ShowS
show :: AddUploadBufferResponse -> String
$cshow :: AddUploadBufferResponse -> String
showsPrec :: Int -> AddUploadBufferResponse -> ShowS
$cshowsPrec :: Int -> AddUploadBufferResponse -> ShowS
Prelude.Show, (forall x.
 AddUploadBufferResponse -> Rep AddUploadBufferResponse x)
-> (forall x.
    Rep AddUploadBufferResponse x -> AddUploadBufferResponse)
-> Generic AddUploadBufferResponse
forall x. Rep AddUploadBufferResponse x -> AddUploadBufferResponse
forall x. AddUploadBufferResponse -> Rep AddUploadBufferResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AddUploadBufferResponse x -> AddUploadBufferResponse
$cfrom :: forall x. AddUploadBufferResponse -> Rep AddUploadBufferResponse x
Prelude.Generic)

-- |
-- Create a value of 'AddUploadBufferResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'gatewayARN', 'addUploadBufferResponse_gatewayARN' - Undocumented member.
--
-- 'httpStatus', 'addUploadBufferResponse_httpStatus' - The response's http status code.
newAddUploadBufferResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  AddUploadBufferResponse
newAddUploadBufferResponse :: Int -> AddUploadBufferResponse
newAddUploadBufferResponse Int
pHttpStatus_ =
  AddUploadBufferResponse' :: Maybe Text -> Int -> AddUploadBufferResponse
AddUploadBufferResponse'
    { $sel:gatewayARN:AddUploadBufferResponse' :: Maybe Text
gatewayARN =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:AddUploadBufferResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Undocumented member.
addUploadBufferResponse_gatewayARN :: Lens.Lens' AddUploadBufferResponse (Prelude.Maybe Prelude.Text)
addUploadBufferResponse_gatewayARN :: (Maybe Text -> f (Maybe Text))
-> AddUploadBufferResponse -> f AddUploadBufferResponse
addUploadBufferResponse_gatewayARN = (AddUploadBufferResponse -> Maybe Text)
-> (AddUploadBufferResponse
    -> Maybe Text -> AddUploadBufferResponse)
-> Lens
     AddUploadBufferResponse
     AddUploadBufferResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AddUploadBufferResponse' {Maybe Text
gatewayARN :: Maybe Text
$sel:gatewayARN:AddUploadBufferResponse' :: AddUploadBufferResponse -> Maybe Text
gatewayARN} -> Maybe Text
gatewayARN) (\s :: AddUploadBufferResponse
s@AddUploadBufferResponse' {} Maybe Text
a -> AddUploadBufferResponse
s {$sel:gatewayARN:AddUploadBufferResponse' :: Maybe Text
gatewayARN = Maybe Text
a} :: AddUploadBufferResponse)

-- | The response's http status code.
addUploadBufferResponse_httpStatus :: Lens.Lens' AddUploadBufferResponse Prelude.Int
addUploadBufferResponse_httpStatus :: (Int -> f Int)
-> AddUploadBufferResponse -> f AddUploadBufferResponse
addUploadBufferResponse_httpStatus = (AddUploadBufferResponse -> Int)
-> (AddUploadBufferResponse -> Int -> AddUploadBufferResponse)
-> Lens AddUploadBufferResponse AddUploadBufferResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AddUploadBufferResponse' {Int
httpStatus :: Int
$sel:httpStatus:AddUploadBufferResponse' :: AddUploadBufferResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: AddUploadBufferResponse
s@AddUploadBufferResponse' {} Int
a -> AddUploadBufferResponse
s {$sel:httpStatus:AddUploadBufferResponse' :: Int
httpStatus = Int
a} :: AddUploadBufferResponse)

instance Prelude.NFData AddUploadBufferResponse