{-# 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.Proton.Types.Revision
-- 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.Proton.Types.Revision where

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
import Amazonka.Proton.Types.RepositoryProvider

-- | Revision detail data for a commit and push that activates a sync attempt
--
-- /See:/ 'newRevision' smart constructor.
data Revision = Revision'
  { -- | The repository branch.
    Revision -> Text
branch :: Prelude.Text,
    -- | The repository directory changed by a commit and push that activated the
    -- sync attempt.
    Revision -> Text
directory :: Prelude.Text,
    -- | The repository name.
    Revision -> Text
repositoryName :: Prelude.Text,
    -- | The repository provider.
    Revision -> RepositoryProvider
repositoryProvider :: RepositoryProvider,
    -- | The secure hash algorithm (SHA) hash for the revision.
    Revision -> Text
sha :: Prelude.Text
  }
  deriving (Revision -> Revision -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Revision -> Revision -> Bool
$c/= :: Revision -> Revision -> Bool
== :: Revision -> Revision -> Bool
$c== :: Revision -> Revision -> Bool
Prelude.Eq, ReadPrec [Revision]
ReadPrec Revision
Int -> ReadS Revision
ReadS [Revision]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Revision]
$creadListPrec :: ReadPrec [Revision]
readPrec :: ReadPrec Revision
$creadPrec :: ReadPrec Revision
readList :: ReadS [Revision]
$creadList :: ReadS [Revision]
readsPrec :: Int -> ReadS Revision
$creadsPrec :: Int -> ReadS Revision
Prelude.Read, Int -> Revision -> ShowS
[Revision] -> ShowS
Revision -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Revision] -> ShowS
$cshowList :: [Revision] -> ShowS
show :: Revision -> String
$cshow :: Revision -> String
showsPrec :: Int -> Revision -> ShowS
$cshowsPrec :: Int -> Revision -> ShowS
Prelude.Show, forall x. Rep Revision x -> Revision
forall x. Revision -> Rep Revision x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Revision x -> Revision
$cfrom :: forall x. Revision -> Rep Revision x
Prelude.Generic)

-- |
-- Create a value of 'Revision' 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:
--
-- 'branch', 'revision_branch' - The repository branch.
--
-- 'directory', 'revision_directory' - The repository directory changed by a commit and push that activated the
-- sync attempt.
--
-- 'repositoryName', 'revision_repositoryName' - The repository name.
--
-- 'repositoryProvider', 'revision_repositoryProvider' - The repository provider.
--
-- 'sha', 'revision_sha' - The secure hash algorithm (SHA) hash for the revision.
newRevision ::
  -- | 'branch'
  Prelude.Text ->
  -- | 'directory'
  Prelude.Text ->
  -- | 'repositoryName'
  Prelude.Text ->
  -- | 'repositoryProvider'
  RepositoryProvider ->
  -- | 'sha'
  Prelude.Text ->
  Revision
newRevision :: Text -> Text -> Text -> RepositoryProvider -> Text -> Revision
newRevision
  Text
pBranch_
  Text
pDirectory_
  Text
pRepositoryName_
  RepositoryProvider
pRepositoryProvider_
  Text
pSha_ =
    Revision'
      { $sel:branch:Revision' :: Text
branch = Text
pBranch_,
        $sel:directory:Revision' :: Text
directory = Text
pDirectory_,
        $sel:repositoryName:Revision' :: Text
repositoryName = Text
pRepositoryName_,
        $sel:repositoryProvider:Revision' :: RepositoryProvider
repositoryProvider = RepositoryProvider
pRepositoryProvider_,
        $sel:sha:Revision' :: Text
sha = Text
pSha_
      }

-- | The repository branch.
revision_branch :: Lens.Lens' Revision Prelude.Text
revision_branch :: Lens' Revision Text
revision_branch = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Revision' {Text
branch :: Text
$sel:branch:Revision' :: Revision -> Text
branch} -> Text
branch) (\s :: Revision
s@Revision' {} Text
a -> Revision
s {$sel:branch:Revision' :: Text
branch = Text
a} :: Revision)

-- | The repository directory changed by a commit and push that activated the
-- sync attempt.
revision_directory :: Lens.Lens' Revision Prelude.Text
revision_directory :: Lens' Revision Text
revision_directory = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Revision' {Text
directory :: Text
$sel:directory:Revision' :: Revision -> Text
directory} -> Text
directory) (\s :: Revision
s@Revision' {} Text
a -> Revision
s {$sel:directory:Revision' :: Text
directory = Text
a} :: Revision)

-- | The repository name.
revision_repositoryName :: Lens.Lens' Revision Prelude.Text
revision_repositoryName :: Lens' Revision Text
revision_repositoryName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Revision' {Text
repositoryName :: Text
$sel:repositoryName:Revision' :: Revision -> Text
repositoryName} -> Text
repositoryName) (\s :: Revision
s@Revision' {} Text
a -> Revision
s {$sel:repositoryName:Revision' :: Text
repositoryName = Text
a} :: Revision)

-- | The repository provider.
revision_repositoryProvider :: Lens.Lens' Revision RepositoryProvider
revision_repositoryProvider :: Lens' Revision RepositoryProvider
revision_repositoryProvider = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Revision' {RepositoryProvider
repositoryProvider :: RepositoryProvider
$sel:repositoryProvider:Revision' :: Revision -> RepositoryProvider
repositoryProvider} -> RepositoryProvider
repositoryProvider) (\s :: Revision
s@Revision' {} RepositoryProvider
a -> Revision
s {$sel:repositoryProvider:Revision' :: RepositoryProvider
repositoryProvider = RepositoryProvider
a} :: Revision)

-- | The secure hash algorithm (SHA) hash for the revision.
revision_sha :: Lens.Lens' Revision Prelude.Text
revision_sha :: Lens' Revision Text
revision_sha = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Revision' {Text
sha :: Text
$sel:sha:Revision' :: Revision -> Text
sha} -> Text
sha) (\s :: Revision
s@Revision' {} Text
a -> Revision
s {$sel:sha:Revision' :: Text
sha = Text
a} :: Revision)

instance Data.FromJSON Revision where
  parseJSON :: Value -> Parser Revision
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Revision"
      ( \Object
x ->
          Text -> Text -> Text -> RepositoryProvider -> Text -> Revision
Revision'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"branch")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"directory")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"repositoryName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"repositoryProvider")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"sha")
      )

instance Prelude.Hashable Revision where
  hashWithSalt :: Int -> Revision -> Int
hashWithSalt Int
_salt Revision' {Text
RepositoryProvider
sha :: Text
repositoryProvider :: RepositoryProvider
repositoryName :: Text
directory :: Text
branch :: Text
$sel:sha:Revision' :: Revision -> Text
$sel:repositoryProvider:Revision' :: Revision -> RepositoryProvider
$sel:repositoryName:Revision' :: Revision -> Text
$sel:directory:Revision' :: Revision -> Text
$sel:branch:Revision' :: Revision -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
branch
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
directory
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
repositoryName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` RepositoryProvider
repositoryProvider
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
sha

instance Prelude.NFData Revision where
  rnf :: Revision -> ()
rnf Revision' {Text
RepositoryProvider
sha :: Text
repositoryProvider :: RepositoryProvider
repositoryName :: Text
directory :: Text
branch :: Text
$sel:sha:Revision' :: Revision -> Text
$sel:repositoryProvider:Revision' :: Revision -> RepositoryProvider
$sel:repositoryName:Revision' :: Revision -> Text
$sel:directory:Revision' :: Revision -> Text
$sel:branch:Revision' :: Revision -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
branch
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
directory
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
repositoryName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf RepositoryProvider
repositoryProvider
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
sha