{-# 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-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)
--
-- Updates the details of an existing subscription. Only enter values for
-- parameters you want to change. Empty parameters are not updated.
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.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:/ '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
(UpdateSubscription -> UpdateSubscription -> Bool)
-> (UpdateSubscription -> UpdateSubscription -> Bool)
-> Eq UpdateSubscription
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]
(Int -> ReadS UpdateSubscription)
-> ReadS [UpdateSubscription]
-> ReadPrec UpdateSubscription
-> ReadPrec [UpdateSubscription]
-> Read 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
(Int -> UpdateSubscription -> ShowS)
-> (UpdateSubscription -> String)
-> ([UpdateSubscription] -> ShowS)
-> Show UpdateSubscription
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. UpdateSubscription -> Rep UpdateSubscription x)
-> (forall x. Rep UpdateSubscription x -> UpdateSubscription)
-> Generic UpdateSubscription
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' :: Maybe AutoRenew -> UpdateSubscription
UpdateSubscription' {$sel:autoRenew:UpdateSubscription' :: Maybe AutoRenew
autoRenew = Maybe 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 :: (Maybe AutoRenew -> f (Maybe AutoRenew))
-> UpdateSubscription -> f UpdateSubscription
updateSubscription_autoRenew = (UpdateSubscription -> Maybe AutoRenew)
-> (UpdateSubscription -> Maybe AutoRenew -> UpdateSubscription)
-> Lens
     UpdateSubscription
     UpdateSubscription
     (Maybe AutoRenew)
     (Maybe 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 :: UpdateSubscription -> Request UpdateSubscription
request = Service -> UpdateSubscription -> Request UpdateSubscription
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateSubscription
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateSubscription)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse UpdateSubscription))
-> Logger
-> Service
-> Proxy UpdateSubscription
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateSubscription)))
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 -> UpdateSubscriptionResponse
UpdateSubscriptionResponse'
            (Int -> UpdateSubscriptionResponse)
-> Either String Int -> Either String UpdateSubscriptionResponse
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 UpdateSubscription

instance Prelude.NFData UpdateSubscription

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

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

instance Core.ToQuery UpdateSubscription where
  toQuery :: UpdateSubscription -> QueryString
toQuery = QueryString -> UpdateSubscription -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(UpdateSubscriptionResponse -> UpdateSubscriptionResponse -> Bool)
-> (UpdateSubscriptionResponse
    -> UpdateSubscriptionResponse -> Bool)
-> Eq UpdateSubscriptionResponse
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]
(Int -> ReadS UpdateSubscriptionResponse)
-> ReadS [UpdateSubscriptionResponse]
-> ReadPrec UpdateSubscriptionResponse
-> ReadPrec [UpdateSubscriptionResponse]
-> Read 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
(Int -> UpdateSubscriptionResponse -> ShowS)
-> (UpdateSubscriptionResponse -> String)
-> ([UpdateSubscriptionResponse] -> ShowS)
-> Show UpdateSubscriptionResponse
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.
 UpdateSubscriptionResponse -> Rep UpdateSubscriptionResponse x)
-> (forall x.
    Rep UpdateSubscriptionResponse x -> UpdateSubscriptionResponse)
-> Generic UpdateSubscriptionResponse
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' :: Int -> UpdateSubscriptionResponse
UpdateSubscriptionResponse'
    { $sel:httpStatus:UpdateSubscriptionResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
updateSubscriptionResponse_httpStatus :: Lens.Lens' UpdateSubscriptionResponse Prelude.Int
updateSubscriptionResponse_httpStatus :: (Int -> f Int)
-> UpdateSubscriptionResponse -> f UpdateSubscriptionResponse
updateSubscriptionResponse_httpStatus = (UpdateSubscriptionResponse -> Int)
-> (UpdateSubscriptionResponse
    -> Int -> UpdateSubscriptionResponse)
-> Lens
     UpdateSubscriptionResponse UpdateSubscriptionResponse Int Int
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