{-# 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.CodeGuruReviewer.Types.RepositoryHeadSourceCodeType
-- 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.CodeGuruReviewer.Types.RepositoryHeadSourceCodeType where

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

-- | A
-- <https://docs.aws.amazon.com/codeguru/latest/reviewer-api/API_SourceCodeType SourceCodeType>
-- that specifies the tip of a branch in an associated repository.
--
-- /See:/ 'newRepositoryHeadSourceCodeType' smart constructor.
data RepositoryHeadSourceCodeType = RepositoryHeadSourceCodeType'
  { -- | The name of the branch in an associated repository. The
    -- @RepositoryHeadSourceCodeType@ specifies the tip of this branch.
    RepositoryHeadSourceCodeType -> Text
branchName :: Prelude.Text
  }
  deriving (RepositoryHeadSourceCodeType
-> RepositoryHeadSourceCodeType -> Bool
(RepositoryHeadSourceCodeType
 -> RepositoryHeadSourceCodeType -> Bool)
-> (RepositoryHeadSourceCodeType
    -> RepositoryHeadSourceCodeType -> Bool)
-> Eq RepositoryHeadSourceCodeType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RepositoryHeadSourceCodeType
-> RepositoryHeadSourceCodeType -> Bool
$c/= :: RepositoryHeadSourceCodeType
-> RepositoryHeadSourceCodeType -> Bool
== :: RepositoryHeadSourceCodeType
-> RepositoryHeadSourceCodeType -> Bool
$c== :: RepositoryHeadSourceCodeType
-> RepositoryHeadSourceCodeType -> Bool
Prelude.Eq, ReadPrec [RepositoryHeadSourceCodeType]
ReadPrec RepositoryHeadSourceCodeType
Int -> ReadS RepositoryHeadSourceCodeType
ReadS [RepositoryHeadSourceCodeType]
(Int -> ReadS RepositoryHeadSourceCodeType)
-> ReadS [RepositoryHeadSourceCodeType]
-> ReadPrec RepositoryHeadSourceCodeType
-> ReadPrec [RepositoryHeadSourceCodeType]
-> Read RepositoryHeadSourceCodeType
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RepositoryHeadSourceCodeType]
$creadListPrec :: ReadPrec [RepositoryHeadSourceCodeType]
readPrec :: ReadPrec RepositoryHeadSourceCodeType
$creadPrec :: ReadPrec RepositoryHeadSourceCodeType
readList :: ReadS [RepositoryHeadSourceCodeType]
$creadList :: ReadS [RepositoryHeadSourceCodeType]
readsPrec :: Int -> ReadS RepositoryHeadSourceCodeType
$creadsPrec :: Int -> ReadS RepositoryHeadSourceCodeType
Prelude.Read, Int -> RepositoryHeadSourceCodeType -> ShowS
[RepositoryHeadSourceCodeType] -> ShowS
RepositoryHeadSourceCodeType -> String
(Int -> RepositoryHeadSourceCodeType -> ShowS)
-> (RepositoryHeadSourceCodeType -> String)
-> ([RepositoryHeadSourceCodeType] -> ShowS)
-> Show RepositoryHeadSourceCodeType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RepositoryHeadSourceCodeType] -> ShowS
$cshowList :: [RepositoryHeadSourceCodeType] -> ShowS
show :: RepositoryHeadSourceCodeType -> String
$cshow :: RepositoryHeadSourceCodeType -> String
showsPrec :: Int -> RepositoryHeadSourceCodeType -> ShowS
$cshowsPrec :: Int -> RepositoryHeadSourceCodeType -> ShowS
Prelude.Show, (forall x.
 RepositoryHeadSourceCodeType -> Rep RepositoryHeadSourceCodeType x)
-> (forall x.
    Rep RepositoryHeadSourceCodeType x -> RepositoryHeadSourceCodeType)
-> Generic RepositoryHeadSourceCodeType
forall x.
Rep RepositoryHeadSourceCodeType x -> RepositoryHeadSourceCodeType
forall x.
RepositoryHeadSourceCodeType -> Rep RepositoryHeadSourceCodeType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep RepositoryHeadSourceCodeType x -> RepositoryHeadSourceCodeType
$cfrom :: forall x.
RepositoryHeadSourceCodeType -> Rep RepositoryHeadSourceCodeType x
Prelude.Generic)

-- |
-- Create a value of 'RepositoryHeadSourceCodeType' 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:
--
-- 'branchName', 'repositoryHeadSourceCodeType_branchName' - The name of the branch in an associated repository. The
-- @RepositoryHeadSourceCodeType@ specifies the tip of this branch.
newRepositoryHeadSourceCodeType ::
  -- | 'branchName'
  Prelude.Text ->
  RepositoryHeadSourceCodeType
newRepositoryHeadSourceCodeType :: Text -> RepositoryHeadSourceCodeType
newRepositoryHeadSourceCodeType Text
pBranchName_ =
  RepositoryHeadSourceCodeType' :: Text -> RepositoryHeadSourceCodeType
RepositoryHeadSourceCodeType'
    { $sel:branchName:RepositoryHeadSourceCodeType' :: Text
branchName =
        Text
pBranchName_
    }

-- | The name of the branch in an associated repository. The
-- @RepositoryHeadSourceCodeType@ specifies the tip of this branch.
repositoryHeadSourceCodeType_branchName :: Lens.Lens' RepositoryHeadSourceCodeType Prelude.Text
repositoryHeadSourceCodeType_branchName :: (Text -> f Text)
-> RepositoryHeadSourceCodeType -> f RepositoryHeadSourceCodeType
repositoryHeadSourceCodeType_branchName = (RepositoryHeadSourceCodeType -> Text)
-> (RepositoryHeadSourceCodeType
    -> Text -> RepositoryHeadSourceCodeType)
-> Lens
     RepositoryHeadSourceCodeType RepositoryHeadSourceCodeType Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RepositoryHeadSourceCodeType' {Text
branchName :: Text
$sel:branchName:RepositoryHeadSourceCodeType' :: RepositoryHeadSourceCodeType -> Text
branchName} -> Text
branchName) (\s :: RepositoryHeadSourceCodeType
s@RepositoryHeadSourceCodeType' {} Text
a -> RepositoryHeadSourceCodeType
s {$sel:branchName:RepositoryHeadSourceCodeType' :: Text
branchName = Text
a} :: RepositoryHeadSourceCodeType)

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

instance
  Prelude.Hashable
    RepositoryHeadSourceCodeType

instance Prelude.NFData RepositoryHeadSourceCodeType

instance Core.ToJSON RepositoryHeadSourceCodeType where
  toJSON :: RepositoryHeadSourceCodeType -> Value
toJSON RepositoryHeadSourceCodeType' {Text
branchName :: Text
$sel:branchName:RepositoryHeadSourceCodeType' :: RepositoryHeadSourceCodeType -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"BranchName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
branchName)]
      )