{-# 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.MGN.GetReplicationConfiguration
-- 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)
--
-- Lists all ReplicationConfigurations, filtered by Source Server ID.
module Amazonka.MGN.GetReplicationConfiguration
  ( -- * Creating a Request
    GetReplicationConfiguration (..),
    newGetReplicationConfiguration,

    -- * Request Lenses
    getReplicationConfiguration_sourceServerID,

    -- * Destructuring the Response
    ReplicationConfiguration (..),
    newReplicationConfiguration,

    -- * Response Lenses
    replicationConfiguration_createPublicIP,
    replicationConfiguration_stagingAreaTags,
    replicationConfiguration_stagingAreaSubnetId,
    replicationConfiguration_replicationServerInstanceType,
    replicationConfiguration_ebsEncryption,
    replicationConfiguration_associateDefaultSecurityGroup,
    replicationConfiguration_replicationServersSecurityGroupsIDs,
    replicationConfiguration_ebsEncryptionKeyArn,
    replicationConfiguration_name,
    replicationConfiguration_defaultLargeStagingDiskType,
    replicationConfiguration_bandwidthThrottling,
    replicationConfiguration_dataPlaneRouting,
    replicationConfiguration_sourceServerID,
    replicationConfiguration_replicatedDisks,
    replicationConfiguration_useDedicatedReplicationServer,
  )
where

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

-- | /See:/ 'newGetReplicationConfiguration' smart constructor.
data GetReplicationConfiguration = GetReplicationConfiguration'
  { -- | Request to get Replication Configuaration by Source Server ID.
    GetReplicationConfiguration -> Text
sourceServerID :: Prelude.Text
  }
  deriving (GetReplicationConfiguration -> GetReplicationConfiguration -> Bool
(GetReplicationConfiguration
 -> GetReplicationConfiguration -> Bool)
-> (GetReplicationConfiguration
    -> GetReplicationConfiguration -> Bool)
-> Eq GetReplicationConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetReplicationConfiguration -> GetReplicationConfiguration -> Bool
$c/= :: GetReplicationConfiguration -> GetReplicationConfiguration -> Bool
== :: GetReplicationConfiguration -> GetReplicationConfiguration -> Bool
$c== :: GetReplicationConfiguration -> GetReplicationConfiguration -> Bool
Prelude.Eq, ReadPrec [GetReplicationConfiguration]
ReadPrec GetReplicationConfiguration
Int -> ReadS GetReplicationConfiguration
ReadS [GetReplicationConfiguration]
(Int -> ReadS GetReplicationConfiguration)
-> ReadS [GetReplicationConfiguration]
-> ReadPrec GetReplicationConfiguration
-> ReadPrec [GetReplicationConfiguration]
-> Read GetReplicationConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetReplicationConfiguration]
$creadListPrec :: ReadPrec [GetReplicationConfiguration]
readPrec :: ReadPrec GetReplicationConfiguration
$creadPrec :: ReadPrec GetReplicationConfiguration
readList :: ReadS [GetReplicationConfiguration]
$creadList :: ReadS [GetReplicationConfiguration]
readsPrec :: Int -> ReadS GetReplicationConfiguration
$creadsPrec :: Int -> ReadS GetReplicationConfiguration
Prelude.Read, Int -> GetReplicationConfiguration -> ShowS
[GetReplicationConfiguration] -> ShowS
GetReplicationConfiguration -> String
(Int -> GetReplicationConfiguration -> ShowS)
-> (GetReplicationConfiguration -> String)
-> ([GetReplicationConfiguration] -> ShowS)
-> Show GetReplicationConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetReplicationConfiguration] -> ShowS
$cshowList :: [GetReplicationConfiguration] -> ShowS
show :: GetReplicationConfiguration -> String
$cshow :: GetReplicationConfiguration -> String
showsPrec :: Int -> GetReplicationConfiguration -> ShowS
$cshowsPrec :: Int -> GetReplicationConfiguration -> ShowS
Prelude.Show, (forall x.
 GetReplicationConfiguration -> Rep GetReplicationConfiguration x)
-> (forall x.
    Rep GetReplicationConfiguration x -> GetReplicationConfiguration)
-> Generic GetReplicationConfiguration
forall x.
Rep GetReplicationConfiguration x -> GetReplicationConfiguration
forall x.
GetReplicationConfiguration -> Rep GetReplicationConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetReplicationConfiguration x -> GetReplicationConfiguration
$cfrom :: forall x.
GetReplicationConfiguration -> Rep GetReplicationConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'GetReplicationConfiguration' 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:
--
-- 'sourceServerID', 'getReplicationConfiguration_sourceServerID' - Request to get Replication Configuaration by Source Server ID.
newGetReplicationConfiguration ::
  -- | 'sourceServerID'
  Prelude.Text ->
  GetReplicationConfiguration
newGetReplicationConfiguration :: Text -> GetReplicationConfiguration
newGetReplicationConfiguration Text
pSourceServerID_ =
  GetReplicationConfiguration' :: Text -> GetReplicationConfiguration
GetReplicationConfiguration'
    { $sel:sourceServerID:GetReplicationConfiguration' :: Text
sourceServerID =
        Text
pSourceServerID_
    }

-- | Request to get Replication Configuaration by Source Server ID.
getReplicationConfiguration_sourceServerID :: Lens.Lens' GetReplicationConfiguration Prelude.Text
getReplicationConfiguration_sourceServerID :: (Text -> f Text)
-> GetReplicationConfiguration -> f GetReplicationConfiguration
getReplicationConfiguration_sourceServerID = (GetReplicationConfiguration -> Text)
-> (GetReplicationConfiguration
    -> Text -> GetReplicationConfiguration)
-> Lens
     GetReplicationConfiguration GetReplicationConfiguration Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetReplicationConfiguration' {Text
sourceServerID :: Text
$sel:sourceServerID:GetReplicationConfiguration' :: GetReplicationConfiguration -> Text
sourceServerID} -> Text
sourceServerID) (\s :: GetReplicationConfiguration
s@GetReplicationConfiguration' {} Text
a -> GetReplicationConfiguration
s {$sel:sourceServerID:GetReplicationConfiguration' :: Text
sourceServerID = Text
a} :: GetReplicationConfiguration)

instance Core.AWSRequest GetReplicationConfiguration where
  type
    AWSResponse GetReplicationConfiguration =
      ReplicationConfiguration
  request :: GetReplicationConfiguration -> Request GetReplicationConfiguration
request = Service
-> GetReplicationConfiguration
-> Request GetReplicationConfiguration
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetReplicationConfiguration
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetReplicationConfiguration)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetReplicationConfiguration))
-> Logger
-> Service
-> Proxy GetReplicationConfiguration
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetReplicationConfiguration)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      (\Int
s ResponseHeaders
h Object
x -> Object -> Either String ReplicationConfiguration
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)

instance Prelude.Hashable GetReplicationConfiguration

instance Prelude.NFData GetReplicationConfiguration

instance Core.ToHeaders GetReplicationConfiguration where
  toHeaders :: GetReplicationConfiguration -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetReplicationConfiguration -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON GetReplicationConfiguration where
  toJSON :: GetReplicationConfiguration -> Value
toJSON GetReplicationConfiguration' {Text
sourceServerID :: Text
$sel:sourceServerID:GetReplicationConfiguration' :: GetReplicationConfiguration -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"sourceServerID" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
sourceServerID)
          ]
      )

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

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