{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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 authentication used by the credentials. Valid options are
    -- OAUTH, BASIC_AUTH, or PERSONAL_ACCESS_TOKEN.
    SourceCredentialsInfo -> Maybe AuthType
authType :: Prelude.Maybe AuthType,
    -- | The type of source provider. The valid options are GITHUB,
    -- GITHUB_ENTERPRISE, or BITBUCKET.
    SourceCredentialsInfo -> Maybe ServerType
serverType :: Prelude.Maybe ServerType
  }
  deriving (SourceCredentialsInfo -> SourceCredentialsInfo -> Bool
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]
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
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. 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.
--
-- 'authType', 'sourceCredentialsInfo_authType' - The type of authentication used by the credentials. Valid options are
-- OAUTH, BASIC_AUTH, or PERSONAL_ACCESS_TOKEN.
--
-- 'serverType', 'sourceCredentialsInfo_serverType' - The type of source provider. The valid options are GITHUB,
-- GITHUB_ENTERPRISE, or BITBUCKET.
newSourceCredentialsInfo ::
  SourceCredentialsInfo
newSourceCredentialsInfo :: SourceCredentialsInfo
newSourceCredentialsInfo =
  SourceCredentialsInfo'
    { $sel:arn:SourceCredentialsInfo' :: Maybe Text
arn = forall a. Maybe a
Prelude.Nothing,
      $sel:authType:SourceCredentialsInfo' :: Maybe AuthType
authType = forall a. Maybe a
Prelude.Nothing,
      $sel:serverType:SourceCredentialsInfo' :: Maybe ServerType
serverType = 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 :: Lens' SourceCredentialsInfo (Maybe Text)
sourceCredentialsInfo_arn = 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 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 :: Lens' SourceCredentialsInfo (Maybe AuthType)
sourceCredentialsInfo_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)

-- | The type of source provider. The valid options are GITHUB,
-- GITHUB_ENTERPRISE, or BITBUCKET.
sourceCredentialsInfo_serverType :: Lens.Lens' SourceCredentialsInfo (Prelude.Maybe ServerType)
sourceCredentialsInfo_serverType :: Lens' SourceCredentialsInfo (Maybe ServerType)
sourceCredentialsInfo_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)

instance Data.FromJSON SourceCredentialsInfo where
  parseJSON :: Value -> Parser SourceCredentialsInfo
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SourceCredentialsInfo"
      ( \Object
x ->
          Maybe Text
-> Maybe AuthType -> Maybe ServerType -> SourceCredentialsInfo
SourceCredentialsInfo'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"arn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"authType")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"serverType")
      )

instance Prelude.Hashable SourceCredentialsInfo where
  hashWithSalt :: Int -> SourceCredentialsInfo -> Int
hashWithSalt Int
_salt SourceCredentialsInfo' {Maybe Text
Maybe AuthType
Maybe ServerType
serverType :: Maybe ServerType
authType :: Maybe AuthType
arn :: Maybe Text
$sel:serverType:SourceCredentialsInfo' :: SourceCredentialsInfo -> Maybe ServerType
$sel:authType:SourceCredentialsInfo' :: SourceCredentialsInfo -> Maybe AuthType
$sel:arn:SourceCredentialsInfo' :: SourceCredentialsInfo -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
arn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AuthType
authType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ServerType
serverType

instance Prelude.NFData SourceCredentialsInfo where
  rnf :: SourceCredentialsInfo -> ()
rnf SourceCredentialsInfo' {Maybe Text
Maybe AuthType
Maybe ServerType
serverType :: Maybe ServerType
authType :: Maybe AuthType
arn :: Maybe Text
$sel:serverType:SourceCredentialsInfo' :: SourceCredentialsInfo -> Maybe ServerType
$sel:authType:SourceCredentialsInfo' :: SourceCredentialsInfo -> Maybe AuthType
$sel:arn:SourceCredentialsInfo' :: SourceCredentialsInfo -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
arn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe AuthType
authType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ServerType
serverType