{-# 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.AppMesh.Types.SubjectAlternativeNames
-- 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.AppMesh.Types.SubjectAlternativeNames where

import Amazonka.AppMesh.Types.SubjectAlternativeNameMatchers
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | An object that represents the subject alternative names secured by the
-- certificate.
--
-- /See:/ 'newSubjectAlternativeNames' smart constructor.
data SubjectAlternativeNames = SubjectAlternativeNames'
  { -- | An object that represents the criteria for determining a SANs match.
    SubjectAlternativeNames -> SubjectAlternativeNameMatchers
match :: SubjectAlternativeNameMatchers
  }
  deriving (SubjectAlternativeNames -> SubjectAlternativeNames -> Bool
(SubjectAlternativeNames -> SubjectAlternativeNames -> Bool)
-> (SubjectAlternativeNames -> SubjectAlternativeNames -> Bool)
-> Eq SubjectAlternativeNames
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SubjectAlternativeNames -> SubjectAlternativeNames -> Bool
$c/= :: SubjectAlternativeNames -> SubjectAlternativeNames -> Bool
== :: SubjectAlternativeNames -> SubjectAlternativeNames -> Bool
$c== :: SubjectAlternativeNames -> SubjectAlternativeNames -> Bool
Prelude.Eq, ReadPrec [SubjectAlternativeNames]
ReadPrec SubjectAlternativeNames
Int -> ReadS SubjectAlternativeNames
ReadS [SubjectAlternativeNames]
(Int -> ReadS SubjectAlternativeNames)
-> ReadS [SubjectAlternativeNames]
-> ReadPrec SubjectAlternativeNames
-> ReadPrec [SubjectAlternativeNames]
-> Read SubjectAlternativeNames
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SubjectAlternativeNames]
$creadListPrec :: ReadPrec [SubjectAlternativeNames]
readPrec :: ReadPrec SubjectAlternativeNames
$creadPrec :: ReadPrec SubjectAlternativeNames
readList :: ReadS [SubjectAlternativeNames]
$creadList :: ReadS [SubjectAlternativeNames]
readsPrec :: Int -> ReadS SubjectAlternativeNames
$creadsPrec :: Int -> ReadS SubjectAlternativeNames
Prelude.Read, Int -> SubjectAlternativeNames -> ShowS
[SubjectAlternativeNames] -> ShowS
SubjectAlternativeNames -> String
(Int -> SubjectAlternativeNames -> ShowS)
-> (SubjectAlternativeNames -> String)
-> ([SubjectAlternativeNames] -> ShowS)
-> Show SubjectAlternativeNames
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SubjectAlternativeNames] -> ShowS
$cshowList :: [SubjectAlternativeNames] -> ShowS
show :: SubjectAlternativeNames -> String
$cshow :: SubjectAlternativeNames -> String
showsPrec :: Int -> SubjectAlternativeNames -> ShowS
$cshowsPrec :: Int -> SubjectAlternativeNames -> ShowS
Prelude.Show, (forall x.
 SubjectAlternativeNames -> Rep SubjectAlternativeNames x)
-> (forall x.
    Rep SubjectAlternativeNames x -> SubjectAlternativeNames)
-> Generic SubjectAlternativeNames
forall x. Rep SubjectAlternativeNames x -> SubjectAlternativeNames
forall x. SubjectAlternativeNames -> Rep SubjectAlternativeNames x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SubjectAlternativeNames x -> SubjectAlternativeNames
$cfrom :: forall x. SubjectAlternativeNames -> Rep SubjectAlternativeNames x
Prelude.Generic)

-- |
-- Create a value of 'SubjectAlternativeNames' 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:
--
-- 'match', 'subjectAlternativeNames_match' - An object that represents the criteria for determining a SANs match.
newSubjectAlternativeNames ::
  -- | 'match'
  SubjectAlternativeNameMatchers ->
  SubjectAlternativeNames
newSubjectAlternativeNames :: SubjectAlternativeNameMatchers -> SubjectAlternativeNames
newSubjectAlternativeNames SubjectAlternativeNameMatchers
pMatch_ =
  SubjectAlternativeNames' :: SubjectAlternativeNameMatchers -> SubjectAlternativeNames
SubjectAlternativeNames' {$sel:match:SubjectAlternativeNames' :: SubjectAlternativeNameMatchers
match = SubjectAlternativeNameMatchers
pMatch_}

-- | An object that represents the criteria for determining a SANs match.
subjectAlternativeNames_match :: Lens.Lens' SubjectAlternativeNames SubjectAlternativeNameMatchers
subjectAlternativeNames_match :: (SubjectAlternativeNameMatchers
 -> f SubjectAlternativeNameMatchers)
-> SubjectAlternativeNames -> f SubjectAlternativeNames
subjectAlternativeNames_match = (SubjectAlternativeNames -> SubjectAlternativeNameMatchers)
-> (SubjectAlternativeNames
    -> SubjectAlternativeNameMatchers -> SubjectAlternativeNames)
-> Lens
     SubjectAlternativeNames
     SubjectAlternativeNames
     SubjectAlternativeNameMatchers
     SubjectAlternativeNameMatchers
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SubjectAlternativeNames' {SubjectAlternativeNameMatchers
match :: SubjectAlternativeNameMatchers
$sel:match:SubjectAlternativeNames' :: SubjectAlternativeNames -> SubjectAlternativeNameMatchers
match} -> SubjectAlternativeNameMatchers
match) (\s :: SubjectAlternativeNames
s@SubjectAlternativeNames' {} SubjectAlternativeNameMatchers
a -> SubjectAlternativeNames
s {$sel:match:SubjectAlternativeNames' :: SubjectAlternativeNameMatchers
match = SubjectAlternativeNameMatchers
a} :: SubjectAlternativeNames)

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

instance Prelude.Hashable SubjectAlternativeNames

instance Prelude.NFData SubjectAlternativeNames

instance Core.ToJSON SubjectAlternativeNames where
  toJSON :: SubjectAlternativeNames -> Value
toJSON SubjectAlternativeNames' {SubjectAlternativeNameMatchers
match :: SubjectAlternativeNameMatchers
$sel:match:SubjectAlternativeNames' :: SubjectAlternativeNames -> SubjectAlternativeNameMatchers
..} =
    [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
"match" Text -> SubjectAlternativeNameMatchers -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= SubjectAlternativeNameMatchers
match)]
      )