{-# 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.EC2.Types.InstanceEventWindow
-- 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.EC2.Types.InstanceEventWindow where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.EC2.Internal
import Amazonka.EC2.Types.InstanceEventWindowAssociationTarget
import Amazonka.EC2.Types.InstanceEventWindowState
import Amazonka.EC2.Types.InstanceEventWindowTimeRange
import Amazonka.EC2.Types.Tag
import qualified Amazonka.Prelude as Prelude

-- | The event window.
--
-- /See:/ 'newInstanceEventWindow' smart constructor.
data InstanceEventWindow = InstanceEventWindow'
  { -- | One or more targets associated with the event window.
    InstanceEventWindow -> Maybe InstanceEventWindowAssociationTarget
associationTarget :: Prelude.Maybe InstanceEventWindowAssociationTarget,
    -- | The cron expression defined for the event window.
    InstanceEventWindow -> Maybe Text
cronExpression :: Prelude.Maybe Prelude.Text,
    -- | The ID of the event window.
    InstanceEventWindow -> Maybe Text
instanceEventWindowId :: Prelude.Maybe Prelude.Text,
    -- | The name of the event window.
    InstanceEventWindow -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The current state of the event window.
    InstanceEventWindow -> Maybe InstanceEventWindowState
state :: Prelude.Maybe InstanceEventWindowState,
    -- | The instance tags associated with the event window.
    InstanceEventWindow -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
    -- | One or more time ranges defined for the event window.
    InstanceEventWindow -> Maybe [InstanceEventWindowTimeRange]
timeRanges :: Prelude.Maybe [InstanceEventWindowTimeRange]
  }
  deriving (InstanceEventWindow -> InstanceEventWindow -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InstanceEventWindow -> InstanceEventWindow -> Bool
$c/= :: InstanceEventWindow -> InstanceEventWindow -> Bool
== :: InstanceEventWindow -> InstanceEventWindow -> Bool
$c== :: InstanceEventWindow -> InstanceEventWindow -> Bool
Prelude.Eq, ReadPrec [InstanceEventWindow]
ReadPrec InstanceEventWindow
Int -> ReadS InstanceEventWindow
ReadS [InstanceEventWindow]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InstanceEventWindow]
$creadListPrec :: ReadPrec [InstanceEventWindow]
readPrec :: ReadPrec InstanceEventWindow
$creadPrec :: ReadPrec InstanceEventWindow
readList :: ReadS [InstanceEventWindow]
$creadList :: ReadS [InstanceEventWindow]
readsPrec :: Int -> ReadS InstanceEventWindow
$creadsPrec :: Int -> ReadS InstanceEventWindow
Prelude.Read, Int -> InstanceEventWindow -> ShowS
[InstanceEventWindow] -> ShowS
InstanceEventWindow -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InstanceEventWindow] -> ShowS
$cshowList :: [InstanceEventWindow] -> ShowS
show :: InstanceEventWindow -> String
$cshow :: InstanceEventWindow -> String
showsPrec :: Int -> InstanceEventWindow -> ShowS
$cshowsPrec :: Int -> InstanceEventWindow -> ShowS
Prelude.Show, forall x. Rep InstanceEventWindow x -> InstanceEventWindow
forall x. InstanceEventWindow -> Rep InstanceEventWindow x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InstanceEventWindow x -> InstanceEventWindow
$cfrom :: forall x. InstanceEventWindow -> Rep InstanceEventWindow x
Prelude.Generic)

-- |
-- Create a value of 'InstanceEventWindow' 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:
--
-- 'associationTarget', 'instanceEventWindow_associationTarget' - One or more targets associated with the event window.
--
-- 'cronExpression', 'instanceEventWindow_cronExpression' - The cron expression defined for the event window.
--
-- 'instanceEventWindowId', 'instanceEventWindow_instanceEventWindowId' - The ID of the event window.
--
-- 'name', 'instanceEventWindow_name' - The name of the event window.
--
-- 'state', 'instanceEventWindow_state' - The current state of the event window.
--
-- 'tags', 'instanceEventWindow_tags' - The instance tags associated with the event window.
--
-- 'timeRanges', 'instanceEventWindow_timeRanges' - One or more time ranges defined for the event window.
newInstanceEventWindow ::
  InstanceEventWindow
newInstanceEventWindow :: InstanceEventWindow
newInstanceEventWindow =
  InstanceEventWindow'
    { $sel:associationTarget:InstanceEventWindow' :: Maybe InstanceEventWindowAssociationTarget
associationTarget =
        forall a. Maybe a
Prelude.Nothing,
      $sel:cronExpression:InstanceEventWindow' :: Maybe Text
cronExpression = forall a. Maybe a
Prelude.Nothing,
      $sel:instanceEventWindowId:InstanceEventWindow' :: Maybe Text
instanceEventWindowId = forall a. Maybe a
Prelude.Nothing,
      $sel:name:InstanceEventWindow' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:state:InstanceEventWindow' :: Maybe InstanceEventWindowState
state = forall a. Maybe a
Prelude.Nothing,
      $sel:tags:InstanceEventWindow' :: Maybe [Tag]
tags = forall a. Maybe a
Prelude.Nothing,
      $sel:timeRanges:InstanceEventWindow' :: Maybe [InstanceEventWindowTimeRange]
timeRanges = forall a. Maybe a
Prelude.Nothing
    }

-- | One or more targets associated with the event window.
instanceEventWindow_associationTarget :: Lens.Lens' InstanceEventWindow (Prelude.Maybe InstanceEventWindowAssociationTarget)
instanceEventWindow_associationTarget :: Lens'
  InstanceEventWindow (Maybe InstanceEventWindowAssociationTarget)
instanceEventWindow_associationTarget = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceEventWindow' {Maybe InstanceEventWindowAssociationTarget
associationTarget :: Maybe InstanceEventWindowAssociationTarget
$sel:associationTarget:InstanceEventWindow' :: InstanceEventWindow -> Maybe InstanceEventWindowAssociationTarget
associationTarget} -> Maybe InstanceEventWindowAssociationTarget
associationTarget) (\s :: InstanceEventWindow
s@InstanceEventWindow' {} Maybe InstanceEventWindowAssociationTarget
a -> InstanceEventWindow
s {$sel:associationTarget:InstanceEventWindow' :: Maybe InstanceEventWindowAssociationTarget
associationTarget = Maybe InstanceEventWindowAssociationTarget
a} :: InstanceEventWindow)

-- | The cron expression defined for the event window.
instanceEventWindow_cronExpression :: Lens.Lens' InstanceEventWindow (Prelude.Maybe Prelude.Text)
instanceEventWindow_cronExpression :: Lens' InstanceEventWindow (Maybe Text)
instanceEventWindow_cronExpression = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceEventWindow' {Maybe Text
cronExpression :: Maybe Text
$sel:cronExpression:InstanceEventWindow' :: InstanceEventWindow -> Maybe Text
cronExpression} -> Maybe Text
cronExpression) (\s :: InstanceEventWindow
s@InstanceEventWindow' {} Maybe Text
a -> InstanceEventWindow
s {$sel:cronExpression:InstanceEventWindow' :: Maybe Text
cronExpression = Maybe Text
a} :: InstanceEventWindow)

-- | The ID of the event window.
instanceEventWindow_instanceEventWindowId :: Lens.Lens' InstanceEventWindow (Prelude.Maybe Prelude.Text)
instanceEventWindow_instanceEventWindowId :: Lens' InstanceEventWindow (Maybe Text)
instanceEventWindow_instanceEventWindowId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceEventWindow' {Maybe Text
instanceEventWindowId :: Maybe Text
$sel:instanceEventWindowId:InstanceEventWindow' :: InstanceEventWindow -> Maybe Text
instanceEventWindowId} -> Maybe Text
instanceEventWindowId) (\s :: InstanceEventWindow
s@InstanceEventWindow' {} Maybe Text
a -> InstanceEventWindow
s {$sel:instanceEventWindowId:InstanceEventWindow' :: Maybe Text
instanceEventWindowId = Maybe Text
a} :: InstanceEventWindow)

-- | The name of the event window.
instanceEventWindow_name :: Lens.Lens' InstanceEventWindow (Prelude.Maybe Prelude.Text)
instanceEventWindow_name :: Lens' InstanceEventWindow (Maybe Text)
instanceEventWindow_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceEventWindow' {Maybe Text
name :: Maybe Text
$sel:name:InstanceEventWindow' :: InstanceEventWindow -> Maybe Text
name} -> Maybe Text
name) (\s :: InstanceEventWindow
s@InstanceEventWindow' {} Maybe Text
a -> InstanceEventWindow
s {$sel:name:InstanceEventWindow' :: Maybe Text
name = Maybe Text
a} :: InstanceEventWindow)

-- | The current state of the event window.
instanceEventWindow_state :: Lens.Lens' InstanceEventWindow (Prelude.Maybe InstanceEventWindowState)
instanceEventWindow_state :: Lens' InstanceEventWindow (Maybe InstanceEventWindowState)
instanceEventWindow_state = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceEventWindow' {Maybe InstanceEventWindowState
state :: Maybe InstanceEventWindowState
$sel:state:InstanceEventWindow' :: InstanceEventWindow -> Maybe InstanceEventWindowState
state} -> Maybe InstanceEventWindowState
state) (\s :: InstanceEventWindow
s@InstanceEventWindow' {} Maybe InstanceEventWindowState
a -> InstanceEventWindow
s {$sel:state:InstanceEventWindow' :: Maybe InstanceEventWindowState
state = Maybe InstanceEventWindowState
a} :: InstanceEventWindow)

-- | The instance tags associated with the event window.
instanceEventWindow_tags :: Lens.Lens' InstanceEventWindow (Prelude.Maybe [Tag])
instanceEventWindow_tags :: Lens' InstanceEventWindow (Maybe [Tag])
instanceEventWindow_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceEventWindow' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:InstanceEventWindow' :: InstanceEventWindow -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: InstanceEventWindow
s@InstanceEventWindow' {} Maybe [Tag]
a -> InstanceEventWindow
s {$sel:tags:InstanceEventWindow' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: InstanceEventWindow) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | One or more time ranges defined for the event window.
instanceEventWindow_timeRanges :: Lens.Lens' InstanceEventWindow (Prelude.Maybe [InstanceEventWindowTimeRange])
instanceEventWindow_timeRanges :: Lens' InstanceEventWindow (Maybe [InstanceEventWindowTimeRange])
instanceEventWindow_timeRanges = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceEventWindow' {Maybe [InstanceEventWindowTimeRange]
timeRanges :: Maybe [InstanceEventWindowTimeRange]
$sel:timeRanges:InstanceEventWindow' :: InstanceEventWindow -> Maybe [InstanceEventWindowTimeRange]
timeRanges} -> Maybe [InstanceEventWindowTimeRange]
timeRanges) (\s :: InstanceEventWindow
s@InstanceEventWindow' {} Maybe [InstanceEventWindowTimeRange]
a -> InstanceEventWindow
s {$sel:timeRanges:InstanceEventWindow' :: Maybe [InstanceEventWindowTimeRange]
timeRanges = Maybe [InstanceEventWindowTimeRange]
a} :: InstanceEventWindow) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromXML InstanceEventWindow where
  parseXML :: [Node] -> Either String InstanceEventWindow
parseXML [Node]
x =
    Maybe InstanceEventWindowAssociationTarget
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe InstanceEventWindowState
-> Maybe [Tag]
-> Maybe [InstanceEventWindowTimeRange]
-> InstanceEventWindow
InstanceEventWindow'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"associationTarget")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"cronExpression")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"instanceEventWindowId")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"name")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"state")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x
                      forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"tagSet"
                      forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                      forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (forall a. FromXML a => Text -> [Node] -> Either String [a]
Data.parseXMLList Text
"item")
                  )
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x
                      forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"timeRangeSet"
                      forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                      forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (forall a. FromXML a => Text -> [Node] -> Either String [a]
Data.parseXMLList Text
"item")
                  )

instance Prelude.Hashable InstanceEventWindow where
  hashWithSalt :: Int -> InstanceEventWindow -> Int
hashWithSalt Int
_salt InstanceEventWindow' {Maybe [Tag]
Maybe [InstanceEventWindowTimeRange]
Maybe Text
Maybe InstanceEventWindowState
Maybe InstanceEventWindowAssociationTarget
timeRanges :: Maybe [InstanceEventWindowTimeRange]
tags :: Maybe [Tag]
state :: Maybe InstanceEventWindowState
name :: Maybe Text
instanceEventWindowId :: Maybe Text
cronExpression :: Maybe Text
associationTarget :: Maybe InstanceEventWindowAssociationTarget
$sel:timeRanges:InstanceEventWindow' :: InstanceEventWindow -> Maybe [InstanceEventWindowTimeRange]
$sel:tags:InstanceEventWindow' :: InstanceEventWindow -> Maybe [Tag]
$sel:state:InstanceEventWindow' :: InstanceEventWindow -> Maybe InstanceEventWindowState
$sel:name:InstanceEventWindow' :: InstanceEventWindow -> Maybe Text
$sel:instanceEventWindowId:InstanceEventWindow' :: InstanceEventWindow -> Maybe Text
$sel:cronExpression:InstanceEventWindow' :: InstanceEventWindow -> Maybe Text
$sel:associationTarget:InstanceEventWindow' :: InstanceEventWindow -> Maybe InstanceEventWindowAssociationTarget
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe InstanceEventWindowAssociationTarget
associationTarget
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
cronExpression
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
instanceEventWindowId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe InstanceEventWindowState
state
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Tag]
tags
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [InstanceEventWindowTimeRange]
timeRanges

instance Prelude.NFData InstanceEventWindow where
  rnf :: InstanceEventWindow -> ()
rnf InstanceEventWindow' {Maybe [Tag]
Maybe [InstanceEventWindowTimeRange]
Maybe Text
Maybe InstanceEventWindowState
Maybe InstanceEventWindowAssociationTarget
timeRanges :: Maybe [InstanceEventWindowTimeRange]
tags :: Maybe [Tag]
state :: Maybe InstanceEventWindowState
name :: Maybe Text
instanceEventWindowId :: Maybe Text
cronExpression :: Maybe Text
associationTarget :: Maybe InstanceEventWindowAssociationTarget
$sel:timeRanges:InstanceEventWindow' :: InstanceEventWindow -> Maybe [InstanceEventWindowTimeRange]
$sel:tags:InstanceEventWindow' :: InstanceEventWindow -> Maybe [Tag]
$sel:state:InstanceEventWindow' :: InstanceEventWindow -> Maybe InstanceEventWindowState
$sel:name:InstanceEventWindow' :: InstanceEventWindow -> Maybe Text
$sel:instanceEventWindowId:InstanceEventWindow' :: InstanceEventWindow -> Maybe Text
$sel:cronExpression:InstanceEventWindow' :: InstanceEventWindow -> Maybe Text
$sel:associationTarget:InstanceEventWindow' :: InstanceEventWindow -> Maybe InstanceEventWindowAssociationTarget
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe InstanceEventWindowAssociationTarget
associationTarget
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
cronExpression
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
instanceEventWindowId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe InstanceEventWindowState
state
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Tag]
tags
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [InstanceEventWindowTimeRange]
timeRanges