{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.SetTimeBasedAutoScaling
-- 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)
--
-- Specify the time-based auto scaling configuration for a specified
-- instance. For more information, see
-- <https://docs.aws.amazon.com/opsworks/latest/userguide/workinginstances-autoscaling.html Managing Load with Time-based and Load-based Instances>.
--
-- __Required Permissions__: To use this action, an IAM user must have a
-- Manage permissions level for the stack, or an attached policy that
-- explicitly grants permissions. For more information on user permissions,
-- see
-- <https://docs.aws.amazon.com/opsworks/latest/userguide/opsworks-security-users.html Managing User Permissions>.
module Amazonka.OpsWorks.SetTimeBasedAutoScaling
  ( -- * Creating a Request
    SetTimeBasedAutoScaling (..),
    newSetTimeBasedAutoScaling,

    -- * Request Lenses
    setTimeBasedAutoScaling_autoScalingSchedule,
    setTimeBasedAutoScaling_instanceId,

    -- * Destructuring the Response
    SetTimeBasedAutoScalingResponse (..),
    newSetTimeBasedAutoScalingResponse,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.OpsWorks.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newSetTimeBasedAutoScaling' smart constructor.
data SetTimeBasedAutoScaling = SetTimeBasedAutoScaling'
  { -- | An @AutoScalingSchedule@ with the instance schedule.
    SetTimeBasedAutoScaling -> Maybe WeeklyAutoScalingSchedule
autoScalingSchedule :: Prelude.Maybe WeeklyAutoScalingSchedule,
    -- | The instance ID.
    SetTimeBasedAutoScaling -> Text
instanceId :: Prelude.Text
  }
  deriving (SetTimeBasedAutoScaling -> SetTimeBasedAutoScaling -> Bool
(SetTimeBasedAutoScaling -> SetTimeBasedAutoScaling -> Bool)
-> (SetTimeBasedAutoScaling -> SetTimeBasedAutoScaling -> Bool)
-> Eq SetTimeBasedAutoScaling
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SetTimeBasedAutoScaling -> SetTimeBasedAutoScaling -> Bool
$c/= :: SetTimeBasedAutoScaling -> SetTimeBasedAutoScaling -> Bool
== :: SetTimeBasedAutoScaling -> SetTimeBasedAutoScaling -> Bool
$c== :: SetTimeBasedAutoScaling -> SetTimeBasedAutoScaling -> Bool
Prelude.Eq, ReadPrec [SetTimeBasedAutoScaling]
ReadPrec SetTimeBasedAutoScaling
Int -> ReadS SetTimeBasedAutoScaling
ReadS [SetTimeBasedAutoScaling]
(Int -> ReadS SetTimeBasedAutoScaling)
-> ReadS [SetTimeBasedAutoScaling]
-> ReadPrec SetTimeBasedAutoScaling
-> ReadPrec [SetTimeBasedAutoScaling]
-> Read SetTimeBasedAutoScaling
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SetTimeBasedAutoScaling]
$creadListPrec :: ReadPrec [SetTimeBasedAutoScaling]
readPrec :: ReadPrec SetTimeBasedAutoScaling
$creadPrec :: ReadPrec SetTimeBasedAutoScaling
readList :: ReadS [SetTimeBasedAutoScaling]
$creadList :: ReadS [SetTimeBasedAutoScaling]
readsPrec :: Int -> ReadS SetTimeBasedAutoScaling
$creadsPrec :: Int -> ReadS SetTimeBasedAutoScaling
Prelude.Read, Int -> SetTimeBasedAutoScaling -> ShowS
[SetTimeBasedAutoScaling] -> ShowS
SetTimeBasedAutoScaling -> String
(Int -> SetTimeBasedAutoScaling -> ShowS)
-> (SetTimeBasedAutoScaling -> String)
-> ([SetTimeBasedAutoScaling] -> ShowS)
-> Show SetTimeBasedAutoScaling
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SetTimeBasedAutoScaling] -> ShowS
$cshowList :: [SetTimeBasedAutoScaling] -> ShowS
show :: SetTimeBasedAutoScaling -> String
$cshow :: SetTimeBasedAutoScaling -> String
showsPrec :: Int -> SetTimeBasedAutoScaling -> ShowS
$cshowsPrec :: Int -> SetTimeBasedAutoScaling -> ShowS
Prelude.Show, (forall x.
 SetTimeBasedAutoScaling -> Rep SetTimeBasedAutoScaling x)
-> (forall x.
    Rep SetTimeBasedAutoScaling x -> SetTimeBasedAutoScaling)
-> Generic SetTimeBasedAutoScaling
forall x. Rep SetTimeBasedAutoScaling x -> SetTimeBasedAutoScaling
forall x. SetTimeBasedAutoScaling -> Rep SetTimeBasedAutoScaling x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SetTimeBasedAutoScaling x -> SetTimeBasedAutoScaling
$cfrom :: forall x. SetTimeBasedAutoScaling -> Rep SetTimeBasedAutoScaling x
Prelude.Generic)

-- |
-- Create a value of 'SetTimeBasedAutoScaling' 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:
--
-- 'autoScalingSchedule', 'setTimeBasedAutoScaling_autoScalingSchedule' - An @AutoScalingSchedule@ with the instance schedule.
--
-- 'instanceId', 'setTimeBasedAutoScaling_instanceId' - The instance ID.
newSetTimeBasedAutoScaling ::
  -- | 'instanceId'
  Prelude.Text ->
  SetTimeBasedAutoScaling
newSetTimeBasedAutoScaling :: Text -> SetTimeBasedAutoScaling
newSetTimeBasedAutoScaling Text
pInstanceId_ =
  SetTimeBasedAutoScaling' :: Maybe WeeklyAutoScalingSchedule -> Text -> SetTimeBasedAutoScaling
SetTimeBasedAutoScaling'
    { $sel:autoScalingSchedule:SetTimeBasedAutoScaling' :: Maybe WeeklyAutoScalingSchedule
autoScalingSchedule =
        Maybe WeeklyAutoScalingSchedule
forall a. Maybe a
Prelude.Nothing,
      $sel:instanceId:SetTimeBasedAutoScaling' :: Text
instanceId = Text
pInstanceId_
    }

-- | An @AutoScalingSchedule@ with the instance schedule.
setTimeBasedAutoScaling_autoScalingSchedule :: Lens.Lens' SetTimeBasedAutoScaling (Prelude.Maybe WeeklyAutoScalingSchedule)
setTimeBasedAutoScaling_autoScalingSchedule :: (Maybe WeeklyAutoScalingSchedule
 -> f (Maybe WeeklyAutoScalingSchedule))
-> SetTimeBasedAutoScaling -> f SetTimeBasedAutoScaling
setTimeBasedAutoScaling_autoScalingSchedule = (SetTimeBasedAutoScaling -> Maybe WeeklyAutoScalingSchedule)
-> (SetTimeBasedAutoScaling
    -> Maybe WeeklyAutoScalingSchedule -> SetTimeBasedAutoScaling)
-> Lens
     SetTimeBasedAutoScaling
     SetTimeBasedAutoScaling
     (Maybe WeeklyAutoScalingSchedule)
     (Maybe WeeklyAutoScalingSchedule)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SetTimeBasedAutoScaling' {Maybe WeeklyAutoScalingSchedule
autoScalingSchedule :: Maybe WeeklyAutoScalingSchedule
$sel:autoScalingSchedule:SetTimeBasedAutoScaling' :: SetTimeBasedAutoScaling -> Maybe WeeklyAutoScalingSchedule
autoScalingSchedule} -> Maybe WeeklyAutoScalingSchedule
autoScalingSchedule) (\s :: SetTimeBasedAutoScaling
s@SetTimeBasedAutoScaling' {} Maybe WeeklyAutoScalingSchedule
a -> SetTimeBasedAutoScaling
s {$sel:autoScalingSchedule:SetTimeBasedAutoScaling' :: Maybe WeeklyAutoScalingSchedule
autoScalingSchedule = Maybe WeeklyAutoScalingSchedule
a} :: SetTimeBasedAutoScaling)

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

instance Core.AWSRequest SetTimeBasedAutoScaling where
  type
    AWSResponse SetTimeBasedAutoScaling =
      SetTimeBasedAutoScalingResponse
  request :: SetTimeBasedAutoScaling -> Request SetTimeBasedAutoScaling
request = Service
-> SetTimeBasedAutoScaling -> Request SetTimeBasedAutoScaling
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy SetTimeBasedAutoScaling
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse SetTimeBasedAutoScaling)))
response =
    AWSResponse SetTimeBasedAutoScaling
-> Logger
-> Service
-> Proxy SetTimeBasedAutoScaling
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse SetTimeBasedAutoScaling)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull
      AWSResponse SetTimeBasedAutoScaling
SetTimeBasedAutoScalingResponse
SetTimeBasedAutoScalingResponse'

instance Prelude.Hashable SetTimeBasedAutoScaling

instance Prelude.NFData SetTimeBasedAutoScaling

instance Core.ToHeaders SetTimeBasedAutoScaling where
  toHeaders :: SetTimeBasedAutoScaling -> [Header]
toHeaders =
    [Header] -> SetTimeBasedAutoScaling -> [Header]
forall a b. a -> b -> a
Prelude.const
      ( [[Header]] -> [Header]
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"OpsWorks_20130218.SetTimeBasedAutoScaling" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON SetTimeBasedAutoScaling where
  toJSON :: SetTimeBasedAutoScaling -> Value
toJSON SetTimeBasedAutoScaling' {Maybe WeeklyAutoScalingSchedule
Text
instanceId :: Text
autoScalingSchedule :: Maybe WeeklyAutoScalingSchedule
$sel:instanceId:SetTimeBasedAutoScaling' :: SetTimeBasedAutoScaling -> Text
$sel:autoScalingSchedule:SetTimeBasedAutoScaling' :: SetTimeBasedAutoScaling -> Maybe WeeklyAutoScalingSchedule
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"AutoScalingSchedule" Text -> WeeklyAutoScalingSchedule -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (WeeklyAutoScalingSchedule -> Pair)
-> Maybe WeeklyAutoScalingSchedule -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe WeeklyAutoScalingSchedule
autoScalingSchedule,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"InstanceId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
instanceId)
          ]
      )

instance Core.ToPath SetTimeBasedAutoScaling where
  toPath :: SetTimeBasedAutoScaling -> ByteString
toPath = ByteString -> SetTimeBasedAutoScaling -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery SetTimeBasedAutoScaling where
  toQuery :: SetTimeBasedAutoScaling -> QueryString
toQuery = QueryString -> SetTimeBasedAutoScaling -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newSetTimeBasedAutoScalingResponse' smart constructor.
data SetTimeBasedAutoScalingResponse = SetTimeBasedAutoScalingResponse'
  {
  }
  deriving (SetTimeBasedAutoScalingResponse
-> SetTimeBasedAutoScalingResponse -> Bool
(SetTimeBasedAutoScalingResponse
 -> SetTimeBasedAutoScalingResponse -> Bool)
-> (SetTimeBasedAutoScalingResponse
    -> SetTimeBasedAutoScalingResponse -> Bool)
-> Eq SetTimeBasedAutoScalingResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SetTimeBasedAutoScalingResponse
-> SetTimeBasedAutoScalingResponse -> Bool
$c/= :: SetTimeBasedAutoScalingResponse
-> SetTimeBasedAutoScalingResponse -> Bool
== :: SetTimeBasedAutoScalingResponse
-> SetTimeBasedAutoScalingResponse -> Bool
$c== :: SetTimeBasedAutoScalingResponse
-> SetTimeBasedAutoScalingResponse -> Bool
Prelude.Eq, ReadPrec [SetTimeBasedAutoScalingResponse]
ReadPrec SetTimeBasedAutoScalingResponse
Int -> ReadS SetTimeBasedAutoScalingResponse
ReadS [SetTimeBasedAutoScalingResponse]
(Int -> ReadS SetTimeBasedAutoScalingResponse)
-> ReadS [SetTimeBasedAutoScalingResponse]
-> ReadPrec SetTimeBasedAutoScalingResponse
-> ReadPrec [SetTimeBasedAutoScalingResponse]
-> Read SetTimeBasedAutoScalingResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SetTimeBasedAutoScalingResponse]
$creadListPrec :: ReadPrec [SetTimeBasedAutoScalingResponse]
readPrec :: ReadPrec SetTimeBasedAutoScalingResponse
$creadPrec :: ReadPrec SetTimeBasedAutoScalingResponse
readList :: ReadS [SetTimeBasedAutoScalingResponse]
$creadList :: ReadS [SetTimeBasedAutoScalingResponse]
readsPrec :: Int -> ReadS SetTimeBasedAutoScalingResponse
$creadsPrec :: Int -> ReadS SetTimeBasedAutoScalingResponse
Prelude.Read, Int -> SetTimeBasedAutoScalingResponse -> ShowS
[SetTimeBasedAutoScalingResponse] -> ShowS
SetTimeBasedAutoScalingResponse -> String
(Int -> SetTimeBasedAutoScalingResponse -> ShowS)
-> (SetTimeBasedAutoScalingResponse -> String)
-> ([SetTimeBasedAutoScalingResponse] -> ShowS)
-> Show SetTimeBasedAutoScalingResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SetTimeBasedAutoScalingResponse] -> ShowS
$cshowList :: [SetTimeBasedAutoScalingResponse] -> ShowS
show :: SetTimeBasedAutoScalingResponse -> String
$cshow :: SetTimeBasedAutoScalingResponse -> String
showsPrec :: Int -> SetTimeBasedAutoScalingResponse -> ShowS
$cshowsPrec :: Int -> SetTimeBasedAutoScalingResponse -> ShowS
Prelude.Show, (forall x.
 SetTimeBasedAutoScalingResponse
 -> Rep SetTimeBasedAutoScalingResponse x)
-> (forall x.
    Rep SetTimeBasedAutoScalingResponse x
    -> SetTimeBasedAutoScalingResponse)
-> Generic SetTimeBasedAutoScalingResponse
forall x.
Rep SetTimeBasedAutoScalingResponse x
-> SetTimeBasedAutoScalingResponse
forall x.
SetTimeBasedAutoScalingResponse
-> Rep SetTimeBasedAutoScalingResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep SetTimeBasedAutoScalingResponse x
-> SetTimeBasedAutoScalingResponse
$cfrom :: forall x.
SetTimeBasedAutoScalingResponse
-> Rep SetTimeBasedAutoScalingResponse x
Prelude.Generic)

-- |
-- Create a value of 'SetTimeBasedAutoScalingResponse' 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.
newSetTimeBasedAutoScalingResponse ::
  SetTimeBasedAutoScalingResponse
newSetTimeBasedAutoScalingResponse :: SetTimeBasedAutoScalingResponse
newSetTimeBasedAutoScalingResponse =
  SetTimeBasedAutoScalingResponse
SetTimeBasedAutoScalingResponse'

instance
  Prelude.NFData
    SetTimeBasedAutoScalingResponse