{-# 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.Connect.DescribeRule
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Describes a rule for the specified Amazon Connect instance.
module Amazonka.Connect.DescribeRule
  ( -- * Creating a Request
    DescribeRule (..),
    newDescribeRule,

    -- * Request Lenses
    describeRule_instanceId,
    describeRule_ruleId,

    -- * Destructuring the Response
    DescribeRuleResponse (..),
    newDescribeRuleResponse,

    -- * Response Lenses
    describeRuleResponse_httpStatus,
    describeRuleResponse_rule,
  )
where

import Amazonka.Connect.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:/ 'newDescribeRule' smart constructor.
data DescribeRule = DescribeRule'
  { -- | The identifier of the Amazon Connect instance. You can find the
    -- instanceId in the ARN of the instance.
    DescribeRule -> Text
instanceId :: Prelude.Text,
    -- | A unique identifier for the rule.
    DescribeRule -> Text
ruleId :: Prelude.Text
  }
  deriving (DescribeRule -> DescribeRule -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeRule -> DescribeRule -> Bool
$c/= :: DescribeRule -> DescribeRule -> Bool
== :: DescribeRule -> DescribeRule -> Bool
$c== :: DescribeRule -> DescribeRule -> Bool
Prelude.Eq, ReadPrec [DescribeRule]
ReadPrec DescribeRule
Int -> ReadS DescribeRule
ReadS [DescribeRule]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeRule]
$creadListPrec :: ReadPrec [DescribeRule]
readPrec :: ReadPrec DescribeRule
$creadPrec :: ReadPrec DescribeRule
readList :: ReadS [DescribeRule]
$creadList :: ReadS [DescribeRule]
readsPrec :: Int -> ReadS DescribeRule
$creadsPrec :: Int -> ReadS DescribeRule
Prelude.Read, Int -> DescribeRule -> ShowS
[DescribeRule] -> ShowS
DescribeRule -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeRule] -> ShowS
$cshowList :: [DescribeRule] -> ShowS
show :: DescribeRule -> String
$cshow :: DescribeRule -> String
showsPrec :: Int -> DescribeRule -> ShowS
$cshowsPrec :: Int -> DescribeRule -> ShowS
Prelude.Show, forall x. Rep DescribeRule x -> DescribeRule
forall x. DescribeRule -> Rep DescribeRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeRule x -> DescribeRule
$cfrom :: forall x. DescribeRule -> Rep DescribeRule x
Prelude.Generic)

-- |
-- Create a value of 'DescribeRule' 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:
--
-- 'instanceId', 'describeRule_instanceId' - The identifier of the Amazon Connect instance. You can find the
-- instanceId in the ARN of the instance.
--
-- 'ruleId', 'describeRule_ruleId' - A unique identifier for the rule.
newDescribeRule ::
  -- | 'instanceId'
  Prelude.Text ->
  -- | 'ruleId'
  Prelude.Text ->
  DescribeRule
newDescribeRule :: Text -> Text -> DescribeRule
newDescribeRule Text
pInstanceId_ Text
pRuleId_ =
  DescribeRule'
    { $sel:instanceId:DescribeRule' :: Text
instanceId = Text
pInstanceId_,
      $sel:ruleId:DescribeRule' :: Text
ruleId = Text
pRuleId_
    }

-- | The identifier of the Amazon Connect instance. You can find the
-- instanceId in the ARN of the instance.
describeRule_instanceId :: Lens.Lens' DescribeRule Prelude.Text
describeRule_instanceId :: Lens' DescribeRule Text
describeRule_instanceId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeRule' {Text
instanceId :: Text
$sel:instanceId:DescribeRule' :: DescribeRule -> Text
instanceId} -> Text
instanceId) (\s :: DescribeRule
s@DescribeRule' {} Text
a -> DescribeRule
s {$sel:instanceId:DescribeRule' :: Text
instanceId = Text
a} :: DescribeRule)

-- | A unique identifier for the rule.
describeRule_ruleId :: Lens.Lens' DescribeRule Prelude.Text
describeRule_ruleId :: Lens' DescribeRule Text
describeRule_ruleId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeRule' {Text
ruleId :: Text
$sel:ruleId:DescribeRule' :: DescribeRule -> Text
ruleId} -> Text
ruleId) (\s :: DescribeRule
s@DescribeRule' {} Text
a -> DescribeRule
s {$sel:ruleId:DescribeRule' :: Text
ruleId = Text
a} :: DescribeRule)

instance Core.AWSRequest DescribeRule where
  type AWSResponse DescribeRule = DescribeRuleResponse
  request :: (Service -> Service) -> DescribeRule -> Request DescribeRule
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DescribeRule
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeRule)))
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 ->
          Int -> Rule -> DescribeRuleResponse
DescribeRuleResponse'
            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))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"Rule")
      )

instance Prelude.Hashable DescribeRule where
  hashWithSalt :: Int -> DescribeRule -> Int
hashWithSalt Int
_salt DescribeRule' {Text
ruleId :: Text
instanceId :: Text
$sel:ruleId:DescribeRule' :: DescribeRule -> Text
$sel:instanceId:DescribeRule' :: DescribeRule -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
instanceId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
ruleId

instance Prelude.NFData DescribeRule where
  rnf :: DescribeRule -> ()
rnf DescribeRule' {Text
ruleId :: Text
instanceId :: Text
$sel:ruleId:DescribeRule' :: DescribeRule -> Text
$sel:instanceId:DescribeRule' :: DescribeRule -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
instanceId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
ruleId

instance Data.ToHeaders DescribeRule where
  toHeaders :: DescribeRule -> 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.ToPath DescribeRule where
  toPath :: DescribeRule -> ByteString
toPath DescribeRule' {Text
ruleId :: Text
instanceId :: Text
$sel:ruleId:DescribeRule' :: DescribeRule -> Text
$sel:instanceId:DescribeRule' :: DescribeRule -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/rules/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
instanceId,
        ByteString
"/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
ruleId
      ]

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

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

-- |
-- Create a value of 'DescribeRuleResponse' 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', 'describeRuleResponse_httpStatus' - The response's http status code.
--
-- 'rule', 'describeRuleResponse_rule' - Information about the rule.
newDescribeRuleResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'rule'
  Rule ->
  DescribeRuleResponse
newDescribeRuleResponse :: Int -> Rule -> DescribeRuleResponse
newDescribeRuleResponse Int
pHttpStatus_ Rule
pRule_ =
  DescribeRuleResponse'
    { $sel:httpStatus:DescribeRuleResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:rule:DescribeRuleResponse' :: Rule
rule = Rule
pRule_
    }

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

-- | Information about the rule.
describeRuleResponse_rule :: Lens.Lens' DescribeRuleResponse Rule
describeRuleResponse_rule :: Lens' DescribeRuleResponse Rule
describeRuleResponse_rule = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeRuleResponse' {Rule
rule :: Rule
$sel:rule:DescribeRuleResponse' :: DescribeRuleResponse -> Rule
rule} -> Rule
rule) (\s :: DescribeRuleResponse
s@DescribeRuleResponse' {} Rule
a -> DescribeRuleResponse
s {$sel:rule:DescribeRuleResponse' :: Rule
rule = Rule
a} :: DescribeRuleResponse)

instance Prelude.NFData DescribeRuleResponse where
  rnf :: DescribeRuleResponse -> ()
rnf DescribeRuleResponse' {Int
Rule
rule :: Rule
httpStatus :: Int
$sel:rule:DescribeRuleResponse' :: DescribeRuleResponse -> Rule
$sel:httpStatus:DescribeRuleResponse' :: DescribeRuleResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Rule
rule