{-# 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-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)
--
-- 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.Lens as Lens
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
(DescribeProtectionGroup -> DescribeProtectionGroup -> Bool)
-> (DescribeProtectionGroup -> DescribeProtectionGroup -> Bool)
-> Eq DescribeProtectionGroup
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]
(Int -> ReadS DescribeProtectionGroup)
-> ReadS [DescribeProtectionGroup]
-> ReadPrec DescribeProtectionGroup
-> ReadPrec [DescribeProtectionGroup]
-> Read 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
(Int -> DescribeProtectionGroup -> ShowS)
-> (DescribeProtectionGroup -> String)
-> ([DescribeProtectionGroup] -> ShowS)
-> Show DescribeProtectionGroup
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.
 DescribeProtectionGroup -> Rep DescribeProtectionGroup x)
-> (forall x.
    Rep DescribeProtectionGroup x -> DescribeProtectionGroup)
-> Generic DescribeProtectionGroup
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' :: Text -> DescribeProtectionGroup
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 :: (Text -> f Text)
-> DescribeProtectionGroup -> f DescribeProtectionGroup
describeProtectionGroup_protectionGroupId = (DescribeProtectionGroup -> Text)
-> (DescribeProtectionGroup -> Text -> DescribeProtectionGroup)
-> Lens DescribeProtectionGroup DescribeProtectionGroup Text Text
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 :: DescribeProtectionGroup -> Request DescribeProtectionGroup
request = Service
-> DescribeProtectionGroup -> Request DescribeProtectionGroup
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeProtectionGroup
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeProtectionGroup)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeProtectionGroup))
-> Logger
-> Service
-> Proxy DescribeProtectionGroup
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeProtectionGroup)))
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 ->
          Int -> ProtectionGroup -> DescribeProtectionGroupResponse
DescribeProtectionGroupResponse'
            (Int -> ProtectionGroup -> DescribeProtectionGroupResponse)
-> Either String Int
-> Either
     String (ProtectionGroup -> DescribeProtectionGroupResponse)
forall (f :: * -> *) a b. Functor 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))
            Either String (ProtectionGroup -> DescribeProtectionGroupResponse)
-> Either String ProtectionGroup
-> Either String DescribeProtectionGroupResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String ProtectionGroup
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"ProtectionGroup")
      )

instance Prelude.Hashable DescribeProtectionGroup

instance Prelude.NFData DescribeProtectionGroup

instance Core.ToHeaders DescribeProtectionGroup where
  toHeaders :: DescribeProtectionGroup -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeProtectionGroup -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"AWSShield_20160616.DescribeProtectionGroup" ::
                          Prelude.ByteString
                      ),
            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.ToJSON DescribeProtectionGroup where
  toJSON :: DescribeProtectionGroup -> Value
toJSON DescribeProtectionGroup' {Text
protectionGroupId :: Text
$sel:protectionGroupId:DescribeProtectionGroup' :: DescribeProtectionGroup -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ProtectionGroupId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
protectionGroupId)
          ]
      )

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

instance Core.ToQuery DescribeProtectionGroup where
  toQuery :: DescribeProtectionGroup -> QueryString
toQuery = QueryString -> DescribeProtectionGroup -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(DescribeProtectionGroupResponse
 -> DescribeProtectionGroupResponse -> Bool)
-> (DescribeProtectionGroupResponse
    -> DescribeProtectionGroupResponse -> Bool)
-> Eq DescribeProtectionGroupResponse
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]
(Int -> ReadS DescribeProtectionGroupResponse)
-> ReadS [DescribeProtectionGroupResponse]
-> ReadPrec DescribeProtectionGroupResponse
-> ReadPrec [DescribeProtectionGroupResponse]
-> Read 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
(Int -> DescribeProtectionGroupResponse -> ShowS)
-> (DescribeProtectionGroupResponse -> String)
-> ([DescribeProtectionGroupResponse] -> ShowS)
-> Show DescribeProtectionGroupResponse
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.
 DescribeProtectionGroupResponse
 -> Rep DescribeProtectionGroupResponse x)
-> (forall x.
    Rep DescribeProtectionGroupResponse x
    -> DescribeProtectionGroupResponse)
-> Generic DescribeProtectionGroupResponse
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' :: Int -> ProtectionGroup -> DescribeProtectionGroupResponse
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 :: (Int -> f Int)
-> DescribeProtectionGroupResponse
-> f DescribeProtectionGroupResponse
describeProtectionGroupResponse_httpStatus = (DescribeProtectionGroupResponse -> Int)
-> (DescribeProtectionGroupResponse
    -> Int -> DescribeProtectionGroupResponse)
-> Lens
     DescribeProtectionGroupResponse
     DescribeProtectionGroupResponse
     Int
     Int
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 :: (ProtectionGroup -> f ProtectionGroup)
-> DescribeProtectionGroupResponse
-> f DescribeProtectionGroupResponse
describeProtectionGroupResponse_protectionGroup = (DescribeProtectionGroupResponse -> ProtectionGroup)
-> (DescribeProtectionGroupResponse
    -> ProtectionGroup -> DescribeProtectionGroupResponse)
-> Lens
     DescribeProtectionGroupResponse
     DescribeProtectionGroupResponse
     ProtectionGroup
     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