{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.IoT.Types.UpdateCACertificateParams
-- 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)
module Amazonka.IoT.Types.UpdateCACertificateParams where

import qualified Amazonka.Core as Core
import Amazonka.IoT.Types.CACertificateUpdateAction
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Parameters to define a mitigation action that changes the state of the
-- CA certificate to inactive.
--
-- /See:/ 'newUpdateCACertificateParams' smart constructor.
data UpdateCACertificateParams = UpdateCACertificateParams'
  { -- | The action that you want to apply to the CA certificate. The only
    -- supported value is @DEACTIVATE@.
    UpdateCACertificateParams -> CACertificateUpdateAction
action :: CACertificateUpdateAction
  }
  deriving (UpdateCACertificateParams -> UpdateCACertificateParams -> Bool
(UpdateCACertificateParams -> UpdateCACertificateParams -> Bool)
-> (UpdateCACertificateParams -> UpdateCACertificateParams -> Bool)
-> Eq UpdateCACertificateParams
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateCACertificateParams -> UpdateCACertificateParams -> Bool
$c/= :: UpdateCACertificateParams -> UpdateCACertificateParams -> Bool
== :: UpdateCACertificateParams -> UpdateCACertificateParams -> Bool
$c== :: UpdateCACertificateParams -> UpdateCACertificateParams -> Bool
Prelude.Eq, ReadPrec [UpdateCACertificateParams]
ReadPrec UpdateCACertificateParams
Int -> ReadS UpdateCACertificateParams
ReadS [UpdateCACertificateParams]
(Int -> ReadS UpdateCACertificateParams)
-> ReadS [UpdateCACertificateParams]
-> ReadPrec UpdateCACertificateParams
-> ReadPrec [UpdateCACertificateParams]
-> Read UpdateCACertificateParams
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateCACertificateParams]
$creadListPrec :: ReadPrec [UpdateCACertificateParams]
readPrec :: ReadPrec UpdateCACertificateParams
$creadPrec :: ReadPrec UpdateCACertificateParams
readList :: ReadS [UpdateCACertificateParams]
$creadList :: ReadS [UpdateCACertificateParams]
readsPrec :: Int -> ReadS UpdateCACertificateParams
$creadsPrec :: Int -> ReadS UpdateCACertificateParams
Prelude.Read, Int -> UpdateCACertificateParams -> ShowS
[UpdateCACertificateParams] -> ShowS
UpdateCACertificateParams -> String
(Int -> UpdateCACertificateParams -> ShowS)
-> (UpdateCACertificateParams -> String)
-> ([UpdateCACertificateParams] -> ShowS)
-> Show UpdateCACertificateParams
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateCACertificateParams] -> ShowS
$cshowList :: [UpdateCACertificateParams] -> ShowS
show :: UpdateCACertificateParams -> String
$cshow :: UpdateCACertificateParams -> String
showsPrec :: Int -> UpdateCACertificateParams -> ShowS
$cshowsPrec :: Int -> UpdateCACertificateParams -> ShowS
Prelude.Show, (forall x.
 UpdateCACertificateParams -> Rep UpdateCACertificateParams x)
-> (forall x.
    Rep UpdateCACertificateParams x -> UpdateCACertificateParams)
-> Generic UpdateCACertificateParams
forall x.
Rep UpdateCACertificateParams x -> UpdateCACertificateParams
forall x.
UpdateCACertificateParams -> Rep UpdateCACertificateParams x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateCACertificateParams x -> UpdateCACertificateParams
$cfrom :: forall x.
UpdateCACertificateParams -> Rep UpdateCACertificateParams x
Prelude.Generic)

-- |
-- Create a value of 'UpdateCACertificateParams' 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:
--
-- 'action', 'updateCACertificateParams_action' - The action that you want to apply to the CA certificate. The only
-- supported value is @DEACTIVATE@.
newUpdateCACertificateParams ::
  -- | 'action'
  CACertificateUpdateAction ->
  UpdateCACertificateParams
newUpdateCACertificateParams :: CACertificateUpdateAction -> UpdateCACertificateParams
newUpdateCACertificateParams CACertificateUpdateAction
pAction_ =
  UpdateCACertificateParams' :: CACertificateUpdateAction -> UpdateCACertificateParams
UpdateCACertificateParams' {$sel:action:UpdateCACertificateParams' :: CACertificateUpdateAction
action = CACertificateUpdateAction
pAction_}

-- | The action that you want to apply to the CA certificate. The only
-- supported value is @DEACTIVATE@.
updateCACertificateParams_action :: Lens.Lens' UpdateCACertificateParams CACertificateUpdateAction
updateCACertificateParams_action :: (CACertificateUpdateAction -> f CACertificateUpdateAction)
-> UpdateCACertificateParams -> f UpdateCACertificateParams
updateCACertificateParams_action = (UpdateCACertificateParams -> CACertificateUpdateAction)
-> (UpdateCACertificateParams
    -> CACertificateUpdateAction -> UpdateCACertificateParams)
-> Lens
     UpdateCACertificateParams
     UpdateCACertificateParams
     CACertificateUpdateAction
     CACertificateUpdateAction
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateCACertificateParams' {CACertificateUpdateAction
action :: CACertificateUpdateAction
$sel:action:UpdateCACertificateParams' :: UpdateCACertificateParams -> CACertificateUpdateAction
action} -> CACertificateUpdateAction
action) (\s :: UpdateCACertificateParams
s@UpdateCACertificateParams' {} CACertificateUpdateAction
a -> UpdateCACertificateParams
s {$sel:action:UpdateCACertificateParams' :: CACertificateUpdateAction
action = CACertificateUpdateAction
a} :: UpdateCACertificateParams)

instance Core.FromJSON UpdateCACertificateParams where
  parseJSON :: Value -> Parser UpdateCACertificateParams
parseJSON =
    String
-> (Object -> Parser UpdateCACertificateParams)
-> Value
-> Parser UpdateCACertificateParams
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"UpdateCACertificateParams"
      ( \Object
x ->
          CACertificateUpdateAction -> UpdateCACertificateParams
UpdateCACertificateParams'
            (CACertificateUpdateAction -> UpdateCACertificateParams)
-> Parser CACertificateUpdateAction
-> Parser UpdateCACertificateParams
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser CACertificateUpdateAction
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"action")
      )

instance Prelude.Hashable UpdateCACertificateParams

instance Prelude.NFData UpdateCACertificateParams

instance Core.ToJSON UpdateCACertificateParams where
  toJSON :: UpdateCACertificateParams -> Value
toJSON UpdateCACertificateParams' {CACertificateUpdateAction
action :: CACertificateUpdateAction
$sel:action:UpdateCACertificateParams' :: UpdateCACertificateParams -> CACertificateUpdateAction
..} =
    [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
"action" Text -> CACertificateUpdateAction -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= CACertificateUpdateAction
action)]
      )