{-# 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.Glue.Types.Crawl
-- 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.Glue.Types.Crawl where

import qualified Amazonka.Core as Core
import Amazonka.Glue.Types.CrawlState
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The details of a crawl in the workflow.
--
-- /See:/ 'newCrawl' smart constructor.
data Crawl = Crawl'
  { -- | The date and time on which the crawl completed.
    Crawl -> Maybe POSIX
completedOn :: Prelude.Maybe Core.POSIX,
    -- | The state of the crawler.
    Crawl -> Maybe CrawlState
state :: Prelude.Maybe CrawlState,
    -- | The date and time on which the crawl started.
    Crawl -> Maybe POSIX
startedOn :: Prelude.Maybe Core.POSIX,
    -- | The log stream associated with the crawl.
    Crawl -> Maybe Text
logStream :: Prelude.Maybe Prelude.Text,
    -- | The log group associated with the crawl.
    Crawl -> Maybe Text
logGroup :: Prelude.Maybe Prelude.Text,
    -- | The error message associated with the crawl.
    Crawl -> Maybe Text
errorMessage :: Prelude.Maybe Prelude.Text
  }
  deriving (Crawl -> Crawl -> Bool
(Crawl -> Crawl -> Bool) -> (Crawl -> Crawl -> Bool) -> Eq Crawl
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Crawl -> Crawl -> Bool
$c/= :: Crawl -> Crawl -> Bool
== :: Crawl -> Crawl -> Bool
$c== :: Crawl -> Crawl -> Bool
Prelude.Eq, ReadPrec [Crawl]
ReadPrec Crawl
Int -> ReadS Crawl
ReadS [Crawl]
(Int -> ReadS Crawl)
-> ReadS [Crawl]
-> ReadPrec Crawl
-> ReadPrec [Crawl]
-> Read Crawl
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Crawl]
$creadListPrec :: ReadPrec [Crawl]
readPrec :: ReadPrec Crawl
$creadPrec :: ReadPrec Crawl
readList :: ReadS [Crawl]
$creadList :: ReadS [Crawl]
readsPrec :: Int -> ReadS Crawl
$creadsPrec :: Int -> ReadS Crawl
Prelude.Read, Int -> Crawl -> ShowS
[Crawl] -> ShowS
Crawl -> String
(Int -> Crawl -> ShowS)
-> (Crawl -> String) -> ([Crawl] -> ShowS) -> Show Crawl
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Crawl] -> ShowS
$cshowList :: [Crawl] -> ShowS
show :: Crawl -> String
$cshow :: Crawl -> String
showsPrec :: Int -> Crawl -> ShowS
$cshowsPrec :: Int -> Crawl -> ShowS
Prelude.Show, (forall x. Crawl -> Rep Crawl x)
-> (forall x. Rep Crawl x -> Crawl) -> Generic Crawl
forall x. Rep Crawl x -> Crawl
forall x. Crawl -> Rep Crawl x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Crawl x -> Crawl
$cfrom :: forall x. Crawl -> Rep Crawl x
Prelude.Generic)

-- |
-- Create a value of 'Crawl' 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:
--
-- 'completedOn', 'crawl_completedOn' - The date and time on which the crawl completed.
--
-- 'state', 'crawl_state' - The state of the crawler.
--
-- 'startedOn', 'crawl_startedOn' - The date and time on which the crawl started.
--
-- 'logStream', 'crawl_logStream' - The log stream associated with the crawl.
--
-- 'logGroup', 'crawl_logGroup' - The log group associated with the crawl.
--
-- 'errorMessage', 'crawl_errorMessage' - The error message associated with the crawl.
newCrawl ::
  Crawl
newCrawl :: Crawl
newCrawl =
  Crawl' :: Maybe POSIX
-> Maybe CrawlState
-> Maybe POSIX
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Crawl
Crawl'
    { $sel:completedOn:Crawl' :: Maybe POSIX
completedOn = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:state:Crawl' :: Maybe CrawlState
state = Maybe CrawlState
forall a. Maybe a
Prelude.Nothing,
      $sel:startedOn:Crawl' :: Maybe POSIX
startedOn = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:logStream:Crawl' :: Maybe Text
logStream = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:logGroup:Crawl' :: Maybe Text
logGroup = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:errorMessage:Crawl' :: Maybe Text
errorMessage = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The date and time on which the crawl completed.
crawl_completedOn :: Lens.Lens' Crawl (Prelude.Maybe Prelude.UTCTime)
crawl_completedOn :: (Maybe UTCTime -> f (Maybe UTCTime)) -> Crawl -> f Crawl
crawl_completedOn = (Crawl -> Maybe POSIX)
-> (Crawl -> Maybe POSIX -> Crawl)
-> Lens Crawl Crawl (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Crawl' {Maybe POSIX
completedOn :: Maybe POSIX
$sel:completedOn:Crawl' :: Crawl -> Maybe POSIX
completedOn} -> Maybe POSIX
completedOn) (\s :: Crawl
s@Crawl' {} Maybe POSIX
a -> Crawl
s {$sel:completedOn:Crawl' :: Maybe POSIX
completedOn = Maybe POSIX
a} :: Crawl) ((Maybe POSIX -> f (Maybe POSIX)) -> Crawl -> f Crawl)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> Crawl
-> f Crawl
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The state of the crawler.
crawl_state :: Lens.Lens' Crawl (Prelude.Maybe CrawlState)
crawl_state :: (Maybe CrawlState -> f (Maybe CrawlState)) -> Crawl -> f Crawl
crawl_state = (Crawl -> Maybe CrawlState)
-> (Crawl -> Maybe CrawlState -> Crawl)
-> Lens Crawl Crawl (Maybe CrawlState) (Maybe CrawlState)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Crawl' {Maybe CrawlState
state :: Maybe CrawlState
$sel:state:Crawl' :: Crawl -> Maybe CrawlState
state} -> Maybe CrawlState
state) (\s :: Crawl
s@Crawl' {} Maybe CrawlState
a -> Crawl
s {$sel:state:Crawl' :: Maybe CrawlState
state = Maybe CrawlState
a} :: Crawl)

-- | The date and time on which the crawl started.
crawl_startedOn :: Lens.Lens' Crawl (Prelude.Maybe Prelude.UTCTime)
crawl_startedOn :: (Maybe UTCTime -> f (Maybe UTCTime)) -> Crawl -> f Crawl
crawl_startedOn = (Crawl -> Maybe POSIX)
-> (Crawl -> Maybe POSIX -> Crawl)
-> Lens Crawl Crawl (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Crawl' {Maybe POSIX
startedOn :: Maybe POSIX
$sel:startedOn:Crawl' :: Crawl -> Maybe POSIX
startedOn} -> Maybe POSIX
startedOn) (\s :: Crawl
s@Crawl' {} Maybe POSIX
a -> Crawl
s {$sel:startedOn:Crawl' :: Maybe POSIX
startedOn = Maybe POSIX
a} :: Crawl) ((Maybe POSIX -> f (Maybe POSIX)) -> Crawl -> f Crawl)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> Crawl
-> f Crawl
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The log stream associated with the crawl.
crawl_logStream :: Lens.Lens' Crawl (Prelude.Maybe Prelude.Text)
crawl_logStream :: (Maybe Text -> f (Maybe Text)) -> Crawl -> f Crawl
crawl_logStream = (Crawl -> Maybe Text)
-> (Crawl -> Maybe Text -> Crawl)
-> Lens Crawl Crawl (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Crawl' {Maybe Text
logStream :: Maybe Text
$sel:logStream:Crawl' :: Crawl -> Maybe Text
logStream} -> Maybe Text
logStream) (\s :: Crawl
s@Crawl' {} Maybe Text
a -> Crawl
s {$sel:logStream:Crawl' :: Maybe Text
logStream = Maybe Text
a} :: Crawl)

-- | The log group associated with the crawl.
crawl_logGroup :: Lens.Lens' Crawl (Prelude.Maybe Prelude.Text)
crawl_logGroup :: (Maybe Text -> f (Maybe Text)) -> Crawl -> f Crawl
crawl_logGroup = (Crawl -> Maybe Text)
-> (Crawl -> Maybe Text -> Crawl)
-> Lens Crawl Crawl (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Crawl' {Maybe Text
logGroup :: Maybe Text
$sel:logGroup:Crawl' :: Crawl -> Maybe Text
logGroup} -> Maybe Text
logGroup) (\s :: Crawl
s@Crawl' {} Maybe Text
a -> Crawl
s {$sel:logGroup:Crawl' :: Maybe Text
logGroup = Maybe Text
a} :: Crawl)

-- | The error message associated with the crawl.
crawl_errorMessage :: Lens.Lens' Crawl (Prelude.Maybe Prelude.Text)
crawl_errorMessage :: (Maybe Text -> f (Maybe Text)) -> Crawl -> f Crawl
crawl_errorMessage = (Crawl -> Maybe Text)
-> (Crawl -> Maybe Text -> Crawl)
-> Lens Crawl Crawl (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Crawl' {Maybe Text
errorMessage :: Maybe Text
$sel:errorMessage:Crawl' :: Crawl -> Maybe Text
errorMessage} -> Maybe Text
errorMessage) (\s :: Crawl
s@Crawl' {} Maybe Text
a -> Crawl
s {$sel:errorMessage:Crawl' :: Maybe Text
errorMessage = Maybe Text
a} :: Crawl)

instance Core.FromJSON Crawl where
  parseJSON :: Value -> Parser Crawl
parseJSON =
    String -> (Object -> Parser Crawl) -> Value -> Parser Crawl
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Crawl"
      ( \Object
x ->
          Maybe POSIX
-> Maybe CrawlState
-> Maybe POSIX
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Crawl
Crawl'
            (Maybe POSIX
 -> Maybe CrawlState
 -> Maybe POSIX
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Crawl)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe CrawlState
      -> Maybe POSIX -> Maybe Text -> Maybe Text -> Maybe Text -> Crawl)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CompletedOn")
            Parser
  (Maybe CrawlState
   -> Maybe POSIX -> Maybe Text -> Maybe Text -> Maybe Text -> Crawl)
-> Parser (Maybe CrawlState)
-> Parser
     (Maybe POSIX -> Maybe Text -> Maybe Text -> Maybe Text -> Crawl)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe CrawlState)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"State")
            Parser
  (Maybe POSIX -> Maybe Text -> Maybe Text -> Maybe Text -> Crawl)
-> Parser (Maybe POSIX)
-> Parser (Maybe Text -> Maybe Text -> Maybe Text -> Crawl)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"StartedOn")
            Parser (Maybe Text -> Maybe Text -> Maybe Text -> Crawl)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> Crawl)
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
"LogStream")
            Parser (Maybe Text -> Maybe Text -> Crawl)
-> Parser (Maybe Text) -> Parser (Maybe Text -> Crawl)
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
"LogGroup")
            Parser (Maybe Text -> Crawl) -> Parser (Maybe Text) -> Parser Crawl
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
"ErrorMessage")
      )

instance Prelude.Hashable Crawl

instance Prelude.NFData Crawl