{-# 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.Lambda.Types.AllowedPublishers
-- 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.Lambda.Types.AllowedPublishers where

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

-- | List of signing profiles that can sign a code package.
--
-- /See:/ 'newAllowedPublishers' smart constructor.
data AllowedPublishers = AllowedPublishers'
  { -- | The Amazon Resource Name (ARN) for each of the signing profiles. A
    -- signing profile defines a trusted user who can sign a code package.
    AllowedPublishers -> NonEmpty Text
signingProfileVersionArns :: Prelude.NonEmpty Prelude.Text
  }
  deriving (AllowedPublishers -> AllowedPublishers -> Bool
(AllowedPublishers -> AllowedPublishers -> Bool)
-> (AllowedPublishers -> AllowedPublishers -> Bool)
-> Eq AllowedPublishers
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AllowedPublishers -> AllowedPublishers -> Bool
$c/= :: AllowedPublishers -> AllowedPublishers -> Bool
== :: AllowedPublishers -> AllowedPublishers -> Bool
$c== :: AllowedPublishers -> AllowedPublishers -> Bool
Prelude.Eq, ReadPrec [AllowedPublishers]
ReadPrec AllowedPublishers
Int -> ReadS AllowedPublishers
ReadS [AllowedPublishers]
(Int -> ReadS AllowedPublishers)
-> ReadS [AllowedPublishers]
-> ReadPrec AllowedPublishers
-> ReadPrec [AllowedPublishers]
-> Read AllowedPublishers
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AllowedPublishers]
$creadListPrec :: ReadPrec [AllowedPublishers]
readPrec :: ReadPrec AllowedPublishers
$creadPrec :: ReadPrec AllowedPublishers
readList :: ReadS [AllowedPublishers]
$creadList :: ReadS [AllowedPublishers]
readsPrec :: Int -> ReadS AllowedPublishers
$creadsPrec :: Int -> ReadS AllowedPublishers
Prelude.Read, Int -> AllowedPublishers -> ShowS
[AllowedPublishers] -> ShowS
AllowedPublishers -> String
(Int -> AllowedPublishers -> ShowS)
-> (AllowedPublishers -> String)
-> ([AllowedPublishers] -> ShowS)
-> Show AllowedPublishers
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AllowedPublishers] -> ShowS
$cshowList :: [AllowedPublishers] -> ShowS
show :: AllowedPublishers -> String
$cshow :: AllowedPublishers -> String
showsPrec :: Int -> AllowedPublishers -> ShowS
$cshowsPrec :: Int -> AllowedPublishers -> ShowS
Prelude.Show, (forall x. AllowedPublishers -> Rep AllowedPublishers x)
-> (forall x. Rep AllowedPublishers x -> AllowedPublishers)
-> Generic AllowedPublishers
forall x. Rep AllowedPublishers x -> AllowedPublishers
forall x. AllowedPublishers -> Rep AllowedPublishers x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AllowedPublishers x -> AllowedPublishers
$cfrom :: forall x. AllowedPublishers -> Rep AllowedPublishers x
Prelude.Generic)

-- |
-- Create a value of 'AllowedPublishers' 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:
--
-- 'signingProfileVersionArns', 'allowedPublishers_signingProfileVersionArns' - The Amazon Resource Name (ARN) for each of the signing profiles. A
-- signing profile defines a trusted user who can sign a code package.
newAllowedPublishers ::
  -- | 'signingProfileVersionArns'
  Prelude.NonEmpty Prelude.Text ->
  AllowedPublishers
newAllowedPublishers :: NonEmpty Text -> AllowedPublishers
newAllowedPublishers NonEmpty Text
pSigningProfileVersionArns_ =
  AllowedPublishers' :: NonEmpty Text -> AllowedPublishers
AllowedPublishers'
    { $sel:signingProfileVersionArns:AllowedPublishers' :: NonEmpty Text
signingProfileVersionArns =
        Tagged (NonEmpty Text) (Identity (NonEmpty Text))
-> Tagged (NonEmpty Text) (Identity (NonEmpty Text))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged (NonEmpty Text) (Identity (NonEmpty Text))
 -> Tagged (NonEmpty Text) (Identity (NonEmpty Text)))
-> NonEmpty Text -> NonEmpty Text
forall t b. AReview t b -> b -> t
Lens.# NonEmpty Text
pSigningProfileVersionArns_
    }

-- | The Amazon Resource Name (ARN) for each of the signing profiles. A
-- signing profile defines a trusted user who can sign a code package.
allowedPublishers_signingProfileVersionArns :: Lens.Lens' AllowedPublishers (Prelude.NonEmpty Prelude.Text)
allowedPublishers_signingProfileVersionArns :: (NonEmpty Text -> f (NonEmpty Text))
-> AllowedPublishers -> f AllowedPublishers
allowedPublishers_signingProfileVersionArns = (AllowedPublishers -> NonEmpty Text)
-> (AllowedPublishers -> NonEmpty Text -> AllowedPublishers)
-> Lens
     AllowedPublishers AllowedPublishers (NonEmpty Text) (NonEmpty Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AllowedPublishers' {NonEmpty Text
signingProfileVersionArns :: NonEmpty Text
$sel:signingProfileVersionArns:AllowedPublishers' :: AllowedPublishers -> NonEmpty Text
signingProfileVersionArns} -> NonEmpty Text
signingProfileVersionArns) (\s :: AllowedPublishers
s@AllowedPublishers' {} NonEmpty Text
a -> AllowedPublishers
s {$sel:signingProfileVersionArns:AllowedPublishers' :: NonEmpty Text
signingProfileVersionArns = NonEmpty Text
a} :: AllowedPublishers) ((NonEmpty Text -> f (NonEmpty Text))
 -> AllowedPublishers -> f AllowedPublishers)
-> ((NonEmpty Text -> f (NonEmpty Text))
    -> NonEmpty Text -> f (NonEmpty Text))
-> (NonEmpty Text -> f (NonEmpty Text))
-> AllowedPublishers
-> f AllowedPublishers
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty Text -> f (NonEmpty Text))
-> NonEmpty Text -> f (NonEmpty Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.Hashable AllowedPublishers

instance Prelude.NFData AllowedPublishers

instance Core.ToJSON AllowedPublishers where
  toJSON :: AllowedPublishers -> Value
toJSON AllowedPublishers' {NonEmpty Text
signingProfileVersionArns :: NonEmpty Text
$sel:signingProfileVersionArns:AllowedPublishers' :: AllowedPublishers -> NonEmpty Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"SigningProfileVersionArns"
                  Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty Text
signingProfileVersionArns
              )
          ]
      )