{-# 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.WorkMail.Types.DnsRecord
-- 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.WorkMail.Types.DnsRecord 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

-- | A DNS record uploaded to your DNS provider.
--
-- /See:/ 'newDnsRecord' smart constructor.
data DnsRecord = DnsRecord'
  { -- | The DNS hostname.- For example, @domain.example.com@.
    DnsRecord -> Maybe Text
hostname :: Prelude.Maybe Prelude.Text,
    -- | The RFC 1035 record type. Possible values: @CNAME@, @A@, @MX@.
    DnsRecord -> Maybe Text
type' :: Prelude.Maybe Prelude.Text,
    -- | The value returned by the DNS for a query to that hostname and record
    -- type.
    DnsRecord -> Maybe Text
value :: Prelude.Maybe Prelude.Text
  }
  deriving (DnsRecord -> DnsRecord -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DnsRecord -> DnsRecord -> Bool
$c/= :: DnsRecord -> DnsRecord -> Bool
== :: DnsRecord -> DnsRecord -> Bool
$c== :: DnsRecord -> DnsRecord -> Bool
Prelude.Eq, ReadPrec [DnsRecord]
ReadPrec DnsRecord
Int -> ReadS DnsRecord
ReadS [DnsRecord]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DnsRecord]
$creadListPrec :: ReadPrec [DnsRecord]
readPrec :: ReadPrec DnsRecord
$creadPrec :: ReadPrec DnsRecord
readList :: ReadS [DnsRecord]
$creadList :: ReadS [DnsRecord]
readsPrec :: Int -> ReadS DnsRecord
$creadsPrec :: Int -> ReadS DnsRecord
Prelude.Read, Int -> DnsRecord -> ShowS
[DnsRecord] -> ShowS
DnsRecord -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DnsRecord] -> ShowS
$cshowList :: [DnsRecord] -> ShowS
show :: DnsRecord -> String
$cshow :: DnsRecord -> String
showsPrec :: Int -> DnsRecord -> ShowS
$cshowsPrec :: Int -> DnsRecord -> ShowS
Prelude.Show, forall x. Rep DnsRecord x -> DnsRecord
forall x. DnsRecord -> Rep DnsRecord x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DnsRecord x -> DnsRecord
$cfrom :: forall x. DnsRecord -> Rep DnsRecord x
Prelude.Generic)

-- |
-- Create a value of 'DnsRecord' 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:
--
-- 'hostname', 'dnsRecord_hostname' - The DNS hostname.- For example, @domain.example.com@.
--
-- 'type'', 'dnsRecord_type' - The RFC 1035 record type. Possible values: @CNAME@, @A@, @MX@.
--
-- 'value', 'dnsRecord_value' - The value returned by the DNS for a query to that hostname and record
-- type.
newDnsRecord ::
  DnsRecord
newDnsRecord :: DnsRecord
newDnsRecord =
  DnsRecord'
    { $sel:hostname:DnsRecord' :: Maybe Text
hostname = forall a. Maybe a
Prelude.Nothing,
      $sel:type':DnsRecord' :: Maybe Text
type' = forall a. Maybe a
Prelude.Nothing,
      $sel:value:DnsRecord' :: Maybe Text
value = forall a. Maybe a
Prelude.Nothing
    }

-- | The DNS hostname.- For example, @domain.example.com@.
dnsRecord_hostname :: Lens.Lens' DnsRecord (Prelude.Maybe Prelude.Text)
dnsRecord_hostname :: Lens' DnsRecord (Maybe Text)
dnsRecord_hostname = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DnsRecord' {Maybe Text
hostname :: Maybe Text
$sel:hostname:DnsRecord' :: DnsRecord -> Maybe Text
hostname} -> Maybe Text
hostname) (\s :: DnsRecord
s@DnsRecord' {} Maybe Text
a -> DnsRecord
s {$sel:hostname:DnsRecord' :: Maybe Text
hostname = Maybe Text
a} :: DnsRecord)

-- | The RFC 1035 record type. Possible values: @CNAME@, @A@, @MX@.
dnsRecord_type :: Lens.Lens' DnsRecord (Prelude.Maybe Prelude.Text)
dnsRecord_type :: Lens' DnsRecord (Maybe Text)
dnsRecord_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DnsRecord' {Maybe Text
type' :: Maybe Text
$sel:type':DnsRecord' :: DnsRecord -> Maybe Text
type'} -> Maybe Text
type') (\s :: DnsRecord
s@DnsRecord' {} Maybe Text
a -> DnsRecord
s {$sel:type':DnsRecord' :: Maybe Text
type' = Maybe Text
a} :: DnsRecord)

-- | The value returned by the DNS for a query to that hostname and record
-- type.
dnsRecord_value :: Lens.Lens' DnsRecord (Prelude.Maybe Prelude.Text)
dnsRecord_value :: Lens' DnsRecord (Maybe Text)
dnsRecord_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DnsRecord' {Maybe Text
value :: Maybe Text
$sel:value:DnsRecord' :: DnsRecord -> Maybe Text
value} -> Maybe Text
value) (\s :: DnsRecord
s@DnsRecord' {} Maybe Text
a -> DnsRecord
s {$sel:value:DnsRecord' :: Maybe Text
value = Maybe Text
a} :: DnsRecord)

instance Data.FromJSON DnsRecord where
  parseJSON :: Value -> Parser DnsRecord
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"DnsRecord"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Maybe Text -> DnsRecord
DnsRecord'
            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
"Hostname")
            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
"Type")
            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
"Value")
      )

instance Prelude.Hashable DnsRecord where
  hashWithSalt :: Int -> DnsRecord -> Int
hashWithSalt Int
_salt DnsRecord' {Maybe Text
value :: Maybe Text
type' :: Maybe Text
hostname :: Maybe Text
$sel:value:DnsRecord' :: DnsRecord -> Maybe Text
$sel:type':DnsRecord' :: DnsRecord -> Maybe Text
$sel:hostname:DnsRecord' :: DnsRecord -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
hostname
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
type'
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
value

instance Prelude.NFData DnsRecord where
  rnf :: DnsRecord -> ()
rnf DnsRecord' {Maybe Text
value :: Maybe Text
type' :: Maybe Text
hostname :: Maybe Text
$sel:value:DnsRecord' :: DnsRecord -> Maybe Text
$sel:type':DnsRecord' :: DnsRecord -> Maybe Text
$sel:hostname:DnsRecord' :: DnsRecord -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
hostname
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
type'
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
value