{-# 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.CancelArchival
-- 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)
--
-- Cancels archiving of a virtual tape to the virtual tape shelf (VTS)
-- after the archiving process is initiated. This operation is only
-- supported in the tape gateway type.
module Amazonka.StorageGateway.CancelArchival
  ( -- * Creating a Request
    CancelArchival (..),
    newCancelArchival,

    -- * Request Lenses
    cancelArchival_gatewayARN,
    cancelArchival_tapeARN,

    -- * Destructuring the Response
    CancelArchivalResponse (..),
    newCancelArchivalResponse,

    -- * Response Lenses
    cancelArchivalResponse_tapeARN,
    cancelArchivalResponse_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

-- | CancelArchivalInput
--
-- /See:/ 'newCancelArchival' smart constructor.
data CancelArchival = CancelArchival'
  { CancelArchival -> Text
gatewayARN :: Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the virtual tape you want to cancel
    -- archiving for.
    CancelArchival -> Text
tapeARN :: Prelude.Text
  }
  deriving (CancelArchival -> CancelArchival -> Bool
(CancelArchival -> CancelArchival -> Bool)
-> (CancelArchival -> CancelArchival -> Bool) -> Eq CancelArchival
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CancelArchival -> CancelArchival -> Bool
$c/= :: CancelArchival -> CancelArchival -> Bool
== :: CancelArchival -> CancelArchival -> Bool
$c== :: CancelArchival -> CancelArchival -> Bool
Prelude.Eq, ReadPrec [CancelArchival]
ReadPrec CancelArchival
Int -> ReadS CancelArchival
ReadS [CancelArchival]
(Int -> ReadS CancelArchival)
-> ReadS [CancelArchival]
-> ReadPrec CancelArchival
-> ReadPrec [CancelArchival]
-> Read CancelArchival
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CancelArchival]
$creadListPrec :: ReadPrec [CancelArchival]
readPrec :: ReadPrec CancelArchival
$creadPrec :: ReadPrec CancelArchival
readList :: ReadS [CancelArchival]
$creadList :: ReadS [CancelArchival]
readsPrec :: Int -> ReadS CancelArchival
$creadsPrec :: Int -> ReadS CancelArchival
Prelude.Read, Int -> CancelArchival -> ShowS
[CancelArchival] -> ShowS
CancelArchival -> String
(Int -> CancelArchival -> ShowS)
-> (CancelArchival -> String)
-> ([CancelArchival] -> ShowS)
-> Show CancelArchival
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CancelArchival] -> ShowS
$cshowList :: [CancelArchival] -> ShowS
show :: CancelArchival -> String
$cshow :: CancelArchival -> String
showsPrec :: Int -> CancelArchival -> ShowS
$cshowsPrec :: Int -> CancelArchival -> ShowS
Prelude.Show, (forall x. CancelArchival -> Rep CancelArchival x)
-> (forall x. Rep CancelArchival x -> CancelArchival)
-> Generic CancelArchival
forall x. Rep CancelArchival x -> CancelArchival
forall x. CancelArchival -> Rep CancelArchival x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CancelArchival x -> CancelArchival
$cfrom :: forall x. CancelArchival -> Rep CancelArchival x
Prelude.Generic)

-- |
-- Create a value of 'CancelArchival' 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', 'cancelArchival_gatewayARN' - Undocumented member.
--
-- 'tapeARN', 'cancelArchival_tapeARN' - The Amazon Resource Name (ARN) of the virtual tape you want to cancel
-- archiving for.
newCancelArchival ::
  -- | 'gatewayARN'
  Prelude.Text ->
  -- | 'tapeARN'
  Prelude.Text ->
  CancelArchival
newCancelArchival :: Text -> Text -> CancelArchival
newCancelArchival Text
pGatewayARN_ Text
pTapeARN_ =
  CancelArchival' :: Text -> Text -> CancelArchival
CancelArchival'
    { $sel:gatewayARN:CancelArchival' :: Text
gatewayARN = Text
pGatewayARN_,
      $sel:tapeARN:CancelArchival' :: Text
tapeARN = Text
pTapeARN_
    }

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

-- | The Amazon Resource Name (ARN) of the virtual tape you want to cancel
-- archiving for.
cancelArchival_tapeARN :: Lens.Lens' CancelArchival Prelude.Text
cancelArchival_tapeARN :: (Text -> f Text) -> CancelArchival -> f CancelArchival
cancelArchival_tapeARN = (CancelArchival -> Text)
-> (CancelArchival -> Text -> CancelArchival)
-> Lens CancelArchival CancelArchival Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelArchival' {Text
tapeARN :: Text
$sel:tapeARN:CancelArchival' :: CancelArchival -> Text
tapeARN} -> Text
tapeARN) (\s :: CancelArchival
s@CancelArchival' {} Text
a -> CancelArchival
s {$sel:tapeARN:CancelArchival' :: Text
tapeARN = Text
a} :: CancelArchival)

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

instance Prelude.NFData CancelArchival

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

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

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

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

-- |
-- Create a value of 'CancelArchivalResponse' 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', 'cancelArchivalResponse_tapeARN' - The Amazon Resource Name (ARN) of the virtual tape for which archiving
-- was canceled.
--
-- 'httpStatus', 'cancelArchivalResponse_httpStatus' - The response's http status code.
newCancelArchivalResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CancelArchivalResponse
newCancelArchivalResponse :: Int -> CancelArchivalResponse
newCancelArchivalResponse Int
pHttpStatus_ =
  CancelArchivalResponse' :: Maybe Text -> Int -> CancelArchivalResponse
CancelArchivalResponse'
    { $sel:tapeARN:CancelArchivalResponse' :: Maybe Text
tapeARN = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CancelArchivalResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The Amazon Resource Name (ARN) of the virtual tape for which archiving
-- was canceled.
cancelArchivalResponse_tapeARN :: Lens.Lens' CancelArchivalResponse (Prelude.Maybe Prelude.Text)
cancelArchivalResponse_tapeARN :: (Maybe Text -> f (Maybe Text))
-> CancelArchivalResponse -> f CancelArchivalResponse
cancelArchivalResponse_tapeARN = (CancelArchivalResponse -> Maybe Text)
-> (CancelArchivalResponse -> Maybe Text -> CancelArchivalResponse)
-> Lens
     CancelArchivalResponse
     CancelArchivalResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelArchivalResponse' {Maybe Text
tapeARN :: Maybe Text
$sel:tapeARN:CancelArchivalResponse' :: CancelArchivalResponse -> Maybe Text
tapeARN} -> Maybe Text
tapeARN) (\s :: CancelArchivalResponse
s@CancelArchivalResponse' {} Maybe Text
a -> CancelArchivalResponse
s {$sel:tapeARN:CancelArchivalResponse' :: Maybe Text
tapeARN = Maybe Text
a} :: CancelArchivalResponse)

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

instance Prelude.NFData CancelArchivalResponse