{-# 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-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. 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.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

-- | 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
(DeleteTape -> DeleteTape -> Bool)
-> (DeleteTape -> DeleteTape -> Bool) -> Eq DeleteTape
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]
(Int -> ReadS DeleteTape)
-> ReadS [DeleteTape]
-> ReadPrec DeleteTape
-> ReadPrec [DeleteTape]
-> Read 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
(Int -> DeleteTape -> ShowS)
-> (DeleteTape -> String)
-> ([DeleteTape] -> ShowS)
-> Show DeleteTape
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. DeleteTape -> Rep DeleteTape x)
-> (forall x. Rep DeleteTape x -> DeleteTape) -> Generic DeleteTape
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' :: Maybe Bool -> Text -> Text -> DeleteTape
DeleteTape'
    { $sel:bypassGovernanceRetention:DeleteTape' :: Maybe Bool
bypassGovernanceRetention =
        Maybe Bool
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 :: (Maybe Bool -> f (Maybe Bool)) -> DeleteTape -> f DeleteTape
deleteTape_bypassGovernanceRetention = (DeleteTape -> Maybe Bool)
-> (DeleteTape -> Maybe Bool -> DeleteTape)
-> Lens DeleteTape DeleteTape (Maybe Bool) (Maybe Bool)
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 :: (Text -> f Text) -> DeleteTape -> f DeleteTape
deleteTape_gatewayARN = (DeleteTape -> Text)
-> (DeleteTape -> Text -> DeleteTape)
-> Lens DeleteTape DeleteTape Text Text
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 :: (Text -> f Text) -> DeleteTape -> f DeleteTape
deleteTape_tapeARN = (DeleteTape -> Text)
-> (DeleteTape -> Text -> DeleteTape)
-> Lens DeleteTape DeleteTape Text Text
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 :: DeleteTape -> Request DeleteTape
request = Service -> DeleteTape -> Request DeleteTape
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteTape
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteTape)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DeleteTape))
-> Logger
-> Service
-> Proxy DeleteTape
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteTape)))
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 -> DeleteTapeResponse
DeleteTapeResponse'
            (Maybe Text -> Int -> DeleteTapeResponse)
-> Either String (Maybe Text)
-> Either String (Int -> DeleteTapeResponse)
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 -> DeleteTapeResponse)
-> Either String Int -> Either String DeleteTapeResponse
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 DeleteTape

instance Prelude.NFData DeleteTape

instance Core.ToHeaders DeleteTape where
  toHeaders :: DeleteTape -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteTape -> 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.DeleteTape" ::
                          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 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
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
"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 DeleteTape where
  toPath :: DeleteTape -> ByteString
toPath = ByteString -> DeleteTape -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery DeleteTape where
  toQuery :: DeleteTape -> QueryString
toQuery = QueryString -> DeleteTape -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(DeleteTapeResponse -> DeleteTapeResponse -> Bool)
-> (DeleteTapeResponse -> DeleteTapeResponse -> Bool)
-> Eq DeleteTapeResponse
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]
(Int -> ReadS DeleteTapeResponse)
-> ReadS [DeleteTapeResponse]
-> ReadPrec DeleteTapeResponse
-> ReadPrec [DeleteTapeResponse]
-> Read 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
(Int -> DeleteTapeResponse -> ShowS)
-> (DeleteTapeResponse -> String)
-> ([DeleteTapeResponse] -> ShowS)
-> Show DeleteTapeResponse
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. DeleteTapeResponse -> Rep DeleteTapeResponse x)
-> (forall x. Rep DeleteTapeResponse x -> DeleteTapeResponse)
-> Generic DeleteTapeResponse
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' :: Maybe Text -> Int -> DeleteTapeResponse
DeleteTapeResponse'
    { $sel:tapeARN:DeleteTapeResponse' :: Maybe Text
tapeARN = Maybe Text
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 :: (Maybe Text -> f (Maybe Text))
-> DeleteTapeResponse -> f DeleteTapeResponse
deleteTapeResponse_tapeARN = (DeleteTapeResponse -> Maybe Text)
-> (DeleteTapeResponse -> Maybe Text -> DeleteTapeResponse)
-> Lens
     DeleteTapeResponse DeleteTapeResponse (Maybe Text) (Maybe Text)
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 :: (Int -> f Int) -> DeleteTapeResponse -> f DeleteTapeResponse
deleteTapeResponse_httpStatus = (DeleteTapeResponse -> Int)
-> (DeleteTapeResponse -> Int -> DeleteTapeResponse)
-> Lens DeleteTapeResponse DeleteTapeResponse Int Int
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