{-# 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.Backup.Types.LegalHold
-- 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.Backup.Types.LegalHold where

import Amazonka.Backup.Types.LegalHoldStatus
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

-- | A legal hold is an administrative tool that helps prevent backups from
-- being deleted while under a hold. While the hold is in place, backups
-- under a hold cannot be deleted and lifecycle policies that would alter
-- the backup status (such as transition to cold storage) are delayed until
-- the legal hold is removed. A backup can have more than one legal hold.
-- Legal holds are applied to one or more backups (also known as recovery
-- points). These backups can be filtered by resource types and by resource
-- IDs.
--
-- /See:/ 'newLegalHold' smart constructor.
data LegalHold = LegalHold'
  { -- | This is the time in number format when legal hold was cancelled.
    LegalHold -> Maybe POSIX
cancellationDate :: Prelude.Maybe Data.POSIX,
    -- | This is the time in number format when legal hold was created.
    LegalHold -> Maybe POSIX
creationDate :: Prelude.Maybe Data.POSIX,
    -- | This is the description of a legal hold.
    LegalHold -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | This is an Amazon Resource Number (ARN) that uniquely identifies the
    -- legal hold; for example,
    -- @arn:aws:backup:us-east-1:123456789012:recovery-point:1EB3B5E7-9EB0-435A-A80B-108B488B0D45@.
    LegalHold -> Maybe Text
legalHoldArn :: Prelude.Maybe Prelude.Text,
    -- | ID of specific legal hold on one or more recovery points.
    LegalHold -> Maybe Text
legalHoldId :: Prelude.Maybe Prelude.Text,
    -- | This is the status of the legal hold. Statuses can be @ACTIVE@,
    -- @CREATING@, @CANCELED@, and @CANCELING@.
    LegalHold -> Maybe LegalHoldStatus
status :: Prelude.Maybe LegalHoldStatus,
    -- | This is the title of a legal hold.
    LegalHold -> Maybe Text
title :: Prelude.Maybe Prelude.Text
  }
  deriving (LegalHold -> LegalHold -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LegalHold -> LegalHold -> Bool
$c/= :: LegalHold -> LegalHold -> Bool
== :: LegalHold -> LegalHold -> Bool
$c== :: LegalHold -> LegalHold -> Bool
Prelude.Eq, ReadPrec [LegalHold]
ReadPrec LegalHold
Int -> ReadS LegalHold
ReadS [LegalHold]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LegalHold]
$creadListPrec :: ReadPrec [LegalHold]
readPrec :: ReadPrec LegalHold
$creadPrec :: ReadPrec LegalHold
readList :: ReadS [LegalHold]
$creadList :: ReadS [LegalHold]
readsPrec :: Int -> ReadS LegalHold
$creadsPrec :: Int -> ReadS LegalHold
Prelude.Read, Int -> LegalHold -> ShowS
[LegalHold] -> ShowS
LegalHold -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LegalHold] -> ShowS
$cshowList :: [LegalHold] -> ShowS
show :: LegalHold -> String
$cshow :: LegalHold -> String
showsPrec :: Int -> LegalHold -> ShowS
$cshowsPrec :: Int -> LegalHold -> ShowS
Prelude.Show, forall x. Rep LegalHold x -> LegalHold
forall x. LegalHold -> Rep LegalHold x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LegalHold x -> LegalHold
$cfrom :: forall x. LegalHold -> Rep LegalHold x
Prelude.Generic)

-- |
-- Create a value of 'LegalHold' 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:
--
-- 'cancellationDate', 'legalHold_cancellationDate' - This is the time in number format when legal hold was cancelled.
--
-- 'creationDate', 'legalHold_creationDate' - This is the time in number format when legal hold was created.
--
-- 'description', 'legalHold_description' - This is the description of a legal hold.
--
-- 'legalHoldArn', 'legalHold_legalHoldArn' - This is an Amazon Resource Number (ARN) that uniquely identifies the
-- legal hold; for example,
-- @arn:aws:backup:us-east-1:123456789012:recovery-point:1EB3B5E7-9EB0-435A-A80B-108B488B0D45@.
--
-- 'legalHoldId', 'legalHold_legalHoldId' - ID of specific legal hold on one or more recovery points.
--
-- 'status', 'legalHold_status' - This is the status of the legal hold. Statuses can be @ACTIVE@,
-- @CREATING@, @CANCELED@, and @CANCELING@.
--
-- 'title', 'legalHold_title' - This is the title of a legal hold.
newLegalHold ::
  LegalHold
newLegalHold :: LegalHold
newLegalHold =
  LegalHold'
    { $sel:cancellationDate:LegalHold' :: Maybe POSIX
cancellationDate = forall a. Maybe a
Prelude.Nothing,
      $sel:creationDate:LegalHold' :: Maybe POSIX
creationDate = forall a. Maybe a
Prelude.Nothing,
      $sel:description:LegalHold' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
      $sel:legalHoldArn:LegalHold' :: Maybe Text
legalHoldArn = forall a. Maybe a
Prelude.Nothing,
      $sel:legalHoldId:LegalHold' :: Maybe Text
legalHoldId = forall a. Maybe a
Prelude.Nothing,
      $sel:status:LegalHold' :: Maybe LegalHoldStatus
status = forall a. Maybe a
Prelude.Nothing,
      $sel:title:LegalHold' :: Maybe Text
title = forall a. Maybe a
Prelude.Nothing
    }

-- | This is the time in number format when legal hold was cancelled.
legalHold_cancellationDate :: Lens.Lens' LegalHold (Prelude.Maybe Prelude.UTCTime)
legalHold_cancellationDate :: Lens' LegalHold (Maybe UTCTime)
legalHold_cancellationDate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LegalHold' {Maybe POSIX
cancellationDate :: Maybe POSIX
$sel:cancellationDate:LegalHold' :: LegalHold -> Maybe POSIX
cancellationDate} -> Maybe POSIX
cancellationDate) (\s :: LegalHold
s@LegalHold' {} Maybe POSIX
a -> LegalHold
s {$sel:cancellationDate:LegalHold' :: Maybe POSIX
cancellationDate = Maybe POSIX
a} :: LegalHold) 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 (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | This is the time in number format when legal hold was created.
legalHold_creationDate :: Lens.Lens' LegalHold (Prelude.Maybe Prelude.UTCTime)
legalHold_creationDate :: Lens' LegalHold (Maybe UTCTime)
legalHold_creationDate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LegalHold' {Maybe POSIX
creationDate :: Maybe POSIX
$sel:creationDate:LegalHold' :: LegalHold -> Maybe POSIX
creationDate} -> Maybe POSIX
creationDate) (\s :: LegalHold
s@LegalHold' {} Maybe POSIX
a -> LegalHold
s {$sel:creationDate:LegalHold' :: Maybe POSIX
creationDate = Maybe POSIX
a} :: LegalHold) 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 (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | This is the description of a legal hold.
legalHold_description :: Lens.Lens' LegalHold (Prelude.Maybe Prelude.Text)
legalHold_description :: Lens' LegalHold (Maybe Text)
legalHold_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LegalHold' {Maybe Text
description :: Maybe Text
$sel:description:LegalHold' :: LegalHold -> Maybe Text
description} -> Maybe Text
description) (\s :: LegalHold
s@LegalHold' {} Maybe Text
a -> LegalHold
s {$sel:description:LegalHold' :: Maybe Text
description = Maybe Text
a} :: LegalHold)

-- | This is an Amazon Resource Number (ARN) that uniquely identifies the
-- legal hold; for example,
-- @arn:aws:backup:us-east-1:123456789012:recovery-point:1EB3B5E7-9EB0-435A-A80B-108B488B0D45@.
legalHold_legalHoldArn :: Lens.Lens' LegalHold (Prelude.Maybe Prelude.Text)
legalHold_legalHoldArn :: Lens' LegalHold (Maybe Text)
legalHold_legalHoldArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LegalHold' {Maybe Text
legalHoldArn :: Maybe Text
$sel:legalHoldArn:LegalHold' :: LegalHold -> Maybe Text
legalHoldArn} -> Maybe Text
legalHoldArn) (\s :: LegalHold
s@LegalHold' {} Maybe Text
a -> LegalHold
s {$sel:legalHoldArn:LegalHold' :: Maybe Text
legalHoldArn = Maybe Text
a} :: LegalHold)

-- | ID of specific legal hold on one or more recovery points.
legalHold_legalHoldId :: Lens.Lens' LegalHold (Prelude.Maybe Prelude.Text)
legalHold_legalHoldId :: Lens' LegalHold (Maybe Text)
legalHold_legalHoldId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LegalHold' {Maybe Text
legalHoldId :: Maybe Text
$sel:legalHoldId:LegalHold' :: LegalHold -> Maybe Text
legalHoldId} -> Maybe Text
legalHoldId) (\s :: LegalHold
s@LegalHold' {} Maybe Text
a -> LegalHold
s {$sel:legalHoldId:LegalHold' :: Maybe Text
legalHoldId = Maybe Text
a} :: LegalHold)

-- | This is the status of the legal hold. Statuses can be @ACTIVE@,
-- @CREATING@, @CANCELED@, and @CANCELING@.
legalHold_status :: Lens.Lens' LegalHold (Prelude.Maybe LegalHoldStatus)
legalHold_status :: Lens' LegalHold (Maybe LegalHoldStatus)
legalHold_status = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LegalHold' {Maybe LegalHoldStatus
status :: Maybe LegalHoldStatus
$sel:status:LegalHold' :: LegalHold -> Maybe LegalHoldStatus
status} -> Maybe LegalHoldStatus
status) (\s :: LegalHold
s@LegalHold' {} Maybe LegalHoldStatus
a -> LegalHold
s {$sel:status:LegalHold' :: Maybe LegalHoldStatus
status = Maybe LegalHoldStatus
a} :: LegalHold)

-- | This is the title of a legal hold.
legalHold_title :: Lens.Lens' LegalHold (Prelude.Maybe Prelude.Text)
legalHold_title :: Lens' LegalHold (Maybe Text)
legalHold_title = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LegalHold' {Maybe Text
title :: Maybe Text
$sel:title:LegalHold' :: LegalHold -> Maybe Text
title} -> Maybe Text
title) (\s :: LegalHold
s@LegalHold' {} Maybe Text
a -> LegalHold
s {$sel:title:LegalHold' :: Maybe Text
title = Maybe Text
a} :: LegalHold)

instance Data.FromJSON LegalHold where
  parseJSON :: Value -> Parser LegalHold
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"LegalHold"
      ( \Object
x ->
          Maybe POSIX
-> Maybe POSIX
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe LegalHoldStatus
-> Maybe Text
-> LegalHold
LegalHold'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"CancellationDate")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"CreationDate")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Description")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"LegalHoldArn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"LegalHoldId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Status")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Title")
      )

instance Prelude.Hashable LegalHold where
  hashWithSalt :: Int -> LegalHold -> Int
hashWithSalt Int
_salt LegalHold' {Maybe Text
Maybe POSIX
Maybe LegalHoldStatus
title :: Maybe Text
status :: Maybe LegalHoldStatus
legalHoldId :: Maybe Text
legalHoldArn :: Maybe Text
description :: Maybe Text
creationDate :: Maybe POSIX
cancellationDate :: Maybe POSIX
$sel:title:LegalHold' :: LegalHold -> Maybe Text
$sel:status:LegalHold' :: LegalHold -> Maybe LegalHoldStatus
$sel:legalHoldId:LegalHold' :: LegalHold -> Maybe Text
$sel:legalHoldArn:LegalHold' :: LegalHold -> Maybe Text
$sel:description:LegalHold' :: LegalHold -> Maybe Text
$sel:creationDate:LegalHold' :: LegalHold -> Maybe POSIX
$sel:cancellationDate:LegalHold' :: LegalHold -> Maybe POSIX
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
cancellationDate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
creationDate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
legalHoldArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
legalHoldId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe LegalHoldStatus
status
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
title

instance Prelude.NFData LegalHold where
  rnf :: LegalHold -> ()
rnf LegalHold' {Maybe Text
Maybe POSIX
Maybe LegalHoldStatus
title :: Maybe Text
status :: Maybe LegalHoldStatus
legalHoldId :: Maybe Text
legalHoldArn :: Maybe Text
description :: Maybe Text
creationDate :: Maybe POSIX
cancellationDate :: Maybe POSIX
$sel:title:LegalHold' :: LegalHold -> Maybe Text
$sel:status:LegalHold' :: LegalHold -> Maybe LegalHoldStatus
$sel:legalHoldId:LegalHold' :: LegalHold -> Maybe Text
$sel:legalHoldArn:LegalHold' :: LegalHold -> Maybe Text
$sel:description:LegalHold' :: LegalHold -> Maybe Text
$sel:creationDate:LegalHold' :: LegalHold -> Maybe POSIX
$sel:cancellationDate:LegalHold' :: LegalHold -> Maybe POSIX
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
cancellationDate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
creationDate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
description
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
legalHoldArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
legalHoldId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe LegalHoldStatus
status
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
title