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

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

-- | A contributor to the attack and their contribution.
--
-- /See:/ 'newContributor' smart constructor.
data Contributor = Contributor'
  { -- | The contribution of this contributor expressed in Protection units. For
    -- example @10,000@.
    Contributor -> Maybe Integer
value :: Prelude.Maybe Prelude.Integer,
    -- | The name of the contributor. This is dependent on the
    -- @AttackPropertyIdentifier@. For example, if the
    -- @AttackPropertyIdentifier@ is @SOURCE_COUNTRY@, the @Name@ could be
    -- @United States@.
    Contributor -> Maybe Text
name :: Prelude.Maybe Prelude.Text
  }
  deriving (Contributor -> Contributor -> Bool
(Contributor -> Contributor -> Bool)
-> (Contributor -> Contributor -> Bool) -> Eq Contributor
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]
(Int -> ReadS Contributor)
-> ReadS [Contributor]
-> ReadPrec Contributor
-> ReadPrec [Contributor]
-> Read 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
(Int -> Contributor -> ShowS)
-> (Contributor -> String)
-> ([Contributor] -> ShowS)
-> Show Contributor
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. Contributor -> Rep Contributor x)
-> (forall x. Rep Contributor x -> Contributor)
-> Generic Contributor
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:
--
-- 'value', 'contributor_value' - The contribution of this contributor expressed in Protection units. For
-- example @10,000@.
--
-- 'name', 'contributor_name' - The name of the contributor. This is dependent on the
-- @AttackPropertyIdentifier@. For example, if the
-- @AttackPropertyIdentifier@ is @SOURCE_COUNTRY@, the @Name@ could be
-- @United States@.
newContributor ::
  Contributor
newContributor :: Contributor
newContributor =
  Contributor' :: Maybe Integer -> Maybe Text -> Contributor
Contributor'
    { $sel:value:Contributor' :: Maybe Integer
value = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:name:Contributor' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The contribution of this contributor expressed in Protection units. For
-- example @10,000@.
contributor_value :: Lens.Lens' Contributor (Prelude.Maybe Prelude.Integer)
contributor_value :: (Maybe Integer -> f (Maybe Integer))
-> Contributor -> f Contributor
contributor_value = (Contributor -> Maybe Integer)
-> (Contributor -> Maybe Integer -> Contributor)
-> Lens Contributor Contributor (Maybe Integer) (Maybe Integer)
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)

-- | The name of the contributor. This is dependent on the
-- @AttackPropertyIdentifier@. 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 :: (Maybe Text -> f (Maybe Text)) -> Contributor -> f Contributor
contributor_name = (Contributor -> Maybe Text)
-> (Contributor -> Maybe Text -> Contributor)
-> Lens Contributor Contributor (Maybe Text) (Maybe Text)
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)

instance Core.FromJSON Contributor where
  parseJSON :: Value -> Parser Contributor
parseJSON =
    String
-> (Object -> Parser Contributor) -> Value -> Parser Contributor
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Contributor"
      ( \Object
x ->
          Maybe Integer -> Maybe Text -> Contributor
Contributor'
            (Maybe Integer -> Maybe Text -> Contributor)
-> Parser (Maybe Integer) -> Parser (Maybe Text -> Contributor)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Integer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Value") Parser (Maybe Text -> Contributor)
-> Parser (Maybe Text) -> Parser Contributor
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
"Name")
      )

instance Prelude.Hashable Contributor

instance Prelude.NFData Contributor