{-# 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.CreateSubscription
-- 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)
--
-- Activates Shield Advanced for an account.
--
-- When you initally create a subscription, your subscription is set to be
-- automatically renewed at the end of the existing subscription period.
-- You can change this by submitting an @UpdateSubscription@ request.
module Amazonka.Shield.CreateSubscription
  ( -- * Creating a Request
    CreateSubscription (..),
    newCreateSubscription,

    -- * Destructuring the Response
    CreateSubscriptionResponse (..),
    newCreateSubscriptionResponse,

    -- * Response Lenses
    createSubscriptionResponse_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:/ 'newCreateSubscription' smart constructor.
data CreateSubscription = CreateSubscription'
  {
  }
  deriving (CreateSubscription -> CreateSubscription -> Bool
(CreateSubscription -> CreateSubscription -> Bool)
-> (CreateSubscription -> CreateSubscription -> Bool)
-> Eq CreateSubscription
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateSubscription -> CreateSubscription -> Bool
$c/= :: CreateSubscription -> CreateSubscription -> Bool
== :: CreateSubscription -> CreateSubscription -> Bool
$c== :: CreateSubscription -> CreateSubscription -> Bool
Prelude.Eq, ReadPrec [CreateSubscription]
ReadPrec CreateSubscription
Int -> ReadS CreateSubscription
ReadS [CreateSubscription]
(Int -> ReadS CreateSubscription)
-> ReadS [CreateSubscription]
-> ReadPrec CreateSubscription
-> ReadPrec [CreateSubscription]
-> Read CreateSubscription
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateSubscription]
$creadListPrec :: ReadPrec [CreateSubscription]
readPrec :: ReadPrec CreateSubscription
$creadPrec :: ReadPrec CreateSubscription
readList :: ReadS [CreateSubscription]
$creadList :: ReadS [CreateSubscription]
readsPrec :: Int -> ReadS CreateSubscription
$creadsPrec :: Int -> ReadS CreateSubscription
Prelude.Read, Int -> CreateSubscription -> ShowS
[CreateSubscription] -> ShowS
CreateSubscription -> String
(Int -> CreateSubscription -> ShowS)
-> (CreateSubscription -> String)
-> ([CreateSubscription] -> ShowS)
-> Show CreateSubscription
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateSubscription] -> ShowS
$cshowList :: [CreateSubscription] -> ShowS
show :: CreateSubscription -> String
$cshow :: CreateSubscription -> String
showsPrec :: Int -> CreateSubscription -> ShowS
$cshowsPrec :: Int -> CreateSubscription -> ShowS
Prelude.Show, (forall x. CreateSubscription -> Rep CreateSubscription x)
-> (forall x. Rep CreateSubscription x -> CreateSubscription)
-> Generic CreateSubscription
forall x. Rep CreateSubscription x -> CreateSubscription
forall x. CreateSubscription -> Rep CreateSubscription x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateSubscription x -> CreateSubscription
$cfrom :: forall x. CreateSubscription -> Rep CreateSubscription x
Prelude.Generic)

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

instance Core.AWSRequest CreateSubscription where
  type
    AWSResponse CreateSubscription =
      CreateSubscriptionResponse
  request :: CreateSubscription -> Request CreateSubscription
request = Service -> CreateSubscription -> Request CreateSubscription
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateSubscription
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateSubscription)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse CreateSubscription))
-> Logger
-> Service
-> Proxy CreateSubscription
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateSubscription)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> CreateSubscriptionResponse
CreateSubscriptionResponse'
            (Int -> CreateSubscriptionResponse)
-> Either String Int -> Either String CreateSubscriptionResponse
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))
      )

instance Prelude.Hashable CreateSubscription

instance Prelude.NFData CreateSubscription

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

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

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

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

-- |
-- Create a value of 'CreateSubscriptionResponse' 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', 'createSubscriptionResponse_httpStatus' - The response's http status code.
newCreateSubscriptionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateSubscriptionResponse
newCreateSubscriptionResponse :: Int -> CreateSubscriptionResponse
newCreateSubscriptionResponse Int
pHttpStatus_ =
  CreateSubscriptionResponse' :: Int -> CreateSubscriptionResponse
CreateSubscriptionResponse'
    { $sel:httpStatus:CreateSubscriptionResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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

instance Prelude.NFData CreateSubscriptionResponse