{-# 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.Glacier.UploadArchive
(
UploadArchive (..),
newUploadArchive,
uploadArchive_checksum,
uploadArchive_archiveDescription,
uploadArchive_vaultName,
uploadArchive_accountId,
uploadArchive_body,
ArchiveCreationOutput (..),
newArchiveCreationOutput,
archiveCreationOutput_archiveId,
archiveCreationOutput_checksum,
archiveCreationOutput_location,
)
where
import qualified Amazonka.Core as Core
import Amazonka.Glacier.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
data UploadArchive = UploadArchive'
{
UploadArchive -> Maybe Text
checksum :: Prelude.Maybe Prelude.Text,
UploadArchive -> Maybe Text
archiveDescription :: Prelude.Maybe Prelude.Text,
UploadArchive -> Text
vaultName :: Prelude.Text,
UploadArchive -> Text
accountId :: Prelude.Text,
UploadArchive -> HashedBody
body :: Core.HashedBody
}
deriving (Int -> UploadArchive -> ShowS
[UploadArchive] -> ShowS
UploadArchive -> String
(Int -> UploadArchive -> ShowS)
-> (UploadArchive -> String)
-> ([UploadArchive] -> ShowS)
-> Show UploadArchive
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UploadArchive] -> ShowS
$cshowList :: [UploadArchive] -> ShowS
show :: UploadArchive -> String
$cshow :: UploadArchive -> String
showsPrec :: Int -> UploadArchive -> ShowS
$cshowsPrec :: Int -> UploadArchive -> ShowS
Prelude.Show, (forall x. UploadArchive -> Rep UploadArchive x)
-> (forall x. Rep UploadArchive x -> UploadArchive)
-> Generic UploadArchive
forall x. Rep UploadArchive x -> UploadArchive
forall x. UploadArchive -> Rep UploadArchive x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UploadArchive x -> UploadArchive
$cfrom :: forall x. UploadArchive -> Rep UploadArchive x
Prelude.Generic)
newUploadArchive ::
Prelude.Text ->
Prelude.Text ->
Core.HashedBody ->
UploadArchive
newUploadArchive :: Text -> Text -> HashedBody -> UploadArchive
newUploadArchive Text
pVaultName_ Text
pAccountId_ HashedBody
pBody_ =
UploadArchive' :: Maybe Text
-> Maybe Text -> Text -> Text -> HashedBody -> UploadArchive
UploadArchive'
{ $sel:checksum:UploadArchive' :: Maybe Text
checksum = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:archiveDescription:UploadArchive' :: Maybe Text
archiveDescription = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:vaultName:UploadArchive' :: Text
vaultName = Text
pVaultName_,
$sel:accountId:UploadArchive' :: Text
accountId = Text
pAccountId_,
$sel:body:UploadArchive' :: HashedBody
body = HashedBody
pBody_
}
uploadArchive_checksum :: Lens.Lens' UploadArchive (Prelude.Maybe Prelude.Text)
uploadArchive_checksum :: (Maybe Text -> f (Maybe Text)) -> UploadArchive -> f UploadArchive
uploadArchive_checksum = (UploadArchive -> Maybe Text)
-> (UploadArchive -> Maybe Text -> UploadArchive)
-> Lens UploadArchive UploadArchive (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UploadArchive' {Maybe Text
checksum :: Maybe Text
$sel:checksum:UploadArchive' :: UploadArchive -> Maybe Text
checksum} -> Maybe Text
checksum) (\s :: UploadArchive
s@UploadArchive' {} Maybe Text
a -> UploadArchive
s {$sel:checksum:UploadArchive' :: Maybe Text
checksum = Maybe Text
a} :: UploadArchive)
uploadArchive_archiveDescription :: Lens.Lens' UploadArchive (Prelude.Maybe Prelude.Text)
uploadArchive_archiveDescription :: (Maybe Text -> f (Maybe Text)) -> UploadArchive -> f UploadArchive
uploadArchive_archiveDescription = (UploadArchive -> Maybe Text)
-> (UploadArchive -> Maybe Text -> UploadArchive)
-> Lens UploadArchive UploadArchive (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UploadArchive' {Maybe Text
archiveDescription :: Maybe Text
$sel:archiveDescription:UploadArchive' :: UploadArchive -> Maybe Text
archiveDescription} -> Maybe Text
archiveDescription) (\s :: UploadArchive
s@UploadArchive' {} Maybe Text
a -> UploadArchive
s {$sel:archiveDescription:UploadArchive' :: Maybe Text
archiveDescription = Maybe Text
a} :: UploadArchive)
uploadArchive_vaultName :: Lens.Lens' UploadArchive Prelude.Text
uploadArchive_vaultName :: (Text -> f Text) -> UploadArchive -> f UploadArchive
uploadArchive_vaultName = (UploadArchive -> Text)
-> (UploadArchive -> Text -> UploadArchive)
-> Lens UploadArchive UploadArchive Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UploadArchive' {Text
vaultName :: Text
$sel:vaultName:UploadArchive' :: UploadArchive -> Text
vaultName} -> Text
vaultName) (\s :: UploadArchive
s@UploadArchive' {} Text
a -> UploadArchive
s {$sel:vaultName:UploadArchive' :: Text
vaultName = Text
a} :: UploadArchive)
uploadArchive_accountId :: Lens.Lens' UploadArchive Prelude.Text
uploadArchive_accountId :: (Text -> f Text) -> UploadArchive -> f UploadArchive
uploadArchive_accountId = (UploadArchive -> Text)
-> (UploadArchive -> Text -> UploadArchive)
-> Lens UploadArchive UploadArchive Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UploadArchive' {Text
accountId :: Text
$sel:accountId:UploadArchive' :: UploadArchive -> Text
accountId} -> Text
accountId) (\s :: UploadArchive
s@UploadArchive' {} Text
a -> UploadArchive
s {$sel:accountId:UploadArchive' :: Text
accountId = Text
a} :: UploadArchive)
uploadArchive_body :: Lens.Lens' UploadArchive Core.HashedBody
uploadArchive_body :: (HashedBody -> f HashedBody) -> UploadArchive -> f UploadArchive
uploadArchive_body = (UploadArchive -> HashedBody)
-> (UploadArchive -> HashedBody -> UploadArchive)
-> Lens UploadArchive UploadArchive HashedBody HashedBody
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UploadArchive' {HashedBody
body :: HashedBody
$sel:body:UploadArchive' :: UploadArchive -> HashedBody
body} -> HashedBody
body) (\s :: UploadArchive
s@UploadArchive' {} HashedBody
a -> UploadArchive
s {$sel:body:UploadArchive' :: HashedBody
body = HashedBody
a} :: UploadArchive)
instance Core.AWSRequest UploadArchive where
type
AWSResponse UploadArchive =
ArchiveCreationOutput
request :: UploadArchive -> Request UploadArchive
request =
ByteString -> Request UploadArchive -> Request UploadArchive
forall a. ByteString -> Request a -> Request a
Request.glacierVersionHeader (Service -> ByteString
Core._serviceVersion Service
defaultService)
(Request UploadArchive -> Request UploadArchive)
-> (UploadArchive -> Request UploadArchive)
-> UploadArchive
-> Request UploadArchive
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Service -> UploadArchive -> Request UploadArchive
forall a. (ToRequest a, ToBody a) => Service -> a -> Request a
Request.postBody Service
defaultService
response :: Logger
-> Service
-> Proxy UploadArchive
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UploadArchive)))
response =
(Int
-> ResponseHeaders
-> ()
-> Either String (AWSResponse UploadArchive))
-> Logger
-> Service
-> Proxy UploadArchive
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UploadArchive)))
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 Text -> Maybe Text -> Maybe Text -> ArchiveCreationOutput
ArchiveCreationOutput'
(Maybe Text -> Maybe Text -> Maybe Text -> ArchiveCreationOutput)
-> Either String (Maybe Text)
-> Either
String (Maybe Text -> Maybe Text -> ArchiveCreationOutput)
forall (f :: * -> *) a b. Functor 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-archive-id")
Either String (Maybe Text -> Maybe Text -> ArchiveCreationOutput)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> ArchiveCreationOutput)
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-sha256-tree-hash")
Either String (Maybe Text -> ArchiveCreationOutput)
-> Either String (Maybe Text)
-> Either String ArchiveCreationOutput
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
"Location")
)
instance Core.ToBody UploadArchive where
toBody :: UploadArchive -> RequestBody
toBody UploadArchive' {Maybe Text
Text
HashedBody
body :: HashedBody
accountId :: Text
vaultName :: Text
archiveDescription :: Maybe Text
checksum :: Maybe Text
$sel:body:UploadArchive' :: UploadArchive -> HashedBody
$sel:accountId:UploadArchive' :: UploadArchive -> Text
$sel:vaultName:UploadArchive' :: UploadArchive -> Text
$sel:archiveDescription:UploadArchive' :: UploadArchive -> Maybe Text
$sel:checksum:UploadArchive' :: UploadArchive -> Maybe Text
..} = HashedBody -> RequestBody
forall a. ToBody a => a -> RequestBody
Core.toBody HashedBody
body
instance Core.ToHeaders UploadArchive where
toHeaders :: UploadArchive -> ResponseHeaders
toHeaders UploadArchive' {Maybe Text
Text
HashedBody
body :: HashedBody
accountId :: Text
vaultName :: Text
archiveDescription :: Maybe Text
checksum :: Maybe Text
$sel:body:UploadArchive' :: UploadArchive -> HashedBody
$sel:accountId:UploadArchive' :: UploadArchive -> Text
$sel:vaultName:UploadArchive' :: UploadArchive -> Text
$sel:archiveDescription:UploadArchive' :: UploadArchive -> Maybe Text
$sel:checksum:UploadArchive' :: UploadArchive -> Maybe Text
..} =
[ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"x-amz-sha256-tree-hash" HeaderName -> Maybe Text -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# Maybe Text
checksum,
HeaderName
"x-amz-archive-description"
HeaderName -> Maybe Text -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# Maybe Text
archiveDescription
]
instance Core.ToPath UploadArchive where
toPath :: UploadArchive -> ByteString
toPath UploadArchive' {Maybe Text
Text
HashedBody
body :: HashedBody
accountId :: Text
vaultName :: Text
archiveDescription :: Maybe Text
checksum :: Maybe Text
$sel:body:UploadArchive' :: UploadArchive -> HashedBody
$sel:accountId:UploadArchive' :: UploadArchive -> Text
$sel:vaultName:UploadArchive' :: UploadArchive -> Text
$sel:archiveDescription:UploadArchive' :: UploadArchive -> Maybe Text
$sel:checksum:UploadArchive' :: UploadArchive -> Maybe Text
..} =
[ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ ByteString
"/",
Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
accountId,
ByteString
"/vaults/",
Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
vaultName,
ByteString
"/archives"
]
instance Core.ToQuery UploadArchive where
toQuery :: UploadArchive -> QueryString
toQuery = QueryString -> UploadArchive -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty