{-# 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.Lightsail.Types.ResourceRecord
-- 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.Lightsail.Types.ResourceRecord 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

-- | Describes the domain name system (DNS) records to add to your domain\'s
-- DNS to validate it for an Amazon Lightsail certificate.
--
-- /See:/ 'newResourceRecord' smart constructor.
data ResourceRecord = ResourceRecord'
  { -- | The name of the record.
    ResourceRecord -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The DNS record type.
    ResourceRecord -> Maybe Text
type' :: Prelude.Maybe Prelude.Text,
    -- | The value for the DNS record.
    ResourceRecord -> Maybe Text
value :: Prelude.Maybe Prelude.Text
  }
  deriving (ResourceRecord -> ResourceRecord -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResourceRecord -> ResourceRecord -> Bool
$c/= :: ResourceRecord -> ResourceRecord -> Bool
== :: ResourceRecord -> ResourceRecord -> Bool
$c== :: ResourceRecord -> ResourceRecord -> Bool
Prelude.Eq, ReadPrec [ResourceRecord]
ReadPrec ResourceRecord
Int -> ReadS ResourceRecord
ReadS [ResourceRecord]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResourceRecord]
$creadListPrec :: ReadPrec [ResourceRecord]
readPrec :: ReadPrec ResourceRecord
$creadPrec :: ReadPrec ResourceRecord
readList :: ReadS [ResourceRecord]
$creadList :: ReadS [ResourceRecord]
readsPrec :: Int -> ReadS ResourceRecord
$creadsPrec :: Int -> ReadS ResourceRecord
Prelude.Read, Int -> ResourceRecord -> ShowS
[ResourceRecord] -> ShowS
ResourceRecord -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResourceRecord] -> ShowS
$cshowList :: [ResourceRecord] -> ShowS
show :: ResourceRecord -> String
$cshow :: ResourceRecord -> String
showsPrec :: Int -> ResourceRecord -> ShowS
$cshowsPrec :: Int -> ResourceRecord -> ShowS
Prelude.Show, forall x. Rep ResourceRecord x -> ResourceRecord
forall x. ResourceRecord -> Rep ResourceRecord x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ResourceRecord x -> ResourceRecord
$cfrom :: forall x. ResourceRecord -> Rep ResourceRecord x
Prelude.Generic)

-- |
-- Create a value of 'ResourceRecord' 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:
--
-- 'name', 'resourceRecord_name' - The name of the record.
--
-- 'type'', 'resourceRecord_type' - The DNS record type.
--
-- 'value', 'resourceRecord_value' - The value for the DNS record.
newResourceRecord ::
  ResourceRecord
newResourceRecord :: ResourceRecord
newResourceRecord =
  ResourceRecord'
    { $sel:name:ResourceRecord' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:type':ResourceRecord' :: Maybe Text
type' = forall a. Maybe a
Prelude.Nothing,
      $sel:value:ResourceRecord' :: Maybe Text
value = forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the record.
resourceRecord_name :: Lens.Lens' ResourceRecord (Prelude.Maybe Prelude.Text)
resourceRecord_name :: Lens' ResourceRecord (Maybe Text)
resourceRecord_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceRecord' {Maybe Text
name :: Maybe Text
$sel:name:ResourceRecord' :: ResourceRecord -> Maybe Text
name} -> Maybe Text
name) (\s :: ResourceRecord
s@ResourceRecord' {} Maybe Text
a -> ResourceRecord
s {$sel:name:ResourceRecord' :: Maybe Text
name = Maybe Text
a} :: ResourceRecord)

-- | The DNS record type.
resourceRecord_type :: Lens.Lens' ResourceRecord (Prelude.Maybe Prelude.Text)
resourceRecord_type :: Lens' ResourceRecord (Maybe Text)
resourceRecord_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceRecord' {Maybe Text
type' :: Maybe Text
$sel:type':ResourceRecord' :: ResourceRecord -> Maybe Text
type'} -> Maybe Text
type') (\s :: ResourceRecord
s@ResourceRecord' {} Maybe Text
a -> ResourceRecord
s {$sel:type':ResourceRecord' :: Maybe Text
type' = Maybe Text
a} :: ResourceRecord)

-- | The value for the DNS record.
resourceRecord_value :: Lens.Lens' ResourceRecord (Prelude.Maybe Prelude.Text)
resourceRecord_value :: Lens' ResourceRecord (Maybe Text)
resourceRecord_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceRecord' {Maybe Text
value :: Maybe Text
$sel:value:ResourceRecord' :: ResourceRecord -> Maybe Text
value} -> Maybe Text
value) (\s :: ResourceRecord
s@ResourceRecord' {} Maybe Text
a -> ResourceRecord
s {$sel:value:ResourceRecord' :: Maybe Text
value = Maybe Text
a} :: ResourceRecord)

instance Data.FromJSON ResourceRecord where
  parseJSON :: Value -> Parser ResourceRecord
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ResourceRecord"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Maybe Text -> ResourceRecord
ResourceRecord'
            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
"name")
            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 ResourceRecord where
  hashWithSalt :: Int -> ResourceRecord -> Int
hashWithSalt Int
_salt ResourceRecord' {Maybe Text
value :: Maybe Text
type' :: Maybe Text
name :: Maybe Text
$sel:value:ResourceRecord' :: ResourceRecord -> Maybe Text
$sel:type':ResourceRecord' :: ResourceRecord -> Maybe Text
$sel:name:ResourceRecord' :: ResourceRecord -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      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 ResourceRecord where
  rnf :: ResourceRecord -> ()
rnf ResourceRecord' {Maybe Text
value :: Maybe Text
type' :: Maybe Text
name :: Maybe Text
$sel:value:ResourceRecord' :: ResourceRecord -> Maybe Text
$sel:type':ResourceRecord' :: ResourceRecord -> Maybe Text
$sel:name:ResourceRecord' :: ResourceRecord -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name
      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