{-# 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.ElastiCache.StartMigration
-- 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)
--
-- Start the migration of data.
module Amazonka.ElastiCache.StartMigration
  ( -- * Creating a Request
    StartMigration (..),
    newStartMigration,

    -- * Request Lenses
    startMigration_replicationGroupId,
    startMigration_customerNodeEndpointList,

    -- * Destructuring the Response
    StartMigrationResponse (..),
    newStartMigrationResponse,

    -- * Response Lenses
    startMigrationResponse_replicationGroup,
    startMigrationResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.ElastiCache.Types
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newStartMigration' smart constructor.
data StartMigration = StartMigration'
  { -- | The ID of the replication group to which data should be migrated.
    StartMigration -> Text
replicationGroupId :: Prelude.Text,
    -- | List of endpoints from which data should be migrated. For Redis (cluster
    -- mode disabled), list should have only one element.
    StartMigration -> [CustomerNodeEndpoint]
customerNodeEndpointList :: [CustomerNodeEndpoint]
  }
  deriving (StartMigration -> StartMigration -> Bool
(StartMigration -> StartMigration -> Bool)
-> (StartMigration -> StartMigration -> Bool) -> Eq StartMigration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StartMigration -> StartMigration -> Bool
$c/= :: StartMigration -> StartMigration -> Bool
== :: StartMigration -> StartMigration -> Bool
$c== :: StartMigration -> StartMigration -> Bool
Prelude.Eq, ReadPrec [StartMigration]
ReadPrec StartMigration
Int -> ReadS StartMigration
ReadS [StartMigration]
(Int -> ReadS StartMigration)
-> ReadS [StartMigration]
-> ReadPrec StartMigration
-> ReadPrec [StartMigration]
-> Read StartMigration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StartMigration]
$creadListPrec :: ReadPrec [StartMigration]
readPrec :: ReadPrec StartMigration
$creadPrec :: ReadPrec StartMigration
readList :: ReadS [StartMigration]
$creadList :: ReadS [StartMigration]
readsPrec :: Int -> ReadS StartMigration
$creadsPrec :: Int -> ReadS StartMigration
Prelude.Read, Int -> StartMigration -> ShowS
[StartMigration] -> ShowS
StartMigration -> String
(Int -> StartMigration -> ShowS)
-> (StartMigration -> String)
-> ([StartMigration] -> ShowS)
-> Show StartMigration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StartMigration] -> ShowS
$cshowList :: [StartMigration] -> ShowS
show :: StartMigration -> String
$cshow :: StartMigration -> String
showsPrec :: Int -> StartMigration -> ShowS
$cshowsPrec :: Int -> StartMigration -> ShowS
Prelude.Show, (forall x. StartMigration -> Rep StartMigration x)
-> (forall x. Rep StartMigration x -> StartMigration)
-> Generic StartMigration
forall x. Rep StartMigration x -> StartMigration
forall x. StartMigration -> Rep StartMigration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StartMigration x -> StartMigration
$cfrom :: forall x. StartMigration -> Rep StartMigration x
Prelude.Generic)

-- |
-- Create a value of 'StartMigration' 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:
--
-- 'replicationGroupId', 'startMigration_replicationGroupId' - The ID of the replication group to which data should be migrated.
--
-- 'customerNodeEndpointList', 'startMigration_customerNodeEndpointList' - List of endpoints from which data should be migrated. For Redis (cluster
-- mode disabled), list should have only one element.
newStartMigration ::
  -- | 'replicationGroupId'
  Prelude.Text ->
  StartMigration
newStartMigration :: Text -> StartMigration
newStartMigration Text
pReplicationGroupId_ =
  StartMigration' :: Text -> [CustomerNodeEndpoint] -> StartMigration
StartMigration'
    { $sel:replicationGroupId:StartMigration' :: Text
replicationGroupId =
        Text
pReplicationGroupId_,
      $sel:customerNodeEndpointList:StartMigration' :: [CustomerNodeEndpoint]
customerNodeEndpointList = [CustomerNodeEndpoint]
forall a. Monoid a => a
Prelude.mempty
    }

-- | The ID of the replication group to which data should be migrated.
startMigration_replicationGroupId :: Lens.Lens' StartMigration Prelude.Text
startMigration_replicationGroupId :: (Text -> f Text) -> StartMigration -> f StartMigration
startMigration_replicationGroupId = (StartMigration -> Text)
-> (StartMigration -> Text -> StartMigration)
-> Lens StartMigration StartMigration Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartMigration' {Text
replicationGroupId :: Text
$sel:replicationGroupId:StartMigration' :: StartMigration -> Text
replicationGroupId} -> Text
replicationGroupId) (\s :: StartMigration
s@StartMigration' {} Text
a -> StartMigration
s {$sel:replicationGroupId:StartMigration' :: Text
replicationGroupId = Text
a} :: StartMigration)

-- | List of endpoints from which data should be migrated. For Redis (cluster
-- mode disabled), list should have only one element.
startMigration_customerNodeEndpointList :: Lens.Lens' StartMigration [CustomerNodeEndpoint]
startMigration_customerNodeEndpointList :: ([CustomerNodeEndpoint] -> f [CustomerNodeEndpoint])
-> StartMigration -> f StartMigration
startMigration_customerNodeEndpointList = (StartMigration -> [CustomerNodeEndpoint])
-> (StartMigration -> [CustomerNodeEndpoint] -> StartMigration)
-> Lens
     StartMigration
     StartMigration
     [CustomerNodeEndpoint]
     [CustomerNodeEndpoint]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartMigration' {[CustomerNodeEndpoint]
customerNodeEndpointList :: [CustomerNodeEndpoint]
$sel:customerNodeEndpointList:StartMigration' :: StartMigration -> [CustomerNodeEndpoint]
customerNodeEndpointList} -> [CustomerNodeEndpoint]
customerNodeEndpointList) (\s :: StartMigration
s@StartMigration' {} [CustomerNodeEndpoint]
a -> StartMigration
s {$sel:customerNodeEndpointList:StartMigration' :: [CustomerNodeEndpoint]
customerNodeEndpointList = [CustomerNodeEndpoint]
a} :: StartMigration) (([CustomerNodeEndpoint] -> f [CustomerNodeEndpoint])
 -> StartMigration -> f StartMigration)
-> (([CustomerNodeEndpoint] -> f [CustomerNodeEndpoint])
    -> [CustomerNodeEndpoint] -> f [CustomerNodeEndpoint])
-> ([CustomerNodeEndpoint] -> f [CustomerNodeEndpoint])
-> StartMigration
-> f StartMigration
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([CustomerNodeEndpoint] -> f [CustomerNodeEndpoint])
-> [CustomerNodeEndpoint] -> f [CustomerNodeEndpoint]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest StartMigration where
  type
    AWSResponse StartMigration =
      StartMigrationResponse
  request :: StartMigration -> Request StartMigration
request = Service -> StartMigration -> Request StartMigration
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy StartMigration
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse StartMigration)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse StartMigration))
-> Logger
-> Service
-> Proxy StartMigration
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse StartMigration)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"StartMigrationResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe ReplicationGroup -> Int -> StartMigrationResponse
StartMigrationResponse'
            (Maybe ReplicationGroup -> Int -> StartMigrationResponse)
-> Either String (Maybe ReplicationGroup)
-> Either String (Int -> StartMigrationResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe ReplicationGroup)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"ReplicationGroup")
            Either String (Int -> StartMigrationResponse)
-> Either String Int -> Either String StartMigrationResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable StartMigration

instance Prelude.NFData StartMigration

instance Core.ToHeaders StartMigration where
  toHeaders :: StartMigration -> ResponseHeaders
toHeaders = ResponseHeaders -> StartMigration -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

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

instance Core.ToQuery StartMigration where
  toQuery :: StartMigration -> QueryString
toQuery StartMigration' {[CustomerNodeEndpoint]
Text
customerNodeEndpointList :: [CustomerNodeEndpoint]
replicationGroupId :: Text
$sel:customerNodeEndpointList:StartMigration' :: StartMigration -> [CustomerNodeEndpoint]
$sel:replicationGroupId:StartMigration' :: StartMigration -> Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"StartMigration" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2015-02-02" :: Prelude.ByteString),
        ByteString
"ReplicationGroupId" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
replicationGroupId,
        ByteString
"CustomerNodeEndpointList"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: ByteString -> [CustomerNodeEndpoint] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"member" [CustomerNodeEndpoint]
customerNodeEndpointList
      ]

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

-- |
-- Create a value of 'StartMigrationResponse' 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:
--
-- 'replicationGroup', 'startMigrationResponse_replicationGroup' - Undocumented member.
--
-- 'httpStatus', 'startMigrationResponse_httpStatus' - The response's http status code.
newStartMigrationResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  StartMigrationResponse
newStartMigrationResponse :: Int -> StartMigrationResponse
newStartMigrationResponse Int
pHttpStatus_ =
  StartMigrationResponse' :: Maybe ReplicationGroup -> Int -> StartMigrationResponse
StartMigrationResponse'
    { $sel:replicationGroup:StartMigrationResponse' :: Maybe ReplicationGroup
replicationGroup =
        Maybe ReplicationGroup
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:StartMigrationResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Undocumented member.
startMigrationResponse_replicationGroup :: Lens.Lens' StartMigrationResponse (Prelude.Maybe ReplicationGroup)
startMigrationResponse_replicationGroup :: (Maybe ReplicationGroup -> f (Maybe ReplicationGroup))
-> StartMigrationResponse -> f StartMigrationResponse
startMigrationResponse_replicationGroup = (StartMigrationResponse -> Maybe ReplicationGroup)
-> (StartMigrationResponse
    -> Maybe ReplicationGroup -> StartMigrationResponse)
-> Lens
     StartMigrationResponse
     StartMigrationResponse
     (Maybe ReplicationGroup)
     (Maybe ReplicationGroup)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartMigrationResponse' {Maybe ReplicationGroup
replicationGroup :: Maybe ReplicationGroup
$sel:replicationGroup:StartMigrationResponse' :: StartMigrationResponse -> Maybe ReplicationGroup
replicationGroup} -> Maybe ReplicationGroup
replicationGroup) (\s :: StartMigrationResponse
s@StartMigrationResponse' {} Maybe ReplicationGroup
a -> StartMigrationResponse
s {$sel:replicationGroup:StartMigrationResponse' :: Maybe ReplicationGroup
replicationGroup = Maybe ReplicationGroup
a} :: StartMigrationResponse)

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

instance Prelude.NFData StartMigrationResponse