{-# 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.SMS.Types.ServerGroupValidationConfiguration
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.SMS.Types.ServerGroupValidationConfiguration 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 Amazonka.SMS.Types.ServerValidationConfiguration

-- | Configuration for validating an instance.
--
-- /See:/ 'newServerGroupValidationConfiguration' smart constructor.
data ServerGroupValidationConfiguration = ServerGroupValidationConfiguration'
  { -- | The ID of the server group.
    ServerGroupValidationConfiguration -> Maybe Text
serverGroupId :: Prelude.Maybe Prelude.Text,
    -- | The validation configuration.
    ServerGroupValidationConfiguration
-> Maybe [ServerValidationConfiguration]
serverValidationConfigurations :: Prelude.Maybe [ServerValidationConfiguration]
  }
  deriving (ServerGroupValidationConfiguration
-> ServerGroupValidationConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ServerGroupValidationConfiguration
-> ServerGroupValidationConfiguration -> Bool
$c/= :: ServerGroupValidationConfiguration
-> ServerGroupValidationConfiguration -> Bool
== :: ServerGroupValidationConfiguration
-> ServerGroupValidationConfiguration -> Bool
$c== :: ServerGroupValidationConfiguration
-> ServerGroupValidationConfiguration -> Bool
Prelude.Eq, ReadPrec [ServerGroupValidationConfiguration]
ReadPrec ServerGroupValidationConfiguration
Int -> ReadS ServerGroupValidationConfiguration
ReadS [ServerGroupValidationConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ServerGroupValidationConfiguration]
$creadListPrec :: ReadPrec [ServerGroupValidationConfiguration]
readPrec :: ReadPrec ServerGroupValidationConfiguration
$creadPrec :: ReadPrec ServerGroupValidationConfiguration
readList :: ReadS [ServerGroupValidationConfiguration]
$creadList :: ReadS [ServerGroupValidationConfiguration]
readsPrec :: Int -> ReadS ServerGroupValidationConfiguration
$creadsPrec :: Int -> ReadS ServerGroupValidationConfiguration
Prelude.Read, Int -> ServerGroupValidationConfiguration -> ShowS
[ServerGroupValidationConfiguration] -> ShowS
ServerGroupValidationConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ServerGroupValidationConfiguration] -> ShowS
$cshowList :: [ServerGroupValidationConfiguration] -> ShowS
show :: ServerGroupValidationConfiguration -> String
$cshow :: ServerGroupValidationConfiguration -> String
showsPrec :: Int -> ServerGroupValidationConfiguration -> ShowS
$cshowsPrec :: Int -> ServerGroupValidationConfiguration -> ShowS
Prelude.Show, forall x.
Rep ServerGroupValidationConfiguration x
-> ServerGroupValidationConfiguration
forall x.
ServerGroupValidationConfiguration
-> Rep ServerGroupValidationConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ServerGroupValidationConfiguration x
-> ServerGroupValidationConfiguration
$cfrom :: forall x.
ServerGroupValidationConfiguration
-> Rep ServerGroupValidationConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'ServerGroupValidationConfiguration' 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:
--
-- 'serverGroupId', 'serverGroupValidationConfiguration_serverGroupId' - The ID of the server group.
--
-- 'serverValidationConfigurations', 'serverGroupValidationConfiguration_serverValidationConfigurations' - The validation configuration.
newServerGroupValidationConfiguration ::
  ServerGroupValidationConfiguration
newServerGroupValidationConfiguration :: ServerGroupValidationConfiguration
newServerGroupValidationConfiguration =
  ServerGroupValidationConfiguration'
    { $sel:serverGroupId:ServerGroupValidationConfiguration' :: Maybe Text
serverGroupId =
        forall a. Maybe a
Prelude.Nothing,
      $sel:serverValidationConfigurations:ServerGroupValidationConfiguration' :: Maybe [ServerValidationConfiguration]
serverValidationConfigurations =
        forall a. Maybe a
Prelude.Nothing
    }

-- | The ID of the server group.
serverGroupValidationConfiguration_serverGroupId :: Lens.Lens' ServerGroupValidationConfiguration (Prelude.Maybe Prelude.Text)
serverGroupValidationConfiguration_serverGroupId :: Lens' ServerGroupValidationConfiguration (Maybe Text)
serverGroupValidationConfiguration_serverGroupId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServerGroupValidationConfiguration' {Maybe Text
serverGroupId :: Maybe Text
$sel:serverGroupId:ServerGroupValidationConfiguration' :: ServerGroupValidationConfiguration -> Maybe Text
serverGroupId} -> Maybe Text
serverGroupId) (\s :: ServerGroupValidationConfiguration
s@ServerGroupValidationConfiguration' {} Maybe Text
a -> ServerGroupValidationConfiguration
s {$sel:serverGroupId:ServerGroupValidationConfiguration' :: Maybe Text
serverGroupId = Maybe Text
a} :: ServerGroupValidationConfiguration)

-- | The validation configuration.
serverGroupValidationConfiguration_serverValidationConfigurations :: Lens.Lens' ServerGroupValidationConfiguration (Prelude.Maybe [ServerValidationConfiguration])
serverGroupValidationConfiguration_serverValidationConfigurations :: Lens'
  ServerGroupValidationConfiguration
  (Maybe [ServerValidationConfiguration])
serverGroupValidationConfiguration_serverValidationConfigurations = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServerGroupValidationConfiguration' {Maybe [ServerValidationConfiguration]
serverValidationConfigurations :: Maybe [ServerValidationConfiguration]
$sel:serverValidationConfigurations:ServerGroupValidationConfiguration' :: ServerGroupValidationConfiguration
-> Maybe [ServerValidationConfiguration]
serverValidationConfigurations} -> Maybe [ServerValidationConfiguration]
serverValidationConfigurations) (\s :: ServerGroupValidationConfiguration
s@ServerGroupValidationConfiguration' {} Maybe [ServerValidationConfiguration]
a -> ServerGroupValidationConfiguration
s {$sel:serverValidationConfigurations:ServerGroupValidationConfiguration' :: Maybe [ServerValidationConfiguration]
serverValidationConfigurations = Maybe [ServerValidationConfiguration]
a} :: ServerGroupValidationConfiguration) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance
  Data.FromJSON
    ServerGroupValidationConfiguration
  where
  parseJSON :: Value -> Parser ServerGroupValidationConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ServerGroupValidationConfiguration"
      ( \Object
x ->
          Maybe Text
-> Maybe [ServerValidationConfiguration]
-> ServerGroupValidationConfiguration
ServerGroupValidationConfiguration'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"serverGroupId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x
                            forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"serverValidationConfigurations"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance
  Prelude.Hashable
    ServerGroupValidationConfiguration
  where
  hashWithSalt :: Int -> ServerGroupValidationConfiguration -> Int
hashWithSalt
    Int
_salt
    ServerGroupValidationConfiguration' {Maybe [ServerValidationConfiguration]
Maybe Text
serverValidationConfigurations :: Maybe [ServerValidationConfiguration]
serverGroupId :: Maybe Text
$sel:serverValidationConfigurations:ServerGroupValidationConfiguration' :: ServerGroupValidationConfiguration
-> Maybe [ServerValidationConfiguration]
$sel:serverGroupId:ServerGroupValidationConfiguration' :: ServerGroupValidationConfiguration -> Maybe Text
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
serverGroupId
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [ServerValidationConfiguration]
serverValidationConfigurations

instance
  Prelude.NFData
    ServerGroupValidationConfiguration
  where
  rnf :: ServerGroupValidationConfiguration -> ()
rnf ServerGroupValidationConfiguration' {Maybe [ServerValidationConfiguration]
Maybe Text
serverValidationConfigurations :: Maybe [ServerValidationConfiguration]
serverGroupId :: Maybe Text
$sel:serverValidationConfigurations:ServerGroupValidationConfiguration' :: ServerGroupValidationConfiguration
-> Maybe [ServerValidationConfiguration]
$sel:serverGroupId:ServerGroupValidationConfiguration' :: ServerGroupValidationConfiguration -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
serverGroupId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [ServerValidationConfiguration]
serverValidationConfigurations

instance
  Data.ToJSON
    ServerGroupValidationConfiguration
  where
  toJSON :: ServerGroupValidationConfiguration -> Value
toJSON ServerGroupValidationConfiguration' {Maybe [ServerValidationConfiguration]
Maybe Text
serverValidationConfigurations :: Maybe [ServerValidationConfiguration]
serverGroupId :: Maybe Text
$sel:serverValidationConfigurations:ServerGroupValidationConfiguration' :: ServerGroupValidationConfiguration
-> Maybe [ServerValidationConfiguration]
$sel:serverGroupId:ServerGroupValidationConfiguration' :: ServerGroupValidationConfiguration -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"serverGroupId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
serverGroupId,
            (Key
"serverValidationConfigurations" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [ServerValidationConfiguration]
serverValidationConfigurations
          ]
      )