{-# 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.Signer.Types.Source
-- 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.Signer.Types.Source where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Signer.Types.S3Source

-- | An @S3Source@ object that contains information about the S3 bucket where
-- you saved your unsigned code.
--
-- /See:/ 'newSource' smart constructor.
data Source = Source'
  { -- | The @S3Source@ object.
    Source -> Maybe S3Source
s3 :: Prelude.Maybe S3Source
  }
  deriving (Source -> Source -> Bool
(Source -> Source -> Bool)
-> (Source -> Source -> Bool) -> Eq Source
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Source -> Source -> Bool
$c/= :: Source -> Source -> Bool
== :: Source -> Source -> Bool
$c== :: Source -> Source -> Bool
Prelude.Eq, ReadPrec [Source]
ReadPrec Source
Int -> ReadS Source
ReadS [Source]
(Int -> ReadS Source)
-> ReadS [Source]
-> ReadPrec Source
-> ReadPrec [Source]
-> Read Source
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Source]
$creadListPrec :: ReadPrec [Source]
readPrec :: ReadPrec Source
$creadPrec :: ReadPrec Source
readList :: ReadS [Source]
$creadList :: ReadS [Source]
readsPrec :: Int -> ReadS Source
$creadsPrec :: Int -> ReadS Source
Prelude.Read, Int -> Source -> ShowS
[Source] -> ShowS
Source -> String
(Int -> Source -> ShowS)
-> (Source -> String) -> ([Source] -> ShowS) -> Show Source
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Source] -> ShowS
$cshowList :: [Source] -> ShowS
show :: Source -> String
$cshow :: Source -> String
showsPrec :: Int -> Source -> ShowS
$cshowsPrec :: Int -> Source -> ShowS
Prelude.Show, (forall x. Source -> Rep Source x)
-> (forall x. Rep Source x -> Source) -> Generic Source
forall x. Rep Source x -> Source
forall x. Source -> Rep Source x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Source x -> Source
$cfrom :: forall x. Source -> Rep Source x
Prelude.Generic)

-- |
-- Create a value of 'Source' 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:
--
-- 's3', 'source_s3' - The @S3Source@ object.
newSource ::
  Source
newSource :: Source
newSource = Source' :: Maybe S3Source -> Source
Source' {$sel:s3:Source' :: Maybe S3Source
s3 = Maybe S3Source
forall a. Maybe a
Prelude.Nothing}

-- | The @S3Source@ object.
source_s3 :: Lens.Lens' Source (Prelude.Maybe S3Source)
source_s3 :: (Maybe S3Source -> f (Maybe S3Source)) -> Source -> f Source
source_s3 = (Source -> Maybe S3Source)
-> (Source -> Maybe S3Source -> Source)
-> Lens Source Source (Maybe S3Source) (Maybe S3Source)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Source' {Maybe S3Source
s3 :: Maybe S3Source
$sel:s3:Source' :: Source -> Maybe S3Source
s3} -> Maybe S3Source
s3) (\s :: Source
s@Source' {} Maybe S3Source
a -> Source
s {$sel:s3:Source' :: Maybe S3Source
s3 = Maybe S3Source
a} :: Source)

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

instance Prelude.Hashable Source

instance Prelude.NFData Source

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