{-# 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.Snowball.UpdateLongTermPricing
-- 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 long-term pricing type.
module Amazonka.Snowball.UpdateLongTermPricing
  ( -- * Creating a Request
    UpdateLongTermPricing (..),
    newUpdateLongTermPricing,

    -- * Request Lenses
    updateLongTermPricing_isLongTermPricingAutoRenew,
    updateLongTermPricing_replacementJob,
    updateLongTermPricing_longTermPricingId,

    -- * Destructuring the Response
    UpdateLongTermPricingResponse (..),
    newUpdateLongTermPricingResponse,

    -- * Response Lenses
    updateLongTermPricingResponse_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.Snowball.Types

-- | /See:/ 'newUpdateLongTermPricing' smart constructor.
data UpdateLongTermPricing = UpdateLongTermPricing'
  { -- | If set to @true@, specifies that the current long-term pricing type for
    -- the device should be automatically renewed before the long-term pricing
    -- contract expires.
    UpdateLongTermPricing -> Maybe Bool
isLongTermPricingAutoRenew :: Prelude.Maybe Prelude.Bool,
    -- | Specifies that a device that is ordered with long-term pricing should be
    -- replaced with a new device.
    UpdateLongTermPricing -> Maybe Text
replacementJob :: Prelude.Maybe Prelude.Text,
    -- | The ID of the long-term pricing type for the device.
    UpdateLongTermPricing -> Text
longTermPricingId :: Prelude.Text
  }
  deriving (UpdateLongTermPricing -> UpdateLongTermPricing -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateLongTermPricing -> UpdateLongTermPricing -> Bool
$c/= :: UpdateLongTermPricing -> UpdateLongTermPricing -> Bool
== :: UpdateLongTermPricing -> UpdateLongTermPricing -> Bool
$c== :: UpdateLongTermPricing -> UpdateLongTermPricing -> Bool
Prelude.Eq, ReadPrec [UpdateLongTermPricing]
ReadPrec UpdateLongTermPricing
Int -> ReadS UpdateLongTermPricing
ReadS [UpdateLongTermPricing]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateLongTermPricing]
$creadListPrec :: ReadPrec [UpdateLongTermPricing]
readPrec :: ReadPrec UpdateLongTermPricing
$creadPrec :: ReadPrec UpdateLongTermPricing
readList :: ReadS [UpdateLongTermPricing]
$creadList :: ReadS [UpdateLongTermPricing]
readsPrec :: Int -> ReadS UpdateLongTermPricing
$creadsPrec :: Int -> ReadS UpdateLongTermPricing
Prelude.Read, Int -> UpdateLongTermPricing -> ShowS
[UpdateLongTermPricing] -> ShowS
UpdateLongTermPricing -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateLongTermPricing] -> ShowS
$cshowList :: [UpdateLongTermPricing] -> ShowS
show :: UpdateLongTermPricing -> String
$cshow :: UpdateLongTermPricing -> String
showsPrec :: Int -> UpdateLongTermPricing -> ShowS
$cshowsPrec :: Int -> UpdateLongTermPricing -> ShowS
Prelude.Show, forall x. Rep UpdateLongTermPricing x -> UpdateLongTermPricing
forall x. UpdateLongTermPricing -> Rep UpdateLongTermPricing x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateLongTermPricing x -> UpdateLongTermPricing
$cfrom :: forall x. UpdateLongTermPricing -> Rep UpdateLongTermPricing x
Prelude.Generic)

-- |
-- Create a value of 'UpdateLongTermPricing' 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:
--
-- 'isLongTermPricingAutoRenew', 'updateLongTermPricing_isLongTermPricingAutoRenew' - If set to @true@, specifies that the current long-term pricing type for
-- the device should be automatically renewed before the long-term pricing
-- contract expires.
--
-- 'replacementJob', 'updateLongTermPricing_replacementJob' - Specifies that a device that is ordered with long-term pricing should be
-- replaced with a new device.
--
-- 'longTermPricingId', 'updateLongTermPricing_longTermPricingId' - The ID of the long-term pricing type for the device.
newUpdateLongTermPricing ::
  -- | 'longTermPricingId'
  Prelude.Text ->
  UpdateLongTermPricing
newUpdateLongTermPricing :: Text -> UpdateLongTermPricing
newUpdateLongTermPricing Text
pLongTermPricingId_ =
  UpdateLongTermPricing'
    { $sel:isLongTermPricingAutoRenew:UpdateLongTermPricing' :: Maybe Bool
isLongTermPricingAutoRenew =
        forall a. Maybe a
Prelude.Nothing,
      $sel:replacementJob:UpdateLongTermPricing' :: Maybe Text
replacementJob = forall a. Maybe a
Prelude.Nothing,
      $sel:longTermPricingId:UpdateLongTermPricing' :: Text
longTermPricingId = Text
pLongTermPricingId_
    }

-- | If set to @true@, specifies that the current long-term pricing type for
-- the device should be automatically renewed before the long-term pricing
-- contract expires.
updateLongTermPricing_isLongTermPricingAutoRenew :: Lens.Lens' UpdateLongTermPricing (Prelude.Maybe Prelude.Bool)
updateLongTermPricing_isLongTermPricingAutoRenew :: Lens' UpdateLongTermPricing (Maybe Bool)
updateLongTermPricing_isLongTermPricingAutoRenew = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateLongTermPricing' {Maybe Bool
isLongTermPricingAutoRenew :: Maybe Bool
$sel:isLongTermPricingAutoRenew:UpdateLongTermPricing' :: UpdateLongTermPricing -> Maybe Bool
isLongTermPricingAutoRenew} -> Maybe Bool
isLongTermPricingAutoRenew) (\s :: UpdateLongTermPricing
s@UpdateLongTermPricing' {} Maybe Bool
a -> UpdateLongTermPricing
s {$sel:isLongTermPricingAutoRenew:UpdateLongTermPricing' :: Maybe Bool
isLongTermPricingAutoRenew = Maybe Bool
a} :: UpdateLongTermPricing)

-- | Specifies that a device that is ordered with long-term pricing should be
-- replaced with a new device.
updateLongTermPricing_replacementJob :: Lens.Lens' UpdateLongTermPricing (Prelude.Maybe Prelude.Text)
updateLongTermPricing_replacementJob :: Lens' UpdateLongTermPricing (Maybe Text)
updateLongTermPricing_replacementJob = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateLongTermPricing' {Maybe Text
replacementJob :: Maybe Text
$sel:replacementJob:UpdateLongTermPricing' :: UpdateLongTermPricing -> Maybe Text
replacementJob} -> Maybe Text
replacementJob) (\s :: UpdateLongTermPricing
s@UpdateLongTermPricing' {} Maybe Text
a -> UpdateLongTermPricing
s {$sel:replacementJob:UpdateLongTermPricing' :: Maybe Text
replacementJob = Maybe Text
a} :: UpdateLongTermPricing)

-- | The ID of the long-term pricing type for the device.
updateLongTermPricing_longTermPricingId :: Lens.Lens' UpdateLongTermPricing Prelude.Text
updateLongTermPricing_longTermPricingId :: Lens' UpdateLongTermPricing Text
updateLongTermPricing_longTermPricingId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateLongTermPricing' {Text
longTermPricingId :: Text
$sel:longTermPricingId:UpdateLongTermPricing' :: UpdateLongTermPricing -> Text
longTermPricingId} -> Text
longTermPricingId) (\s :: UpdateLongTermPricing
s@UpdateLongTermPricing' {} Text
a -> UpdateLongTermPricing
s {$sel:longTermPricingId:UpdateLongTermPricing' :: Text
longTermPricingId = Text
a} :: UpdateLongTermPricing)

instance Core.AWSRequest UpdateLongTermPricing where
  type
    AWSResponse UpdateLongTermPricing =
      UpdateLongTermPricingResponse
  request :: (Service -> Service)
-> UpdateLongTermPricing -> Request UpdateLongTermPricing
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 UpdateLongTermPricing
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateLongTermPricing)))
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 -> UpdateLongTermPricingResponse
UpdateLongTermPricingResponse'
            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 UpdateLongTermPricing where
  hashWithSalt :: Int -> UpdateLongTermPricing -> Int
hashWithSalt Int
_salt UpdateLongTermPricing' {Maybe Bool
Maybe Text
Text
longTermPricingId :: Text
replacementJob :: Maybe Text
isLongTermPricingAutoRenew :: Maybe Bool
$sel:longTermPricingId:UpdateLongTermPricing' :: UpdateLongTermPricing -> Text
$sel:replacementJob:UpdateLongTermPricing' :: UpdateLongTermPricing -> Maybe Text
$sel:isLongTermPricingAutoRenew:UpdateLongTermPricing' :: UpdateLongTermPricing -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
isLongTermPricingAutoRenew
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
replacementJob
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
longTermPricingId

instance Prelude.NFData UpdateLongTermPricing where
  rnf :: UpdateLongTermPricing -> ()
rnf UpdateLongTermPricing' {Maybe Bool
Maybe Text
Text
longTermPricingId :: Text
replacementJob :: Maybe Text
isLongTermPricingAutoRenew :: Maybe Bool
$sel:longTermPricingId:UpdateLongTermPricing' :: UpdateLongTermPricing -> Text
$sel:replacementJob:UpdateLongTermPricing' :: UpdateLongTermPricing -> Maybe Text
$sel:isLongTermPricingAutoRenew:UpdateLongTermPricing' :: UpdateLongTermPricing -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
isLongTermPricingAutoRenew
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
replacementJob
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
longTermPricingId

instance Data.ToHeaders UpdateLongTermPricing where
  toHeaders :: UpdateLongTermPricing -> 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
"AWSIESnowballJobManagementService.UpdateLongTermPricing" ::
                          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 UpdateLongTermPricing where
  toJSON :: UpdateLongTermPricing -> Value
toJSON UpdateLongTermPricing' {Maybe Bool
Maybe Text
Text
longTermPricingId :: Text
replacementJob :: Maybe Text
isLongTermPricingAutoRenew :: Maybe Bool
$sel:longTermPricingId:UpdateLongTermPricing' :: UpdateLongTermPricing -> Text
$sel:replacementJob:UpdateLongTermPricing' :: UpdateLongTermPricing -> Maybe Text
$sel:isLongTermPricingAutoRenew:UpdateLongTermPricing' :: UpdateLongTermPricing -> Maybe Bool
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"IsLongTermPricingAutoRenew" 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 Bool
isLongTermPricingAutoRenew,
            (Key
"ReplacementJob" 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 Text
replacementJob,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"LongTermPricingId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
longTermPricingId)
          ]
      )

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

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

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

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

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

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