{-# 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.Shield.Types.Contributor
-- 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.Shield.Types.Contributor 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

-- | A contributor to the attack and their contribution.
--
-- /See:/ 'newContributor' smart constructor.
data Contributor = Contributor'
  { -- | The name of the contributor. The type of name that you\'ll find here
    -- depends on the @AttackPropertyIdentifier@ setting in the
    -- @AttackProperty@ where this contributor is defined. For example, if the
    -- @AttackPropertyIdentifier@ is @SOURCE_COUNTRY@, the @Name@ could be
    -- @United States@.
    Contributor -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The contribution of this contributor expressed in Protection units. For
    -- example @10,000@.
    Contributor -> Maybe Integer
value :: Prelude.Maybe Prelude.Integer
  }
  deriving (Contributor -> Contributor -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Contributor -> Contributor -> Bool
$c/= :: Contributor -> Contributor -> Bool
== :: Contributor -> Contributor -> Bool
$c== :: Contributor -> Contributor -> Bool
Prelude.Eq, ReadPrec [Contributor]
ReadPrec Contributor
Int -> ReadS Contributor
ReadS [Contributor]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Contributor]
$creadListPrec :: ReadPrec [Contributor]
readPrec :: ReadPrec Contributor
$creadPrec :: ReadPrec Contributor
readList :: ReadS [Contributor]
$creadList :: ReadS [Contributor]
readsPrec :: Int -> ReadS Contributor
$creadsPrec :: Int -> ReadS Contributor
Prelude.Read, Int -> Contributor -> ShowS
[Contributor] -> ShowS
Contributor -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Contributor] -> ShowS
$cshowList :: [Contributor] -> ShowS
show :: Contributor -> String
$cshow :: Contributor -> String
showsPrec :: Int -> Contributor -> ShowS
$cshowsPrec :: Int -> Contributor -> ShowS
Prelude.Show, forall x. Rep Contributor x -> Contributor
forall x. Contributor -> Rep Contributor x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Contributor x -> Contributor
$cfrom :: forall x. Contributor -> Rep Contributor x
Prelude.Generic)

-- |
-- Create a value of 'Contributor' 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:
--
-- 'name', 'contributor_name' - The name of the contributor. The type of name that you\'ll find here
-- depends on the @AttackPropertyIdentifier@ setting in the
-- @AttackProperty@ where this contributor is defined. For example, if the
-- @AttackPropertyIdentifier@ is @SOURCE_COUNTRY@, the @Name@ could be
-- @United States@.
--
-- 'value', 'contributor_value' - The contribution of this contributor expressed in Protection units. For
-- example @10,000@.
newContributor ::
  Contributor
newContributor :: Contributor
newContributor =
  Contributor'
    { $sel:name:Contributor' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:value:Contributor' :: Maybe Integer
value = forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the contributor. The type of name that you\'ll find here
-- depends on the @AttackPropertyIdentifier@ setting in the
-- @AttackProperty@ where this contributor is defined. For example, if the
-- @AttackPropertyIdentifier@ is @SOURCE_COUNTRY@, the @Name@ could be
-- @United States@.
contributor_name :: Lens.Lens' Contributor (Prelude.Maybe Prelude.Text)
contributor_name :: Lens' Contributor (Maybe Text)
contributor_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Contributor' {Maybe Text
name :: Maybe Text
$sel:name:Contributor' :: Contributor -> Maybe Text
name} -> Maybe Text
name) (\s :: Contributor
s@Contributor' {} Maybe Text
a -> Contributor
s {$sel:name:Contributor' :: Maybe Text
name = Maybe Text
a} :: Contributor)

-- | The contribution of this contributor expressed in Protection units. For
-- example @10,000@.
contributor_value :: Lens.Lens' Contributor (Prelude.Maybe Prelude.Integer)
contributor_value :: Lens' Contributor (Maybe Integer)
contributor_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Contributor' {Maybe Integer
value :: Maybe Integer
$sel:value:Contributor' :: Contributor -> Maybe Integer
value} -> Maybe Integer
value) (\s :: Contributor
s@Contributor' {} Maybe Integer
a -> Contributor
s {$sel:value:Contributor' :: Maybe Integer
value = Maybe Integer
a} :: Contributor)

instance Data.FromJSON Contributor where
  parseJSON :: Value -> Parser Contributor
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Contributor"
      ( \Object
x ->
          Maybe Text -> Maybe Integer -> Contributor
Contributor'
            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
"Name")
            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
"Value")
      )

instance Prelude.Hashable Contributor where
  hashWithSalt :: Int -> Contributor -> Int
hashWithSalt Int
_salt Contributor' {Maybe Integer
Maybe Text
value :: Maybe Integer
name :: Maybe Text
$sel:value:Contributor' :: Contributor -> Maybe Integer
$sel:name:Contributor' :: Contributor -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Integer
value

instance Prelude.NFData Contributor where
  rnf :: Contributor -> ()
rnf Contributor' {Maybe Integer
Maybe Text
value :: Maybe Integer
name :: Maybe Text
$sel:value:Contributor' :: Contributor -> Maybe Integer
$sel:name:Contributor' :: Contributor -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Integer
value