{-# 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.OpsWorks.Types.TimeBasedAutoScalingConfiguration
-- 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.OpsWorks.Types.TimeBasedAutoScalingConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.OpsWorks.Types.WeeklyAutoScalingSchedule
import qualified Amazonka.Prelude as Prelude

-- | Describes an instance\'s time-based auto scaling configuration.
--
-- /See:/ 'newTimeBasedAutoScalingConfiguration' smart constructor.
data TimeBasedAutoScalingConfiguration = TimeBasedAutoScalingConfiguration'
  { -- | The instance ID.
    TimeBasedAutoScalingConfiguration -> Maybe Text
instanceId :: Prelude.Maybe Prelude.Text,
    -- | A @WeeklyAutoScalingSchedule@ object with the instance schedule.
    TimeBasedAutoScalingConfiguration
-> Maybe WeeklyAutoScalingSchedule
autoScalingSchedule :: Prelude.Maybe WeeklyAutoScalingSchedule
  }
  deriving (TimeBasedAutoScalingConfiguration
-> TimeBasedAutoScalingConfiguration -> Bool
(TimeBasedAutoScalingConfiguration
 -> TimeBasedAutoScalingConfiguration -> Bool)
-> (TimeBasedAutoScalingConfiguration
    -> TimeBasedAutoScalingConfiguration -> Bool)
-> Eq TimeBasedAutoScalingConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TimeBasedAutoScalingConfiguration
-> TimeBasedAutoScalingConfiguration -> Bool
$c/= :: TimeBasedAutoScalingConfiguration
-> TimeBasedAutoScalingConfiguration -> Bool
== :: TimeBasedAutoScalingConfiguration
-> TimeBasedAutoScalingConfiguration -> Bool
$c== :: TimeBasedAutoScalingConfiguration
-> TimeBasedAutoScalingConfiguration -> Bool
Prelude.Eq, ReadPrec [TimeBasedAutoScalingConfiguration]
ReadPrec TimeBasedAutoScalingConfiguration
Int -> ReadS TimeBasedAutoScalingConfiguration
ReadS [TimeBasedAutoScalingConfiguration]
(Int -> ReadS TimeBasedAutoScalingConfiguration)
-> ReadS [TimeBasedAutoScalingConfiguration]
-> ReadPrec TimeBasedAutoScalingConfiguration
-> ReadPrec [TimeBasedAutoScalingConfiguration]
-> Read TimeBasedAutoScalingConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TimeBasedAutoScalingConfiguration]
$creadListPrec :: ReadPrec [TimeBasedAutoScalingConfiguration]
readPrec :: ReadPrec TimeBasedAutoScalingConfiguration
$creadPrec :: ReadPrec TimeBasedAutoScalingConfiguration
readList :: ReadS [TimeBasedAutoScalingConfiguration]
$creadList :: ReadS [TimeBasedAutoScalingConfiguration]
readsPrec :: Int -> ReadS TimeBasedAutoScalingConfiguration
$creadsPrec :: Int -> ReadS TimeBasedAutoScalingConfiguration
Prelude.Read, Int -> TimeBasedAutoScalingConfiguration -> ShowS
[TimeBasedAutoScalingConfiguration] -> ShowS
TimeBasedAutoScalingConfiguration -> String
(Int -> TimeBasedAutoScalingConfiguration -> ShowS)
-> (TimeBasedAutoScalingConfiguration -> String)
-> ([TimeBasedAutoScalingConfiguration] -> ShowS)
-> Show TimeBasedAutoScalingConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TimeBasedAutoScalingConfiguration] -> ShowS
$cshowList :: [TimeBasedAutoScalingConfiguration] -> ShowS
show :: TimeBasedAutoScalingConfiguration -> String
$cshow :: TimeBasedAutoScalingConfiguration -> String
showsPrec :: Int -> TimeBasedAutoScalingConfiguration -> ShowS
$cshowsPrec :: Int -> TimeBasedAutoScalingConfiguration -> ShowS
Prelude.Show, (forall x.
 TimeBasedAutoScalingConfiguration
 -> Rep TimeBasedAutoScalingConfiguration x)
-> (forall x.
    Rep TimeBasedAutoScalingConfiguration x
    -> TimeBasedAutoScalingConfiguration)
-> Generic TimeBasedAutoScalingConfiguration
forall x.
Rep TimeBasedAutoScalingConfiguration x
-> TimeBasedAutoScalingConfiguration
forall x.
TimeBasedAutoScalingConfiguration
-> Rep TimeBasedAutoScalingConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep TimeBasedAutoScalingConfiguration x
-> TimeBasedAutoScalingConfiguration
$cfrom :: forall x.
TimeBasedAutoScalingConfiguration
-> Rep TimeBasedAutoScalingConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'TimeBasedAutoScalingConfiguration' 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:
--
-- 'instanceId', 'timeBasedAutoScalingConfiguration_instanceId' - The instance ID.
--
-- 'autoScalingSchedule', 'timeBasedAutoScalingConfiguration_autoScalingSchedule' - A @WeeklyAutoScalingSchedule@ object with the instance schedule.
newTimeBasedAutoScalingConfiguration ::
  TimeBasedAutoScalingConfiguration
newTimeBasedAutoScalingConfiguration :: TimeBasedAutoScalingConfiguration
newTimeBasedAutoScalingConfiguration =
  TimeBasedAutoScalingConfiguration' :: Maybe Text
-> Maybe WeeklyAutoScalingSchedule
-> TimeBasedAutoScalingConfiguration
TimeBasedAutoScalingConfiguration'
    { $sel:instanceId:TimeBasedAutoScalingConfiguration' :: Maybe Text
instanceId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:autoScalingSchedule:TimeBasedAutoScalingConfiguration' :: Maybe WeeklyAutoScalingSchedule
autoScalingSchedule = Maybe WeeklyAutoScalingSchedule
forall a. Maybe a
Prelude.Nothing
    }

-- | The instance ID.
timeBasedAutoScalingConfiguration_instanceId :: Lens.Lens' TimeBasedAutoScalingConfiguration (Prelude.Maybe Prelude.Text)
timeBasedAutoScalingConfiguration_instanceId :: (Maybe Text -> f (Maybe Text))
-> TimeBasedAutoScalingConfiguration
-> f TimeBasedAutoScalingConfiguration
timeBasedAutoScalingConfiguration_instanceId = (TimeBasedAutoScalingConfiguration -> Maybe Text)
-> (TimeBasedAutoScalingConfiguration
    -> Maybe Text -> TimeBasedAutoScalingConfiguration)
-> Lens
     TimeBasedAutoScalingConfiguration
     TimeBasedAutoScalingConfiguration
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TimeBasedAutoScalingConfiguration' {Maybe Text
instanceId :: Maybe Text
$sel:instanceId:TimeBasedAutoScalingConfiguration' :: TimeBasedAutoScalingConfiguration -> Maybe Text
instanceId} -> Maybe Text
instanceId) (\s :: TimeBasedAutoScalingConfiguration
s@TimeBasedAutoScalingConfiguration' {} Maybe Text
a -> TimeBasedAutoScalingConfiguration
s {$sel:instanceId:TimeBasedAutoScalingConfiguration' :: Maybe Text
instanceId = Maybe Text
a} :: TimeBasedAutoScalingConfiguration)

-- | A @WeeklyAutoScalingSchedule@ object with the instance schedule.
timeBasedAutoScalingConfiguration_autoScalingSchedule :: Lens.Lens' TimeBasedAutoScalingConfiguration (Prelude.Maybe WeeklyAutoScalingSchedule)
timeBasedAutoScalingConfiguration_autoScalingSchedule :: (Maybe WeeklyAutoScalingSchedule
 -> f (Maybe WeeklyAutoScalingSchedule))
-> TimeBasedAutoScalingConfiguration
-> f TimeBasedAutoScalingConfiguration
timeBasedAutoScalingConfiguration_autoScalingSchedule = (TimeBasedAutoScalingConfiguration
 -> Maybe WeeklyAutoScalingSchedule)
-> (TimeBasedAutoScalingConfiguration
    -> Maybe WeeklyAutoScalingSchedule
    -> TimeBasedAutoScalingConfiguration)
-> Lens
     TimeBasedAutoScalingConfiguration
     TimeBasedAutoScalingConfiguration
     (Maybe WeeklyAutoScalingSchedule)
     (Maybe WeeklyAutoScalingSchedule)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TimeBasedAutoScalingConfiguration' {Maybe WeeklyAutoScalingSchedule
autoScalingSchedule :: Maybe WeeklyAutoScalingSchedule
$sel:autoScalingSchedule:TimeBasedAutoScalingConfiguration' :: TimeBasedAutoScalingConfiguration
-> Maybe WeeklyAutoScalingSchedule
autoScalingSchedule} -> Maybe WeeklyAutoScalingSchedule
autoScalingSchedule) (\s :: TimeBasedAutoScalingConfiguration
s@TimeBasedAutoScalingConfiguration' {} Maybe WeeklyAutoScalingSchedule
a -> TimeBasedAutoScalingConfiguration
s {$sel:autoScalingSchedule:TimeBasedAutoScalingConfiguration' :: Maybe WeeklyAutoScalingSchedule
autoScalingSchedule = Maybe WeeklyAutoScalingSchedule
a} :: TimeBasedAutoScalingConfiguration)

instance
  Core.FromJSON
    TimeBasedAutoScalingConfiguration
  where
  parseJSON :: Value -> Parser TimeBasedAutoScalingConfiguration
parseJSON =
    String
-> (Object -> Parser TimeBasedAutoScalingConfiguration)
-> Value
-> Parser TimeBasedAutoScalingConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"TimeBasedAutoScalingConfiguration"
      ( \Object
x ->
          Maybe Text
-> Maybe WeeklyAutoScalingSchedule
-> TimeBasedAutoScalingConfiguration
TimeBasedAutoScalingConfiguration'
            (Maybe Text
 -> Maybe WeeklyAutoScalingSchedule
 -> TimeBasedAutoScalingConfiguration)
-> Parser (Maybe Text)
-> Parser
     (Maybe WeeklyAutoScalingSchedule
      -> TimeBasedAutoScalingConfiguration)
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
"InstanceId")
            Parser
  (Maybe WeeklyAutoScalingSchedule
   -> TimeBasedAutoScalingConfiguration)
-> Parser (Maybe WeeklyAutoScalingSchedule)
-> Parser TimeBasedAutoScalingConfiguration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe WeeklyAutoScalingSchedule)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AutoScalingSchedule")
      )

instance
  Prelude.Hashable
    TimeBasedAutoScalingConfiguration

instance
  Prelude.NFData
    TimeBasedAutoScalingConfiguration