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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A structure that contains information about a backed-up resource.
--
-- /See:/ 'newProtectedResource' smart constructor.
data ProtectedResource = ProtectedResource'
  { -- | The type of Amazon Web Services resource; for example, an Amazon Elastic
    -- Block Store (Amazon EBS) volume or an Amazon Relational Database Service
    -- (Amazon RDS) database. For Windows Volume Shadow Copy Service (VSS)
    -- backups, the only supported resource type is Amazon EC2.
    ProtectedResource -> Maybe Text
resourceType :: Prelude.Maybe Prelude.Text,
    -- | The date and time a resource was last backed up, in Unix format and
    -- Coordinated Universal Time (UTC). The value of @LastBackupTime@ is
    -- accurate to milliseconds. For example, the value 1516925490.087
    -- represents Friday, January 26, 2018 12:11:30.087 AM.
    ProtectedResource -> Maybe POSIX
lastBackupTime :: Prelude.Maybe Core.POSIX,
    -- | An Amazon Resource Name (ARN) that uniquely identifies a resource. The
    -- format of the ARN depends on the resource type.
    ProtectedResource -> Maybe Text
resourceArn :: Prelude.Maybe Prelude.Text
  }
  deriving (ProtectedResource -> ProtectedResource -> Bool
(ProtectedResource -> ProtectedResource -> Bool)
-> (ProtectedResource -> ProtectedResource -> Bool)
-> Eq ProtectedResource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ProtectedResource -> ProtectedResource -> Bool
$c/= :: ProtectedResource -> ProtectedResource -> Bool
== :: ProtectedResource -> ProtectedResource -> Bool
$c== :: ProtectedResource -> ProtectedResource -> Bool
Prelude.Eq, ReadPrec [ProtectedResource]
ReadPrec ProtectedResource
Int -> ReadS ProtectedResource
ReadS [ProtectedResource]
(Int -> ReadS ProtectedResource)
-> ReadS [ProtectedResource]
-> ReadPrec ProtectedResource
-> ReadPrec [ProtectedResource]
-> Read ProtectedResource
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ProtectedResource]
$creadListPrec :: ReadPrec [ProtectedResource]
readPrec :: ReadPrec ProtectedResource
$creadPrec :: ReadPrec ProtectedResource
readList :: ReadS [ProtectedResource]
$creadList :: ReadS [ProtectedResource]
readsPrec :: Int -> ReadS ProtectedResource
$creadsPrec :: Int -> ReadS ProtectedResource
Prelude.Read, Int -> ProtectedResource -> ShowS
[ProtectedResource] -> ShowS
ProtectedResource -> String
(Int -> ProtectedResource -> ShowS)
-> (ProtectedResource -> String)
-> ([ProtectedResource] -> ShowS)
-> Show ProtectedResource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ProtectedResource] -> ShowS
$cshowList :: [ProtectedResource] -> ShowS
show :: ProtectedResource -> String
$cshow :: ProtectedResource -> String
showsPrec :: Int -> ProtectedResource -> ShowS
$cshowsPrec :: Int -> ProtectedResource -> ShowS
Prelude.Show, (forall x. ProtectedResource -> Rep ProtectedResource x)
-> (forall x. Rep ProtectedResource x -> ProtectedResource)
-> Generic ProtectedResource
forall x. Rep ProtectedResource x -> ProtectedResource
forall x. ProtectedResource -> Rep ProtectedResource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ProtectedResource x -> ProtectedResource
$cfrom :: forall x. ProtectedResource -> Rep ProtectedResource x
Prelude.Generic)

-- |
-- Create a value of 'ProtectedResource' 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:
--
-- 'resourceType', 'protectedResource_resourceType' - The type of Amazon Web Services resource; for example, an Amazon Elastic
-- Block Store (Amazon EBS) volume or an Amazon Relational Database Service
-- (Amazon RDS) database. For Windows Volume Shadow Copy Service (VSS)
-- backups, the only supported resource type is Amazon EC2.
--
-- 'lastBackupTime', 'protectedResource_lastBackupTime' - The date and time a resource was last backed up, in Unix format and
-- Coordinated Universal Time (UTC). The value of @LastBackupTime@ is
-- accurate to milliseconds. For example, the value 1516925490.087
-- represents Friday, January 26, 2018 12:11:30.087 AM.
--
-- 'resourceArn', 'protectedResource_resourceArn' - An Amazon Resource Name (ARN) that uniquely identifies a resource. The
-- format of the ARN depends on the resource type.
newProtectedResource ::
  ProtectedResource
newProtectedResource :: ProtectedResource
newProtectedResource =
  ProtectedResource' :: Maybe Text -> Maybe POSIX -> Maybe Text -> ProtectedResource
ProtectedResource'
    { $sel:resourceType:ProtectedResource' :: Maybe Text
resourceType = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:lastBackupTime:ProtectedResource' :: Maybe POSIX
lastBackupTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceArn:ProtectedResource' :: Maybe Text
resourceArn = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The type of Amazon Web Services resource; for example, an Amazon Elastic
-- Block Store (Amazon EBS) volume or an Amazon Relational Database Service
-- (Amazon RDS) database. For Windows Volume Shadow Copy Service (VSS)
-- backups, the only supported resource type is Amazon EC2.
protectedResource_resourceType :: Lens.Lens' ProtectedResource (Prelude.Maybe Prelude.Text)
protectedResource_resourceType :: (Maybe Text -> f (Maybe Text))
-> ProtectedResource -> f ProtectedResource
protectedResource_resourceType = (ProtectedResource -> Maybe Text)
-> (ProtectedResource -> Maybe Text -> ProtectedResource)
-> Lens
     ProtectedResource ProtectedResource (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProtectedResource' {Maybe Text
resourceType :: Maybe Text
$sel:resourceType:ProtectedResource' :: ProtectedResource -> Maybe Text
resourceType} -> Maybe Text
resourceType) (\s :: ProtectedResource
s@ProtectedResource' {} Maybe Text
a -> ProtectedResource
s {$sel:resourceType:ProtectedResource' :: Maybe Text
resourceType = Maybe Text
a} :: ProtectedResource)

-- | The date and time a resource was last backed up, in Unix format and
-- Coordinated Universal Time (UTC). The value of @LastBackupTime@ is
-- accurate to milliseconds. For example, the value 1516925490.087
-- represents Friday, January 26, 2018 12:11:30.087 AM.
protectedResource_lastBackupTime :: Lens.Lens' ProtectedResource (Prelude.Maybe Prelude.UTCTime)
protectedResource_lastBackupTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> ProtectedResource -> f ProtectedResource
protectedResource_lastBackupTime = (ProtectedResource -> Maybe POSIX)
-> (ProtectedResource -> Maybe POSIX -> ProtectedResource)
-> Lens
     ProtectedResource ProtectedResource (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProtectedResource' {Maybe POSIX
lastBackupTime :: Maybe POSIX
$sel:lastBackupTime:ProtectedResource' :: ProtectedResource -> Maybe POSIX
lastBackupTime} -> Maybe POSIX
lastBackupTime) (\s :: ProtectedResource
s@ProtectedResource' {} Maybe POSIX
a -> ProtectedResource
s {$sel:lastBackupTime:ProtectedResource' :: Maybe POSIX
lastBackupTime = Maybe POSIX
a} :: ProtectedResource) ((Maybe POSIX -> f (Maybe POSIX))
 -> ProtectedResource -> f ProtectedResource)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ProtectedResource
-> f ProtectedResource
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | An Amazon Resource Name (ARN) that uniquely identifies a resource. The
-- format of the ARN depends on the resource type.
protectedResource_resourceArn :: Lens.Lens' ProtectedResource (Prelude.Maybe Prelude.Text)
protectedResource_resourceArn :: (Maybe Text -> f (Maybe Text))
-> ProtectedResource -> f ProtectedResource
protectedResource_resourceArn = (ProtectedResource -> Maybe Text)
-> (ProtectedResource -> Maybe Text -> ProtectedResource)
-> Lens
     ProtectedResource ProtectedResource (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProtectedResource' {Maybe Text
resourceArn :: Maybe Text
$sel:resourceArn:ProtectedResource' :: ProtectedResource -> Maybe Text
resourceArn} -> Maybe Text
resourceArn) (\s :: ProtectedResource
s@ProtectedResource' {} Maybe Text
a -> ProtectedResource
s {$sel:resourceArn:ProtectedResource' :: Maybe Text
resourceArn = Maybe Text
a} :: ProtectedResource)

instance Core.FromJSON ProtectedResource where
  parseJSON :: Value -> Parser ProtectedResource
parseJSON =
    String
-> (Object -> Parser ProtectedResource)
-> Value
-> Parser ProtectedResource
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ProtectedResource"
      ( \Object
x ->
          Maybe Text -> Maybe POSIX -> Maybe Text -> ProtectedResource
ProtectedResource'
            (Maybe Text -> Maybe POSIX -> Maybe Text -> ProtectedResource)
-> Parser (Maybe Text)
-> Parser (Maybe POSIX -> Maybe Text -> ProtectedResource)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ResourceType")
            Parser (Maybe POSIX -> Maybe Text -> ProtectedResource)
-> Parser (Maybe POSIX) -> Parser (Maybe Text -> ProtectedResource)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"LastBackupTime")
            Parser (Maybe Text -> ProtectedResource)
-> Parser (Maybe Text) -> Parser ProtectedResource
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ResourceArn")
      )

instance Prelude.Hashable ProtectedResource

instance Prelude.NFData ProtectedResource