{-# 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.CertificateManager.PutAccountConfiguration
-- 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)
--
-- Adds or modifies account-level configurations in ACM.
--
-- The supported configuration option is @DaysBeforeExpiry@. This option
-- specifies the number of days prior to certificate expiration when ACM
-- starts generating @EventBridge@ events. ACM sends one event per day per
-- certificate until the certificate expires. By default, accounts receive
-- events starting 45 days before certificate expiration.
module Amazonka.CertificateManager.PutAccountConfiguration
  ( -- * Creating a Request
    PutAccountConfiguration (..),
    newPutAccountConfiguration,

    -- * Request Lenses
    putAccountConfiguration_expiryEvents,
    putAccountConfiguration_idempotencyToken,

    -- * Destructuring the Response
    PutAccountConfigurationResponse (..),
    newPutAccountConfigurationResponse,
  )
where

import Amazonka.CertificateManager.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:/ 'newPutAccountConfiguration' smart constructor.
data PutAccountConfiguration = PutAccountConfiguration'
  { -- | Specifies expiration events associated with an account.
    PutAccountConfiguration -> Maybe ExpiryEventsConfiguration
expiryEvents :: Prelude.Maybe ExpiryEventsConfiguration,
    -- | Customer-chosen string used to distinguish between calls to
    -- @PutAccountConfiguration@. Idempotency tokens time out after one hour.
    -- If you call @PutAccountConfiguration@ multiple times with the same
    -- unexpired idempotency token, ACM treats it as the same request and
    -- returns the original result. If you change the idempotency token for
    -- each call, ACM treats each call as a new request.
    PutAccountConfiguration -> Text
idempotencyToken :: Prelude.Text
  }
  deriving (PutAccountConfiguration -> PutAccountConfiguration -> Bool
(PutAccountConfiguration -> PutAccountConfiguration -> Bool)
-> (PutAccountConfiguration -> PutAccountConfiguration -> Bool)
-> Eq PutAccountConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutAccountConfiguration -> PutAccountConfiguration -> Bool
$c/= :: PutAccountConfiguration -> PutAccountConfiguration -> Bool
== :: PutAccountConfiguration -> PutAccountConfiguration -> Bool
$c== :: PutAccountConfiguration -> PutAccountConfiguration -> Bool
Prelude.Eq, ReadPrec [PutAccountConfiguration]
ReadPrec PutAccountConfiguration
Int -> ReadS PutAccountConfiguration
ReadS [PutAccountConfiguration]
(Int -> ReadS PutAccountConfiguration)
-> ReadS [PutAccountConfiguration]
-> ReadPrec PutAccountConfiguration
-> ReadPrec [PutAccountConfiguration]
-> Read PutAccountConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutAccountConfiguration]
$creadListPrec :: ReadPrec [PutAccountConfiguration]
readPrec :: ReadPrec PutAccountConfiguration
$creadPrec :: ReadPrec PutAccountConfiguration
readList :: ReadS [PutAccountConfiguration]
$creadList :: ReadS [PutAccountConfiguration]
readsPrec :: Int -> ReadS PutAccountConfiguration
$creadsPrec :: Int -> ReadS PutAccountConfiguration
Prelude.Read, Int -> PutAccountConfiguration -> ShowS
[PutAccountConfiguration] -> ShowS
PutAccountConfiguration -> String
(Int -> PutAccountConfiguration -> ShowS)
-> (PutAccountConfiguration -> String)
-> ([PutAccountConfiguration] -> ShowS)
-> Show PutAccountConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutAccountConfiguration] -> ShowS
$cshowList :: [PutAccountConfiguration] -> ShowS
show :: PutAccountConfiguration -> String
$cshow :: PutAccountConfiguration -> String
showsPrec :: Int -> PutAccountConfiguration -> ShowS
$cshowsPrec :: Int -> PutAccountConfiguration -> ShowS
Prelude.Show, (forall x.
 PutAccountConfiguration -> Rep PutAccountConfiguration x)
-> (forall x.
    Rep PutAccountConfiguration x -> PutAccountConfiguration)
-> Generic PutAccountConfiguration
forall x. Rep PutAccountConfiguration x -> PutAccountConfiguration
forall x. PutAccountConfiguration -> Rep PutAccountConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutAccountConfiguration x -> PutAccountConfiguration
$cfrom :: forall x. PutAccountConfiguration -> Rep PutAccountConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'PutAccountConfiguration' 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:
--
-- 'expiryEvents', 'putAccountConfiguration_expiryEvents' - Specifies expiration events associated with an account.
--
-- 'idempotencyToken', 'putAccountConfiguration_idempotencyToken' - Customer-chosen string used to distinguish between calls to
-- @PutAccountConfiguration@. Idempotency tokens time out after one hour.
-- If you call @PutAccountConfiguration@ multiple times with the same
-- unexpired idempotency token, ACM treats it as the same request and
-- returns the original result. If you change the idempotency token for
-- each call, ACM treats each call as a new request.
newPutAccountConfiguration ::
  -- | 'idempotencyToken'
  Prelude.Text ->
  PutAccountConfiguration
newPutAccountConfiguration :: Text -> PutAccountConfiguration
newPutAccountConfiguration Text
pIdempotencyToken_ =
  PutAccountConfiguration' :: Maybe ExpiryEventsConfiguration -> Text -> PutAccountConfiguration
PutAccountConfiguration'
    { $sel:expiryEvents:PutAccountConfiguration' :: Maybe ExpiryEventsConfiguration
expiryEvents =
        Maybe ExpiryEventsConfiguration
forall a. Maybe a
Prelude.Nothing,
      $sel:idempotencyToken:PutAccountConfiguration' :: Text
idempotencyToken = Text
pIdempotencyToken_
    }

-- | Specifies expiration events associated with an account.
putAccountConfiguration_expiryEvents :: Lens.Lens' PutAccountConfiguration (Prelude.Maybe ExpiryEventsConfiguration)
putAccountConfiguration_expiryEvents :: (Maybe ExpiryEventsConfiguration
 -> f (Maybe ExpiryEventsConfiguration))
-> PutAccountConfiguration -> f PutAccountConfiguration
putAccountConfiguration_expiryEvents = (PutAccountConfiguration -> Maybe ExpiryEventsConfiguration)
-> (PutAccountConfiguration
    -> Maybe ExpiryEventsConfiguration -> PutAccountConfiguration)
-> Lens
     PutAccountConfiguration
     PutAccountConfiguration
     (Maybe ExpiryEventsConfiguration)
     (Maybe ExpiryEventsConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutAccountConfiguration' {Maybe ExpiryEventsConfiguration
expiryEvents :: Maybe ExpiryEventsConfiguration
$sel:expiryEvents:PutAccountConfiguration' :: PutAccountConfiguration -> Maybe ExpiryEventsConfiguration
expiryEvents} -> Maybe ExpiryEventsConfiguration
expiryEvents) (\s :: PutAccountConfiguration
s@PutAccountConfiguration' {} Maybe ExpiryEventsConfiguration
a -> PutAccountConfiguration
s {$sel:expiryEvents:PutAccountConfiguration' :: Maybe ExpiryEventsConfiguration
expiryEvents = Maybe ExpiryEventsConfiguration
a} :: PutAccountConfiguration)

-- | Customer-chosen string used to distinguish between calls to
-- @PutAccountConfiguration@. Idempotency tokens time out after one hour.
-- If you call @PutAccountConfiguration@ multiple times with the same
-- unexpired idempotency token, ACM treats it as the same request and
-- returns the original result. If you change the idempotency token for
-- each call, ACM treats each call as a new request.
putAccountConfiguration_idempotencyToken :: Lens.Lens' PutAccountConfiguration Prelude.Text
putAccountConfiguration_idempotencyToken :: (Text -> f Text)
-> PutAccountConfiguration -> f PutAccountConfiguration
putAccountConfiguration_idempotencyToken = (PutAccountConfiguration -> Text)
-> (PutAccountConfiguration -> Text -> PutAccountConfiguration)
-> Lens PutAccountConfiguration PutAccountConfiguration Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutAccountConfiguration' {Text
idempotencyToken :: Text
$sel:idempotencyToken:PutAccountConfiguration' :: PutAccountConfiguration -> Text
idempotencyToken} -> Text
idempotencyToken) (\s :: PutAccountConfiguration
s@PutAccountConfiguration' {} Text
a -> PutAccountConfiguration
s {$sel:idempotencyToken:PutAccountConfiguration' :: Text
idempotencyToken = Text
a} :: PutAccountConfiguration)

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

instance Prelude.Hashable PutAccountConfiguration

instance Prelude.NFData PutAccountConfiguration

instance Core.ToHeaders PutAccountConfiguration where
  toHeaders :: PutAccountConfiguration -> [Header]
toHeaders =
    [Header] -> PutAccountConfiguration -> [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
"CertificateManager.PutAccountConfiguration" ::
                          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 PutAccountConfiguration where
  toJSON :: PutAccountConfiguration -> Value
toJSON PutAccountConfiguration' {Maybe ExpiryEventsConfiguration
Text
idempotencyToken :: Text
expiryEvents :: Maybe ExpiryEventsConfiguration
$sel:idempotencyToken:PutAccountConfiguration' :: PutAccountConfiguration -> Text
$sel:expiryEvents:PutAccountConfiguration' :: PutAccountConfiguration -> Maybe ExpiryEventsConfiguration
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ExpiryEvents" Text -> ExpiryEventsConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (ExpiryEventsConfiguration -> Pair)
-> Maybe ExpiryEventsConfiguration -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ExpiryEventsConfiguration
expiryEvents,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"IdempotencyToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
idempotencyToken)
          ]
      )

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

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

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

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

instance
  Prelude.NFData
    PutAccountConfigurationResponse