{-# 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.EC2.Types.DhcpConfiguration
-- 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.EC2.Types.DhcpConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.EC2.Internal
import Amazonka.EC2.Types.AttributeValue
import qualified Amazonka.Prelude as Prelude

-- | Describes a DHCP configuration option.
--
-- /See:/ 'newDhcpConfiguration' smart constructor.
data DhcpConfiguration = DhcpConfiguration'
  { -- | The name of a DHCP option.
    DhcpConfiguration -> Maybe Text
key :: Prelude.Maybe Prelude.Text,
    -- | One or more values for the DHCP option.
    DhcpConfiguration -> Maybe [AttributeValue]
values :: Prelude.Maybe [AttributeValue]
  }
  deriving (DhcpConfiguration -> DhcpConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DhcpConfiguration -> DhcpConfiguration -> Bool
$c/= :: DhcpConfiguration -> DhcpConfiguration -> Bool
== :: DhcpConfiguration -> DhcpConfiguration -> Bool
$c== :: DhcpConfiguration -> DhcpConfiguration -> Bool
Prelude.Eq, ReadPrec [DhcpConfiguration]
ReadPrec DhcpConfiguration
Int -> ReadS DhcpConfiguration
ReadS [DhcpConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DhcpConfiguration]
$creadListPrec :: ReadPrec [DhcpConfiguration]
readPrec :: ReadPrec DhcpConfiguration
$creadPrec :: ReadPrec DhcpConfiguration
readList :: ReadS [DhcpConfiguration]
$creadList :: ReadS [DhcpConfiguration]
readsPrec :: Int -> ReadS DhcpConfiguration
$creadsPrec :: Int -> ReadS DhcpConfiguration
Prelude.Read, Int -> DhcpConfiguration -> ShowS
[DhcpConfiguration] -> ShowS
DhcpConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DhcpConfiguration] -> ShowS
$cshowList :: [DhcpConfiguration] -> ShowS
show :: DhcpConfiguration -> String
$cshow :: DhcpConfiguration -> String
showsPrec :: Int -> DhcpConfiguration -> ShowS
$cshowsPrec :: Int -> DhcpConfiguration -> ShowS
Prelude.Show, forall x. Rep DhcpConfiguration x -> DhcpConfiguration
forall x. DhcpConfiguration -> Rep DhcpConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DhcpConfiguration x -> DhcpConfiguration
$cfrom :: forall x. DhcpConfiguration -> Rep DhcpConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'DhcpConfiguration' 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:
--
-- 'key', 'dhcpConfiguration_key' - The name of a DHCP option.
--
-- 'values', 'dhcpConfiguration_values' - One or more values for the DHCP option.
newDhcpConfiguration ::
  DhcpConfiguration
newDhcpConfiguration :: DhcpConfiguration
newDhcpConfiguration =
  DhcpConfiguration'
    { $sel:key:DhcpConfiguration' :: Maybe Text
key = forall a. Maybe a
Prelude.Nothing,
      $sel:values:DhcpConfiguration' :: Maybe [AttributeValue]
values = forall a. Maybe a
Prelude.Nothing
    }

-- | The name of a DHCP option.
dhcpConfiguration_key :: Lens.Lens' DhcpConfiguration (Prelude.Maybe Prelude.Text)
dhcpConfiguration_key :: Lens' DhcpConfiguration (Maybe Text)
dhcpConfiguration_key = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DhcpConfiguration' {Maybe Text
key :: Maybe Text
$sel:key:DhcpConfiguration' :: DhcpConfiguration -> Maybe Text
key} -> Maybe Text
key) (\s :: DhcpConfiguration
s@DhcpConfiguration' {} Maybe Text
a -> DhcpConfiguration
s {$sel:key:DhcpConfiguration' :: Maybe Text
key = Maybe Text
a} :: DhcpConfiguration)

-- | One or more values for the DHCP option.
dhcpConfiguration_values :: Lens.Lens' DhcpConfiguration (Prelude.Maybe [AttributeValue])
dhcpConfiguration_values :: Lens' DhcpConfiguration (Maybe [AttributeValue])
dhcpConfiguration_values = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DhcpConfiguration' {Maybe [AttributeValue]
values :: Maybe [AttributeValue]
$sel:values:DhcpConfiguration' :: DhcpConfiguration -> Maybe [AttributeValue]
values} -> Maybe [AttributeValue]
values) (\s :: DhcpConfiguration
s@DhcpConfiguration' {} Maybe [AttributeValue]
a -> DhcpConfiguration
s {$sel:values:DhcpConfiguration' :: Maybe [AttributeValue]
values = Maybe [AttributeValue]
a} :: DhcpConfiguration) 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.FromXML DhcpConfiguration where
  parseXML :: [Node] -> Either String DhcpConfiguration
parseXML [Node]
x =
    Maybe Text -> Maybe [AttributeValue] -> DhcpConfiguration
DhcpConfiguration'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"key")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x
                      forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"valueSet"
                      forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                      forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (forall a. FromXML a => Text -> [Node] -> Either String [a]
Data.parseXMLList Text
"item")
                  )

instance Prelude.Hashable DhcpConfiguration where
  hashWithSalt :: Int -> DhcpConfiguration -> Int
hashWithSalt Int
_salt DhcpConfiguration' {Maybe [AttributeValue]
Maybe Text
values :: Maybe [AttributeValue]
key :: Maybe Text
$sel:values:DhcpConfiguration' :: DhcpConfiguration -> Maybe [AttributeValue]
$sel:key:DhcpConfiguration' :: DhcpConfiguration -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
key
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [AttributeValue]
values

instance Prelude.NFData DhcpConfiguration where
  rnf :: DhcpConfiguration -> ()
rnf DhcpConfiguration' {Maybe [AttributeValue]
Maybe Text
values :: Maybe [AttributeValue]
key :: Maybe Text
$sel:values:DhcpConfiguration' :: DhcpConfiguration -> Maybe [AttributeValue]
$sel:key:DhcpConfiguration' :: DhcpConfiguration -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
key seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [AttributeValue]
values