{-# 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.CopySnapshot
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Copies a manual snapshot of an instance or disk as another manual
-- snapshot, or copies an automatic snapshot of an instance or disk as a
-- manual snapshot. This operation can also be used to copy a manual or
-- automatic snapshot of an instance or a disk from one Amazon Web Services
-- Region to another in Amazon Lightsail.
--
-- When copying a /manual snapshot/, be sure to define the @source region@,
-- @source snapshot name@, and @target snapshot name@ parameters.
--
-- When copying an /automatic snapshot/, be sure to define the
-- @source region@, @source resource name@, @target snapshot name@, and
-- either the @restore date@ or the @use latest restorable auto snapshot@
-- parameters.
module Amazonka.Lightsail.CopySnapshot
  ( -- * Creating a Request
    CopySnapshot (..),
    newCopySnapshot,

    -- * Request Lenses
    copySnapshot_restoreDate,
    copySnapshot_sourceResourceName,
    copySnapshot_sourceSnapshotName,
    copySnapshot_useLatestRestorableAutoSnapshot,
    copySnapshot_targetSnapshotName,
    copySnapshot_sourceRegion,

    -- * Destructuring the Response
    CopySnapshotResponse (..),
    newCopySnapshotResponse,

    -- * Response Lenses
    copySnapshotResponse_operations,
    copySnapshotResponse_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:/ 'newCopySnapshot' smart constructor.
data CopySnapshot = CopySnapshot'
  { -- | The date of the source automatic snapshot to copy. 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 copying an automatic snapshot as a
    --     manual snapshot. For more information, see the
    --     <https://lightsail.aws.amazon.com/ls/docs/en_us/articles/amazon-lightsail-keeping-automatic-snapshots Amazon Lightsail Developer Guide>.
    CopySnapshot -> Maybe Text
restoreDate :: Prelude.Maybe Prelude.Text,
    -- | The name of the source instance or disk from which the source automatic
    -- snapshot was created.
    --
    -- Constraint:
    --
    -- -   Define this parameter only when copying an automatic snapshot as a
    --     manual snapshot. For more information, see the
    --     <https://lightsail.aws.amazon.com/ls/docs/en_us/articles/amazon-lightsail-keeping-automatic-snapshots Amazon Lightsail Developer Guide>.
    CopySnapshot -> Maybe Text
sourceResourceName :: Prelude.Maybe Prelude.Text,
    -- | The name of the source manual snapshot to copy.
    --
    -- Constraint:
    --
    -- -   Define this parameter only when copying a manual snapshot as another
    --     manual snapshot.
    CopySnapshot -> Maybe Text
sourceSnapshotName :: Prelude.Maybe Prelude.Text,
    -- | A Boolean value to indicate whether to use the latest available
    -- automatic snapshot of the specified source instance or disk.
    --
    -- 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 copying an automatic snapshot as a
    --     manual snapshot. For more information, see the
    --     <https://lightsail.aws.amazon.com/ls/docs/en_us/articles/amazon-lightsail-keeping-automatic-snapshots Amazon Lightsail Developer Guide>.
    CopySnapshot -> Maybe Bool
useLatestRestorableAutoSnapshot :: Prelude.Maybe Prelude.Bool,
    -- | The name of the new manual snapshot to be created as a copy.
    CopySnapshot -> Text
targetSnapshotName :: Prelude.Text,
    -- | The Amazon Web Services Region where the source manual or automatic
    -- snapshot is located.
    CopySnapshot -> RegionName
sourceRegion :: RegionName
  }
  deriving (CopySnapshot -> CopySnapshot -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CopySnapshot -> CopySnapshot -> Bool
$c/= :: CopySnapshot -> CopySnapshot -> Bool
== :: CopySnapshot -> CopySnapshot -> Bool
$c== :: CopySnapshot -> CopySnapshot -> Bool
Prelude.Eq, ReadPrec [CopySnapshot]
ReadPrec CopySnapshot
Int -> ReadS CopySnapshot
ReadS [CopySnapshot]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CopySnapshot]
$creadListPrec :: ReadPrec [CopySnapshot]
readPrec :: ReadPrec CopySnapshot
$creadPrec :: ReadPrec CopySnapshot
readList :: ReadS [CopySnapshot]
$creadList :: ReadS [CopySnapshot]
readsPrec :: Int -> ReadS CopySnapshot
$creadsPrec :: Int -> ReadS CopySnapshot
Prelude.Read, Int -> CopySnapshot -> ShowS
[CopySnapshot] -> ShowS
CopySnapshot -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CopySnapshot] -> ShowS
$cshowList :: [CopySnapshot] -> ShowS
show :: CopySnapshot -> String
$cshow :: CopySnapshot -> String
showsPrec :: Int -> CopySnapshot -> ShowS
$cshowsPrec :: Int -> CopySnapshot -> ShowS
Prelude.Show, forall x. Rep CopySnapshot x -> CopySnapshot
forall x. CopySnapshot -> Rep CopySnapshot x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CopySnapshot x -> CopySnapshot
$cfrom :: forall x. CopySnapshot -> Rep CopySnapshot x
Prelude.Generic)

-- |
-- Create a value of 'CopySnapshot' 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:
--
-- 'restoreDate', 'copySnapshot_restoreDate' - The date of the source automatic snapshot to copy. 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 copying an automatic snapshot as a
--     manual snapshot. For more information, see the
--     <https://lightsail.aws.amazon.com/ls/docs/en_us/articles/amazon-lightsail-keeping-automatic-snapshots Amazon Lightsail Developer Guide>.
--
-- 'sourceResourceName', 'copySnapshot_sourceResourceName' - The name of the source instance or disk from which the source automatic
-- snapshot was created.
--
-- Constraint:
--
-- -   Define this parameter only when copying an automatic snapshot as a
--     manual snapshot. For more information, see the
--     <https://lightsail.aws.amazon.com/ls/docs/en_us/articles/amazon-lightsail-keeping-automatic-snapshots Amazon Lightsail Developer Guide>.
--
-- 'sourceSnapshotName', 'copySnapshot_sourceSnapshotName' - The name of the source manual snapshot to copy.
--
-- Constraint:
--
-- -   Define this parameter only when copying a manual snapshot as another
--     manual snapshot.
--
-- 'useLatestRestorableAutoSnapshot', 'copySnapshot_useLatestRestorableAutoSnapshot' - A Boolean value to indicate whether to use the latest available
-- automatic snapshot of the specified source instance or disk.
--
-- 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 copying an automatic snapshot as a
--     manual snapshot. For more information, see the
--     <https://lightsail.aws.amazon.com/ls/docs/en_us/articles/amazon-lightsail-keeping-automatic-snapshots Amazon Lightsail Developer Guide>.
--
-- 'targetSnapshotName', 'copySnapshot_targetSnapshotName' - The name of the new manual snapshot to be created as a copy.
--
-- 'sourceRegion', 'copySnapshot_sourceRegion' - The Amazon Web Services Region where the source manual or automatic
-- snapshot is located.
newCopySnapshot ::
  -- | 'targetSnapshotName'
  Prelude.Text ->
  -- | 'sourceRegion'
  RegionName ->
  CopySnapshot
newCopySnapshot :: Text -> RegionName -> CopySnapshot
newCopySnapshot Text
pTargetSnapshotName_ RegionName
pSourceRegion_ =
  CopySnapshot'
    { $sel:restoreDate:CopySnapshot' :: Maybe Text
restoreDate = forall a. Maybe a
Prelude.Nothing,
      $sel:sourceResourceName:CopySnapshot' :: Maybe Text
sourceResourceName = forall a. Maybe a
Prelude.Nothing,
      $sel:sourceSnapshotName:CopySnapshot' :: Maybe Text
sourceSnapshotName = forall a. Maybe a
Prelude.Nothing,
      $sel:useLatestRestorableAutoSnapshot:CopySnapshot' :: Maybe Bool
useLatestRestorableAutoSnapshot = forall a. Maybe a
Prelude.Nothing,
      $sel:targetSnapshotName:CopySnapshot' :: Text
targetSnapshotName = Text
pTargetSnapshotName_,
      $sel:sourceRegion:CopySnapshot' :: RegionName
sourceRegion = RegionName
pSourceRegion_
    }

-- | The date of the source automatic snapshot to copy. 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 copying an automatic snapshot as a
--     manual snapshot. For more information, see the
--     <https://lightsail.aws.amazon.com/ls/docs/en_us/articles/amazon-lightsail-keeping-automatic-snapshots Amazon Lightsail Developer Guide>.
copySnapshot_restoreDate :: Lens.Lens' CopySnapshot (Prelude.Maybe Prelude.Text)
copySnapshot_restoreDate :: Lens' CopySnapshot (Maybe Text)
copySnapshot_restoreDate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CopySnapshot' {Maybe Text
restoreDate :: Maybe Text
$sel:restoreDate:CopySnapshot' :: CopySnapshot -> Maybe Text
restoreDate} -> Maybe Text
restoreDate) (\s :: CopySnapshot
s@CopySnapshot' {} Maybe Text
a -> CopySnapshot
s {$sel:restoreDate:CopySnapshot' :: Maybe Text
restoreDate = Maybe Text
a} :: CopySnapshot)

-- | The name of the source instance or disk from which the source automatic
-- snapshot was created.
--
-- Constraint:
--
-- -   Define this parameter only when copying an automatic snapshot as a
--     manual snapshot. For more information, see the
--     <https://lightsail.aws.amazon.com/ls/docs/en_us/articles/amazon-lightsail-keeping-automatic-snapshots Amazon Lightsail Developer Guide>.
copySnapshot_sourceResourceName :: Lens.Lens' CopySnapshot (Prelude.Maybe Prelude.Text)
copySnapshot_sourceResourceName :: Lens' CopySnapshot (Maybe Text)
copySnapshot_sourceResourceName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CopySnapshot' {Maybe Text
sourceResourceName :: Maybe Text
$sel:sourceResourceName:CopySnapshot' :: CopySnapshot -> Maybe Text
sourceResourceName} -> Maybe Text
sourceResourceName) (\s :: CopySnapshot
s@CopySnapshot' {} Maybe Text
a -> CopySnapshot
s {$sel:sourceResourceName:CopySnapshot' :: Maybe Text
sourceResourceName = Maybe Text
a} :: CopySnapshot)

-- | The name of the source manual snapshot to copy.
--
-- Constraint:
--
-- -   Define this parameter only when copying a manual snapshot as another
--     manual snapshot.
copySnapshot_sourceSnapshotName :: Lens.Lens' CopySnapshot (Prelude.Maybe Prelude.Text)
copySnapshot_sourceSnapshotName :: Lens' CopySnapshot (Maybe Text)
copySnapshot_sourceSnapshotName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CopySnapshot' {Maybe Text
sourceSnapshotName :: Maybe Text
$sel:sourceSnapshotName:CopySnapshot' :: CopySnapshot -> Maybe Text
sourceSnapshotName} -> Maybe Text
sourceSnapshotName) (\s :: CopySnapshot
s@CopySnapshot' {} Maybe Text
a -> CopySnapshot
s {$sel:sourceSnapshotName:CopySnapshot' :: Maybe Text
sourceSnapshotName = Maybe Text
a} :: CopySnapshot)

-- | A Boolean value to indicate whether to use the latest available
-- automatic snapshot of the specified source instance or disk.
--
-- 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 copying an automatic snapshot as a
--     manual snapshot. For more information, see the
--     <https://lightsail.aws.amazon.com/ls/docs/en_us/articles/amazon-lightsail-keeping-automatic-snapshots Amazon Lightsail Developer Guide>.
copySnapshot_useLatestRestorableAutoSnapshot :: Lens.Lens' CopySnapshot (Prelude.Maybe Prelude.Bool)
copySnapshot_useLatestRestorableAutoSnapshot :: Lens' CopySnapshot (Maybe Bool)
copySnapshot_useLatestRestorableAutoSnapshot = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CopySnapshot' {Maybe Bool
useLatestRestorableAutoSnapshot :: Maybe Bool
$sel:useLatestRestorableAutoSnapshot:CopySnapshot' :: CopySnapshot -> Maybe Bool
useLatestRestorableAutoSnapshot} -> Maybe Bool
useLatestRestorableAutoSnapshot) (\s :: CopySnapshot
s@CopySnapshot' {} Maybe Bool
a -> CopySnapshot
s {$sel:useLatestRestorableAutoSnapshot:CopySnapshot' :: Maybe Bool
useLatestRestorableAutoSnapshot = Maybe Bool
a} :: CopySnapshot)

-- | The name of the new manual snapshot to be created as a copy.
copySnapshot_targetSnapshotName :: Lens.Lens' CopySnapshot Prelude.Text
copySnapshot_targetSnapshotName :: Lens' CopySnapshot Text
copySnapshot_targetSnapshotName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CopySnapshot' {Text
targetSnapshotName :: Text
$sel:targetSnapshotName:CopySnapshot' :: CopySnapshot -> Text
targetSnapshotName} -> Text
targetSnapshotName) (\s :: CopySnapshot
s@CopySnapshot' {} Text
a -> CopySnapshot
s {$sel:targetSnapshotName:CopySnapshot' :: Text
targetSnapshotName = Text
a} :: CopySnapshot)

-- | The Amazon Web Services Region where the source manual or automatic
-- snapshot is located.
copySnapshot_sourceRegion :: Lens.Lens' CopySnapshot RegionName
copySnapshot_sourceRegion :: Lens' CopySnapshot RegionName
copySnapshot_sourceRegion = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CopySnapshot' {RegionName
sourceRegion :: RegionName
$sel:sourceRegion:CopySnapshot' :: CopySnapshot -> RegionName
sourceRegion} -> RegionName
sourceRegion) (\s :: CopySnapshot
s@CopySnapshot' {} RegionName
a -> CopySnapshot
s {$sel:sourceRegion:CopySnapshot' :: RegionName
sourceRegion = RegionName
a} :: CopySnapshot)

instance Core.AWSRequest CopySnapshot where
  type AWSResponse CopySnapshot = CopySnapshotResponse
  request :: (Service -> Service) -> CopySnapshot -> Request CopySnapshot
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 CopySnapshot
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CopySnapshot)))
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 -> CopySnapshotResponse
CopySnapshotResponse'
            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 CopySnapshot where
  hashWithSalt :: Int -> CopySnapshot -> Int
hashWithSalt Int
_salt CopySnapshot' {Maybe Bool
Maybe Text
Text
RegionName
sourceRegion :: RegionName
targetSnapshotName :: Text
useLatestRestorableAutoSnapshot :: Maybe Bool
sourceSnapshotName :: Maybe Text
sourceResourceName :: Maybe Text
restoreDate :: Maybe Text
$sel:sourceRegion:CopySnapshot' :: CopySnapshot -> RegionName
$sel:targetSnapshotName:CopySnapshot' :: CopySnapshot -> Text
$sel:useLatestRestorableAutoSnapshot:CopySnapshot' :: CopySnapshot -> Maybe Bool
$sel:sourceSnapshotName:CopySnapshot' :: CopySnapshot -> Maybe Text
$sel:sourceResourceName:CopySnapshot' :: CopySnapshot -> Maybe Text
$sel:restoreDate:CopySnapshot' :: CopySnapshot -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
restoreDate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
sourceResourceName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
sourceSnapshotName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
useLatestRestorableAutoSnapshot
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
targetSnapshotName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` RegionName
sourceRegion

instance Prelude.NFData CopySnapshot where
  rnf :: CopySnapshot -> ()
rnf CopySnapshot' {Maybe Bool
Maybe Text
Text
RegionName
sourceRegion :: RegionName
targetSnapshotName :: Text
useLatestRestorableAutoSnapshot :: Maybe Bool
sourceSnapshotName :: Maybe Text
sourceResourceName :: Maybe Text
restoreDate :: Maybe Text
$sel:sourceRegion:CopySnapshot' :: CopySnapshot -> RegionName
$sel:targetSnapshotName:CopySnapshot' :: CopySnapshot -> Text
$sel:useLatestRestorableAutoSnapshot:CopySnapshot' :: CopySnapshot -> Maybe Bool
$sel:sourceSnapshotName:CopySnapshot' :: CopySnapshot -> Maybe Text
$sel:sourceResourceName:CopySnapshot' :: CopySnapshot -> Maybe Text
$sel:restoreDate:CopySnapshot' :: CopySnapshot -> Maybe Text
..} =
    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
sourceResourceName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
sourceSnapshotName
      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
targetSnapshotName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf RegionName
sourceRegion

instance Data.ToHeaders CopySnapshot where
  toHeaders :: CopySnapshot -> 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.CopySnapshot" ::
                          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 CopySnapshot where
  toJSON :: CopySnapshot -> Value
toJSON CopySnapshot' {Maybe Bool
Maybe Text
Text
RegionName
sourceRegion :: RegionName
targetSnapshotName :: Text
useLatestRestorableAutoSnapshot :: Maybe Bool
sourceSnapshotName :: Maybe Text
sourceResourceName :: Maybe Text
restoreDate :: Maybe Text
$sel:sourceRegion:CopySnapshot' :: CopySnapshot -> RegionName
$sel:targetSnapshotName:CopySnapshot' :: CopySnapshot -> Text
$sel:useLatestRestorableAutoSnapshot:CopySnapshot' :: CopySnapshot -> Maybe Bool
$sel:sourceSnapshotName:CopySnapshot' :: CopySnapshot -> Maybe Text
$sel:sourceResourceName:CopySnapshot' :: CopySnapshot -> Maybe Text
$sel:restoreDate:CopySnapshot' :: CopySnapshot -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (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
"sourceResourceName" 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
sourceResourceName,
            (Key
"sourceSnapshotName" 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
sourceSnapshotName,
            (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
"targetSnapshotName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
targetSnapshotName),
            forall a. a -> Maybe a
Prelude.Just (Key
"sourceRegion" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= RegionName
sourceRegion)
          ]
      )

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

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

-- | /See:/ 'newCopySnapshotResponse' smart constructor.
data CopySnapshotResponse = CopySnapshotResponse'
  { -- | 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.
    CopySnapshotResponse -> Maybe [Operation]
operations :: Prelude.Maybe [Operation],
    -- | The response's http status code.
    CopySnapshotResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CopySnapshotResponse -> CopySnapshotResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CopySnapshotResponse -> CopySnapshotResponse -> Bool
$c/= :: CopySnapshotResponse -> CopySnapshotResponse -> Bool
== :: CopySnapshotResponse -> CopySnapshotResponse -> Bool
$c== :: CopySnapshotResponse -> CopySnapshotResponse -> Bool
Prelude.Eq, ReadPrec [CopySnapshotResponse]
ReadPrec CopySnapshotResponse
Int -> ReadS CopySnapshotResponse
ReadS [CopySnapshotResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CopySnapshotResponse]
$creadListPrec :: ReadPrec [CopySnapshotResponse]
readPrec :: ReadPrec CopySnapshotResponse
$creadPrec :: ReadPrec CopySnapshotResponse
readList :: ReadS [CopySnapshotResponse]
$creadList :: ReadS [CopySnapshotResponse]
readsPrec :: Int -> ReadS CopySnapshotResponse
$creadsPrec :: Int -> ReadS CopySnapshotResponse
Prelude.Read, Int -> CopySnapshotResponse -> ShowS
[CopySnapshotResponse] -> ShowS
CopySnapshotResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CopySnapshotResponse] -> ShowS
$cshowList :: [CopySnapshotResponse] -> ShowS
show :: CopySnapshotResponse -> String
$cshow :: CopySnapshotResponse -> String
showsPrec :: Int -> CopySnapshotResponse -> ShowS
$cshowsPrec :: Int -> CopySnapshotResponse -> ShowS
Prelude.Show, forall x. Rep CopySnapshotResponse x -> CopySnapshotResponse
forall x. CopySnapshotResponse -> Rep CopySnapshotResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CopySnapshotResponse x -> CopySnapshotResponse
$cfrom :: forall x. CopySnapshotResponse -> Rep CopySnapshotResponse x
Prelude.Generic)

-- |
-- Create a value of 'CopySnapshotResponse' 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', 'copySnapshotResponse_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', 'copySnapshotResponse_httpStatus' - The response's http status code.
newCopySnapshotResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CopySnapshotResponse
newCopySnapshotResponse :: Int -> CopySnapshotResponse
newCopySnapshotResponse Int
pHttpStatus_ =
  CopySnapshotResponse'
    { $sel:operations:CopySnapshotResponse' :: Maybe [Operation]
operations = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CopySnapshotResponse' :: 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.
copySnapshotResponse_operations :: Lens.Lens' CopySnapshotResponse (Prelude.Maybe [Operation])
copySnapshotResponse_operations :: Lens' CopySnapshotResponse (Maybe [Operation])
copySnapshotResponse_operations = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CopySnapshotResponse' {Maybe [Operation]
operations :: Maybe [Operation]
$sel:operations:CopySnapshotResponse' :: CopySnapshotResponse -> Maybe [Operation]
operations} -> Maybe [Operation]
operations) (\s :: CopySnapshotResponse
s@CopySnapshotResponse' {} Maybe [Operation]
a -> CopySnapshotResponse
s {$sel:operations:CopySnapshotResponse' :: Maybe [Operation]
operations = Maybe [Operation]
a} :: CopySnapshotResponse) 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.
copySnapshotResponse_httpStatus :: Lens.Lens' CopySnapshotResponse Prelude.Int
copySnapshotResponse_httpStatus :: Lens' CopySnapshotResponse Int
copySnapshotResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CopySnapshotResponse' {Int
httpStatus :: Int
$sel:httpStatus:CopySnapshotResponse' :: CopySnapshotResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CopySnapshotResponse
s@CopySnapshotResponse' {} Int
a -> CopySnapshotResponse
s {$sel:httpStatus:CopySnapshotResponse' :: Int
httpStatus = Int
a} :: CopySnapshotResponse)

instance Prelude.NFData CopySnapshotResponse where
  rnf :: CopySnapshotResponse -> ()
rnf CopySnapshotResponse' {Int
Maybe [Operation]
httpStatus :: Int
operations :: Maybe [Operation]
$sel:httpStatus:CopySnapshotResponse' :: CopySnapshotResponse -> Int
$sel:operations:CopySnapshotResponse' :: CopySnapshotResponse -> 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