{-# 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.DeleteTape
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Deletes the specified virtual tape. This operation is only supported in
-- the tape gateway type.
module Amazonka.StorageGateway.DeleteTape
  ( -- * Creating a Request
    DeleteTape (..),
    newDeleteTape,

    -- * Request Lenses
    deleteTape_bypassGovernanceRetention,
    deleteTape_gatewayARN,
    deleteTape_tapeARN,

    -- * Destructuring the Response
    DeleteTapeResponse (..),
    newDeleteTapeResponse,

    -- * Response Lenses
    deleteTapeResponse_tapeARN,
    deleteTapeResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.StorageGateway.Types

-- | DeleteTapeInput
--
-- /See:/ 'newDeleteTape' smart constructor.
data DeleteTape = DeleteTape'
  { -- | 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.
    DeleteTape -> Maybe Bool
bypassGovernanceRetention :: Prelude.Maybe Prelude.Bool,
    -- | The unique Amazon Resource Name (ARN) of the gateway that the virtual
    -- tape to delete is associated with. Use the ListGateways operation to
    -- return a list of gateways for your account and Amazon Web Services
    -- Region.
    DeleteTape -> Text
gatewayARN :: Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the virtual tape to delete.
    DeleteTape -> Text
tapeARN :: Prelude.Text
  }
  deriving (DeleteTape -> DeleteTape -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteTape -> DeleteTape -> Bool
$c/= :: DeleteTape -> DeleteTape -> Bool
== :: DeleteTape -> DeleteTape -> Bool
$c== :: DeleteTape -> DeleteTape -> Bool
Prelude.Eq, ReadPrec [DeleteTape]
ReadPrec DeleteTape
Int -> ReadS DeleteTape
ReadS [DeleteTape]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteTape]
$creadListPrec :: ReadPrec [DeleteTape]
readPrec :: ReadPrec DeleteTape
$creadPrec :: ReadPrec DeleteTape
readList :: ReadS [DeleteTape]
$creadList :: ReadS [DeleteTape]
readsPrec :: Int -> ReadS DeleteTape
$creadsPrec :: Int -> ReadS DeleteTape
Prelude.Read, Int -> DeleteTape -> ShowS
[DeleteTape] -> ShowS
DeleteTape -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteTape] -> ShowS
$cshowList :: [DeleteTape] -> ShowS
show :: DeleteTape -> String
$cshow :: DeleteTape -> String
showsPrec :: Int -> DeleteTape -> ShowS
$cshowsPrec :: Int -> DeleteTape -> ShowS
Prelude.Show, forall x. Rep DeleteTape x -> DeleteTape
forall x. DeleteTape -> Rep DeleteTape x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteTape x -> DeleteTape
$cfrom :: forall x. DeleteTape -> Rep DeleteTape x
Prelude.Generic)

-- |
-- Create a value of 'DeleteTape' 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', 'deleteTape_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.
--
-- 'gatewayARN', 'deleteTape_gatewayARN' - The unique Amazon Resource Name (ARN) of the gateway that the virtual
-- tape to delete is associated with. Use the ListGateways operation to
-- return a list of gateways for your account and Amazon Web Services
-- Region.
--
-- 'tapeARN', 'deleteTape_tapeARN' - The Amazon Resource Name (ARN) of the virtual tape to delete.
newDeleteTape ::
  -- | 'gatewayARN'
  Prelude.Text ->
  -- | 'tapeARN'
  Prelude.Text ->
  DeleteTape
newDeleteTape :: Text -> Text -> DeleteTape
newDeleteTape Text
pGatewayARN_ Text
pTapeARN_ =
  DeleteTape'
    { $sel:bypassGovernanceRetention:DeleteTape' :: Maybe Bool
bypassGovernanceRetention =
        forall a. Maybe a
Prelude.Nothing,
      $sel:gatewayARN:DeleteTape' :: Text
gatewayARN = Text
pGatewayARN_,
      $sel:tapeARN:DeleteTape' :: 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.
deleteTape_bypassGovernanceRetention :: Lens.Lens' DeleteTape (Prelude.Maybe Prelude.Bool)
deleteTape_bypassGovernanceRetention :: Lens' DeleteTape (Maybe Bool)
deleteTape_bypassGovernanceRetention = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteTape' {Maybe Bool
bypassGovernanceRetention :: Maybe Bool
$sel:bypassGovernanceRetention:DeleteTape' :: DeleteTape -> Maybe Bool
bypassGovernanceRetention} -> Maybe Bool
bypassGovernanceRetention) (\s :: DeleteTape
s@DeleteTape' {} Maybe Bool
a -> DeleteTape
s {$sel:bypassGovernanceRetention:DeleteTape' :: Maybe Bool
bypassGovernanceRetention = Maybe Bool
a} :: DeleteTape)

-- | The unique Amazon Resource Name (ARN) of the gateway that the virtual
-- tape to delete is associated with. Use the ListGateways operation to
-- return a list of gateways for your account and Amazon Web Services
-- Region.
deleteTape_gatewayARN :: Lens.Lens' DeleteTape Prelude.Text
deleteTape_gatewayARN :: Lens' DeleteTape Text
deleteTape_gatewayARN = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteTape' {Text
gatewayARN :: Text
$sel:gatewayARN:DeleteTape' :: DeleteTape -> Text
gatewayARN} -> Text
gatewayARN) (\s :: DeleteTape
s@DeleteTape' {} Text
a -> DeleteTape
s {$sel:gatewayARN:DeleteTape' :: Text
gatewayARN = Text
a} :: DeleteTape)

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

instance Core.AWSRequest DeleteTape where
  type AWSResponse DeleteTape = DeleteTapeResponse
  request :: (Service -> Service) -> DeleteTape -> Request DeleteTape
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DeleteTape
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteTape)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text -> Int -> DeleteTapeResponse
DeleteTapeResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"TapeARN")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable DeleteTape where
  hashWithSalt :: Int -> DeleteTape -> Int
hashWithSalt Int
_salt DeleteTape' {Maybe Bool
Text
tapeARN :: Text
gatewayARN :: Text
bypassGovernanceRetention :: Maybe Bool
$sel:tapeARN:DeleteTape' :: DeleteTape -> Text
$sel:gatewayARN:DeleteTape' :: DeleteTape -> Text
$sel:bypassGovernanceRetention:DeleteTape' :: DeleteTape -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
bypassGovernanceRetention
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
gatewayARN
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
tapeARN

instance Prelude.NFData DeleteTape where
  rnf :: DeleteTape -> ()
rnf DeleteTape' {Maybe Bool
Text
tapeARN :: Text
gatewayARN :: Text
bypassGovernanceRetention :: Maybe Bool
$sel:tapeARN:DeleteTape' :: DeleteTape -> Text
$sel:gatewayARN:DeleteTape' :: DeleteTape -> Text
$sel:bypassGovernanceRetention:DeleteTape' :: DeleteTape -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
bypassGovernanceRetention
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
gatewayARN
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
tapeARN

instance Data.ToHeaders DeleteTape where
  toHeaders :: DeleteTape -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"StorageGateway_20130630.DeleteTape" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON DeleteTape where
  toJSON :: DeleteTape -> Value
toJSON DeleteTape' {Maybe Bool
Text
tapeARN :: Text
gatewayARN :: Text
bypassGovernanceRetention :: Maybe Bool
$sel:tapeARN:DeleteTape' :: DeleteTape -> Text
$sel:gatewayARN:DeleteTape' :: DeleteTape -> Text
$sel:bypassGovernanceRetention:DeleteTape' :: DeleteTape -> Maybe Bool
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"BypassGovernanceRetention" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
bypassGovernanceRetention,
            forall a. a -> Maybe a
Prelude.Just (Key
"GatewayARN" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
gatewayARN),
            forall a. a -> Maybe a
Prelude.Just (Key
"TapeARN" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
tapeARN)
          ]
      )

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

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

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

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

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

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

instance Prelude.NFData DeleteTapeResponse where
  rnf :: DeleteTapeResponse -> ()
rnf DeleteTapeResponse' {Int
Maybe Text
httpStatus :: Int
tapeARN :: Maybe Text
$sel:httpStatus:DeleteTapeResponse' :: DeleteTapeResponse -> Int
$sel:tapeARN:DeleteTapeResponse' :: DeleteTapeResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
tapeARN
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus