{-# 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.CodeBuild.Types.SourceCredentialsInfo
-- 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.CodeBuild.Types.SourceCredentialsInfo where

import Amazonka.CodeBuild.Types.AuthType
import Amazonka.CodeBuild.Types.ServerType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Information about the credentials for a GitHub, GitHub Enterprise, or
-- Bitbucket repository.
--
-- /See:/ 'newSourceCredentialsInfo' smart constructor.
data SourceCredentialsInfo = SourceCredentialsInfo'
  { -- | The Amazon Resource Name (ARN) of the token.
    SourceCredentialsInfo -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The type of source provider. The valid options are GITHUB,
    -- GITHUB_ENTERPRISE, or BITBUCKET.
    SourceCredentialsInfo -> Maybe ServerType
serverType :: Prelude.Maybe ServerType,
    -- | The type of authentication used by the credentials. Valid options are
    -- OAUTH, BASIC_AUTH, or PERSONAL_ACCESS_TOKEN.
    SourceCredentialsInfo -> Maybe AuthType
authType :: Prelude.Maybe AuthType
  }
  deriving (SourceCredentialsInfo -> SourceCredentialsInfo -> Bool
(SourceCredentialsInfo -> SourceCredentialsInfo -> Bool)
-> (SourceCredentialsInfo -> SourceCredentialsInfo -> Bool)
-> Eq SourceCredentialsInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SourceCredentialsInfo -> SourceCredentialsInfo -> Bool
$c/= :: SourceCredentialsInfo -> SourceCredentialsInfo -> Bool
== :: SourceCredentialsInfo -> SourceCredentialsInfo -> Bool
$c== :: SourceCredentialsInfo -> SourceCredentialsInfo -> Bool
Prelude.Eq, ReadPrec [SourceCredentialsInfo]
ReadPrec SourceCredentialsInfo
Int -> ReadS SourceCredentialsInfo
ReadS [SourceCredentialsInfo]
(Int -> ReadS SourceCredentialsInfo)
-> ReadS [SourceCredentialsInfo]
-> ReadPrec SourceCredentialsInfo
-> ReadPrec [SourceCredentialsInfo]
-> Read SourceCredentialsInfo
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SourceCredentialsInfo]
$creadListPrec :: ReadPrec [SourceCredentialsInfo]
readPrec :: ReadPrec SourceCredentialsInfo
$creadPrec :: ReadPrec SourceCredentialsInfo
readList :: ReadS [SourceCredentialsInfo]
$creadList :: ReadS [SourceCredentialsInfo]
readsPrec :: Int -> ReadS SourceCredentialsInfo
$creadsPrec :: Int -> ReadS SourceCredentialsInfo
Prelude.Read, Int -> SourceCredentialsInfo -> ShowS
[SourceCredentialsInfo] -> ShowS
SourceCredentialsInfo -> String
(Int -> SourceCredentialsInfo -> ShowS)
-> (SourceCredentialsInfo -> String)
-> ([SourceCredentialsInfo] -> ShowS)
-> Show SourceCredentialsInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SourceCredentialsInfo] -> ShowS
$cshowList :: [SourceCredentialsInfo] -> ShowS
show :: SourceCredentialsInfo -> String
$cshow :: SourceCredentialsInfo -> String
showsPrec :: Int -> SourceCredentialsInfo -> ShowS
$cshowsPrec :: Int -> SourceCredentialsInfo -> ShowS
Prelude.Show, (forall x. SourceCredentialsInfo -> Rep SourceCredentialsInfo x)
-> (forall x. Rep SourceCredentialsInfo x -> SourceCredentialsInfo)
-> Generic SourceCredentialsInfo
forall x. Rep SourceCredentialsInfo x -> SourceCredentialsInfo
forall x. SourceCredentialsInfo -> Rep SourceCredentialsInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SourceCredentialsInfo x -> SourceCredentialsInfo
$cfrom :: forall x. SourceCredentialsInfo -> Rep SourceCredentialsInfo x
Prelude.Generic)

-- |
-- Create a value of 'SourceCredentialsInfo' 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:
--
-- 'arn', 'sourceCredentialsInfo_arn' - The Amazon Resource Name (ARN) of the token.
--
-- 'serverType', 'sourceCredentialsInfo_serverType' - The type of source provider. The valid options are GITHUB,
-- GITHUB_ENTERPRISE, or BITBUCKET.
--
-- 'authType', 'sourceCredentialsInfo_authType' - The type of authentication used by the credentials. Valid options are
-- OAUTH, BASIC_AUTH, or PERSONAL_ACCESS_TOKEN.
newSourceCredentialsInfo ::
  SourceCredentialsInfo
newSourceCredentialsInfo :: SourceCredentialsInfo
newSourceCredentialsInfo =
  SourceCredentialsInfo' :: Maybe Text
-> Maybe ServerType -> Maybe AuthType -> SourceCredentialsInfo
SourceCredentialsInfo'
    { $sel:arn:SourceCredentialsInfo' :: Maybe Text
arn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:serverType:SourceCredentialsInfo' :: Maybe ServerType
serverType = Maybe ServerType
forall a. Maybe a
Prelude.Nothing,
      $sel:authType:SourceCredentialsInfo' :: Maybe AuthType
authType = Maybe AuthType
forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Resource Name (ARN) of the token.
sourceCredentialsInfo_arn :: Lens.Lens' SourceCredentialsInfo (Prelude.Maybe Prelude.Text)
sourceCredentialsInfo_arn :: (Maybe Text -> f (Maybe Text))
-> SourceCredentialsInfo -> f SourceCredentialsInfo
sourceCredentialsInfo_arn = (SourceCredentialsInfo -> Maybe Text)
-> (SourceCredentialsInfo -> Maybe Text -> SourceCredentialsInfo)
-> Lens
     SourceCredentialsInfo
     SourceCredentialsInfo
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SourceCredentialsInfo' {Maybe Text
arn :: Maybe Text
$sel:arn:SourceCredentialsInfo' :: SourceCredentialsInfo -> Maybe Text
arn} -> Maybe Text
arn) (\s :: SourceCredentialsInfo
s@SourceCredentialsInfo' {} Maybe Text
a -> SourceCredentialsInfo
s {$sel:arn:SourceCredentialsInfo' :: Maybe Text
arn = Maybe Text
a} :: SourceCredentialsInfo)

-- | The type of source provider. The valid options are GITHUB,
-- GITHUB_ENTERPRISE, or BITBUCKET.
sourceCredentialsInfo_serverType :: Lens.Lens' SourceCredentialsInfo (Prelude.Maybe ServerType)
sourceCredentialsInfo_serverType :: (Maybe ServerType -> f (Maybe ServerType))
-> SourceCredentialsInfo -> f SourceCredentialsInfo
sourceCredentialsInfo_serverType = (SourceCredentialsInfo -> Maybe ServerType)
-> (SourceCredentialsInfo
    -> Maybe ServerType -> SourceCredentialsInfo)
-> Lens
     SourceCredentialsInfo
     SourceCredentialsInfo
     (Maybe ServerType)
     (Maybe ServerType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SourceCredentialsInfo' {Maybe ServerType
serverType :: Maybe ServerType
$sel:serverType:SourceCredentialsInfo' :: SourceCredentialsInfo -> Maybe ServerType
serverType} -> Maybe ServerType
serverType) (\s :: SourceCredentialsInfo
s@SourceCredentialsInfo' {} Maybe ServerType
a -> SourceCredentialsInfo
s {$sel:serverType:SourceCredentialsInfo' :: Maybe ServerType
serverType = Maybe ServerType
a} :: SourceCredentialsInfo)

-- | The type of authentication used by the credentials. Valid options are
-- OAUTH, BASIC_AUTH, or PERSONAL_ACCESS_TOKEN.
sourceCredentialsInfo_authType :: Lens.Lens' SourceCredentialsInfo (Prelude.Maybe AuthType)
sourceCredentialsInfo_authType :: (Maybe AuthType -> f (Maybe AuthType))
-> SourceCredentialsInfo -> f SourceCredentialsInfo
sourceCredentialsInfo_authType = (SourceCredentialsInfo -> Maybe AuthType)
-> (SourceCredentialsInfo
    -> Maybe AuthType -> SourceCredentialsInfo)
-> Lens
     SourceCredentialsInfo
     SourceCredentialsInfo
     (Maybe AuthType)
     (Maybe AuthType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SourceCredentialsInfo' {Maybe AuthType
authType :: Maybe AuthType
$sel:authType:SourceCredentialsInfo' :: SourceCredentialsInfo -> Maybe AuthType
authType} -> Maybe AuthType
authType) (\s :: SourceCredentialsInfo
s@SourceCredentialsInfo' {} Maybe AuthType
a -> SourceCredentialsInfo
s {$sel:authType:SourceCredentialsInfo' :: Maybe AuthType
authType = Maybe AuthType
a} :: SourceCredentialsInfo)

instance Core.FromJSON SourceCredentialsInfo where
  parseJSON :: Value -> Parser SourceCredentialsInfo
parseJSON =
    String
-> (Object -> Parser SourceCredentialsInfo)
-> Value
-> Parser SourceCredentialsInfo
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SourceCredentialsInfo"
      ( \Object
x ->
          Maybe Text
-> Maybe ServerType -> Maybe AuthType -> SourceCredentialsInfo
SourceCredentialsInfo'
            (Maybe Text
 -> Maybe ServerType -> Maybe AuthType -> SourceCredentialsInfo)
-> Parser (Maybe Text)
-> Parser
     (Maybe ServerType -> Maybe AuthType -> SourceCredentialsInfo)
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
"arn")
            Parser
  (Maybe ServerType -> Maybe AuthType -> SourceCredentialsInfo)
-> Parser (Maybe ServerType)
-> Parser (Maybe AuthType -> SourceCredentialsInfo)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ServerType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"serverType")
            Parser (Maybe AuthType -> SourceCredentialsInfo)
-> Parser (Maybe AuthType) -> Parser SourceCredentialsInfo
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe AuthType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"authType")
      )

instance Prelude.Hashable SourceCredentialsInfo

instance Prelude.NFData SourceCredentialsInfo