{-# 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.AlexaBusiness.Types.BusinessReport
-- 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.AlexaBusiness.Types.BusinessReport where

import Amazonka.AlexaBusiness.Types.BusinessReportFailureCode
import Amazonka.AlexaBusiness.Types.BusinessReportS3Location
import Amazonka.AlexaBusiness.Types.BusinessReportStatus
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Usage report with specified parameters.
--
-- /See:/ 'newBusinessReport' smart constructor.
data BusinessReport = BusinessReport'
  { -- | The status of the report generation execution (RUNNING, SUCCEEDED, or
    -- FAILED).
    BusinessReport -> Maybe BusinessReportStatus
status :: Prelude.Maybe BusinessReportStatus,
    -- | The failure code.
    BusinessReport -> Maybe BusinessReportFailureCode
failureCode :: Prelude.Maybe BusinessReportFailureCode,
    -- | The time of report delivery.
    BusinessReport -> Maybe POSIX
deliveryTime :: Prelude.Maybe Core.POSIX,
    -- | The download link where a user can download the report.
    BusinessReport -> Maybe Text
downloadUrl :: Prelude.Maybe Prelude.Text,
    -- | The S3 location of the output reports.
    BusinessReport -> Maybe BusinessReportS3Location
s3Location :: Prelude.Maybe BusinessReportS3Location
  }
  deriving (BusinessReport -> BusinessReport -> Bool
(BusinessReport -> BusinessReport -> Bool)
-> (BusinessReport -> BusinessReport -> Bool) -> Eq BusinessReport
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BusinessReport -> BusinessReport -> Bool
$c/= :: BusinessReport -> BusinessReport -> Bool
== :: BusinessReport -> BusinessReport -> Bool
$c== :: BusinessReport -> BusinessReport -> Bool
Prelude.Eq, ReadPrec [BusinessReport]
ReadPrec BusinessReport
Int -> ReadS BusinessReport
ReadS [BusinessReport]
(Int -> ReadS BusinessReport)
-> ReadS [BusinessReport]
-> ReadPrec BusinessReport
-> ReadPrec [BusinessReport]
-> Read BusinessReport
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BusinessReport]
$creadListPrec :: ReadPrec [BusinessReport]
readPrec :: ReadPrec BusinessReport
$creadPrec :: ReadPrec BusinessReport
readList :: ReadS [BusinessReport]
$creadList :: ReadS [BusinessReport]
readsPrec :: Int -> ReadS BusinessReport
$creadsPrec :: Int -> ReadS BusinessReport
Prelude.Read, Int -> BusinessReport -> ShowS
[BusinessReport] -> ShowS
BusinessReport -> String
(Int -> BusinessReport -> ShowS)
-> (BusinessReport -> String)
-> ([BusinessReport] -> ShowS)
-> Show BusinessReport
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BusinessReport] -> ShowS
$cshowList :: [BusinessReport] -> ShowS
show :: BusinessReport -> String
$cshow :: BusinessReport -> String
showsPrec :: Int -> BusinessReport -> ShowS
$cshowsPrec :: Int -> BusinessReport -> ShowS
Prelude.Show, (forall x. BusinessReport -> Rep BusinessReport x)
-> (forall x. Rep BusinessReport x -> BusinessReport)
-> Generic BusinessReport
forall x. Rep BusinessReport x -> BusinessReport
forall x. BusinessReport -> Rep BusinessReport x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BusinessReport x -> BusinessReport
$cfrom :: forall x. BusinessReport -> Rep BusinessReport x
Prelude.Generic)

-- |
-- Create a value of 'BusinessReport' 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:
--
-- 'status', 'businessReport_status' - The status of the report generation execution (RUNNING, SUCCEEDED, or
-- FAILED).
--
-- 'failureCode', 'businessReport_failureCode' - The failure code.
--
-- 'deliveryTime', 'businessReport_deliveryTime' - The time of report delivery.
--
-- 'downloadUrl', 'businessReport_downloadUrl' - The download link where a user can download the report.
--
-- 's3Location', 'businessReport_s3Location' - The S3 location of the output reports.
newBusinessReport ::
  BusinessReport
newBusinessReport :: BusinessReport
newBusinessReport =
  BusinessReport' :: Maybe BusinessReportStatus
-> Maybe BusinessReportFailureCode
-> Maybe POSIX
-> Maybe Text
-> Maybe BusinessReportS3Location
-> BusinessReport
BusinessReport'
    { $sel:status:BusinessReport' :: Maybe BusinessReportStatus
status = Maybe BusinessReportStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:failureCode:BusinessReport' :: Maybe BusinessReportFailureCode
failureCode = Maybe BusinessReportFailureCode
forall a. Maybe a
Prelude.Nothing,
      $sel:deliveryTime:BusinessReport' :: Maybe POSIX
deliveryTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:downloadUrl:BusinessReport' :: Maybe Text
downloadUrl = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:s3Location:BusinessReport' :: Maybe BusinessReportS3Location
s3Location = Maybe BusinessReportS3Location
forall a. Maybe a
Prelude.Nothing
    }

-- | The status of the report generation execution (RUNNING, SUCCEEDED, or
-- FAILED).
businessReport_status :: Lens.Lens' BusinessReport (Prelude.Maybe BusinessReportStatus)
businessReport_status :: (Maybe BusinessReportStatus -> f (Maybe BusinessReportStatus))
-> BusinessReport -> f BusinessReport
businessReport_status = (BusinessReport -> Maybe BusinessReportStatus)
-> (BusinessReport -> Maybe BusinessReportStatus -> BusinessReport)
-> Lens
     BusinessReport
     BusinessReport
     (Maybe BusinessReportStatus)
     (Maybe BusinessReportStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BusinessReport' {Maybe BusinessReportStatus
status :: Maybe BusinessReportStatus
$sel:status:BusinessReport' :: BusinessReport -> Maybe BusinessReportStatus
status} -> Maybe BusinessReportStatus
status) (\s :: BusinessReport
s@BusinessReport' {} Maybe BusinessReportStatus
a -> BusinessReport
s {$sel:status:BusinessReport' :: Maybe BusinessReportStatus
status = Maybe BusinessReportStatus
a} :: BusinessReport)

-- | The failure code.
businessReport_failureCode :: Lens.Lens' BusinessReport (Prelude.Maybe BusinessReportFailureCode)
businessReport_failureCode :: (Maybe BusinessReportFailureCode
 -> f (Maybe BusinessReportFailureCode))
-> BusinessReport -> f BusinessReport
businessReport_failureCode = (BusinessReport -> Maybe BusinessReportFailureCode)
-> (BusinessReport
    -> Maybe BusinessReportFailureCode -> BusinessReport)
-> Lens
     BusinessReport
     BusinessReport
     (Maybe BusinessReportFailureCode)
     (Maybe BusinessReportFailureCode)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BusinessReport' {Maybe BusinessReportFailureCode
failureCode :: Maybe BusinessReportFailureCode
$sel:failureCode:BusinessReport' :: BusinessReport -> Maybe BusinessReportFailureCode
failureCode} -> Maybe BusinessReportFailureCode
failureCode) (\s :: BusinessReport
s@BusinessReport' {} Maybe BusinessReportFailureCode
a -> BusinessReport
s {$sel:failureCode:BusinessReport' :: Maybe BusinessReportFailureCode
failureCode = Maybe BusinessReportFailureCode
a} :: BusinessReport)

-- | The time of report delivery.
businessReport_deliveryTime :: Lens.Lens' BusinessReport (Prelude.Maybe Prelude.UTCTime)
businessReport_deliveryTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> BusinessReport -> f BusinessReport
businessReport_deliveryTime = (BusinessReport -> Maybe POSIX)
-> (BusinessReport -> Maybe POSIX -> BusinessReport)
-> Lens BusinessReport BusinessReport (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BusinessReport' {Maybe POSIX
deliveryTime :: Maybe POSIX
$sel:deliveryTime:BusinessReport' :: BusinessReport -> Maybe POSIX
deliveryTime} -> Maybe POSIX
deliveryTime) (\s :: BusinessReport
s@BusinessReport' {} Maybe POSIX
a -> BusinessReport
s {$sel:deliveryTime:BusinessReport' :: Maybe POSIX
deliveryTime = Maybe POSIX
a} :: BusinessReport) ((Maybe POSIX -> f (Maybe POSIX))
 -> BusinessReport -> f BusinessReport)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> BusinessReport
-> f BusinessReport
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 download link where a user can download the report.
businessReport_downloadUrl :: Lens.Lens' BusinessReport (Prelude.Maybe Prelude.Text)
businessReport_downloadUrl :: (Maybe Text -> f (Maybe Text))
-> BusinessReport -> f BusinessReport
businessReport_downloadUrl = (BusinessReport -> Maybe Text)
-> (BusinessReport -> Maybe Text -> BusinessReport)
-> Lens BusinessReport BusinessReport (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BusinessReport' {Maybe Text
downloadUrl :: Maybe Text
$sel:downloadUrl:BusinessReport' :: BusinessReport -> Maybe Text
downloadUrl} -> Maybe Text
downloadUrl) (\s :: BusinessReport
s@BusinessReport' {} Maybe Text
a -> BusinessReport
s {$sel:downloadUrl:BusinessReport' :: Maybe Text
downloadUrl = Maybe Text
a} :: BusinessReport)

-- | The S3 location of the output reports.
businessReport_s3Location :: Lens.Lens' BusinessReport (Prelude.Maybe BusinessReportS3Location)
businessReport_s3Location :: (Maybe BusinessReportS3Location
 -> f (Maybe BusinessReportS3Location))
-> BusinessReport -> f BusinessReport
businessReport_s3Location = (BusinessReport -> Maybe BusinessReportS3Location)
-> (BusinessReport
    -> Maybe BusinessReportS3Location -> BusinessReport)
-> Lens
     BusinessReport
     BusinessReport
     (Maybe BusinessReportS3Location)
     (Maybe BusinessReportS3Location)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BusinessReport' {Maybe BusinessReportS3Location
s3Location :: Maybe BusinessReportS3Location
$sel:s3Location:BusinessReport' :: BusinessReport -> Maybe BusinessReportS3Location
s3Location} -> Maybe BusinessReportS3Location
s3Location) (\s :: BusinessReport
s@BusinessReport' {} Maybe BusinessReportS3Location
a -> BusinessReport
s {$sel:s3Location:BusinessReport' :: Maybe BusinessReportS3Location
s3Location = Maybe BusinessReportS3Location
a} :: BusinessReport)

instance Core.FromJSON BusinessReport where
  parseJSON :: Value -> Parser BusinessReport
parseJSON =
    String
-> (Object -> Parser BusinessReport)
-> Value
-> Parser BusinessReport
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"BusinessReport"
      ( \Object
x ->
          Maybe BusinessReportStatus
-> Maybe BusinessReportFailureCode
-> Maybe POSIX
-> Maybe Text
-> Maybe BusinessReportS3Location
-> BusinessReport
BusinessReport'
            (Maybe BusinessReportStatus
 -> Maybe BusinessReportFailureCode
 -> Maybe POSIX
 -> Maybe Text
 -> Maybe BusinessReportS3Location
 -> BusinessReport)
-> Parser (Maybe BusinessReportStatus)
-> Parser
     (Maybe BusinessReportFailureCode
      -> Maybe POSIX
      -> Maybe Text
      -> Maybe BusinessReportS3Location
      -> BusinessReport)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe BusinessReportStatus)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Status")
            Parser
  (Maybe BusinessReportFailureCode
   -> Maybe POSIX
   -> Maybe Text
   -> Maybe BusinessReportS3Location
   -> BusinessReport)
-> Parser (Maybe BusinessReportFailureCode)
-> Parser
     (Maybe POSIX
      -> Maybe Text -> Maybe BusinessReportS3Location -> BusinessReport)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe BusinessReportFailureCode)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"FailureCode")
            Parser
  (Maybe POSIX
   -> Maybe Text -> Maybe BusinessReportS3Location -> BusinessReport)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe Text -> Maybe BusinessReportS3Location -> BusinessReport)
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
"DeliveryTime")
            Parser
  (Maybe Text -> Maybe BusinessReportS3Location -> BusinessReport)
-> Parser (Maybe Text)
-> Parser (Maybe BusinessReportS3Location -> BusinessReport)
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
"DownloadUrl")
            Parser (Maybe BusinessReportS3Location -> BusinessReport)
-> Parser (Maybe BusinessReportS3Location) -> Parser BusinessReport
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe BusinessReportS3Location)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"S3Location")
      )

instance Prelude.Hashable BusinessReport

instance Prelude.NFData BusinessReport