{-# 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.PutInboundDmarcSettings
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Enables or disables a DMARC policy for a given organization.
module Amazonka.WorkMail.PutInboundDmarcSettings
  ( -- * Creating a Request
    PutInboundDmarcSettings (..),
    newPutInboundDmarcSettings,

    -- * Request Lenses
    putInboundDmarcSettings_organizationId,
    putInboundDmarcSettings_enforced,

    -- * Destructuring the Response
    PutInboundDmarcSettingsResponse (..),
    newPutInboundDmarcSettingsResponse,

    -- * Response Lenses
    putInboundDmarcSettingsResponse_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:/ 'newPutInboundDmarcSettings' smart constructor.
data PutInboundDmarcSettings = PutInboundDmarcSettings'
  { -- | The ID of the organization that you are applying the DMARC policy to.
    PutInboundDmarcSettings -> Text
organizationId :: Prelude.Text,
    -- | Enforces or suspends a policy after it\'s applied.
    PutInboundDmarcSettings -> Bool
enforced :: Prelude.Bool
  }
  deriving (PutInboundDmarcSettings -> PutInboundDmarcSettings -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutInboundDmarcSettings -> PutInboundDmarcSettings -> Bool
$c/= :: PutInboundDmarcSettings -> PutInboundDmarcSettings -> Bool
== :: PutInboundDmarcSettings -> PutInboundDmarcSettings -> Bool
$c== :: PutInboundDmarcSettings -> PutInboundDmarcSettings -> Bool
Prelude.Eq, ReadPrec [PutInboundDmarcSettings]
ReadPrec PutInboundDmarcSettings
Int -> ReadS PutInboundDmarcSettings
ReadS [PutInboundDmarcSettings]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutInboundDmarcSettings]
$creadListPrec :: ReadPrec [PutInboundDmarcSettings]
readPrec :: ReadPrec PutInboundDmarcSettings
$creadPrec :: ReadPrec PutInboundDmarcSettings
readList :: ReadS [PutInboundDmarcSettings]
$creadList :: ReadS [PutInboundDmarcSettings]
readsPrec :: Int -> ReadS PutInboundDmarcSettings
$creadsPrec :: Int -> ReadS PutInboundDmarcSettings
Prelude.Read, Int -> PutInboundDmarcSettings -> ShowS
[PutInboundDmarcSettings] -> ShowS
PutInboundDmarcSettings -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutInboundDmarcSettings] -> ShowS
$cshowList :: [PutInboundDmarcSettings] -> ShowS
show :: PutInboundDmarcSettings -> String
$cshow :: PutInboundDmarcSettings -> String
showsPrec :: Int -> PutInboundDmarcSettings -> ShowS
$cshowsPrec :: Int -> PutInboundDmarcSettings -> ShowS
Prelude.Show, forall x. Rep PutInboundDmarcSettings x -> PutInboundDmarcSettings
forall x. PutInboundDmarcSettings -> Rep PutInboundDmarcSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutInboundDmarcSettings x -> PutInboundDmarcSettings
$cfrom :: forall x. PutInboundDmarcSettings -> Rep PutInboundDmarcSettings x
Prelude.Generic)

-- |
-- Create a value of 'PutInboundDmarcSettings' 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', 'putInboundDmarcSettings_organizationId' - The ID of the organization that you are applying the DMARC policy to.
--
-- 'enforced', 'putInboundDmarcSettings_enforced' - Enforces or suspends a policy after it\'s applied.
newPutInboundDmarcSettings ::
  -- | 'organizationId'
  Prelude.Text ->
  -- | 'enforced'
  Prelude.Bool ->
  PutInboundDmarcSettings
newPutInboundDmarcSettings :: Text -> Bool -> PutInboundDmarcSettings
newPutInboundDmarcSettings
  Text
pOrganizationId_
  Bool
pEnforced_ =
    PutInboundDmarcSettings'
      { $sel:organizationId:PutInboundDmarcSettings' :: Text
organizationId =
          Text
pOrganizationId_,
        $sel:enforced:PutInboundDmarcSettings' :: Bool
enforced = Bool
pEnforced_
      }

-- | The ID of the organization that you are applying the DMARC policy to.
putInboundDmarcSettings_organizationId :: Lens.Lens' PutInboundDmarcSettings Prelude.Text
putInboundDmarcSettings_organizationId :: Lens' PutInboundDmarcSettings Text
putInboundDmarcSettings_organizationId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutInboundDmarcSettings' {Text
organizationId :: Text
$sel:organizationId:PutInboundDmarcSettings' :: PutInboundDmarcSettings -> Text
organizationId} -> Text
organizationId) (\s :: PutInboundDmarcSettings
s@PutInboundDmarcSettings' {} Text
a -> PutInboundDmarcSettings
s {$sel:organizationId:PutInboundDmarcSettings' :: Text
organizationId = Text
a} :: PutInboundDmarcSettings)

-- | Enforces or suspends a policy after it\'s applied.
putInboundDmarcSettings_enforced :: Lens.Lens' PutInboundDmarcSettings Prelude.Bool
putInboundDmarcSettings_enforced :: Lens' PutInboundDmarcSettings Bool
putInboundDmarcSettings_enforced = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutInboundDmarcSettings' {Bool
enforced :: Bool
$sel:enforced:PutInboundDmarcSettings' :: PutInboundDmarcSettings -> Bool
enforced} -> Bool
enforced) (\s :: PutInboundDmarcSettings
s@PutInboundDmarcSettings' {} Bool
a -> PutInboundDmarcSettings
s {$sel:enforced:PutInboundDmarcSettings' :: Bool
enforced = Bool
a} :: PutInboundDmarcSettings)

instance Core.AWSRequest PutInboundDmarcSettings where
  type
    AWSResponse PutInboundDmarcSettings =
      PutInboundDmarcSettingsResponse
  request :: (Service -> Service)
-> PutInboundDmarcSettings -> Request PutInboundDmarcSettings
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 PutInboundDmarcSettings
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse PutInboundDmarcSettings)))
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 -> PutInboundDmarcSettingsResponse
PutInboundDmarcSettingsResponse'
            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 PutInboundDmarcSettings where
  hashWithSalt :: Int -> PutInboundDmarcSettings -> Int
hashWithSalt Int
_salt PutInboundDmarcSettings' {Bool
Text
enforced :: Bool
organizationId :: Text
$sel:enforced:PutInboundDmarcSettings' :: PutInboundDmarcSettings -> Bool
$sel:organizationId:PutInboundDmarcSettings' :: PutInboundDmarcSettings -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
organizationId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Bool
enforced

instance Prelude.NFData PutInboundDmarcSettings where
  rnf :: PutInboundDmarcSettings -> ()
rnf PutInboundDmarcSettings' {Bool
Text
enforced :: Bool
organizationId :: Text
$sel:enforced:PutInboundDmarcSettings' :: PutInboundDmarcSettings -> Bool
$sel:organizationId:PutInboundDmarcSettings' :: PutInboundDmarcSettings -> 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 Bool
enforced

instance Data.ToHeaders PutInboundDmarcSettings where
  toHeaders :: PutInboundDmarcSettings -> 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.PutInboundDmarcSettings" ::
                          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 PutInboundDmarcSettings where
  toJSON :: PutInboundDmarcSettings -> Value
toJSON PutInboundDmarcSettings' {Bool
Text
enforced :: Bool
organizationId :: Text
$sel:enforced:PutInboundDmarcSettings' :: PutInboundDmarcSettings -> Bool
$sel:organizationId:PutInboundDmarcSettings' :: PutInboundDmarcSettings -> 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
"Enforced" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Bool
enforced)
          ]
      )

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

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

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

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

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

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