{-# 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.IotTwinMaker.UpdatePricingPlan
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Update the pricing plan.
module Amazonka.IotTwinMaker.UpdatePricingPlan
  ( -- * Creating a Request
    UpdatePricingPlan (..),
    newUpdatePricingPlan,

    -- * Request Lenses
    updatePricingPlan_bundleNames,
    updatePricingPlan_pricingMode,

    -- * Destructuring the Response
    UpdatePricingPlanResponse (..),
    newUpdatePricingPlanResponse,

    -- * Response Lenses
    updatePricingPlanResponse_pendingPricingPlan,
    updatePricingPlanResponse_httpStatus,
    updatePricingPlanResponse_currentPricingPlan,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IotTwinMaker.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newUpdatePricingPlan' smart constructor.
data UpdatePricingPlan = UpdatePricingPlan'
  { -- | The bundle names.
    UpdatePricingPlan -> Maybe (NonEmpty Text)
bundleNames :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text),
    -- | The pricing mode.
    UpdatePricingPlan -> PricingMode
pricingMode :: PricingMode
  }
  deriving (UpdatePricingPlan -> UpdatePricingPlan -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdatePricingPlan -> UpdatePricingPlan -> Bool
$c/= :: UpdatePricingPlan -> UpdatePricingPlan -> Bool
== :: UpdatePricingPlan -> UpdatePricingPlan -> Bool
$c== :: UpdatePricingPlan -> UpdatePricingPlan -> Bool
Prelude.Eq, ReadPrec [UpdatePricingPlan]
ReadPrec UpdatePricingPlan
Int -> ReadS UpdatePricingPlan
ReadS [UpdatePricingPlan]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdatePricingPlan]
$creadListPrec :: ReadPrec [UpdatePricingPlan]
readPrec :: ReadPrec UpdatePricingPlan
$creadPrec :: ReadPrec UpdatePricingPlan
readList :: ReadS [UpdatePricingPlan]
$creadList :: ReadS [UpdatePricingPlan]
readsPrec :: Int -> ReadS UpdatePricingPlan
$creadsPrec :: Int -> ReadS UpdatePricingPlan
Prelude.Read, Int -> UpdatePricingPlan -> ShowS
[UpdatePricingPlan] -> ShowS
UpdatePricingPlan -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdatePricingPlan] -> ShowS
$cshowList :: [UpdatePricingPlan] -> ShowS
show :: UpdatePricingPlan -> String
$cshow :: UpdatePricingPlan -> String
showsPrec :: Int -> UpdatePricingPlan -> ShowS
$cshowsPrec :: Int -> UpdatePricingPlan -> ShowS
Prelude.Show, forall x. Rep UpdatePricingPlan x -> UpdatePricingPlan
forall x. UpdatePricingPlan -> Rep UpdatePricingPlan x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdatePricingPlan x -> UpdatePricingPlan
$cfrom :: forall x. UpdatePricingPlan -> Rep UpdatePricingPlan x
Prelude.Generic)

-- |
-- Create a value of 'UpdatePricingPlan' 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:
--
-- 'bundleNames', 'updatePricingPlan_bundleNames' - The bundle names.
--
-- 'pricingMode', 'updatePricingPlan_pricingMode' - The pricing mode.
newUpdatePricingPlan ::
  -- | 'pricingMode'
  PricingMode ->
  UpdatePricingPlan
newUpdatePricingPlan :: PricingMode -> UpdatePricingPlan
newUpdatePricingPlan PricingMode
pPricingMode_ =
  UpdatePricingPlan'
    { $sel:bundleNames:UpdatePricingPlan' :: Maybe (NonEmpty Text)
bundleNames = forall a. Maybe a
Prelude.Nothing,
      $sel:pricingMode:UpdatePricingPlan' :: PricingMode
pricingMode = PricingMode
pPricingMode_
    }

-- | The bundle names.
updatePricingPlan_bundleNames :: Lens.Lens' UpdatePricingPlan (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
updatePricingPlan_bundleNames :: Lens' UpdatePricingPlan (Maybe (NonEmpty Text))
updatePricingPlan_bundleNames = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdatePricingPlan' {Maybe (NonEmpty Text)
bundleNames :: Maybe (NonEmpty Text)
$sel:bundleNames:UpdatePricingPlan' :: UpdatePricingPlan -> Maybe (NonEmpty Text)
bundleNames} -> Maybe (NonEmpty Text)
bundleNames) (\s :: UpdatePricingPlan
s@UpdatePricingPlan' {} Maybe (NonEmpty Text)
a -> UpdatePricingPlan
s {$sel:bundleNames:UpdatePricingPlan' :: Maybe (NonEmpty Text)
bundleNames = Maybe (NonEmpty Text)
a} :: UpdatePricingPlan) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The pricing mode.
updatePricingPlan_pricingMode :: Lens.Lens' UpdatePricingPlan PricingMode
updatePricingPlan_pricingMode :: Lens' UpdatePricingPlan PricingMode
updatePricingPlan_pricingMode = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdatePricingPlan' {PricingMode
pricingMode :: PricingMode
$sel:pricingMode:UpdatePricingPlan' :: UpdatePricingPlan -> PricingMode
pricingMode} -> PricingMode
pricingMode) (\s :: UpdatePricingPlan
s@UpdatePricingPlan' {} PricingMode
a -> UpdatePricingPlan
s {$sel:pricingMode:UpdatePricingPlan' :: PricingMode
pricingMode = PricingMode
a} :: UpdatePricingPlan)

instance Core.AWSRequest UpdatePricingPlan where
  type
    AWSResponse UpdatePricingPlan =
      UpdatePricingPlanResponse
  request :: (Service -> Service)
-> UpdatePricingPlan -> Request UpdatePricingPlan
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 UpdatePricingPlan
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdatePricingPlan)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe PricingPlan
-> Int -> PricingPlan -> UpdatePricingPlanResponse
UpdatePricingPlanResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"pendingPricingPlan")
            forall (f :: * -> *) a b. Applicative f => 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))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"currentPricingPlan")
      )

instance Prelude.Hashable UpdatePricingPlan where
  hashWithSalt :: Int -> UpdatePricingPlan -> Int
hashWithSalt Int
_salt UpdatePricingPlan' {Maybe (NonEmpty Text)
PricingMode
pricingMode :: PricingMode
bundleNames :: Maybe (NonEmpty Text)
$sel:pricingMode:UpdatePricingPlan' :: UpdatePricingPlan -> PricingMode
$sel:bundleNames:UpdatePricingPlan' :: UpdatePricingPlan -> Maybe (NonEmpty Text)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty Text)
bundleNames
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` PricingMode
pricingMode

instance Prelude.NFData UpdatePricingPlan where
  rnf :: UpdatePricingPlan -> ()
rnf UpdatePricingPlan' {Maybe (NonEmpty Text)
PricingMode
pricingMode :: PricingMode
bundleNames :: Maybe (NonEmpty Text)
$sel:pricingMode:UpdatePricingPlan' :: UpdatePricingPlan -> PricingMode
$sel:bundleNames:UpdatePricingPlan' :: UpdatePricingPlan -> Maybe (NonEmpty Text)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty Text)
bundleNames
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf PricingMode
pricingMode

instance Data.ToHeaders UpdatePricingPlan where
  toHeaders :: UpdatePricingPlan -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON UpdatePricingPlan where
  toJSON :: UpdatePricingPlan -> Value
toJSON UpdatePricingPlan' {Maybe (NonEmpty Text)
PricingMode
pricingMode :: PricingMode
bundleNames :: Maybe (NonEmpty Text)
$sel:pricingMode:UpdatePricingPlan' :: UpdatePricingPlan -> PricingMode
$sel:bundleNames:UpdatePricingPlan' :: UpdatePricingPlan -> Maybe (NonEmpty Text)
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"bundleNames" 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 (NonEmpty Text)
bundleNames,
            forall a. a -> Maybe a
Prelude.Just (Key
"pricingMode" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= PricingMode
pricingMode)
          ]
      )

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

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

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

-- |
-- Create a value of 'UpdatePricingPlanResponse' 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:
--
-- 'pendingPricingPlan', 'updatePricingPlanResponse_pendingPricingPlan' - Update the pending pricing plan.
--
-- 'httpStatus', 'updatePricingPlanResponse_httpStatus' - The response's http status code.
--
-- 'currentPricingPlan', 'updatePricingPlanResponse_currentPricingPlan' - Update the current pricing plan.
newUpdatePricingPlanResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'currentPricingPlan'
  PricingPlan ->
  UpdatePricingPlanResponse
newUpdatePricingPlanResponse :: Int -> PricingPlan -> UpdatePricingPlanResponse
newUpdatePricingPlanResponse
  Int
pHttpStatus_
  PricingPlan
pCurrentPricingPlan_ =
    UpdatePricingPlanResponse'
      { $sel:pendingPricingPlan:UpdatePricingPlanResponse' :: Maybe PricingPlan
pendingPricingPlan =
          forall a. Maybe a
Prelude.Nothing,
        $sel:httpStatus:UpdatePricingPlanResponse' :: Int
httpStatus = Int
pHttpStatus_,
        $sel:currentPricingPlan:UpdatePricingPlanResponse' :: PricingPlan
currentPricingPlan = PricingPlan
pCurrentPricingPlan_
      }

-- | Update the pending pricing plan.
updatePricingPlanResponse_pendingPricingPlan :: Lens.Lens' UpdatePricingPlanResponse (Prelude.Maybe PricingPlan)
updatePricingPlanResponse_pendingPricingPlan :: Lens' UpdatePricingPlanResponse (Maybe PricingPlan)
updatePricingPlanResponse_pendingPricingPlan = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdatePricingPlanResponse' {Maybe PricingPlan
pendingPricingPlan :: Maybe PricingPlan
$sel:pendingPricingPlan:UpdatePricingPlanResponse' :: UpdatePricingPlanResponse -> Maybe PricingPlan
pendingPricingPlan} -> Maybe PricingPlan
pendingPricingPlan) (\s :: UpdatePricingPlanResponse
s@UpdatePricingPlanResponse' {} Maybe PricingPlan
a -> UpdatePricingPlanResponse
s {$sel:pendingPricingPlan:UpdatePricingPlanResponse' :: Maybe PricingPlan
pendingPricingPlan = Maybe PricingPlan
a} :: UpdatePricingPlanResponse)

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

-- | Update the current pricing plan.
updatePricingPlanResponse_currentPricingPlan :: Lens.Lens' UpdatePricingPlanResponse PricingPlan
updatePricingPlanResponse_currentPricingPlan :: Lens' UpdatePricingPlanResponse PricingPlan
updatePricingPlanResponse_currentPricingPlan = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdatePricingPlanResponse' {PricingPlan
currentPricingPlan :: PricingPlan
$sel:currentPricingPlan:UpdatePricingPlanResponse' :: UpdatePricingPlanResponse -> PricingPlan
currentPricingPlan} -> PricingPlan
currentPricingPlan) (\s :: UpdatePricingPlanResponse
s@UpdatePricingPlanResponse' {} PricingPlan
a -> UpdatePricingPlanResponse
s {$sel:currentPricingPlan:UpdatePricingPlanResponse' :: PricingPlan
currentPricingPlan = PricingPlan
a} :: UpdatePricingPlanResponse)

instance Prelude.NFData UpdatePricingPlanResponse where
  rnf :: UpdatePricingPlanResponse -> ()
rnf UpdatePricingPlanResponse' {Int
Maybe PricingPlan
PricingPlan
currentPricingPlan :: PricingPlan
httpStatus :: Int
pendingPricingPlan :: Maybe PricingPlan
$sel:currentPricingPlan:UpdatePricingPlanResponse' :: UpdatePricingPlanResponse -> PricingPlan
$sel:httpStatus:UpdatePricingPlanResponse' :: UpdatePricingPlanResponse -> Int
$sel:pendingPricingPlan:UpdatePricingPlanResponse' :: UpdatePricingPlanResponse -> Maybe PricingPlan
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe PricingPlan
pendingPricingPlan
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf PricingPlan
currentPricingPlan