{-# 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.CloudWatch.Types.Range
-- 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.CloudWatch.Types.Range 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

-- | Specifies one range of days or times to exclude from use for training an
-- anomaly detection model.
--
-- /See:/ 'newRange' smart constructor.
data Range = Range'
  { -- | The start time of the range to exclude. The format is
    -- @yyyy-MM-dd\'T\'HH:mm:ss@. For example, @2019-07-01T23:59:59@.
    Range -> ISO8601
startTime :: Data.ISO8601,
    -- | The end time of the range to exclude. The format is
    -- @yyyy-MM-dd\'T\'HH:mm:ss@. For example, @2019-07-01T23:59:59@.
    Range -> ISO8601
endTime :: Data.ISO8601
  }
  deriving (Range -> Range -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Range -> Range -> Bool
$c/= :: Range -> Range -> Bool
== :: Range -> Range -> Bool
$c== :: Range -> Range -> Bool
Prelude.Eq, ReadPrec [Range]
ReadPrec Range
Int -> ReadS Range
ReadS [Range]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Range]
$creadListPrec :: ReadPrec [Range]
readPrec :: ReadPrec Range
$creadPrec :: ReadPrec Range
readList :: ReadS [Range]
$creadList :: ReadS [Range]
readsPrec :: Int -> ReadS Range
$creadsPrec :: Int -> ReadS Range
Prelude.Read, Int -> Range -> ShowS
[Range] -> ShowS
Range -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Range] -> ShowS
$cshowList :: [Range] -> ShowS
show :: Range -> String
$cshow :: Range -> String
showsPrec :: Int -> Range -> ShowS
$cshowsPrec :: Int -> Range -> ShowS
Prelude.Show, forall x. Rep Range x -> Range
forall x. Range -> Rep Range x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Range x -> Range
$cfrom :: forall x. Range -> Rep Range x
Prelude.Generic)

-- |
-- Create a value of 'Range' 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:
--
-- 'startTime', 'range_startTime' - The start time of the range to exclude. The format is
-- @yyyy-MM-dd\'T\'HH:mm:ss@. For example, @2019-07-01T23:59:59@.
--
-- 'endTime', 'range_endTime' - The end time of the range to exclude. The format is
-- @yyyy-MM-dd\'T\'HH:mm:ss@. For example, @2019-07-01T23:59:59@.
newRange ::
  -- | 'startTime'
  Prelude.UTCTime ->
  -- | 'endTime'
  Prelude.UTCTime ->
  Range
newRange :: UTCTime -> UTCTime -> Range
newRange UTCTime
pStartTime_ UTCTime
pEndTime_ =
  Range'
    { $sel:startTime:Range' :: ISO8601
startTime = forall (a :: Format). Iso' (Time a) UTCTime
Data._Time forall t b. AReview t b -> b -> t
Lens.# UTCTime
pStartTime_,
      $sel:endTime:Range' :: ISO8601
endTime = forall (a :: Format). Iso' (Time a) UTCTime
Data._Time forall t b. AReview t b -> b -> t
Lens.# UTCTime
pEndTime_
    }

-- | The start time of the range to exclude. The format is
-- @yyyy-MM-dd\'T\'HH:mm:ss@. For example, @2019-07-01T23:59:59@.
range_startTime :: Lens.Lens' Range Prelude.UTCTime
range_startTime :: Lens' Range UTCTime
range_startTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Range' {ISO8601
startTime :: ISO8601
$sel:startTime:Range' :: Range -> ISO8601
startTime} -> ISO8601
startTime) (\s :: Range
s@Range' {} ISO8601
a -> Range
s {$sel:startTime:Range' :: ISO8601
startTime = ISO8601
a} :: Range) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The end time of the range to exclude. The format is
-- @yyyy-MM-dd\'T\'HH:mm:ss@. For example, @2019-07-01T23:59:59@.
range_endTime :: Lens.Lens' Range Prelude.UTCTime
range_endTime :: Lens' Range UTCTime
range_endTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Range' {ISO8601
endTime :: ISO8601
$sel:endTime:Range' :: Range -> ISO8601
endTime} -> ISO8601
endTime) (\s :: Range
s@Range' {} ISO8601
a -> Range
s {$sel:endTime:Range' :: ISO8601
endTime = ISO8601
a} :: Range) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

instance Data.FromXML Range where
  parseXML :: [Node] -> Either String Range
parseXML [Node]
x =
    ISO8601 -> ISO8601 -> Range
Range'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"StartTime")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"EndTime")

instance Prelude.Hashable Range where
  hashWithSalt :: Int -> Range -> Int
hashWithSalt Int
_salt Range' {ISO8601
endTime :: ISO8601
startTime :: ISO8601
$sel:endTime:Range' :: Range -> ISO8601
$sel:startTime:Range' :: Range -> ISO8601
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ISO8601
startTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ISO8601
endTime

instance Prelude.NFData Range where
  rnf :: Range -> ()
rnf Range' {ISO8601
endTime :: ISO8601
startTime :: ISO8601
$sel:endTime:Range' :: Range -> ISO8601
$sel:startTime:Range' :: Range -> ISO8601
..} =
    forall a. NFData a => a -> ()
Prelude.rnf ISO8601
startTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ISO8601
endTime

instance Data.ToQuery Range where
  toQuery :: Range -> QueryString
toQuery Range' {ISO8601
endTime :: ISO8601
startTime :: ISO8601
$sel:endTime:Range' :: Range -> ISO8601
$sel:startTime:Range' :: Range -> ISO8601
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"StartTime" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: ISO8601
startTime,
        ByteString
"EndTime" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: ISO8601
endTime
      ]