{-# 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.GuardDuty.Types.ProductCode
-- 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.GuardDuty.Types.ProductCode where

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

-- | Contains information about the product code for the EC2 instance.
--
-- /See:/ 'newProductCode' smart constructor.
data ProductCode = ProductCode'
  { -- | The product code type.
    ProductCode -> Maybe Text
productType :: Prelude.Maybe Prelude.Text,
    -- | The product code information.
    ProductCode -> Maybe Text
code :: Prelude.Maybe Prelude.Text
  }
  deriving (ProductCode -> ProductCode -> Bool
(ProductCode -> ProductCode -> Bool)
-> (ProductCode -> ProductCode -> Bool) -> Eq ProductCode
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ProductCode -> ProductCode -> Bool
$c/= :: ProductCode -> ProductCode -> Bool
== :: ProductCode -> ProductCode -> Bool
$c== :: ProductCode -> ProductCode -> Bool
Prelude.Eq, ReadPrec [ProductCode]
ReadPrec ProductCode
Int -> ReadS ProductCode
ReadS [ProductCode]
(Int -> ReadS ProductCode)
-> ReadS [ProductCode]
-> ReadPrec ProductCode
-> ReadPrec [ProductCode]
-> Read ProductCode
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ProductCode]
$creadListPrec :: ReadPrec [ProductCode]
readPrec :: ReadPrec ProductCode
$creadPrec :: ReadPrec ProductCode
readList :: ReadS [ProductCode]
$creadList :: ReadS [ProductCode]
readsPrec :: Int -> ReadS ProductCode
$creadsPrec :: Int -> ReadS ProductCode
Prelude.Read, Int -> ProductCode -> ShowS
[ProductCode] -> ShowS
ProductCode -> String
(Int -> ProductCode -> ShowS)
-> (ProductCode -> String)
-> ([ProductCode] -> ShowS)
-> Show ProductCode
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ProductCode] -> ShowS
$cshowList :: [ProductCode] -> ShowS
show :: ProductCode -> String
$cshow :: ProductCode -> String
showsPrec :: Int -> ProductCode -> ShowS
$cshowsPrec :: Int -> ProductCode -> ShowS
Prelude.Show, (forall x. ProductCode -> Rep ProductCode x)
-> (forall x. Rep ProductCode x -> ProductCode)
-> Generic ProductCode
forall x. Rep ProductCode x -> ProductCode
forall x. ProductCode -> Rep ProductCode x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ProductCode x -> ProductCode
$cfrom :: forall x. ProductCode -> Rep ProductCode x
Prelude.Generic)

-- |
-- Create a value of 'ProductCode' 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:
--
-- 'productType', 'productCode_productType' - The product code type.
--
-- 'code', 'productCode_code' - The product code information.
newProductCode ::
  ProductCode
newProductCode :: ProductCode
newProductCode =
  ProductCode' :: Maybe Text -> Maybe Text -> ProductCode
ProductCode'
    { $sel:productType:ProductCode' :: Maybe Text
productType = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:code:ProductCode' :: Maybe Text
code = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The product code type.
productCode_productType :: Lens.Lens' ProductCode (Prelude.Maybe Prelude.Text)
productCode_productType :: (Maybe Text -> f (Maybe Text)) -> ProductCode -> f ProductCode
productCode_productType = (ProductCode -> Maybe Text)
-> (ProductCode -> Maybe Text -> ProductCode)
-> Lens ProductCode ProductCode (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProductCode' {Maybe Text
productType :: Maybe Text
$sel:productType:ProductCode' :: ProductCode -> Maybe Text
productType} -> Maybe Text
productType) (\s :: ProductCode
s@ProductCode' {} Maybe Text
a -> ProductCode
s {$sel:productType:ProductCode' :: Maybe Text
productType = Maybe Text
a} :: ProductCode)

-- | The product code information.
productCode_code :: Lens.Lens' ProductCode (Prelude.Maybe Prelude.Text)
productCode_code :: (Maybe Text -> f (Maybe Text)) -> ProductCode -> f ProductCode
productCode_code = (ProductCode -> Maybe Text)
-> (ProductCode -> Maybe Text -> ProductCode)
-> Lens ProductCode ProductCode (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProductCode' {Maybe Text
code :: Maybe Text
$sel:code:ProductCode' :: ProductCode -> Maybe Text
code} -> Maybe Text
code) (\s :: ProductCode
s@ProductCode' {} Maybe Text
a -> ProductCode
s {$sel:code:ProductCode' :: Maybe Text
code = Maybe Text
a} :: ProductCode)

instance Core.FromJSON ProductCode where
  parseJSON :: Value -> Parser ProductCode
parseJSON =
    String
-> (Object -> Parser ProductCode) -> Value -> Parser ProductCode
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ProductCode"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> ProductCode
ProductCode'
            (Maybe Text -> Maybe Text -> ProductCode)
-> Parser (Maybe Text) -> Parser (Maybe Text -> ProductCode)
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
"productType")
            Parser (Maybe Text -> ProductCode)
-> Parser (Maybe Text) -> Parser ProductCode
forall (f :: * -> *) a b. Applicative f => 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
"code")
      )

instance Prelude.Hashable ProductCode

instance Prelude.NFData ProductCode