{-# 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.RepositorySyncAttempt
-- 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.RepositorySyncAttempt 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.RepositorySyncEvent
import Amazonka.Proton.Types.RepositorySyncStatus

-- | Detail data for a repository sync attempt activated by a push to a
-- repository.
--
-- /See:/ 'newRepositorySyncAttempt' smart constructor.
data RepositorySyncAttempt = RepositorySyncAttempt'
  { -- | Detail data for sync attempt events.
    RepositorySyncAttempt -> [RepositorySyncEvent]
events :: [RepositorySyncEvent],
    -- | The time when the sync attempt started.
    RepositorySyncAttempt -> POSIX
startedAt :: Data.POSIX,
    -- | The sync attempt status.
    RepositorySyncAttempt -> RepositorySyncStatus
status :: RepositorySyncStatus
  }
  deriving (RepositorySyncAttempt -> RepositorySyncAttempt -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RepositorySyncAttempt -> RepositorySyncAttempt -> Bool
$c/= :: RepositorySyncAttempt -> RepositorySyncAttempt -> Bool
== :: RepositorySyncAttempt -> RepositorySyncAttempt -> Bool
$c== :: RepositorySyncAttempt -> RepositorySyncAttempt -> Bool
Prelude.Eq, ReadPrec [RepositorySyncAttempt]
ReadPrec RepositorySyncAttempt
Int -> ReadS RepositorySyncAttempt
ReadS [RepositorySyncAttempt]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RepositorySyncAttempt]
$creadListPrec :: ReadPrec [RepositorySyncAttempt]
readPrec :: ReadPrec RepositorySyncAttempt
$creadPrec :: ReadPrec RepositorySyncAttempt
readList :: ReadS [RepositorySyncAttempt]
$creadList :: ReadS [RepositorySyncAttempt]
readsPrec :: Int -> ReadS RepositorySyncAttempt
$creadsPrec :: Int -> ReadS RepositorySyncAttempt
Prelude.Read, Int -> RepositorySyncAttempt -> ShowS
[RepositorySyncAttempt] -> ShowS
RepositorySyncAttempt -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RepositorySyncAttempt] -> ShowS
$cshowList :: [RepositorySyncAttempt] -> ShowS
show :: RepositorySyncAttempt -> String
$cshow :: RepositorySyncAttempt -> String
showsPrec :: Int -> RepositorySyncAttempt -> ShowS
$cshowsPrec :: Int -> RepositorySyncAttempt -> ShowS
Prelude.Show, forall x. Rep RepositorySyncAttempt x -> RepositorySyncAttempt
forall x. RepositorySyncAttempt -> Rep RepositorySyncAttempt x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RepositorySyncAttempt x -> RepositorySyncAttempt
$cfrom :: forall x. RepositorySyncAttempt -> Rep RepositorySyncAttempt x
Prelude.Generic)

-- |
-- Create a value of 'RepositorySyncAttempt' 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:
--
-- 'events', 'repositorySyncAttempt_events' - Detail data for sync attempt events.
--
-- 'startedAt', 'repositorySyncAttempt_startedAt' - The time when the sync attempt started.
--
-- 'status', 'repositorySyncAttempt_status' - The sync attempt status.
newRepositorySyncAttempt ::
  -- | 'startedAt'
  Prelude.UTCTime ->
  -- | 'status'
  RepositorySyncStatus ->
  RepositorySyncAttempt
newRepositorySyncAttempt :: UTCTime -> RepositorySyncStatus -> RepositorySyncAttempt
newRepositorySyncAttempt UTCTime
pStartedAt_ RepositorySyncStatus
pStatus_ =
  RepositorySyncAttempt'
    { $sel:events:RepositorySyncAttempt' :: [RepositorySyncEvent]
events = forall a. Monoid a => a
Prelude.mempty,
      $sel:startedAt:RepositorySyncAttempt' :: POSIX
startedAt = forall (a :: Format). Iso' (Time a) UTCTime
Data._Time forall t b. AReview t b -> b -> t
Lens.# UTCTime
pStartedAt_,
      $sel:status:RepositorySyncAttempt' :: RepositorySyncStatus
status = RepositorySyncStatus
pStatus_
    }

-- | Detail data for sync attempt events.
repositorySyncAttempt_events :: Lens.Lens' RepositorySyncAttempt [RepositorySyncEvent]
repositorySyncAttempt_events :: Lens' RepositorySyncAttempt [RepositorySyncEvent]
repositorySyncAttempt_events = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RepositorySyncAttempt' {[RepositorySyncEvent]
events :: [RepositorySyncEvent]
$sel:events:RepositorySyncAttempt' :: RepositorySyncAttempt -> [RepositorySyncEvent]
events} -> [RepositorySyncEvent]
events) (\s :: RepositorySyncAttempt
s@RepositorySyncAttempt' {} [RepositorySyncEvent]
a -> RepositorySyncAttempt
s {$sel:events:RepositorySyncAttempt' :: [RepositorySyncEvent]
events = [RepositorySyncEvent]
a} :: RepositorySyncAttempt) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The time when the sync attempt started.
repositorySyncAttempt_startedAt :: Lens.Lens' RepositorySyncAttempt Prelude.UTCTime
repositorySyncAttempt_startedAt :: Lens' RepositorySyncAttempt UTCTime
repositorySyncAttempt_startedAt = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RepositorySyncAttempt' {POSIX
startedAt :: POSIX
$sel:startedAt:RepositorySyncAttempt' :: RepositorySyncAttempt -> POSIX
startedAt} -> POSIX
startedAt) (\s :: RepositorySyncAttempt
s@RepositorySyncAttempt' {} POSIX
a -> RepositorySyncAttempt
s {$sel:startedAt:RepositorySyncAttempt' :: POSIX
startedAt = POSIX
a} :: RepositorySyncAttempt) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The sync attempt status.
repositorySyncAttempt_status :: Lens.Lens' RepositorySyncAttempt RepositorySyncStatus
repositorySyncAttempt_status :: Lens' RepositorySyncAttempt RepositorySyncStatus
repositorySyncAttempt_status = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RepositorySyncAttempt' {RepositorySyncStatus
status :: RepositorySyncStatus
$sel:status:RepositorySyncAttempt' :: RepositorySyncAttempt -> RepositorySyncStatus
status} -> RepositorySyncStatus
status) (\s :: RepositorySyncAttempt
s@RepositorySyncAttempt' {} RepositorySyncStatus
a -> RepositorySyncAttempt
s {$sel:status:RepositorySyncAttempt' :: RepositorySyncStatus
status = RepositorySyncStatus
a} :: RepositorySyncAttempt)

instance Data.FromJSON RepositorySyncAttempt where
  parseJSON :: Value -> Parser RepositorySyncAttempt
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"RepositorySyncAttempt"
      ( \Object
x ->
          [RepositorySyncEvent]
-> POSIX -> RepositorySyncStatus -> RepositorySyncAttempt
RepositorySyncAttempt'
            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
"events" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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
"startedAt")
            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
"status")
      )

instance Prelude.Hashable RepositorySyncAttempt where
  hashWithSalt :: Int -> RepositorySyncAttempt -> Int
hashWithSalt Int
_salt RepositorySyncAttempt' {[RepositorySyncEvent]
POSIX
RepositorySyncStatus
status :: RepositorySyncStatus
startedAt :: POSIX
events :: [RepositorySyncEvent]
$sel:status:RepositorySyncAttempt' :: RepositorySyncAttempt -> RepositorySyncStatus
$sel:startedAt:RepositorySyncAttempt' :: RepositorySyncAttempt -> POSIX
$sel:events:RepositorySyncAttempt' :: RepositorySyncAttempt -> [RepositorySyncEvent]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [RepositorySyncEvent]
events
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` POSIX
startedAt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` RepositorySyncStatus
status

instance Prelude.NFData RepositorySyncAttempt where
  rnf :: RepositorySyncAttempt -> ()
rnf RepositorySyncAttempt' {[RepositorySyncEvent]
POSIX
RepositorySyncStatus
status :: RepositorySyncStatus
startedAt :: POSIX
events :: [RepositorySyncEvent]
$sel:status:RepositorySyncAttempt' :: RepositorySyncAttempt -> RepositorySyncStatus
$sel:startedAt:RepositorySyncAttempt' :: RepositorySyncAttempt -> POSIX
$sel:events:RepositorySyncAttempt' :: RepositorySyncAttempt -> [RepositorySyncEvent]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf [RepositorySyncEvent]
events
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf POSIX
startedAt
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf RepositorySyncStatus
status