{-# 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.UpdateSubscription
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Updates the details of an existing subscription. Only enter values for
-- parameters you want to change. Empty parameters are not updated.
--
-- 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.
module Amazonka.Shield.UpdateSubscription
  ( -- * Creating a Request
    UpdateSubscription (..),
    newUpdateSubscription,

    -- * Request Lenses
    updateSubscription_autoRenew,

    -- * Destructuring the Response
    UpdateSubscriptionResponse (..),
    newUpdateSubscriptionResponse,

    -- * Response Lenses
    updateSubscriptionResponse_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:/ 'newUpdateSubscription' smart constructor.
data UpdateSubscription = UpdateSubscription'
  { -- | When you initally create a subscription, @AutoRenew@ is set to
    -- @ENABLED@. If @ENABLED@, the subscription will be automatically renewed
    -- at the end of the existing subscription period. You can change this by
    -- submitting an @UpdateSubscription@ request. If the @UpdateSubscription@
    -- request does not included a value for @AutoRenew@, the existing value
    -- for @AutoRenew@ remains unchanged.
    UpdateSubscription -> Maybe AutoRenew
autoRenew :: Prelude.Maybe AutoRenew
  }
  deriving (UpdateSubscription -> UpdateSubscription -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateSubscription -> UpdateSubscription -> Bool
$c/= :: UpdateSubscription -> UpdateSubscription -> Bool
== :: UpdateSubscription -> UpdateSubscription -> Bool
$c== :: UpdateSubscription -> UpdateSubscription -> Bool
Prelude.Eq, ReadPrec [UpdateSubscription]
ReadPrec UpdateSubscription
Int -> ReadS UpdateSubscription
ReadS [UpdateSubscription]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateSubscription]
$creadListPrec :: ReadPrec [UpdateSubscription]
readPrec :: ReadPrec UpdateSubscription
$creadPrec :: ReadPrec UpdateSubscription
readList :: ReadS [UpdateSubscription]
$creadList :: ReadS [UpdateSubscription]
readsPrec :: Int -> ReadS UpdateSubscription
$creadsPrec :: Int -> ReadS UpdateSubscription
Prelude.Read, Int -> UpdateSubscription -> ShowS
[UpdateSubscription] -> ShowS
UpdateSubscription -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateSubscription] -> ShowS
$cshowList :: [UpdateSubscription] -> ShowS
show :: UpdateSubscription -> String
$cshow :: UpdateSubscription -> String
showsPrec :: Int -> UpdateSubscription -> ShowS
$cshowsPrec :: Int -> UpdateSubscription -> ShowS
Prelude.Show, forall x. Rep UpdateSubscription x -> UpdateSubscription
forall x. UpdateSubscription -> Rep UpdateSubscription x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateSubscription x -> UpdateSubscription
$cfrom :: forall x. UpdateSubscription -> Rep UpdateSubscription x
Prelude.Generic)

-- |
-- Create a value of 'UpdateSubscription' 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:
--
-- 'autoRenew', 'updateSubscription_autoRenew' - When you initally create a subscription, @AutoRenew@ is set to
-- @ENABLED@. If @ENABLED@, the subscription will be automatically renewed
-- at the end of the existing subscription period. You can change this by
-- submitting an @UpdateSubscription@ request. If the @UpdateSubscription@
-- request does not included a value for @AutoRenew@, the existing value
-- for @AutoRenew@ remains unchanged.
newUpdateSubscription ::
  UpdateSubscription
newUpdateSubscription :: UpdateSubscription
newUpdateSubscription =
  UpdateSubscription' {$sel:autoRenew:UpdateSubscription' :: Maybe AutoRenew
autoRenew = forall a. Maybe a
Prelude.Nothing}

-- | When you initally create a subscription, @AutoRenew@ is set to
-- @ENABLED@. If @ENABLED@, the subscription will be automatically renewed
-- at the end of the existing subscription period. You can change this by
-- submitting an @UpdateSubscription@ request. If the @UpdateSubscription@
-- request does not included a value for @AutoRenew@, the existing value
-- for @AutoRenew@ remains unchanged.
updateSubscription_autoRenew :: Lens.Lens' UpdateSubscription (Prelude.Maybe AutoRenew)
updateSubscription_autoRenew :: Lens' UpdateSubscription (Maybe AutoRenew)
updateSubscription_autoRenew = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateSubscription' {Maybe AutoRenew
autoRenew :: Maybe AutoRenew
$sel:autoRenew:UpdateSubscription' :: UpdateSubscription -> Maybe AutoRenew
autoRenew} -> Maybe AutoRenew
autoRenew) (\s :: UpdateSubscription
s@UpdateSubscription' {} Maybe AutoRenew
a -> UpdateSubscription
s {$sel:autoRenew:UpdateSubscription' :: Maybe AutoRenew
autoRenew = Maybe AutoRenew
a} :: UpdateSubscription)

instance Core.AWSRequest UpdateSubscription where
  type
    AWSResponse UpdateSubscription =
      UpdateSubscriptionResponse
  request :: (Service -> Service)
-> UpdateSubscription -> Request UpdateSubscription
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 UpdateSubscription
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateSubscription)))
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 -> UpdateSubscriptionResponse
UpdateSubscriptionResponse'
            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 UpdateSubscription where
  hashWithSalt :: Int -> UpdateSubscription -> Int
hashWithSalt Int
_salt UpdateSubscription' {Maybe AutoRenew
autoRenew :: Maybe AutoRenew
$sel:autoRenew:UpdateSubscription' :: UpdateSubscription -> Maybe AutoRenew
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AutoRenew
autoRenew

instance Prelude.NFData UpdateSubscription where
  rnf :: UpdateSubscription -> ()
rnf UpdateSubscription' {Maybe AutoRenew
autoRenew :: Maybe AutoRenew
$sel:autoRenew:UpdateSubscription' :: UpdateSubscription -> Maybe AutoRenew
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe AutoRenew
autoRenew

instance Data.ToHeaders UpdateSubscription where
  toHeaders :: UpdateSubscription -> 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.UpdateSubscription" ::
                          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 UpdateSubscription where
  toJSON :: UpdateSubscription -> Value
toJSON UpdateSubscription' {Maybe AutoRenew
autoRenew :: Maybe AutoRenew
$sel:autoRenew:UpdateSubscription' :: UpdateSubscription -> Maybe AutoRenew
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Key
"AutoRenew" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe AutoRenew
autoRenew]
      )

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

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

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

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

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

instance Prelude.NFData UpdateSubscriptionResponse where
  rnf :: UpdateSubscriptionResponse -> ()
rnf UpdateSubscriptionResponse' {Int
httpStatus :: Int
$sel:httpStatus:UpdateSubscriptionResponse' :: UpdateSubscriptionResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus