{-# 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.PrivateIpAddressSpecification
-- 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.PrivateIpAddressSpecification 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 qualified Amazonka.Prelude as Prelude

-- | Describes a secondary private IPv4 address for a network interface.
--
-- /See:/ 'newPrivateIpAddressSpecification' smart constructor.
data PrivateIpAddressSpecification = PrivateIpAddressSpecification'
  { -- | Indicates whether the private IPv4 address is the primary private IPv4
    -- address. Only one IPv4 address can be designated as primary.
    PrivateIpAddressSpecification -> Maybe Bool
primary :: Prelude.Maybe Prelude.Bool,
    -- | The private IPv4 address.
    PrivateIpAddressSpecification -> Maybe Text
privateIpAddress :: Prelude.Maybe Prelude.Text
  }
  deriving (PrivateIpAddressSpecification
-> PrivateIpAddressSpecification -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PrivateIpAddressSpecification
-> PrivateIpAddressSpecification -> Bool
$c/= :: PrivateIpAddressSpecification
-> PrivateIpAddressSpecification -> Bool
== :: PrivateIpAddressSpecification
-> PrivateIpAddressSpecification -> Bool
$c== :: PrivateIpAddressSpecification
-> PrivateIpAddressSpecification -> Bool
Prelude.Eq, ReadPrec [PrivateIpAddressSpecification]
ReadPrec PrivateIpAddressSpecification
Int -> ReadS PrivateIpAddressSpecification
ReadS [PrivateIpAddressSpecification]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PrivateIpAddressSpecification]
$creadListPrec :: ReadPrec [PrivateIpAddressSpecification]
readPrec :: ReadPrec PrivateIpAddressSpecification
$creadPrec :: ReadPrec PrivateIpAddressSpecification
readList :: ReadS [PrivateIpAddressSpecification]
$creadList :: ReadS [PrivateIpAddressSpecification]
readsPrec :: Int -> ReadS PrivateIpAddressSpecification
$creadsPrec :: Int -> ReadS PrivateIpAddressSpecification
Prelude.Read, Int -> PrivateIpAddressSpecification -> ShowS
[PrivateIpAddressSpecification] -> ShowS
PrivateIpAddressSpecification -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PrivateIpAddressSpecification] -> ShowS
$cshowList :: [PrivateIpAddressSpecification] -> ShowS
show :: PrivateIpAddressSpecification -> String
$cshow :: PrivateIpAddressSpecification -> String
showsPrec :: Int -> PrivateIpAddressSpecification -> ShowS
$cshowsPrec :: Int -> PrivateIpAddressSpecification -> ShowS
Prelude.Show, forall x.
Rep PrivateIpAddressSpecification x
-> PrivateIpAddressSpecification
forall x.
PrivateIpAddressSpecification
-> Rep PrivateIpAddressSpecification x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PrivateIpAddressSpecification x
-> PrivateIpAddressSpecification
$cfrom :: forall x.
PrivateIpAddressSpecification
-> Rep PrivateIpAddressSpecification x
Prelude.Generic)

-- |
-- Create a value of 'PrivateIpAddressSpecification' 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:
--
-- 'primary', 'privateIpAddressSpecification_primary' - Indicates whether the private IPv4 address is the primary private IPv4
-- address. Only one IPv4 address can be designated as primary.
--
-- 'privateIpAddress', 'privateIpAddressSpecification_privateIpAddress' - The private IPv4 address.
newPrivateIpAddressSpecification ::
  PrivateIpAddressSpecification
newPrivateIpAddressSpecification :: PrivateIpAddressSpecification
newPrivateIpAddressSpecification =
  PrivateIpAddressSpecification'
    { $sel:primary:PrivateIpAddressSpecification' :: Maybe Bool
primary =
        forall a. Maybe a
Prelude.Nothing,
      $sel:privateIpAddress:PrivateIpAddressSpecification' :: Maybe Text
privateIpAddress = forall a. Maybe a
Prelude.Nothing
    }

-- | Indicates whether the private IPv4 address is the primary private IPv4
-- address. Only one IPv4 address can be designated as primary.
privateIpAddressSpecification_primary :: Lens.Lens' PrivateIpAddressSpecification (Prelude.Maybe Prelude.Bool)
privateIpAddressSpecification_primary :: Lens' PrivateIpAddressSpecification (Maybe Bool)
privateIpAddressSpecification_primary = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PrivateIpAddressSpecification' {Maybe Bool
primary :: Maybe Bool
$sel:primary:PrivateIpAddressSpecification' :: PrivateIpAddressSpecification -> Maybe Bool
primary} -> Maybe Bool
primary) (\s :: PrivateIpAddressSpecification
s@PrivateIpAddressSpecification' {} Maybe Bool
a -> PrivateIpAddressSpecification
s {$sel:primary:PrivateIpAddressSpecification' :: Maybe Bool
primary = Maybe Bool
a} :: PrivateIpAddressSpecification)

-- | The private IPv4 address.
privateIpAddressSpecification_privateIpAddress :: Lens.Lens' PrivateIpAddressSpecification (Prelude.Maybe Prelude.Text)
privateIpAddressSpecification_privateIpAddress :: Lens' PrivateIpAddressSpecification (Maybe Text)
privateIpAddressSpecification_privateIpAddress = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PrivateIpAddressSpecification' {Maybe Text
privateIpAddress :: Maybe Text
$sel:privateIpAddress:PrivateIpAddressSpecification' :: PrivateIpAddressSpecification -> Maybe Text
privateIpAddress} -> Maybe Text
privateIpAddress) (\s :: PrivateIpAddressSpecification
s@PrivateIpAddressSpecification' {} Maybe Text
a -> PrivateIpAddressSpecification
s {$sel:privateIpAddress:PrivateIpAddressSpecification' :: Maybe Text
privateIpAddress = Maybe Text
a} :: PrivateIpAddressSpecification)

instance Data.FromXML PrivateIpAddressSpecification where
  parseXML :: [Node] -> Either String PrivateIpAddressSpecification
parseXML [Node]
x =
    Maybe Bool -> Maybe Text -> PrivateIpAddressSpecification
PrivateIpAddressSpecification'
      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
"primary")
      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
"privateIpAddress")

instance
  Prelude.Hashable
    PrivateIpAddressSpecification
  where
  hashWithSalt :: Int -> PrivateIpAddressSpecification -> Int
hashWithSalt Int
_salt PrivateIpAddressSpecification' {Maybe Bool
Maybe Text
privateIpAddress :: Maybe Text
primary :: Maybe Bool
$sel:privateIpAddress:PrivateIpAddressSpecification' :: PrivateIpAddressSpecification -> Maybe Text
$sel:primary:PrivateIpAddressSpecification' :: PrivateIpAddressSpecification -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
primary
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
privateIpAddress

instance Prelude.NFData PrivateIpAddressSpecification where
  rnf :: PrivateIpAddressSpecification -> ()
rnf PrivateIpAddressSpecification' {Maybe Bool
Maybe Text
privateIpAddress :: Maybe Text
primary :: Maybe Bool
$sel:privateIpAddress:PrivateIpAddressSpecification' :: PrivateIpAddressSpecification -> Maybe Text
$sel:primary:PrivateIpAddressSpecification' :: PrivateIpAddressSpecification -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
primary
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
privateIpAddress

instance Data.ToQuery PrivateIpAddressSpecification where
  toQuery :: PrivateIpAddressSpecification -> QueryString
toQuery PrivateIpAddressSpecification' {Maybe Bool
Maybe Text
privateIpAddress :: Maybe Text
primary :: Maybe Bool
$sel:privateIpAddress:PrivateIpAddressSpecification' :: PrivateIpAddressSpecification -> Maybe Text
$sel:primary:PrivateIpAddressSpecification' :: PrivateIpAddressSpecification -> Maybe Bool
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Primary" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Bool
primary,
        ByteString
"PrivateIpAddress" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
privateIpAddress
      ]