{-# 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.DescribeMetricCollectionTypes
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Describes the available CloudWatch metrics for Amazon EC2 Auto Scaling.
module Amazonka.AutoScaling.DescribeMetricCollectionTypes
  ( -- * Creating a Request
    DescribeMetricCollectionTypes (..),
    newDescribeMetricCollectionTypes,

    -- * Destructuring the Response
    DescribeMetricCollectionTypesResponse (..),
    newDescribeMetricCollectionTypesResponse,

    -- * Response Lenses
    describeMetricCollectionTypesResponse_granularities,
    describeMetricCollectionTypesResponse_metrics,
    describeMetricCollectionTypesResponse_httpStatus,
  )
where

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

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

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

instance
  Core.AWSRequest
    DescribeMetricCollectionTypes
  where
  type
    AWSResponse DescribeMetricCollectionTypes =
      DescribeMetricCollectionTypesResponse
  request :: (Service -> Service)
-> DescribeMetricCollectionTypes
-> Request DescribeMetricCollectionTypes
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.postQuery (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DescribeMetricCollectionTypes
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeMetricCollectionTypes)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"DescribeMetricCollectionTypesResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe [MetricGranularityType]
-> Maybe [MetricCollectionType]
-> Int
-> DescribeMetricCollectionTypesResponse
DescribeMetricCollectionTypesResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( [Node]
x
                            forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"Granularities"
                            forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                            forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (forall a. FromXML a => Text -> [Node] -> Either String [a]
Data.parseXMLList Text
"member")
                        )
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x
                            forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"Metrics"
                            forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                            forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (forall a. FromXML a => Text -> [Node] -> Either String [a]
Data.parseXMLList Text
"member")
                        )
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance
  Prelude.Hashable
    DescribeMetricCollectionTypes
  where
  hashWithSalt :: Int -> DescribeMetricCollectionTypes -> Int
hashWithSalt Int
_salt DescribeMetricCollectionTypes
_ =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ()

instance Prelude.NFData DescribeMetricCollectionTypes where
  rnf :: DescribeMetricCollectionTypes -> ()
rnf DescribeMetricCollectionTypes
_ = ()

instance Data.ToHeaders DescribeMetricCollectionTypes where
  toHeaders :: DescribeMetricCollectionTypes -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

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

instance Data.ToQuery DescribeMetricCollectionTypes where
  toQuery :: DescribeMetricCollectionTypes -> QueryString
toQuery =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ ByteString
"Action"
              forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: ( ByteString
"DescribeMetricCollectionTypes" ::
                          Prelude.ByteString
                      ),
            ByteString
"Version"
              forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2011-01-01" :: Prelude.ByteString)
          ]
      )

-- | /See:/ 'newDescribeMetricCollectionTypesResponse' smart constructor.
data DescribeMetricCollectionTypesResponse = DescribeMetricCollectionTypesResponse'
  { -- | The granularities for the metrics.
    DescribeMetricCollectionTypesResponse
-> Maybe [MetricGranularityType]
granularities :: Prelude.Maybe [MetricGranularityType],
    -- | The metrics.
    DescribeMetricCollectionTypesResponse
-> Maybe [MetricCollectionType]
metrics :: Prelude.Maybe [MetricCollectionType],
    -- | The response's http status code.
    DescribeMetricCollectionTypesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeMetricCollectionTypesResponse
-> DescribeMetricCollectionTypesResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeMetricCollectionTypesResponse
-> DescribeMetricCollectionTypesResponse -> Bool
$c/= :: DescribeMetricCollectionTypesResponse
-> DescribeMetricCollectionTypesResponse -> Bool
== :: DescribeMetricCollectionTypesResponse
-> DescribeMetricCollectionTypesResponse -> Bool
$c== :: DescribeMetricCollectionTypesResponse
-> DescribeMetricCollectionTypesResponse -> Bool
Prelude.Eq, ReadPrec [DescribeMetricCollectionTypesResponse]
ReadPrec DescribeMetricCollectionTypesResponse
Int -> ReadS DescribeMetricCollectionTypesResponse
ReadS [DescribeMetricCollectionTypesResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeMetricCollectionTypesResponse]
$creadListPrec :: ReadPrec [DescribeMetricCollectionTypesResponse]
readPrec :: ReadPrec DescribeMetricCollectionTypesResponse
$creadPrec :: ReadPrec DescribeMetricCollectionTypesResponse
readList :: ReadS [DescribeMetricCollectionTypesResponse]
$creadList :: ReadS [DescribeMetricCollectionTypesResponse]
readsPrec :: Int -> ReadS DescribeMetricCollectionTypesResponse
$creadsPrec :: Int -> ReadS DescribeMetricCollectionTypesResponse
Prelude.Read, Int -> DescribeMetricCollectionTypesResponse -> ShowS
[DescribeMetricCollectionTypesResponse] -> ShowS
DescribeMetricCollectionTypesResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeMetricCollectionTypesResponse] -> ShowS
$cshowList :: [DescribeMetricCollectionTypesResponse] -> ShowS
show :: DescribeMetricCollectionTypesResponse -> String
$cshow :: DescribeMetricCollectionTypesResponse -> String
showsPrec :: Int -> DescribeMetricCollectionTypesResponse -> ShowS
$cshowsPrec :: Int -> DescribeMetricCollectionTypesResponse -> ShowS
Prelude.Show, forall x.
Rep DescribeMetricCollectionTypesResponse x
-> DescribeMetricCollectionTypesResponse
forall x.
DescribeMetricCollectionTypesResponse
-> Rep DescribeMetricCollectionTypesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeMetricCollectionTypesResponse x
-> DescribeMetricCollectionTypesResponse
$cfrom :: forall x.
DescribeMetricCollectionTypesResponse
-> Rep DescribeMetricCollectionTypesResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeMetricCollectionTypesResponse' 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:
--
-- 'granularities', 'describeMetricCollectionTypesResponse_granularities' - The granularities for the metrics.
--
-- 'metrics', 'describeMetricCollectionTypesResponse_metrics' - The metrics.
--
-- 'httpStatus', 'describeMetricCollectionTypesResponse_httpStatus' - The response's http status code.
newDescribeMetricCollectionTypesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeMetricCollectionTypesResponse
newDescribeMetricCollectionTypesResponse :: Int -> DescribeMetricCollectionTypesResponse
newDescribeMetricCollectionTypesResponse Int
pHttpStatus_ =
  DescribeMetricCollectionTypesResponse'
    { $sel:granularities:DescribeMetricCollectionTypesResponse' :: Maybe [MetricGranularityType]
granularities =
        forall a. Maybe a
Prelude.Nothing,
      $sel:metrics:DescribeMetricCollectionTypesResponse' :: Maybe [MetricCollectionType]
metrics = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeMetricCollectionTypesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The granularities for the metrics.
describeMetricCollectionTypesResponse_granularities :: Lens.Lens' DescribeMetricCollectionTypesResponse (Prelude.Maybe [MetricGranularityType])
describeMetricCollectionTypesResponse_granularities :: Lens'
  DescribeMetricCollectionTypesResponse
  (Maybe [MetricGranularityType])
describeMetricCollectionTypesResponse_granularities = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeMetricCollectionTypesResponse' {Maybe [MetricGranularityType]
granularities :: Maybe [MetricGranularityType]
$sel:granularities:DescribeMetricCollectionTypesResponse' :: DescribeMetricCollectionTypesResponse
-> Maybe [MetricGranularityType]
granularities} -> Maybe [MetricGranularityType]
granularities) (\s :: DescribeMetricCollectionTypesResponse
s@DescribeMetricCollectionTypesResponse' {} Maybe [MetricGranularityType]
a -> DescribeMetricCollectionTypesResponse
s {$sel:granularities:DescribeMetricCollectionTypesResponse' :: Maybe [MetricGranularityType]
granularities = Maybe [MetricGranularityType]
a} :: DescribeMetricCollectionTypesResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The metrics.
describeMetricCollectionTypesResponse_metrics :: Lens.Lens' DescribeMetricCollectionTypesResponse (Prelude.Maybe [MetricCollectionType])
describeMetricCollectionTypesResponse_metrics :: Lens'
  DescribeMetricCollectionTypesResponse
  (Maybe [MetricCollectionType])
describeMetricCollectionTypesResponse_metrics = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeMetricCollectionTypesResponse' {Maybe [MetricCollectionType]
metrics :: Maybe [MetricCollectionType]
$sel:metrics:DescribeMetricCollectionTypesResponse' :: DescribeMetricCollectionTypesResponse
-> Maybe [MetricCollectionType]
metrics} -> Maybe [MetricCollectionType]
metrics) (\s :: DescribeMetricCollectionTypesResponse
s@DescribeMetricCollectionTypesResponse' {} Maybe [MetricCollectionType]
a -> DescribeMetricCollectionTypesResponse
s {$sel:metrics:DescribeMetricCollectionTypesResponse' :: Maybe [MetricCollectionType]
metrics = Maybe [MetricCollectionType]
a} :: DescribeMetricCollectionTypesResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The response's http status code.
describeMetricCollectionTypesResponse_httpStatus :: Lens.Lens' DescribeMetricCollectionTypesResponse Prelude.Int
describeMetricCollectionTypesResponse_httpStatus :: Lens' DescribeMetricCollectionTypesResponse Int
describeMetricCollectionTypesResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeMetricCollectionTypesResponse' {Int
httpStatus :: Int
$sel:httpStatus:DescribeMetricCollectionTypesResponse' :: DescribeMetricCollectionTypesResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: DescribeMetricCollectionTypesResponse
s@DescribeMetricCollectionTypesResponse' {} Int
a -> DescribeMetricCollectionTypesResponse
s {$sel:httpStatus:DescribeMetricCollectionTypesResponse' :: Int
httpStatus = Int
a} :: DescribeMetricCollectionTypesResponse)

instance
  Prelude.NFData
    DescribeMetricCollectionTypesResponse
  where
  rnf :: DescribeMetricCollectionTypesResponse -> ()
rnf DescribeMetricCollectionTypesResponse' {Int
Maybe [MetricCollectionType]
Maybe [MetricGranularityType]
httpStatus :: Int
metrics :: Maybe [MetricCollectionType]
granularities :: Maybe [MetricGranularityType]
$sel:httpStatus:DescribeMetricCollectionTypesResponse' :: DescribeMetricCollectionTypesResponse -> Int
$sel:metrics:DescribeMetricCollectionTypesResponse' :: DescribeMetricCollectionTypesResponse
-> Maybe [MetricCollectionType]
$sel:granularities:DescribeMetricCollectionTypesResponse' :: DescribeMetricCollectionTypesResponse
-> Maybe [MetricGranularityType]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [MetricGranularityType]
granularities
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [MetricCollectionType]
metrics
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus