{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.Lightsail.CreateDiskFromSnapshot
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Creates a block storage disk from a manual or automatic snapshot of a
-- disk. The resulting disk can be attached to an Amazon Lightsail instance
-- in the same Availability Zone (e.g., @us-east-2a@).
--
-- The @create disk from snapshot@ operation supports tag-based access
-- control via request tags and resource tags applied to the resource
-- identified by @disk snapshot name@. For more information, see the
-- <https://lightsail.aws.amazon.com/ls/docs/en_us/articles/amazon-lightsail-controlling-access-using-tags Amazon Lightsail Developer Guide>.
module Amazonka.Lightsail.CreateDiskFromSnapshot
  ( -- * Creating a Request
    CreateDiskFromSnapshot (..),
    newCreateDiskFromSnapshot,

    -- * Request Lenses
    createDiskFromSnapshot_addOns,
    createDiskFromSnapshot_diskSnapshotName,
    createDiskFromSnapshot_restoreDate,
    createDiskFromSnapshot_sourceDiskName,
    createDiskFromSnapshot_tags,
    createDiskFromSnapshot_useLatestRestorableAutoSnapshot,
    createDiskFromSnapshot_diskName,
    createDiskFromSnapshot_availabilityZone,
    createDiskFromSnapshot_sizeInGb,

    -- * Destructuring the Response
    CreateDiskFromSnapshotResponse (..),
    newCreateDiskFromSnapshotResponse,

    -- * Response Lenses
    createDiskFromSnapshotResponse_operations,
    createDiskFromSnapshotResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Lightsail.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newCreateDiskFromSnapshot' smart constructor.
data CreateDiskFromSnapshot = CreateDiskFromSnapshot'
  { -- | An array of objects that represent the add-ons to enable for the new
    -- disk.
    CreateDiskFromSnapshot -> Maybe [AddOnRequest]
addOns :: Prelude.Maybe [AddOnRequest],
    -- | The name of the disk snapshot (e.g., @my-snapshot@) from which to create
    -- the new storage disk.
    --
    -- Constraint:
    --
    -- -   This parameter cannot be defined together with the
    --     @source disk name@ parameter. The @disk snapshot name@ and
    --     @source disk name@ parameters are mutually exclusive.
    CreateDiskFromSnapshot -> Maybe Text
diskSnapshotName :: Prelude.Maybe Prelude.Text,
    -- | The date of the automatic snapshot to use for the new disk. Use the
    -- @get auto snapshots@ operation to identify the dates of the available
    -- automatic snapshots.
    --
    -- Constraints:
    --
    -- -   Must be specified in @YYYY-MM-DD@ format.
    --
    -- -   This parameter cannot be defined together with the
    --     @use latest restorable auto snapshot@ parameter. The @restore date@
    --     and @use latest restorable auto snapshot@ parameters are mutually
    --     exclusive.
    --
    -- -   Define this parameter only when creating a new disk from an
    --     automatic snapshot. For more information, see the
    --     <https://lightsail.aws.amazon.com/ls/docs/en_us/articles/amazon-lightsail-configuring-automatic-snapshots Amazon Lightsail Developer Guide>.
    CreateDiskFromSnapshot -> Maybe Text
restoreDate :: Prelude.Maybe Prelude.Text,
    -- | The name of the source disk from which the source automatic snapshot was
    -- created.
    --
    -- Constraints:
    --
    -- -   This parameter cannot be defined together with the
    --     @disk snapshot name@ parameter. The @source disk name@ and
    --     @disk snapshot name@ parameters are mutually exclusive.
    --
    -- -   Define this parameter only when creating a new disk from an
    --     automatic snapshot. For more information, see the
    --     <https://lightsail.aws.amazon.com/ls/docs/en_us/articles/amazon-lightsail-configuring-automatic-snapshots Amazon Lightsail Developer Guide>.
    CreateDiskFromSnapshot -> Maybe Text
sourceDiskName :: Prelude.Maybe Prelude.Text,
    -- | The tag keys and optional values to add to the resource during create.
    --
    -- Use the @TagResource@ action to tag a resource after it\'s created.
    CreateDiskFromSnapshot -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
    -- | A Boolean value to indicate whether to use the latest available
    -- automatic snapshot.
    --
    -- Constraints:
    --
    -- -   This parameter cannot be defined together with the @restore date@
    --     parameter. The @use latest restorable auto snapshot@ and
    --     @restore date@ parameters are mutually exclusive.
    --
    -- -   Define this parameter only when creating a new disk from an
    --     automatic snapshot. For more information, see the
    --     <https://lightsail.aws.amazon.com/ls/docs/en_us/articles/amazon-lightsail-configuring-automatic-snapshots Amazon Lightsail Developer Guide>.
    CreateDiskFromSnapshot -> Maybe Bool
useLatestRestorableAutoSnapshot :: Prelude.Maybe Prelude.Bool,
    -- | The unique Lightsail disk name (e.g., @my-disk@).
    CreateDiskFromSnapshot -> Text
diskName :: Prelude.Text,
    -- | The Availability Zone where you want to create the disk (e.g.,
    -- @us-east-2a@). Choose the same Availability Zone as the Lightsail
    -- instance where you want to create the disk.
    --
    -- Use the GetRegions operation to list the Availability Zones where
    -- Lightsail is currently available.
    CreateDiskFromSnapshot -> Text
availabilityZone :: Prelude.Text,
    -- | The size of the disk in GB (e.g., @32@).
    CreateDiskFromSnapshot -> Int
sizeInGb :: Prelude.Int
  }
  deriving (CreateDiskFromSnapshot -> CreateDiskFromSnapshot -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateDiskFromSnapshot -> CreateDiskFromSnapshot -> Bool
$c/= :: CreateDiskFromSnapshot -> CreateDiskFromSnapshot -> Bool
== :: CreateDiskFromSnapshot -> CreateDiskFromSnapshot -> Bool
$c== :: CreateDiskFromSnapshot -> CreateDiskFromSnapshot -> Bool
Prelude.Eq, ReadPrec [CreateDiskFromSnapshot]
ReadPrec CreateDiskFromSnapshot
Int -> ReadS CreateDiskFromSnapshot
ReadS [CreateDiskFromSnapshot]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateDiskFromSnapshot]
$creadListPrec :: ReadPrec [CreateDiskFromSnapshot]
readPrec :: ReadPrec CreateDiskFromSnapshot
$creadPrec :: ReadPrec CreateDiskFromSnapshot
readList :: ReadS [CreateDiskFromSnapshot]
$creadList :: ReadS [CreateDiskFromSnapshot]
readsPrec :: Int -> ReadS CreateDiskFromSnapshot
$creadsPrec :: Int -> ReadS CreateDiskFromSnapshot
Prelude.Read, Int -> CreateDiskFromSnapshot -> ShowS
[CreateDiskFromSnapshot] -> ShowS
CreateDiskFromSnapshot -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateDiskFromSnapshot] -> ShowS
$cshowList :: [CreateDiskFromSnapshot] -> ShowS
show :: CreateDiskFromSnapshot -> String
$cshow :: CreateDiskFromSnapshot -> String
showsPrec :: Int -> CreateDiskFromSnapshot -> ShowS
$cshowsPrec :: Int -> CreateDiskFromSnapshot -> ShowS
Prelude.Show, forall x. Rep CreateDiskFromSnapshot x -> CreateDiskFromSnapshot
forall x. CreateDiskFromSnapshot -> Rep CreateDiskFromSnapshot x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateDiskFromSnapshot x -> CreateDiskFromSnapshot
$cfrom :: forall x. CreateDiskFromSnapshot -> Rep CreateDiskFromSnapshot x
Prelude.Generic)

-- |
-- Create a value of 'CreateDiskFromSnapshot' 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:
--
-- 'addOns', 'createDiskFromSnapshot_addOns' - An array of objects that represent the add-ons to enable for the new
-- disk.
--
-- 'diskSnapshotName', 'createDiskFromSnapshot_diskSnapshotName' - The name of the disk snapshot (e.g., @my-snapshot@) from which to create
-- the new storage disk.
--
-- Constraint:
--
-- -   This parameter cannot be defined together with the
--     @source disk name@ parameter. The @disk snapshot name@ and
--     @source disk name@ parameters are mutually exclusive.
--
-- 'restoreDate', 'createDiskFromSnapshot_restoreDate' - The date of the automatic snapshot to use for the new disk. Use the
-- @get auto snapshots@ operation to identify the dates of the available
-- automatic snapshots.
--
-- Constraints:
--
-- -   Must be specified in @YYYY-MM-DD@ format.
--
-- -   This parameter cannot be defined together with the
--     @use latest restorable auto snapshot@ parameter. The @restore date@
--     and @use latest restorable auto snapshot@ parameters are mutually
--     exclusive.
--
-- -   Define this parameter only when creating a new disk from an
--     automatic snapshot. For more information, see the
--     <https://lightsail.aws.amazon.com/ls/docs/en_us/articles/amazon-lightsail-configuring-automatic-snapshots Amazon Lightsail Developer Guide>.
--
-- 'sourceDiskName', 'createDiskFromSnapshot_sourceDiskName' - The name of the source disk from which the source automatic snapshot was
-- created.
--
-- Constraints:
--
-- -   This parameter cannot be defined together with the
--     @disk snapshot name@ parameter. The @source disk name@ and
--     @disk snapshot name@ parameters are mutually exclusive.
--
-- -   Define this parameter only when creating a new disk from an
--     automatic snapshot. For more information, see the
--     <https://lightsail.aws.amazon.com/ls/docs/en_us/articles/amazon-lightsail-configuring-automatic-snapshots Amazon Lightsail Developer Guide>.
--
-- 'tags', 'createDiskFromSnapshot_tags' - The tag keys and optional values to add to the resource during create.
--
-- Use the @TagResource@ action to tag a resource after it\'s created.
--
-- 'useLatestRestorableAutoSnapshot', 'createDiskFromSnapshot_useLatestRestorableAutoSnapshot' - A Boolean value to indicate whether to use the latest available
-- automatic snapshot.
--
-- Constraints:
--
-- -   This parameter cannot be defined together with the @restore date@
--     parameter. The @use latest restorable auto snapshot@ and
--     @restore date@ parameters are mutually exclusive.
--
-- -   Define this parameter only when creating a new disk from an
--     automatic snapshot. For more information, see the
--     <https://lightsail.aws.amazon.com/ls/docs/en_us/articles/amazon-lightsail-configuring-automatic-snapshots Amazon Lightsail Developer Guide>.
--
-- 'diskName', 'createDiskFromSnapshot_diskName' - The unique Lightsail disk name (e.g., @my-disk@).
--
-- 'availabilityZone', 'createDiskFromSnapshot_availabilityZone' - The Availability Zone where you want to create the disk (e.g.,
-- @us-east-2a@). Choose the same Availability Zone as the Lightsail
-- instance where you want to create the disk.
--
-- Use the GetRegions operation to list the Availability Zones where
-- Lightsail is currently available.
--
-- 'sizeInGb', 'createDiskFromSnapshot_sizeInGb' - The size of the disk in GB (e.g., @32@).
newCreateDiskFromSnapshot ::
  -- | 'diskName'
  Prelude.Text ->
  -- | 'availabilityZone'
  Prelude.Text ->
  -- | 'sizeInGb'
  Prelude.Int ->
  CreateDiskFromSnapshot
newCreateDiskFromSnapshot :: Text -> Text -> Int -> CreateDiskFromSnapshot
newCreateDiskFromSnapshot
  Text
pDiskName_
  Text
pAvailabilityZone_
  Int
pSizeInGb_ =
    CreateDiskFromSnapshot'
      { $sel:addOns:CreateDiskFromSnapshot' :: Maybe [AddOnRequest]
addOns = forall a. Maybe a
Prelude.Nothing,
        $sel:diskSnapshotName:CreateDiskFromSnapshot' :: Maybe Text
diskSnapshotName = forall a. Maybe a
Prelude.Nothing,
        $sel:restoreDate:CreateDiskFromSnapshot' :: Maybe Text
restoreDate = forall a. Maybe a
Prelude.Nothing,
        $sel:sourceDiskName:CreateDiskFromSnapshot' :: Maybe Text
sourceDiskName = forall a. Maybe a
Prelude.Nothing,
        $sel:tags:CreateDiskFromSnapshot' :: Maybe [Tag]
tags = forall a. Maybe a
Prelude.Nothing,
        $sel:useLatestRestorableAutoSnapshot:CreateDiskFromSnapshot' :: Maybe Bool
useLatestRestorableAutoSnapshot = forall a. Maybe a
Prelude.Nothing,
        $sel:diskName:CreateDiskFromSnapshot' :: Text
diskName = Text
pDiskName_,
        $sel:availabilityZone:CreateDiskFromSnapshot' :: Text
availabilityZone = Text
pAvailabilityZone_,
        $sel:sizeInGb:CreateDiskFromSnapshot' :: Int
sizeInGb = Int
pSizeInGb_
      }

-- | An array of objects that represent the add-ons to enable for the new
-- disk.
createDiskFromSnapshot_addOns :: Lens.Lens' CreateDiskFromSnapshot (Prelude.Maybe [AddOnRequest])
createDiskFromSnapshot_addOns :: Lens' CreateDiskFromSnapshot (Maybe [AddOnRequest])
createDiskFromSnapshot_addOns = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDiskFromSnapshot' {Maybe [AddOnRequest]
addOns :: Maybe [AddOnRequest]
$sel:addOns:CreateDiskFromSnapshot' :: CreateDiskFromSnapshot -> Maybe [AddOnRequest]
addOns} -> Maybe [AddOnRequest]
addOns) (\s :: CreateDiskFromSnapshot
s@CreateDiskFromSnapshot' {} Maybe [AddOnRequest]
a -> CreateDiskFromSnapshot
s {$sel:addOns:CreateDiskFromSnapshot' :: Maybe [AddOnRequest]
addOns = Maybe [AddOnRequest]
a} :: CreateDiskFromSnapshot) 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

-- | The name of the disk snapshot (e.g., @my-snapshot@) from which to create
-- the new storage disk.
--
-- Constraint:
--
-- -   This parameter cannot be defined together with the
--     @source disk name@ parameter. The @disk snapshot name@ and
--     @source disk name@ parameters are mutually exclusive.
createDiskFromSnapshot_diskSnapshotName :: Lens.Lens' CreateDiskFromSnapshot (Prelude.Maybe Prelude.Text)
createDiskFromSnapshot_diskSnapshotName :: Lens' CreateDiskFromSnapshot (Maybe Text)
createDiskFromSnapshot_diskSnapshotName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDiskFromSnapshot' {Maybe Text
diskSnapshotName :: Maybe Text
$sel:diskSnapshotName:CreateDiskFromSnapshot' :: CreateDiskFromSnapshot -> Maybe Text
diskSnapshotName} -> Maybe Text
diskSnapshotName) (\s :: CreateDiskFromSnapshot
s@CreateDiskFromSnapshot' {} Maybe Text
a -> CreateDiskFromSnapshot
s {$sel:diskSnapshotName:CreateDiskFromSnapshot' :: Maybe Text
diskSnapshotName = Maybe Text
a} :: CreateDiskFromSnapshot)

-- | The date of the automatic snapshot to use for the new disk. Use the
-- @get auto snapshots@ operation to identify the dates of the available
-- automatic snapshots.
--
-- Constraints:
--
-- -   Must be specified in @YYYY-MM-DD@ format.
--
-- -   This parameter cannot be defined together with the
--     @use latest restorable auto snapshot@ parameter. The @restore date@
--     and @use latest restorable auto snapshot@ parameters are mutually
--     exclusive.
--
-- -   Define this parameter only when creating a new disk from an
--     automatic snapshot. For more information, see the
--     <https://lightsail.aws.amazon.com/ls/docs/en_us/articles/amazon-lightsail-configuring-automatic-snapshots Amazon Lightsail Developer Guide>.
createDiskFromSnapshot_restoreDate :: Lens.Lens' CreateDiskFromSnapshot (Prelude.Maybe Prelude.Text)
createDiskFromSnapshot_restoreDate :: Lens' CreateDiskFromSnapshot (Maybe Text)
createDiskFromSnapshot_restoreDate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDiskFromSnapshot' {Maybe Text
restoreDate :: Maybe Text
$sel:restoreDate:CreateDiskFromSnapshot' :: CreateDiskFromSnapshot -> Maybe Text
restoreDate} -> Maybe Text
restoreDate) (\s :: CreateDiskFromSnapshot
s@CreateDiskFromSnapshot' {} Maybe Text
a -> CreateDiskFromSnapshot
s {$sel:restoreDate:CreateDiskFromSnapshot' :: Maybe Text
restoreDate = Maybe Text
a} :: CreateDiskFromSnapshot)

-- | The name of the source disk from which the source automatic snapshot was
-- created.
--
-- Constraints:
--
-- -   This parameter cannot be defined together with the
--     @disk snapshot name@ parameter. The @source disk name@ and
--     @disk snapshot name@ parameters are mutually exclusive.
--
-- -   Define this parameter only when creating a new disk from an
--     automatic snapshot. For more information, see the
--     <https://lightsail.aws.amazon.com/ls/docs/en_us/articles/amazon-lightsail-configuring-automatic-snapshots Amazon Lightsail Developer Guide>.
createDiskFromSnapshot_sourceDiskName :: Lens.Lens' CreateDiskFromSnapshot (Prelude.Maybe Prelude.Text)
createDiskFromSnapshot_sourceDiskName :: Lens' CreateDiskFromSnapshot (Maybe Text)
createDiskFromSnapshot_sourceDiskName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDiskFromSnapshot' {Maybe Text
sourceDiskName :: Maybe Text
$sel:sourceDiskName:CreateDiskFromSnapshot' :: CreateDiskFromSnapshot -> Maybe Text
sourceDiskName} -> Maybe Text
sourceDiskName) (\s :: CreateDiskFromSnapshot
s@CreateDiskFromSnapshot' {} Maybe Text
a -> CreateDiskFromSnapshot
s {$sel:sourceDiskName:CreateDiskFromSnapshot' :: Maybe Text
sourceDiskName = Maybe Text
a} :: CreateDiskFromSnapshot)

-- | The tag keys and optional values to add to the resource during create.
--
-- Use the @TagResource@ action to tag a resource after it\'s created.
createDiskFromSnapshot_tags :: Lens.Lens' CreateDiskFromSnapshot (Prelude.Maybe [Tag])
createDiskFromSnapshot_tags :: Lens' CreateDiskFromSnapshot (Maybe [Tag])
createDiskFromSnapshot_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDiskFromSnapshot' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:CreateDiskFromSnapshot' :: CreateDiskFromSnapshot -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: CreateDiskFromSnapshot
s@CreateDiskFromSnapshot' {} Maybe [Tag]
a -> CreateDiskFromSnapshot
s {$sel:tags:CreateDiskFromSnapshot' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: CreateDiskFromSnapshot) 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

-- | A Boolean value to indicate whether to use the latest available
-- automatic snapshot.
--
-- Constraints:
--
-- -   This parameter cannot be defined together with the @restore date@
--     parameter. The @use latest restorable auto snapshot@ and
--     @restore date@ parameters are mutually exclusive.
--
-- -   Define this parameter only when creating a new disk from an
--     automatic snapshot. For more information, see the
--     <https://lightsail.aws.amazon.com/ls/docs/en_us/articles/amazon-lightsail-configuring-automatic-snapshots Amazon Lightsail Developer Guide>.
createDiskFromSnapshot_useLatestRestorableAutoSnapshot :: Lens.Lens' CreateDiskFromSnapshot (Prelude.Maybe Prelude.Bool)
createDiskFromSnapshot_useLatestRestorableAutoSnapshot :: Lens' CreateDiskFromSnapshot (Maybe Bool)
createDiskFromSnapshot_useLatestRestorableAutoSnapshot = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDiskFromSnapshot' {Maybe Bool
useLatestRestorableAutoSnapshot :: Maybe Bool
$sel:useLatestRestorableAutoSnapshot:CreateDiskFromSnapshot' :: CreateDiskFromSnapshot -> Maybe Bool
useLatestRestorableAutoSnapshot} -> Maybe Bool
useLatestRestorableAutoSnapshot) (\s :: CreateDiskFromSnapshot
s@CreateDiskFromSnapshot' {} Maybe Bool
a -> CreateDiskFromSnapshot
s {$sel:useLatestRestorableAutoSnapshot:CreateDiskFromSnapshot' :: Maybe Bool
useLatestRestorableAutoSnapshot = Maybe Bool
a} :: CreateDiskFromSnapshot)

-- | The unique Lightsail disk name (e.g., @my-disk@).
createDiskFromSnapshot_diskName :: Lens.Lens' CreateDiskFromSnapshot Prelude.Text
createDiskFromSnapshot_diskName :: Lens' CreateDiskFromSnapshot Text
createDiskFromSnapshot_diskName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDiskFromSnapshot' {Text
diskName :: Text
$sel:diskName:CreateDiskFromSnapshot' :: CreateDiskFromSnapshot -> Text
diskName} -> Text
diskName) (\s :: CreateDiskFromSnapshot
s@CreateDiskFromSnapshot' {} Text
a -> CreateDiskFromSnapshot
s {$sel:diskName:CreateDiskFromSnapshot' :: Text
diskName = Text
a} :: CreateDiskFromSnapshot)

-- | The Availability Zone where you want to create the disk (e.g.,
-- @us-east-2a@). Choose the same Availability Zone as the Lightsail
-- instance where you want to create the disk.
--
-- Use the GetRegions operation to list the Availability Zones where
-- Lightsail is currently available.
createDiskFromSnapshot_availabilityZone :: Lens.Lens' CreateDiskFromSnapshot Prelude.Text
createDiskFromSnapshot_availabilityZone :: Lens' CreateDiskFromSnapshot Text
createDiskFromSnapshot_availabilityZone = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDiskFromSnapshot' {Text
availabilityZone :: Text
$sel:availabilityZone:CreateDiskFromSnapshot' :: CreateDiskFromSnapshot -> Text
availabilityZone} -> Text
availabilityZone) (\s :: CreateDiskFromSnapshot
s@CreateDiskFromSnapshot' {} Text
a -> CreateDiskFromSnapshot
s {$sel:availabilityZone:CreateDiskFromSnapshot' :: Text
availabilityZone = Text
a} :: CreateDiskFromSnapshot)

-- | The size of the disk in GB (e.g., @32@).
createDiskFromSnapshot_sizeInGb :: Lens.Lens' CreateDiskFromSnapshot Prelude.Int
createDiskFromSnapshot_sizeInGb :: Lens' CreateDiskFromSnapshot Int
createDiskFromSnapshot_sizeInGb = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDiskFromSnapshot' {Int
sizeInGb :: Int
$sel:sizeInGb:CreateDiskFromSnapshot' :: CreateDiskFromSnapshot -> Int
sizeInGb} -> Int
sizeInGb) (\s :: CreateDiskFromSnapshot
s@CreateDiskFromSnapshot' {} Int
a -> CreateDiskFromSnapshot
s {$sel:sizeInGb:CreateDiskFromSnapshot' :: Int
sizeInGb = Int
a} :: CreateDiskFromSnapshot)

instance Core.AWSRequest CreateDiskFromSnapshot where
  type
    AWSResponse CreateDiskFromSnapshot =
      CreateDiskFromSnapshotResponse
  request :: (Service -> Service)
-> CreateDiskFromSnapshot -> Request CreateDiskFromSnapshot
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy CreateDiskFromSnapshot
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateDiskFromSnapshot)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe [Operation] -> Int -> CreateDiskFromSnapshotResponse
CreateDiskFromSnapshotResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"operations" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable CreateDiskFromSnapshot where
  hashWithSalt :: Int -> CreateDiskFromSnapshot -> Int
hashWithSalt Int
_salt CreateDiskFromSnapshot' {Int
Maybe Bool
Maybe [AddOnRequest]
Maybe [Tag]
Maybe Text
Text
sizeInGb :: Int
availabilityZone :: Text
diskName :: Text
useLatestRestorableAutoSnapshot :: Maybe Bool
tags :: Maybe [Tag]
sourceDiskName :: Maybe Text
restoreDate :: Maybe Text
diskSnapshotName :: Maybe Text
addOns :: Maybe [AddOnRequest]
$sel:sizeInGb:CreateDiskFromSnapshot' :: CreateDiskFromSnapshot -> Int
$sel:availabilityZone:CreateDiskFromSnapshot' :: CreateDiskFromSnapshot -> Text
$sel:diskName:CreateDiskFromSnapshot' :: CreateDiskFromSnapshot -> Text
$sel:useLatestRestorableAutoSnapshot:CreateDiskFromSnapshot' :: CreateDiskFromSnapshot -> Maybe Bool
$sel:tags:CreateDiskFromSnapshot' :: CreateDiskFromSnapshot -> Maybe [Tag]
$sel:sourceDiskName:CreateDiskFromSnapshot' :: CreateDiskFromSnapshot -> Maybe Text
$sel:restoreDate:CreateDiskFromSnapshot' :: CreateDiskFromSnapshot -> Maybe Text
$sel:diskSnapshotName:CreateDiskFromSnapshot' :: CreateDiskFromSnapshot -> Maybe Text
$sel:addOns:CreateDiskFromSnapshot' :: CreateDiskFromSnapshot -> Maybe [AddOnRequest]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [AddOnRequest]
addOns
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
diskSnapshotName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
restoreDate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
sourceDiskName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Tag]
tags
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
useLatestRestorableAutoSnapshot
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
diskName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
availabilityZone
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Int
sizeInGb

instance Prelude.NFData CreateDiskFromSnapshot where
  rnf :: CreateDiskFromSnapshot -> ()
rnf CreateDiskFromSnapshot' {Int
Maybe Bool
Maybe [AddOnRequest]
Maybe [Tag]
Maybe Text
Text
sizeInGb :: Int
availabilityZone :: Text
diskName :: Text
useLatestRestorableAutoSnapshot :: Maybe Bool
tags :: Maybe [Tag]
sourceDiskName :: Maybe Text
restoreDate :: Maybe Text
diskSnapshotName :: Maybe Text
addOns :: Maybe [AddOnRequest]
$sel:sizeInGb:CreateDiskFromSnapshot' :: CreateDiskFromSnapshot -> Int
$sel:availabilityZone:CreateDiskFromSnapshot' :: CreateDiskFromSnapshot -> Text
$sel:diskName:CreateDiskFromSnapshot' :: CreateDiskFromSnapshot -> Text
$sel:useLatestRestorableAutoSnapshot:CreateDiskFromSnapshot' :: CreateDiskFromSnapshot -> Maybe Bool
$sel:tags:CreateDiskFromSnapshot' :: CreateDiskFromSnapshot -> Maybe [Tag]
$sel:sourceDiskName:CreateDiskFromSnapshot' :: CreateDiskFromSnapshot -> Maybe Text
$sel:restoreDate:CreateDiskFromSnapshot' :: CreateDiskFromSnapshot -> Maybe Text
$sel:diskSnapshotName:CreateDiskFromSnapshot' :: CreateDiskFromSnapshot -> Maybe Text
$sel:addOns:CreateDiskFromSnapshot' :: CreateDiskFromSnapshot -> Maybe [AddOnRequest]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [AddOnRequest]
addOns
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
diskSnapshotName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
restoreDate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
sourceDiskName
      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 Bool
useLatestRestorableAutoSnapshot
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
diskName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
availabilityZone
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
sizeInGb

instance Data.ToHeaders CreateDiskFromSnapshot where
  toHeaders :: CreateDiskFromSnapshot -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"Lightsail_20161128.CreateDiskFromSnapshot" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON CreateDiskFromSnapshot where
  toJSON :: CreateDiskFromSnapshot -> Value
toJSON CreateDiskFromSnapshot' {Int
Maybe Bool
Maybe [AddOnRequest]
Maybe [Tag]
Maybe Text
Text
sizeInGb :: Int
availabilityZone :: Text
diskName :: Text
useLatestRestorableAutoSnapshot :: Maybe Bool
tags :: Maybe [Tag]
sourceDiskName :: Maybe Text
restoreDate :: Maybe Text
diskSnapshotName :: Maybe Text
addOns :: Maybe [AddOnRequest]
$sel:sizeInGb:CreateDiskFromSnapshot' :: CreateDiskFromSnapshot -> Int
$sel:availabilityZone:CreateDiskFromSnapshot' :: CreateDiskFromSnapshot -> Text
$sel:diskName:CreateDiskFromSnapshot' :: CreateDiskFromSnapshot -> Text
$sel:useLatestRestorableAutoSnapshot:CreateDiskFromSnapshot' :: CreateDiskFromSnapshot -> Maybe Bool
$sel:tags:CreateDiskFromSnapshot' :: CreateDiskFromSnapshot -> Maybe [Tag]
$sel:sourceDiskName:CreateDiskFromSnapshot' :: CreateDiskFromSnapshot -> Maybe Text
$sel:restoreDate:CreateDiskFromSnapshot' :: CreateDiskFromSnapshot -> Maybe Text
$sel:diskSnapshotName:CreateDiskFromSnapshot' :: CreateDiskFromSnapshot -> Maybe Text
$sel:addOns:CreateDiskFromSnapshot' :: CreateDiskFromSnapshot -> Maybe [AddOnRequest]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"addOns" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [AddOnRequest]
addOns,
            (Key
"diskSnapshotName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
diskSnapshotName,
            (Key
"restoreDate" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
restoreDate,
            (Key
"sourceDiskName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
sourceDiskName,
            (Key
"tags" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Tag]
tags,
            (Key
"useLatestRestorableAutoSnapshot" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
useLatestRestorableAutoSnapshot,
            forall a. a -> Maybe a
Prelude.Just (Key
"diskName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
diskName),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"availabilityZone" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
availabilityZone),
            forall a. a -> Maybe a
Prelude.Just (Key
"sizeInGb" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Int
sizeInGb)
          ]
      )

instance Data.ToPath CreateDiskFromSnapshot where
  toPath :: CreateDiskFromSnapshot -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Data.ToQuery CreateDiskFromSnapshot where
  toQuery :: CreateDiskFromSnapshot -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newCreateDiskFromSnapshotResponse' smart constructor.
data CreateDiskFromSnapshotResponse = CreateDiskFromSnapshotResponse'
  { -- | An array of objects that describe the result of the action, such as the
    -- status of the request, the timestamp of the request, and the resources
    -- affected by the request.
    CreateDiskFromSnapshotResponse -> Maybe [Operation]
operations :: Prelude.Maybe [Operation],
    -- | The response's http status code.
    CreateDiskFromSnapshotResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateDiskFromSnapshotResponse
-> CreateDiskFromSnapshotResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateDiskFromSnapshotResponse
-> CreateDiskFromSnapshotResponse -> Bool
$c/= :: CreateDiskFromSnapshotResponse
-> CreateDiskFromSnapshotResponse -> Bool
== :: CreateDiskFromSnapshotResponse
-> CreateDiskFromSnapshotResponse -> Bool
$c== :: CreateDiskFromSnapshotResponse
-> CreateDiskFromSnapshotResponse -> Bool
Prelude.Eq, ReadPrec [CreateDiskFromSnapshotResponse]
ReadPrec CreateDiskFromSnapshotResponse
Int -> ReadS CreateDiskFromSnapshotResponse
ReadS [CreateDiskFromSnapshotResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateDiskFromSnapshotResponse]
$creadListPrec :: ReadPrec [CreateDiskFromSnapshotResponse]
readPrec :: ReadPrec CreateDiskFromSnapshotResponse
$creadPrec :: ReadPrec CreateDiskFromSnapshotResponse
readList :: ReadS [CreateDiskFromSnapshotResponse]
$creadList :: ReadS [CreateDiskFromSnapshotResponse]
readsPrec :: Int -> ReadS CreateDiskFromSnapshotResponse
$creadsPrec :: Int -> ReadS CreateDiskFromSnapshotResponse
Prelude.Read, Int -> CreateDiskFromSnapshotResponse -> ShowS
[CreateDiskFromSnapshotResponse] -> ShowS
CreateDiskFromSnapshotResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateDiskFromSnapshotResponse] -> ShowS
$cshowList :: [CreateDiskFromSnapshotResponse] -> ShowS
show :: CreateDiskFromSnapshotResponse -> String
$cshow :: CreateDiskFromSnapshotResponse -> String
showsPrec :: Int -> CreateDiskFromSnapshotResponse -> ShowS
$cshowsPrec :: Int -> CreateDiskFromSnapshotResponse -> ShowS
Prelude.Show, forall x.
Rep CreateDiskFromSnapshotResponse x
-> CreateDiskFromSnapshotResponse
forall x.
CreateDiskFromSnapshotResponse
-> Rep CreateDiskFromSnapshotResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateDiskFromSnapshotResponse x
-> CreateDiskFromSnapshotResponse
$cfrom :: forall x.
CreateDiskFromSnapshotResponse
-> Rep CreateDiskFromSnapshotResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateDiskFromSnapshotResponse' 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:
--
-- 'operations', 'createDiskFromSnapshotResponse_operations' - An array of objects that describe the result of the action, such as the
-- status of the request, the timestamp of the request, and the resources
-- affected by the request.
--
-- 'httpStatus', 'createDiskFromSnapshotResponse_httpStatus' - The response's http status code.
newCreateDiskFromSnapshotResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateDiskFromSnapshotResponse
newCreateDiskFromSnapshotResponse :: Int -> CreateDiskFromSnapshotResponse
newCreateDiskFromSnapshotResponse Int
pHttpStatus_ =
  CreateDiskFromSnapshotResponse'
    { $sel:operations:CreateDiskFromSnapshotResponse' :: Maybe [Operation]
operations =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateDiskFromSnapshotResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An array of objects that describe the result of the action, such as the
-- status of the request, the timestamp of the request, and the resources
-- affected by the request.
createDiskFromSnapshotResponse_operations :: Lens.Lens' CreateDiskFromSnapshotResponse (Prelude.Maybe [Operation])
createDiskFromSnapshotResponse_operations :: Lens' CreateDiskFromSnapshotResponse (Maybe [Operation])
createDiskFromSnapshotResponse_operations = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDiskFromSnapshotResponse' {Maybe [Operation]
operations :: Maybe [Operation]
$sel:operations:CreateDiskFromSnapshotResponse' :: CreateDiskFromSnapshotResponse -> Maybe [Operation]
operations} -> Maybe [Operation]
operations) (\s :: CreateDiskFromSnapshotResponse
s@CreateDiskFromSnapshotResponse' {} Maybe [Operation]
a -> CreateDiskFromSnapshotResponse
s {$sel:operations:CreateDiskFromSnapshotResponse' :: Maybe [Operation]
operations = Maybe [Operation]
a} :: CreateDiskFromSnapshotResponse) 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

-- | The response's http status code.
createDiskFromSnapshotResponse_httpStatus :: Lens.Lens' CreateDiskFromSnapshotResponse Prelude.Int
createDiskFromSnapshotResponse_httpStatus :: Lens' CreateDiskFromSnapshotResponse Int
createDiskFromSnapshotResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDiskFromSnapshotResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateDiskFromSnapshotResponse' :: CreateDiskFromSnapshotResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateDiskFromSnapshotResponse
s@CreateDiskFromSnapshotResponse' {} Int
a -> CreateDiskFromSnapshotResponse
s {$sel:httpStatus:CreateDiskFromSnapshotResponse' :: Int
httpStatus = Int
a} :: CreateDiskFromSnapshotResponse)

instance
  Prelude.NFData
    CreateDiskFromSnapshotResponse
  where
  rnf :: CreateDiskFromSnapshotResponse -> ()
rnf CreateDiskFromSnapshotResponse' {Int
Maybe [Operation]
httpStatus :: Int
operations :: Maybe [Operation]
$sel:httpStatus:CreateDiskFromSnapshotResponse' :: CreateDiskFromSnapshotResponse -> Int
$sel:operations:CreateDiskFromSnapshotResponse' :: CreateDiskFromSnapshotResponse -> Maybe [Operation]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Operation]
operations
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus