{-# 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.OpenSearch.Types.AWSDomainInformation
-- 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.OpenSearch.Types.AWSDomainInformation 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

-- | Information about an Amazon OpenSearch Service domain.
--
-- /See:/ 'newAWSDomainInformation' smart constructor.
data AWSDomainInformation = AWSDomainInformation'
  { -- | The Amazon Web Services account ID of the domain owner.
    AWSDomainInformation -> Maybe Text
ownerId :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Web Services Region in which the domain is located.
    AWSDomainInformation -> Maybe Text
region :: Prelude.Maybe Prelude.Text,
    -- | Name of the domain.
    AWSDomainInformation -> Text
domainName :: Prelude.Text
  }
  deriving (AWSDomainInformation -> AWSDomainInformation -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AWSDomainInformation -> AWSDomainInformation -> Bool
$c/= :: AWSDomainInformation -> AWSDomainInformation -> Bool
== :: AWSDomainInformation -> AWSDomainInformation -> Bool
$c== :: AWSDomainInformation -> AWSDomainInformation -> Bool
Prelude.Eq, ReadPrec [AWSDomainInformation]
ReadPrec AWSDomainInformation
Int -> ReadS AWSDomainInformation
ReadS [AWSDomainInformation]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AWSDomainInformation]
$creadListPrec :: ReadPrec [AWSDomainInformation]
readPrec :: ReadPrec AWSDomainInformation
$creadPrec :: ReadPrec AWSDomainInformation
readList :: ReadS [AWSDomainInformation]
$creadList :: ReadS [AWSDomainInformation]
readsPrec :: Int -> ReadS AWSDomainInformation
$creadsPrec :: Int -> ReadS AWSDomainInformation
Prelude.Read, Int -> AWSDomainInformation -> ShowS
[AWSDomainInformation] -> ShowS
AWSDomainInformation -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AWSDomainInformation] -> ShowS
$cshowList :: [AWSDomainInformation] -> ShowS
show :: AWSDomainInformation -> String
$cshow :: AWSDomainInformation -> String
showsPrec :: Int -> AWSDomainInformation -> ShowS
$cshowsPrec :: Int -> AWSDomainInformation -> ShowS
Prelude.Show, forall x. Rep AWSDomainInformation x -> AWSDomainInformation
forall x. AWSDomainInformation -> Rep AWSDomainInformation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AWSDomainInformation x -> AWSDomainInformation
$cfrom :: forall x. AWSDomainInformation -> Rep AWSDomainInformation x
Prelude.Generic)

-- |
-- Create a value of 'AWSDomainInformation' 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', 'aWSDomainInformation_ownerId' - The Amazon Web Services account ID of the domain owner.
--
-- 'region', 'aWSDomainInformation_region' - The Amazon Web Services Region in which the domain is located.
--
-- 'domainName', 'aWSDomainInformation_domainName' - Name of the domain.
newAWSDomainInformation ::
  -- | 'domainName'
  Prelude.Text ->
  AWSDomainInformation
newAWSDomainInformation :: Text -> AWSDomainInformation
newAWSDomainInformation Text
pDomainName_ =
  AWSDomainInformation'
    { $sel:ownerId:AWSDomainInformation' :: Maybe Text
ownerId = forall a. Maybe a
Prelude.Nothing,
      $sel:region:AWSDomainInformation' :: Maybe Text
region = forall a. Maybe a
Prelude.Nothing,
      $sel:domainName:AWSDomainInformation' :: Text
domainName = Text
pDomainName_
    }

-- | The Amazon Web Services account ID of the domain owner.
aWSDomainInformation_ownerId :: Lens.Lens' AWSDomainInformation (Prelude.Maybe Prelude.Text)
aWSDomainInformation_ownerId :: Lens' AWSDomainInformation (Maybe Text)
aWSDomainInformation_ownerId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AWSDomainInformation' {Maybe Text
ownerId :: Maybe Text
$sel:ownerId:AWSDomainInformation' :: AWSDomainInformation -> Maybe Text
ownerId} -> Maybe Text
ownerId) (\s :: AWSDomainInformation
s@AWSDomainInformation' {} Maybe Text
a -> AWSDomainInformation
s {$sel:ownerId:AWSDomainInformation' :: Maybe Text
ownerId = Maybe Text
a} :: AWSDomainInformation)

-- | The Amazon Web Services Region in which the domain is located.
aWSDomainInformation_region :: Lens.Lens' AWSDomainInformation (Prelude.Maybe Prelude.Text)
aWSDomainInformation_region :: Lens' AWSDomainInformation (Maybe Text)
aWSDomainInformation_region = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AWSDomainInformation' {Maybe Text
region :: Maybe Text
$sel:region:AWSDomainInformation' :: AWSDomainInformation -> Maybe Text
region} -> Maybe Text
region) (\s :: AWSDomainInformation
s@AWSDomainInformation' {} Maybe Text
a -> AWSDomainInformation
s {$sel:region:AWSDomainInformation' :: Maybe Text
region = Maybe Text
a} :: AWSDomainInformation)

-- | Name of the domain.
aWSDomainInformation_domainName :: Lens.Lens' AWSDomainInformation Prelude.Text
aWSDomainInformation_domainName :: Lens' AWSDomainInformation Text
aWSDomainInformation_domainName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AWSDomainInformation' {Text
domainName :: Text
$sel:domainName:AWSDomainInformation' :: AWSDomainInformation -> Text
domainName} -> Text
domainName) (\s :: AWSDomainInformation
s@AWSDomainInformation' {} Text
a -> AWSDomainInformation
s {$sel:domainName:AWSDomainInformation' :: Text
domainName = Text
a} :: AWSDomainInformation)

instance Data.FromJSON AWSDomainInformation where
  parseJSON :: Value -> Parser AWSDomainInformation
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AWSDomainInformation"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Text -> AWSDomainInformation
AWSDomainInformation'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"OwnerId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Region")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"DomainName")
      )

instance Prelude.Hashable AWSDomainInformation where
  hashWithSalt :: Int -> AWSDomainInformation -> Int
hashWithSalt Int
_salt AWSDomainInformation' {Maybe Text
Text
domainName :: Text
region :: Maybe Text
ownerId :: Maybe Text
$sel:domainName:AWSDomainInformation' :: AWSDomainInformation -> Text
$sel:region:AWSDomainInformation' :: AWSDomainInformation -> Maybe Text
$sel:ownerId:AWSDomainInformation' :: AWSDomainInformation -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
ownerId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
region
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
domainName

instance Prelude.NFData AWSDomainInformation where
  rnf :: AWSDomainInformation -> ()
rnf AWSDomainInformation' {Maybe Text
Text
domainName :: Text
region :: Maybe Text
ownerId :: Maybe Text
$sel:domainName:AWSDomainInformation' :: AWSDomainInformation -> Text
$sel:region:AWSDomainInformation' :: AWSDomainInformation -> Maybe Text
$sel:ownerId:AWSDomainInformation' :: AWSDomainInformation -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
ownerId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
region
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
domainName

instance Data.ToJSON AWSDomainInformation where
  toJSON :: AWSDomainInformation -> Value
toJSON AWSDomainInformation' {Maybe Text
Text
domainName :: Text
region :: Maybe Text
ownerId :: Maybe Text
$sel:domainName:AWSDomainInformation' :: AWSDomainInformation -> Text
$sel:region:AWSDomainInformation' :: AWSDomainInformation -> Maybe Text
$sel:ownerId:AWSDomainInformation' :: AWSDomainInformation -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"OwnerId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
ownerId,
            (Key
"Region" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
region,
            forall a. a -> Maybe a
Prelude.Just (Key
"DomainName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
domainName)
          ]
      )