{-# 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.CloudWatchEvents.DeleteArchive
-- 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 archive.
module Amazonka.CloudWatchEvents.DeleteArchive
  ( -- * Creating a Request
    DeleteArchive (..),
    newDeleteArchive,

    -- * Request Lenses
    deleteArchive_archiveName,

    -- * Destructuring the Response
    DeleteArchiveResponse (..),
    newDeleteArchiveResponse,

    -- * Response Lenses
    deleteArchiveResponse_httpStatus,
  )
where

import Amazonka.CloudWatchEvents.Types
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

-- | /See:/ 'newDeleteArchive' smart constructor.
data DeleteArchive = DeleteArchive'
  { -- | The name of the archive to delete.
    DeleteArchive -> Text
archiveName :: Prelude.Text
  }
  deriving (DeleteArchive -> DeleteArchive -> Bool
(DeleteArchive -> DeleteArchive -> Bool)
-> (DeleteArchive -> DeleteArchive -> Bool) -> Eq DeleteArchive
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteArchive -> DeleteArchive -> Bool
$c/= :: DeleteArchive -> DeleteArchive -> Bool
== :: DeleteArchive -> DeleteArchive -> Bool
$c== :: DeleteArchive -> DeleteArchive -> Bool
Prelude.Eq, ReadPrec [DeleteArchive]
ReadPrec DeleteArchive
Int -> ReadS DeleteArchive
ReadS [DeleteArchive]
(Int -> ReadS DeleteArchive)
-> ReadS [DeleteArchive]
-> ReadPrec DeleteArchive
-> ReadPrec [DeleteArchive]
-> Read DeleteArchive
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteArchive]
$creadListPrec :: ReadPrec [DeleteArchive]
readPrec :: ReadPrec DeleteArchive
$creadPrec :: ReadPrec DeleteArchive
readList :: ReadS [DeleteArchive]
$creadList :: ReadS [DeleteArchive]
readsPrec :: Int -> ReadS DeleteArchive
$creadsPrec :: Int -> ReadS DeleteArchive
Prelude.Read, Int -> DeleteArchive -> ShowS
[DeleteArchive] -> ShowS
DeleteArchive -> String
(Int -> DeleteArchive -> ShowS)
-> (DeleteArchive -> String)
-> ([DeleteArchive] -> ShowS)
-> Show DeleteArchive
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteArchive] -> ShowS
$cshowList :: [DeleteArchive] -> ShowS
show :: DeleteArchive -> String
$cshow :: DeleteArchive -> String
showsPrec :: Int -> DeleteArchive -> ShowS
$cshowsPrec :: Int -> DeleteArchive -> ShowS
Prelude.Show, (forall x. DeleteArchive -> Rep DeleteArchive x)
-> (forall x. Rep DeleteArchive x -> DeleteArchive)
-> Generic DeleteArchive
forall x. Rep DeleteArchive x -> DeleteArchive
forall x. DeleteArchive -> Rep DeleteArchive x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteArchive x -> DeleteArchive
$cfrom :: forall x. DeleteArchive -> Rep DeleteArchive x
Prelude.Generic)

-- |
-- Create a value of 'DeleteArchive' 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:
--
-- 'archiveName', 'deleteArchive_archiveName' - The name of the archive to delete.
newDeleteArchive ::
  -- | 'archiveName'
  Prelude.Text ->
  DeleteArchive
newDeleteArchive :: Text -> DeleteArchive
newDeleteArchive Text
pArchiveName_ =
  DeleteArchive' :: Text -> DeleteArchive
DeleteArchive' {$sel:archiveName:DeleteArchive' :: Text
archiveName = Text
pArchiveName_}

-- | The name of the archive to delete.
deleteArchive_archiveName :: Lens.Lens' DeleteArchive Prelude.Text
deleteArchive_archiveName :: (Text -> f Text) -> DeleteArchive -> f DeleteArchive
deleteArchive_archiveName = (DeleteArchive -> Text)
-> (DeleteArchive -> Text -> DeleteArchive)
-> Lens DeleteArchive DeleteArchive Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteArchive' {Text
archiveName :: Text
$sel:archiveName:DeleteArchive' :: DeleteArchive -> Text
archiveName} -> Text
archiveName) (\s :: DeleteArchive
s@DeleteArchive' {} Text
a -> DeleteArchive
s {$sel:archiveName:DeleteArchive' :: Text
archiveName = Text
a} :: DeleteArchive)

instance Core.AWSRequest DeleteArchive where
  type
    AWSResponse DeleteArchive =
      DeleteArchiveResponse
  request :: DeleteArchive -> Request DeleteArchive
request = Service -> DeleteArchive -> Request DeleteArchive
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteArchive
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteArchive)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DeleteArchive))
-> Logger
-> Service
-> Proxy DeleteArchive
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteArchive)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> DeleteArchiveResponse
DeleteArchiveResponse'
            (Int -> DeleteArchiveResponse)
-> Either String Int -> Either String DeleteArchiveResponse
forall (f :: * -> *) a b. Functor 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 DeleteArchive

instance Prelude.NFData DeleteArchive

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

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

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

-- | /See:/ 'newDeleteArchiveResponse' smart constructor.
data DeleteArchiveResponse = DeleteArchiveResponse'
  { -- | The response's http status code.
    DeleteArchiveResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteArchiveResponse -> DeleteArchiveResponse -> Bool
(DeleteArchiveResponse -> DeleteArchiveResponse -> Bool)
-> (DeleteArchiveResponse -> DeleteArchiveResponse -> Bool)
-> Eq DeleteArchiveResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteArchiveResponse -> DeleteArchiveResponse -> Bool
$c/= :: DeleteArchiveResponse -> DeleteArchiveResponse -> Bool
== :: DeleteArchiveResponse -> DeleteArchiveResponse -> Bool
$c== :: DeleteArchiveResponse -> DeleteArchiveResponse -> Bool
Prelude.Eq, ReadPrec [DeleteArchiveResponse]
ReadPrec DeleteArchiveResponse
Int -> ReadS DeleteArchiveResponse
ReadS [DeleteArchiveResponse]
(Int -> ReadS DeleteArchiveResponse)
-> ReadS [DeleteArchiveResponse]
-> ReadPrec DeleteArchiveResponse
-> ReadPrec [DeleteArchiveResponse]
-> Read DeleteArchiveResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteArchiveResponse]
$creadListPrec :: ReadPrec [DeleteArchiveResponse]
readPrec :: ReadPrec DeleteArchiveResponse
$creadPrec :: ReadPrec DeleteArchiveResponse
readList :: ReadS [DeleteArchiveResponse]
$creadList :: ReadS [DeleteArchiveResponse]
readsPrec :: Int -> ReadS DeleteArchiveResponse
$creadsPrec :: Int -> ReadS DeleteArchiveResponse
Prelude.Read, Int -> DeleteArchiveResponse -> ShowS
[DeleteArchiveResponse] -> ShowS
DeleteArchiveResponse -> String
(Int -> DeleteArchiveResponse -> ShowS)
-> (DeleteArchiveResponse -> String)
-> ([DeleteArchiveResponse] -> ShowS)
-> Show DeleteArchiveResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteArchiveResponse] -> ShowS
$cshowList :: [DeleteArchiveResponse] -> ShowS
show :: DeleteArchiveResponse -> String
$cshow :: DeleteArchiveResponse -> String
showsPrec :: Int -> DeleteArchiveResponse -> ShowS
$cshowsPrec :: Int -> DeleteArchiveResponse -> ShowS
Prelude.Show, (forall x. DeleteArchiveResponse -> Rep DeleteArchiveResponse x)
-> (forall x. Rep DeleteArchiveResponse x -> DeleteArchiveResponse)
-> Generic DeleteArchiveResponse
forall x. Rep DeleteArchiveResponse x -> DeleteArchiveResponse
forall x. DeleteArchiveResponse -> Rep DeleteArchiveResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteArchiveResponse x -> DeleteArchiveResponse
$cfrom :: forall x. DeleteArchiveResponse -> Rep DeleteArchiveResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteArchiveResponse' 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:
--
-- 'httpStatus', 'deleteArchiveResponse_httpStatus' - The response's http status code.
newDeleteArchiveResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteArchiveResponse
newDeleteArchiveResponse :: Int -> DeleteArchiveResponse
newDeleteArchiveResponse Int
pHttpStatus_ =
  DeleteArchiveResponse' :: Int -> DeleteArchiveResponse
DeleteArchiveResponse' {$sel:httpStatus:DeleteArchiveResponse' :: Int
httpStatus = Int
pHttpStatus_}

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

instance Prelude.NFData DeleteArchiveResponse