{-# 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.IoTWireless.Types.Ip
-- 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.IoTWireless.Types.Ip 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

-- | IP address used for resolving device location.
--
-- /See:/ 'newIp' smart constructor.
data Ip = Ip'
  { -- | IP address information.
    Ip -> Text
ipAddress :: Prelude.Text
  }
  deriving (Ip -> Ip -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Ip -> Ip -> Bool
$c/= :: Ip -> Ip -> Bool
== :: Ip -> Ip -> Bool
$c== :: Ip -> Ip -> Bool
Prelude.Eq, ReadPrec [Ip]
ReadPrec Ip
Int -> ReadS Ip
ReadS [Ip]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Ip]
$creadListPrec :: ReadPrec [Ip]
readPrec :: ReadPrec Ip
$creadPrec :: ReadPrec Ip
readList :: ReadS [Ip]
$creadList :: ReadS [Ip]
readsPrec :: Int -> ReadS Ip
$creadsPrec :: Int -> ReadS Ip
Prelude.Read, Int -> Ip -> ShowS
[Ip] -> ShowS
Ip -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Ip] -> ShowS
$cshowList :: [Ip] -> ShowS
show :: Ip -> String
$cshow :: Ip -> String
showsPrec :: Int -> Ip -> ShowS
$cshowsPrec :: Int -> Ip -> ShowS
Prelude.Show, forall x. Rep Ip x -> Ip
forall x. Ip -> Rep Ip x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Ip x -> Ip
$cfrom :: forall x. Ip -> Rep Ip x
Prelude.Generic)

-- |
-- Create a value of 'Ip' 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:
--
-- 'ipAddress', 'ip_ipAddress' - IP address information.
newIp ::
  -- | 'ipAddress'
  Prelude.Text ->
  Ip
newIp :: Text -> Ip
newIp Text
pIpAddress_ = Ip' {$sel:ipAddress:Ip' :: Text
ipAddress = Text
pIpAddress_}

-- | IP address information.
ip_ipAddress :: Lens.Lens' Ip Prelude.Text
ip_ipAddress :: Lens' Ip Text
ip_ipAddress = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Ip' {Text
ipAddress :: Text
$sel:ipAddress:Ip' :: Ip -> Text
ipAddress} -> Text
ipAddress) (\s :: Ip
s@Ip' {} Text
a -> Ip
s {$sel:ipAddress:Ip' :: Text
ipAddress = Text
a} :: Ip)

instance Prelude.Hashable Ip where
  hashWithSalt :: Int -> Ip -> Int
hashWithSalt Int
_salt Ip' {Text
ipAddress :: Text
$sel:ipAddress:Ip' :: Ip -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
ipAddress

instance Prelude.NFData Ip where
  rnf :: Ip -> ()
rnf Ip' {Text
ipAddress :: Text
$sel:ipAddress:Ip' :: Ip -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
ipAddress

instance Data.ToJSON Ip where
  toJSON :: Ip -> Value
toJSON Ip' {Text
ipAddress :: Text
$sel:ipAddress:Ip' :: Ip -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"IpAddress" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
ipAddress)]
      )