{-# 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.DeleteTapeArchive
-- 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)
--
-- Deletes the specified virtual tape from the virtual tape shelf (VTS).
-- This operation is only supported in the tape gateway type.
module Amazonka.StorageGateway.DeleteTapeArchive
  ( -- * Creating a Request
    DeleteTapeArchive (..),
    newDeleteTapeArchive,

    -- * Request Lenses
    deleteTapeArchive_bypassGovernanceRetention,
    deleteTapeArchive_tapeARN,

    -- * Destructuring the Response
    DeleteTapeArchiveResponse (..),
    newDeleteTapeArchiveResponse,

    -- * Response Lenses
    deleteTapeArchiveResponse_tapeARN,
    deleteTapeArchiveResponse_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

-- | DeleteTapeArchiveInput
--
-- /See:/ 'newDeleteTapeArchive' smart constructor.
data DeleteTapeArchive = DeleteTapeArchive'
  { -- | Set to @TRUE@ to delete an archived tape that belongs to a custom pool
    -- with tape retention lock. Only archived tapes with tape retention lock
    -- set to @governance@ can be deleted. Archived tapes with tape retention
    -- lock set to @compliance@ can\'t be deleted.
    DeleteTapeArchive -> Maybe Bool
bypassGovernanceRetention :: Prelude.Maybe Prelude.Bool,
    -- | The Amazon Resource Name (ARN) of the virtual tape to delete from the
    -- virtual tape shelf (VTS).
    DeleteTapeArchive -> Text
tapeARN :: Prelude.Text
  }
  deriving (DeleteTapeArchive -> DeleteTapeArchive -> Bool
(DeleteTapeArchive -> DeleteTapeArchive -> Bool)
-> (DeleteTapeArchive -> DeleteTapeArchive -> Bool)
-> Eq DeleteTapeArchive
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteTapeArchive -> DeleteTapeArchive -> Bool
$c/= :: DeleteTapeArchive -> DeleteTapeArchive -> Bool
== :: DeleteTapeArchive -> DeleteTapeArchive -> Bool
$c== :: DeleteTapeArchive -> DeleteTapeArchive -> Bool
Prelude.Eq, ReadPrec [DeleteTapeArchive]
ReadPrec DeleteTapeArchive
Int -> ReadS DeleteTapeArchive
ReadS [DeleteTapeArchive]
(Int -> ReadS DeleteTapeArchive)
-> ReadS [DeleteTapeArchive]
-> ReadPrec DeleteTapeArchive
-> ReadPrec [DeleteTapeArchive]
-> Read DeleteTapeArchive
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteTapeArchive]
$creadListPrec :: ReadPrec [DeleteTapeArchive]
readPrec :: ReadPrec DeleteTapeArchive
$creadPrec :: ReadPrec DeleteTapeArchive
readList :: ReadS [DeleteTapeArchive]
$creadList :: ReadS [DeleteTapeArchive]
readsPrec :: Int -> ReadS DeleteTapeArchive
$creadsPrec :: Int -> ReadS DeleteTapeArchive
Prelude.Read, Int -> DeleteTapeArchive -> ShowS
[DeleteTapeArchive] -> ShowS
DeleteTapeArchive -> String
(Int -> DeleteTapeArchive -> ShowS)
-> (DeleteTapeArchive -> String)
-> ([DeleteTapeArchive] -> ShowS)
-> Show DeleteTapeArchive
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteTapeArchive] -> ShowS
$cshowList :: [DeleteTapeArchive] -> ShowS
show :: DeleteTapeArchive -> String
$cshow :: DeleteTapeArchive -> String
showsPrec :: Int -> DeleteTapeArchive -> ShowS
$cshowsPrec :: Int -> DeleteTapeArchive -> ShowS
Prelude.Show, (forall x. DeleteTapeArchive -> Rep DeleteTapeArchive x)
-> (forall x. Rep DeleteTapeArchive x -> DeleteTapeArchive)
-> Generic DeleteTapeArchive
forall x. Rep DeleteTapeArchive x -> DeleteTapeArchive
forall x. DeleteTapeArchive -> Rep DeleteTapeArchive x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteTapeArchive x -> DeleteTapeArchive
$cfrom :: forall x. DeleteTapeArchive -> Rep DeleteTapeArchive x
Prelude.Generic)

-- |
-- Create a value of 'DeleteTapeArchive' 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:
--
-- 'bypassGovernanceRetention', 'deleteTapeArchive_bypassGovernanceRetention' - Set to @TRUE@ to delete an archived tape that belongs to a custom pool
-- with tape retention lock. Only archived tapes with tape retention lock
-- set to @governance@ can be deleted. Archived tapes with tape retention
-- lock set to @compliance@ can\'t be deleted.
--
-- 'tapeARN', 'deleteTapeArchive_tapeARN' - The Amazon Resource Name (ARN) of the virtual tape to delete from the
-- virtual tape shelf (VTS).
newDeleteTapeArchive ::
  -- | 'tapeARN'
  Prelude.Text ->
  DeleteTapeArchive
newDeleteTapeArchive :: Text -> DeleteTapeArchive
newDeleteTapeArchive Text
pTapeARN_ =
  DeleteTapeArchive' :: Maybe Bool -> Text -> DeleteTapeArchive
DeleteTapeArchive'
    { $sel:bypassGovernanceRetention:DeleteTapeArchive' :: Maybe Bool
bypassGovernanceRetention =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:tapeARN:DeleteTapeArchive' :: Text
tapeARN = Text
pTapeARN_
    }

-- | Set to @TRUE@ to delete an archived tape that belongs to a custom pool
-- with tape retention lock. Only archived tapes with tape retention lock
-- set to @governance@ can be deleted. Archived tapes with tape retention
-- lock set to @compliance@ can\'t be deleted.
deleteTapeArchive_bypassGovernanceRetention :: Lens.Lens' DeleteTapeArchive (Prelude.Maybe Prelude.Bool)
deleteTapeArchive_bypassGovernanceRetention :: (Maybe Bool -> f (Maybe Bool))
-> DeleteTapeArchive -> f DeleteTapeArchive
deleteTapeArchive_bypassGovernanceRetention = (DeleteTapeArchive -> Maybe Bool)
-> (DeleteTapeArchive -> Maybe Bool -> DeleteTapeArchive)
-> Lens
     DeleteTapeArchive DeleteTapeArchive (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteTapeArchive' {Maybe Bool
bypassGovernanceRetention :: Maybe Bool
$sel:bypassGovernanceRetention:DeleteTapeArchive' :: DeleteTapeArchive -> Maybe Bool
bypassGovernanceRetention} -> Maybe Bool
bypassGovernanceRetention) (\s :: DeleteTapeArchive
s@DeleteTapeArchive' {} Maybe Bool
a -> DeleteTapeArchive
s {$sel:bypassGovernanceRetention:DeleteTapeArchive' :: Maybe Bool
bypassGovernanceRetention = Maybe Bool
a} :: DeleteTapeArchive)

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

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

instance Prelude.NFData DeleteTapeArchive

instance Core.ToHeaders DeleteTapeArchive where
  toHeaders :: DeleteTapeArchive -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteTapeArchive -> 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.DeleteTapeArchive" ::
                          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 DeleteTapeArchive where
  toJSON :: DeleteTapeArchive -> Value
toJSON DeleteTapeArchive' {Maybe Bool
Text
tapeARN :: Text
bypassGovernanceRetention :: Maybe Bool
$sel:tapeARN:DeleteTapeArchive' :: DeleteTapeArchive -> Text
$sel:bypassGovernanceRetention:DeleteTapeArchive' :: DeleteTapeArchive -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"BypassGovernanceRetention" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
bypassGovernanceRetention,
            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 DeleteTapeArchive where
  toPath :: DeleteTapeArchive -> ByteString
toPath = ByteString -> DeleteTapeArchive -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

-- |
-- Create a value of 'DeleteTapeArchiveResponse' 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', 'deleteTapeArchiveResponse_tapeARN' - The Amazon Resource Name (ARN) of the virtual tape that was deleted from
-- the virtual tape shelf (VTS).
--
-- 'httpStatus', 'deleteTapeArchiveResponse_httpStatus' - The response's http status code.
newDeleteTapeArchiveResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteTapeArchiveResponse
newDeleteTapeArchiveResponse :: Int -> DeleteTapeArchiveResponse
newDeleteTapeArchiveResponse Int
pHttpStatus_ =
  DeleteTapeArchiveResponse' :: Maybe Text -> Int -> DeleteTapeArchiveResponse
DeleteTapeArchiveResponse'
    { $sel:tapeARN:DeleteTapeArchiveResponse' :: Maybe Text
tapeARN =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteTapeArchiveResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The Amazon Resource Name (ARN) of the virtual tape that was deleted from
-- the virtual tape shelf (VTS).
deleteTapeArchiveResponse_tapeARN :: Lens.Lens' DeleteTapeArchiveResponse (Prelude.Maybe Prelude.Text)
deleteTapeArchiveResponse_tapeARN :: (Maybe Text -> f (Maybe Text))
-> DeleteTapeArchiveResponse -> f DeleteTapeArchiveResponse
deleteTapeArchiveResponse_tapeARN = (DeleteTapeArchiveResponse -> Maybe Text)
-> (DeleteTapeArchiveResponse
    -> Maybe Text -> DeleteTapeArchiveResponse)
-> Lens
     DeleteTapeArchiveResponse
     DeleteTapeArchiveResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteTapeArchiveResponse' {Maybe Text
tapeARN :: Maybe Text
$sel:tapeARN:DeleteTapeArchiveResponse' :: DeleteTapeArchiveResponse -> Maybe Text
tapeARN} -> Maybe Text
tapeARN) (\s :: DeleteTapeArchiveResponse
s@DeleteTapeArchiveResponse' {} Maybe Text
a -> DeleteTapeArchiveResponse
s {$sel:tapeARN:DeleteTapeArchiveResponse' :: Maybe Text
tapeARN = Maybe Text
a} :: DeleteTapeArchiveResponse)

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

instance Prelude.NFData DeleteTapeArchiveResponse