{-# 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.Difference
-- 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.Difference where

import Amazonka.CodeCommit.Types.BlobMetadata
import Amazonka.CodeCommit.Types.ChangeTypeEnum
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Returns information about a set of differences for a commit specifier.
--
-- /See:/ 'newDifference' smart constructor.
data Difference = Difference'
  { -- | Information about an @afterBlob@ data type object, including the ID, the
    -- file mode permission code, and the path.
    Difference -> Maybe BlobMetadata
afterBlob :: Prelude.Maybe BlobMetadata,
    -- | Information about a @beforeBlob@ data type object, including the ID, the
    -- file mode permission code, and the path.
    Difference -> Maybe BlobMetadata
beforeBlob :: Prelude.Maybe BlobMetadata,
    -- | Whether the change type of the difference is an addition (A), deletion
    -- (D), or modification (M).
    Difference -> Maybe ChangeTypeEnum
changeType :: Prelude.Maybe ChangeTypeEnum
  }
  deriving (Difference -> Difference -> Bool
(Difference -> Difference -> Bool)
-> (Difference -> Difference -> Bool) -> Eq Difference
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Difference -> Difference -> Bool
$c/= :: Difference -> Difference -> Bool
== :: Difference -> Difference -> Bool
$c== :: Difference -> Difference -> Bool
Prelude.Eq, ReadPrec [Difference]
ReadPrec Difference
Int -> ReadS Difference
ReadS [Difference]
(Int -> ReadS Difference)
-> ReadS [Difference]
-> ReadPrec Difference
-> ReadPrec [Difference]
-> Read Difference
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Difference]
$creadListPrec :: ReadPrec [Difference]
readPrec :: ReadPrec Difference
$creadPrec :: ReadPrec Difference
readList :: ReadS [Difference]
$creadList :: ReadS [Difference]
readsPrec :: Int -> ReadS Difference
$creadsPrec :: Int -> ReadS Difference
Prelude.Read, Int -> Difference -> ShowS
[Difference] -> ShowS
Difference -> String
(Int -> Difference -> ShowS)
-> (Difference -> String)
-> ([Difference] -> ShowS)
-> Show Difference
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Difference] -> ShowS
$cshowList :: [Difference] -> ShowS
show :: Difference -> String
$cshow :: Difference -> String
showsPrec :: Int -> Difference -> ShowS
$cshowsPrec :: Int -> Difference -> ShowS
Prelude.Show, (forall x. Difference -> Rep Difference x)
-> (forall x. Rep Difference x -> Difference) -> Generic Difference
forall x. Rep Difference x -> Difference
forall x. Difference -> Rep Difference x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Difference x -> Difference
$cfrom :: forall x. Difference -> Rep Difference x
Prelude.Generic)

-- |
-- Create a value of 'Difference' 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:
--
-- 'afterBlob', 'difference_afterBlob' - Information about an @afterBlob@ data type object, including the ID, the
-- file mode permission code, and the path.
--
-- 'beforeBlob', 'difference_beforeBlob' - Information about a @beforeBlob@ data type object, including the ID, the
-- file mode permission code, and the path.
--
-- 'changeType', 'difference_changeType' - Whether the change type of the difference is an addition (A), deletion
-- (D), or modification (M).
newDifference ::
  Difference
newDifference :: Difference
newDifference =
  Difference' :: Maybe BlobMetadata
-> Maybe BlobMetadata -> Maybe ChangeTypeEnum -> Difference
Difference'
    { $sel:afterBlob:Difference' :: Maybe BlobMetadata
afterBlob = Maybe BlobMetadata
forall a. Maybe a
Prelude.Nothing,
      $sel:beforeBlob:Difference' :: Maybe BlobMetadata
beforeBlob = Maybe BlobMetadata
forall a. Maybe a
Prelude.Nothing,
      $sel:changeType:Difference' :: Maybe ChangeTypeEnum
changeType = Maybe ChangeTypeEnum
forall a. Maybe a
Prelude.Nothing
    }

-- | Information about an @afterBlob@ data type object, including the ID, the
-- file mode permission code, and the path.
difference_afterBlob :: Lens.Lens' Difference (Prelude.Maybe BlobMetadata)
difference_afterBlob :: (Maybe BlobMetadata -> f (Maybe BlobMetadata))
-> Difference -> f Difference
difference_afterBlob = (Difference -> Maybe BlobMetadata)
-> (Difference -> Maybe BlobMetadata -> Difference)
-> Lens
     Difference Difference (Maybe BlobMetadata) (Maybe BlobMetadata)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Difference' {Maybe BlobMetadata
afterBlob :: Maybe BlobMetadata
$sel:afterBlob:Difference' :: Difference -> Maybe BlobMetadata
afterBlob} -> Maybe BlobMetadata
afterBlob) (\s :: Difference
s@Difference' {} Maybe BlobMetadata
a -> Difference
s {$sel:afterBlob:Difference' :: Maybe BlobMetadata
afterBlob = Maybe BlobMetadata
a} :: Difference)

-- | Information about a @beforeBlob@ data type object, including the ID, the
-- file mode permission code, and the path.
difference_beforeBlob :: Lens.Lens' Difference (Prelude.Maybe BlobMetadata)
difference_beforeBlob :: (Maybe BlobMetadata -> f (Maybe BlobMetadata))
-> Difference -> f Difference
difference_beforeBlob = (Difference -> Maybe BlobMetadata)
-> (Difference -> Maybe BlobMetadata -> Difference)
-> Lens
     Difference Difference (Maybe BlobMetadata) (Maybe BlobMetadata)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Difference' {Maybe BlobMetadata
beforeBlob :: Maybe BlobMetadata
$sel:beforeBlob:Difference' :: Difference -> Maybe BlobMetadata
beforeBlob} -> Maybe BlobMetadata
beforeBlob) (\s :: Difference
s@Difference' {} Maybe BlobMetadata
a -> Difference
s {$sel:beforeBlob:Difference' :: Maybe BlobMetadata
beforeBlob = Maybe BlobMetadata
a} :: Difference)

-- | Whether the change type of the difference is an addition (A), deletion
-- (D), or modification (M).
difference_changeType :: Lens.Lens' Difference (Prelude.Maybe ChangeTypeEnum)
difference_changeType :: (Maybe ChangeTypeEnum -> f (Maybe ChangeTypeEnum))
-> Difference -> f Difference
difference_changeType = (Difference -> Maybe ChangeTypeEnum)
-> (Difference -> Maybe ChangeTypeEnum -> Difference)
-> Lens
     Difference Difference (Maybe ChangeTypeEnum) (Maybe ChangeTypeEnum)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Difference' {Maybe ChangeTypeEnum
changeType :: Maybe ChangeTypeEnum
$sel:changeType:Difference' :: Difference -> Maybe ChangeTypeEnum
changeType} -> Maybe ChangeTypeEnum
changeType) (\s :: Difference
s@Difference' {} Maybe ChangeTypeEnum
a -> Difference
s {$sel:changeType:Difference' :: Maybe ChangeTypeEnum
changeType = Maybe ChangeTypeEnum
a} :: Difference)

instance Core.FromJSON Difference where
  parseJSON :: Value -> Parser Difference
parseJSON =
    String
-> (Object -> Parser Difference) -> Value -> Parser Difference
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Difference"
      ( \Object
x ->
          Maybe BlobMetadata
-> Maybe BlobMetadata -> Maybe ChangeTypeEnum -> Difference
Difference'
            (Maybe BlobMetadata
 -> Maybe BlobMetadata -> Maybe ChangeTypeEnum -> Difference)
-> Parser (Maybe BlobMetadata)
-> Parser
     (Maybe BlobMetadata -> Maybe ChangeTypeEnum -> Difference)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe BlobMetadata)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"afterBlob")
            Parser (Maybe BlobMetadata -> Maybe ChangeTypeEnum -> Difference)
-> Parser (Maybe BlobMetadata)
-> Parser (Maybe ChangeTypeEnum -> Difference)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe BlobMetadata)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"beforeBlob")
            Parser (Maybe ChangeTypeEnum -> Difference)
-> Parser (Maybe ChangeTypeEnum) -> Parser Difference
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ChangeTypeEnum)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"changeType")
      )

instance Prelude.Hashable Difference

instance Prelude.NFData Difference