{-# 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.DLM.Types.PolicyDetails
-- 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.DLM.Types.PolicyDetails where

import qualified Amazonka.Core as Core
import Amazonka.DLM.Types.Action
import Amazonka.DLM.Types.EventSource
import Amazonka.DLM.Types.Parameters
import Amazonka.DLM.Types.PolicyTypeValues
import Amazonka.DLM.Types.ResourceLocationValues
import Amazonka.DLM.Types.ResourceTypeValues
import Amazonka.DLM.Types.Schedule
import Amazonka.DLM.Types.Tag
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Specifies the configuration of a lifecycle policy.
--
-- /See:/ 'newPolicyDetails' smart constructor.
data PolicyDetails = PolicyDetails'
  { -- | The actions to be performed when the event-based policy is triggered.
    -- You can specify only one action per policy.
    --
    -- This parameter is required for event-based policies only. If you are
    -- creating a snapshot or AMI policy, omit this parameter.
    PolicyDetails -> Maybe (NonEmpty Action)
actions :: Prelude.Maybe (Prelude.NonEmpty Action),
    -- | The single tag that identifies targeted resources for this policy.
    --
    -- This parameter is required for snapshot and AMI policies only. If you
    -- are creating an event-based policy, omit this parameter.
    PolicyDetails -> Maybe (NonEmpty Tag)
targetTags :: Prelude.Maybe (Prelude.NonEmpty Tag),
    -- | The valid target resource types and actions a policy can manage. Specify
    -- @EBS_SNAPSHOT_MANAGEMENT@ to create a lifecycle policy that manages the
    -- lifecycle of Amazon EBS snapshots. Specify @IMAGE_MANAGEMENT@ to create
    -- a lifecycle policy that manages the lifecycle of EBS-backed AMIs.
    -- Specify @EVENT_BASED_POLICY @ to create an event-based policy that
    -- performs specific actions when a defined event occurs in your Amazon Web
    -- Services account.
    --
    -- The default is @EBS_SNAPSHOT_MANAGEMENT@.
    PolicyDetails -> Maybe PolicyTypeValues
policyType :: Prelude.Maybe PolicyTypeValues,
    -- | The location of the resources to backup. If the source resources are
    -- located in an Amazon Web Services Region, specify @CLOUD@. If the source
    -- resources are located on an Outpost in your account, specify @OUTPOST@.
    --
    -- If you specify @OUTPOST@, Amazon Data Lifecycle Manager backs up all
    -- resources of the specified type with matching target tags across all of
    -- the Outposts in your account.
    PolicyDetails -> Maybe (NonEmpty ResourceLocationValues)
resourceLocations :: Prelude.Maybe (Prelude.NonEmpty ResourceLocationValues),
    -- | A set of optional parameters for snapshot and AMI lifecycle policies.
    --
    -- This parameter is required for snapshot and AMI policies only. If you
    -- are creating an event-based policy, omit this parameter.
    PolicyDetails -> Maybe Parameters
parameters :: Prelude.Maybe Parameters,
    -- | The schedules of policy-defined actions for snapshot and AMI lifecycle
    -- policies. A policy can have up to four schedules—one mandatory schedule
    -- and up to three optional schedules.
    --
    -- This parameter is required for snapshot and AMI policies only. If you
    -- are creating an event-based policy, omit this parameter.
    PolicyDetails -> Maybe (NonEmpty Schedule)
schedules :: Prelude.Maybe (Prelude.NonEmpty Schedule),
    -- | The event that triggers the event-based policy.
    --
    -- This parameter is required for event-based policies only. If you are
    -- creating a snapshot or AMI policy, omit this parameter.
    PolicyDetails -> Maybe EventSource
eventSource :: Prelude.Maybe EventSource,
    -- | The target resource type for snapshot and AMI lifecycle policies. Use
    -- @VOLUME @to create snapshots of individual volumes or use @INSTANCE@ to
    -- create multi-volume snapshots from the volumes for an instance.
    --
    -- This parameter is required for snapshot and AMI policies only. If you
    -- are creating an event-based policy, omit this parameter.
    PolicyDetails -> Maybe (NonEmpty ResourceTypeValues)
resourceTypes :: Prelude.Maybe (Prelude.NonEmpty ResourceTypeValues)
  }
  deriving (PolicyDetails -> PolicyDetails -> Bool
(PolicyDetails -> PolicyDetails -> Bool)
-> (PolicyDetails -> PolicyDetails -> Bool) -> Eq PolicyDetails
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PolicyDetails -> PolicyDetails -> Bool
$c/= :: PolicyDetails -> PolicyDetails -> Bool
== :: PolicyDetails -> PolicyDetails -> Bool
$c== :: PolicyDetails -> PolicyDetails -> Bool
Prelude.Eq, ReadPrec [PolicyDetails]
ReadPrec PolicyDetails
Int -> ReadS PolicyDetails
ReadS [PolicyDetails]
(Int -> ReadS PolicyDetails)
-> ReadS [PolicyDetails]
-> ReadPrec PolicyDetails
-> ReadPrec [PolicyDetails]
-> Read PolicyDetails
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PolicyDetails]
$creadListPrec :: ReadPrec [PolicyDetails]
readPrec :: ReadPrec PolicyDetails
$creadPrec :: ReadPrec PolicyDetails
readList :: ReadS [PolicyDetails]
$creadList :: ReadS [PolicyDetails]
readsPrec :: Int -> ReadS PolicyDetails
$creadsPrec :: Int -> ReadS PolicyDetails
Prelude.Read, Int -> PolicyDetails -> ShowS
[PolicyDetails] -> ShowS
PolicyDetails -> String
(Int -> PolicyDetails -> ShowS)
-> (PolicyDetails -> String)
-> ([PolicyDetails] -> ShowS)
-> Show PolicyDetails
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PolicyDetails] -> ShowS
$cshowList :: [PolicyDetails] -> ShowS
show :: PolicyDetails -> String
$cshow :: PolicyDetails -> String
showsPrec :: Int -> PolicyDetails -> ShowS
$cshowsPrec :: Int -> PolicyDetails -> ShowS
Prelude.Show, (forall x. PolicyDetails -> Rep PolicyDetails x)
-> (forall x. Rep PolicyDetails x -> PolicyDetails)
-> Generic PolicyDetails
forall x. Rep PolicyDetails x -> PolicyDetails
forall x. PolicyDetails -> Rep PolicyDetails x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PolicyDetails x -> PolicyDetails
$cfrom :: forall x. PolicyDetails -> Rep PolicyDetails x
Prelude.Generic)

-- |
-- Create a value of 'PolicyDetails' 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:
--
-- 'actions', 'policyDetails_actions' - The actions to be performed when the event-based policy is triggered.
-- You can specify only one action per policy.
--
-- This parameter is required for event-based policies only. If you are
-- creating a snapshot or AMI policy, omit this parameter.
--
-- 'targetTags', 'policyDetails_targetTags' - The single tag that identifies targeted resources for this policy.
--
-- This parameter is required for snapshot and AMI policies only. If you
-- are creating an event-based policy, omit this parameter.
--
-- 'policyType', 'policyDetails_policyType' - The valid target resource types and actions a policy can manage. Specify
-- @EBS_SNAPSHOT_MANAGEMENT@ to create a lifecycle policy that manages the
-- lifecycle of Amazon EBS snapshots. Specify @IMAGE_MANAGEMENT@ to create
-- a lifecycle policy that manages the lifecycle of EBS-backed AMIs.
-- Specify @EVENT_BASED_POLICY @ to create an event-based policy that
-- performs specific actions when a defined event occurs in your Amazon Web
-- Services account.
--
-- The default is @EBS_SNAPSHOT_MANAGEMENT@.
--
-- 'resourceLocations', 'policyDetails_resourceLocations' - The location of the resources to backup. If the source resources are
-- located in an Amazon Web Services Region, specify @CLOUD@. If the source
-- resources are located on an Outpost in your account, specify @OUTPOST@.
--
-- If you specify @OUTPOST@, Amazon Data Lifecycle Manager backs up all
-- resources of the specified type with matching target tags across all of
-- the Outposts in your account.
--
-- 'parameters', 'policyDetails_parameters' - A set of optional parameters for snapshot and AMI lifecycle policies.
--
-- This parameter is required for snapshot and AMI policies only. If you
-- are creating an event-based policy, omit this parameter.
--
-- 'schedules', 'policyDetails_schedules' - The schedules of policy-defined actions for snapshot and AMI lifecycle
-- policies. A policy can have up to four schedules—one mandatory schedule
-- and up to three optional schedules.
--
-- This parameter is required for snapshot and AMI policies only. If you
-- are creating an event-based policy, omit this parameter.
--
-- 'eventSource', 'policyDetails_eventSource' - The event that triggers the event-based policy.
--
-- This parameter is required for event-based policies only. If you are
-- creating a snapshot or AMI policy, omit this parameter.
--
-- 'resourceTypes', 'policyDetails_resourceTypes' - The target resource type for snapshot and AMI lifecycle policies. Use
-- @VOLUME @to create snapshots of individual volumes or use @INSTANCE@ to
-- create multi-volume snapshots from the volumes for an instance.
--
-- This parameter is required for snapshot and AMI policies only. If you
-- are creating an event-based policy, omit this parameter.
newPolicyDetails ::
  PolicyDetails
newPolicyDetails :: PolicyDetails
newPolicyDetails =
  PolicyDetails' :: Maybe (NonEmpty Action)
-> Maybe (NonEmpty Tag)
-> Maybe PolicyTypeValues
-> Maybe (NonEmpty ResourceLocationValues)
-> Maybe Parameters
-> Maybe (NonEmpty Schedule)
-> Maybe EventSource
-> Maybe (NonEmpty ResourceTypeValues)
-> PolicyDetails
PolicyDetails'
    { $sel:actions:PolicyDetails' :: Maybe (NonEmpty Action)
actions = Maybe (NonEmpty Action)
forall a. Maybe a
Prelude.Nothing,
      $sel:targetTags:PolicyDetails' :: Maybe (NonEmpty Tag)
targetTags = Maybe (NonEmpty Tag)
forall a. Maybe a
Prelude.Nothing,
      $sel:policyType:PolicyDetails' :: Maybe PolicyTypeValues
policyType = Maybe PolicyTypeValues
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceLocations:PolicyDetails' :: Maybe (NonEmpty ResourceLocationValues)
resourceLocations = Maybe (NonEmpty ResourceLocationValues)
forall a. Maybe a
Prelude.Nothing,
      $sel:parameters:PolicyDetails' :: Maybe Parameters
parameters = Maybe Parameters
forall a. Maybe a
Prelude.Nothing,
      $sel:schedules:PolicyDetails' :: Maybe (NonEmpty Schedule)
schedules = Maybe (NonEmpty Schedule)
forall a. Maybe a
Prelude.Nothing,
      $sel:eventSource:PolicyDetails' :: Maybe EventSource
eventSource = Maybe EventSource
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceTypes:PolicyDetails' :: Maybe (NonEmpty ResourceTypeValues)
resourceTypes = Maybe (NonEmpty ResourceTypeValues)
forall a. Maybe a
Prelude.Nothing
    }

-- | The actions to be performed when the event-based policy is triggered.
-- You can specify only one action per policy.
--
-- This parameter is required for event-based policies only. If you are
-- creating a snapshot or AMI policy, omit this parameter.
policyDetails_actions :: Lens.Lens' PolicyDetails (Prelude.Maybe (Prelude.NonEmpty Action))
policyDetails_actions :: (Maybe (NonEmpty Action) -> f (Maybe (NonEmpty Action)))
-> PolicyDetails -> f PolicyDetails
policyDetails_actions = (PolicyDetails -> Maybe (NonEmpty Action))
-> (PolicyDetails -> Maybe (NonEmpty Action) -> PolicyDetails)
-> Lens
     PolicyDetails
     PolicyDetails
     (Maybe (NonEmpty Action))
     (Maybe (NonEmpty Action))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PolicyDetails' {Maybe (NonEmpty Action)
actions :: Maybe (NonEmpty Action)
$sel:actions:PolicyDetails' :: PolicyDetails -> Maybe (NonEmpty Action)
actions} -> Maybe (NonEmpty Action)
actions) (\s :: PolicyDetails
s@PolicyDetails' {} Maybe (NonEmpty Action)
a -> PolicyDetails
s {$sel:actions:PolicyDetails' :: Maybe (NonEmpty Action)
actions = Maybe (NonEmpty Action)
a} :: PolicyDetails) ((Maybe (NonEmpty Action) -> f (Maybe (NonEmpty Action)))
 -> PolicyDetails -> f PolicyDetails)
-> ((Maybe (NonEmpty Action) -> f (Maybe (NonEmpty Action)))
    -> Maybe (NonEmpty Action) -> f (Maybe (NonEmpty Action)))
-> (Maybe (NonEmpty Action) -> f (Maybe (NonEmpty Action)))
-> PolicyDetails
-> f PolicyDetails
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty Action)
  (NonEmpty Action)
  (NonEmpty Action)
  (NonEmpty Action)
-> Iso
     (Maybe (NonEmpty Action))
     (Maybe (NonEmpty Action))
     (Maybe (NonEmpty Action))
     (Maybe (NonEmpty Action))
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
  (NonEmpty Action)
  (NonEmpty Action)
  (NonEmpty Action)
  (NonEmpty Action)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The single tag that identifies targeted resources for this policy.
--
-- This parameter is required for snapshot and AMI policies only. If you
-- are creating an event-based policy, omit this parameter.
policyDetails_targetTags :: Lens.Lens' PolicyDetails (Prelude.Maybe (Prelude.NonEmpty Tag))
policyDetails_targetTags :: (Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
-> PolicyDetails -> f PolicyDetails
policyDetails_targetTags = (PolicyDetails -> Maybe (NonEmpty Tag))
-> (PolicyDetails -> Maybe (NonEmpty Tag) -> PolicyDetails)
-> Lens
     PolicyDetails
     PolicyDetails
     (Maybe (NonEmpty Tag))
     (Maybe (NonEmpty Tag))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PolicyDetails' {Maybe (NonEmpty Tag)
targetTags :: Maybe (NonEmpty Tag)
$sel:targetTags:PolicyDetails' :: PolicyDetails -> Maybe (NonEmpty Tag)
targetTags} -> Maybe (NonEmpty Tag)
targetTags) (\s :: PolicyDetails
s@PolicyDetails' {} Maybe (NonEmpty Tag)
a -> PolicyDetails
s {$sel:targetTags:PolicyDetails' :: Maybe (NonEmpty Tag)
targetTags = Maybe (NonEmpty Tag)
a} :: PolicyDetails) ((Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
 -> PolicyDetails -> f PolicyDetails)
-> ((Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
    -> Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
-> (Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
-> PolicyDetails
-> f PolicyDetails
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (NonEmpty Tag) (NonEmpty Tag) (NonEmpty Tag) (NonEmpty Tag)
-> Iso
     (Maybe (NonEmpty Tag))
     (Maybe (NonEmpty Tag))
     (Maybe (NonEmpty Tag))
     (Maybe (NonEmpty Tag))
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 (NonEmpty Tag) (NonEmpty Tag) (NonEmpty Tag) (NonEmpty Tag)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The valid target resource types and actions a policy can manage. Specify
-- @EBS_SNAPSHOT_MANAGEMENT@ to create a lifecycle policy that manages the
-- lifecycle of Amazon EBS snapshots. Specify @IMAGE_MANAGEMENT@ to create
-- a lifecycle policy that manages the lifecycle of EBS-backed AMIs.
-- Specify @EVENT_BASED_POLICY @ to create an event-based policy that
-- performs specific actions when a defined event occurs in your Amazon Web
-- Services account.
--
-- The default is @EBS_SNAPSHOT_MANAGEMENT@.
policyDetails_policyType :: Lens.Lens' PolicyDetails (Prelude.Maybe PolicyTypeValues)
policyDetails_policyType :: (Maybe PolicyTypeValues -> f (Maybe PolicyTypeValues))
-> PolicyDetails -> f PolicyDetails
policyDetails_policyType = (PolicyDetails -> Maybe PolicyTypeValues)
-> (PolicyDetails -> Maybe PolicyTypeValues -> PolicyDetails)
-> Lens
     PolicyDetails
     PolicyDetails
     (Maybe PolicyTypeValues)
     (Maybe PolicyTypeValues)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PolicyDetails' {Maybe PolicyTypeValues
policyType :: Maybe PolicyTypeValues
$sel:policyType:PolicyDetails' :: PolicyDetails -> Maybe PolicyTypeValues
policyType} -> Maybe PolicyTypeValues
policyType) (\s :: PolicyDetails
s@PolicyDetails' {} Maybe PolicyTypeValues
a -> PolicyDetails
s {$sel:policyType:PolicyDetails' :: Maybe PolicyTypeValues
policyType = Maybe PolicyTypeValues
a} :: PolicyDetails)

-- | The location of the resources to backup. If the source resources are
-- located in an Amazon Web Services Region, specify @CLOUD@. If the source
-- resources are located on an Outpost in your account, specify @OUTPOST@.
--
-- If you specify @OUTPOST@, Amazon Data Lifecycle Manager backs up all
-- resources of the specified type with matching target tags across all of
-- the Outposts in your account.
policyDetails_resourceLocations :: Lens.Lens' PolicyDetails (Prelude.Maybe (Prelude.NonEmpty ResourceLocationValues))
policyDetails_resourceLocations :: (Maybe (NonEmpty ResourceLocationValues)
 -> f (Maybe (NonEmpty ResourceLocationValues)))
-> PolicyDetails -> f PolicyDetails
policyDetails_resourceLocations = (PolicyDetails -> Maybe (NonEmpty ResourceLocationValues))
-> (PolicyDetails
    -> Maybe (NonEmpty ResourceLocationValues) -> PolicyDetails)
-> Lens
     PolicyDetails
     PolicyDetails
     (Maybe (NonEmpty ResourceLocationValues))
     (Maybe (NonEmpty ResourceLocationValues))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PolicyDetails' {Maybe (NonEmpty ResourceLocationValues)
resourceLocations :: Maybe (NonEmpty ResourceLocationValues)
$sel:resourceLocations:PolicyDetails' :: PolicyDetails -> Maybe (NonEmpty ResourceLocationValues)
resourceLocations} -> Maybe (NonEmpty ResourceLocationValues)
resourceLocations) (\s :: PolicyDetails
s@PolicyDetails' {} Maybe (NonEmpty ResourceLocationValues)
a -> PolicyDetails
s {$sel:resourceLocations:PolicyDetails' :: Maybe (NonEmpty ResourceLocationValues)
resourceLocations = Maybe (NonEmpty ResourceLocationValues)
a} :: PolicyDetails) ((Maybe (NonEmpty ResourceLocationValues)
  -> f (Maybe (NonEmpty ResourceLocationValues)))
 -> PolicyDetails -> f PolicyDetails)
-> ((Maybe (NonEmpty ResourceLocationValues)
     -> f (Maybe (NonEmpty ResourceLocationValues)))
    -> Maybe (NonEmpty ResourceLocationValues)
    -> f (Maybe (NonEmpty ResourceLocationValues)))
-> (Maybe (NonEmpty ResourceLocationValues)
    -> f (Maybe (NonEmpty ResourceLocationValues)))
-> PolicyDetails
-> f PolicyDetails
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty ResourceLocationValues)
  (NonEmpty ResourceLocationValues)
  (NonEmpty ResourceLocationValues)
  (NonEmpty ResourceLocationValues)
-> Iso
     (Maybe (NonEmpty ResourceLocationValues))
     (Maybe (NonEmpty ResourceLocationValues))
     (Maybe (NonEmpty ResourceLocationValues))
     (Maybe (NonEmpty ResourceLocationValues))
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
  (NonEmpty ResourceLocationValues)
  (NonEmpty ResourceLocationValues)
  (NonEmpty ResourceLocationValues)
  (NonEmpty ResourceLocationValues)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A set of optional parameters for snapshot and AMI lifecycle policies.
--
-- This parameter is required for snapshot and AMI policies only. If you
-- are creating an event-based policy, omit this parameter.
policyDetails_parameters :: Lens.Lens' PolicyDetails (Prelude.Maybe Parameters)
policyDetails_parameters :: (Maybe Parameters -> f (Maybe Parameters))
-> PolicyDetails -> f PolicyDetails
policyDetails_parameters = (PolicyDetails -> Maybe Parameters)
-> (PolicyDetails -> Maybe Parameters -> PolicyDetails)
-> Lens
     PolicyDetails PolicyDetails (Maybe Parameters) (Maybe Parameters)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PolicyDetails' {Maybe Parameters
parameters :: Maybe Parameters
$sel:parameters:PolicyDetails' :: PolicyDetails -> Maybe Parameters
parameters} -> Maybe Parameters
parameters) (\s :: PolicyDetails
s@PolicyDetails' {} Maybe Parameters
a -> PolicyDetails
s {$sel:parameters:PolicyDetails' :: Maybe Parameters
parameters = Maybe Parameters
a} :: PolicyDetails)

-- | The schedules of policy-defined actions for snapshot and AMI lifecycle
-- policies. A policy can have up to four schedules—one mandatory schedule
-- and up to three optional schedules.
--
-- This parameter is required for snapshot and AMI policies only. If you
-- are creating an event-based policy, omit this parameter.
policyDetails_schedules :: Lens.Lens' PolicyDetails (Prelude.Maybe (Prelude.NonEmpty Schedule))
policyDetails_schedules :: (Maybe (NonEmpty Schedule) -> f (Maybe (NonEmpty Schedule)))
-> PolicyDetails -> f PolicyDetails
policyDetails_schedules = (PolicyDetails -> Maybe (NonEmpty Schedule))
-> (PolicyDetails -> Maybe (NonEmpty Schedule) -> PolicyDetails)
-> Lens
     PolicyDetails
     PolicyDetails
     (Maybe (NonEmpty Schedule))
     (Maybe (NonEmpty Schedule))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PolicyDetails' {Maybe (NonEmpty Schedule)
schedules :: Maybe (NonEmpty Schedule)
$sel:schedules:PolicyDetails' :: PolicyDetails -> Maybe (NonEmpty Schedule)
schedules} -> Maybe (NonEmpty Schedule)
schedules) (\s :: PolicyDetails
s@PolicyDetails' {} Maybe (NonEmpty Schedule)
a -> PolicyDetails
s {$sel:schedules:PolicyDetails' :: Maybe (NonEmpty Schedule)
schedules = Maybe (NonEmpty Schedule)
a} :: PolicyDetails) ((Maybe (NonEmpty Schedule) -> f (Maybe (NonEmpty Schedule)))
 -> PolicyDetails -> f PolicyDetails)
-> ((Maybe (NonEmpty Schedule) -> f (Maybe (NonEmpty Schedule)))
    -> Maybe (NonEmpty Schedule) -> f (Maybe (NonEmpty Schedule)))
-> (Maybe (NonEmpty Schedule) -> f (Maybe (NonEmpty Schedule)))
-> PolicyDetails
-> f PolicyDetails
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty Schedule)
  (NonEmpty Schedule)
  (NonEmpty Schedule)
  (NonEmpty Schedule)
-> Iso
     (Maybe (NonEmpty Schedule))
     (Maybe (NonEmpty Schedule))
     (Maybe (NonEmpty Schedule))
     (Maybe (NonEmpty Schedule))
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
  (NonEmpty Schedule)
  (NonEmpty Schedule)
  (NonEmpty Schedule)
  (NonEmpty Schedule)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The event that triggers the event-based policy.
--
-- This parameter is required for event-based policies only. If you are
-- creating a snapshot or AMI policy, omit this parameter.
policyDetails_eventSource :: Lens.Lens' PolicyDetails (Prelude.Maybe EventSource)
policyDetails_eventSource :: (Maybe EventSource -> f (Maybe EventSource))
-> PolicyDetails -> f PolicyDetails
policyDetails_eventSource = (PolicyDetails -> Maybe EventSource)
-> (PolicyDetails -> Maybe EventSource -> PolicyDetails)
-> Lens
     PolicyDetails PolicyDetails (Maybe EventSource) (Maybe EventSource)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PolicyDetails' {Maybe EventSource
eventSource :: Maybe EventSource
$sel:eventSource:PolicyDetails' :: PolicyDetails -> Maybe EventSource
eventSource} -> Maybe EventSource
eventSource) (\s :: PolicyDetails
s@PolicyDetails' {} Maybe EventSource
a -> PolicyDetails
s {$sel:eventSource:PolicyDetails' :: Maybe EventSource
eventSource = Maybe EventSource
a} :: PolicyDetails)

-- | The target resource type for snapshot and AMI lifecycle policies. Use
-- @VOLUME @to create snapshots of individual volumes or use @INSTANCE@ to
-- create multi-volume snapshots from the volumes for an instance.
--
-- This parameter is required for snapshot and AMI policies only. If you
-- are creating an event-based policy, omit this parameter.
policyDetails_resourceTypes :: Lens.Lens' PolicyDetails (Prelude.Maybe (Prelude.NonEmpty ResourceTypeValues))
policyDetails_resourceTypes :: (Maybe (NonEmpty ResourceTypeValues)
 -> f (Maybe (NonEmpty ResourceTypeValues)))
-> PolicyDetails -> f PolicyDetails
policyDetails_resourceTypes = (PolicyDetails -> Maybe (NonEmpty ResourceTypeValues))
-> (PolicyDetails
    -> Maybe (NonEmpty ResourceTypeValues) -> PolicyDetails)
-> Lens
     PolicyDetails
     PolicyDetails
     (Maybe (NonEmpty ResourceTypeValues))
     (Maybe (NonEmpty ResourceTypeValues))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PolicyDetails' {Maybe (NonEmpty ResourceTypeValues)
resourceTypes :: Maybe (NonEmpty ResourceTypeValues)
$sel:resourceTypes:PolicyDetails' :: PolicyDetails -> Maybe (NonEmpty ResourceTypeValues)
resourceTypes} -> Maybe (NonEmpty ResourceTypeValues)
resourceTypes) (\s :: PolicyDetails
s@PolicyDetails' {} Maybe (NonEmpty ResourceTypeValues)
a -> PolicyDetails
s {$sel:resourceTypes:PolicyDetails' :: Maybe (NonEmpty ResourceTypeValues)
resourceTypes = Maybe (NonEmpty ResourceTypeValues)
a} :: PolicyDetails) ((Maybe (NonEmpty ResourceTypeValues)
  -> f (Maybe (NonEmpty ResourceTypeValues)))
 -> PolicyDetails -> f PolicyDetails)
-> ((Maybe (NonEmpty ResourceTypeValues)
     -> f (Maybe (NonEmpty ResourceTypeValues)))
    -> Maybe (NonEmpty ResourceTypeValues)
    -> f (Maybe (NonEmpty ResourceTypeValues)))
-> (Maybe (NonEmpty ResourceTypeValues)
    -> f (Maybe (NonEmpty ResourceTypeValues)))
-> PolicyDetails
-> f PolicyDetails
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty ResourceTypeValues)
  (NonEmpty ResourceTypeValues)
  (NonEmpty ResourceTypeValues)
  (NonEmpty ResourceTypeValues)
-> Iso
     (Maybe (NonEmpty ResourceTypeValues))
     (Maybe (NonEmpty ResourceTypeValues))
     (Maybe (NonEmpty ResourceTypeValues))
     (Maybe (NonEmpty ResourceTypeValues))
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
  (NonEmpty ResourceTypeValues)
  (NonEmpty ResourceTypeValues)
  (NonEmpty ResourceTypeValues)
  (NonEmpty ResourceTypeValues)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON PolicyDetails where
  parseJSON :: Value -> Parser PolicyDetails
parseJSON =
    String
-> (Object -> Parser PolicyDetails)
-> Value
-> Parser PolicyDetails
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"PolicyDetails"
      ( \Object
x ->
          Maybe (NonEmpty Action)
-> Maybe (NonEmpty Tag)
-> Maybe PolicyTypeValues
-> Maybe (NonEmpty ResourceLocationValues)
-> Maybe Parameters
-> Maybe (NonEmpty Schedule)
-> Maybe EventSource
-> Maybe (NonEmpty ResourceTypeValues)
-> PolicyDetails
PolicyDetails'
            (Maybe (NonEmpty Action)
 -> Maybe (NonEmpty Tag)
 -> Maybe PolicyTypeValues
 -> Maybe (NonEmpty ResourceLocationValues)
 -> Maybe Parameters
 -> Maybe (NonEmpty Schedule)
 -> Maybe EventSource
 -> Maybe (NonEmpty ResourceTypeValues)
 -> PolicyDetails)
-> Parser (Maybe (NonEmpty Action))
-> Parser
     (Maybe (NonEmpty Tag)
      -> Maybe PolicyTypeValues
      -> Maybe (NonEmpty ResourceLocationValues)
      -> Maybe Parameters
      -> Maybe (NonEmpty Schedule)
      -> Maybe EventSource
      -> Maybe (NonEmpty ResourceTypeValues)
      -> PolicyDetails)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (NonEmpty Action))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Actions")
            Parser
  (Maybe (NonEmpty Tag)
   -> Maybe PolicyTypeValues
   -> Maybe (NonEmpty ResourceLocationValues)
   -> Maybe Parameters
   -> Maybe (NonEmpty Schedule)
   -> Maybe EventSource
   -> Maybe (NonEmpty ResourceTypeValues)
   -> PolicyDetails)
-> Parser (Maybe (NonEmpty Tag))
-> Parser
     (Maybe PolicyTypeValues
      -> Maybe (NonEmpty ResourceLocationValues)
      -> Maybe Parameters
      -> Maybe (NonEmpty Schedule)
      -> Maybe EventSource
      -> Maybe (NonEmpty ResourceTypeValues)
      -> PolicyDetails)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (NonEmpty Tag))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"TargetTags")
            Parser
  (Maybe PolicyTypeValues
   -> Maybe (NonEmpty ResourceLocationValues)
   -> Maybe Parameters
   -> Maybe (NonEmpty Schedule)
   -> Maybe EventSource
   -> Maybe (NonEmpty ResourceTypeValues)
   -> PolicyDetails)
-> Parser (Maybe PolicyTypeValues)
-> Parser
     (Maybe (NonEmpty ResourceLocationValues)
      -> Maybe Parameters
      -> Maybe (NonEmpty Schedule)
      -> Maybe EventSource
      -> Maybe (NonEmpty ResourceTypeValues)
      -> PolicyDetails)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe PolicyTypeValues)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"PolicyType")
            Parser
  (Maybe (NonEmpty ResourceLocationValues)
   -> Maybe Parameters
   -> Maybe (NonEmpty Schedule)
   -> Maybe EventSource
   -> Maybe (NonEmpty ResourceTypeValues)
   -> PolicyDetails)
-> Parser (Maybe (NonEmpty ResourceLocationValues))
-> Parser
     (Maybe Parameters
      -> Maybe (NonEmpty Schedule)
      -> Maybe EventSource
      -> Maybe (NonEmpty ResourceTypeValues)
      -> PolicyDetails)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (NonEmpty ResourceLocationValues))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ResourceLocations")
            Parser
  (Maybe Parameters
   -> Maybe (NonEmpty Schedule)
   -> Maybe EventSource
   -> Maybe (NonEmpty ResourceTypeValues)
   -> PolicyDetails)
-> Parser (Maybe Parameters)
-> Parser
     (Maybe (NonEmpty Schedule)
      -> Maybe EventSource
      -> Maybe (NonEmpty ResourceTypeValues)
      -> PolicyDetails)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Parameters)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Parameters")
            Parser
  (Maybe (NonEmpty Schedule)
   -> Maybe EventSource
   -> Maybe (NonEmpty ResourceTypeValues)
   -> PolicyDetails)
-> Parser (Maybe (NonEmpty Schedule))
-> Parser
     (Maybe EventSource
      -> Maybe (NonEmpty ResourceTypeValues) -> PolicyDetails)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (NonEmpty Schedule))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Schedules")
            Parser
  (Maybe EventSource
   -> Maybe (NonEmpty ResourceTypeValues) -> PolicyDetails)
-> Parser (Maybe EventSource)
-> Parser (Maybe (NonEmpty ResourceTypeValues) -> PolicyDetails)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe EventSource)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"EventSource")
            Parser (Maybe (NonEmpty ResourceTypeValues) -> PolicyDetails)
-> Parser (Maybe (NonEmpty ResourceTypeValues))
-> Parser PolicyDetails
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (NonEmpty ResourceTypeValues))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ResourceTypes")
      )

instance Prelude.Hashable PolicyDetails

instance Prelude.NFData PolicyDetails

instance Core.ToJSON PolicyDetails where
  toJSON :: PolicyDetails -> Value
toJSON PolicyDetails' {Maybe (NonEmpty ResourceLocationValues)
Maybe (NonEmpty ResourceTypeValues)
Maybe (NonEmpty Action)
Maybe (NonEmpty Tag)
Maybe (NonEmpty Schedule)
Maybe EventSource
Maybe Parameters
Maybe PolicyTypeValues
resourceTypes :: Maybe (NonEmpty ResourceTypeValues)
eventSource :: Maybe EventSource
schedules :: Maybe (NonEmpty Schedule)
parameters :: Maybe Parameters
resourceLocations :: Maybe (NonEmpty ResourceLocationValues)
policyType :: Maybe PolicyTypeValues
targetTags :: Maybe (NonEmpty Tag)
actions :: Maybe (NonEmpty Action)
$sel:resourceTypes:PolicyDetails' :: PolicyDetails -> Maybe (NonEmpty ResourceTypeValues)
$sel:eventSource:PolicyDetails' :: PolicyDetails -> Maybe EventSource
$sel:schedules:PolicyDetails' :: PolicyDetails -> Maybe (NonEmpty Schedule)
$sel:parameters:PolicyDetails' :: PolicyDetails -> Maybe Parameters
$sel:resourceLocations:PolicyDetails' :: PolicyDetails -> Maybe (NonEmpty ResourceLocationValues)
$sel:policyType:PolicyDetails' :: PolicyDetails -> Maybe PolicyTypeValues
$sel:targetTags:PolicyDetails' :: PolicyDetails -> Maybe (NonEmpty Tag)
$sel:actions:PolicyDetails' :: PolicyDetails -> Maybe (NonEmpty Action)
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Actions" Text -> NonEmpty Action -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (NonEmpty Action -> Pair) -> Maybe (NonEmpty Action) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Action)
actions,
            (Text
"TargetTags" Text -> NonEmpty Tag -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (NonEmpty Tag -> Pair) -> Maybe (NonEmpty Tag) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Tag)
targetTags,
            (Text
"PolicyType" Text -> PolicyTypeValues -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (PolicyTypeValues -> Pair) -> Maybe PolicyTypeValues -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe PolicyTypeValues
policyType,
            (Text
"ResourceLocations" Text -> NonEmpty ResourceLocationValues -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (NonEmpty ResourceLocationValues -> Pair)
-> Maybe (NonEmpty ResourceLocationValues) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty ResourceLocationValues)
resourceLocations,
            (Text
"Parameters" Text -> Parameters -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Parameters -> Pair) -> Maybe Parameters -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Parameters
parameters,
            (Text
"Schedules" Text -> NonEmpty Schedule -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (NonEmpty Schedule -> Pair)
-> Maybe (NonEmpty Schedule) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Schedule)
schedules,
            (Text
"EventSource" Text -> EventSource -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (EventSource -> Pair) -> Maybe EventSource -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe EventSource
eventSource,
            (Text
"ResourceTypes" Text -> NonEmpty ResourceTypeValues -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (NonEmpty ResourceTypeValues -> Pair)
-> Maybe (NonEmpty ResourceTypeValues) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty ResourceTypeValues)
resourceTypes
          ]
      )