{-# 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.AddOnRequest
-- 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.AddOnRequest where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Lightsail.Types.AddOnType
import Amazonka.Lightsail.Types.AutoSnapshotAddOnRequest
import qualified Amazonka.Prelude as Prelude

-- | Describes a request to enable, modify, or disable an add-on for an
-- Amazon Lightsail resource.
--
-- An additional cost may be associated with enabling add-ons. For more
-- information, see the
-- <https://aws.amazon.com/lightsail/pricing/ Lightsail pricing page>.
--
-- /See:/ 'newAddOnRequest' smart constructor.
data AddOnRequest = AddOnRequest'
  { -- | An object that represents additional parameters when enabling or
    -- modifying the automatic snapshot add-on.
    AddOnRequest -> Maybe AutoSnapshotAddOnRequest
autoSnapshotAddOnRequest :: Prelude.Maybe AutoSnapshotAddOnRequest,
    -- | The add-on type.
    AddOnRequest -> AddOnType
addOnType :: AddOnType
  }
  deriving (AddOnRequest -> AddOnRequest -> Bool
(AddOnRequest -> AddOnRequest -> Bool)
-> (AddOnRequest -> AddOnRequest -> Bool) -> Eq AddOnRequest
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AddOnRequest -> AddOnRequest -> Bool
$c/= :: AddOnRequest -> AddOnRequest -> Bool
== :: AddOnRequest -> AddOnRequest -> Bool
$c== :: AddOnRequest -> AddOnRequest -> Bool
Prelude.Eq, ReadPrec [AddOnRequest]
ReadPrec AddOnRequest
Int -> ReadS AddOnRequest
ReadS [AddOnRequest]
(Int -> ReadS AddOnRequest)
-> ReadS [AddOnRequest]
-> ReadPrec AddOnRequest
-> ReadPrec [AddOnRequest]
-> Read AddOnRequest
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AddOnRequest]
$creadListPrec :: ReadPrec [AddOnRequest]
readPrec :: ReadPrec AddOnRequest
$creadPrec :: ReadPrec AddOnRequest
readList :: ReadS [AddOnRequest]
$creadList :: ReadS [AddOnRequest]
readsPrec :: Int -> ReadS AddOnRequest
$creadsPrec :: Int -> ReadS AddOnRequest
Prelude.Read, Int -> AddOnRequest -> ShowS
[AddOnRequest] -> ShowS
AddOnRequest -> String
(Int -> AddOnRequest -> ShowS)
-> (AddOnRequest -> String)
-> ([AddOnRequest] -> ShowS)
-> Show AddOnRequest
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AddOnRequest] -> ShowS
$cshowList :: [AddOnRequest] -> ShowS
show :: AddOnRequest -> String
$cshow :: AddOnRequest -> String
showsPrec :: Int -> AddOnRequest -> ShowS
$cshowsPrec :: Int -> AddOnRequest -> ShowS
Prelude.Show, (forall x. AddOnRequest -> Rep AddOnRequest x)
-> (forall x. Rep AddOnRequest x -> AddOnRequest)
-> Generic AddOnRequest
forall x. Rep AddOnRequest x -> AddOnRequest
forall x. AddOnRequest -> Rep AddOnRequest x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AddOnRequest x -> AddOnRequest
$cfrom :: forall x. AddOnRequest -> Rep AddOnRequest x
Prelude.Generic)

-- |
-- Create a value of 'AddOnRequest' 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:
--
-- 'autoSnapshotAddOnRequest', 'addOnRequest_autoSnapshotAddOnRequest' - An object that represents additional parameters when enabling or
-- modifying the automatic snapshot add-on.
--
-- 'addOnType', 'addOnRequest_addOnType' - The add-on type.
newAddOnRequest ::
  -- | 'addOnType'
  AddOnType ->
  AddOnRequest
newAddOnRequest :: AddOnType -> AddOnRequest
newAddOnRequest AddOnType
pAddOnType_ =
  AddOnRequest' :: Maybe AutoSnapshotAddOnRequest -> AddOnType -> AddOnRequest
AddOnRequest'
    { $sel:autoSnapshotAddOnRequest:AddOnRequest' :: Maybe AutoSnapshotAddOnRequest
autoSnapshotAddOnRequest =
        Maybe AutoSnapshotAddOnRequest
forall a. Maybe a
Prelude.Nothing,
      $sel:addOnType:AddOnRequest' :: AddOnType
addOnType = AddOnType
pAddOnType_
    }

-- | An object that represents additional parameters when enabling or
-- modifying the automatic snapshot add-on.
addOnRequest_autoSnapshotAddOnRequest :: Lens.Lens' AddOnRequest (Prelude.Maybe AutoSnapshotAddOnRequest)
addOnRequest_autoSnapshotAddOnRequest :: (Maybe AutoSnapshotAddOnRequest
 -> f (Maybe AutoSnapshotAddOnRequest))
-> AddOnRequest -> f AddOnRequest
addOnRequest_autoSnapshotAddOnRequest = (AddOnRequest -> Maybe AutoSnapshotAddOnRequest)
-> (AddOnRequest -> Maybe AutoSnapshotAddOnRequest -> AddOnRequest)
-> Lens
     AddOnRequest
     AddOnRequest
     (Maybe AutoSnapshotAddOnRequest)
     (Maybe AutoSnapshotAddOnRequest)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AddOnRequest' {Maybe AutoSnapshotAddOnRequest
autoSnapshotAddOnRequest :: Maybe AutoSnapshotAddOnRequest
$sel:autoSnapshotAddOnRequest:AddOnRequest' :: AddOnRequest -> Maybe AutoSnapshotAddOnRequest
autoSnapshotAddOnRequest} -> Maybe AutoSnapshotAddOnRequest
autoSnapshotAddOnRequest) (\s :: AddOnRequest
s@AddOnRequest' {} Maybe AutoSnapshotAddOnRequest
a -> AddOnRequest
s {$sel:autoSnapshotAddOnRequest:AddOnRequest' :: Maybe AutoSnapshotAddOnRequest
autoSnapshotAddOnRequest = Maybe AutoSnapshotAddOnRequest
a} :: AddOnRequest)

-- | The add-on type.
addOnRequest_addOnType :: Lens.Lens' AddOnRequest AddOnType
addOnRequest_addOnType :: (AddOnType -> f AddOnType) -> AddOnRequest -> f AddOnRequest
addOnRequest_addOnType = (AddOnRequest -> AddOnType)
-> (AddOnRequest -> AddOnType -> AddOnRequest)
-> Lens AddOnRequest AddOnRequest AddOnType AddOnType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AddOnRequest' {AddOnType
addOnType :: AddOnType
$sel:addOnType:AddOnRequest' :: AddOnRequest -> AddOnType
addOnType} -> AddOnType
addOnType) (\s :: AddOnRequest
s@AddOnRequest' {} AddOnType
a -> AddOnRequest
s {$sel:addOnType:AddOnRequest' :: AddOnType
addOnType = AddOnType
a} :: AddOnRequest)

instance Prelude.Hashable AddOnRequest

instance Prelude.NFData AddOnRequest

instance Core.ToJSON AddOnRequest where
  toJSON :: AddOnRequest -> Value
toJSON AddOnRequest' {Maybe AutoSnapshotAddOnRequest
AddOnType
addOnType :: AddOnType
autoSnapshotAddOnRequest :: Maybe AutoSnapshotAddOnRequest
$sel:addOnType:AddOnRequest' :: AddOnRequest -> AddOnType
$sel:autoSnapshotAddOnRequest:AddOnRequest' :: AddOnRequest -> Maybe AutoSnapshotAddOnRequest
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"autoSnapshotAddOnRequest" Text -> AutoSnapshotAddOnRequest -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (AutoSnapshotAddOnRequest -> Pair)
-> Maybe AutoSnapshotAddOnRequest -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe AutoSnapshotAddOnRequest
autoSnapshotAddOnRequest,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"addOnType" Text -> AddOnType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= AddOnType
addOnType)
          ]
      )