{-# 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-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)
--
-- 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.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:/ '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
(GetAnomalyGroup -> GetAnomalyGroup -> Bool)
-> (GetAnomalyGroup -> GetAnomalyGroup -> Bool)
-> Eq GetAnomalyGroup
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]
(Int -> ReadS GetAnomalyGroup)
-> ReadS [GetAnomalyGroup]
-> ReadPrec GetAnomalyGroup
-> ReadPrec [GetAnomalyGroup]
-> Read 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
(Int -> GetAnomalyGroup -> ShowS)
-> (GetAnomalyGroup -> String)
-> ([GetAnomalyGroup] -> ShowS)
-> Show GetAnomalyGroup
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. GetAnomalyGroup -> Rep GetAnomalyGroup x)
-> (forall x. Rep GetAnomalyGroup x -> GetAnomalyGroup)
-> Generic GetAnomalyGroup
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' :: Text -> Text -> GetAnomalyGroup
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 :: (Text -> f Text) -> GetAnomalyGroup -> f GetAnomalyGroup
getAnomalyGroup_anomalyGroupId = (GetAnomalyGroup -> Text)
-> (GetAnomalyGroup -> Text -> GetAnomalyGroup)
-> Lens GetAnomalyGroup GetAnomalyGroup Text Text
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 :: (Text -> f Text) -> GetAnomalyGroup -> f GetAnomalyGroup
getAnomalyGroup_anomalyDetectorArn = (GetAnomalyGroup -> Text)
-> (GetAnomalyGroup -> Text -> GetAnomalyGroup)
-> Lens GetAnomalyGroup GetAnomalyGroup Text Text
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 :: GetAnomalyGroup -> Request GetAnomalyGroup
request = Service -> GetAnomalyGroup -> Request GetAnomalyGroup
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetAnomalyGroup
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetAnomalyGroup)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetAnomalyGroup))
-> Logger
-> Service
-> Proxy GetAnomalyGroup
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetAnomalyGroup)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe AnomalyGroup -> Int -> GetAnomalyGroupResponse
GetAnomalyGroupResponse'
            (Maybe AnomalyGroup -> Int -> GetAnomalyGroupResponse)
-> Either String (Maybe AnomalyGroup)
-> Either String (Int -> GetAnomalyGroupResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe AnomalyGroup)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"AnomalyGroup")
            Either String (Int -> GetAnomalyGroupResponse)
-> Either String Int -> Either String GetAnomalyGroupResponse
forall (f :: * -> *) a b. Applicative f => 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 GetAnomalyGroup

instance Prelude.NFData GetAnomalyGroup

instance Core.ToHeaders GetAnomalyGroup where
  toHeaders :: GetAnomalyGroup -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetAnomalyGroup -> 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 GetAnomalyGroup where
  toJSON :: GetAnomalyGroup -> Value
toJSON GetAnomalyGroup' {Text
anomalyDetectorArn :: Text
anomalyGroupId :: Text
$sel:anomalyDetectorArn:GetAnomalyGroup' :: GetAnomalyGroup -> Text
$sel:anomalyGroupId:GetAnomalyGroup' :: GetAnomalyGroup -> 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
"AnomalyGroupId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
anomalyGroupId),
            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 GetAnomalyGroup where
  toPath :: GetAnomalyGroup -> ByteString
toPath = ByteString -> GetAnomalyGroup -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/GetAnomalyGroup"

instance Core.ToQuery GetAnomalyGroup where
  toQuery :: GetAnomalyGroup -> QueryString
toQuery = QueryString -> GetAnomalyGroup -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(GetAnomalyGroupResponse -> GetAnomalyGroupResponse -> Bool)
-> (GetAnomalyGroupResponse -> GetAnomalyGroupResponse -> Bool)
-> Eq GetAnomalyGroupResponse
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]
(Int -> ReadS GetAnomalyGroupResponse)
-> ReadS [GetAnomalyGroupResponse]
-> ReadPrec GetAnomalyGroupResponse
-> ReadPrec [GetAnomalyGroupResponse]
-> Read 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
(Int -> GetAnomalyGroupResponse -> ShowS)
-> (GetAnomalyGroupResponse -> String)
-> ([GetAnomalyGroupResponse] -> ShowS)
-> Show GetAnomalyGroupResponse
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.
 GetAnomalyGroupResponse -> Rep GetAnomalyGroupResponse x)
-> (forall x.
    Rep GetAnomalyGroupResponse x -> GetAnomalyGroupResponse)
-> Generic GetAnomalyGroupResponse
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' :: Maybe AnomalyGroup -> Int -> GetAnomalyGroupResponse
GetAnomalyGroupResponse'
    { $sel:anomalyGroup:GetAnomalyGroupResponse' :: Maybe AnomalyGroup
anomalyGroup =
        Maybe 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 :: (Maybe AnomalyGroup -> f (Maybe AnomalyGroup))
-> GetAnomalyGroupResponse -> f GetAnomalyGroupResponse
getAnomalyGroupResponse_anomalyGroup = (GetAnomalyGroupResponse -> Maybe AnomalyGroup)
-> (GetAnomalyGroupResponse
    -> Maybe AnomalyGroup -> GetAnomalyGroupResponse)
-> Lens
     GetAnomalyGroupResponse
     GetAnomalyGroupResponse
     (Maybe AnomalyGroup)
     (Maybe 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 :: (Int -> f Int)
-> GetAnomalyGroupResponse -> f GetAnomalyGroupResponse
getAnomalyGroupResponse_httpStatus = (GetAnomalyGroupResponse -> Int)
-> (GetAnomalyGroupResponse -> Int -> GetAnomalyGroupResponse)
-> Lens GetAnomalyGroupResponse GetAnomalyGroupResponse Int Int
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