{-# 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.EBS.Types.ChangedBlock
-- 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.EBS.Types.ChangedBlock where

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

-- | A block of data in an Amazon Elastic Block Store snapshot that is
-- different from another snapshot of the same volume\/snapshot lineage.
--
-- /See:/ 'newChangedBlock' smart constructor.
data ChangedBlock = ChangedBlock'
  { -- | The block index.
    ChangedBlock -> Maybe Natural
blockIndex :: Prelude.Maybe Prelude.Natural,
    -- | The block token for the block index of the @SecondSnapshotId@ specified
    -- in the @ListChangedBlocks@ operation.
    ChangedBlock -> Maybe Text
secondBlockToken :: Prelude.Maybe Prelude.Text,
    -- | The block token for the block index of the @FirstSnapshotId@ specified
    -- in the @ListChangedBlocks@ operation. This value is absent if the first
    -- snapshot does not have the changed block that is on the second snapshot.
    ChangedBlock -> Maybe Text
firstBlockToken :: Prelude.Maybe Prelude.Text
  }
  deriving (ChangedBlock -> ChangedBlock -> Bool
(ChangedBlock -> ChangedBlock -> Bool)
-> (ChangedBlock -> ChangedBlock -> Bool) -> Eq ChangedBlock
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ChangedBlock -> ChangedBlock -> Bool
$c/= :: ChangedBlock -> ChangedBlock -> Bool
== :: ChangedBlock -> ChangedBlock -> Bool
$c== :: ChangedBlock -> ChangedBlock -> Bool
Prelude.Eq, Int -> ChangedBlock -> ShowS
[ChangedBlock] -> ShowS
ChangedBlock -> String
(Int -> ChangedBlock -> ShowS)
-> (ChangedBlock -> String)
-> ([ChangedBlock] -> ShowS)
-> Show ChangedBlock
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ChangedBlock] -> ShowS
$cshowList :: [ChangedBlock] -> ShowS
show :: ChangedBlock -> String
$cshow :: ChangedBlock -> String
showsPrec :: Int -> ChangedBlock -> ShowS
$cshowsPrec :: Int -> ChangedBlock -> ShowS
Prelude.Show, (forall x. ChangedBlock -> Rep ChangedBlock x)
-> (forall x. Rep ChangedBlock x -> ChangedBlock)
-> Generic ChangedBlock
forall x. Rep ChangedBlock x -> ChangedBlock
forall x. ChangedBlock -> Rep ChangedBlock x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ChangedBlock x -> ChangedBlock
$cfrom :: forall x. ChangedBlock -> Rep ChangedBlock x
Prelude.Generic)

-- |
-- Create a value of 'ChangedBlock' 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:
--
-- 'blockIndex', 'changedBlock_blockIndex' - The block index.
--
-- 'secondBlockToken', 'changedBlock_secondBlockToken' - The block token for the block index of the @SecondSnapshotId@ specified
-- in the @ListChangedBlocks@ operation.
--
-- 'firstBlockToken', 'changedBlock_firstBlockToken' - The block token for the block index of the @FirstSnapshotId@ specified
-- in the @ListChangedBlocks@ operation. This value is absent if the first
-- snapshot does not have the changed block that is on the second snapshot.
newChangedBlock ::
  ChangedBlock
newChangedBlock :: ChangedBlock
newChangedBlock =
  ChangedBlock' :: Maybe Natural -> Maybe Text -> Maybe Text -> ChangedBlock
ChangedBlock'
    { $sel:blockIndex:ChangedBlock' :: Maybe Natural
blockIndex = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:secondBlockToken:ChangedBlock' :: Maybe Text
secondBlockToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:firstBlockToken:ChangedBlock' :: Maybe Text
firstBlockToken = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The block index.
changedBlock_blockIndex :: Lens.Lens' ChangedBlock (Prelude.Maybe Prelude.Natural)
changedBlock_blockIndex :: (Maybe Natural -> f (Maybe Natural))
-> ChangedBlock -> f ChangedBlock
changedBlock_blockIndex = (ChangedBlock -> Maybe Natural)
-> (ChangedBlock -> Maybe Natural -> ChangedBlock)
-> Lens ChangedBlock ChangedBlock (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ChangedBlock' {Maybe Natural
blockIndex :: Maybe Natural
$sel:blockIndex:ChangedBlock' :: ChangedBlock -> Maybe Natural
blockIndex} -> Maybe Natural
blockIndex) (\s :: ChangedBlock
s@ChangedBlock' {} Maybe Natural
a -> ChangedBlock
s {$sel:blockIndex:ChangedBlock' :: Maybe Natural
blockIndex = Maybe Natural
a} :: ChangedBlock)

-- | The block token for the block index of the @SecondSnapshotId@ specified
-- in the @ListChangedBlocks@ operation.
changedBlock_secondBlockToken :: Lens.Lens' ChangedBlock (Prelude.Maybe Prelude.Text)
changedBlock_secondBlockToken :: (Maybe Text -> f (Maybe Text)) -> ChangedBlock -> f ChangedBlock
changedBlock_secondBlockToken = (ChangedBlock -> Maybe Text)
-> (ChangedBlock -> Maybe Text -> ChangedBlock)
-> Lens ChangedBlock ChangedBlock (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ChangedBlock' {Maybe Text
secondBlockToken :: Maybe Text
$sel:secondBlockToken:ChangedBlock' :: ChangedBlock -> Maybe Text
secondBlockToken} -> Maybe Text
secondBlockToken) (\s :: ChangedBlock
s@ChangedBlock' {} Maybe Text
a -> ChangedBlock
s {$sel:secondBlockToken:ChangedBlock' :: Maybe Text
secondBlockToken = Maybe Text
a} :: ChangedBlock)

-- | The block token for the block index of the @FirstSnapshotId@ specified
-- in the @ListChangedBlocks@ operation. This value is absent if the first
-- snapshot does not have the changed block that is on the second snapshot.
changedBlock_firstBlockToken :: Lens.Lens' ChangedBlock (Prelude.Maybe Prelude.Text)
changedBlock_firstBlockToken :: (Maybe Text -> f (Maybe Text)) -> ChangedBlock -> f ChangedBlock
changedBlock_firstBlockToken = (ChangedBlock -> Maybe Text)
-> (ChangedBlock -> Maybe Text -> ChangedBlock)
-> Lens ChangedBlock ChangedBlock (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ChangedBlock' {Maybe Text
firstBlockToken :: Maybe Text
$sel:firstBlockToken:ChangedBlock' :: ChangedBlock -> Maybe Text
firstBlockToken} -> Maybe Text
firstBlockToken) (\s :: ChangedBlock
s@ChangedBlock' {} Maybe Text
a -> ChangedBlock
s {$sel:firstBlockToken:ChangedBlock' :: Maybe Text
firstBlockToken = Maybe Text
a} :: ChangedBlock)

instance Core.FromJSON ChangedBlock where
  parseJSON :: Value -> Parser ChangedBlock
parseJSON =
    String
-> (Object -> Parser ChangedBlock) -> Value -> Parser ChangedBlock
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ChangedBlock"
      ( \Object
x ->
          Maybe Natural -> Maybe Text -> Maybe Text -> ChangedBlock
ChangedBlock'
            (Maybe Natural -> Maybe Text -> Maybe Text -> ChangedBlock)
-> Parser (Maybe Natural)
-> Parser (Maybe Text -> Maybe Text -> ChangedBlock)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"BlockIndex")
            Parser (Maybe Text -> Maybe Text -> ChangedBlock)
-> Parser (Maybe Text) -> Parser (Maybe Text -> ChangedBlock)
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
"SecondBlockToken")
            Parser (Maybe Text -> ChangedBlock)
-> Parser (Maybe Text) -> Parser ChangedBlock
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
"FirstBlockToken")
      )

instance Prelude.Hashable ChangedBlock

instance Prelude.NFData ChangedBlock