{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.GuardDuty.Types.ProductCode 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

-- | Contains information about the product code for the EC2 instance.
--
-- /See:/ 'newProductCode' smart constructor.
data ProductCode = ProductCode'
  { -- | The product code information.
    ProductCode -> Maybe Text
code :: Prelude.Maybe Prelude.Text,
    -- | The product code type.
    ProductCode -> Maybe Text
productType :: Prelude.Maybe Prelude.Text
  }
  deriving (ProductCode -> ProductCode -> Bool
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]
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
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. 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:
--
-- 'code', 'productCode_code' - The product code information.
--
-- 'productType', 'productCode_productType' - The product code type.
newProductCode ::
  ProductCode
newProductCode :: ProductCode
newProductCode =
  ProductCode'
    { $sel:code:ProductCode' :: Maybe Text
code = forall a. Maybe a
Prelude.Nothing,
      $sel:productType:ProductCode' :: Maybe Text
productType = forall a. Maybe a
Prelude.Nothing
    }

-- | The product code information.
productCode_code :: Lens.Lens' ProductCode (Prelude.Maybe Prelude.Text)
productCode_code :: Lens' ProductCode (Maybe Text)
productCode_code = 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)

-- | The product code type.
productCode_productType :: Lens.Lens' ProductCode (Prelude.Maybe Prelude.Text)
productCode_productType :: Lens' ProductCode (Maybe Text)
productCode_productType = 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)

instance Data.FromJSON ProductCode where
  parseJSON :: Value -> Parser ProductCode
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ProductCode"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> ProductCode
ProductCode'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"productCodeId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"productCodeType")
      )

instance Prelude.Hashable ProductCode where
  hashWithSalt :: Int -> ProductCode -> Int
hashWithSalt Int
_salt ProductCode' {Maybe Text
productType :: Maybe Text
code :: Maybe Text
$sel:productType:ProductCode' :: ProductCode -> Maybe Text
$sel:code:ProductCode' :: ProductCode -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
code
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
productType

instance Prelude.NFData ProductCode where
  rnf :: ProductCode -> ()
rnf ProductCode' {Maybe Text
productType :: Maybe Text
code :: Maybe Text
$sel:productType:ProductCode' :: ProductCode -> Maybe Text
$sel:code:ProductCode' :: ProductCode -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
code
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
productType