{-# 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.IoT.CreateFleetMetric
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Creates a fleet metric.
--
-- Requires permission to access the
-- <https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiot.html#awsiot-actions-as-permissions CreateFleetMetric>
-- action.
module Amazonka.IoT.CreateFleetMetric
  ( -- * Creating a Request
    CreateFleetMetric (..),
    newCreateFleetMetric,

    -- * Request Lenses
    createFleetMetric_description,
    createFleetMetric_indexName,
    createFleetMetric_queryVersion,
    createFleetMetric_tags,
    createFleetMetric_unit,
    createFleetMetric_metricName,
    createFleetMetric_queryString,
    createFleetMetric_aggregationType,
    createFleetMetric_period,
    createFleetMetric_aggregationField,

    -- * Destructuring the Response
    CreateFleetMetricResponse (..),
    newCreateFleetMetricResponse,

    -- * Response Lenses
    createFleetMetricResponse_metricArn,
    createFleetMetricResponse_metricName,
    createFleetMetricResponse_httpStatus,
  )
where

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

-- | /See:/ 'newCreateFleetMetric' smart constructor.
data CreateFleetMetric = CreateFleetMetric'
  { -- | The fleet metric description.
    CreateFleetMetric -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The name of the index to search.
    CreateFleetMetric -> Maybe Text
indexName :: Prelude.Maybe Prelude.Text,
    -- | The query version.
    CreateFleetMetric -> Maybe Text
queryVersion :: Prelude.Maybe Prelude.Text,
    -- | Metadata, which can be used to manage the fleet metric.
    CreateFleetMetric -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
    -- | Used to support unit transformation such as milliseconds to seconds. The
    -- unit must be supported by
    -- <https://docs.aws.amazon.com/https:/docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_MetricDatum.html CW metric>.
    -- Default to null.
    CreateFleetMetric -> Maybe FleetMetricUnit
unit :: Prelude.Maybe FleetMetricUnit,
    -- | The name of the fleet metric to create.
    CreateFleetMetric -> Text
metricName :: Prelude.Text,
    -- | The search query string.
    CreateFleetMetric -> Text
queryString :: Prelude.Text,
    -- | The type of the aggregation query.
    CreateFleetMetric -> AggregationType
aggregationType :: AggregationType,
    -- | The time in seconds between fleet metric emissions. Range [60(1 min),
    -- 86400(1 day)] and must be multiple of 60.
    CreateFleetMetric -> Natural
period :: Prelude.Natural,
    -- | The field to aggregate.
    CreateFleetMetric -> Text
aggregationField :: Prelude.Text
  }
  deriving (CreateFleetMetric -> CreateFleetMetric -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateFleetMetric -> CreateFleetMetric -> Bool
$c/= :: CreateFleetMetric -> CreateFleetMetric -> Bool
== :: CreateFleetMetric -> CreateFleetMetric -> Bool
$c== :: CreateFleetMetric -> CreateFleetMetric -> Bool
Prelude.Eq, ReadPrec [CreateFleetMetric]
ReadPrec CreateFleetMetric
Int -> ReadS CreateFleetMetric
ReadS [CreateFleetMetric]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateFleetMetric]
$creadListPrec :: ReadPrec [CreateFleetMetric]
readPrec :: ReadPrec CreateFleetMetric
$creadPrec :: ReadPrec CreateFleetMetric
readList :: ReadS [CreateFleetMetric]
$creadList :: ReadS [CreateFleetMetric]
readsPrec :: Int -> ReadS CreateFleetMetric
$creadsPrec :: Int -> ReadS CreateFleetMetric
Prelude.Read, Int -> CreateFleetMetric -> ShowS
[CreateFleetMetric] -> ShowS
CreateFleetMetric -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateFleetMetric] -> ShowS
$cshowList :: [CreateFleetMetric] -> ShowS
show :: CreateFleetMetric -> String
$cshow :: CreateFleetMetric -> String
showsPrec :: Int -> CreateFleetMetric -> ShowS
$cshowsPrec :: Int -> CreateFleetMetric -> ShowS
Prelude.Show, forall x. Rep CreateFleetMetric x -> CreateFleetMetric
forall x. CreateFleetMetric -> Rep CreateFleetMetric x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateFleetMetric x -> CreateFleetMetric
$cfrom :: forall x. CreateFleetMetric -> Rep CreateFleetMetric x
Prelude.Generic)

-- |
-- Create a value of 'CreateFleetMetric' 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:
--
-- 'description', 'createFleetMetric_description' - The fleet metric description.
--
-- 'indexName', 'createFleetMetric_indexName' - The name of the index to search.
--
-- 'queryVersion', 'createFleetMetric_queryVersion' - The query version.
--
-- 'tags', 'createFleetMetric_tags' - Metadata, which can be used to manage the fleet metric.
--
-- 'unit', 'createFleetMetric_unit' - Used to support unit transformation such as milliseconds to seconds. The
-- unit must be supported by
-- <https://docs.aws.amazon.com/https:/docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_MetricDatum.html CW metric>.
-- Default to null.
--
-- 'metricName', 'createFleetMetric_metricName' - The name of the fleet metric to create.
--
-- 'queryString', 'createFleetMetric_queryString' - The search query string.
--
-- 'aggregationType', 'createFleetMetric_aggregationType' - The type of the aggregation query.
--
-- 'period', 'createFleetMetric_period' - The time in seconds between fleet metric emissions. Range [60(1 min),
-- 86400(1 day)] and must be multiple of 60.
--
-- 'aggregationField', 'createFleetMetric_aggregationField' - The field to aggregate.
newCreateFleetMetric ::
  -- | 'metricName'
  Prelude.Text ->
  -- | 'queryString'
  Prelude.Text ->
  -- | 'aggregationType'
  AggregationType ->
  -- | 'period'
  Prelude.Natural ->
  -- | 'aggregationField'
  Prelude.Text ->
  CreateFleetMetric
newCreateFleetMetric :: Text
-> Text -> AggregationType -> Natural -> Text -> CreateFleetMetric
newCreateFleetMetric
  Text
pMetricName_
  Text
pQueryString_
  AggregationType
pAggregationType_
  Natural
pPeriod_
  Text
pAggregationField_ =
    CreateFleetMetric'
      { $sel:description:CreateFleetMetric' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
        $sel:indexName:CreateFleetMetric' :: Maybe Text
indexName = forall a. Maybe a
Prelude.Nothing,
        $sel:queryVersion:CreateFleetMetric' :: Maybe Text
queryVersion = forall a. Maybe a
Prelude.Nothing,
        $sel:tags:CreateFleetMetric' :: Maybe [Tag]
tags = forall a. Maybe a
Prelude.Nothing,
        $sel:unit:CreateFleetMetric' :: Maybe FleetMetricUnit
unit = forall a. Maybe a
Prelude.Nothing,
        $sel:metricName:CreateFleetMetric' :: Text
metricName = Text
pMetricName_,
        $sel:queryString:CreateFleetMetric' :: Text
queryString = Text
pQueryString_,
        $sel:aggregationType:CreateFleetMetric' :: AggregationType
aggregationType = AggregationType
pAggregationType_,
        $sel:period:CreateFleetMetric' :: Natural
period = Natural
pPeriod_,
        $sel:aggregationField:CreateFleetMetric' :: Text
aggregationField = Text
pAggregationField_
      }

-- | The fleet metric description.
createFleetMetric_description :: Lens.Lens' CreateFleetMetric (Prelude.Maybe Prelude.Text)
createFleetMetric_description :: Lens' CreateFleetMetric (Maybe Text)
createFleetMetric_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateFleetMetric' {Maybe Text
description :: Maybe Text
$sel:description:CreateFleetMetric' :: CreateFleetMetric -> Maybe Text
description} -> Maybe Text
description) (\s :: CreateFleetMetric
s@CreateFleetMetric' {} Maybe Text
a -> CreateFleetMetric
s {$sel:description:CreateFleetMetric' :: Maybe Text
description = Maybe Text
a} :: CreateFleetMetric)

-- | The name of the index to search.
createFleetMetric_indexName :: Lens.Lens' CreateFleetMetric (Prelude.Maybe Prelude.Text)
createFleetMetric_indexName :: Lens' CreateFleetMetric (Maybe Text)
createFleetMetric_indexName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateFleetMetric' {Maybe Text
indexName :: Maybe Text
$sel:indexName:CreateFleetMetric' :: CreateFleetMetric -> Maybe Text
indexName} -> Maybe Text
indexName) (\s :: CreateFleetMetric
s@CreateFleetMetric' {} Maybe Text
a -> CreateFleetMetric
s {$sel:indexName:CreateFleetMetric' :: Maybe Text
indexName = Maybe Text
a} :: CreateFleetMetric)

-- | The query version.
createFleetMetric_queryVersion :: Lens.Lens' CreateFleetMetric (Prelude.Maybe Prelude.Text)
createFleetMetric_queryVersion :: Lens' CreateFleetMetric (Maybe Text)
createFleetMetric_queryVersion = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateFleetMetric' {Maybe Text
queryVersion :: Maybe Text
$sel:queryVersion:CreateFleetMetric' :: CreateFleetMetric -> Maybe Text
queryVersion} -> Maybe Text
queryVersion) (\s :: CreateFleetMetric
s@CreateFleetMetric' {} Maybe Text
a -> CreateFleetMetric
s {$sel:queryVersion:CreateFleetMetric' :: Maybe Text
queryVersion = Maybe Text
a} :: CreateFleetMetric)

-- | Metadata, which can be used to manage the fleet metric.
createFleetMetric_tags :: Lens.Lens' CreateFleetMetric (Prelude.Maybe [Tag])
createFleetMetric_tags :: Lens' CreateFleetMetric (Maybe [Tag])
createFleetMetric_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateFleetMetric' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:CreateFleetMetric' :: CreateFleetMetric -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: CreateFleetMetric
s@CreateFleetMetric' {} Maybe [Tag]
a -> CreateFleetMetric
s {$sel:tags:CreateFleetMetric' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: CreateFleetMetric) 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

-- | Used to support unit transformation such as milliseconds to seconds. The
-- unit must be supported by
-- <https://docs.aws.amazon.com/https:/docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_MetricDatum.html CW metric>.
-- Default to null.
createFleetMetric_unit :: Lens.Lens' CreateFleetMetric (Prelude.Maybe FleetMetricUnit)
createFleetMetric_unit :: Lens' CreateFleetMetric (Maybe FleetMetricUnit)
createFleetMetric_unit = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateFleetMetric' {Maybe FleetMetricUnit
unit :: Maybe FleetMetricUnit
$sel:unit:CreateFleetMetric' :: CreateFleetMetric -> Maybe FleetMetricUnit
unit} -> Maybe FleetMetricUnit
unit) (\s :: CreateFleetMetric
s@CreateFleetMetric' {} Maybe FleetMetricUnit
a -> CreateFleetMetric
s {$sel:unit:CreateFleetMetric' :: Maybe FleetMetricUnit
unit = Maybe FleetMetricUnit
a} :: CreateFleetMetric)

-- | The name of the fleet metric to create.
createFleetMetric_metricName :: Lens.Lens' CreateFleetMetric Prelude.Text
createFleetMetric_metricName :: Lens' CreateFleetMetric Text
createFleetMetric_metricName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateFleetMetric' {Text
metricName :: Text
$sel:metricName:CreateFleetMetric' :: CreateFleetMetric -> Text
metricName} -> Text
metricName) (\s :: CreateFleetMetric
s@CreateFleetMetric' {} Text
a -> CreateFleetMetric
s {$sel:metricName:CreateFleetMetric' :: Text
metricName = Text
a} :: CreateFleetMetric)

-- | The search query string.
createFleetMetric_queryString :: Lens.Lens' CreateFleetMetric Prelude.Text
createFleetMetric_queryString :: Lens' CreateFleetMetric Text
createFleetMetric_queryString = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateFleetMetric' {Text
queryString :: Text
$sel:queryString:CreateFleetMetric' :: CreateFleetMetric -> Text
queryString} -> Text
queryString) (\s :: CreateFleetMetric
s@CreateFleetMetric' {} Text
a -> CreateFleetMetric
s {$sel:queryString:CreateFleetMetric' :: Text
queryString = Text
a} :: CreateFleetMetric)

-- | The type of the aggregation query.
createFleetMetric_aggregationType :: Lens.Lens' CreateFleetMetric AggregationType
createFleetMetric_aggregationType :: Lens' CreateFleetMetric AggregationType
createFleetMetric_aggregationType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateFleetMetric' {AggregationType
aggregationType :: AggregationType
$sel:aggregationType:CreateFleetMetric' :: CreateFleetMetric -> AggregationType
aggregationType} -> AggregationType
aggregationType) (\s :: CreateFleetMetric
s@CreateFleetMetric' {} AggregationType
a -> CreateFleetMetric
s {$sel:aggregationType:CreateFleetMetric' :: AggregationType
aggregationType = AggregationType
a} :: CreateFleetMetric)

-- | The time in seconds between fleet metric emissions. Range [60(1 min),
-- 86400(1 day)] and must be multiple of 60.
createFleetMetric_period :: Lens.Lens' CreateFleetMetric Prelude.Natural
createFleetMetric_period :: Lens' CreateFleetMetric Natural
createFleetMetric_period = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateFleetMetric' {Natural
period :: Natural
$sel:period:CreateFleetMetric' :: CreateFleetMetric -> Natural
period} -> Natural
period) (\s :: CreateFleetMetric
s@CreateFleetMetric' {} Natural
a -> CreateFleetMetric
s {$sel:period:CreateFleetMetric' :: Natural
period = Natural
a} :: CreateFleetMetric)

-- | The field to aggregate.
createFleetMetric_aggregationField :: Lens.Lens' CreateFleetMetric Prelude.Text
createFleetMetric_aggregationField :: Lens' CreateFleetMetric Text
createFleetMetric_aggregationField = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateFleetMetric' {Text
aggregationField :: Text
$sel:aggregationField:CreateFleetMetric' :: CreateFleetMetric -> Text
aggregationField} -> Text
aggregationField) (\s :: CreateFleetMetric
s@CreateFleetMetric' {} Text
a -> CreateFleetMetric
s {$sel:aggregationField:CreateFleetMetric' :: Text
aggregationField = Text
a} :: CreateFleetMetric)

instance Core.AWSRequest CreateFleetMetric where
  type
    AWSResponse CreateFleetMetric =
      CreateFleetMetricResponse
  request :: (Service -> Service)
-> CreateFleetMetric -> Request CreateFleetMetric
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy CreateFleetMetric
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateFleetMetric)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text -> Maybe Text -> Int -> CreateFleetMetricResponse
CreateFleetMetricResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"metricArn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"metricName")
            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 CreateFleetMetric where
  hashWithSalt :: Int -> CreateFleetMetric -> Int
hashWithSalt Int
_salt CreateFleetMetric' {Natural
Maybe [Tag]
Maybe Text
Maybe FleetMetricUnit
Text
AggregationType
aggregationField :: Text
period :: Natural
aggregationType :: AggregationType
queryString :: Text
metricName :: Text
unit :: Maybe FleetMetricUnit
tags :: Maybe [Tag]
queryVersion :: Maybe Text
indexName :: Maybe Text
description :: Maybe Text
$sel:aggregationField:CreateFleetMetric' :: CreateFleetMetric -> Text
$sel:period:CreateFleetMetric' :: CreateFleetMetric -> Natural
$sel:aggregationType:CreateFleetMetric' :: CreateFleetMetric -> AggregationType
$sel:queryString:CreateFleetMetric' :: CreateFleetMetric -> Text
$sel:metricName:CreateFleetMetric' :: CreateFleetMetric -> Text
$sel:unit:CreateFleetMetric' :: CreateFleetMetric -> Maybe FleetMetricUnit
$sel:tags:CreateFleetMetric' :: CreateFleetMetric -> Maybe [Tag]
$sel:queryVersion:CreateFleetMetric' :: CreateFleetMetric -> Maybe Text
$sel:indexName:CreateFleetMetric' :: CreateFleetMetric -> Maybe Text
$sel:description:CreateFleetMetric' :: CreateFleetMetric -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
indexName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
queryVersion
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Tag]
tags
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe FleetMetricUnit
unit
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
metricName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
queryString
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` AggregationType
aggregationType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
period
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
aggregationField

instance Prelude.NFData CreateFleetMetric where
  rnf :: CreateFleetMetric -> ()
rnf CreateFleetMetric' {Natural
Maybe [Tag]
Maybe Text
Maybe FleetMetricUnit
Text
AggregationType
aggregationField :: Text
period :: Natural
aggregationType :: AggregationType
queryString :: Text
metricName :: Text
unit :: Maybe FleetMetricUnit
tags :: Maybe [Tag]
queryVersion :: Maybe Text
indexName :: Maybe Text
description :: Maybe Text
$sel:aggregationField:CreateFleetMetric' :: CreateFleetMetric -> Text
$sel:period:CreateFleetMetric' :: CreateFleetMetric -> Natural
$sel:aggregationType:CreateFleetMetric' :: CreateFleetMetric -> AggregationType
$sel:queryString:CreateFleetMetric' :: CreateFleetMetric -> Text
$sel:metricName:CreateFleetMetric' :: CreateFleetMetric -> Text
$sel:unit:CreateFleetMetric' :: CreateFleetMetric -> Maybe FleetMetricUnit
$sel:tags:CreateFleetMetric' :: CreateFleetMetric -> Maybe [Tag]
$sel:queryVersion:CreateFleetMetric' :: CreateFleetMetric -> Maybe Text
$sel:indexName:CreateFleetMetric' :: CreateFleetMetric -> Maybe Text
$sel:description:CreateFleetMetric' :: CreateFleetMetric -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
description
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
indexName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
queryVersion
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Tag]
tags
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe FleetMetricUnit
unit
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
metricName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
queryString
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf AggregationType
aggregationType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Natural
period
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
aggregationField

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

instance Data.ToJSON CreateFleetMetric where
  toJSON :: CreateFleetMetric -> Value
toJSON CreateFleetMetric' {Natural
Maybe [Tag]
Maybe Text
Maybe FleetMetricUnit
Text
AggregationType
aggregationField :: Text
period :: Natural
aggregationType :: AggregationType
queryString :: Text
metricName :: Text
unit :: Maybe FleetMetricUnit
tags :: Maybe [Tag]
queryVersion :: Maybe Text
indexName :: Maybe Text
description :: Maybe Text
$sel:aggregationField:CreateFleetMetric' :: CreateFleetMetric -> Text
$sel:period:CreateFleetMetric' :: CreateFleetMetric -> Natural
$sel:aggregationType:CreateFleetMetric' :: CreateFleetMetric -> AggregationType
$sel:queryString:CreateFleetMetric' :: CreateFleetMetric -> Text
$sel:metricName:CreateFleetMetric' :: CreateFleetMetric -> Text
$sel:unit:CreateFleetMetric' :: CreateFleetMetric -> Maybe FleetMetricUnit
$sel:tags:CreateFleetMetric' :: CreateFleetMetric -> Maybe [Tag]
$sel:queryVersion:CreateFleetMetric' :: CreateFleetMetric -> Maybe Text
$sel:indexName:CreateFleetMetric' :: CreateFleetMetric -> Maybe Text
$sel:description:CreateFleetMetric' :: CreateFleetMetric -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"description" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
description,
            (Key
"indexName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
indexName,
            (Key
"queryVersion" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
queryVersion,
            (Key
"tags" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Tag]
tags,
            (Key
"unit" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe FleetMetricUnit
unit,
            forall a. a -> Maybe a
Prelude.Just (Key
"queryString" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
queryString),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"aggregationType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= AggregationType
aggregationType),
            forall a. a -> Maybe a
Prelude.Just (Key
"period" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Natural
period),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"aggregationField" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
aggregationField)
          ]
      )

instance Data.ToPath CreateFleetMetric where
  toPath :: CreateFleetMetric -> ByteString
toPath CreateFleetMetric' {Natural
Maybe [Tag]
Maybe Text
Maybe FleetMetricUnit
Text
AggregationType
aggregationField :: Text
period :: Natural
aggregationType :: AggregationType
queryString :: Text
metricName :: Text
unit :: Maybe FleetMetricUnit
tags :: Maybe [Tag]
queryVersion :: Maybe Text
indexName :: Maybe Text
description :: Maybe Text
$sel:aggregationField:CreateFleetMetric' :: CreateFleetMetric -> Text
$sel:period:CreateFleetMetric' :: CreateFleetMetric -> Natural
$sel:aggregationType:CreateFleetMetric' :: CreateFleetMetric -> AggregationType
$sel:queryString:CreateFleetMetric' :: CreateFleetMetric -> Text
$sel:metricName:CreateFleetMetric' :: CreateFleetMetric -> Text
$sel:unit:CreateFleetMetric' :: CreateFleetMetric -> Maybe FleetMetricUnit
$sel:tags:CreateFleetMetric' :: CreateFleetMetric -> Maybe [Tag]
$sel:queryVersion:CreateFleetMetric' :: CreateFleetMetric -> Maybe Text
$sel:indexName:CreateFleetMetric' :: CreateFleetMetric -> Maybe Text
$sel:description:CreateFleetMetric' :: CreateFleetMetric -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/fleet-metric/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
metricName]

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

-- | /See:/ 'newCreateFleetMetricResponse' smart constructor.
data CreateFleetMetricResponse = CreateFleetMetricResponse'
  { -- | The Amazon Resource Name (ARN) of the new fleet metric.
    CreateFleetMetricResponse -> Maybe Text
metricArn :: Prelude.Maybe Prelude.Text,
    -- | The name of the fleet metric to create.
    CreateFleetMetricResponse -> Maybe Text
metricName :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    CreateFleetMetricResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateFleetMetricResponse -> CreateFleetMetricResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateFleetMetricResponse -> CreateFleetMetricResponse -> Bool
$c/= :: CreateFleetMetricResponse -> CreateFleetMetricResponse -> Bool
== :: CreateFleetMetricResponse -> CreateFleetMetricResponse -> Bool
$c== :: CreateFleetMetricResponse -> CreateFleetMetricResponse -> Bool
Prelude.Eq, ReadPrec [CreateFleetMetricResponse]
ReadPrec CreateFleetMetricResponse
Int -> ReadS CreateFleetMetricResponse
ReadS [CreateFleetMetricResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateFleetMetricResponse]
$creadListPrec :: ReadPrec [CreateFleetMetricResponse]
readPrec :: ReadPrec CreateFleetMetricResponse
$creadPrec :: ReadPrec CreateFleetMetricResponse
readList :: ReadS [CreateFleetMetricResponse]
$creadList :: ReadS [CreateFleetMetricResponse]
readsPrec :: Int -> ReadS CreateFleetMetricResponse
$creadsPrec :: Int -> ReadS CreateFleetMetricResponse
Prelude.Read, Int -> CreateFleetMetricResponse -> ShowS
[CreateFleetMetricResponse] -> ShowS
CreateFleetMetricResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateFleetMetricResponse] -> ShowS
$cshowList :: [CreateFleetMetricResponse] -> ShowS
show :: CreateFleetMetricResponse -> String
$cshow :: CreateFleetMetricResponse -> String
showsPrec :: Int -> CreateFleetMetricResponse -> ShowS
$cshowsPrec :: Int -> CreateFleetMetricResponse -> ShowS
Prelude.Show, forall x.
Rep CreateFleetMetricResponse x -> CreateFleetMetricResponse
forall x.
CreateFleetMetricResponse -> Rep CreateFleetMetricResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateFleetMetricResponse x -> CreateFleetMetricResponse
$cfrom :: forall x.
CreateFleetMetricResponse -> Rep CreateFleetMetricResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateFleetMetricResponse' 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:
--
-- 'metricArn', 'createFleetMetricResponse_metricArn' - The Amazon Resource Name (ARN) of the new fleet metric.
--
-- 'metricName', 'createFleetMetricResponse_metricName' - The name of the fleet metric to create.
--
-- 'httpStatus', 'createFleetMetricResponse_httpStatus' - The response's http status code.
newCreateFleetMetricResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateFleetMetricResponse
newCreateFleetMetricResponse :: Int -> CreateFleetMetricResponse
newCreateFleetMetricResponse Int
pHttpStatus_ =
  CreateFleetMetricResponse'
    { $sel:metricArn:CreateFleetMetricResponse' :: Maybe Text
metricArn =
        forall a. Maybe a
Prelude.Nothing,
      $sel:metricName:CreateFleetMetricResponse' :: Maybe Text
metricName = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateFleetMetricResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The Amazon Resource Name (ARN) of the new fleet metric.
createFleetMetricResponse_metricArn :: Lens.Lens' CreateFleetMetricResponse (Prelude.Maybe Prelude.Text)
createFleetMetricResponse_metricArn :: Lens' CreateFleetMetricResponse (Maybe Text)
createFleetMetricResponse_metricArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateFleetMetricResponse' {Maybe Text
metricArn :: Maybe Text
$sel:metricArn:CreateFleetMetricResponse' :: CreateFleetMetricResponse -> Maybe Text
metricArn} -> Maybe Text
metricArn) (\s :: CreateFleetMetricResponse
s@CreateFleetMetricResponse' {} Maybe Text
a -> CreateFleetMetricResponse
s {$sel:metricArn:CreateFleetMetricResponse' :: Maybe Text
metricArn = Maybe Text
a} :: CreateFleetMetricResponse)

-- | The name of the fleet metric to create.
createFleetMetricResponse_metricName :: Lens.Lens' CreateFleetMetricResponse (Prelude.Maybe Prelude.Text)
createFleetMetricResponse_metricName :: Lens' CreateFleetMetricResponse (Maybe Text)
createFleetMetricResponse_metricName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateFleetMetricResponse' {Maybe Text
metricName :: Maybe Text
$sel:metricName:CreateFleetMetricResponse' :: CreateFleetMetricResponse -> Maybe Text
metricName} -> Maybe Text
metricName) (\s :: CreateFleetMetricResponse
s@CreateFleetMetricResponse' {} Maybe Text
a -> CreateFleetMetricResponse
s {$sel:metricName:CreateFleetMetricResponse' :: Maybe Text
metricName = Maybe Text
a} :: CreateFleetMetricResponse)

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

instance Prelude.NFData CreateFleetMetricResponse where
  rnf :: CreateFleetMetricResponse -> ()
rnf CreateFleetMetricResponse' {Int
Maybe Text
httpStatus :: Int
metricName :: Maybe Text
metricArn :: Maybe Text
$sel:httpStatus:CreateFleetMetricResponse' :: CreateFleetMetricResponse -> Int
$sel:metricName:CreateFleetMetricResponse' :: CreateFleetMetricResponse -> Maybe Text
$sel:metricArn:CreateFleetMetricResponse' :: CreateFleetMetricResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
metricArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
metricName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus