{-# 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.ApplicationInsights.DescribeLogPattern
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Describe a specific log pattern from a @LogPatternSet@.
module Amazonka.ApplicationInsights.DescribeLogPattern
  ( -- * Creating a Request
    DescribeLogPattern (..),
    newDescribeLogPattern,

    -- * Request Lenses
    describeLogPattern_resourceGroupName,
    describeLogPattern_patternSetName,
    describeLogPattern_patternName,

    -- * Destructuring the Response
    DescribeLogPatternResponse (..),
    newDescribeLogPatternResponse,

    -- * Response Lenses
    describeLogPatternResponse_logPattern,
    describeLogPatternResponse_resourceGroupName,
    describeLogPatternResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDescribeLogPattern' smart constructor.
data DescribeLogPattern = DescribeLogPattern'
  { -- | The name of the resource group.
    DescribeLogPattern -> Text
resourceGroupName :: Prelude.Text,
    -- | The name of the log pattern set.
    DescribeLogPattern -> Text
patternSetName :: Prelude.Text,
    -- | The name of the log pattern.
    DescribeLogPattern -> Text
patternName :: Prelude.Text
  }
  deriving (DescribeLogPattern -> DescribeLogPattern -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeLogPattern -> DescribeLogPattern -> Bool
$c/= :: DescribeLogPattern -> DescribeLogPattern -> Bool
== :: DescribeLogPattern -> DescribeLogPattern -> Bool
$c== :: DescribeLogPattern -> DescribeLogPattern -> Bool
Prelude.Eq, ReadPrec [DescribeLogPattern]
ReadPrec DescribeLogPattern
Int -> ReadS DescribeLogPattern
ReadS [DescribeLogPattern]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeLogPattern]
$creadListPrec :: ReadPrec [DescribeLogPattern]
readPrec :: ReadPrec DescribeLogPattern
$creadPrec :: ReadPrec DescribeLogPattern
readList :: ReadS [DescribeLogPattern]
$creadList :: ReadS [DescribeLogPattern]
readsPrec :: Int -> ReadS DescribeLogPattern
$creadsPrec :: Int -> ReadS DescribeLogPattern
Prelude.Read, Int -> DescribeLogPattern -> ShowS
[DescribeLogPattern] -> ShowS
DescribeLogPattern -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeLogPattern] -> ShowS
$cshowList :: [DescribeLogPattern] -> ShowS
show :: DescribeLogPattern -> String
$cshow :: DescribeLogPattern -> String
showsPrec :: Int -> DescribeLogPattern -> ShowS
$cshowsPrec :: Int -> DescribeLogPattern -> ShowS
Prelude.Show, forall x. Rep DescribeLogPattern x -> DescribeLogPattern
forall x. DescribeLogPattern -> Rep DescribeLogPattern x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeLogPattern x -> DescribeLogPattern
$cfrom :: forall x. DescribeLogPattern -> Rep DescribeLogPattern x
Prelude.Generic)

-- |
-- Create a value of 'DescribeLogPattern' 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:
--
-- 'resourceGroupName', 'describeLogPattern_resourceGroupName' - The name of the resource group.
--
-- 'patternSetName', 'describeLogPattern_patternSetName' - The name of the log pattern set.
--
-- 'patternName', 'describeLogPattern_patternName' - The name of the log pattern.
newDescribeLogPattern ::
  -- | 'resourceGroupName'
  Prelude.Text ->
  -- | 'patternSetName'
  Prelude.Text ->
  -- | 'patternName'
  Prelude.Text ->
  DescribeLogPattern
newDescribeLogPattern :: Text -> Text -> Text -> DescribeLogPattern
newDescribeLogPattern
  Text
pResourceGroupName_
  Text
pPatternSetName_
  Text
pPatternName_ =
    DescribeLogPattern'
      { $sel:resourceGroupName:DescribeLogPattern' :: Text
resourceGroupName =
          Text
pResourceGroupName_,
        $sel:patternSetName:DescribeLogPattern' :: Text
patternSetName = Text
pPatternSetName_,
        $sel:patternName:DescribeLogPattern' :: Text
patternName = Text
pPatternName_
      }

-- | The name of the resource group.
describeLogPattern_resourceGroupName :: Lens.Lens' DescribeLogPattern Prelude.Text
describeLogPattern_resourceGroupName :: Lens' DescribeLogPattern Text
describeLogPattern_resourceGroupName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeLogPattern' {Text
resourceGroupName :: Text
$sel:resourceGroupName:DescribeLogPattern' :: DescribeLogPattern -> Text
resourceGroupName} -> Text
resourceGroupName) (\s :: DescribeLogPattern
s@DescribeLogPattern' {} Text
a -> DescribeLogPattern
s {$sel:resourceGroupName:DescribeLogPattern' :: Text
resourceGroupName = Text
a} :: DescribeLogPattern)

-- | The name of the log pattern set.
describeLogPattern_patternSetName :: Lens.Lens' DescribeLogPattern Prelude.Text
describeLogPattern_patternSetName :: Lens' DescribeLogPattern Text
describeLogPattern_patternSetName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeLogPattern' {Text
patternSetName :: Text
$sel:patternSetName:DescribeLogPattern' :: DescribeLogPattern -> Text
patternSetName} -> Text
patternSetName) (\s :: DescribeLogPattern
s@DescribeLogPattern' {} Text
a -> DescribeLogPattern
s {$sel:patternSetName:DescribeLogPattern' :: Text
patternSetName = Text
a} :: DescribeLogPattern)

-- | The name of the log pattern.
describeLogPattern_patternName :: Lens.Lens' DescribeLogPattern Prelude.Text
describeLogPattern_patternName :: Lens' DescribeLogPattern Text
describeLogPattern_patternName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeLogPattern' {Text
patternName :: Text
$sel:patternName:DescribeLogPattern' :: DescribeLogPattern -> Text
patternName} -> Text
patternName) (\s :: DescribeLogPattern
s@DescribeLogPattern' {} Text
a -> DescribeLogPattern
s {$sel:patternName:DescribeLogPattern' :: Text
patternName = Text
a} :: DescribeLogPattern)

instance Core.AWSRequest DescribeLogPattern where
  type
    AWSResponse DescribeLogPattern =
      DescribeLogPatternResponse
  request :: (Service -> Service)
-> DescribeLogPattern -> Request DescribeLogPattern
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 DescribeLogPattern
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeLogPattern)))
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 LogPattern -> Maybe Text -> Int -> DescribeLogPatternResponse
DescribeLogPatternResponse'
            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
"LogPattern")
            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
"ResourceGroupName")
            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 DescribeLogPattern where
  hashWithSalt :: Int -> DescribeLogPattern -> Int
hashWithSalt Int
_salt DescribeLogPattern' {Text
patternName :: Text
patternSetName :: Text
resourceGroupName :: Text
$sel:patternName:DescribeLogPattern' :: DescribeLogPattern -> Text
$sel:patternSetName:DescribeLogPattern' :: DescribeLogPattern -> Text
$sel:resourceGroupName:DescribeLogPattern' :: DescribeLogPattern -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
resourceGroupName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
patternSetName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
patternName

instance Prelude.NFData DescribeLogPattern where
  rnf :: DescribeLogPattern -> ()
rnf DescribeLogPattern' {Text
patternName :: Text
patternSetName :: Text
resourceGroupName :: Text
$sel:patternName:DescribeLogPattern' :: DescribeLogPattern -> Text
$sel:patternSetName:DescribeLogPattern' :: DescribeLogPattern -> Text
$sel:resourceGroupName:DescribeLogPattern' :: DescribeLogPattern -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
resourceGroupName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
patternSetName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
patternName

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

instance Data.ToJSON DescribeLogPattern where
  toJSON :: DescribeLogPattern -> Value
toJSON DescribeLogPattern' {Text
patternName :: Text
patternSetName :: Text
resourceGroupName :: Text
$sel:patternName:DescribeLogPattern' :: DescribeLogPattern -> Text
$sel:patternSetName:DescribeLogPattern' :: DescribeLogPattern -> Text
$sel:resourceGroupName:DescribeLogPattern' :: DescribeLogPattern -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"ResourceGroupName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
resourceGroupName),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"PatternSetName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
patternSetName),
            forall a. a -> Maybe a
Prelude.Just (Key
"PatternName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
patternName)
          ]
      )

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

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

-- | /See:/ 'newDescribeLogPatternResponse' smart constructor.
data DescribeLogPatternResponse = DescribeLogPatternResponse'
  { -- | The successfully created log pattern.
    DescribeLogPatternResponse -> Maybe LogPattern
logPattern :: Prelude.Maybe LogPattern,
    -- | The name of the resource group.
    DescribeLogPatternResponse -> Maybe Text
resourceGroupName :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    DescribeLogPatternResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeLogPatternResponse -> DescribeLogPatternResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeLogPatternResponse -> DescribeLogPatternResponse -> Bool
$c/= :: DescribeLogPatternResponse -> DescribeLogPatternResponse -> Bool
== :: DescribeLogPatternResponse -> DescribeLogPatternResponse -> Bool
$c== :: DescribeLogPatternResponse -> DescribeLogPatternResponse -> Bool
Prelude.Eq, ReadPrec [DescribeLogPatternResponse]
ReadPrec DescribeLogPatternResponse
Int -> ReadS DescribeLogPatternResponse
ReadS [DescribeLogPatternResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeLogPatternResponse]
$creadListPrec :: ReadPrec [DescribeLogPatternResponse]
readPrec :: ReadPrec DescribeLogPatternResponse
$creadPrec :: ReadPrec DescribeLogPatternResponse
readList :: ReadS [DescribeLogPatternResponse]
$creadList :: ReadS [DescribeLogPatternResponse]
readsPrec :: Int -> ReadS DescribeLogPatternResponse
$creadsPrec :: Int -> ReadS DescribeLogPatternResponse
Prelude.Read, Int -> DescribeLogPatternResponse -> ShowS
[DescribeLogPatternResponse] -> ShowS
DescribeLogPatternResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeLogPatternResponse] -> ShowS
$cshowList :: [DescribeLogPatternResponse] -> ShowS
show :: DescribeLogPatternResponse -> String
$cshow :: DescribeLogPatternResponse -> String
showsPrec :: Int -> DescribeLogPatternResponse -> ShowS
$cshowsPrec :: Int -> DescribeLogPatternResponse -> ShowS
Prelude.Show, forall x.
Rep DescribeLogPatternResponse x -> DescribeLogPatternResponse
forall x.
DescribeLogPatternResponse -> Rep DescribeLogPatternResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeLogPatternResponse x -> DescribeLogPatternResponse
$cfrom :: forall x.
DescribeLogPatternResponse -> Rep DescribeLogPatternResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeLogPatternResponse' 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:
--
-- 'logPattern', 'describeLogPatternResponse_logPattern' - The successfully created log pattern.
--
-- 'resourceGroupName', 'describeLogPatternResponse_resourceGroupName' - The name of the resource group.
--
-- 'httpStatus', 'describeLogPatternResponse_httpStatus' - The response's http status code.
newDescribeLogPatternResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeLogPatternResponse
newDescribeLogPatternResponse :: Int -> DescribeLogPatternResponse
newDescribeLogPatternResponse Int
pHttpStatus_ =
  DescribeLogPatternResponse'
    { $sel:logPattern:DescribeLogPatternResponse' :: Maybe LogPattern
logPattern =
        forall a. Maybe a
Prelude.Nothing,
      $sel:resourceGroupName:DescribeLogPatternResponse' :: Maybe Text
resourceGroupName = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeLogPatternResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The successfully created log pattern.
describeLogPatternResponse_logPattern :: Lens.Lens' DescribeLogPatternResponse (Prelude.Maybe LogPattern)
describeLogPatternResponse_logPattern :: Lens' DescribeLogPatternResponse (Maybe LogPattern)
describeLogPatternResponse_logPattern = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeLogPatternResponse' {Maybe LogPattern
logPattern :: Maybe LogPattern
$sel:logPattern:DescribeLogPatternResponse' :: DescribeLogPatternResponse -> Maybe LogPattern
logPattern} -> Maybe LogPattern
logPattern) (\s :: DescribeLogPatternResponse
s@DescribeLogPatternResponse' {} Maybe LogPattern
a -> DescribeLogPatternResponse
s {$sel:logPattern:DescribeLogPatternResponse' :: Maybe LogPattern
logPattern = Maybe LogPattern
a} :: DescribeLogPatternResponse)

-- | The name of the resource group.
describeLogPatternResponse_resourceGroupName :: Lens.Lens' DescribeLogPatternResponse (Prelude.Maybe Prelude.Text)
describeLogPatternResponse_resourceGroupName :: Lens' DescribeLogPatternResponse (Maybe Text)
describeLogPatternResponse_resourceGroupName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeLogPatternResponse' {Maybe Text
resourceGroupName :: Maybe Text
$sel:resourceGroupName:DescribeLogPatternResponse' :: DescribeLogPatternResponse -> Maybe Text
resourceGroupName} -> Maybe Text
resourceGroupName) (\s :: DescribeLogPatternResponse
s@DescribeLogPatternResponse' {} Maybe Text
a -> DescribeLogPatternResponse
s {$sel:resourceGroupName:DescribeLogPatternResponse' :: Maybe Text
resourceGroupName = Maybe Text
a} :: DescribeLogPatternResponse)

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

instance Prelude.NFData DescribeLogPatternResponse where
  rnf :: DescribeLogPatternResponse -> ()
rnf DescribeLogPatternResponse' {Int
Maybe Text
Maybe LogPattern
httpStatus :: Int
resourceGroupName :: Maybe Text
logPattern :: Maybe LogPattern
$sel:httpStatus:DescribeLogPatternResponse' :: DescribeLogPatternResponse -> Int
$sel:resourceGroupName:DescribeLogPatternResponse' :: DescribeLogPatternResponse -> Maybe Text
$sel:logPattern:DescribeLogPatternResponse' :: DescribeLogPatternResponse -> Maybe LogPattern
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe LogPattern
logPattern
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
resourceGroupName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus