{-# 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-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)
--
-- 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.Lens as Lens
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
(ActivateAnomalyDetector -> ActivateAnomalyDetector -> Bool)
-> (ActivateAnomalyDetector -> ActivateAnomalyDetector -> Bool)
-> Eq ActivateAnomalyDetector
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]
(Int -> ReadS ActivateAnomalyDetector)
-> ReadS [ActivateAnomalyDetector]
-> ReadPrec ActivateAnomalyDetector
-> ReadPrec [ActivateAnomalyDetector]
-> Read 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
(Int -> ActivateAnomalyDetector -> ShowS)
-> (ActivateAnomalyDetector -> String)
-> ([ActivateAnomalyDetector] -> ShowS)
-> Show ActivateAnomalyDetector
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.
 ActivateAnomalyDetector -> Rep ActivateAnomalyDetector x)
-> (forall x.
    Rep ActivateAnomalyDetector x -> ActivateAnomalyDetector)
-> Generic ActivateAnomalyDetector
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' :: Text -> ActivateAnomalyDetector
ActivateAnomalyDetector'
    { $sel:anomalyDetectorArn:ActivateAnomalyDetector' :: Text
anomalyDetectorArn =
        Text
pAnomalyDetectorArn_
    }

-- | The ARN of the anomaly detector.
activateAnomalyDetector_anomalyDetectorArn :: Lens.Lens' ActivateAnomalyDetector Prelude.Text
activateAnomalyDetector_anomalyDetectorArn :: (Text -> f Text)
-> ActivateAnomalyDetector -> f ActivateAnomalyDetector
activateAnomalyDetector_anomalyDetectorArn = (ActivateAnomalyDetector -> Text)
-> (ActivateAnomalyDetector -> Text -> ActivateAnomalyDetector)
-> Lens ActivateAnomalyDetector ActivateAnomalyDetector Text Text
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 :: ActivateAnomalyDetector -> Request ActivateAnomalyDetector
request = Service
-> ActivateAnomalyDetector -> Request ActivateAnomalyDetector
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy ActivateAnomalyDetector
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ActivateAnomalyDetector)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse ActivateAnomalyDetector))
-> Logger
-> Service
-> Proxy ActivateAnomalyDetector
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ActivateAnomalyDetector)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> ActivateAnomalyDetectorResponse
ActivateAnomalyDetectorResponse'
            (Int -> ActivateAnomalyDetectorResponse)
-> Either String Int
-> Either String ActivateAnomalyDetectorResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable ActivateAnomalyDetector

instance Prelude.NFData ActivateAnomalyDetector

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

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

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

instance Core.ToQuery ActivateAnomalyDetector where
  toQuery :: ActivateAnomalyDetector -> QueryString
toQuery = QueryString -> ActivateAnomalyDetector -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(ActivateAnomalyDetectorResponse
 -> ActivateAnomalyDetectorResponse -> Bool)
-> (ActivateAnomalyDetectorResponse
    -> ActivateAnomalyDetectorResponse -> Bool)
-> Eq ActivateAnomalyDetectorResponse
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]
(Int -> ReadS ActivateAnomalyDetectorResponse)
-> ReadS [ActivateAnomalyDetectorResponse]
-> ReadPrec ActivateAnomalyDetectorResponse
-> ReadPrec [ActivateAnomalyDetectorResponse]
-> Read 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
(Int -> ActivateAnomalyDetectorResponse -> ShowS)
-> (ActivateAnomalyDetectorResponse -> String)
-> ([ActivateAnomalyDetectorResponse] -> ShowS)
-> Show ActivateAnomalyDetectorResponse
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.
 ActivateAnomalyDetectorResponse
 -> Rep ActivateAnomalyDetectorResponse x)
-> (forall x.
    Rep ActivateAnomalyDetectorResponse x
    -> ActivateAnomalyDetectorResponse)
-> Generic ActivateAnomalyDetectorResponse
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' :: Int -> ActivateAnomalyDetectorResponse
ActivateAnomalyDetectorResponse'
    { $sel:httpStatus:ActivateAnomalyDetectorResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
activateAnomalyDetectorResponse_httpStatus :: Lens.Lens' ActivateAnomalyDetectorResponse Prelude.Int
activateAnomalyDetectorResponse_httpStatus :: (Int -> f Int)
-> ActivateAnomalyDetectorResponse
-> f ActivateAnomalyDetectorResponse
activateAnomalyDetectorResponse_httpStatus = (ActivateAnomalyDetectorResponse -> Int)
-> (ActivateAnomalyDetectorResponse
    -> Int -> ActivateAnomalyDetectorResponse)
-> Lens
     ActivateAnomalyDetectorResponse
     ActivateAnomalyDetectorResponse
     Int
     Int
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