{-# 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.UpdateDeviceCertificateParams
-- 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.UpdateDeviceCertificateParams where

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

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

-- |
-- Create a value of 'UpdateDeviceCertificateParams' 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', 'updateDeviceCertificateParams_action' - The action that you want to apply to the device certificate. The only
-- supported value is @DEACTIVATE@.
newUpdateDeviceCertificateParams ::
  -- | 'action'
  DeviceCertificateUpdateAction ->
  UpdateDeviceCertificateParams
newUpdateDeviceCertificateParams :: DeviceCertificateUpdateAction -> UpdateDeviceCertificateParams
newUpdateDeviceCertificateParams DeviceCertificateUpdateAction
pAction_ =
  UpdateDeviceCertificateParams' :: DeviceCertificateUpdateAction -> UpdateDeviceCertificateParams
UpdateDeviceCertificateParams' {$sel:action:UpdateDeviceCertificateParams' :: DeviceCertificateUpdateAction
action = DeviceCertificateUpdateAction
pAction_}

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

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

instance
  Prelude.Hashable
    UpdateDeviceCertificateParams

instance Prelude.NFData UpdateDeviceCertificateParams

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