{-# 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.WorkMail.DeleteRetentionPolicy
-- 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 retention policy from the specified organization.
module Amazonka.WorkMail.DeleteRetentionPolicy
  ( -- * Creating a Request
    DeleteRetentionPolicy (..),
    newDeleteRetentionPolicy,

    -- * Request Lenses
    deleteRetentionPolicy_organizationId,
    deleteRetentionPolicy_id,

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

    -- * Response Lenses
    deleteRetentionPolicyResponse_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.WorkMail.Types

-- | /See:/ 'newDeleteRetentionPolicy' smart constructor.
data DeleteRetentionPolicy = DeleteRetentionPolicy'
  { -- | The organization ID.
    DeleteRetentionPolicy -> Text
organizationId :: Prelude.Text,
    -- | The retention policy ID.
    DeleteRetentionPolicy -> Text
id :: Prelude.Text
  }
  deriving (DeleteRetentionPolicy -> DeleteRetentionPolicy -> Bool
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]
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
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. 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:
--
-- 'organizationId', 'deleteRetentionPolicy_organizationId' - The organization ID.
--
-- 'id', 'deleteRetentionPolicy_id' - The retention policy ID.
newDeleteRetentionPolicy ::
  -- | 'organizationId'
  Prelude.Text ->
  -- | 'id'
  Prelude.Text ->
  DeleteRetentionPolicy
newDeleteRetentionPolicy :: Text -> Text -> DeleteRetentionPolicy
newDeleteRetentionPolicy Text
pOrganizationId_ Text
pId_ =
  DeleteRetentionPolicy'
    { $sel:organizationId:DeleteRetentionPolicy' :: Text
organizationId =
        Text
pOrganizationId_,
      $sel:id:DeleteRetentionPolicy' :: Text
id = Text
pId_
    }

-- | The organization ID.
deleteRetentionPolicy_organizationId :: Lens.Lens' DeleteRetentionPolicy Prelude.Text
deleteRetentionPolicy_organizationId :: Lens' DeleteRetentionPolicy Text
deleteRetentionPolicy_organizationId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteRetentionPolicy' {Text
organizationId :: Text
$sel:organizationId:DeleteRetentionPolicy' :: DeleteRetentionPolicy -> Text
organizationId} -> Text
organizationId) (\s :: DeleteRetentionPolicy
s@DeleteRetentionPolicy' {} Text
a -> DeleteRetentionPolicy
s {$sel:organizationId:DeleteRetentionPolicy' :: Text
organizationId = Text
a} :: DeleteRetentionPolicy)

-- | The retention policy ID.
deleteRetentionPolicy_id :: Lens.Lens' DeleteRetentionPolicy Prelude.Text
deleteRetentionPolicy_id :: Lens' DeleteRetentionPolicy Text
deleteRetentionPolicy_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteRetentionPolicy' {Text
id :: Text
$sel:id:DeleteRetentionPolicy' :: DeleteRetentionPolicy -> Text
id} -> Text
id) (\s :: DeleteRetentionPolicy
s@DeleteRetentionPolicy' {} Text
a -> DeleteRetentionPolicy
s {$sel:id:DeleteRetentionPolicy' :: Text
id = Text
a} :: DeleteRetentionPolicy)

instance Core.AWSRequest DeleteRetentionPolicy where
  type
    AWSResponse DeleteRetentionPolicy =
      DeleteRetentionPolicyResponse
  request :: (Service -> Service)
-> DeleteRetentionPolicy -> Request DeleteRetentionPolicy
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 DeleteRetentionPolicy
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteRetentionPolicy)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> DeleteRetentionPolicyResponse
DeleteRetentionPolicyResponse'
            forall (f :: * -> *) a b. Functor 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 DeleteRetentionPolicy where
  hashWithSalt :: Int -> DeleteRetentionPolicy -> Int
hashWithSalt Int
_salt DeleteRetentionPolicy' {Text
id :: Text
organizationId :: Text
$sel:id:DeleteRetentionPolicy' :: DeleteRetentionPolicy -> Text
$sel:organizationId:DeleteRetentionPolicy' :: DeleteRetentionPolicy -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
organizationId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
id

instance Prelude.NFData DeleteRetentionPolicy where
  rnf :: DeleteRetentionPolicy -> ()
rnf DeleteRetentionPolicy' {Text
id :: Text
organizationId :: Text
$sel:id:DeleteRetentionPolicy' :: DeleteRetentionPolicy -> Text
$sel:organizationId:DeleteRetentionPolicy' :: DeleteRetentionPolicy -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
organizationId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
id

instance Data.ToHeaders DeleteRetentionPolicy where
  toHeaders :: DeleteRetentionPolicy -> 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
"WorkMailService.DeleteRetentionPolicy" ::
                          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 DeleteRetentionPolicy where
  toJSON :: DeleteRetentionPolicy -> Value
toJSON DeleteRetentionPolicy' {Text
id :: Text
organizationId :: Text
$sel:id:DeleteRetentionPolicy' :: DeleteRetentionPolicy -> Text
$sel:organizationId:DeleteRetentionPolicy' :: DeleteRetentionPolicy -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"OrganizationId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
organizationId),
            forall a. a -> Maybe a
Prelude.Just (Key
"Id" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
id)
          ]
      )

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

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

-- | /See:/ 'newDeleteRetentionPolicyResponse' smart constructor.
data DeleteRetentionPolicyResponse = DeleteRetentionPolicyResponse'
  { -- | The response's http status code.
    DeleteRetentionPolicyResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteRetentionPolicyResponse
-> DeleteRetentionPolicyResponse -> Bool
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]
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
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.
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.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'httpStatus', 'deleteRetentionPolicyResponse_httpStatus' - The response's http status code.
newDeleteRetentionPolicyResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteRetentionPolicyResponse
newDeleteRetentionPolicyResponse :: Int -> DeleteRetentionPolicyResponse
newDeleteRetentionPolicyResponse Int
pHttpStatus_ =
  DeleteRetentionPolicyResponse'
    { $sel:httpStatus:DeleteRetentionPolicyResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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

instance Prelude.NFData DeleteRetentionPolicyResponse where
  rnf :: DeleteRetentionPolicyResponse -> ()
rnf DeleteRetentionPolicyResponse' {Int
httpStatus :: Int
$sel:httpStatus:DeleteRetentionPolicyResponse' :: DeleteRetentionPolicyResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus