{-# 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.CodeSigningSignature
-- 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.CodeSigningSignature where

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

-- | Describes the signature for a file.
--
-- /See:/ 'newCodeSigningSignature' smart constructor.
data CodeSigningSignature = CodeSigningSignature'
  { -- | A base64 encoded binary representation of the code signing signature.
    CodeSigningSignature -> Maybe Base64
inlineDocument :: Prelude.Maybe Core.Base64
  }
  deriving (CodeSigningSignature -> CodeSigningSignature -> Bool
(CodeSigningSignature -> CodeSigningSignature -> Bool)
-> (CodeSigningSignature -> CodeSigningSignature -> Bool)
-> Eq CodeSigningSignature
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CodeSigningSignature -> CodeSigningSignature -> Bool
$c/= :: CodeSigningSignature -> CodeSigningSignature -> Bool
== :: CodeSigningSignature -> CodeSigningSignature -> Bool
$c== :: CodeSigningSignature -> CodeSigningSignature -> Bool
Prelude.Eq, ReadPrec [CodeSigningSignature]
ReadPrec CodeSigningSignature
Int -> ReadS CodeSigningSignature
ReadS [CodeSigningSignature]
(Int -> ReadS CodeSigningSignature)
-> ReadS [CodeSigningSignature]
-> ReadPrec CodeSigningSignature
-> ReadPrec [CodeSigningSignature]
-> Read CodeSigningSignature
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CodeSigningSignature]
$creadListPrec :: ReadPrec [CodeSigningSignature]
readPrec :: ReadPrec CodeSigningSignature
$creadPrec :: ReadPrec CodeSigningSignature
readList :: ReadS [CodeSigningSignature]
$creadList :: ReadS [CodeSigningSignature]
readsPrec :: Int -> ReadS CodeSigningSignature
$creadsPrec :: Int -> ReadS CodeSigningSignature
Prelude.Read, Int -> CodeSigningSignature -> ShowS
[CodeSigningSignature] -> ShowS
CodeSigningSignature -> String
(Int -> CodeSigningSignature -> ShowS)
-> (CodeSigningSignature -> String)
-> ([CodeSigningSignature] -> ShowS)
-> Show CodeSigningSignature
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CodeSigningSignature] -> ShowS
$cshowList :: [CodeSigningSignature] -> ShowS
show :: CodeSigningSignature -> String
$cshow :: CodeSigningSignature -> String
showsPrec :: Int -> CodeSigningSignature -> ShowS
$cshowsPrec :: Int -> CodeSigningSignature -> ShowS
Prelude.Show, (forall x. CodeSigningSignature -> Rep CodeSigningSignature x)
-> (forall x. Rep CodeSigningSignature x -> CodeSigningSignature)
-> Generic CodeSigningSignature
forall x. Rep CodeSigningSignature x -> CodeSigningSignature
forall x. CodeSigningSignature -> Rep CodeSigningSignature x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CodeSigningSignature x -> CodeSigningSignature
$cfrom :: forall x. CodeSigningSignature -> Rep CodeSigningSignature x
Prelude.Generic)

-- |
-- Create a value of 'CodeSigningSignature' 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:
--
-- 'inlineDocument', 'codeSigningSignature_inlineDocument' - A base64 encoded binary representation of the code signing signature.--
-- -- /Note:/ This 'Lens' automatically encodes and decodes Base64 data.
-- -- The underlying isomorphism will encode to Base64 representation during
-- -- serialisation, and decode from Base64 representation during deserialisation.
-- -- This 'Lens' accepts and returns only raw unencoded data.
newCodeSigningSignature ::
  CodeSigningSignature
newCodeSigningSignature :: CodeSigningSignature
newCodeSigningSignature =
  CodeSigningSignature' :: Maybe Base64 -> CodeSigningSignature
CodeSigningSignature'
    { $sel:inlineDocument:CodeSigningSignature' :: Maybe Base64
inlineDocument =
        Maybe Base64
forall a. Maybe a
Prelude.Nothing
    }

-- | A base64 encoded binary representation of the code signing signature.--
-- -- /Note:/ This 'Lens' automatically encodes and decodes Base64 data.
-- -- The underlying isomorphism will encode to Base64 representation during
-- -- serialisation, and decode from Base64 representation during deserialisation.
-- -- This 'Lens' accepts and returns only raw unencoded data.
codeSigningSignature_inlineDocument :: Lens.Lens' CodeSigningSignature (Prelude.Maybe Prelude.ByteString)
codeSigningSignature_inlineDocument :: (Maybe ByteString -> f (Maybe ByteString))
-> CodeSigningSignature -> f CodeSigningSignature
codeSigningSignature_inlineDocument = (CodeSigningSignature -> Maybe Base64)
-> (CodeSigningSignature -> Maybe Base64 -> CodeSigningSignature)
-> Lens
     CodeSigningSignature
     CodeSigningSignature
     (Maybe Base64)
     (Maybe Base64)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CodeSigningSignature' {Maybe Base64
inlineDocument :: Maybe Base64
$sel:inlineDocument:CodeSigningSignature' :: CodeSigningSignature -> Maybe Base64
inlineDocument} -> Maybe Base64
inlineDocument) (\s :: CodeSigningSignature
s@CodeSigningSignature' {} Maybe Base64
a -> CodeSigningSignature
s {$sel:inlineDocument:CodeSigningSignature' :: Maybe Base64
inlineDocument = Maybe Base64
a} :: CodeSigningSignature) ((Maybe Base64 -> f (Maybe Base64))
 -> CodeSigningSignature -> f CodeSigningSignature)
-> ((Maybe ByteString -> f (Maybe ByteString))
    -> Maybe Base64 -> f (Maybe Base64))
-> (Maybe ByteString -> f (Maybe ByteString))
-> CodeSigningSignature
-> f CodeSigningSignature
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso Base64 Base64 ByteString ByteString
-> Iso
     (Maybe Base64) (Maybe Base64) (Maybe ByteString) (Maybe ByteString)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso Base64 Base64 ByteString ByteString
Iso' Base64 ByteString
Core._Base64

instance Core.FromJSON CodeSigningSignature where
  parseJSON :: Value -> Parser CodeSigningSignature
parseJSON =
    String
-> (Object -> Parser CodeSigningSignature)
-> Value
-> Parser CodeSigningSignature
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CodeSigningSignature"
      ( \Object
x ->
          Maybe Base64 -> CodeSigningSignature
CodeSigningSignature'
            (Maybe Base64 -> CodeSigningSignature)
-> Parser (Maybe Base64) -> Parser CodeSigningSignature
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Base64)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"inlineDocument")
      )

instance Prelude.Hashable CodeSigningSignature

instance Prelude.NFData CodeSigningSignature

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