{-# 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.RetrieveTapeArchive
-- 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)
--
-- Retrieves an archived virtual tape from the virtual tape shelf (VTS) to
-- a tape gateway. Virtual tapes archived in the VTS are not associated
-- with any gateway. However after a tape is retrieved, it is associated
-- with a gateway, even though it is also listed in the VTS, that is,
-- archive. This operation is only supported in the tape gateway type.
--
-- Once a tape is successfully retrieved to a gateway, it cannot be
-- retrieved again to another gateway. You must archive the tape again
-- before you can retrieve it to another gateway. This operation is only
-- supported in the tape gateway type.
module Amazonka.StorageGateway.RetrieveTapeArchive
  ( -- * Creating a Request
    RetrieveTapeArchive (..),
    newRetrieveTapeArchive,

    -- * Request Lenses
    retrieveTapeArchive_tapeARN,
    retrieveTapeArchive_gatewayARN,

    -- * Destructuring the Response
    RetrieveTapeArchiveResponse (..),
    newRetrieveTapeArchiveResponse,

    -- * Response Lenses
    retrieveTapeArchiveResponse_tapeARN,
    retrieveTapeArchiveResponse_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

-- | RetrieveTapeArchiveInput
--
-- /See:/ 'newRetrieveTapeArchive' smart constructor.
data RetrieveTapeArchive = RetrieveTapeArchive'
  { -- | The Amazon Resource Name (ARN) of the virtual tape you want to retrieve
    -- from the virtual tape shelf (VTS).
    RetrieveTapeArchive -> Text
tapeARN :: Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the gateway you want to retrieve the
    -- virtual tape to. Use the ListGateways operation to return a list of
    -- gateways for your account and Amazon Web Services Region.
    --
    -- You retrieve archived virtual tapes to only one gateway and the gateway
    -- must be a tape gateway.
    RetrieveTapeArchive -> Text
gatewayARN :: Prelude.Text
  }
  deriving (RetrieveTapeArchive -> RetrieveTapeArchive -> Bool
(RetrieveTapeArchive -> RetrieveTapeArchive -> Bool)
-> (RetrieveTapeArchive -> RetrieveTapeArchive -> Bool)
-> Eq RetrieveTapeArchive
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RetrieveTapeArchive -> RetrieveTapeArchive -> Bool
$c/= :: RetrieveTapeArchive -> RetrieveTapeArchive -> Bool
== :: RetrieveTapeArchive -> RetrieveTapeArchive -> Bool
$c== :: RetrieveTapeArchive -> RetrieveTapeArchive -> Bool
Prelude.Eq, ReadPrec [RetrieveTapeArchive]
ReadPrec RetrieveTapeArchive
Int -> ReadS RetrieveTapeArchive
ReadS [RetrieveTapeArchive]
(Int -> ReadS RetrieveTapeArchive)
-> ReadS [RetrieveTapeArchive]
-> ReadPrec RetrieveTapeArchive
-> ReadPrec [RetrieveTapeArchive]
-> Read RetrieveTapeArchive
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RetrieveTapeArchive]
$creadListPrec :: ReadPrec [RetrieveTapeArchive]
readPrec :: ReadPrec RetrieveTapeArchive
$creadPrec :: ReadPrec RetrieveTapeArchive
readList :: ReadS [RetrieveTapeArchive]
$creadList :: ReadS [RetrieveTapeArchive]
readsPrec :: Int -> ReadS RetrieveTapeArchive
$creadsPrec :: Int -> ReadS RetrieveTapeArchive
Prelude.Read, Int -> RetrieveTapeArchive -> ShowS
[RetrieveTapeArchive] -> ShowS
RetrieveTapeArchive -> String
(Int -> RetrieveTapeArchive -> ShowS)
-> (RetrieveTapeArchive -> String)
-> ([RetrieveTapeArchive] -> ShowS)
-> Show RetrieveTapeArchive
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RetrieveTapeArchive] -> ShowS
$cshowList :: [RetrieveTapeArchive] -> ShowS
show :: RetrieveTapeArchive -> String
$cshow :: RetrieveTapeArchive -> String
showsPrec :: Int -> RetrieveTapeArchive -> ShowS
$cshowsPrec :: Int -> RetrieveTapeArchive -> ShowS
Prelude.Show, (forall x. RetrieveTapeArchive -> Rep RetrieveTapeArchive x)
-> (forall x. Rep RetrieveTapeArchive x -> RetrieveTapeArchive)
-> Generic RetrieveTapeArchive
forall x. Rep RetrieveTapeArchive x -> RetrieveTapeArchive
forall x. RetrieveTapeArchive -> Rep RetrieveTapeArchive x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RetrieveTapeArchive x -> RetrieveTapeArchive
$cfrom :: forall x. RetrieveTapeArchive -> Rep RetrieveTapeArchive x
Prelude.Generic)

-- |
-- Create a value of 'RetrieveTapeArchive' 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:
--
-- 'tapeARN', 'retrieveTapeArchive_tapeARN' - The Amazon Resource Name (ARN) of the virtual tape you want to retrieve
-- from the virtual tape shelf (VTS).
--
-- 'gatewayARN', 'retrieveTapeArchive_gatewayARN' - The Amazon Resource Name (ARN) of the gateway you want to retrieve the
-- virtual tape to. Use the ListGateways operation to return a list of
-- gateways for your account and Amazon Web Services Region.
--
-- You retrieve archived virtual tapes to only one gateway and the gateway
-- must be a tape gateway.
newRetrieveTapeArchive ::
  -- | 'tapeARN'
  Prelude.Text ->
  -- | 'gatewayARN'
  Prelude.Text ->
  RetrieveTapeArchive
newRetrieveTapeArchive :: Text -> Text -> RetrieveTapeArchive
newRetrieveTapeArchive Text
pTapeARN_ Text
pGatewayARN_ =
  RetrieveTapeArchive' :: Text -> Text -> RetrieveTapeArchive
RetrieveTapeArchive'
    { $sel:tapeARN:RetrieveTapeArchive' :: Text
tapeARN = Text
pTapeARN_,
      $sel:gatewayARN:RetrieveTapeArchive' :: Text
gatewayARN = Text
pGatewayARN_
    }

-- | The Amazon Resource Name (ARN) of the virtual tape you want to retrieve
-- from the virtual tape shelf (VTS).
retrieveTapeArchive_tapeARN :: Lens.Lens' RetrieveTapeArchive Prelude.Text
retrieveTapeArchive_tapeARN :: (Text -> f Text) -> RetrieveTapeArchive -> f RetrieveTapeArchive
retrieveTapeArchive_tapeARN = (RetrieveTapeArchive -> Text)
-> (RetrieveTapeArchive -> Text -> RetrieveTapeArchive)
-> Lens RetrieveTapeArchive RetrieveTapeArchive Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RetrieveTapeArchive' {Text
tapeARN :: Text
$sel:tapeARN:RetrieveTapeArchive' :: RetrieveTapeArchive -> Text
tapeARN} -> Text
tapeARN) (\s :: RetrieveTapeArchive
s@RetrieveTapeArchive' {} Text
a -> RetrieveTapeArchive
s {$sel:tapeARN:RetrieveTapeArchive' :: Text
tapeARN = Text
a} :: RetrieveTapeArchive)

-- | The Amazon Resource Name (ARN) of the gateway you want to retrieve the
-- virtual tape to. Use the ListGateways operation to return a list of
-- gateways for your account and Amazon Web Services Region.
--
-- You retrieve archived virtual tapes to only one gateway and the gateway
-- must be a tape gateway.
retrieveTapeArchive_gatewayARN :: Lens.Lens' RetrieveTapeArchive Prelude.Text
retrieveTapeArchive_gatewayARN :: (Text -> f Text) -> RetrieveTapeArchive -> f RetrieveTapeArchive
retrieveTapeArchive_gatewayARN = (RetrieveTapeArchive -> Text)
-> (RetrieveTapeArchive -> Text -> RetrieveTapeArchive)
-> Lens RetrieveTapeArchive RetrieveTapeArchive Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RetrieveTapeArchive' {Text
gatewayARN :: Text
$sel:gatewayARN:RetrieveTapeArchive' :: RetrieveTapeArchive -> Text
gatewayARN} -> Text
gatewayARN) (\s :: RetrieveTapeArchive
s@RetrieveTapeArchive' {} Text
a -> RetrieveTapeArchive
s {$sel:gatewayARN:RetrieveTapeArchive' :: Text
gatewayARN = Text
a} :: RetrieveTapeArchive)

instance Core.AWSRequest RetrieveTapeArchive where
  type
    AWSResponse RetrieveTapeArchive =
      RetrieveTapeArchiveResponse
  request :: RetrieveTapeArchive -> Request RetrieveTapeArchive
request = Service -> RetrieveTapeArchive -> Request RetrieveTapeArchive
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy RetrieveTapeArchive
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse RetrieveTapeArchive)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse RetrieveTapeArchive))
-> Logger
-> Service
-> Proxy RetrieveTapeArchive
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse RetrieveTapeArchive)))
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 -> RetrieveTapeArchiveResponse
RetrieveTapeArchiveResponse'
            (Maybe Text -> Int -> RetrieveTapeArchiveResponse)
-> Either String (Maybe Text)
-> Either String (Int -> RetrieveTapeArchiveResponse)
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
"TapeARN")
            Either String (Int -> RetrieveTapeArchiveResponse)
-> Either String Int -> Either String RetrieveTapeArchiveResponse
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 RetrieveTapeArchive

instance Prelude.NFData RetrieveTapeArchive

instance Core.ToHeaders RetrieveTapeArchive where
  toHeaders :: RetrieveTapeArchive -> ResponseHeaders
toHeaders =
    ResponseHeaders -> RetrieveTapeArchive -> 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.RetrieveTapeArchive" ::
                          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 RetrieveTapeArchive where
  toJSON :: RetrieveTapeArchive -> Value
toJSON RetrieveTapeArchive' {Text
gatewayARN :: Text
tapeARN :: Text
$sel:gatewayARN:RetrieveTapeArchive' :: RetrieveTapeArchive -> Text
$sel:tapeARN:RetrieveTapeArchive' :: RetrieveTapeArchive -> 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
"TapeARN" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
tapeARN),
            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)
          ]
      )

instance Core.ToPath RetrieveTapeArchive where
  toPath :: RetrieveTapeArchive -> ByteString
toPath = ByteString -> RetrieveTapeArchive -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | RetrieveTapeArchiveOutput
--
-- /See:/ 'newRetrieveTapeArchiveResponse' smart constructor.
data RetrieveTapeArchiveResponse = RetrieveTapeArchiveResponse'
  { -- | The Amazon Resource Name (ARN) of the retrieved virtual tape.
    RetrieveTapeArchiveResponse -> Maybe Text
tapeARN :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    RetrieveTapeArchiveResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (RetrieveTapeArchiveResponse -> RetrieveTapeArchiveResponse -> Bool
(RetrieveTapeArchiveResponse
 -> RetrieveTapeArchiveResponse -> Bool)
-> (RetrieveTapeArchiveResponse
    -> RetrieveTapeArchiveResponse -> Bool)
-> Eq RetrieveTapeArchiveResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RetrieveTapeArchiveResponse -> RetrieveTapeArchiveResponse -> Bool
$c/= :: RetrieveTapeArchiveResponse -> RetrieveTapeArchiveResponse -> Bool
== :: RetrieveTapeArchiveResponse -> RetrieveTapeArchiveResponse -> Bool
$c== :: RetrieveTapeArchiveResponse -> RetrieveTapeArchiveResponse -> Bool
Prelude.Eq, ReadPrec [RetrieveTapeArchiveResponse]
ReadPrec RetrieveTapeArchiveResponse
Int -> ReadS RetrieveTapeArchiveResponse
ReadS [RetrieveTapeArchiveResponse]
(Int -> ReadS RetrieveTapeArchiveResponse)
-> ReadS [RetrieveTapeArchiveResponse]
-> ReadPrec RetrieveTapeArchiveResponse
-> ReadPrec [RetrieveTapeArchiveResponse]
-> Read RetrieveTapeArchiveResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RetrieveTapeArchiveResponse]
$creadListPrec :: ReadPrec [RetrieveTapeArchiveResponse]
readPrec :: ReadPrec RetrieveTapeArchiveResponse
$creadPrec :: ReadPrec RetrieveTapeArchiveResponse
readList :: ReadS [RetrieveTapeArchiveResponse]
$creadList :: ReadS [RetrieveTapeArchiveResponse]
readsPrec :: Int -> ReadS RetrieveTapeArchiveResponse
$creadsPrec :: Int -> ReadS RetrieveTapeArchiveResponse
Prelude.Read, Int -> RetrieveTapeArchiveResponse -> ShowS
[RetrieveTapeArchiveResponse] -> ShowS
RetrieveTapeArchiveResponse -> String
(Int -> RetrieveTapeArchiveResponse -> ShowS)
-> (RetrieveTapeArchiveResponse -> String)
-> ([RetrieveTapeArchiveResponse] -> ShowS)
-> Show RetrieveTapeArchiveResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RetrieveTapeArchiveResponse] -> ShowS
$cshowList :: [RetrieveTapeArchiveResponse] -> ShowS
show :: RetrieveTapeArchiveResponse -> String
$cshow :: RetrieveTapeArchiveResponse -> String
showsPrec :: Int -> RetrieveTapeArchiveResponse -> ShowS
$cshowsPrec :: Int -> RetrieveTapeArchiveResponse -> ShowS
Prelude.Show, (forall x.
 RetrieveTapeArchiveResponse -> Rep RetrieveTapeArchiveResponse x)
-> (forall x.
    Rep RetrieveTapeArchiveResponse x -> RetrieveTapeArchiveResponse)
-> Generic RetrieveTapeArchiveResponse
forall x.
Rep RetrieveTapeArchiveResponse x -> RetrieveTapeArchiveResponse
forall x.
RetrieveTapeArchiveResponse -> Rep RetrieveTapeArchiveResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep RetrieveTapeArchiveResponse x -> RetrieveTapeArchiveResponse
$cfrom :: forall x.
RetrieveTapeArchiveResponse -> Rep RetrieveTapeArchiveResponse x
Prelude.Generic)

-- |
-- Create a value of 'RetrieveTapeArchiveResponse' 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:
--
-- 'tapeARN', 'retrieveTapeArchiveResponse_tapeARN' - The Amazon Resource Name (ARN) of the retrieved virtual tape.
--
-- 'httpStatus', 'retrieveTapeArchiveResponse_httpStatus' - The response's http status code.
newRetrieveTapeArchiveResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  RetrieveTapeArchiveResponse
newRetrieveTapeArchiveResponse :: Int -> RetrieveTapeArchiveResponse
newRetrieveTapeArchiveResponse Int
pHttpStatus_ =
  RetrieveTapeArchiveResponse' :: Maybe Text -> Int -> RetrieveTapeArchiveResponse
RetrieveTapeArchiveResponse'
    { $sel:tapeARN:RetrieveTapeArchiveResponse' :: Maybe Text
tapeARN =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:RetrieveTapeArchiveResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The Amazon Resource Name (ARN) of the retrieved virtual tape.
retrieveTapeArchiveResponse_tapeARN :: Lens.Lens' RetrieveTapeArchiveResponse (Prelude.Maybe Prelude.Text)
retrieveTapeArchiveResponse_tapeARN :: (Maybe Text -> f (Maybe Text))
-> RetrieveTapeArchiveResponse -> f RetrieveTapeArchiveResponse
retrieveTapeArchiveResponse_tapeARN = (RetrieveTapeArchiveResponse -> Maybe Text)
-> (RetrieveTapeArchiveResponse
    -> Maybe Text -> RetrieveTapeArchiveResponse)
-> Lens
     RetrieveTapeArchiveResponse
     RetrieveTapeArchiveResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RetrieveTapeArchiveResponse' {Maybe Text
tapeARN :: Maybe Text
$sel:tapeARN:RetrieveTapeArchiveResponse' :: RetrieveTapeArchiveResponse -> Maybe Text
tapeARN} -> Maybe Text
tapeARN) (\s :: RetrieveTapeArchiveResponse
s@RetrieveTapeArchiveResponse' {} Maybe Text
a -> RetrieveTapeArchiveResponse
s {$sel:tapeARN:RetrieveTapeArchiveResponse' :: Maybe Text
tapeARN = Maybe Text
a} :: RetrieveTapeArchiveResponse)

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

instance Prelude.NFData RetrieveTapeArchiveResponse