{-# 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.AutoScaling.EnableMetricsCollection
-- 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)
--
-- Enables group metrics for the specified Auto Scaling group. For more
-- information, see
-- <https://docs.aws.amazon.com/autoscaling/ec2/userguide/as-instance-monitoring.html Monitoring CloudWatch metrics for your Auto Scaling groups and instances>
-- in the /Amazon EC2 Auto Scaling User Guide/.
module Amazonka.AutoScaling.EnableMetricsCollection
  ( -- * Creating a Request
    EnableMetricsCollection (..),
    newEnableMetricsCollection,

    -- * Request Lenses
    enableMetricsCollection_metrics,
    enableMetricsCollection_autoScalingGroupName,
    enableMetricsCollection_granularity,

    -- * Destructuring the Response
    EnableMetricsCollectionResponse (..),
    newEnableMetricsCollectionResponse,
  )
where

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

-- | /See:/ 'newEnableMetricsCollection' smart constructor.
data EnableMetricsCollection = EnableMetricsCollection'
  { -- | Specifies which group-level metrics to start collecting. You can specify
    -- one or more of the following metrics:
    --
    -- -   @GroupMinSize@
    --
    -- -   @GroupMaxSize@
    --
    -- -   @GroupDesiredCapacity@
    --
    -- -   @GroupInServiceInstances@
    --
    -- -   @GroupPendingInstances@
    --
    -- -   @GroupStandbyInstances@
    --
    -- -   @GroupTerminatingInstances@
    --
    -- -   @GroupTotalInstances@
    --
    -- The instance weighting feature supports the following additional
    -- metrics:
    --
    -- -   @GroupInServiceCapacity@
    --
    -- -   @GroupPendingCapacity@
    --
    -- -   @GroupStandbyCapacity@
    --
    -- -   @GroupTerminatingCapacity@
    --
    -- -   @GroupTotalCapacity@
    --
    -- The warm pools feature supports the following additional metrics:
    --
    -- -   @WarmPoolDesiredCapacity@
    --
    -- -   @WarmPoolWarmedCapacity@
    --
    -- -   @WarmPoolPendingCapacity@
    --
    -- -   @WarmPoolTerminatingCapacity@
    --
    -- -   @WarmPoolTotalCapacity@
    --
    -- -   @GroupAndWarmPoolDesiredCapacity@
    --
    -- -   @GroupAndWarmPoolTotalCapacity@
    --
    -- If you omit this parameter, all metrics are enabled.
    EnableMetricsCollection -> Maybe [Text]
metrics :: Prelude.Maybe [Prelude.Text],
    -- | The name of the Auto Scaling group.
    EnableMetricsCollection -> Text
autoScalingGroupName :: Prelude.Text,
    -- | The granularity to associate with the metrics to collect. The only valid
    -- value is @1Minute@.
    EnableMetricsCollection -> Text
granularity :: Prelude.Text
  }
  deriving (EnableMetricsCollection -> EnableMetricsCollection -> Bool
(EnableMetricsCollection -> EnableMetricsCollection -> Bool)
-> (EnableMetricsCollection -> EnableMetricsCollection -> Bool)
-> Eq EnableMetricsCollection
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EnableMetricsCollection -> EnableMetricsCollection -> Bool
$c/= :: EnableMetricsCollection -> EnableMetricsCollection -> Bool
== :: EnableMetricsCollection -> EnableMetricsCollection -> Bool
$c== :: EnableMetricsCollection -> EnableMetricsCollection -> Bool
Prelude.Eq, ReadPrec [EnableMetricsCollection]
ReadPrec EnableMetricsCollection
Int -> ReadS EnableMetricsCollection
ReadS [EnableMetricsCollection]
(Int -> ReadS EnableMetricsCollection)
-> ReadS [EnableMetricsCollection]
-> ReadPrec EnableMetricsCollection
-> ReadPrec [EnableMetricsCollection]
-> Read EnableMetricsCollection
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EnableMetricsCollection]
$creadListPrec :: ReadPrec [EnableMetricsCollection]
readPrec :: ReadPrec EnableMetricsCollection
$creadPrec :: ReadPrec EnableMetricsCollection
readList :: ReadS [EnableMetricsCollection]
$creadList :: ReadS [EnableMetricsCollection]
readsPrec :: Int -> ReadS EnableMetricsCollection
$creadsPrec :: Int -> ReadS EnableMetricsCollection
Prelude.Read, Int -> EnableMetricsCollection -> ShowS
[EnableMetricsCollection] -> ShowS
EnableMetricsCollection -> String
(Int -> EnableMetricsCollection -> ShowS)
-> (EnableMetricsCollection -> String)
-> ([EnableMetricsCollection] -> ShowS)
-> Show EnableMetricsCollection
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EnableMetricsCollection] -> ShowS
$cshowList :: [EnableMetricsCollection] -> ShowS
show :: EnableMetricsCollection -> String
$cshow :: EnableMetricsCollection -> String
showsPrec :: Int -> EnableMetricsCollection -> ShowS
$cshowsPrec :: Int -> EnableMetricsCollection -> ShowS
Prelude.Show, (forall x.
 EnableMetricsCollection -> Rep EnableMetricsCollection x)
-> (forall x.
    Rep EnableMetricsCollection x -> EnableMetricsCollection)
-> Generic EnableMetricsCollection
forall x. Rep EnableMetricsCollection x -> EnableMetricsCollection
forall x. EnableMetricsCollection -> Rep EnableMetricsCollection x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EnableMetricsCollection x -> EnableMetricsCollection
$cfrom :: forall x. EnableMetricsCollection -> Rep EnableMetricsCollection x
Prelude.Generic)

-- |
-- Create a value of 'EnableMetricsCollection' 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:
--
-- 'metrics', 'enableMetricsCollection_metrics' - Specifies which group-level metrics to start collecting. You can specify
-- one or more of the following metrics:
--
-- -   @GroupMinSize@
--
-- -   @GroupMaxSize@
--
-- -   @GroupDesiredCapacity@
--
-- -   @GroupInServiceInstances@
--
-- -   @GroupPendingInstances@
--
-- -   @GroupStandbyInstances@
--
-- -   @GroupTerminatingInstances@
--
-- -   @GroupTotalInstances@
--
-- The instance weighting feature supports the following additional
-- metrics:
--
-- -   @GroupInServiceCapacity@
--
-- -   @GroupPendingCapacity@
--
-- -   @GroupStandbyCapacity@
--
-- -   @GroupTerminatingCapacity@
--
-- -   @GroupTotalCapacity@
--
-- The warm pools feature supports the following additional metrics:
--
-- -   @WarmPoolDesiredCapacity@
--
-- -   @WarmPoolWarmedCapacity@
--
-- -   @WarmPoolPendingCapacity@
--
-- -   @WarmPoolTerminatingCapacity@
--
-- -   @WarmPoolTotalCapacity@
--
-- -   @GroupAndWarmPoolDesiredCapacity@
--
-- -   @GroupAndWarmPoolTotalCapacity@
--
-- If you omit this parameter, all metrics are enabled.
--
-- 'autoScalingGroupName', 'enableMetricsCollection_autoScalingGroupName' - The name of the Auto Scaling group.
--
-- 'granularity', 'enableMetricsCollection_granularity' - The granularity to associate with the metrics to collect. The only valid
-- value is @1Minute@.
newEnableMetricsCollection ::
  -- | 'autoScalingGroupName'
  Prelude.Text ->
  -- | 'granularity'
  Prelude.Text ->
  EnableMetricsCollection
newEnableMetricsCollection :: Text -> Text -> EnableMetricsCollection
newEnableMetricsCollection
  Text
pAutoScalingGroupName_
  Text
pGranularity_ =
    EnableMetricsCollection' :: Maybe [Text] -> Text -> Text -> EnableMetricsCollection
EnableMetricsCollection'
      { $sel:metrics:EnableMetricsCollection' :: Maybe [Text]
metrics = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
        $sel:autoScalingGroupName:EnableMetricsCollection' :: Text
autoScalingGroupName = Text
pAutoScalingGroupName_,
        $sel:granularity:EnableMetricsCollection' :: Text
granularity = Text
pGranularity_
      }

-- | Specifies which group-level metrics to start collecting. You can specify
-- one or more of the following metrics:
--
-- -   @GroupMinSize@
--
-- -   @GroupMaxSize@
--
-- -   @GroupDesiredCapacity@
--
-- -   @GroupInServiceInstances@
--
-- -   @GroupPendingInstances@
--
-- -   @GroupStandbyInstances@
--
-- -   @GroupTerminatingInstances@
--
-- -   @GroupTotalInstances@
--
-- The instance weighting feature supports the following additional
-- metrics:
--
-- -   @GroupInServiceCapacity@
--
-- -   @GroupPendingCapacity@
--
-- -   @GroupStandbyCapacity@
--
-- -   @GroupTerminatingCapacity@
--
-- -   @GroupTotalCapacity@
--
-- The warm pools feature supports the following additional metrics:
--
-- -   @WarmPoolDesiredCapacity@
--
-- -   @WarmPoolWarmedCapacity@
--
-- -   @WarmPoolPendingCapacity@
--
-- -   @WarmPoolTerminatingCapacity@
--
-- -   @WarmPoolTotalCapacity@
--
-- -   @GroupAndWarmPoolDesiredCapacity@
--
-- -   @GroupAndWarmPoolTotalCapacity@
--
-- If you omit this parameter, all metrics are enabled.
enableMetricsCollection_metrics :: Lens.Lens' EnableMetricsCollection (Prelude.Maybe [Prelude.Text])
enableMetricsCollection_metrics :: (Maybe [Text] -> f (Maybe [Text]))
-> EnableMetricsCollection -> f EnableMetricsCollection
enableMetricsCollection_metrics = (EnableMetricsCollection -> Maybe [Text])
-> (EnableMetricsCollection
    -> Maybe [Text] -> EnableMetricsCollection)
-> Lens
     EnableMetricsCollection
     EnableMetricsCollection
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnableMetricsCollection' {Maybe [Text]
metrics :: Maybe [Text]
$sel:metrics:EnableMetricsCollection' :: EnableMetricsCollection -> Maybe [Text]
metrics} -> Maybe [Text]
metrics) (\s :: EnableMetricsCollection
s@EnableMetricsCollection' {} Maybe [Text]
a -> EnableMetricsCollection
s {$sel:metrics:EnableMetricsCollection' :: Maybe [Text]
metrics = Maybe [Text]
a} :: EnableMetricsCollection) ((Maybe [Text] -> f (Maybe [Text]))
 -> EnableMetricsCollection -> f EnableMetricsCollection)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> EnableMetricsCollection
-> f EnableMetricsCollection
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of the Auto Scaling group.
enableMetricsCollection_autoScalingGroupName :: Lens.Lens' EnableMetricsCollection Prelude.Text
enableMetricsCollection_autoScalingGroupName :: (Text -> f Text)
-> EnableMetricsCollection -> f EnableMetricsCollection
enableMetricsCollection_autoScalingGroupName = (EnableMetricsCollection -> Text)
-> (EnableMetricsCollection -> Text -> EnableMetricsCollection)
-> Lens EnableMetricsCollection EnableMetricsCollection Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnableMetricsCollection' {Text
autoScalingGroupName :: Text
$sel:autoScalingGroupName:EnableMetricsCollection' :: EnableMetricsCollection -> Text
autoScalingGroupName} -> Text
autoScalingGroupName) (\s :: EnableMetricsCollection
s@EnableMetricsCollection' {} Text
a -> EnableMetricsCollection
s {$sel:autoScalingGroupName:EnableMetricsCollection' :: Text
autoScalingGroupName = Text
a} :: EnableMetricsCollection)

-- | The granularity to associate with the metrics to collect. The only valid
-- value is @1Minute@.
enableMetricsCollection_granularity :: Lens.Lens' EnableMetricsCollection Prelude.Text
enableMetricsCollection_granularity :: (Text -> f Text)
-> EnableMetricsCollection -> f EnableMetricsCollection
enableMetricsCollection_granularity = (EnableMetricsCollection -> Text)
-> (EnableMetricsCollection -> Text -> EnableMetricsCollection)
-> Lens EnableMetricsCollection EnableMetricsCollection Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnableMetricsCollection' {Text
granularity :: Text
$sel:granularity:EnableMetricsCollection' :: EnableMetricsCollection -> Text
granularity} -> Text
granularity) (\s :: EnableMetricsCollection
s@EnableMetricsCollection' {} Text
a -> EnableMetricsCollection
s {$sel:granularity:EnableMetricsCollection' :: Text
granularity = Text
a} :: EnableMetricsCollection)

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

instance Prelude.Hashable EnableMetricsCollection

instance Prelude.NFData EnableMetricsCollection

instance Core.ToHeaders EnableMetricsCollection where
  toHeaders :: EnableMetricsCollection -> [Header]
toHeaders = [Header] -> EnableMetricsCollection -> [Header]
forall a b. a -> b -> a
Prelude.const [Header]
forall a. Monoid a => a
Prelude.mempty

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

instance Core.ToQuery EnableMetricsCollection where
  toQuery :: EnableMetricsCollection -> QueryString
toQuery EnableMetricsCollection' {Maybe [Text]
Text
granularity :: Text
autoScalingGroupName :: Text
metrics :: Maybe [Text]
$sel:granularity:EnableMetricsCollection' :: EnableMetricsCollection -> Text
$sel:autoScalingGroupName:EnableMetricsCollection' :: EnableMetricsCollection -> Text
$sel:metrics:EnableMetricsCollection' :: EnableMetricsCollection -> Maybe [Text]
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"EnableMetricsCollection" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2011-01-01" :: Prelude.ByteString),
        ByteString
"Metrics"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe QueryString -> QueryString
forall a. ToQuery a => a -> QueryString
Core.toQuery
            (ByteString -> [Text] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"member" ([Text] -> QueryString) -> Maybe [Text] -> Maybe QueryString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
metrics),
        ByteString
"AutoScalingGroupName" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
autoScalingGroupName,
        ByteString
"Granularity" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
granularity
      ]

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

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

instance
  Prelude.NFData
    EnableMetricsCollectionResponse