{-# 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.CloudWatchLogs.DeleteRetentionPolicy
-- 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 retention policy.
--
-- Log events do not expire if they belong to log groups without a
-- retention policy.
module Amazonka.CloudWatchLogs.DeleteRetentionPolicy
  ( -- * Creating a Request
    DeleteRetentionPolicy (..),
    newDeleteRetentionPolicy,

    -- * Request Lenses
    deleteRetentionPolicy_logGroupName,

    -- * Destructuring the Response
    DeleteRetentionPolicyResponse (..),
    newDeleteRetentionPolicyResponse,
  )
where

import Amazonka.CloudWatchLogs.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:/ 'newDeleteRetentionPolicy' smart constructor.
data DeleteRetentionPolicy = DeleteRetentionPolicy'
  { -- | The name of the log group.
    DeleteRetentionPolicy -> Text
logGroupName :: Prelude.Text
  }
  deriving (DeleteRetentionPolicy -> DeleteRetentionPolicy -> Bool
(DeleteRetentionPolicy -> DeleteRetentionPolicy -> Bool)
-> (DeleteRetentionPolicy -> DeleteRetentionPolicy -> Bool)
-> Eq DeleteRetentionPolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteRetentionPolicy -> DeleteRetentionPolicy -> Bool
$c/= :: DeleteRetentionPolicy -> DeleteRetentionPolicy -> Bool
== :: DeleteRetentionPolicy -> DeleteRetentionPolicy -> Bool
$c== :: DeleteRetentionPolicy -> DeleteRetentionPolicy -> Bool
Prelude.Eq, ReadPrec [DeleteRetentionPolicy]
ReadPrec DeleteRetentionPolicy
Int -> ReadS DeleteRetentionPolicy
ReadS [DeleteRetentionPolicy]
(Int -> ReadS DeleteRetentionPolicy)
-> ReadS [DeleteRetentionPolicy]
-> ReadPrec DeleteRetentionPolicy
-> ReadPrec [DeleteRetentionPolicy]
-> Read DeleteRetentionPolicy
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteRetentionPolicy]
$creadListPrec :: ReadPrec [DeleteRetentionPolicy]
readPrec :: ReadPrec DeleteRetentionPolicy
$creadPrec :: ReadPrec DeleteRetentionPolicy
readList :: ReadS [DeleteRetentionPolicy]
$creadList :: ReadS [DeleteRetentionPolicy]
readsPrec :: Int -> ReadS DeleteRetentionPolicy
$creadsPrec :: Int -> ReadS DeleteRetentionPolicy
Prelude.Read, Int -> DeleteRetentionPolicy -> ShowS
[DeleteRetentionPolicy] -> ShowS
DeleteRetentionPolicy -> String
(Int -> DeleteRetentionPolicy -> ShowS)
-> (DeleteRetentionPolicy -> String)
-> ([DeleteRetentionPolicy] -> ShowS)
-> Show DeleteRetentionPolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteRetentionPolicy] -> ShowS
$cshowList :: [DeleteRetentionPolicy] -> ShowS
show :: DeleteRetentionPolicy -> String
$cshow :: DeleteRetentionPolicy -> String
showsPrec :: Int -> DeleteRetentionPolicy -> ShowS
$cshowsPrec :: Int -> DeleteRetentionPolicy -> ShowS
Prelude.Show, (forall x. DeleteRetentionPolicy -> Rep DeleteRetentionPolicy x)
-> (forall x. Rep DeleteRetentionPolicy x -> DeleteRetentionPolicy)
-> Generic DeleteRetentionPolicy
forall x. Rep DeleteRetentionPolicy x -> DeleteRetentionPolicy
forall x. DeleteRetentionPolicy -> Rep DeleteRetentionPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteRetentionPolicy x -> DeleteRetentionPolicy
$cfrom :: forall x. DeleteRetentionPolicy -> Rep DeleteRetentionPolicy x
Prelude.Generic)

-- |
-- Create a value of 'DeleteRetentionPolicy' 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:
--
-- 'logGroupName', 'deleteRetentionPolicy_logGroupName' - The name of the log group.
newDeleteRetentionPolicy ::
  -- | 'logGroupName'
  Prelude.Text ->
  DeleteRetentionPolicy
newDeleteRetentionPolicy :: Text -> DeleteRetentionPolicy
newDeleteRetentionPolicy Text
pLogGroupName_ =
  DeleteRetentionPolicy' :: Text -> DeleteRetentionPolicy
DeleteRetentionPolicy'
    { $sel:logGroupName:DeleteRetentionPolicy' :: Text
logGroupName =
        Text
pLogGroupName_
    }

-- | The name of the log group.
deleteRetentionPolicy_logGroupName :: Lens.Lens' DeleteRetentionPolicy Prelude.Text
deleteRetentionPolicy_logGroupName :: (Text -> f Text)
-> DeleteRetentionPolicy -> f DeleteRetentionPolicy
deleteRetentionPolicy_logGroupName = (DeleteRetentionPolicy -> Text)
-> (DeleteRetentionPolicy -> Text -> DeleteRetentionPolicy)
-> Lens DeleteRetentionPolicy DeleteRetentionPolicy Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteRetentionPolicy' {Text
logGroupName :: Text
$sel:logGroupName:DeleteRetentionPolicy' :: DeleteRetentionPolicy -> Text
logGroupName} -> Text
logGroupName) (\s :: DeleteRetentionPolicy
s@DeleteRetentionPolicy' {} Text
a -> DeleteRetentionPolicy
s {$sel:logGroupName:DeleteRetentionPolicy' :: Text
logGroupName = Text
a} :: DeleteRetentionPolicy)

instance Core.AWSRequest DeleteRetentionPolicy where
  type
    AWSResponse DeleteRetentionPolicy =
      DeleteRetentionPolicyResponse
  request :: DeleteRetentionPolicy -> Request DeleteRetentionPolicy
request = Service -> DeleteRetentionPolicy -> Request DeleteRetentionPolicy
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteRetentionPolicy
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteRetentionPolicy)))
response =
    AWSResponse DeleteRetentionPolicy
-> Logger
-> Service
-> Proxy DeleteRetentionPolicy
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteRetentionPolicy)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse DeleteRetentionPolicy
DeleteRetentionPolicyResponse
DeleteRetentionPolicyResponse'

instance Prelude.Hashable DeleteRetentionPolicy

instance Prelude.NFData DeleteRetentionPolicy

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

instance Core.ToJSON DeleteRetentionPolicy where
  toJSON :: DeleteRetentionPolicy -> Value
toJSON DeleteRetentionPolicy' {Text
logGroupName :: Text
$sel:logGroupName:DeleteRetentionPolicy' :: DeleteRetentionPolicy -> 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
"logGroupName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
logGroupName)]
      )

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

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

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

-- |
-- Create a value of 'DeleteRetentionPolicyResponse' 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.
newDeleteRetentionPolicyResponse ::
  DeleteRetentionPolicyResponse
newDeleteRetentionPolicyResponse :: DeleteRetentionPolicyResponse
newDeleteRetentionPolicyResponse =
  DeleteRetentionPolicyResponse
DeleteRetentionPolicyResponse'

instance Prelude.NFData DeleteRetentionPolicyResponse