{-# 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-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.SMS.Types.ServerGroupValidationConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SMS.Types.ServerValidationConfiguration

-- | Configuration for validating an instance.
--
-- /See:/ 'newServerGroupValidationConfiguration' smart constructor.
data ServerGroupValidationConfiguration = ServerGroupValidationConfiguration'
  { -- | The validation configuration.
    ServerGroupValidationConfiguration
-> Maybe [ServerValidationConfiguration]
serverValidationConfigurations :: Prelude.Maybe [ServerValidationConfiguration],
    -- | The ID of the server group.
    ServerGroupValidationConfiguration -> Maybe Text
serverGroupId :: Prelude.Maybe Prelude.Text
  }
  deriving (ServerGroupValidationConfiguration
-> ServerGroupValidationConfiguration -> Bool
(ServerGroupValidationConfiguration
 -> ServerGroupValidationConfiguration -> Bool)
-> (ServerGroupValidationConfiguration
    -> ServerGroupValidationConfiguration -> Bool)
-> Eq ServerGroupValidationConfiguration
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]
(Int -> ReadS ServerGroupValidationConfiguration)
-> ReadS [ServerGroupValidationConfiguration]
-> ReadPrec ServerGroupValidationConfiguration
-> ReadPrec [ServerGroupValidationConfiguration]
-> Read 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
(Int -> ServerGroupValidationConfiguration -> ShowS)
-> (ServerGroupValidationConfiguration -> String)
-> ([ServerGroupValidationConfiguration] -> ShowS)
-> Show ServerGroupValidationConfiguration
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.
 ServerGroupValidationConfiguration
 -> Rep ServerGroupValidationConfiguration x)
-> (forall x.
    Rep ServerGroupValidationConfiguration x
    -> ServerGroupValidationConfiguration)
-> Generic ServerGroupValidationConfiguration
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:
--
-- 'serverValidationConfigurations', 'serverGroupValidationConfiguration_serverValidationConfigurations' - The validation configuration.
--
-- 'serverGroupId', 'serverGroupValidationConfiguration_serverGroupId' - The ID of the server group.
newServerGroupValidationConfiguration ::
  ServerGroupValidationConfiguration
newServerGroupValidationConfiguration :: ServerGroupValidationConfiguration
newServerGroupValidationConfiguration =
  ServerGroupValidationConfiguration' :: Maybe [ServerValidationConfiguration]
-> Maybe Text -> ServerGroupValidationConfiguration
ServerGroupValidationConfiguration'
    { $sel:serverValidationConfigurations:ServerGroupValidationConfiguration' :: Maybe [ServerValidationConfiguration]
serverValidationConfigurations =
        Maybe [ServerValidationConfiguration]
forall a. Maybe a
Prelude.Nothing,
      $sel:serverGroupId:ServerGroupValidationConfiguration' :: Maybe Text
serverGroupId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The validation configuration.
serverGroupValidationConfiguration_serverValidationConfigurations :: Lens.Lens' ServerGroupValidationConfiguration (Prelude.Maybe [ServerValidationConfiguration])
serverGroupValidationConfiguration_serverValidationConfigurations :: (Maybe [ServerValidationConfiguration]
 -> f (Maybe [ServerValidationConfiguration]))
-> ServerGroupValidationConfiguration
-> f ServerGroupValidationConfiguration
serverGroupValidationConfiguration_serverValidationConfigurations = (ServerGroupValidationConfiguration
 -> Maybe [ServerValidationConfiguration])
-> (ServerGroupValidationConfiguration
    -> Maybe [ServerValidationConfiguration]
    -> ServerGroupValidationConfiguration)
-> Lens
     ServerGroupValidationConfiguration
     ServerGroupValidationConfiguration
     (Maybe [ServerValidationConfiguration])
     (Maybe [ServerValidationConfiguration])
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) ((Maybe [ServerValidationConfiguration]
  -> f (Maybe [ServerValidationConfiguration]))
 -> ServerGroupValidationConfiguration
 -> f ServerGroupValidationConfiguration)
-> ((Maybe [ServerValidationConfiguration]
     -> f (Maybe [ServerValidationConfiguration]))
    -> Maybe [ServerValidationConfiguration]
    -> f (Maybe [ServerValidationConfiguration]))
-> (Maybe [ServerValidationConfiguration]
    -> f (Maybe [ServerValidationConfiguration]))
-> ServerGroupValidationConfiguration
-> f ServerGroupValidationConfiguration
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ServerValidationConfiguration]
  [ServerValidationConfiguration]
  [ServerValidationConfiguration]
  [ServerValidationConfiguration]
-> Iso
     (Maybe [ServerValidationConfiguration])
     (Maybe [ServerValidationConfiguration])
     (Maybe [ServerValidationConfiguration])
     (Maybe [ServerValidationConfiguration])
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 AnIso
  [ServerValidationConfiguration]
  [ServerValidationConfiguration]
  [ServerValidationConfiguration]
  [ServerValidationConfiguration]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The ID of the server group.
serverGroupValidationConfiguration_serverGroupId :: Lens.Lens' ServerGroupValidationConfiguration (Prelude.Maybe Prelude.Text)
serverGroupValidationConfiguration_serverGroupId :: (Maybe Text -> f (Maybe Text))
-> ServerGroupValidationConfiguration
-> f ServerGroupValidationConfiguration
serverGroupValidationConfiguration_serverGroupId = (ServerGroupValidationConfiguration -> Maybe Text)
-> (ServerGroupValidationConfiguration
    -> Maybe Text -> ServerGroupValidationConfiguration)
-> Lens
     ServerGroupValidationConfiguration
     ServerGroupValidationConfiguration
     (Maybe Text)
     (Maybe Text)
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)

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

instance
  Prelude.Hashable
    ServerGroupValidationConfiguration

instance
  Prelude.NFData
    ServerGroupValidationConfiguration

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