{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Activates Shield Advanced for an account.
--
-- For accounts that are members of an Organizations organization, Shield
-- Advanced subscriptions are billed against the organization\'s payer
-- account, regardless of whether the payer account itself is subscribed.
--
-- When you initially 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.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:/ 'newCreateSubscription' smart constructor.
data CreateSubscription = CreateSubscription'
  {
  }
  deriving (CreateSubscription -> CreateSubscription -> Bool
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]
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
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. 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 :: (Service -> Service)
-> CreateSubscription -> Request CreateSubscription
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 CreateSubscription
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateSubscription)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> CreateSubscriptionResponse
CreateSubscriptionResponse'
            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))
      )

instance Prelude.Hashable CreateSubscription where
  hashWithSalt :: Int -> CreateSubscription -> Int
hashWithSalt Int
_salt CreateSubscription
_ =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ()

instance Prelude.NFData CreateSubscription where
  rnf :: CreateSubscription -> ()
rnf CreateSubscription
_ = ()

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

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

instance Data.ToQuery CreateSubscription where
  toQuery :: CreateSubscription -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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.
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'
    { $sel:httpStatus:CreateSubscriptionResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
createSubscriptionResponse_httpStatus :: Lens.Lens' CreateSubscriptionResponse Prelude.Int
createSubscriptionResponse_httpStatus :: Lens' CreateSubscriptionResponse Int
createSubscriptionResponse_httpStatus = 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 where
  rnf :: CreateSubscriptionResponse -> ()
rnf CreateSubscriptionResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateSubscriptionResponse' :: CreateSubscriptionResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus