{-# 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-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 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.Lens as Lens
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
(UpdateLongTermPricing -> UpdateLongTermPricing -> Bool)
-> (UpdateLongTermPricing -> UpdateLongTermPricing -> Bool)
-> Eq UpdateLongTermPricing
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]
(Int -> ReadS UpdateLongTermPricing)
-> ReadS [UpdateLongTermPricing]
-> ReadPrec UpdateLongTermPricing
-> ReadPrec [UpdateLongTermPricing]
-> Read 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
(Int -> UpdateLongTermPricing -> ShowS)
-> (UpdateLongTermPricing -> String)
-> ([UpdateLongTermPricing] -> ShowS)
-> Show UpdateLongTermPricing
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. UpdateLongTermPricing -> Rep UpdateLongTermPricing x)
-> (forall x. Rep UpdateLongTermPricing x -> UpdateLongTermPricing)
-> Generic UpdateLongTermPricing
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' :: Maybe Bool -> Maybe Text -> Text -> UpdateLongTermPricing
UpdateLongTermPricing'
    { $sel:isLongTermPricingAutoRenew:UpdateLongTermPricing' :: Maybe Bool
isLongTermPricingAutoRenew =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:replacementJob:UpdateLongTermPricing' :: Maybe Text
replacementJob = Maybe Text
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 :: (Maybe Bool -> f (Maybe Bool))
-> UpdateLongTermPricing -> f UpdateLongTermPricing
updateLongTermPricing_isLongTermPricingAutoRenew = (UpdateLongTermPricing -> Maybe Bool)
-> (UpdateLongTermPricing -> Maybe Bool -> UpdateLongTermPricing)
-> Lens
     UpdateLongTermPricing
     UpdateLongTermPricing
     (Maybe Bool)
     (Maybe Bool)
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 :: (Maybe Text -> f (Maybe Text))
-> UpdateLongTermPricing -> f UpdateLongTermPricing
updateLongTermPricing_replacementJob = (UpdateLongTermPricing -> Maybe Text)
-> (UpdateLongTermPricing -> Maybe Text -> UpdateLongTermPricing)
-> Lens
     UpdateLongTermPricing
     UpdateLongTermPricing
     (Maybe Text)
     (Maybe Text)
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 :: (Text -> f Text)
-> UpdateLongTermPricing -> f UpdateLongTermPricing
updateLongTermPricing_longTermPricingId = (UpdateLongTermPricing -> Text)
-> (UpdateLongTermPricing -> Text -> UpdateLongTermPricing)
-> Lens UpdateLongTermPricing UpdateLongTermPricing Text Text
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 :: UpdateLongTermPricing -> Request UpdateLongTermPricing
request = Service -> UpdateLongTermPricing -> Request UpdateLongTermPricing
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateLongTermPricing
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateLongTermPricing)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse UpdateLongTermPricing))
-> Logger
-> Service
-> Proxy UpdateLongTermPricing
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateLongTermPricing)))
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 -> UpdateLongTermPricingResponse
UpdateLongTermPricingResponse'
            (Int -> UpdateLongTermPricingResponse)
-> Either String Int -> Either String UpdateLongTermPricingResponse
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 UpdateLongTermPricing

instance Prelude.NFData UpdateLongTermPricing

instance Core.ToHeaders UpdateLongTermPricing where
  toHeaders :: UpdateLongTermPricing -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateLongTermPricing -> 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
"AWSIESnowballJobManagementService.UpdateLongTermPricing" ::
                          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 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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"IsLongTermPricingAutoRenew" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
isLongTermPricingAutoRenew,
            (Text
"ReplacementJob" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
replacementJob,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"LongTermPricingId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
longTermPricingId)
          ]
      )

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

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

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