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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 value for the DNS record.
    ResourceRecord -> Maybe Text
value :: Prelude.Maybe Prelude.Text,
    -- | 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
  }
  deriving (ResourceRecord -> ResourceRecord -> Bool
(ResourceRecord -> ResourceRecord -> Bool)
-> (ResourceRecord -> ResourceRecord -> Bool) -> Eq ResourceRecord
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]
(Int -> ReadS ResourceRecord)
-> ReadS [ResourceRecord]
-> ReadPrec ResourceRecord
-> ReadPrec [ResourceRecord]
-> Read 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
(Int -> ResourceRecord -> ShowS)
-> (ResourceRecord -> String)
-> ([ResourceRecord] -> ShowS)
-> Show ResourceRecord
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. ResourceRecord -> Rep ResourceRecord x)
-> (forall x. Rep ResourceRecord x -> ResourceRecord)
-> Generic ResourceRecord
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:
--
-- 'value', 'resourceRecord_value' - The value for the DNS record.
--
-- 'name', 'resourceRecord_name' - The name of the record.
--
-- 'type'', 'resourceRecord_type' - The DNS record type.
newResourceRecord ::
  ResourceRecord
newResourceRecord :: ResourceRecord
newResourceRecord =
  ResourceRecord' :: Maybe Text -> Maybe Text -> Maybe Text -> ResourceRecord
ResourceRecord'
    { $sel:value:ResourceRecord' :: Maybe Text
value = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:ResourceRecord' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:type':ResourceRecord' :: Maybe Text
type' = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The value for the DNS record.
resourceRecord_value :: Lens.Lens' ResourceRecord (Prelude.Maybe Prelude.Text)
resourceRecord_value :: (Maybe Text -> f (Maybe Text))
-> ResourceRecord -> f ResourceRecord
resourceRecord_value = (ResourceRecord -> Maybe Text)
-> (ResourceRecord -> Maybe Text -> ResourceRecord)
-> Lens ResourceRecord ResourceRecord (Maybe Text) (Maybe Text)
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)

-- | The name of the record.
resourceRecord_name :: Lens.Lens' ResourceRecord (Prelude.Maybe Prelude.Text)
resourceRecord_name :: (Maybe Text -> f (Maybe Text))
-> ResourceRecord -> f ResourceRecord
resourceRecord_name = (ResourceRecord -> Maybe Text)
-> (ResourceRecord -> Maybe Text -> ResourceRecord)
-> Lens ResourceRecord ResourceRecord (Maybe Text) (Maybe Text)
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 :: (Maybe Text -> f (Maybe Text))
-> ResourceRecord -> f ResourceRecord
resourceRecord_type = (ResourceRecord -> Maybe Text)
-> (ResourceRecord -> Maybe Text -> ResourceRecord)
-> Lens ResourceRecord ResourceRecord (Maybe Text) (Maybe Text)
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)

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

instance Prelude.NFData ResourceRecord