{-# 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.DescribeSubscription
-- 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)
--
-- Provides details about the Shield Advanced subscription for an account.
module Amazonka.Shield.DescribeSubscription
  ( -- * Creating a Request
    DescribeSubscription (..),
    newDescribeSubscription,

    -- * Destructuring the Response
    DescribeSubscriptionResponse (..),
    newDescribeSubscriptionResponse,

    -- * Response Lenses
    describeSubscriptionResponse_subscription,
    describeSubscriptionResponse_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.Shield.Types

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

-- |
-- Create a value of 'DescribeSubscription' 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.
newDescribeSubscription ::
  DescribeSubscription
newDescribeSubscription :: DescribeSubscription
newDescribeSubscription = DescribeSubscription
DescribeSubscription'

instance Core.AWSRequest DescribeSubscription where
  type
    AWSResponse DescribeSubscription =
      DescribeSubscriptionResponse
  request :: DescribeSubscription -> Request DescribeSubscription
request = Service -> DescribeSubscription -> Request DescribeSubscription
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeSubscription
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeSubscription)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeSubscription))
-> Logger
-> Service
-> Proxy DescribeSubscription
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeSubscription)))
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 Subscription -> Int -> DescribeSubscriptionResponse
DescribeSubscriptionResponse'
            (Maybe Subscription -> Int -> DescribeSubscriptionResponse)
-> Either String (Maybe Subscription)
-> Either String (Int -> DescribeSubscriptionResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Key -> Either String (Maybe Subscription)
forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Core..?> Key
"Subscription")
            Either String (Int -> DescribeSubscriptionResponse)
-> Either String Int -> Either String DescribeSubscriptionResponse
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 DescribeSubscription

instance Prelude.NFData DescribeSubscription

instance Core.ToHeaders DescribeSubscription where
  toHeaders :: DescribeSubscription -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeSubscription -> 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.DescribeSubscription" ::
                          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 DescribeSubscription where
  toJSON :: DescribeSubscription -> Value
toJSON = Value -> DescribeSubscription -> Value
forall a b. a -> b -> a
Prelude.const (Object -> Value
Core.Object Object
forall a. Monoid a => a
Prelude.mempty)

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

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

-- | /See:/ 'newDescribeSubscriptionResponse' smart constructor.
data DescribeSubscriptionResponse = DescribeSubscriptionResponse'
  { -- | The Shield Advanced subscription details for an account.
    DescribeSubscriptionResponse -> Maybe Subscription
subscription :: Prelude.Maybe Subscription,
    -- | The response's http status code.
    DescribeSubscriptionResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeSubscriptionResponse
-> DescribeSubscriptionResponse -> Bool
(DescribeSubscriptionResponse
 -> DescribeSubscriptionResponse -> Bool)
-> (DescribeSubscriptionResponse
    -> DescribeSubscriptionResponse -> Bool)
-> Eq DescribeSubscriptionResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeSubscriptionResponse
-> DescribeSubscriptionResponse -> Bool
$c/= :: DescribeSubscriptionResponse
-> DescribeSubscriptionResponse -> Bool
== :: DescribeSubscriptionResponse
-> DescribeSubscriptionResponse -> Bool
$c== :: DescribeSubscriptionResponse
-> DescribeSubscriptionResponse -> Bool
Prelude.Eq, ReadPrec [DescribeSubscriptionResponse]
ReadPrec DescribeSubscriptionResponse
Int -> ReadS DescribeSubscriptionResponse
ReadS [DescribeSubscriptionResponse]
(Int -> ReadS DescribeSubscriptionResponse)
-> ReadS [DescribeSubscriptionResponse]
-> ReadPrec DescribeSubscriptionResponse
-> ReadPrec [DescribeSubscriptionResponse]
-> Read DescribeSubscriptionResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeSubscriptionResponse]
$creadListPrec :: ReadPrec [DescribeSubscriptionResponse]
readPrec :: ReadPrec DescribeSubscriptionResponse
$creadPrec :: ReadPrec DescribeSubscriptionResponse
readList :: ReadS [DescribeSubscriptionResponse]
$creadList :: ReadS [DescribeSubscriptionResponse]
readsPrec :: Int -> ReadS DescribeSubscriptionResponse
$creadsPrec :: Int -> ReadS DescribeSubscriptionResponse
Prelude.Read, Int -> DescribeSubscriptionResponse -> ShowS
[DescribeSubscriptionResponse] -> ShowS
DescribeSubscriptionResponse -> String
(Int -> DescribeSubscriptionResponse -> ShowS)
-> (DescribeSubscriptionResponse -> String)
-> ([DescribeSubscriptionResponse] -> ShowS)
-> Show DescribeSubscriptionResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeSubscriptionResponse] -> ShowS
$cshowList :: [DescribeSubscriptionResponse] -> ShowS
show :: DescribeSubscriptionResponse -> String
$cshow :: DescribeSubscriptionResponse -> String
showsPrec :: Int -> DescribeSubscriptionResponse -> ShowS
$cshowsPrec :: Int -> DescribeSubscriptionResponse -> ShowS
Prelude.Show, (forall x.
 DescribeSubscriptionResponse -> Rep DescribeSubscriptionResponse x)
-> (forall x.
    Rep DescribeSubscriptionResponse x -> DescribeSubscriptionResponse)
-> Generic DescribeSubscriptionResponse
forall x.
Rep DescribeSubscriptionResponse x -> DescribeSubscriptionResponse
forall x.
DescribeSubscriptionResponse -> Rep DescribeSubscriptionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeSubscriptionResponse x -> DescribeSubscriptionResponse
$cfrom :: forall x.
DescribeSubscriptionResponse -> Rep DescribeSubscriptionResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeSubscriptionResponse' 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:
--
-- 'subscription', 'describeSubscriptionResponse_subscription' - The Shield Advanced subscription details for an account.
--
-- 'httpStatus', 'describeSubscriptionResponse_httpStatus' - The response's http status code.
newDescribeSubscriptionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeSubscriptionResponse
newDescribeSubscriptionResponse :: Int -> DescribeSubscriptionResponse
newDescribeSubscriptionResponse Int
pHttpStatus_ =
  DescribeSubscriptionResponse' :: Maybe Subscription -> Int -> DescribeSubscriptionResponse
DescribeSubscriptionResponse'
    { $sel:subscription:DescribeSubscriptionResponse' :: Maybe Subscription
subscription =
        Maybe Subscription
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeSubscriptionResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The Shield Advanced subscription details for an account.
describeSubscriptionResponse_subscription :: Lens.Lens' DescribeSubscriptionResponse (Prelude.Maybe Subscription)
describeSubscriptionResponse_subscription :: (Maybe Subscription -> f (Maybe Subscription))
-> DescribeSubscriptionResponse -> f DescribeSubscriptionResponse
describeSubscriptionResponse_subscription = (DescribeSubscriptionResponse -> Maybe Subscription)
-> (DescribeSubscriptionResponse
    -> Maybe Subscription -> DescribeSubscriptionResponse)
-> Lens
     DescribeSubscriptionResponse
     DescribeSubscriptionResponse
     (Maybe Subscription)
     (Maybe Subscription)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeSubscriptionResponse' {Maybe Subscription
subscription :: Maybe Subscription
$sel:subscription:DescribeSubscriptionResponse' :: DescribeSubscriptionResponse -> Maybe Subscription
subscription} -> Maybe Subscription
subscription) (\s :: DescribeSubscriptionResponse
s@DescribeSubscriptionResponse' {} Maybe Subscription
a -> DescribeSubscriptionResponse
s {$sel:subscription:DescribeSubscriptionResponse' :: Maybe Subscription
subscription = Maybe Subscription
a} :: DescribeSubscriptionResponse)

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

instance Prelude.NFData DescribeSubscriptionResponse