{-# 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.InitiateJob
(
InitiateJob (..),
newInitiateJob,
initiateJob_jobParameters,
initiateJob_accountId,
initiateJob_vaultName,
InitiateJobResponse (..),
newInitiateJobResponse,
initiateJobResponse_jobId,
initiateJobResponse_jobOutputPath,
initiateJobResponse_location,
initiateJobResponse_httpStatus,
)
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 InitiateJob = InitiateJob'
{
InitiateJob -> Maybe JobParameters
jobParameters :: Prelude.Maybe JobParameters,
InitiateJob -> Text
accountId :: Prelude.Text,
InitiateJob -> Text
vaultName :: Prelude.Text
}
deriving (InitiateJob -> InitiateJob -> Bool
(InitiateJob -> InitiateJob -> Bool)
-> (InitiateJob -> InitiateJob -> Bool) -> Eq InitiateJob
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InitiateJob -> InitiateJob -> Bool
$c/= :: InitiateJob -> InitiateJob -> Bool
== :: InitiateJob -> InitiateJob -> Bool
$c== :: InitiateJob -> InitiateJob -> Bool
Prelude.Eq, ReadPrec [InitiateJob]
ReadPrec InitiateJob
Int -> ReadS InitiateJob
ReadS [InitiateJob]
(Int -> ReadS InitiateJob)
-> ReadS [InitiateJob]
-> ReadPrec InitiateJob
-> ReadPrec [InitiateJob]
-> Read InitiateJob
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InitiateJob]
$creadListPrec :: ReadPrec [InitiateJob]
readPrec :: ReadPrec InitiateJob
$creadPrec :: ReadPrec InitiateJob
readList :: ReadS [InitiateJob]
$creadList :: ReadS [InitiateJob]
readsPrec :: Int -> ReadS InitiateJob
$creadsPrec :: Int -> ReadS InitiateJob
Prelude.Read, Int -> InitiateJob -> ShowS
[InitiateJob] -> ShowS
InitiateJob -> String
(Int -> InitiateJob -> ShowS)
-> (InitiateJob -> String)
-> ([InitiateJob] -> ShowS)
-> Show InitiateJob
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InitiateJob] -> ShowS
$cshowList :: [InitiateJob] -> ShowS
show :: InitiateJob -> String
$cshow :: InitiateJob -> String
showsPrec :: Int -> InitiateJob -> ShowS
$cshowsPrec :: Int -> InitiateJob -> ShowS
Prelude.Show, (forall x. InitiateJob -> Rep InitiateJob x)
-> (forall x. Rep InitiateJob x -> InitiateJob)
-> Generic InitiateJob
forall x. Rep InitiateJob x -> InitiateJob
forall x. InitiateJob -> Rep InitiateJob x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InitiateJob x -> InitiateJob
$cfrom :: forall x. InitiateJob -> Rep InitiateJob x
Prelude.Generic)
newInitiateJob ::
Prelude.Text ->
Prelude.Text ->
InitiateJob
newInitiateJob :: Text -> Text -> InitiateJob
newInitiateJob Text
pAccountId_ Text
pVaultName_ =
InitiateJob' :: Maybe JobParameters -> Text -> Text -> InitiateJob
InitiateJob'
{ $sel:jobParameters:InitiateJob' :: Maybe JobParameters
jobParameters = Maybe JobParameters
forall a. Maybe a
Prelude.Nothing,
$sel:accountId:InitiateJob' :: Text
accountId = Text
pAccountId_,
$sel:vaultName:InitiateJob' :: Text
vaultName = Text
pVaultName_
}
initiateJob_jobParameters :: Lens.Lens' InitiateJob (Prelude.Maybe JobParameters)
initiateJob_jobParameters :: (Maybe JobParameters -> f (Maybe JobParameters))
-> InitiateJob -> f InitiateJob
initiateJob_jobParameters = (InitiateJob -> Maybe JobParameters)
-> (InitiateJob -> Maybe JobParameters -> InitiateJob)
-> Lens
InitiateJob InitiateJob (Maybe JobParameters) (Maybe JobParameters)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InitiateJob' {Maybe JobParameters
jobParameters :: Maybe JobParameters
$sel:jobParameters:InitiateJob' :: InitiateJob -> Maybe JobParameters
jobParameters} -> Maybe JobParameters
jobParameters) (\s :: InitiateJob
s@InitiateJob' {} Maybe JobParameters
a -> InitiateJob
s {$sel:jobParameters:InitiateJob' :: Maybe JobParameters
jobParameters = Maybe JobParameters
a} :: InitiateJob)
initiateJob_accountId :: Lens.Lens' InitiateJob Prelude.Text
initiateJob_accountId :: (Text -> f Text) -> InitiateJob -> f InitiateJob
initiateJob_accountId = (InitiateJob -> Text)
-> (InitiateJob -> Text -> InitiateJob)
-> Lens InitiateJob InitiateJob Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InitiateJob' {Text
accountId :: Text
$sel:accountId:InitiateJob' :: InitiateJob -> Text
accountId} -> Text
accountId) (\s :: InitiateJob
s@InitiateJob' {} Text
a -> InitiateJob
s {$sel:accountId:InitiateJob' :: Text
accountId = Text
a} :: InitiateJob)
initiateJob_vaultName :: Lens.Lens' InitiateJob Prelude.Text
initiateJob_vaultName :: (Text -> f Text) -> InitiateJob -> f InitiateJob
initiateJob_vaultName = (InitiateJob -> Text)
-> (InitiateJob -> Text -> InitiateJob)
-> Lens InitiateJob InitiateJob Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InitiateJob' {Text
vaultName :: Text
$sel:vaultName:InitiateJob' :: InitiateJob -> Text
vaultName} -> Text
vaultName) (\s :: InitiateJob
s@InitiateJob' {} Text
a -> InitiateJob
s {$sel:vaultName:InitiateJob' :: Text
vaultName = Text
a} :: InitiateJob)
instance Core.AWSRequest InitiateJob where
type AWSResponse InitiateJob = InitiateJobResponse
request :: InitiateJob -> Request InitiateJob
request =
ByteString -> Request InitiateJob -> Request InitiateJob
forall a. ByteString -> Request a -> Request a
Request.glacierVersionHeader (Service -> ByteString
Core._serviceVersion Service
defaultService)
(Request InitiateJob -> Request InitiateJob)
-> (InitiateJob -> Request InitiateJob)
-> InitiateJob
-> Request InitiateJob
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Service -> InitiateJob -> Request InitiateJob
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy InitiateJob
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse InitiateJob)))
response =
(Int
-> ResponseHeaders
-> ()
-> Either String (AWSResponse InitiateJob))
-> Logger
-> Service
-> Proxy InitiateJob
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse InitiateJob)))
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 -> Int -> InitiateJobResponse
InitiateJobResponse'
(Maybe Text
-> Maybe Text -> Maybe Text -> Int -> InitiateJobResponse)
-> Either String (Maybe Text)
-> Either
String (Maybe Text -> Maybe Text -> Int -> InitiateJobResponse)
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-job-id")
Either
String (Maybe Text -> Maybe Text -> Int -> InitiateJobResponse)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> Int -> InitiateJobResponse)
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-job-output-path")
Either String (Maybe Text -> Int -> InitiateJobResponse)
-> Either String (Maybe Text)
-> Either String (Int -> InitiateJobResponse)
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")
Either String (Int -> InitiateJobResponse)
-> Either String Int -> Either String InitiateJobResponse
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 InitiateJob
instance Prelude.NFData InitiateJob
instance Core.ToHeaders InitiateJob where
toHeaders :: InitiateJob -> ResponseHeaders
toHeaders = ResponseHeaders -> InitiateJob -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty
instance Core.ToJSON InitiateJob where
toJSON :: InitiateJob -> Value
toJSON InitiateJob' {Maybe JobParameters
Text
vaultName :: Text
accountId :: Text
jobParameters :: Maybe JobParameters
$sel:vaultName:InitiateJob' :: InitiateJob -> Text
$sel:accountId:InitiateJob' :: InitiateJob -> Text
$sel:jobParameters:InitiateJob' :: InitiateJob -> Maybe JobParameters
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"jobParameters" Text -> JobParameters -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(JobParameters -> Pair) -> Maybe JobParameters -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe JobParameters
jobParameters
]
)
instance Core.ToPath InitiateJob where
toPath :: InitiateJob -> ByteString
toPath InitiateJob' {Maybe JobParameters
Text
vaultName :: Text
accountId :: Text
jobParameters :: Maybe JobParameters
$sel:vaultName:InitiateJob' :: InitiateJob -> Text
$sel:accountId:InitiateJob' :: InitiateJob -> Text
$sel:jobParameters:InitiateJob' :: InitiateJob -> Maybe JobParameters
..} =
[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
"/jobs"
]
instance Core.ToQuery InitiateJob where
toQuery :: InitiateJob -> QueryString
toQuery = QueryString -> InitiateJob -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data InitiateJobResponse = InitiateJobResponse'
{
InitiateJobResponse -> Maybe Text
jobId :: Prelude.Maybe Prelude.Text,
InitiateJobResponse -> Maybe Text
jobOutputPath :: Prelude.Maybe Prelude.Text,
InitiateJobResponse -> Maybe Text
location :: Prelude.Maybe Prelude.Text,
InitiateJobResponse -> Int
httpStatus :: Prelude.Int
}
deriving (InitiateJobResponse -> InitiateJobResponse -> Bool
(InitiateJobResponse -> InitiateJobResponse -> Bool)
-> (InitiateJobResponse -> InitiateJobResponse -> Bool)
-> Eq InitiateJobResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InitiateJobResponse -> InitiateJobResponse -> Bool
$c/= :: InitiateJobResponse -> InitiateJobResponse -> Bool
== :: InitiateJobResponse -> InitiateJobResponse -> Bool
$c== :: InitiateJobResponse -> InitiateJobResponse -> Bool
Prelude.Eq, ReadPrec [InitiateJobResponse]
ReadPrec InitiateJobResponse
Int -> ReadS InitiateJobResponse
ReadS [InitiateJobResponse]
(Int -> ReadS InitiateJobResponse)
-> ReadS [InitiateJobResponse]
-> ReadPrec InitiateJobResponse
-> ReadPrec [InitiateJobResponse]
-> Read InitiateJobResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InitiateJobResponse]
$creadListPrec :: ReadPrec [InitiateJobResponse]
readPrec :: ReadPrec InitiateJobResponse
$creadPrec :: ReadPrec InitiateJobResponse
readList :: ReadS [InitiateJobResponse]
$creadList :: ReadS [InitiateJobResponse]
readsPrec :: Int -> ReadS InitiateJobResponse
$creadsPrec :: Int -> ReadS InitiateJobResponse
Prelude.Read, Int -> InitiateJobResponse -> ShowS
[InitiateJobResponse] -> ShowS
InitiateJobResponse -> String
(Int -> InitiateJobResponse -> ShowS)
-> (InitiateJobResponse -> String)
-> ([InitiateJobResponse] -> ShowS)
-> Show InitiateJobResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InitiateJobResponse] -> ShowS
$cshowList :: [InitiateJobResponse] -> ShowS
show :: InitiateJobResponse -> String
$cshow :: InitiateJobResponse -> String
showsPrec :: Int -> InitiateJobResponse -> ShowS
$cshowsPrec :: Int -> InitiateJobResponse -> ShowS
Prelude.Show, (forall x. InitiateJobResponse -> Rep InitiateJobResponse x)
-> (forall x. Rep InitiateJobResponse x -> InitiateJobResponse)
-> Generic InitiateJobResponse
forall x. Rep InitiateJobResponse x -> InitiateJobResponse
forall x. InitiateJobResponse -> Rep InitiateJobResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InitiateJobResponse x -> InitiateJobResponse
$cfrom :: forall x. InitiateJobResponse -> Rep InitiateJobResponse x
Prelude.Generic)
newInitiateJobResponse ::
Prelude.Int ->
InitiateJobResponse
newInitiateJobResponse :: Int -> InitiateJobResponse
newInitiateJobResponse Int
pHttpStatus_ =
InitiateJobResponse' :: Maybe Text
-> Maybe Text -> Maybe Text -> Int -> InitiateJobResponse
InitiateJobResponse'
{ $sel:jobId:InitiateJobResponse' :: Maybe Text
jobId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:jobOutputPath:InitiateJobResponse' :: Maybe Text
jobOutputPath = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:location:InitiateJobResponse' :: Maybe Text
location = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:InitiateJobResponse' :: Int
httpStatus = Int
pHttpStatus_
}
initiateJobResponse_jobId :: Lens.Lens' InitiateJobResponse (Prelude.Maybe Prelude.Text)
initiateJobResponse_jobId :: (Maybe Text -> f (Maybe Text))
-> InitiateJobResponse -> f InitiateJobResponse
initiateJobResponse_jobId = (InitiateJobResponse -> Maybe Text)
-> (InitiateJobResponse -> Maybe Text -> InitiateJobResponse)
-> Lens
InitiateJobResponse InitiateJobResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InitiateJobResponse' {Maybe Text
jobId :: Maybe Text
$sel:jobId:InitiateJobResponse' :: InitiateJobResponse -> Maybe Text
jobId} -> Maybe Text
jobId) (\s :: InitiateJobResponse
s@InitiateJobResponse' {} Maybe Text
a -> InitiateJobResponse
s {$sel:jobId:InitiateJobResponse' :: Maybe Text
jobId = Maybe Text
a} :: InitiateJobResponse)
initiateJobResponse_jobOutputPath :: Lens.Lens' InitiateJobResponse (Prelude.Maybe Prelude.Text)
initiateJobResponse_jobOutputPath :: (Maybe Text -> f (Maybe Text))
-> InitiateJobResponse -> f InitiateJobResponse
initiateJobResponse_jobOutputPath = (InitiateJobResponse -> Maybe Text)
-> (InitiateJobResponse -> Maybe Text -> InitiateJobResponse)
-> Lens
InitiateJobResponse InitiateJobResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InitiateJobResponse' {Maybe Text
jobOutputPath :: Maybe Text
$sel:jobOutputPath:InitiateJobResponse' :: InitiateJobResponse -> Maybe Text
jobOutputPath} -> Maybe Text
jobOutputPath) (\s :: InitiateJobResponse
s@InitiateJobResponse' {} Maybe Text
a -> InitiateJobResponse
s {$sel:jobOutputPath:InitiateJobResponse' :: Maybe Text
jobOutputPath = Maybe Text
a} :: InitiateJobResponse)
initiateJobResponse_location :: Lens.Lens' InitiateJobResponse (Prelude.Maybe Prelude.Text)
initiateJobResponse_location :: (Maybe Text -> f (Maybe Text))
-> InitiateJobResponse -> f InitiateJobResponse
initiateJobResponse_location = (InitiateJobResponse -> Maybe Text)
-> (InitiateJobResponse -> Maybe Text -> InitiateJobResponse)
-> Lens
InitiateJobResponse InitiateJobResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InitiateJobResponse' {Maybe Text
location :: Maybe Text
$sel:location:InitiateJobResponse' :: InitiateJobResponse -> Maybe Text
location} -> Maybe Text
location) (\s :: InitiateJobResponse
s@InitiateJobResponse' {} Maybe Text
a -> InitiateJobResponse
s {$sel:location:InitiateJobResponse' :: Maybe Text
location = Maybe Text
a} :: InitiateJobResponse)
initiateJobResponse_httpStatus :: Lens.Lens' InitiateJobResponse Prelude.Int
initiateJobResponse_httpStatus :: (Int -> f Int) -> InitiateJobResponse -> f InitiateJobResponse
initiateJobResponse_httpStatus = (InitiateJobResponse -> Int)
-> (InitiateJobResponse -> Int -> InitiateJobResponse)
-> Lens InitiateJobResponse InitiateJobResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InitiateJobResponse' {Int
httpStatus :: Int
$sel:httpStatus:InitiateJobResponse' :: InitiateJobResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: InitiateJobResponse
s@InitiateJobResponse' {} Int
a -> InitiateJobResponse
s {$sel:httpStatus:InitiateJobResponse' :: Int
httpStatus = Int
a} :: InitiateJobResponse)
instance Prelude.NFData InitiateJobResponse