{-# 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.Route53RecoveryControlConfig.DescribeSafetyRule
-- 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 information about a safety rule.
module Amazonka.Route53RecoveryControlConfig.DescribeSafetyRule
  ( -- * Creating a Request
    DescribeSafetyRule (..),
    newDescribeSafetyRule,

    -- * Request Lenses
    describeSafetyRule_safetyRuleArn,

    -- * Destructuring the Response
    DescribeSafetyRuleResponse (..),
    newDescribeSafetyRuleResponse,

    -- * Response Lenses
    describeSafetyRuleResponse_assertionRule,
    describeSafetyRuleResponse_gatingRule,
    describeSafetyRuleResponse_httpStatus,
  )
where

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
import Amazonka.Route53RecoveryControlConfig.Types

-- | /See:/ 'newDescribeSafetyRule' smart constructor.
data DescribeSafetyRule = DescribeSafetyRule'
  { -- | The ARN of the safety rule.
    DescribeSafetyRule -> Text
safetyRuleArn :: Prelude.Text
  }
  deriving (DescribeSafetyRule -> DescribeSafetyRule -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeSafetyRule -> DescribeSafetyRule -> Bool
$c/= :: DescribeSafetyRule -> DescribeSafetyRule -> Bool
== :: DescribeSafetyRule -> DescribeSafetyRule -> Bool
$c== :: DescribeSafetyRule -> DescribeSafetyRule -> Bool
Prelude.Eq, ReadPrec [DescribeSafetyRule]
ReadPrec DescribeSafetyRule
Int -> ReadS DescribeSafetyRule
ReadS [DescribeSafetyRule]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeSafetyRule]
$creadListPrec :: ReadPrec [DescribeSafetyRule]
readPrec :: ReadPrec DescribeSafetyRule
$creadPrec :: ReadPrec DescribeSafetyRule
readList :: ReadS [DescribeSafetyRule]
$creadList :: ReadS [DescribeSafetyRule]
readsPrec :: Int -> ReadS DescribeSafetyRule
$creadsPrec :: Int -> ReadS DescribeSafetyRule
Prelude.Read, Int -> DescribeSafetyRule -> ShowS
[DescribeSafetyRule] -> ShowS
DescribeSafetyRule -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeSafetyRule] -> ShowS
$cshowList :: [DescribeSafetyRule] -> ShowS
show :: DescribeSafetyRule -> String
$cshow :: DescribeSafetyRule -> String
showsPrec :: Int -> DescribeSafetyRule -> ShowS
$cshowsPrec :: Int -> DescribeSafetyRule -> ShowS
Prelude.Show, forall x. Rep DescribeSafetyRule x -> DescribeSafetyRule
forall x. DescribeSafetyRule -> Rep DescribeSafetyRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeSafetyRule x -> DescribeSafetyRule
$cfrom :: forall x. DescribeSafetyRule -> Rep DescribeSafetyRule x
Prelude.Generic)

-- |
-- Create a value of 'DescribeSafetyRule' 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:
--
-- 'safetyRuleArn', 'describeSafetyRule_safetyRuleArn' - The ARN of the safety rule.
newDescribeSafetyRule ::
  -- | 'safetyRuleArn'
  Prelude.Text ->
  DescribeSafetyRule
newDescribeSafetyRule :: Text -> DescribeSafetyRule
newDescribeSafetyRule Text
pSafetyRuleArn_ =
  DescribeSafetyRule'
    { $sel:safetyRuleArn:DescribeSafetyRule' :: Text
safetyRuleArn =
        Text
pSafetyRuleArn_
    }

-- | The ARN of the safety rule.
describeSafetyRule_safetyRuleArn :: Lens.Lens' DescribeSafetyRule Prelude.Text
describeSafetyRule_safetyRuleArn :: Lens' DescribeSafetyRule Text
describeSafetyRule_safetyRuleArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeSafetyRule' {Text
safetyRuleArn :: Text
$sel:safetyRuleArn:DescribeSafetyRule' :: DescribeSafetyRule -> Text
safetyRuleArn} -> Text
safetyRuleArn) (\s :: DescribeSafetyRule
s@DescribeSafetyRule' {} Text
a -> DescribeSafetyRule
s {$sel:safetyRuleArn:DescribeSafetyRule' :: Text
safetyRuleArn = Text
a} :: DescribeSafetyRule)

instance Core.AWSRequest DescribeSafetyRule where
  type
    AWSResponse DescribeSafetyRule =
      DescribeSafetyRuleResponse
  request :: (Service -> Service)
-> DescribeSafetyRule -> Request DescribeSafetyRule
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 DescribeSafetyRule
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeSafetyRule)))
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 AssertionRule
-> Maybe GatingRule -> Int -> DescribeSafetyRuleResponse
DescribeSafetyRuleResponse'
            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
"AssertionRule")
            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
"GatingRule")
            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 DescribeSafetyRule where
  hashWithSalt :: Int -> DescribeSafetyRule -> Int
hashWithSalt Int
_salt DescribeSafetyRule' {Text
safetyRuleArn :: Text
$sel:safetyRuleArn:DescribeSafetyRule' :: DescribeSafetyRule -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
safetyRuleArn

instance Prelude.NFData DescribeSafetyRule where
  rnf :: DescribeSafetyRule -> ()
rnf DescribeSafetyRule' {Text
safetyRuleArn :: Text
$sel:safetyRuleArn:DescribeSafetyRule' :: DescribeSafetyRule -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
safetyRuleArn

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

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

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

-- |
-- Create a value of 'DescribeSafetyRuleResponse' 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:
--
-- 'assertionRule', 'describeSafetyRuleResponse_assertionRule' - The assertion rule in the response.
--
-- 'gatingRule', 'describeSafetyRuleResponse_gatingRule' - The gating rule in the response.
--
-- 'httpStatus', 'describeSafetyRuleResponse_httpStatus' - The response's http status code.
newDescribeSafetyRuleResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeSafetyRuleResponse
newDescribeSafetyRuleResponse :: Int -> DescribeSafetyRuleResponse
newDescribeSafetyRuleResponse Int
pHttpStatus_ =
  DescribeSafetyRuleResponse'
    { $sel:assertionRule:DescribeSafetyRuleResponse' :: Maybe AssertionRule
assertionRule =
        forall a. Maybe a
Prelude.Nothing,
      $sel:gatingRule:DescribeSafetyRuleResponse' :: Maybe GatingRule
gatingRule = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeSafetyRuleResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The assertion rule in the response.
describeSafetyRuleResponse_assertionRule :: Lens.Lens' DescribeSafetyRuleResponse (Prelude.Maybe AssertionRule)
describeSafetyRuleResponse_assertionRule :: Lens' DescribeSafetyRuleResponse (Maybe AssertionRule)
describeSafetyRuleResponse_assertionRule = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeSafetyRuleResponse' {Maybe AssertionRule
assertionRule :: Maybe AssertionRule
$sel:assertionRule:DescribeSafetyRuleResponse' :: DescribeSafetyRuleResponse -> Maybe AssertionRule
assertionRule} -> Maybe AssertionRule
assertionRule) (\s :: DescribeSafetyRuleResponse
s@DescribeSafetyRuleResponse' {} Maybe AssertionRule
a -> DescribeSafetyRuleResponse
s {$sel:assertionRule:DescribeSafetyRuleResponse' :: Maybe AssertionRule
assertionRule = Maybe AssertionRule
a} :: DescribeSafetyRuleResponse)

-- | The gating rule in the response.
describeSafetyRuleResponse_gatingRule :: Lens.Lens' DescribeSafetyRuleResponse (Prelude.Maybe GatingRule)
describeSafetyRuleResponse_gatingRule :: Lens' DescribeSafetyRuleResponse (Maybe GatingRule)
describeSafetyRuleResponse_gatingRule = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeSafetyRuleResponse' {Maybe GatingRule
gatingRule :: Maybe GatingRule
$sel:gatingRule:DescribeSafetyRuleResponse' :: DescribeSafetyRuleResponse -> Maybe GatingRule
gatingRule} -> Maybe GatingRule
gatingRule) (\s :: DescribeSafetyRuleResponse
s@DescribeSafetyRuleResponse' {} Maybe GatingRule
a -> DescribeSafetyRuleResponse
s {$sel:gatingRule:DescribeSafetyRuleResponse' :: Maybe GatingRule
gatingRule = Maybe GatingRule
a} :: DescribeSafetyRuleResponse)

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

instance Prelude.NFData DescribeSafetyRuleResponse where
  rnf :: DescribeSafetyRuleResponse -> ()
rnf DescribeSafetyRuleResponse' {Int
Maybe GatingRule
Maybe AssertionRule
httpStatus :: Int
gatingRule :: Maybe GatingRule
assertionRule :: Maybe AssertionRule
$sel:httpStatus:DescribeSafetyRuleResponse' :: DescribeSafetyRuleResponse -> Int
$sel:gatingRule:DescribeSafetyRuleResponse' :: DescribeSafetyRuleResponse -> Maybe GatingRule
$sel:assertionRule:DescribeSafetyRuleResponse' :: DescribeSafetyRuleResponse -> Maybe AssertionRule
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe AssertionRule
assertionRule
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe GatingRule
gatingRule
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus