{-# 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.Config.Types.RemediationExceptionResourceKey
-- 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.Config.Types.RemediationExceptionResourceKey where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The details that identify a resource within Config, including the
-- resource type and resource ID.
--
-- /See:/ 'newRemediationExceptionResourceKey' smart constructor.
data RemediationExceptionResourceKey = RemediationExceptionResourceKey'
  { -- | The ID of the resource (for example., sg-xxxxxx).
    RemediationExceptionResourceKey -> Maybe Text
resourceId :: Prelude.Maybe Prelude.Text,
    -- | The type of a resource.
    RemediationExceptionResourceKey -> Maybe Text
resourceType :: Prelude.Maybe Prelude.Text
  }
  deriving (RemediationExceptionResourceKey
-> RemediationExceptionResourceKey -> Bool
(RemediationExceptionResourceKey
 -> RemediationExceptionResourceKey -> Bool)
-> (RemediationExceptionResourceKey
    -> RemediationExceptionResourceKey -> Bool)
-> Eq RemediationExceptionResourceKey
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RemediationExceptionResourceKey
-> RemediationExceptionResourceKey -> Bool
$c/= :: RemediationExceptionResourceKey
-> RemediationExceptionResourceKey -> Bool
== :: RemediationExceptionResourceKey
-> RemediationExceptionResourceKey -> Bool
$c== :: RemediationExceptionResourceKey
-> RemediationExceptionResourceKey -> Bool
Prelude.Eq, ReadPrec [RemediationExceptionResourceKey]
ReadPrec RemediationExceptionResourceKey
Int -> ReadS RemediationExceptionResourceKey
ReadS [RemediationExceptionResourceKey]
(Int -> ReadS RemediationExceptionResourceKey)
-> ReadS [RemediationExceptionResourceKey]
-> ReadPrec RemediationExceptionResourceKey
-> ReadPrec [RemediationExceptionResourceKey]
-> Read RemediationExceptionResourceKey
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RemediationExceptionResourceKey]
$creadListPrec :: ReadPrec [RemediationExceptionResourceKey]
readPrec :: ReadPrec RemediationExceptionResourceKey
$creadPrec :: ReadPrec RemediationExceptionResourceKey
readList :: ReadS [RemediationExceptionResourceKey]
$creadList :: ReadS [RemediationExceptionResourceKey]
readsPrec :: Int -> ReadS RemediationExceptionResourceKey
$creadsPrec :: Int -> ReadS RemediationExceptionResourceKey
Prelude.Read, Int -> RemediationExceptionResourceKey -> ShowS
[RemediationExceptionResourceKey] -> ShowS
RemediationExceptionResourceKey -> String
(Int -> RemediationExceptionResourceKey -> ShowS)
-> (RemediationExceptionResourceKey -> String)
-> ([RemediationExceptionResourceKey] -> ShowS)
-> Show RemediationExceptionResourceKey
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RemediationExceptionResourceKey] -> ShowS
$cshowList :: [RemediationExceptionResourceKey] -> ShowS
show :: RemediationExceptionResourceKey -> String
$cshow :: RemediationExceptionResourceKey -> String
showsPrec :: Int -> RemediationExceptionResourceKey -> ShowS
$cshowsPrec :: Int -> RemediationExceptionResourceKey -> ShowS
Prelude.Show, (forall x.
 RemediationExceptionResourceKey
 -> Rep RemediationExceptionResourceKey x)
-> (forall x.
    Rep RemediationExceptionResourceKey x
    -> RemediationExceptionResourceKey)
-> Generic RemediationExceptionResourceKey
forall x.
Rep RemediationExceptionResourceKey x
-> RemediationExceptionResourceKey
forall x.
RemediationExceptionResourceKey
-> Rep RemediationExceptionResourceKey x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep RemediationExceptionResourceKey x
-> RemediationExceptionResourceKey
$cfrom :: forall x.
RemediationExceptionResourceKey
-> Rep RemediationExceptionResourceKey x
Prelude.Generic)

-- |
-- Create a value of 'RemediationExceptionResourceKey' 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:
--
-- 'resourceId', 'remediationExceptionResourceKey_resourceId' - The ID of the resource (for example., sg-xxxxxx).
--
-- 'resourceType', 'remediationExceptionResourceKey_resourceType' - The type of a resource.
newRemediationExceptionResourceKey ::
  RemediationExceptionResourceKey
newRemediationExceptionResourceKey :: RemediationExceptionResourceKey
newRemediationExceptionResourceKey =
  RemediationExceptionResourceKey' :: Maybe Text -> Maybe Text -> RemediationExceptionResourceKey
RemediationExceptionResourceKey'
    { $sel:resourceId:RemediationExceptionResourceKey' :: Maybe Text
resourceId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceType:RemediationExceptionResourceKey' :: Maybe Text
resourceType = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The ID of the resource (for example., sg-xxxxxx).
remediationExceptionResourceKey_resourceId :: Lens.Lens' RemediationExceptionResourceKey (Prelude.Maybe Prelude.Text)
remediationExceptionResourceKey_resourceId :: (Maybe Text -> f (Maybe Text))
-> RemediationExceptionResourceKey
-> f RemediationExceptionResourceKey
remediationExceptionResourceKey_resourceId = (RemediationExceptionResourceKey -> Maybe Text)
-> (RemediationExceptionResourceKey
    -> Maybe Text -> RemediationExceptionResourceKey)
-> Lens
     RemediationExceptionResourceKey
     RemediationExceptionResourceKey
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemediationExceptionResourceKey' {Maybe Text
resourceId :: Maybe Text
$sel:resourceId:RemediationExceptionResourceKey' :: RemediationExceptionResourceKey -> Maybe Text
resourceId} -> Maybe Text
resourceId) (\s :: RemediationExceptionResourceKey
s@RemediationExceptionResourceKey' {} Maybe Text
a -> RemediationExceptionResourceKey
s {$sel:resourceId:RemediationExceptionResourceKey' :: Maybe Text
resourceId = Maybe Text
a} :: RemediationExceptionResourceKey)

-- | The type of a resource.
remediationExceptionResourceKey_resourceType :: Lens.Lens' RemediationExceptionResourceKey (Prelude.Maybe Prelude.Text)
remediationExceptionResourceKey_resourceType :: (Maybe Text -> f (Maybe Text))
-> RemediationExceptionResourceKey
-> f RemediationExceptionResourceKey
remediationExceptionResourceKey_resourceType = (RemediationExceptionResourceKey -> Maybe Text)
-> (RemediationExceptionResourceKey
    -> Maybe Text -> RemediationExceptionResourceKey)
-> Lens
     RemediationExceptionResourceKey
     RemediationExceptionResourceKey
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemediationExceptionResourceKey' {Maybe Text
resourceType :: Maybe Text
$sel:resourceType:RemediationExceptionResourceKey' :: RemediationExceptionResourceKey -> Maybe Text
resourceType} -> Maybe Text
resourceType) (\s :: RemediationExceptionResourceKey
s@RemediationExceptionResourceKey' {} Maybe Text
a -> RemediationExceptionResourceKey
s {$sel:resourceType:RemediationExceptionResourceKey' :: Maybe Text
resourceType = Maybe Text
a} :: RemediationExceptionResourceKey)

instance
  Core.FromJSON
    RemediationExceptionResourceKey
  where
  parseJSON :: Value -> Parser RemediationExceptionResourceKey
parseJSON =
    String
-> (Object -> Parser RemediationExceptionResourceKey)
-> Value
-> Parser RemediationExceptionResourceKey
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"RemediationExceptionResourceKey"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> RemediationExceptionResourceKey
RemediationExceptionResourceKey'
            (Maybe Text -> Maybe Text -> RemediationExceptionResourceKey)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> RemediationExceptionResourceKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ResourceId")
            Parser (Maybe Text -> RemediationExceptionResourceKey)
-> Parser (Maybe Text) -> Parser RemediationExceptionResourceKey
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ResourceType")
      )

instance
  Prelude.Hashable
    RemediationExceptionResourceKey

instance
  Prelude.NFData
    RemediationExceptionResourceKey

instance Core.ToJSON RemediationExceptionResourceKey where
  toJSON :: RemediationExceptionResourceKey -> Value
toJSON RemediationExceptionResourceKey' {Maybe Text
resourceType :: Maybe Text
resourceId :: Maybe Text
$sel:resourceType:RemediationExceptionResourceKey' :: RemediationExceptionResourceKey -> Maybe Text
$sel:resourceId:RemediationExceptionResourceKey' :: RemediationExceptionResourceKey -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ResourceId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
resourceId,
            (Text
"ResourceType" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
resourceType
          ]
      )