{-# 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-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)
--
-- Describes the safety rules (that is, the assertion rules and gating
-- rules) for the routing controls in a control panel.
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.Lens as Lens
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 request body that you include when you update a safety rule.
    DescribeSafetyRule -> Text
safetyRuleArn :: Prelude.Text
  }
  deriving (DescribeSafetyRule -> DescribeSafetyRule -> Bool
(DescribeSafetyRule -> DescribeSafetyRule -> Bool)
-> (DescribeSafetyRule -> DescribeSafetyRule -> Bool)
-> Eq DescribeSafetyRule
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]
(Int -> ReadS DescribeSafetyRule)
-> ReadS [DescribeSafetyRule]
-> ReadPrec DescribeSafetyRule
-> ReadPrec [DescribeSafetyRule]
-> Read 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
(Int -> DescribeSafetyRule -> ShowS)
-> (DescribeSafetyRule -> String)
-> ([DescribeSafetyRule] -> ShowS)
-> Show DescribeSafetyRule
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. DescribeSafetyRule -> Rep DescribeSafetyRule x)
-> (forall x. Rep DescribeSafetyRule x -> DescribeSafetyRule)
-> Generic DescribeSafetyRule
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 request body that you include when you update a safety rule.
newDescribeSafetyRule ::
  -- | 'safetyRuleArn'
  Prelude.Text ->
  DescribeSafetyRule
newDescribeSafetyRule :: Text -> DescribeSafetyRule
newDescribeSafetyRule Text
pSafetyRuleArn_ =
  DescribeSafetyRule' :: Text -> DescribeSafetyRule
DescribeSafetyRule'
    { $sel:safetyRuleArn:DescribeSafetyRule' :: Text
safetyRuleArn =
        Text
pSafetyRuleArn_
    }

-- | The request body that you include when you update a safety rule.
describeSafetyRule_safetyRuleArn :: Lens.Lens' DescribeSafetyRule Prelude.Text
describeSafetyRule_safetyRuleArn :: (Text -> f Text) -> DescribeSafetyRule -> f DescribeSafetyRule
describeSafetyRule_safetyRuleArn = (DescribeSafetyRule -> Text)
-> (DescribeSafetyRule -> Text -> DescribeSafetyRule)
-> Lens DescribeSafetyRule DescribeSafetyRule Text Text
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 :: DescribeSafetyRule -> Request DescribeSafetyRule
request = Service -> DescribeSafetyRule -> Request DescribeSafetyRule
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeSafetyRule
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeSafetyRule)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeSafetyRule))
-> Logger
-> Service
-> Proxy DescribeSafetyRule
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeSafetyRule)))
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 AssertionRule
-> Maybe GatingRule -> Int -> DescribeSafetyRuleResponse
DescribeSafetyRuleResponse'
            (Maybe AssertionRule
 -> Maybe GatingRule -> Int -> DescribeSafetyRuleResponse)
-> Either String (Maybe AssertionRule)
-> Either
     String (Maybe GatingRule -> Int -> DescribeSafetyRuleResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe AssertionRule)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"AssertionRule")
            Either
  String (Maybe GatingRule -> Int -> DescribeSafetyRuleResponse)
-> Either String (Maybe GatingRule)
-> Either String (Int -> DescribeSafetyRuleResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe GatingRule)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"GatingRule")
            Either String (Int -> DescribeSafetyRuleResponse)
-> Either String Int -> Either String DescribeSafetyRuleResponse
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 DescribeSafetyRule

instance Prelude.NFData DescribeSafetyRule

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

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

-- | /See:/ 'newDescribeSafetyRuleResponse' smart constructor.
data DescribeSafetyRuleResponse = DescribeSafetyRuleResponse'
  { DescribeSafetyRuleResponse -> Maybe AssertionRule
assertionRule :: Prelude.Maybe AssertionRule,
    DescribeSafetyRuleResponse -> Maybe GatingRule
gatingRule :: Prelude.Maybe GatingRule,
    -- | The response's http status code.
    DescribeSafetyRuleResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeSafetyRuleResponse -> DescribeSafetyRuleResponse -> Bool
(DescribeSafetyRuleResponse -> DescribeSafetyRuleResponse -> Bool)
-> (DescribeSafetyRuleResponse
    -> DescribeSafetyRuleResponse -> Bool)
-> Eq DescribeSafetyRuleResponse
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]
(Int -> ReadS DescribeSafetyRuleResponse)
-> ReadS [DescribeSafetyRuleResponse]
-> ReadPrec DescribeSafetyRuleResponse
-> ReadPrec [DescribeSafetyRuleResponse]
-> Read 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
(Int -> DescribeSafetyRuleResponse -> ShowS)
-> (DescribeSafetyRuleResponse -> String)
-> ([DescribeSafetyRuleResponse] -> ShowS)
-> Show DescribeSafetyRuleResponse
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.
 DescribeSafetyRuleResponse -> Rep DescribeSafetyRuleResponse x)
-> (forall x.
    Rep DescribeSafetyRuleResponse x -> DescribeSafetyRuleResponse)
-> Generic DescribeSafetyRuleResponse
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' - Undocumented member.
--
-- 'gatingRule', 'describeSafetyRuleResponse_gatingRule' - Undocumented member.
--
-- 'httpStatus', 'describeSafetyRuleResponse_httpStatus' - The response's http status code.
newDescribeSafetyRuleResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeSafetyRuleResponse
newDescribeSafetyRuleResponse :: Int -> DescribeSafetyRuleResponse
newDescribeSafetyRuleResponse Int
pHttpStatus_ =
  DescribeSafetyRuleResponse' :: Maybe AssertionRule
-> Maybe GatingRule -> Int -> DescribeSafetyRuleResponse
DescribeSafetyRuleResponse'
    { $sel:assertionRule:DescribeSafetyRuleResponse' :: Maybe AssertionRule
assertionRule =
        Maybe AssertionRule
forall a. Maybe a
Prelude.Nothing,
      $sel:gatingRule:DescribeSafetyRuleResponse' :: Maybe GatingRule
gatingRule = Maybe GatingRule
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeSafetyRuleResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Undocumented member.
describeSafetyRuleResponse_assertionRule :: Lens.Lens' DescribeSafetyRuleResponse (Prelude.Maybe AssertionRule)
describeSafetyRuleResponse_assertionRule :: (Maybe AssertionRule -> f (Maybe AssertionRule))
-> DescribeSafetyRuleResponse -> f DescribeSafetyRuleResponse
describeSafetyRuleResponse_assertionRule = (DescribeSafetyRuleResponse -> Maybe AssertionRule)
-> (DescribeSafetyRuleResponse
    -> Maybe AssertionRule -> DescribeSafetyRuleResponse)
-> Lens
     DescribeSafetyRuleResponse
     DescribeSafetyRuleResponse
     (Maybe AssertionRule)
     (Maybe 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)

-- | Undocumented member.
describeSafetyRuleResponse_gatingRule :: Lens.Lens' DescribeSafetyRuleResponse (Prelude.Maybe GatingRule)
describeSafetyRuleResponse_gatingRule :: (Maybe GatingRule -> f (Maybe GatingRule))
-> DescribeSafetyRuleResponse -> f DescribeSafetyRuleResponse
describeSafetyRuleResponse_gatingRule = (DescribeSafetyRuleResponse -> Maybe GatingRule)
-> (DescribeSafetyRuleResponse
    -> Maybe GatingRule -> DescribeSafetyRuleResponse)
-> Lens
     DescribeSafetyRuleResponse
     DescribeSafetyRuleResponse
     (Maybe GatingRule)
     (Maybe 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 :: (Int -> f Int)
-> DescribeSafetyRuleResponse -> f DescribeSafetyRuleResponse
describeSafetyRuleResponse_httpStatus = (DescribeSafetyRuleResponse -> Int)
-> (DescribeSafetyRuleResponse
    -> Int -> DescribeSafetyRuleResponse)
-> Lens
     DescribeSafetyRuleResponse DescribeSafetyRuleResponse Int Int
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