{-# 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-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)
--
-- 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.Lens as Lens
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
(PutInboundDmarcSettings -> PutInboundDmarcSettings -> Bool)
-> (PutInboundDmarcSettings -> PutInboundDmarcSettings -> Bool)
-> Eq PutInboundDmarcSettings
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]
(Int -> ReadS PutInboundDmarcSettings)
-> ReadS [PutInboundDmarcSettings]
-> ReadPrec PutInboundDmarcSettings
-> ReadPrec [PutInboundDmarcSettings]
-> Read 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
(Int -> PutInboundDmarcSettings -> ShowS)
-> (PutInboundDmarcSettings -> String)
-> ([PutInboundDmarcSettings] -> ShowS)
-> Show PutInboundDmarcSettings
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.
 PutInboundDmarcSettings -> Rep PutInboundDmarcSettings x)
-> (forall x.
    Rep PutInboundDmarcSettings x -> PutInboundDmarcSettings)
-> Generic PutInboundDmarcSettings
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' :: Text -> Bool -> PutInboundDmarcSettings
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 :: (Text -> f Text)
-> PutInboundDmarcSettings -> f PutInboundDmarcSettings
putInboundDmarcSettings_organizationId = (PutInboundDmarcSettings -> Text)
-> (PutInboundDmarcSettings -> Text -> PutInboundDmarcSettings)
-> Lens PutInboundDmarcSettings PutInboundDmarcSettings Text Text
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 :: (Bool -> f Bool)
-> PutInboundDmarcSettings -> f PutInboundDmarcSettings
putInboundDmarcSettings_enforced = (PutInboundDmarcSettings -> Bool)
-> (PutInboundDmarcSettings -> Bool -> PutInboundDmarcSettings)
-> Lens PutInboundDmarcSettings PutInboundDmarcSettings Bool Bool
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 :: PutInboundDmarcSettings -> Request PutInboundDmarcSettings
request = Service
-> PutInboundDmarcSettings -> Request PutInboundDmarcSettings
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy PutInboundDmarcSettings
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse PutInboundDmarcSettings)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse PutInboundDmarcSettings))
-> Logger
-> Service
-> Proxy PutInboundDmarcSettings
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse PutInboundDmarcSettings)))
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 -> PutInboundDmarcSettingsResponse
PutInboundDmarcSettingsResponse'
            (Int -> PutInboundDmarcSettingsResponse)
-> Either String Int
-> Either String PutInboundDmarcSettingsResponse
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 PutInboundDmarcSettings

instance Prelude.NFData PutInboundDmarcSettings

instance Core.ToHeaders PutInboundDmarcSettings where
  toHeaders :: PutInboundDmarcSettings -> ResponseHeaders
toHeaders =
    ResponseHeaders -> PutInboundDmarcSettings -> 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
"WorkMailService.PutInboundDmarcSettings" ::
                          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 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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"OrganizationId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
organizationId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Enforced" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Bool
enforced)
          ]
      )

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

instance Core.ToQuery PutInboundDmarcSettings where
  toQuery :: PutInboundDmarcSettings -> QueryString
toQuery = QueryString -> PutInboundDmarcSettings -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(PutInboundDmarcSettingsResponse
 -> PutInboundDmarcSettingsResponse -> Bool)
-> (PutInboundDmarcSettingsResponse
    -> PutInboundDmarcSettingsResponse -> Bool)
-> Eq PutInboundDmarcSettingsResponse
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]
(Int -> ReadS PutInboundDmarcSettingsResponse)
-> ReadS [PutInboundDmarcSettingsResponse]
-> ReadPrec PutInboundDmarcSettingsResponse
-> ReadPrec [PutInboundDmarcSettingsResponse]
-> Read 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
(Int -> PutInboundDmarcSettingsResponse -> ShowS)
-> (PutInboundDmarcSettingsResponse -> String)
-> ([PutInboundDmarcSettingsResponse] -> ShowS)
-> Show PutInboundDmarcSettingsResponse
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.
 PutInboundDmarcSettingsResponse
 -> Rep PutInboundDmarcSettingsResponse x)
-> (forall x.
    Rep PutInboundDmarcSettingsResponse x
    -> PutInboundDmarcSettingsResponse)
-> Generic PutInboundDmarcSettingsResponse
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' :: Int -> PutInboundDmarcSettingsResponse
PutInboundDmarcSettingsResponse'
    { $sel:httpStatus:PutInboundDmarcSettingsResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
putInboundDmarcSettingsResponse_httpStatus :: Lens.Lens' PutInboundDmarcSettingsResponse Prelude.Int
putInboundDmarcSettingsResponse_httpStatus :: (Int -> f Int)
-> PutInboundDmarcSettingsResponse
-> f PutInboundDmarcSettingsResponse
putInboundDmarcSettingsResponse_httpStatus = (PutInboundDmarcSettingsResponse -> Int)
-> (PutInboundDmarcSettingsResponse
    -> Int -> PutInboundDmarcSettingsResponse)
-> Lens
     PutInboundDmarcSettingsResponse
     PutInboundDmarcSettingsResponse
     Int
     Int
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