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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 value returned by the DNS for a query to that hostname and record
    -- type.
    DnsRecord -> Maybe Text
value :: Prelude.Maybe Prelude.Text,
    -- | The RFC 1035 record type. Possible values: @CNAME@, @A@, @MX@.
    DnsRecord -> Maybe Text
type' :: Prelude.Maybe Prelude.Text
  }
  deriving (DnsRecord -> DnsRecord -> Bool
(DnsRecord -> DnsRecord -> Bool)
-> (DnsRecord -> DnsRecord -> Bool) -> Eq DnsRecord
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]
(Int -> ReadS DnsRecord)
-> ReadS [DnsRecord]
-> ReadPrec DnsRecord
-> ReadPrec [DnsRecord]
-> Read 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
(Int -> DnsRecord -> ShowS)
-> (DnsRecord -> String)
-> ([DnsRecord] -> ShowS)
-> Show DnsRecord
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. DnsRecord -> Rep DnsRecord x)
-> (forall x. Rep DnsRecord x -> DnsRecord) -> Generic DnsRecord
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@.
--
-- 'value', 'dnsRecord_value' - The value returned by the DNS for a query to that hostname and record
-- type.
--
-- 'type'', 'dnsRecord_type' - The RFC 1035 record type. Possible values: @CNAME@, @A@, @MX@.
newDnsRecord ::
  DnsRecord
newDnsRecord :: DnsRecord
newDnsRecord =
  DnsRecord' :: Maybe Text -> Maybe Text -> Maybe Text -> DnsRecord
DnsRecord'
    { $sel:hostname:DnsRecord' :: Maybe Text
hostname = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:value:DnsRecord' :: Maybe Text
value = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:type':DnsRecord' :: Maybe Text
type' = Maybe Text
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 :: (Maybe Text -> f (Maybe Text)) -> DnsRecord -> f DnsRecord
dnsRecord_hostname = (DnsRecord -> Maybe Text)
-> (DnsRecord -> Maybe Text -> DnsRecord)
-> Lens DnsRecord DnsRecord (Maybe Text) (Maybe Text)
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 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 :: (Maybe Text -> f (Maybe Text)) -> DnsRecord -> f DnsRecord
dnsRecord_value = (DnsRecord -> Maybe Text)
-> (DnsRecord -> Maybe Text -> DnsRecord)
-> Lens DnsRecord DnsRecord (Maybe Text) (Maybe Text)
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)

-- | The RFC 1035 record type. Possible values: @CNAME@, @A@, @MX@.
dnsRecord_type :: Lens.Lens' DnsRecord (Prelude.Maybe Prelude.Text)
dnsRecord_type :: (Maybe Text -> f (Maybe Text)) -> DnsRecord -> f DnsRecord
dnsRecord_type = (DnsRecord -> Maybe Text)
-> (DnsRecord -> Maybe Text -> DnsRecord)
-> Lens DnsRecord DnsRecord (Maybe Text) (Maybe Text)
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)

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

instance Prelude.Hashable DnsRecord

instance Prelude.NFData DnsRecord