{-# 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.IoT.Types.CodeSigningCertificateChain
-- 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.IoT.Types.CodeSigningCertificateChain where

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

-- | Describes the certificate chain being used when code signing a file.
--
-- /See:/ 'newCodeSigningCertificateChain' smart constructor.
data CodeSigningCertificateChain = CodeSigningCertificateChain'
  { -- | The name of the certificate.
    CodeSigningCertificateChain -> Maybe Text
certificateName :: Prelude.Maybe Prelude.Text,
    -- | A base64 encoded binary representation of the code signing certificate
    -- chain.
    CodeSigningCertificateChain -> Maybe Text
inlineDocument :: Prelude.Maybe Prelude.Text
  }
  deriving (CodeSigningCertificateChain -> CodeSigningCertificateChain -> Bool
(CodeSigningCertificateChain
 -> CodeSigningCertificateChain -> Bool)
-> (CodeSigningCertificateChain
    -> CodeSigningCertificateChain -> Bool)
-> Eq CodeSigningCertificateChain
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CodeSigningCertificateChain -> CodeSigningCertificateChain -> Bool
$c/= :: CodeSigningCertificateChain -> CodeSigningCertificateChain -> Bool
== :: CodeSigningCertificateChain -> CodeSigningCertificateChain -> Bool
$c== :: CodeSigningCertificateChain -> CodeSigningCertificateChain -> Bool
Prelude.Eq, ReadPrec [CodeSigningCertificateChain]
ReadPrec CodeSigningCertificateChain
Int -> ReadS CodeSigningCertificateChain
ReadS [CodeSigningCertificateChain]
(Int -> ReadS CodeSigningCertificateChain)
-> ReadS [CodeSigningCertificateChain]
-> ReadPrec CodeSigningCertificateChain
-> ReadPrec [CodeSigningCertificateChain]
-> Read CodeSigningCertificateChain
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CodeSigningCertificateChain]
$creadListPrec :: ReadPrec [CodeSigningCertificateChain]
readPrec :: ReadPrec CodeSigningCertificateChain
$creadPrec :: ReadPrec CodeSigningCertificateChain
readList :: ReadS [CodeSigningCertificateChain]
$creadList :: ReadS [CodeSigningCertificateChain]
readsPrec :: Int -> ReadS CodeSigningCertificateChain
$creadsPrec :: Int -> ReadS CodeSigningCertificateChain
Prelude.Read, Int -> CodeSigningCertificateChain -> ShowS
[CodeSigningCertificateChain] -> ShowS
CodeSigningCertificateChain -> String
(Int -> CodeSigningCertificateChain -> ShowS)
-> (CodeSigningCertificateChain -> String)
-> ([CodeSigningCertificateChain] -> ShowS)
-> Show CodeSigningCertificateChain
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CodeSigningCertificateChain] -> ShowS
$cshowList :: [CodeSigningCertificateChain] -> ShowS
show :: CodeSigningCertificateChain -> String
$cshow :: CodeSigningCertificateChain -> String
showsPrec :: Int -> CodeSigningCertificateChain -> ShowS
$cshowsPrec :: Int -> CodeSigningCertificateChain -> ShowS
Prelude.Show, (forall x.
 CodeSigningCertificateChain -> Rep CodeSigningCertificateChain x)
-> (forall x.
    Rep CodeSigningCertificateChain x -> CodeSigningCertificateChain)
-> Generic CodeSigningCertificateChain
forall x.
Rep CodeSigningCertificateChain x -> CodeSigningCertificateChain
forall x.
CodeSigningCertificateChain -> Rep CodeSigningCertificateChain x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CodeSigningCertificateChain x -> CodeSigningCertificateChain
$cfrom :: forall x.
CodeSigningCertificateChain -> Rep CodeSigningCertificateChain x
Prelude.Generic)

-- |
-- Create a value of 'CodeSigningCertificateChain' 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:
--
-- 'certificateName', 'codeSigningCertificateChain_certificateName' - The name of the certificate.
--
-- 'inlineDocument', 'codeSigningCertificateChain_inlineDocument' - A base64 encoded binary representation of the code signing certificate
-- chain.
newCodeSigningCertificateChain ::
  CodeSigningCertificateChain
newCodeSigningCertificateChain :: CodeSigningCertificateChain
newCodeSigningCertificateChain =
  CodeSigningCertificateChain' :: Maybe Text -> Maybe Text -> CodeSigningCertificateChain
CodeSigningCertificateChain'
    { $sel:certificateName:CodeSigningCertificateChain' :: Maybe Text
certificateName =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:inlineDocument:CodeSigningCertificateChain' :: Maybe Text
inlineDocument = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the certificate.
codeSigningCertificateChain_certificateName :: Lens.Lens' CodeSigningCertificateChain (Prelude.Maybe Prelude.Text)
codeSigningCertificateChain_certificateName :: (Maybe Text -> f (Maybe Text))
-> CodeSigningCertificateChain -> f CodeSigningCertificateChain
codeSigningCertificateChain_certificateName = (CodeSigningCertificateChain -> Maybe Text)
-> (CodeSigningCertificateChain
    -> Maybe Text -> CodeSigningCertificateChain)
-> Lens
     CodeSigningCertificateChain
     CodeSigningCertificateChain
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CodeSigningCertificateChain' {Maybe Text
certificateName :: Maybe Text
$sel:certificateName:CodeSigningCertificateChain' :: CodeSigningCertificateChain -> Maybe Text
certificateName} -> Maybe Text
certificateName) (\s :: CodeSigningCertificateChain
s@CodeSigningCertificateChain' {} Maybe Text
a -> CodeSigningCertificateChain
s {$sel:certificateName:CodeSigningCertificateChain' :: Maybe Text
certificateName = Maybe Text
a} :: CodeSigningCertificateChain)

-- | A base64 encoded binary representation of the code signing certificate
-- chain.
codeSigningCertificateChain_inlineDocument :: Lens.Lens' CodeSigningCertificateChain (Prelude.Maybe Prelude.Text)
codeSigningCertificateChain_inlineDocument :: (Maybe Text -> f (Maybe Text))
-> CodeSigningCertificateChain -> f CodeSigningCertificateChain
codeSigningCertificateChain_inlineDocument = (CodeSigningCertificateChain -> Maybe Text)
-> (CodeSigningCertificateChain
    -> Maybe Text -> CodeSigningCertificateChain)
-> Lens
     CodeSigningCertificateChain
     CodeSigningCertificateChain
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CodeSigningCertificateChain' {Maybe Text
inlineDocument :: Maybe Text
$sel:inlineDocument:CodeSigningCertificateChain' :: CodeSigningCertificateChain -> Maybe Text
inlineDocument} -> Maybe Text
inlineDocument) (\s :: CodeSigningCertificateChain
s@CodeSigningCertificateChain' {} Maybe Text
a -> CodeSigningCertificateChain
s {$sel:inlineDocument:CodeSigningCertificateChain' :: Maybe Text
inlineDocument = Maybe Text
a} :: CodeSigningCertificateChain)

instance Core.FromJSON CodeSigningCertificateChain where
  parseJSON :: Value -> Parser CodeSigningCertificateChain
parseJSON =
    String
-> (Object -> Parser CodeSigningCertificateChain)
-> Value
-> Parser CodeSigningCertificateChain
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CodeSigningCertificateChain"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> CodeSigningCertificateChain
CodeSigningCertificateChain'
            (Maybe Text -> Maybe Text -> CodeSigningCertificateChain)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> CodeSigningCertificateChain)
forall (f :: * -> *) a b. Functor 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
"certificateName")
            Parser (Maybe Text -> CodeSigningCertificateChain)
-> Parser (Maybe Text) -> Parser CodeSigningCertificateChain
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
"inlineDocument")
      )

instance Prelude.Hashable CodeSigningCertificateChain

instance Prelude.NFData CodeSigningCertificateChain

instance Core.ToJSON CodeSigningCertificateChain where
  toJSON :: CodeSigningCertificateChain -> Value
toJSON CodeSigningCertificateChain' {Maybe Text
inlineDocument :: Maybe Text
certificateName :: Maybe Text
$sel:inlineDocument:CodeSigningCertificateChain' :: CodeSigningCertificateChain -> Maybe Text
$sel:certificateName:CodeSigningCertificateChain' :: CodeSigningCertificateChain -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"certificateName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
certificateName,
            (Text
"inlineDocument" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
inlineDocument
          ]
      )