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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 :: Core.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 :: Core.ISO8601
  }
  deriving (Range -> Range -> Bool
(Range -> Range -> Bool) -> (Range -> Range -> Bool) -> Eq Range
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]
(Int -> ReadS Range)
-> ReadS [Range]
-> ReadPrec Range
-> ReadPrec [Range]
-> Read 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
(Int -> Range -> ShowS)
-> (Range -> String) -> ([Range] -> ShowS) -> Show Range
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. Range -> Rep Range x)
-> (forall x. Rep Range x -> Range) -> Generic Range
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' :: ISO8601 -> ISO8601 -> Range
Range'
    { $sel:startTime:Range' :: ISO8601
startTime = Tagged UTCTime (Identity UTCTime)
-> Tagged ISO8601 (Identity ISO8601)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged ISO8601 (Identity ISO8601))
-> UTCTime -> ISO8601
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pStartTime_,
      $sel:endTime:Range' :: ISO8601
endTime = Tagged UTCTime (Identity UTCTime)
-> Tagged ISO8601 (Identity ISO8601)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged ISO8601 (Identity ISO8601))
-> UTCTime -> ISO8601
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 :: (UTCTime -> f UTCTime) -> Range -> f Range
range_startTime = (Range -> ISO8601)
-> (Range -> ISO8601 -> Range) -> Lens Range Range ISO8601 ISO8601
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) ((ISO8601 -> f ISO8601) -> Range -> f Range)
-> ((UTCTime -> f UTCTime) -> ISO8601 -> f ISO8601)
-> (UTCTime -> f UTCTime)
-> Range
-> f Range
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> ISO8601 -> f ISO8601
forall (a :: Format). Iso' (Time a) UTCTime
Core._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 :: (UTCTime -> f UTCTime) -> Range -> f Range
range_endTime = (Range -> ISO8601)
-> (Range -> ISO8601 -> Range) -> Lens Range Range ISO8601 ISO8601
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) ((ISO8601 -> f ISO8601) -> Range -> f Range)
-> ((UTCTime -> f UTCTime) -> ISO8601 -> f ISO8601)
-> (UTCTime -> f UTCTime)
-> Range
-> f Range
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> ISO8601 -> f ISO8601
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

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

instance Prelude.Hashable Range

instance Prelude.NFData Range

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