{-# 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.LookoutMetrics.ActivateAnomalyDetector
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Activates an anomaly detector.
module Amazonka.LookoutMetrics.ActivateAnomalyDetector
  ( -- * Creating a Request
    ActivateAnomalyDetector (..),
    newActivateAnomalyDetector,

    -- * Request Lenses
    activateAnomalyDetector_anomalyDetectorArn,

    -- * Destructuring the Response
    ActivateAnomalyDetectorResponse (..),
    newActivateAnomalyDetectorResponse,

    -- * Response Lenses
    activateAnomalyDetectorResponse_httpStatus,
  )
where

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

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

-- |
-- Create a value of 'ActivateAnomalyDetector' 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:
--
-- 'anomalyDetectorArn', 'activateAnomalyDetector_anomalyDetectorArn' - The ARN of the anomaly detector.
newActivateAnomalyDetector ::
  -- | 'anomalyDetectorArn'
  Prelude.Text ->
  ActivateAnomalyDetector
newActivateAnomalyDetector :: Text -> ActivateAnomalyDetector
newActivateAnomalyDetector Text
pAnomalyDetectorArn_ =
  ActivateAnomalyDetector'
    { $sel:anomalyDetectorArn:ActivateAnomalyDetector' :: Text
anomalyDetectorArn =
        Text
pAnomalyDetectorArn_
    }

-- | The ARN of the anomaly detector.
activateAnomalyDetector_anomalyDetectorArn :: Lens.Lens' ActivateAnomalyDetector Prelude.Text
activateAnomalyDetector_anomalyDetectorArn :: Lens' ActivateAnomalyDetector Text
activateAnomalyDetector_anomalyDetectorArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ActivateAnomalyDetector' {Text
anomalyDetectorArn :: Text
$sel:anomalyDetectorArn:ActivateAnomalyDetector' :: ActivateAnomalyDetector -> Text
anomalyDetectorArn} -> Text
anomalyDetectorArn) (\s :: ActivateAnomalyDetector
s@ActivateAnomalyDetector' {} Text
a -> ActivateAnomalyDetector
s {$sel:anomalyDetectorArn:ActivateAnomalyDetector' :: Text
anomalyDetectorArn = Text
a} :: ActivateAnomalyDetector)

instance Core.AWSRequest ActivateAnomalyDetector where
  type
    AWSResponse ActivateAnomalyDetector =
      ActivateAnomalyDetectorResponse
  request :: (Service -> Service)
-> ActivateAnomalyDetector -> Request ActivateAnomalyDetector
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ActivateAnomalyDetector
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ActivateAnomalyDetector)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> ActivateAnomalyDetectorResponse
ActivateAnomalyDetectorResponse'
            forall (f :: * -> *) a b. Functor 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 ActivateAnomalyDetector where
  hashWithSalt :: Int -> ActivateAnomalyDetector -> Int
hashWithSalt Int
_salt ActivateAnomalyDetector' {Text
anomalyDetectorArn :: Text
$sel:anomalyDetectorArn:ActivateAnomalyDetector' :: ActivateAnomalyDetector -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
anomalyDetectorArn

instance Prelude.NFData ActivateAnomalyDetector where
  rnf :: ActivateAnomalyDetector -> ()
rnf ActivateAnomalyDetector' {Text
anomalyDetectorArn :: Text
$sel:anomalyDetectorArn:ActivateAnomalyDetector' :: ActivateAnomalyDetector -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
anomalyDetectorArn

instance Data.ToHeaders ActivateAnomalyDetector where
  toHeaders :: ActivateAnomalyDetector -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON ActivateAnomalyDetector where
  toJSON :: ActivateAnomalyDetector -> Value
toJSON ActivateAnomalyDetector' {Text
anomalyDetectorArn :: Text
$sel:anomalyDetectorArn:ActivateAnomalyDetector' :: ActivateAnomalyDetector -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"AnomalyDetectorArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
anomalyDetectorArn)
          ]
      )

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

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

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

-- |
-- Create a value of 'ActivateAnomalyDetectorResponse' 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:
--
-- 'httpStatus', 'activateAnomalyDetectorResponse_httpStatus' - The response's http status code.
newActivateAnomalyDetectorResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ActivateAnomalyDetectorResponse
newActivateAnomalyDetectorResponse :: Int -> ActivateAnomalyDetectorResponse
newActivateAnomalyDetectorResponse Int
pHttpStatus_ =
  ActivateAnomalyDetectorResponse'
    { $sel:httpStatus:ActivateAnomalyDetectorResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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

instance
  Prelude.NFData
    ActivateAnomalyDetectorResponse
  where
  rnf :: ActivateAnomalyDetectorResponse -> ()
rnf ActivateAnomalyDetectorResponse' {Int
httpStatus :: Int
$sel:httpStatus:ActivateAnomalyDetectorResponse' :: ActivateAnomalyDetectorResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus