{-# 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.CodeCommit.Types.BranchInfo
-- 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.CodeCommit.Types.BranchInfo where

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

-- | Returns information about a branch.
--
-- /See:/ 'newBranchInfo' smart constructor.
data BranchInfo = BranchInfo'
  { -- | The ID of the last commit made to the branch.
    BranchInfo -> Maybe Text
commitId :: Prelude.Maybe Prelude.Text,
    -- | The name of the branch.
    BranchInfo -> Maybe Text
branchName :: Prelude.Maybe Prelude.Text
  }
  deriving (BranchInfo -> BranchInfo -> Bool
(BranchInfo -> BranchInfo -> Bool)
-> (BranchInfo -> BranchInfo -> Bool) -> Eq BranchInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BranchInfo -> BranchInfo -> Bool
$c/= :: BranchInfo -> BranchInfo -> Bool
== :: BranchInfo -> BranchInfo -> Bool
$c== :: BranchInfo -> BranchInfo -> Bool
Prelude.Eq, ReadPrec [BranchInfo]
ReadPrec BranchInfo
Int -> ReadS BranchInfo
ReadS [BranchInfo]
(Int -> ReadS BranchInfo)
-> ReadS [BranchInfo]
-> ReadPrec BranchInfo
-> ReadPrec [BranchInfo]
-> Read BranchInfo
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BranchInfo]
$creadListPrec :: ReadPrec [BranchInfo]
readPrec :: ReadPrec BranchInfo
$creadPrec :: ReadPrec BranchInfo
readList :: ReadS [BranchInfo]
$creadList :: ReadS [BranchInfo]
readsPrec :: Int -> ReadS BranchInfo
$creadsPrec :: Int -> ReadS BranchInfo
Prelude.Read, Int -> BranchInfo -> ShowS
[BranchInfo] -> ShowS
BranchInfo -> String
(Int -> BranchInfo -> ShowS)
-> (BranchInfo -> String)
-> ([BranchInfo] -> ShowS)
-> Show BranchInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BranchInfo] -> ShowS
$cshowList :: [BranchInfo] -> ShowS
show :: BranchInfo -> String
$cshow :: BranchInfo -> String
showsPrec :: Int -> BranchInfo -> ShowS
$cshowsPrec :: Int -> BranchInfo -> ShowS
Prelude.Show, (forall x. BranchInfo -> Rep BranchInfo x)
-> (forall x. Rep BranchInfo x -> BranchInfo) -> Generic BranchInfo
forall x. Rep BranchInfo x -> BranchInfo
forall x. BranchInfo -> Rep BranchInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BranchInfo x -> BranchInfo
$cfrom :: forall x. BranchInfo -> Rep BranchInfo x
Prelude.Generic)

-- |
-- Create a value of 'BranchInfo' 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:
--
-- 'commitId', 'branchInfo_commitId' - The ID of the last commit made to the branch.
--
-- 'branchName', 'branchInfo_branchName' - The name of the branch.
newBranchInfo ::
  BranchInfo
newBranchInfo :: BranchInfo
newBranchInfo =
  BranchInfo' :: Maybe Text -> Maybe Text -> BranchInfo
BranchInfo'
    { $sel:commitId:BranchInfo' :: Maybe Text
commitId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:branchName:BranchInfo' :: Maybe Text
branchName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The ID of the last commit made to the branch.
branchInfo_commitId :: Lens.Lens' BranchInfo (Prelude.Maybe Prelude.Text)
branchInfo_commitId :: (Maybe Text -> f (Maybe Text)) -> BranchInfo -> f BranchInfo
branchInfo_commitId = (BranchInfo -> Maybe Text)
-> (BranchInfo -> Maybe Text -> BranchInfo)
-> Lens BranchInfo BranchInfo (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BranchInfo' {Maybe Text
commitId :: Maybe Text
$sel:commitId:BranchInfo' :: BranchInfo -> Maybe Text
commitId} -> Maybe Text
commitId) (\s :: BranchInfo
s@BranchInfo' {} Maybe Text
a -> BranchInfo
s {$sel:commitId:BranchInfo' :: Maybe Text
commitId = Maybe Text
a} :: BranchInfo)

-- | The name of the branch.
branchInfo_branchName :: Lens.Lens' BranchInfo (Prelude.Maybe Prelude.Text)
branchInfo_branchName :: (Maybe Text -> f (Maybe Text)) -> BranchInfo -> f BranchInfo
branchInfo_branchName = (BranchInfo -> Maybe Text)
-> (BranchInfo -> Maybe Text -> BranchInfo)
-> Lens BranchInfo BranchInfo (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BranchInfo' {Maybe Text
branchName :: Maybe Text
$sel:branchName:BranchInfo' :: BranchInfo -> Maybe Text
branchName} -> Maybe Text
branchName) (\s :: BranchInfo
s@BranchInfo' {} Maybe Text
a -> BranchInfo
s {$sel:branchName:BranchInfo' :: Maybe Text
branchName = Maybe Text
a} :: BranchInfo)

instance Core.FromJSON BranchInfo where
  parseJSON :: Value -> Parser BranchInfo
parseJSON =
    String
-> (Object -> Parser BranchInfo) -> Value -> Parser BranchInfo
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"BranchInfo"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> BranchInfo
BranchInfo'
            (Maybe Text -> Maybe Text -> BranchInfo)
-> Parser (Maybe Text) -> Parser (Maybe Text -> BranchInfo)
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
"commitId")
            Parser (Maybe Text -> BranchInfo)
-> Parser (Maybe Text) -> Parser BranchInfo
forall (f :: * -> *) a b. Applicative f => 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
"branchName")
      )

instance Prelude.Hashable BranchInfo

instance Prelude.NFData BranchInfo