{-# 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.ElasticSearch.Types.DomainInformation
-- 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.ElasticSearch.Types.DomainInformation where

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

-- | /See:/ 'newDomainInformation' smart constructor.
data DomainInformation = DomainInformation'
  { DomainInformation -> Maybe Text
ownerId :: Prelude.Maybe Prelude.Text,
    DomainInformation -> Maybe Text
region :: Prelude.Maybe Prelude.Text,
    DomainInformation -> Text
domainName :: Prelude.Text
  }
  deriving (DomainInformation -> DomainInformation -> Bool
(DomainInformation -> DomainInformation -> Bool)
-> (DomainInformation -> DomainInformation -> Bool)
-> Eq DomainInformation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DomainInformation -> DomainInformation -> Bool
$c/= :: DomainInformation -> DomainInformation -> Bool
== :: DomainInformation -> DomainInformation -> Bool
$c== :: DomainInformation -> DomainInformation -> Bool
Prelude.Eq, ReadPrec [DomainInformation]
ReadPrec DomainInformation
Int -> ReadS DomainInformation
ReadS [DomainInformation]
(Int -> ReadS DomainInformation)
-> ReadS [DomainInformation]
-> ReadPrec DomainInformation
-> ReadPrec [DomainInformation]
-> Read DomainInformation
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DomainInformation]
$creadListPrec :: ReadPrec [DomainInformation]
readPrec :: ReadPrec DomainInformation
$creadPrec :: ReadPrec DomainInformation
readList :: ReadS [DomainInformation]
$creadList :: ReadS [DomainInformation]
readsPrec :: Int -> ReadS DomainInformation
$creadsPrec :: Int -> ReadS DomainInformation
Prelude.Read, Int -> DomainInformation -> ShowS
[DomainInformation] -> ShowS
DomainInformation -> String
(Int -> DomainInformation -> ShowS)
-> (DomainInformation -> String)
-> ([DomainInformation] -> ShowS)
-> Show DomainInformation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DomainInformation] -> ShowS
$cshowList :: [DomainInformation] -> ShowS
show :: DomainInformation -> String
$cshow :: DomainInformation -> String
showsPrec :: Int -> DomainInformation -> ShowS
$cshowsPrec :: Int -> DomainInformation -> ShowS
Prelude.Show, (forall x. DomainInformation -> Rep DomainInformation x)
-> (forall x. Rep DomainInformation x -> DomainInformation)
-> Generic DomainInformation
forall x. Rep DomainInformation x -> DomainInformation
forall x. DomainInformation -> Rep DomainInformation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DomainInformation x -> DomainInformation
$cfrom :: forall x. DomainInformation -> Rep DomainInformation x
Prelude.Generic)

-- |
-- Create a value of 'DomainInformation' 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:
--
-- 'ownerId', 'domainInformation_ownerId' - Undocumented member.
--
-- 'region', 'domainInformation_region' - Undocumented member.
--
-- 'domainName', 'domainInformation_domainName' - Undocumented member.
newDomainInformation ::
  -- | 'domainName'
  Prelude.Text ->
  DomainInformation
newDomainInformation :: Text -> DomainInformation
newDomainInformation Text
pDomainName_ =
  DomainInformation' :: Maybe Text -> Maybe Text -> Text -> DomainInformation
DomainInformation'
    { $sel:ownerId:DomainInformation' :: Maybe Text
ownerId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:region:DomainInformation' :: Maybe Text
region = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:domainName:DomainInformation' :: Text
domainName = Text
pDomainName_
    }

-- | Undocumented member.
domainInformation_ownerId :: Lens.Lens' DomainInformation (Prelude.Maybe Prelude.Text)
domainInformation_ownerId :: (Maybe Text -> f (Maybe Text))
-> DomainInformation -> f DomainInformation
domainInformation_ownerId = (DomainInformation -> Maybe Text)
-> (DomainInformation -> Maybe Text -> DomainInformation)
-> Lens
     DomainInformation DomainInformation (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DomainInformation' {Maybe Text
ownerId :: Maybe Text
$sel:ownerId:DomainInformation' :: DomainInformation -> Maybe Text
ownerId} -> Maybe Text
ownerId) (\s :: DomainInformation
s@DomainInformation' {} Maybe Text
a -> DomainInformation
s {$sel:ownerId:DomainInformation' :: Maybe Text
ownerId = Maybe Text
a} :: DomainInformation)

-- | Undocumented member.
domainInformation_region :: Lens.Lens' DomainInformation (Prelude.Maybe Prelude.Text)
domainInformation_region :: (Maybe Text -> f (Maybe Text))
-> DomainInformation -> f DomainInformation
domainInformation_region = (DomainInformation -> Maybe Text)
-> (DomainInformation -> Maybe Text -> DomainInformation)
-> Lens
     DomainInformation DomainInformation (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DomainInformation' {Maybe Text
region :: Maybe Text
$sel:region:DomainInformation' :: DomainInformation -> Maybe Text
region} -> Maybe Text
region) (\s :: DomainInformation
s@DomainInformation' {} Maybe Text
a -> DomainInformation
s {$sel:region:DomainInformation' :: Maybe Text
region = Maybe Text
a} :: DomainInformation)

-- | Undocumented member.
domainInformation_domainName :: Lens.Lens' DomainInformation Prelude.Text
domainInformation_domainName :: (Text -> f Text) -> DomainInformation -> f DomainInformation
domainInformation_domainName = (DomainInformation -> Text)
-> (DomainInformation -> Text -> DomainInformation)
-> Lens DomainInformation DomainInformation Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DomainInformation' {Text
domainName :: Text
$sel:domainName:DomainInformation' :: DomainInformation -> Text
domainName} -> Text
domainName) (\s :: DomainInformation
s@DomainInformation' {} Text
a -> DomainInformation
s {$sel:domainName:DomainInformation' :: Text
domainName = Text
a} :: DomainInformation)

instance Core.FromJSON DomainInformation where
  parseJSON :: Value -> Parser DomainInformation
parseJSON =
    String
-> (Object -> Parser DomainInformation)
-> Value
-> Parser DomainInformation
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DomainInformation"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Text -> DomainInformation
DomainInformation'
            (Maybe Text -> Maybe Text -> Text -> DomainInformation)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Text -> DomainInformation)
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
"OwnerId")
            Parser (Maybe Text -> Text -> DomainInformation)
-> Parser (Maybe Text) -> Parser (Text -> DomainInformation)
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")
            Parser (Text -> DomainInformation)
-> Parser Text -> Parser DomainInformation
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"DomainName")
      )

instance Prelude.Hashable DomainInformation

instance Prelude.NFData DomainInformation

instance Core.ToJSON DomainInformation where
  toJSON :: DomainInformation -> Value
toJSON DomainInformation' {Maybe Text
Text
domainName :: Text
region :: Maybe Text
ownerId :: Maybe Text
$sel:domainName:DomainInformation' :: DomainInformation -> Text
$sel:region:DomainInformation' :: DomainInformation -> Maybe Text
$sel:ownerId:DomainInformation' :: DomainInformation -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"OwnerId" 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
ownerId,
            (Text
"Region" 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
region,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"DomainName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
domainName)
          ]
      )