{-# 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.GetAnomalyGroup
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Returns details about a group of anomalous metrics.
module Amazonka.LookoutMetrics.GetAnomalyGroup
  ( -- * Creating a Request
    GetAnomalyGroup (..),
    newGetAnomalyGroup,

    -- * Request Lenses
    getAnomalyGroup_anomalyGroupId,
    getAnomalyGroup_anomalyDetectorArn,

    -- * Destructuring the Response
    GetAnomalyGroupResponse (..),
    newGetAnomalyGroupResponse,

    -- * Response Lenses
    getAnomalyGroupResponse_anomalyGroup,
    getAnomalyGroupResponse_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:/ 'newGetAnomalyGroup' smart constructor.
data GetAnomalyGroup = GetAnomalyGroup'
  { -- | The ID of the anomaly group.
    GetAnomalyGroup -> Text
anomalyGroupId :: Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the anomaly detector.
    GetAnomalyGroup -> Text
anomalyDetectorArn :: Prelude.Text
  }
  deriving (GetAnomalyGroup -> GetAnomalyGroup -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetAnomalyGroup -> GetAnomalyGroup -> Bool
$c/= :: GetAnomalyGroup -> GetAnomalyGroup -> Bool
== :: GetAnomalyGroup -> GetAnomalyGroup -> Bool
$c== :: GetAnomalyGroup -> GetAnomalyGroup -> Bool
Prelude.Eq, ReadPrec [GetAnomalyGroup]
ReadPrec GetAnomalyGroup
Int -> ReadS GetAnomalyGroup
ReadS [GetAnomalyGroup]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetAnomalyGroup]
$creadListPrec :: ReadPrec [GetAnomalyGroup]
readPrec :: ReadPrec GetAnomalyGroup
$creadPrec :: ReadPrec GetAnomalyGroup
readList :: ReadS [GetAnomalyGroup]
$creadList :: ReadS [GetAnomalyGroup]
readsPrec :: Int -> ReadS GetAnomalyGroup
$creadsPrec :: Int -> ReadS GetAnomalyGroup
Prelude.Read, Int -> GetAnomalyGroup -> ShowS
[GetAnomalyGroup] -> ShowS
GetAnomalyGroup -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetAnomalyGroup] -> ShowS
$cshowList :: [GetAnomalyGroup] -> ShowS
show :: GetAnomalyGroup -> String
$cshow :: GetAnomalyGroup -> String
showsPrec :: Int -> GetAnomalyGroup -> ShowS
$cshowsPrec :: Int -> GetAnomalyGroup -> ShowS
Prelude.Show, forall x. Rep GetAnomalyGroup x -> GetAnomalyGroup
forall x. GetAnomalyGroup -> Rep GetAnomalyGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetAnomalyGroup x -> GetAnomalyGroup
$cfrom :: forall x. GetAnomalyGroup -> Rep GetAnomalyGroup x
Prelude.Generic)

-- |
-- Create a value of 'GetAnomalyGroup' 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:
--
-- 'anomalyGroupId', 'getAnomalyGroup_anomalyGroupId' - The ID of the anomaly group.
--
-- 'anomalyDetectorArn', 'getAnomalyGroup_anomalyDetectorArn' - The Amazon Resource Name (ARN) of the anomaly detector.
newGetAnomalyGroup ::
  -- | 'anomalyGroupId'
  Prelude.Text ->
  -- | 'anomalyDetectorArn'
  Prelude.Text ->
  GetAnomalyGroup
newGetAnomalyGroup :: Text -> Text -> GetAnomalyGroup
newGetAnomalyGroup
  Text
pAnomalyGroupId_
  Text
pAnomalyDetectorArn_ =
    GetAnomalyGroup'
      { $sel:anomalyGroupId:GetAnomalyGroup' :: Text
anomalyGroupId = Text
pAnomalyGroupId_,
        $sel:anomalyDetectorArn:GetAnomalyGroup' :: Text
anomalyDetectorArn = Text
pAnomalyDetectorArn_
      }

-- | The ID of the anomaly group.
getAnomalyGroup_anomalyGroupId :: Lens.Lens' GetAnomalyGroup Prelude.Text
getAnomalyGroup_anomalyGroupId :: Lens' GetAnomalyGroup Text
getAnomalyGroup_anomalyGroupId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetAnomalyGroup' {Text
anomalyGroupId :: Text
$sel:anomalyGroupId:GetAnomalyGroup' :: GetAnomalyGroup -> Text
anomalyGroupId} -> Text
anomalyGroupId) (\s :: GetAnomalyGroup
s@GetAnomalyGroup' {} Text
a -> GetAnomalyGroup
s {$sel:anomalyGroupId:GetAnomalyGroup' :: Text
anomalyGroupId = Text
a} :: GetAnomalyGroup)

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

instance Core.AWSRequest GetAnomalyGroup where
  type
    AWSResponse GetAnomalyGroup =
      GetAnomalyGroupResponse
  request :: (Service -> Service) -> GetAnomalyGroup -> Request GetAnomalyGroup
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 GetAnomalyGroup
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetAnomalyGroup)))
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 AnomalyGroup -> Int -> GetAnomalyGroupResponse
GetAnomalyGroupResponse'
            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
"AnomalyGroup")
            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 GetAnomalyGroup where
  hashWithSalt :: Int -> GetAnomalyGroup -> Int
hashWithSalt Int
_salt GetAnomalyGroup' {Text
anomalyDetectorArn :: Text
anomalyGroupId :: Text
$sel:anomalyDetectorArn:GetAnomalyGroup' :: GetAnomalyGroup -> Text
$sel:anomalyGroupId:GetAnomalyGroup' :: GetAnomalyGroup -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
anomalyGroupId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
anomalyDetectorArn

instance Prelude.NFData GetAnomalyGroup where
  rnf :: GetAnomalyGroup -> ()
rnf GetAnomalyGroup' {Text
anomalyDetectorArn :: Text
anomalyGroupId :: Text
$sel:anomalyDetectorArn:GetAnomalyGroup' :: GetAnomalyGroup -> Text
$sel:anomalyGroupId:GetAnomalyGroup' :: GetAnomalyGroup -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
anomalyGroupId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
anomalyDetectorArn

instance Data.ToHeaders GetAnomalyGroup where
  toHeaders :: GetAnomalyGroup -> 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 GetAnomalyGroup where
  toJSON :: GetAnomalyGroup -> Value
toJSON GetAnomalyGroup' {Text
anomalyDetectorArn :: Text
anomalyGroupId :: Text
$sel:anomalyDetectorArn:GetAnomalyGroup' :: GetAnomalyGroup -> Text
$sel:anomalyGroupId:GetAnomalyGroup' :: GetAnomalyGroup -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"AnomalyGroupId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
anomalyGroupId),
            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 GetAnomalyGroup where
  toPath :: GetAnomalyGroup -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/GetAnomalyGroup"

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

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

-- |
-- Create a value of 'GetAnomalyGroupResponse' 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:
--
-- 'anomalyGroup', 'getAnomalyGroupResponse_anomalyGroup' - Details about the anomaly group.
--
-- 'httpStatus', 'getAnomalyGroupResponse_httpStatus' - The response's http status code.
newGetAnomalyGroupResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetAnomalyGroupResponse
newGetAnomalyGroupResponse :: Int -> GetAnomalyGroupResponse
newGetAnomalyGroupResponse Int
pHttpStatus_ =
  GetAnomalyGroupResponse'
    { $sel:anomalyGroup:GetAnomalyGroupResponse' :: Maybe AnomalyGroup
anomalyGroup =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetAnomalyGroupResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Details about the anomaly group.
getAnomalyGroupResponse_anomalyGroup :: Lens.Lens' GetAnomalyGroupResponse (Prelude.Maybe AnomalyGroup)
getAnomalyGroupResponse_anomalyGroup :: Lens' GetAnomalyGroupResponse (Maybe AnomalyGroup)
getAnomalyGroupResponse_anomalyGroup = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetAnomalyGroupResponse' {Maybe AnomalyGroup
anomalyGroup :: Maybe AnomalyGroup
$sel:anomalyGroup:GetAnomalyGroupResponse' :: GetAnomalyGroupResponse -> Maybe AnomalyGroup
anomalyGroup} -> Maybe AnomalyGroup
anomalyGroup) (\s :: GetAnomalyGroupResponse
s@GetAnomalyGroupResponse' {} Maybe AnomalyGroup
a -> GetAnomalyGroupResponse
s {$sel:anomalyGroup:GetAnomalyGroupResponse' :: Maybe AnomalyGroup
anomalyGroup = Maybe AnomalyGroup
a} :: GetAnomalyGroupResponse)

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

instance Prelude.NFData GetAnomalyGroupResponse where
  rnf :: GetAnomalyGroupResponse -> ()
rnf GetAnomalyGroupResponse' {Int
Maybe AnomalyGroup
httpStatus :: Int
anomalyGroup :: Maybe AnomalyGroup
$sel:httpStatus:GetAnomalyGroupResponse' :: GetAnomalyGroupResponse -> Int
$sel:anomalyGroup:GetAnomalyGroupResponse' :: GetAnomalyGroupResponse -> Maybe AnomalyGroup
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe AnomalyGroup
anomalyGroup
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus