{-# 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.Shield.DescribeProtectionGroup
-- 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 the specification for the specified protection group.
module Amazonka.Shield.DescribeProtectionGroup
  ( -- * Creating a Request
    DescribeProtectionGroup (..),
    newDescribeProtectionGroup,

    -- * Request Lenses
    describeProtectionGroup_protectionGroupId,

    -- * Destructuring the Response
    DescribeProtectionGroupResponse (..),
    newDescribeProtectionGroupResponse,

    -- * Response Lenses
    describeProtectionGroupResponse_httpStatus,
    describeProtectionGroupResponse_protectionGroup,
  )
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.Shield.Types

-- | /See:/ 'newDescribeProtectionGroup' smart constructor.
data DescribeProtectionGroup = DescribeProtectionGroup'
  { -- | The name of the protection group. You use this to identify the
    -- protection group in lists and to manage the protection group, for
    -- example to update, delete, or describe it.
    DescribeProtectionGroup -> Text
protectionGroupId :: Prelude.Text
  }
  deriving (DescribeProtectionGroup -> DescribeProtectionGroup -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeProtectionGroup -> DescribeProtectionGroup -> Bool
$c/= :: DescribeProtectionGroup -> DescribeProtectionGroup -> Bool
== :: DescribeProtectionGroup -> DescribeProtectionGroup -> Bool
$c== :: DescribeProtectionGroup -> DescribeProtectionGroup -> Bool
Prelude.Eq, ReadPrec [DescribeProtectionGroup]
ReadPrec DescribeProtectionGroup
Int -> ReadS DescribeProtectionGroup
ReadS [DescribeProtectionGroup]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeProtectionGroup]
$creadListPrec :: ReadPrec [DescribeProtectionGroup]
readPrec :: ReadPrec DescribeProtectionGroup
$creadPrec :: ReadPrec DescribeProtectionGroup
readList :: ReadS [DescribeProtectionGroup]
$creadList :: ReadS [DescribeProtectionGroup]
readsPrec :: Int -> ReadS DescribeProtectionGroup
$creadsPrec :: Int -> ReadS DescribeProtectionGroup
Prelude.Read, Int -> DescribeProtectionGroup -> ShowS
[DescribeProtectionGroup] -> ShowS
DescribeProtectionGroup -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeProtectionGroup] -> ShowS
$cshowList :: [DescribeProtectionGroup] -> ShowS
show :: DescribeProtectionGroup -> String
$cshow :: DescribeProtectionGroup -> String
showsPrec :: Int -> DescribeProtectionGroup -> ShowS
$cshowsPrec :: Int -> DescribeProtectionGroup -> ShowS
Prelude.Show, forall x. Rep DescribeProtectionGroup x -> DescribeProtectionGroup
forall x. DescribeProtectionGroup -> Rep DescribeProtectionGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeProtectionGroup x -> DescribeProtectionGroup
$cfrom :: forall x. DescribeProtectionGroup -> Rep DescribeProtectionGroup x
Prelude.Generic)

-- |
-- Create a value of 'DescribeProtectionGroup' 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:
--
-- 'protectionGroupId', 'describeProtectionGroup_protectionGroupId' - The name of the protection group. You use this to identify the
-- protection group in lists and to manage the protection group, for
-- example to update, delete, or describe it.
newDescribeProtectionGroup ::
  -- | 'protectionGroupId'
  Prelude.Text ->
  DescribeProtectionGroup
newDescribeProtectionGroup :: Text -> DescribeProtectionGroup
newDescribeProtectionGroup Text
pProtectionGroupId_ =
  DescribeProtectionGroup'
    { $sel:protectionGroupId:DescribeProtectionGroup' :: Text
protectionGroupId =
        Text
pProtectionGroupId_
    }

-- | The name of the protection group. You use this to identify the
-- protection group in lists and to manage the protection group, for
-- example to update, delete, or describe it.
describeProtectionGroup_protectionGroupId :: Lens.Lens' DescribeProtectionGroup Prelude.Text
describeProtectionGroup_protectionGroupId :: Lens' DescribeProtectionGroup Text
describeProtectionGroup_protectionGroupId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeProtectionGroup' {Text
protectionGroupId :: Text
$sel:protectionGroupId:DescribeProtectionGroup' :: DescribeProtectionGroup -> Text
protectionGroupId} -> Text
protectionGroupId) (\s :: DescribeProtectionGroup
s@DescribeProtectionGroup' {} Text
a -> DescribeProtectionGroup
s {$sel:protectionGroupId:DescribeProtectionGroup' :: Text
protectionGroupId = Text
a} :: DescribeProtectionGroup)

instance Core.AWSRequest DescribeProtectionGroup where
  type
    AWSResponse DescribeProtectionGroup =
      DescribeProtectionGroupResponse
  request :: (Service -> Service)
-> DescribeProtectionGroup -> Request DescribeProtectionGroup
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 DescribeProtectionGroup
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeProtectionGroup)))
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 -> ProtectionGroup -> DescribeProtectionGroupResponse
DescribeProtectionGroupResponse'
            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
"ProtectionGroup")
      )

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

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

instance Data.ToHeaders DescribeProtectionGroup where
  toHeaders :: DescribeProtectionGroup -> 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
"AWSShield_20160616.DescribeProtectionGroup" ::
                          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 DescribeProtectionGroup where
  toJSON :: DescribeProtectionGroup -> Value
toJSON DescribeProtectionGroup' {Text
protectionGroupId :: Text
$sel:protectionGroupId:DescribeProtectionGroup' :: DescribeProtectionGroup -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"ProtectionGroupId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
protectionGroupId)
          ]
      )

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

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

-- | /See:/ 'newDescribeProtectionGroupResponse' smart constructor.
data DescribeProtectionGroupResponse = DescribeProtectionGroupResponse'
  { -- | The response's http status code.
    DescribeProtectionGroupResponse -> Int
httpStatus :: Prelude.Int,
    -- | A grouping of protected resources that you and Shield Advanced can
    -- monitor as a collective. This resource grouping improves the accuracy of
    -- detection and reduces false positives.
    DescribeProtectionGroupResponse -> ProtectionGroup
protectionGroup :: ProtectionGroup
  }
  deriving (DescribeProtectionGroupResponse
-> DescribeProtectionGroupResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeProtectionGroupResponse
-> DescribeProtectionGroupResponse -> Bool
$c/= :: DescribeProtectionGroupResponse
-> DescribeProtectionGroupResponse -> Bool
== :: DescribeProtectionGroupResponse
-> DescribeProtectionGroupResponse -> Bool
$c== :: DescribeProtectionGroupResponse
-> DescribeProtectionGroupResponse -> Bool
Prelude.Eq, ReadPrec [DescribeProtectionGroupResponse]
ReadPrec DescribeProtectionGroupResponse
Int -> ReadS DescribeProtectionGroupResponse
ReadS [DescribeProtectionGroupResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeProtectionGroupResponse]
$creadListPrec :: ReadPrec [DescribeProtectionGroupResponse]
readPrec :: ReadPrec DescribeProtectionGroupResponse
$creadPrec :: ReadPrec DescribeProtectionGroupResponse
readList :: ReadS [DescribeProtectionGroupResponse]
$creadList :: ReadS [DescribeProtectionGroupResponse]
readsPrec :: Int -> ReadS DescribeProtectionGroupResponse
$creadsPrec :: Int -> ReadS DescribeProtectionGroupResponse
Prelude.Read, Int -> DescribeProtectionGroupResponse -> ShowS
[DescribeProtectionGroupResponse] -> ShowS
DescribeProtectionGroupResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeProtectionGroupResponse] -> ShowS
$cshowList :: [DescribeProtectionGroupResponse] -> ShowS
show :: DescribeProtectionGroupResponse -> String
$cshow :: DescribeProtectionGroupResponse -> String
showsPrec :: Int -> DescribeProtectionGroupResponse -> ShowS
$cshowsPrec :: Int -> DescribeProtectionGroupResponse -> ShowS
Prelude.Show, forall x.
Rep DescribeProtectionGroupResponse x
-> DescribeProtectionGroupResponse
forall x.
DescribeProtectionGroupResponse
-> Rep DescribeProtectionGroupResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeProtectionGroupResponse x
-> DescribeProtectionGroupResponse
$cfrom :: forall x.
DescribeProtectionGroupResponse
-> Rep DescribeProtectionGroupResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeProtectionGroupResponse' 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', 'describeProtectionGroupResponse_httpStatus' - The response's http status code.
--
-- 'protectionGroup', 'describeProtectionGroupResponse_protectionGroup' - A grouping of protected resources that you and Shield Advanced can
-- monitor as a collective. This resource grouping improves the accuracy of
-- detection and reduces false positives.
newDescribeProtectionGroupResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'protectionGroup'
  ProtectionGroup ->
  DescribeProtectionGroupResponse
newDescribeProtectionGroupResponse :: Int -> ProtectionGroup -> DescribeProtectionGroupResponse
newDescribeProtectionGroupResponse
  Int
pHttpStatus_
  ProtectionGroup
pProtectionGroup_ =
    DescribeProtectionGroupResponse'
      { $sel:httpStatus:DescribeProtectionGroupResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:protectionGroup:DescribeProtectionGroupResponse' :: ProtectionGroup
protectionGroup = ProtectionGroup
pProtectionGroup_
      }

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

-- | A grouping of protected resources that you and Shield Advanced can
-- monitor as a collective. This resource grouping improves the accuracy of
-- detection and reduces false positives.
describeProtectionGroupResponse_protectionGroup :: Lens.Lens' DescribeProtectionGroupResponse ProtectionGroup
describeProtectionGroupResponse_protectionGroup :: Lens' DescribeProtectionGroupResponse ProtectionGroup
describeProtectionGroupResponse_protectionGroup = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeProtectionGroupResponse' {ProtectionGroup
protectionGroup :: ProtectionGroup
$sel:protectionGroup:DescribeProtectionGroupResponse' :: DescribeProtectionGroupResponse -> ProtectionGroup
protectionGroup} -> ProtectionGroup
protectionGroup) (\s :: DescribeProtectionGroupResponse
s@DescribeProtectionGroupResponse' {} ProtectionGroup
a -> DescribeProtectionGroupResponse
s {$sel:protectionGroup:DescribeProtectionGroupResponse' :: ProtectionGroup
protectionGroup = ProtectionGroup
a} :: DescribeProtectionGroupResponse)

instance
  Prelude.NFData
    DescribeProtectionGroupResponse
  where
  rnf :: DescribeProtectionGroupResponse -> ()
rnf DescribeProtectionGroupResponse' {Int
ProtectionGroup
protectionGroup :: ProtectionGroup
httpStatus :: Int
$sel:protectionGroup:DescribeProtectionGroupResponse' :: DescribeProtectionGroupResponse -> ProtectionGroup
$sel:httpStatus:DescribeProtectionGroupResponse' :: DescribeProtectionGroupResponse -> 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 ProtectionGroup
protectionGroup