{-# 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.EBS.PutSnapshotBlock
-- 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)
--
-- Writes a block of data to a snapshot. If the specified block contains
-- data, the existing data is overwritten. The target snapshot must be in
-- the @pending@ state.
--
-- Data written to a snapshot must be aligned with 512-KiB sectors.
module Amazonka.EBS.PutSnapshotBlock
  ( -- * Creating a Request
    PutSnapshotBlock (..),
    newPutSnapshotBlock,

    -- * Request Lenses
    putSnapshotBlock_progress,
    putSnapshotBlock_snapshotId,
    putSnapshotBlock_blockIndex,
    putSnapshotBlock_dataLength,
    putSnapshotBlock_checksum,
    putSnapshotBlock_checksumAlgorithm,
    putSnapshotBlock_blockData,

    -- * Destructuring the Response
    PutSnapshotBlockResponse (..),
    newPutSnapshotBlockResponse,

    -- * Response Lenses
    putSnapshotBlockResponse_checksumAlgorithm,
    putSnapshotBlockResponse_checksum,
    putSnapshotBlockResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.EBS.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

-- | /See:/ 'newPutSnapshotBlock' smart constructor.
data PutSnapshotBlock = PutSnapshotBlock'
  { -- | The progress of the write process, as a percentage.
    PutSnapshotBlock -> Maybe Natural
progress :: Prelude.Maybe Prelude.Natural,
    -- | The ID of the snapshot.
    PutSnapshotBlock -> Text
snapshotId :: Prelude.Text,
    -- | The block index of the block in which to write the data. A block index
    -- is a logical index in units of @512@ KiB blocks. To identify the block
    -- index, divide the logical offset of the data in the logical volume by
    -- the block size (logical offset of data\/@524288@). The logical offset of
    -- the data must be @512@ KiB aligned.
    PutSnapshotBlock -> Natural
blockIndex :: Prelude.Natural,
    -- | The size of the data to write to the block, in bytes. Currently, the
    -- only supported size is @524288@ bytes.
    --
    -- Valid values: @524288@
    PutSnapshotBlock -> Int
dataLength :: Prelude.Int,
    -- | A Base64-encoded SHA256 checksum of the data. Only SHA256 checksums are
    -- supported.
    PutSnapshotBlock -> Text
checksum :: Prelude.Text,
    -- | The algorithm used to generate the checksum. Currently, the only
    -- supported algorithm is @SHA256@.
    PutSnapshotBlock -> ChecksumAlgorithm
checksumAlgorithm :: ChecksumAlgorithm,
    -- | The data to write to the block.
    --
    -- The block data is not signed as part of the Signature Version 4 signing
    -- process. As a result, you must generate and provide a Base64-encoded
    -- SHA256 checksum for the block data using the __x-amz-Checksum__ header.
    -- Also, you must specify the checksum algorithm using the
    -- __x-amz-Checksum-Algorithm__ header. The checksum that you provide is
    -- part of the Signature Version 4 signing process. It is validated against
    -- a checksum generated by Amazon EBS to ensure the validity and
    -- authenticity of the data. If the checksums do not correspond, the
    -- request fails. For more information, see
    -- <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-accessing-snapshot.html#ebsapis-using-checksums Using checksums with the EBS direct APIs>
    -- in the /Amazon Elastic Compute Cloud User Guide/.
    PutSnapshotBlock -> HashedBody
blockData :: Core.HashedBody
  }
  deriving (Int -> PutSnapshotBlock -> ShowS
[PutSnapshotBlock] -> ShowS
PutSnapshotBlock -> String
(Int -> PutSnapshotBlock -> ShowS)
-> (PutSnapshotBlock -> String)
-> ([PutSnapshotBlock] -> ShowS)
-> Show PutSnapshotBlock
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutSnapshotBlock] -> ShowS
$cshowList :: [PutSnapshotBlock] -> ShowS
show :: PutSnapshotBlock -> String
$cshow :: PutSnapshotBlock -> String
showsPrec :: Int -> PutSnapshotBlock -> ShowS
$cshowsPrec :: Int -> PutSnapshotBlock -> ShowS
Prelude.Show, (forall x. PutSnapshotBlock -> Rep PutSnapshotBlock x)
-> (forall x. Rep PutSnapshotBlock x -> PutSnapshotBlock)
-> Generic PutSnapshotBlock
forall x. Rep PutSnapshotBlock x -> PutSnapshotBlock
forall x. PutSnapshotBlock -> Rep PutSnapshotBlock x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutSnapshotBlock x -> PutSnapshotBlock
$cfrom :: forall x. PutSnapshotBlock -> Rep PutSnapshotBlock x
Prelude.Generic)

-- |
-- Create a value of 'PutSnapshotBlock' 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:
--
-- 'progress', 'putSnapshotBlock_progress' - The progress of the write process, as a percentage.
--
-- 'snapshotId', 'putSnapshotBlock_snapshotId' - The ID of the snapshot.
--
-- 'blockIndex', 'putSnapshotBlock_blockIndex' - The block index of the block in which to write the data. A block index
-- is a logical index in units of @512@ KiB blocks. To identify the block
-- index, divide the logical offset of the data in the logical volume by
-- the block size (logical offset of data\/@524288@). The logical offset of
-- the data must be @512@ KiB aligned.
--
-- 'dataLength', 'putSnapshotBlock_dataLength' - The size of the data to write to the block, in bytes. Currently, the
-- only supported size is @524288@ bytes.
--
-- Valid values: @524288@
--
-- 'checksum', 'putSnapshotBlock_checksum' - A Base64-encoded SHA256 checksum of the data. Only SHA256 checksums are
-- supported.
--
-- 'checksumAlgorithm', 'putSnapshotBlock_checksumAlgorithm' - The algorithm used to generate the checksum. Currently, the only
-- supported algorithm is @SHA256@.
--
-- 'blockData', 'putSnapshotBlock_blockData' - The data to write to the block.
--
-- The block data is not signed as part of the Signature Version 4 signing
-- process. As a result, you must generate and provide a Base64-encoded
-- SHA256 checksum for the block data using the __x-amz-Checksum__ header.
-- Also, you must specify the checksum algorithm using the
-- __x-amz-Checksum-Algorithm__ header. The checksum that you provide is
-- part of the Signature Version 4 signing process. It is validated against
-- a checksum generated by Amazon EBS to ensure the validity and
-- authenticity of the data. If the checksums do not correspond, the
-- request fails. For more information, see
-- <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-accessing-snapshot.html#ebsapis-using-checksums Using checksums with the EBS direct APIs>
-- in the /Amazon Elastic Compute Cloud User Guide/.
newPutSnapshotBlock ::
  -- | 'snapshotId'
  Prelude.Text ->
  -- | 'blockIndex'
  Prelude.Natural ->
  -- | 'dataLength'
  Prelude.Int ->
  -- | 'checksum'
  Prelude.Text ->
  -- | 'checksumAlgorithm'
  ChecksumAlgorithm ->
  -- | 'blockData'
  Core.HashedBody ->
  PutSnapshotBlock
newPutSnapshotBlock :: Text
-> Natural
-> Int
-> Text
-> ChecksumAlgorithm
-> HashedBody
-> PutSnapshotBlock
newPutSnapshotBlock
  Text
pSnapshotId_
  Natural
pBlockIndex_
  Int
pDataLength_
  Text
pChecksum_
  ChecksumAlgorithm
pChecksumAlgorithm_
  HashedBody
pBlockData_ =
    PutSnapshotBlock' :: Maybe Natural
-> Text
-> Natural
-> Int
-> Text
-> ChecksumAlgorithm
-> HashedBody
-> PutSnapshotBlock
PutSnapshotBlock'
      { $sel:progress:PutSnapshotBlock' :: Maybe Natural
progress = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
        $sel:snapshotId:PutSnapshotBlock' :: Text
snapshotId = Text
pSnapshotId_,
        $sel:blockIndex:PutSnapshotBlock' :: Natural
blockIndex = Natural
pBlockIndex_,
        $sel:dataLength:PutSnapshotBlock' :: Int
dataLength = Int
pDataLength_,
        $sel:checksum:PutSnapshotBlock' :: Text
checksum = Text
pChecksum_,
        $sel:checksumAlgorithm:PutSnapshotBlock' :: ChecksumAlgorithm
checksumAlgorithm = ChecksumAlgorithm
pChecksumAlgorithm_,
        $sel:blockData:PutSnapshotBlock' :: HashedBody
blockData = HashedBody
pBlockData_
      }

-- | The progress of the write process, as a percentage.
putSnapshotBlock_progress :: Lens.Lens' PutSnapshotBlock (Prelude.Maybe Prelude.Natural)
putSnapshotBlock_progress :: (Maybe Natural -> f (Maybe Natural))
-> PutSnapshotBlock -> f PutSnapshotBlock
putSnapshotBlock_progress = (PutSnapshotBlock -> Maybe Natural)
-> (PutSnapshotBlock -> Maybe Natural -> PutSnapshotBlock)
-> Lens
     PutSnapshotBlock PutSnapshotBlock (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutSnapshotBlock' {Maybe Natural
progress :: Maybe Natural
$sel:progress:PutSnapshotBlock' :: PutSnapshotBlock -> Maybe Natural
progress} -> Maybe Natural
progress) (\s :: PutSnapshotBlock
s@PutSnapshotBlock' {} Maybe Natural
a -> PutSnapshotBlock
s {$sel:progress:PutSnapshotBlock' :: Maybe Natural
progress = Maybe Natural
a} :: PutSnapshotBlock)

-- | The ID of the snapshot.
putSnapshotBlock_snapshotId :: Lens.Lens' PutSnapshotBlock Prelude.Text
putSnapshotBlock_snapshotId :: (Text -> f Text) -> PutSnapshotBlock -> f PutSnapshotBlock
putSnapshotBlock_snapshotId = (PutSnapshotBlock -> Text)
-> (PutSnapshotBlock -> Text -> PutSnapshotBlock)
-> Lens PutSnapshotBlock PutSnapshotBlock Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutSnapshotBlock' {Text
snapshotId :: Text
$sel:snapshotId:PutSnapshotBlock' :: PutSnapshotBlock -> Text
snapshotId} -> Text
snapshotId) (\s :: PutSnapshotBlock
s@PutSnapshotBlock' {} Text
a -> PutSnapshotBlock
s {$sel:snapshotId:PutSnapshotBlock' :: Text
snapshotId = Text
a} :: PutSnapshotBlock)

-- | The block index of the block in which to write the data. A block index
-- is a logical index in units of @512@ KiB blocks. To identify the block
-- index, divide the logical offset of the data in the logical volume by
-- the block size (logical offset of data\/@524288@). The logical offset of
-- the data must be @512@ KiB aligned.
putSnapshotBlock_blockIndex :: Lens.Lens' PutSnapshotBlock Prelude.Natural
putSnapshotBlock_blockIndex :: (Natural -> f Natural) -> PutSnapshotBlock -> f PutSnapshotBlock
putSnapshotBlock_blockIndex = (PutSnapshotBlock -> Natural)
-> (PutSnapshotBlock -> Natural -> PutSnapshotBlock)
-> Lens PutSnapshotBlock PutSnapshotBlock Natural Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutSnapshotBlock' {Natural
blockIndex :: Natural
$sel:blockIndex:PutSnapshotBlock' :: PutSnapshotBlock -> Natural
blockIndex} -> Natural
blockIndex) (\s :: PutSnapshotBlock
s@PutSnapshotBlock' {} Natural
a -> PutSnapshotBlock
s {$sel:blockIndex:PutSnapshotBlock' :: Natural
blockIndex = Natural
a} :: PutSnapshotBlock)

-- | The size of the data to write to the block, in bytes. Currently, the
-- only supported size is @524288@ bytes.
--
-- Valid values: @524288@
putSnapshotBlock_dataLength :: Lens.Lens' PutSnapshotBlock Prelude.Int
putSnapshotBlock_dataLength :: (Int -> f Int) -> PutSnapshotBlock -> f PutSnapshotBlock
putSnapshotBlock_dataLength = (PutSnapshotBlock -> Int)
-> (PutSnapshotBlock -> Int -> PutSnapshotBlock)
-> Lens PutSnapshotBlock PutSnapshotBlock Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutSnapshotBlock' {Int
dataLength :: Int
$sel:dataLength:PutSnapshotBlock' :: PutSnapshotBlock -> Int
dataLength} -> Int
dataLength) (\s :: PutSnapshotBlock
s@PutSnapshotBlock' {} Int
a -> PutSnapshotBlock
s {$sel:dataLength:PutSnapshotBlock' :: Int
dataLength = Int
a} :: PutSnapshotBlock)

-- | A Base64-encoded SHA256 checksum of the data. Only SHA256 checksums are
-- supported.
putSnapshotBlock_checksum :: Lens.Lens' PutSnapshotBlock Prelude.Text
putSnapshotBlock_checksum :: (Text -> f Text) -> PutSnapshotBlock -> f PutSnapshotBlock
putSnapshotBlock_checksum = (PutSnapshotBlock -> Text)
-> (PutSnapshotBlock -> Text -> PutSnapshotBlock)
-> Lens PutSnapshotBlock PutSnapshotBlock Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutSnapshotBlock' {Text
checksum :: Text
$sel:checksum:PutSnapshotBlock' :: PutSnapshotBlock -> Text
checksum} -> Text
checksum) (\s :: PutSnapshotBlock
s@PutSnapshotBlock' {} Text
a -> PutSnapshotBlock
s {$sel:checksum:PutSnapshotBlock' :: Text
checksum = Text
a} :: PutSnapshotBlock)

-- | The algorithm used to generate the checksum. Currently, the only
-- supported algorithm is @SHA256@.
putSnapshotBlock_checksumAlgorithm :: Lens.Lens' PutSnapshotBlock ChecksumAlgorithm
putSnapshotBlock_checksumAlgorithm :: (ChecksumAlgorithm -> f ChecksumAlgorithm)
-> PutSnapshotBlock -> f PutSnapshotBlock
putSnapshotBlock_checksumAlgorithm = (PutSnapshotBlock -> ChecksumAlgorithm)
-> (PutSnapshotBlock -> ChecksumAlgorithm -> PutSnapshotBlock)
-> Lens
     PutSnapshotBlock
     PutSnapshotBlock
     ChecksumAlgorithm
     ChecksumAlgorithm
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutSnapshotBlock' {ChecksumAlgorithm
checksumAlgorithm :: ChecksumAlgorithm
$sel:checksumAlgorithm:PutSnapshotBlock' :: PutSnapshotBlock -> ChecksumAlgorithm
checksumAlgorithm} -> ChecksumAlgorithm
checksumAlgorithm) (\s :: PutSnapshotBlock
s@PutSnapshotBlock' {} ChecksumAlgorithm
a -> PutSnapshotBlock
s {$sel:checksumAlgorithm:PutSnapshotBlock' :: ChecksumAlgorithm
checksumAlgorithm = ChecksumAlgorithm
a} :: PutSnapshotBlock)

-- | The data to write to the block.
--
-- The block data is not signed as part of the Signature Version 4 signing
-- process. As a result, you must generate and provide a Base64-encoded
-- SHA256 checksum for the block data using the __x-amz-Checksum__ header.
-- Also, you must specify the checksum algorithm using the
-- __x-amz-Checksum-Algorithm__ header. The checksum that you provide is
-- part of the Signature Version 4 signing process. It is validated against
-- a checksum generated by Amazon EBS to ensure the validity and
-- authenticity of the data. If the checksums do not correspond, the
-- request fails. For more information, see
-- <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-accessing-snapshot.html#ebsapis-using-checksums Using checksums with the EBS direct APIs>
-- in the /Amazon Elastic Compute Cloud User Guide/.
putSnapshotBlock_blockData :: Lens.Lens' PutSnapshotBlock Core.HashedBody
putSnapshotBlock_blockData :: (HashedBody -> f HashedBody)
-> PutSnapshotBlock -> f PutSnapshotBlock
putSnapshotBlock_blockData = (PutSnapshotBlock -> HashedBody)
-> (PutSnapshotBlock -> HashedBody -> PutSnapshotBlock)
-> Lens PutSnapshotBlock PutSnapshotBlock HashedBody HashedBody
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutSnapshotBlock' {HashedBody
blockData :: HashedBody
$sel:blockData:PutSnapshotBlock' :: PutSnapshotBlock -> HashedBody
blockData} -> HashedBody
blockData) (\s :: PutSnapshotBlock
s@PutSnapshotBlock' {} HashedBody
a -> PutSnapshotBlock
s {$sel:blockData:PutSnapshotBlock' :: HashedBody
blockData = HashedBody
a} :: PutSnapshotBlock)

instance Core.AWSRequest PutSnapshotBlock where
  type
    AWSResponse PutSnapshotBlock =
      PutSnapshotBlockResponse
  request :: PutSnapshotBlock -> Request PutSnapshotBlock
request = Service -> PutSnapshotBlock -> Request PutSnapshotBlock
forall a. (ToRequest a, ToBody a) => Service -> a -> Request a
Request.putBody Service
defaultService
  response :: Logger
-> Service
-> Proxy PutSnapshotBlock
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutSnapshotBlock)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse PutSnapshotBlock))
-> Logger
-> Service
-> Proxy PutSnapshotBlock
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutSnapshotBlock)))
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 ->
          Maybe ChecksumAlgorithm
-> Maybe Text -> Int -> PutSnapshotBlockResponse
PutSnapshotBlockResponse'
            (Maybe ChecksumAlgorithm
 -> Maybe Text -> Int -> PutSnapshotBlockResponse)
-> Either String (Maybe ChecksumAlgorithm)
-> Either String (Maybe Text -> Int -> PutSnapshotBlockResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (ResponseHeaders
h ResponseHeaders
-> HeaderName -> Either String (Maybe ChecksumAlgorithm)
forall a.
FromText a =>
ResponseHeaders -> HeaderName -> Either String (Maybe a)
Core..#? HeaderName
"x-amz-Checksum-Algorithm")
            Either String (Maybe Text -> Int -> PutSnapshotBlockResponse)
-> Either String (Maybe Text)
-> Either String (Int -> PutSnapshotBlockResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (ResponseHeaders
h ResponseHeaders -> HeaderName -> Either String (Maybe Text)
forall a.
FromText a =>
ResponseHeaders -> HeaderName -> Either String (Maybe a)
Core..#? HeaderName
"x-amz-Checksum")
            Either String (Int -> PutSnapshotBlockResponse)
-> Either String Int -> Either String PutSnapshotBlockResponse
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 Core.ToBody PutSnapshotBlock where
  toBody :: PutSnapshotBlock -> RequestBody
toBody PutSnapshotBlock' {Int
Natural
Maybe Natural
Text
HashedBody
ChecksumAlgorithm
blockData :: HashedBody
checksumAlgorithm :: ChecksumAlgorithm
checksum :: Text
dataLength :: Int
blockIndex :: Natural
snapshotId :: Text
progress :: Maybe Natural
$sel:blockData:PutSnapshotBlock' :: PutSnapshotBlock -> HashedBody
$sel:checksumAlgorithm:PutSnapshotBlock' :: PutSnapshotBlock -> ChecksumAlgorithm
$sel:checksum:PutSnapshotBlock' :: PutSnapshotBlock -> Text
$sel:dataLength:PutSnapshotBlock' :: PutSnapshotBlock -> Int
$sel:blockIndex:PutSnapshotBlock' :: PutSnapshotBlock -> Natural
$sel:snapshotId:PutSnapshotBlock' :: PutSnapshotBlock -> Text
$sel:progress:PutSnapshotBlock' :: PutSnapshotBlock -> Maybe Natural
..} = HashedBody -> RequestBody
forall a. ToBody a => a -> RequestBody
Core.toBody HashedBody
blockData

instance Core.ToHeaders PutSnapshotBlock where
  toHeaders :: PutSnapshotBlock -> ResponseHeaders
toHeaders PutSnapshotBlock' {Int
Natural
Maybe Natural
Text
HashedBody
ChecksumAlgorithm
blockData :: HashedBody
checksumAlgorithm :: ChecksumAlgorithm
checksum :: Text
dataLength :: Int
blockIndex :: Natural
snapshotId :: Text
progress :: Maybe Natural
$sel:blockData:PutSnapshotBlock' :: PutSnapshotBlock -> HashedBody
$sel:checksumAlgorithm:PutSnapshotBlock' :: PutSnapshotBlock -> ChecksumAlgorithm
$sel:checksum:PutSnapshotBlock' :: PutSnapshotBlock -> Text
$sel:dataLength:PutSnapshotBlock' :: PutSnapshotBlock -> Int
$sel:blockIndex:PutSnapshotBlock' :: PutSnapshotBlock -> Natural
$sel:snapshotId:PutSnapshotBlock' :: PutSnapshotBlock -> Text
$sel:progress:PutSnapshotBlock' :: PutSnapshotBlock -> Maybe Natural
..} =
    [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ HeaderName
"x-amz-Progress" HeaderName -> Maybe Natural -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# Maybe Natural
progress,
        HeaderName
"x-amz-Data-Length" HeaderName -> Int -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# Int
dataLength,
        HeaderName
"x-amz-Checksum" HeaderName -> Text -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# Text
checksum,
        HeaderName
"x-amz-Checksum-Algorithm" HeaderName -> ChecksumAlgorithm -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ChecksumAlgorithm
checksumAlgorithm,
        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.ToPath PutSnapshotBlock where
  toPath :: PutSnapshotBlock -> ByteString
toPath PutSnapshotBlock' {Int
Natural
Maybe Natural
Text
HashedBody
ChecksumAlgorithm
blockData :: HashedBody
checksumAlgorithm :: ChecksumAlgorithm
checksum :: Text
dataLength :: Int
blockIndex :: Natural
snapshotId :: Text
progress :: Maybe Natural
$sel:blockData:PutSnapshotBlock' :: PutSnapshotBlock -> HashedBody
$sel:checksumAlgorithm:PutSnapshotBlock' :: PutSnapshotBlock -> ChecksumAlgorithm
$sel:checksum:PutSnapshotBlock' :: PutSnapshotBlock -> Text
$sel:dataLength:PutSnapshotBlock' :: PutSnapshotBlock -> Int
$sel:blockIndex:PutSnapshotBlock' :: PutSnapshotBlock -> Natural
$sel:snapshotId:PutSnapshotBlock' :: PutSnapshotBlock -> Text
$sel:progress:PutSnapshotBlock' :: PutSnapshotBlock -> Maybe Natural
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/snapshots/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
snapshotId,
        ByteString
"/blocks/",
        Natural -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Natural
blockIndex
      ]

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

-- | /See:/ 'newPutSnapshotBlockResponse' smart constructor.
data PutSnapshotBlockResponse = PutSnapshotBlockResponse'
  { -- | The algorithm used by Amazon EBS to generate the checksum.
    PutSnapshotBlockResponse -> Maybe ChecksumAlgorithm
checksumAlgorithm :: Prelude.Maybe ChecksumAlgorithm,
    -- | The SHA256 checksum generated for the block data by Amazon EBS.
    PutSnapshotBlockResponse -> Maybe Text
checksum :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    PutSnapshotBlockResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (PutSnapshotBlockResponse -> PutSnapshotBlockResponse -> Bool
(PutSnapshotBlockResponse -> PutSnapshotBlockResponse -> Bool)
-> (PutSnapshotBlockResponse -> PutSnapshotBlockResponse -> Bool)
-> Eq PutSnapshotBlockResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutSnapshotBlockResponse -> PutSnapshotBlockResponse -> Bool
$c/= :: PutSnapshotBlockResponse -> PutSnapshotBlockResponse -> Bool
== :: PutSnapshotBlockResponse -> PutSnapshotBlockResponse -> Bool
$c== :: PutSnapshotBlockResponse -> PutSnapshotBlockResponse -> Bool
Prelude.Eq, ReadPrec [PutSnapshotBlockResponse]
ReadPrec PutSnapshotBlockResponse
Int -> ReadS PutSnapshotBlockResponse
ReadS [PutSnapshotBlockResponse]
(Int -> ReadS PutSnapshotBlockResponse)
-> ReadS [PutSnapshotBlockResponse]
-> ReadPrec PutSnapshotBlockResponse
-> ReadPrec [PutSnapshotBlockResponse]
-> Read PutSnapshotBlockResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutSnapshotBlockResponse]
$creadListPrec :: ReadPrec [PutSnapshotBlockResponse]
readPrec :: ReadPrec PutSnapshotBlockResponse
$creadPrec :: ReadPrec PutSnapshotBlockResponse
readList :: ReadS [PutSnapshotBlockResponse]
$creadList :: ReadS [PutSnapshotBlockResponse]
readsPrec :: Int -> ReadS PutSnapshotBlockResponse
$creadsPrec :: Int -> ReadS PutSnapshotBlockResponse
Prelude.Read, Int -> PutSnapshotBlockResponse -> ShowS
[PutSnapshotBlockResponse] -> ShowS
PutSnapshotBlockResponse -> String
(Int -> PutSnapshotBlockResponse -> ShowS)
-> (PutSnapshotBlockResponse -> String)
-> ([PutSnapshotBlockResponse] -> ShowS)
-> Show PutSnapshotBlockResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutSnapshotBlockResponse] -> ShowS
$cshowList :: [PutSnapshotBlockResponse] -> ShowS
show :: PutSnapshotBlockResponse -> String
$cshow :: PutSnapshotBlockResponse -> String
showsPrec :: Int -> PutSnapshotBlockResponse -> ShowS
$cshowsPrec :: Int -> PutSnapshotBlockResponse -> ShowS
Prelude.Show, (forall x.
 PutSnapshotBlockResponse -> Rep PutSnapshotBlockResponse x)
-> (forall x.
    Rep PutSnapshotBlockResponse x -> PutSnapshotBlockResponse)
-> Generic PutSnapshotBlockResponse
forall x.
Rep PutSnapshotBlockResponse x -> PutSnapshotBlockResponse
forall x.
PutSnapshotBlockResponse -> Rep PutSnapshotBlockResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PutSnapshotBlockResponse x -> PutSnapshotBlockResponse
$cfrom :: forall x.
PutSnapshotBlockResponse -> Rep PutSnapshotBlockResponse x
Prelude.Generic)

-- |
-- Create a value of 'PutSnapshotBlockResponse' 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:
--
-- 'checksumAlgorithm', 'putSnapshotBlockResponse_checksumAlgorithm' - The algorithm used by Amazon EBS to generate the checksum.
--
-- 'checksum', 'putSnapshotBlockResponse_checksum' - The SHA256 checksum generated for the block data by Amazon EBS.
--
-- 'httpStatus', 'putSnapshotBlockResponse_httpStatus' - The response's http status code.
newPutSnapshotBlockResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  PutSnapshotBlockResponse
newPutSnapshotBlockResponse :: Int -> PutSnapshotBlockResponse
newPutSnapshotBlockResponse Int
pHttpStatus_ =
  PutSnapshotBlockResponse' :: Maybe ChecksumAlgorithm
-> Maybe Text -> Int -> PutSnapshotBlockResponse
PutSnapshotBlockResponse'
    { $sel:checksumAlgorithm:PutSnapshotBlockResponse' :: Maybe ChecksumAlgorithm
checksumAlgorithm =
        Maybe ChecksumAlgorithm
forall a. Maybe a
Prelude.Nothing,
      $sel:checksum:PutSnapshotBlockResponse' :: Maybe Text
checksum = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:PutSnapshotBlockResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The algorithm used by Amazon EBS to generate the checksum.
putSnapshotBlockResponse_checksumAlgorithm :: Lens.Lens' PutSnapshotBlockResponse (Prelude.Maybe ChecksumAlgorithm)
putSnapshotBlockResponse_checksumAlgorithm :: (Maybe ChecksumAlgorithm -> f (Maybe ChecksumAlgorithm))
-> PutSnapshotBlockResponse -> f PutSnapshotBlockResponse
putSnapshotBlockResponse_checksumAlgorithm = (PutSnapshotBlockResponse -> Maybe ChecksumAlgorithm)
-> (PutSnapshotBlockResponse
    -> Maybe ChecksumAlgorithm -> PutSnapshotBlockResponse)
-> Lens
     PutSnapshotBlockResponse
     PutSnapshotBlockResponse
     (Maybe ChecksumAlgorithm)
     (Maybe ChecksumAlgorithm)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutSnapshotBlockResponse' {Maybe ChecksumAlgorithm
checksumAlgorithm :: Maybe ChecksumAlgorithm
$sel:checksumAlgorithm:PutSnapshotBlockResponse' :: PutSnapshotBlockResponse -> Maybe ChecksumAlgorithm
checksumAlgorithm} -> Maybe ChecksumAlgorithm
checksumAlgorithm) (\s :: PutSnapshotBlockResponse
s@PutSnapshotBlockResponse' {} Maybe ChecksumAlgorithm
a -> PutSnapshotBlockResponse
s {$sel:checksumAlgorithm:PutSnapshotBlockResponse' :: Maybe ChecksumAlgorithm
checksumAlgorithm = Maybe ChecksumAlgorithm
a} :: PutSnapshotBlockResponse)

-- | The SHA256 checksum generated for the block data by Amazon EBS.
putSnapshotBlockResponse_checksum :: Lens.Lens' PutSnapshotBlockResponse (Prelude.Maybe Prelude.Text)
putSnapshotBlockResponse_checksum :: (Maybe Text -> f (Maybe Text))
-> PutSnapshotBlockResponse -> f PutSnapshotBlockResponse
putSnapshotBlockResponse_checksum = (PutSnapshotBlockResponse -> Maybe Text)
-> (PutSnapshotBlockResponse
    -> Maybe Text -> PutSnapshotBlockResponse)
-> Lens
     PutSnapshotBlockResponse
     PutSnapshotBlockResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutSnapshotBlockResponse' {Maybe Text
checksum :: Maybe Text
$sel:checksum:PutSnapshotBlockResponse' :: PutSnapshotBlockResponse -> Maybe Text
checksum} -> Maybe Text
checksum) (\s :: PutSnapshotBlockResponse
s@PutSnapshotBlockResponse' {} Maybe Text
a -> PutSnapshotBlockResponse
s {$sel:checksum:PutSnapshotBlockResponse' :: Maybe Text
checksum = Maybe Text
a} :: PutSnapshotBlockResponse)

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

instance Prelude.NFData PutSnapshotBlockResponse