{-# 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.OpsWorks.Types.ElasticIp
-- 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.OpsWorks.Types.ElasticIp where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes an Elastic IP address.
--
-- /See:/ 'newElasticIp' smart constructor.
data ElasticIp = ElasticIp'
  { -- | The ID of the instance that the address is attached to.
    ElasticIp -> Maybe Text
instanceId :: Prelude.Maybe Prelude.Text,
    -- | The domain.
    ElasticIp -> Maybe Text
domain :: Prelude.Maybe Prelude.Text,
    -- | The IP address.
    ElasticIp -> Maybe Text
ip :: Prelude.Maybe Prelude.Text,
    -- | The name.
    ElasticIp -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The AWS region. For more information, see
    -- <https://docs.aws.amazon.com/general/latest/gr/rande.html Regions and Endpoints>.
    ElasticIp -> Maybe Text
region :: Prelude.Maybe Prelude.Text
  }
  deriving (ElasticIp -> ElasticIp -> Bool
(ElasticIp -> ElasticIp -> Bool)
-> (ElasticIp -> ElasticIp -> Bool) -> Eq ElasticIp
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ElasticIp -> ElasticIp -> Bool
$c/= :: ElasticIp -> ElasticIp -> Bool
== :: ElasticIp -> ElasticIp -> Bool
$c== :: ElasticIp -> ElasticIp -> Bool
Prelude.Eq, ReadPrec [ElasticIp]
ReadPrec ElasticIp
Int -> ReadS ElasticIp
ReadS [ElasticIp]
(Int -> ReadS ElasticIp)
-> ReadS [ElasticIp]
-> ReadPrec ElasticIp
-> ReadPrec [ElasticIp]
-> Read ElasticIp
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ElasticIp]
$creadListPrec :: ReadPrec [ElasticIp]
readPrec :: ReadPrec ElasticIp
$creadPrec :: ReadPrec ElasticIp
readList :: ReadS [ElasticIp]
$creadList :: ReadS [ElasticIp]
readsPrec :: Int -> ReadS ElasticIp
$creadsPrec :: Int -> ReadS ElasticIp
Prelude.Read, Int -> ElasticIp -> ShowS
[ElasticIp] -> ShowS
ElasticIp -> String
(Int -> ElasticIp -> ShowS)
-> (ElasticIp -> String)
-> ([ElasticIp] -> ShowS)
-> Show ElasticIp
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ElasticIp] -> ShowS
$cshowList :: [ElasticIp] -> ShowS
show :: ElasticIp -> String
$cshow :: ElasticIp -> String
showsPrec :: Int -> ElasticIp -> ShowS
$cshowsPrec :: Int -> ElasticIp -> ShowS
Prelude.Show, (forall x. ElasticIp -> Rep ElasticIp x)
-> (forall x. Rep ElasticIp x -> ElasticIp) -> Generic ElasticIp
forall x. Rep ElasticIp x -> ElasticIp
forall x. ElasticIp -> Rep ElasticIp x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ElasticIp x -> ElasticIp
$cfrom :: forall x. ElasticIp -> Rep ElasticIp x
Prelude.Generic)

-- |
-- Create a value of 'ElasticIp' 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:
--
-- 'instanceId', 'elasticIp_instanceId' - The ID of the instance that the address is attached to.
--
-- 'domain', 'elasticIp_domain' - The domain.
--
-- 'ip', 'elasticIp_ip' - The IP address.
--
-- 'name', 'elasticIp_name' - The name.
--
-- 'region', 'elasticIp_region' - The AWS region. For more information, see
-- <https://docs.aws.amazon.com/general/latest/gr/rande.html Regions and Endpoints>.
newElasticIp ::
  ElasticIp
newElasticIp :: ElasticIp
newElasticIp =
  ElasticIp' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> ElasticIp
ElasticIp'
    { $sel:instanceId:ElasticIp' :: Maybe Text
instanceId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:domain:ElasticIp' :: Maybe Text
domain = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:ip:ElasticIp' :: Maybe Text
ip = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:ElasticIp' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:region:ElasticIp' :: Maybe Text
region = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The ID of the instance that the address is attached to.
elasticIp_instanceId :: Lens.Lens' ElasticIp (Prelude.Maybe Prelude.Text)
elasticIp_instanceId :: (Maybe Text -> f (Maybe Text)) -> ElasticIp -> f ElasticIp
elasticIp_instanceId = (ElasticIp -> Maybe Text)
-> (ElasticIp -> Maybe Text -> ElasticIp)
-> Lens ElasticIp ElasticIp (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ElasticIp' {Maybe Text
instanceId :: Maybe Text
$sel:instanceId:ElasticIp' :: ElasticIp -> Maybe Text
instanceId} -> Maybe Text
instanceId) (\s :: ElasticIp
s@ElasticIp' {} Maybe Text
a -> ElasticIp
s {$sel:instanceId:ElasticIp' :: Maybe Text
instanceId = Maybe Text
a} :: ElasticIp)

-- | The domain.
elasticIp_domain :: Lens.Lens' ElasticIp (Prelude.Maybe Prelude.Text)
elasticIp_domain :: (Maybe Text -> f (Maybe Text)) -> ElasticIp -> f ElasticIp
elasticIp_domain = (ElasticIp -> Maybe Text)
-> (ElasticIp -> Maybe Text -> ElasticIp)
-> Lens ElasticIp ElasticIp (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ElasticIp' {Maybe Text
domain :: Maybe Text
$sel:domain:ElasticIp' :: ElasticIp -> Maybe Text
domain} -> Maybe Text
domain) (\s :: ElasticIp
s@ElasticIp' {} Maybe Text
a -> ElasticIp
s {$sel:domain:ElasticIp' :: Maybe Text
domain = Maybe Text
a} :: ElasticIp)

-- | The IP address.
elasticIp_ip :: Lens.Lens' ElasticIp (Prelude.Maybe Prelude.Text)
elasticIp_ip :: (Maybe Text -> f (Maybe Text)) -> ElasticIp -> f ElasticIp
elasticIp_ip = (ElasticIp -> Maybe Text)
-> (ElasticIp -> Maybe Text -> ElasticIp)
-> Lens ElasticIp ElasticIp (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ElasticIp' {Maybe Text
ip :: Maybe Text
$sel:ip:ElasticIp' :: ElasticIp -> Maybe Text
ip} -> Maybe Text
ip) (\s :: ElasticIp
s@ElasticIp' {} Maybe Text
a -> ElasticIp
s {$sel:ip:ElasticIp' :: Maybe Text
ip = Maybe Text
a} :: ElasticIp)

-- | The name.
elasticIp_name :: Lens.Lens' ElasticIp (Prelude.Maybe Prelude.Text)
elasticIp_name :: (Maybe Text -> f (Maybe Text)) -> ElasticIp -> f ElasticIp
elasticIp_name = (ElasticIp -> Maybe Text)
-> (ElasticIp -> Maybe Text -> ElasticIp)
-> Lens ElasticIp ElasticIp (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ElasticIp' {Maybe Text
name :: Maybe Text
$sel:name:ElasticIp' :: ElasticIp -> Maybe Text
name} -> Maybe Text
name) (\s :: ElasticIp
s@ElasticIp' {} Maybe Text
a -> ElasticIp
s {$sel:name:ElasticIp' :: Maybe Text
name = Maybe Text
a} :: ElasticIp)

-- | The AWS region. For more information, see
-- <https://docs.aws.amazon.com/general/latest/gr/rande.html Regions and Endpoints>.
elasticIp_region :: Lens.Lens' ElasticIp (Prelude.Maybe Prelude.Text)
elasticIp_region :: (Maybe Text -> f (Maybe Text)) -> ElasticIp -> f ElasticIp
elasticIp_region = (ElasticIp -> Maybe Text)
-> (ElasticIp -> Maybe Text -> ElasticIp)
-> Lens ElasticIp ElasticIp (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ElasticIp' {Maybe Text
region :: Maybe Text
$sel:region:ElasticIp' :: ElasticIp -> Maybe Text
region} -> Maybe Text
region) (\s :: ElasticIp
s@ElasticIp' {} Maybe Text
a -> ElasticIp
s {$sel:region:ElasticIp' :: Maybe Text
region = Maybe Text
a} :: ElasticIp)

instance Core.FromJSON ElasticIp where
  parseJSON :: Value -> Parser ElasticIp
parseJSON =
    String -> (Object -> Parser ElasticIp) -> Value -> Parser ElasticIp
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ElasticIp"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> ElasticIp
ElasticIp'
            (Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> ElasticIp)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe Text -> Maybe Text -> Maybe Text -> ElasticIp)
forall (f :: * -> *) a b. Functor 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
"InstanceId")
            Parser
  (Maybe Text -> Maybe Text -> Maybe Text -> Maybe Text -> ElasticIp)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> Maybe Text -> ElasticIp)
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
"Domain")
            Parser (Maybe Text -> Maybe Text -> Maybe Text -> ElasticIp)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> ElasticIp)
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
"Ip")
            Parser (Maybe Text -> Maybe Text -> ElasticIp)
-> Parser (Maybe Text) -> Parser (Maybe Text -> ElasticIp)
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
"Name")
            Parser (Maybe Text -> ElasticIp)
-> Parser (Maybe Text) -> Parser ElasticIp
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
"Region")
      )

instance Prelude.Hashable ElasticIp

instance Prelude.NFData ElasticIp