{-# 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 #-}
module Amazonka.CodeBuild.Types.SourceAuth where
import Amazonka.CodeBuild.Types.SourceAuthType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data SourceAuth = SourceAuth'
{
SourceAuth -> Maybe Text
resource :: Prelude.Maybe Prelude.Text,
SourceAuth -> SourceAuthType
type' :: SourceAuthType
}
deriving (SourceAuth -> SourceAuth -> Bool
(SourceAuth -> SourceAuth -> Bool)
-> (SourceAuth -> SourceAuth -> Bool) -> Eq SourceAuth
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SourceAuth -> SourceAuth -> Bool
$c/= :: SourceAuth -> SourceAuth -> Bool
== :: SourceAuth -> SourceAuth -> Bool
$c== :: SourceAuth -> SourceAuth -> Bool
Prelude.Eq, ReadPrec [SourceAuth]
ReadPrec SourceAuth
Int -> ReadS SourceAuth
ReadS [SourceAuth]
(Int -> ReadS SourceAuth)
-> ReadS [SourceAuth]
-> ReadPrec SourceAuth
-> ReadPrec [SourceAuth]
-> Read SourceAuth
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SourceAuth]
$creadListPrec :: ReadPrec [SourceAuth]
readPrec :: ReadPrec SourceAuth
$creadPrec :: ReadPrec SourceAuth
readList :: ReadS [SourceAuth]
$creadList :: ReadS [SourceAuth]
readsPrec :: Int -> ReadS SourceAuth
$creadsPrec :: Int -> ReadS SourceAuth
Prelude.Read, Int -> SourceAuth -> ShowS
[SourceAuth] -> ShowS
SourceAuth -> String
(Int -> SourceAuth -> ShowS)
-> (SourceAuth -> String)
-> ([SourceAuth] -> ShowS)
-> Show SourceAuth
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SourceAuth] -> ShowS
$cshowList :: [SourceAuth] -> ShowS
show :: SourceAuth -> String
$cshow :: SourceAuth -> String
showsPrec :: Int -> SourceAuth -> ShowS
$cshowsPrec :: Int -> SourceAuth -> ShowS
Prelude.Show, (forall x. SourceAuth -> Rep SourceAuth x)
-> (forall x. Rep SourceAuth x -> SourceAuth) -> Generic SourceAuth
forall x. Rep SourceAuth x -> SourceAuth
forall x. SourceAuth -> Rep SourceAuth x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SourceAuth x -> SourceAuth
$cfrom :: forall x. SourceAuth -> Rep SourceAuth x
Prelude.Generic)
newSourceAuth ::
SourceAuthType ->
SourceAuth
newSourceAuth :: SourceAuthType -> SourceAuth
newSourceAuth SourceAuthType
pType_ =
SourceAuth' :: Maybe Text -> SourceAuthType -> SourceAuth
SourceAuth'
{ $sel:resource:SourceAuth' :: Maybe Text
resource = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:type':SourceAuth' :: SourceAuthType
type' = SourceAuthType
pType_
}
sourceAuth_resource :: Lens.Lens' SourceAuth (Prelude.Maybe Prelude.Text)
sourceAuth_resource :: (Maybe Text -> f (Maybe Text)) -> SourceAuth -> f SourceAuth
sourceAuth_resource = (SourceAuth -> Maybe Text)
-> (SourceAuth -> Maybe Text -> SourceAuth)
-> Lens SourceAuth SourceAuth (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SourceAuth' {Maybe Text
resource :: Maybe Text
$sel:resource:SourceAuth' :: SourceAuth -> Maybe Text
resource} -> Maybe Text
resource) (\s :: SourceAuth
s@SourceAuth' {} Maybe Text
a -> SourceAuth
s {$sel:resource:SourceAuth' :: Maybe Text
resource = Maybe Text
a} :: SourceAuth)
sourceAuth_type :: Lens.Lens' SourceAuth SourceAuthType
sourceAuth_type :: (SourceAuthType -> f SourceAuthType) -> SourceAuth -> f SourceAuth
sourceAuth_type = (SourceAuth -> SourceAuthType)
-> (SourceAuth -> SourceAuthType -> SourceAuth)
-> Lens SourceAuth SourceAuth SourceAuthType SourceAuthType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SourceAuth' {SourceAuthType
type' :: SourceAuthType
$sel:type':SourceAuth' :: SourceAuth -> SourceAuthType
type'} -> SourceAuthType
type') (\s :: SourceAuth
s@SourceAuth' {} SourceAuthType
a -> SourceAuth
s {$sel:type':SourceAuth' :: SourceAuthType
type' = SourceAuthType
a} :: SourceAuth)
instance Core.FromJSON SourceAuth where
parseJSON :: Value -> Parser SourceAuth
parseJSON =
String
-> (Object -> Parser SourceAuth) -> Value -> Parser SourceAuth
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"SourceAuth"
( \Object
x ->
Maybe Text -> SourceAuthType -> SourceAuth
SourceAuth'
(Maybe Text -> SourceAuthType -> SourceAuth)
-> Parser (Maybe Text) -> Parser (SourceAuthType -> SourceAuth)
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
"resource")
Parser (SourceAuthType -> SourceAuth)
-> Parser SourceAuthType -> Parser SourceAuth
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser SourceAuthType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"type")
)
instance Prelude.Hashable SourceAuth
instance Prelude.NFData SourceAuth
instance Core.ToJSON SourceAuth where
toJSON :: SourceAuth -> Value
toJSON SourceAuth' {Maybe Text
SourceAuthType
type' :: SourceAuthType
resource :: Maybe Text
$sel:type':SourceAuth' :: SourceAuth -> SourceAuthType
$sel:resource:SourceAuth' :: SourceAuth -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"resource" 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
resource,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"type" Text -> SourceAuthType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= SourceAuthType
type')
]
)