{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.LicenseManager.Types.LicenseConversionContext
-- 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)
module Amazonka.LicenseManager.Types.LicenseConversionContext where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Information about a license type conversion task.
--
-- /See:/ 'newLicenseConversionContext' smart constructor.
data LicenseConversionContext = LicenseConversionContext'
  { -- | The Usage operation value that corresponds to the license type you are
    -- converting your resource from. For more information about which
    -- platforms correspond to which usage operation values see
    -- <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/billing-info-fields.html#billing-info Sample data: usage operation by platform>
    LicenseConversionContext -> Maybe Text
usageOperation :: Prelude.Maybe Prelude.Text
  }
  deriving (LicenseConversionContext -> LicenseConversionContext -> Bool
(LicenseConversionContext -> LicenseConversionContext -> Bool)
-> (LicenseConversionContext -> LicenseConversionContext -> Bool)
-> Eq LicenseConversionContext
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LicenseConversionContext -> LicenseConversionContext -> Bool
$c/= :: LicenseConversionContext -> LicenseConversionContext -> Bool
== :: LicenseConversionContext -> LicenseConversionContext -> Bool
$c== :: LicenseConversionContext -> LicenseConversionContext -> Bool
Prelude.Eq, ReadPrec [LicenseConversionContext]
ReadPrec LicenseConversionContext
Int -> ReadS LicenseConversionContext
ReadS [LicenseConversionContext]
(Int -> ReadS LicenseConversionContext)
-> ReadS [LicenseConversionContext]
-> ReadPrec LicenseConversionContext
-> ReadPrec [LicenseConversionContext]
-> Read LicenseConversionContext
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LicenseConversionContext]
$creadListPrec :: ReadPrec [LicenseConversionContext]
readPrec :: ReadPrec LicenseConversionContext
$creadPrec :: ReadPrec LicenseConversionContext
readList :: ReadS [LicenseConversionContext]
$creadList :: ReadS [LicenseConversionContext]
readsPrec :: Int -> ReadS LicenseConversionContext
$creadsPrec :: Int -> ReadS LicenseConversionContext
Prelude.Read, Int -> LicenseConversionContext -> ShowS
[LicenseConversionContext] -> ShowS
LicenseConversionContext -> String
(Int -> LicenseConversionContext -> ShowS)
-> (LicenseConversionContext -> String)
-> ([LicenseConversionContext] -> ShowS)
-> Show LicenseConversionContext
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LicenseConversionContext] -> ShowS
$cshowList :: [LicenseConversionContext] -> ShowS
show :: LicenseConversionContext -> String
$cshow :: LicenseConversionContext -> String
showsPrec :: Int -> LicenseConversionContext -> ShowS
$cshowsPrec :: Int -> LicenseConversionContext -> ShowS
Prelude.Show, (forall x.
 LicenseConversionContext -> Rep LicenseConversionContext x)
-> (forall x.
    Rep LicenseConversionContext x -> LicenseConversionContext)
-> Generic LicenseConversionContext
forall x.
Rep LicenseConversionContext x -> LicenseConversionContext
forall x.
LicenseConversionContext -> Rep LicenseConversionContext x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep LicenseConversionContext x -> LicenseConversionContext
$cfrom :: forall x.
LicenseConversionContext -> Rep LicenseConversionContext x
Prelude.Generic)

-- |
-- Create a value of 'LicenseConversionContext' 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:
--
-- 'usageOperation', 'licenseConversionContext_usageOperation' - The Usage operation value that corresponds to the license type you are
-- converting your resource from. For more information about which
-- platforms correspond to which usage operation values see
-- <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/billing-info-fields.html#billing-info Sample data: usage operation by platform>
newLicenseConversionContext ::
  LicenseConversionContext
newLicenseConversionContext :: LicenseConversionContext
newLicenseConversionContext =
  LicenseConversionContext' :: Maybe Text -> LicenseConversionContext
LicenseConversionContext'
    { $sel:usageOperation:LicenseConversionContext' :: Maybe Text
usageOperation =
        Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The Usage operation value that corresponds to the license type you are
-- converting your resource from. For more information about which
-- platforms correspond to which usage operation values see
-- <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/billing-info-fields.html#billing-info Sample data: usage operation by platform>
licenseConversionContext_usageOperation :: Lens.Lens' LicenseConversionContext (Prelude.Maybe Prelude.Text)
licenseConversionContext_usageOperation :: (Maybe Text -> f (Maybe Text))
-> LicenseConversionContext -> f LicenseConversionContext
licenseConversionContext_usageOperation = (LicenseConversionContext -> Maybe Text)
-> (LicenseConversionContext
    -> Maybe Text -> LicenseConversionContext)
-> Lens
     LicenseConversionContext
     LicenseConversionContext
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LicenseConversionContext' {Maybe Text
usageOperation :: Maybe Text
$sel:usageOperation:LicenseConversionContext' :: LicenseConversionContext -> Maybe Text
usageOperation} -> Maybe Text
usageOperation) (\s :: LicenseConversionContext
s@LicenseConversionContext' {} Maybe Text
a -> LicenseConversionContext
s {$sel:usageOperation:LicenseConversionContext' :: Maybe Text
usageOperation = Maybe Text
a} :: LicenseConversionContext)

instance Core.FromJSON LicenseConversionContext where
  parseJSON :: Value -> Parser LicenseConversionContext
parseJSON =
    String
-> (Object -> Parser LicenseConversionContext)
-> Value
-> Parser LicenseConversionContext
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"LicenseConversionContext"
      ( \Object
x ->
          Maybe Text -> LicenseConversionContext
LicenseConversionContext'
            (Maybe Text -> LicenseConversionContext)
-> Parser (Maybe Text) -> Parser LicenseConversionContext
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"UsageOperation")
      )

instance Prelude.Hashable LicenseConversionContext

instance Prelude.NFData LicenseConversionContext

instance Core.ToJSON LicenseConversionContext where
  toJSON :: LicenseConversionContext -> Value
toJSON LicenseConversionContext' {Maybe Text
usageOperation :: Maybe Text
$sel:usageOperation:LicenseConversionContext' :: LicenseConversionContext -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"UsageOperation" 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
usageOperation
          ]
      )