{-# 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.PutEmailMonitoringConfiguration
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Creates or updates the email monitoring configuration for a specified
-- organization.
module Amazonka.WorkMail.PutEmailMonitoringConfiguration
  ( -- * Creating a Request
    PutEmailMonitoringConfiguration (..),
    newPutEmailMonitoringConfiguration,

    -- * Request Lenses
    putEmailMonitoringConfiguration_organizationId,
    putEmailMonitoringConfiguration_roleArn,
    putEmailMonitoringConfiguration_logGroupArn,

    -- * Destructuring the Response
    PutEmailMonitoringConfigurationResponse (..),
    newPutEmailMonitoringConfigurationResponse,

    -- * Response Lenses
    putEmailMonitoringConfigurationResponse_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:/ 'newPutEmailMonitoringConfiguration' smart constructor.
data PutEmailMonitoringConfiguration = PutEmailMonitoringConfiguration'
  { -- | The ID of the organization for which the email monitoring configuration
    -- is set.
    PutEmailMonitoringConfiguration -> Text
organizationId :: Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the IAM Role associated with the email
    -- monitoring configuration.
    PutEmailMonitoringConfiguration -> Text
roleArn :: Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the CloudWatch Log group associated
    -- with the email monitoring configuration.
    PutEmailMonitoringConfiguration -> Text
logGroupArn :: Prelude.Text
  }
  deriving (PutEmailMonitoringConfiguration
-> PutEmailMonitoringConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutEmailMonitoringConfiguration
-> PutEmailMonitoringConfiguration -> Bool
$c/= :: PutEmailMonitoringConfiguration
-> PutEmailMonitoringConfiguration -> Bool
== :: PutEmailMonitoringConfiguration
-> PutEmailMonitoringConfiguration -> Bool
$c== :: PutEmailMonitoringConfiguration
-> PutEmailMonitoringConfiguration -> Bool
Prelude.Eq, ReadPrec [PutEmailMonitoringConfiguration]
ReadPrec PutEmailMonitoringConfiguration
Int -> ReadS PutEmailMonitoringConfiguration
ReadS [PutEmailMonitoringConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutEmailMonitoringConfiguration]
$creadListPrec :: ReadPrec [PutEmailMonitoringConfiguration]
readPrec :: ReadPrec PutEmailMonitoringConfiguration
$creadPrec :: ReadPrec PutEmailMonitoringConfiguration
readList :: ReadS [PutEmailMonitoringConfiguration]
$creadList :: ReadS [PutEmailMonitoringConfiguration]
readsPrec :: Int -> ReadS PutEmailMonitoringConfiguration
$creadsPrec :: Int -> ReadS PutEmailMonitoringConfiguration
Prelude.Read, Int -> PutEmailMonitoringConfiguration -> ShowS
[PutEmailMonitoringConfiguration] -> ShowS
PutEmailMonitoringConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutEmailMonitoringConfiguration] -> ShowS
$cshowList :: [PutEmailMonitoringConfiguration] -> ShowS
show :: PutEmailMonitoringConfiguration -> String
$cshow :: PutEmailMonitoringConfiguration -> String
showsPrec :: Int -> PutEmailMonitoringConfiguration -> ShowS
$cshowsPrec :: Int -> PutEmailMonitoringConfiguration -> ShowS
Prelude.Show, forall x.
Rep PutEmailMonitoringConfiguration x
-> PutEmailMonitoringConfiguration
forall x.
PutEmailMonitoringConfiguration
-> Rep PutEmailMonitoringConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PutEmailMonitoringConfiguration x
-> PutEmailMonitoringConfiguration
$cfrom :: forall x.
PutEmailMonitoringConfiguration
-> Rep PutEmailMonitoringConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'PutEmailMonitoringConfiguration' 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', 'putEmailMonitoringConfiguration_organizationId' - The ID of the organization for which the email monitoring configuration
-- is set.
--
-- 'roleArn', 'putEmailMonitoringConfiguration_roleArn' - The Amazon Resource Name (ARN) of the IAM Role associated with the email
-- monitoring configuration.
--
-- 'logGroupArn', 'putEmailMonitoringConfiguration_logGroupArn' - The Amazon Resource Name (ARN) of the CloudWatch Log group associated
-- with the email monitoring configuration.
newPutEmailMonitoringConfiguration ::
  -- | 'organizationId'
  Prelude.Text ->
  -- | 'roleArn'
  Prelude.Text ->
  -- | 'logGroupArn'
  Prelude.Text ->
  PutEmailMonitoringConfiguration
newPutEmailMonitoringConfiguration :: Text -> Text -> Text -> PutEmailMonitoringConfiguration
newPutEmailMonitoringConfiguration
  Text
pOrganizationId_
  Text
pRoleArn_
  Text
pLogGroupArn_ =
    PutEmailMonitoringConfiguration'
      { $sel:organizationId:PutEmailMonitoringConfiguration' :: Text
organizationId =
          Text
pOrganizationId_,
        $sel:roleArn:PutEmailMonitoringConfiguration' :: Text
roleArn = Text
pRoleArn_,
        $sel:logGroupArn:PutEmailMonitoringConfiguration' :: Text
logGroupArn = Text
pLogGroupArn_
      }

-- | The ID of the organization for which the email monitoring configuration
-- is set.
putEmailMonitoringConfiguration_organizationId :: Lens.Lens' PutEmailMonitoringConfiguration Prelude.Text
putEmailMonitoringConfiguration_organizationId :: Lens' PutEmailMonitoringConfiguration Text
putEmailMonitoringConfiguration_organizationId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutEmailMonitoringConfiguration' {Text
organizationId :: Text
$sel:organizationId:PutEmailMonitoringConfiguration' :: PutEmailMonitoringConfiguration -> Text
organizationId} -> Text
organizationId) (\s :: PutEmailMonitoringConfiguration
s@PutEmailMonitoringConfiguration' {} Text
a -> PutEmailMonitoringConfiguration
s {$sel:organizationId:PutEmailMonitoringConfiguration' :: Text
organizationId = Text
a} :: PutEmailMonitoringConfiguration)

-- | The Amazon Resource Name (ARN) of the IAM Role associated with the email
-- monitoring configuration.
putEmailMonitoringConfiguration_roleArn :: Lens.Lens' PutEmailMonitoringConfiguration Prelude.Text
putEmailMonitoringConfiguration_roleArn :: Lens' PutEmailMonitoringConfiguration Text
putEmailMonitoringConfiguration_roleArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutEmailMonitoringConfiguration' {Text
roleArn :: Text
$sel:roleArn:PutEmailMonitoringConfiguration' :: PutEmailMonitoringConfiguration -> Text
roleArn} -> Text
roleArn) (\s :: PutEmailMonitoringConfiguration
s@PutEmailMonitoringConfiguration' {} Text
a -> PutEmailMonitoringConfiguration
s {$sel:roleArn:PutEmailMonitoringConfiguration' :: Text
roleArn = Text
a} :: PutEmailMonitoringConfiguration)

-- | The Amazon Resource Name (ARN) of the CloudWatch Log group associated
-- with the email monitoring configuration.
putEmailMonitoringConfiguration_logGroupArn :: Lens.Lens' PutEmailMonitoringConfiguration Prelude.Text
putEmailMonitoringConfiguration_logGroupArn :: Lens' PutEmailMonitoringConfiguration Text
putEmailMonitoringConfiguration_logGroupArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutEmailMonitoringConfiguration' {Text
logGroupArn :: Text
$sel:logGroupArn:PutEmailMonitoringConfiguration' :: PutEmailMonitoringConfiguration -> Text
logGroupArn} -> Text
logGroupArn) (\s :: PutEmailMonitoringConfiguration
s@PutEmailMonitoringConfiguration' {} Text
a -> PutEmailMonitoringConfiguration
s {$sel:logGroupArn:PutEmailMonitoringConfiguration' :: Text
logGroupArn = Text
a} :: PutEmailMonitoringConfiguration)

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

instance
  Prelude.NFData
    PutEmailMonitoringConfiguration
  where
  rnf :: PutEmailMonitoringConfiguration -> ()
rnf PutEmailMonitoringConfiguration' {Text
logGroupArn :: Text
roleArn :: Text
organizationId :: Text
$sel:logGroupArn:PutEmailMonitoringConfiguration' :: PutEmailMonitoringConfiguration -> Text
$sel:roleArn:PutEmailMonitoringConfiguration' :: PutEmailMonitoringConfiguration -> Text
$sel:organizationId:PutEmailMonitoringConfiguration' :: PutEmailMonitoringConfiguration -> 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
roleArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
logGroupArn

instance
  Data.ToHeaders
    PutEmailMonitoringConfiguration
  where
  toHeaders :: PutEmailMonitoringConfiguration -> 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.PutEmailMonitoringConfiguration" ::
                          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 PutEmailMonitoringConfiguration where
  toJSON :: PutEmailMonitoringConfiguration -> Value
toJSON PutEmailMonitoringConfiguration' {Text
logGroupArn :: Text
roleArn :: Text
organizationId :: Text
$sel:logGroupArn:PutEmailMonitoringConfiguration' :: PutEmailMonitoringConfiguration -> Text
$sel:roleArn:PutEmailMonitoringConfiguration' :: PutEmailMonitoringConfiguration -> Text
$sel:organizationId:PutEmailMonitoringConfiguration' :: PutEmailMonitoringConfiguration -> 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
"RoleArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
roleArn),
            forall a. a -> Maybe a
Prelude.Just (Key
"LogGroupArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
logGroupArn)
          ]
      )

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

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

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

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

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

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