{-# 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.SMS.GetAppReplicationConfiguration
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Retrieves the application replication configuration associated with the
-- specified application.
module Amazonka.SMS.GetAppReplicationConfiguration
  ( -- * Creating a Request
    GetAppReplicationConfiguration (..),
    newGetAppReplicationConfiguration,

    -- * Request Lenses
    getAppReplicationConfiguration_appId,

    -- * Destructuring the Response
    GetAppReplicationConfigurationResponse (..),
    newGetAppReplicationConfigurationResponse,

    -- * Response Lenses
    getAppReplicationConfigurationResponse_serverGroupReplicationConfigurations,
    getAppReplicationConfigurationResponse_httpStatus,
  )
where

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

-- | /See:/ 'newGetAppReplicationConfiguration' smart constructor.
data GetAppReplicationConfiguration = GetAppReplicationConfiguration'
  { -- | The ID of the application.
    GetAppReplicationConfiguration -> Maybe Text
appId :: Prelude.Maybe Prelude.Text
  }
  deriving (GetAppReplicationConfiguration
-> GetAppReplicationConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetAppReplicationConfiguration
-> GetAppReplicationConfiguration -> Bool
$c/= :: GetAppReplicationConfiguration
-> GetAppReplicationConfiguration -> Bool
== :: GetAppReplicationConfiguration
-> GetAppReplicationConfiguration -> Bool
$c== :: GetAppReplicationConfiguration
-> GetAppReplicationConfiguration -> Bool
Prelude.Eq, ReadPrec [GetAppReplicationConfiguration]
ReadPrec GetAppReplicationConfiguration
Int -> ReadS GetAppReplicationConfiguration
ReadS [GetAppReplicationConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetAppReplicationConfiguration]
$creadListPrec :: ReadPrec [GetAppReplicationConfiguration]
readPrec :: ReadPrec GetAppReplicationConfiguration
$creadPrec :: ReadPrec GetAppReplicationConfiguration
readList :: ReadS [GetAppReplicationConfiguration]
$creadList :: ReadS [GetAppReplicationConfiguration]
readsPrec :: Int -> ReadS GetAppReplicationConfiguration
$creadsPrec :: Int -> ReadS GetAppReplicationConfiguration
Prelude.Read, Int -> GetAppReplicationConfiguration -> ShowS
[GetAppReplicationConfiguration] -> ShowS
GetAppReplicationConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetAppReplicationConfiguration] -> ShowS
$cshowList :: [GetAppReplicationConfiguration] -> ShowS
show :: GetAppReplicationConfiguration -> String
$cshow :: GetAppReplicationConfiguration -> String
showsPrec :: Int -> GetAppReplicationConfiguration -> ShowS
$cshowsPrec :: Int -> GetAppReplicationConfiguration -> ShowS
Prelude.Show, forall x.
Rep GetAppReplicationConfiguration x
-> GetAppReplicationConfiguration
forall x.
GetAppReplicationConfiguration
-> Rep GetAppReplicationConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetAppReplicationConfiguration x
-> GetAppReplicationConfiguration
$cfrom :: forall x.
GetAppReplicationConfiguration
-> Rep GetAppReplicationConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'GetAppReplicationConfiguration' 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:
--
-- 'appId', 'getAppReplicationConfiguration_appId' - The ID of the application.
newGetAppReplicationConfiguration ::
  GetAppReplicationConfiguration
newGetAppReplicationConfiguration :: GetAppReplicationConfiguration
newGetAppReplicationConfiguration =
  GetAppReplicationConfiguration'
    { $sel:appId:GetAppReplicationConfiguration' :: Maybe Text
appId =
        forall a. Maybe a
Prelude.Nothing
    }

-- | The ID of the application.
getAppReplicationConfiguration_appId :: Lens.Lens' GetAppReplicationConfiguration (Prelude.Maybe Prelude.Text)
getAppReplicationConfiguration_appId :: Lens' GetAppReplicationConfiguration (Maybe Text)
getAppReplicationConfiguration_appId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetAppReplicationConfiguration' {Maybe Text
appId :: Maybe Text
$sel:appId:GetAppReplicationConfiguration' :: GetAppReplicationConfiguration -> Maybe Text
appId} -> Maybe Text
appId) (\s :: GetAppReplicationConfiguration
s@GetAppReplicationConfiguration' {} Maybe Text
a -> GetAppReplicationConfiguration
s {$sel:appId:GetAppReplicationConfiguration' :: Maybe Text
appId = Maybe Text
a} :: GetAppReplicationConfiguration)

instance
  Core.AWSRequest
    GetAppReplicationConfiguration
  where
  type
    AWSResponse GetAppReplicationConfiguration =
      GetAppReplicationConfigurationResponse
  request :: (Service -> Service)
-> GetAppReplicationConfiguration
-> Request GetAppReplicationConfiguration
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 GetAppReplicationConfiguration
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse GetAppReplicationConfiguration)))
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 [ServerGroupReplicationConfiguration]
-> Int -> GetAppReplicationConfigurationResponse
GetAppReplicationConfigurationResponse'
            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
"serverGroupReplicationConfigurations"
                            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
    GetAppReplicationConfiguration
  where
  hashWithSalt :: Int -> GetAppReplicationConfiguration -> Int
hashWithSalt
    Int
_salt
    GetAppReplicationConfiguration' {Maybe Text
appId :: Maybe Text
$sel:appId:GetAppReplicationConfiguration' :: GetAppReplicationConfiguration -> Maybe Text
..} =
      Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
appId

instance
  Prelude.NFData
    GetAppReplicationConfiguration
  where
  rnf :: GetAppReplicationConfiguration -> ()
rnf GetAppReplicationConfiguration' {Maybe Text
appId :: Maybe Text
$sel:appId:GetAppReplicationConfiguration' :: GetAppReplicationConfiguration -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
appId

instance
  Data.ToHeaders
    GetAppReplicationConfiguration
  where
  toHeaders :: GetAppReplicationConfiguration -> 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
"AWSServerMigrationService_V2016_10_24.GetAppReplicationConfiguration" ::
                          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 GetAppReplicationConfiguration where
  toJSON :: GetAppReplicationConfiguration -> Value
toJSON GetAppReplicationConfiguration' {Maybe Text
appId :: Maybe Text
$sel:appId:GetAppReplicationConfiguration' :: GetAppReplicationConfiguration -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Key
"appId" 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
appId]
      )

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

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

-- | /See:/ 'newGetAppReplicationConfigurationResponse' smart constructor.
data GetAppReplicationConfigurationResponse = GetAppReplicationConfigurationResponse'
  { -- | The replication configurations associated with server groups in this
    -- application.
    GetAppReplicationConfigurationResponse
-> Maybe [ServerGroupReplicationConfiguration]
serverGroupReplicationConfigurations :: Prelude.Maybe [ServerGroupReplicationConfiguration],
    -- | The response's http status code.
    GetAppReplicationConfigurationResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetAppReplicationConfigurationResponse
-> GetAppReplicationConfigurationResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetAppReplicationConfigurationResponse
-> GetAppReplicationConfigurationResponse -> Bool
$c/= :: GetAppReplicationConfigurationResponse
-> GetAppReplicationConfigurationResponse -> Bool
== :: GetAppReplicationConfigurationResponse
-> GetAppReplicationConfigurationResponse -> Bool
$c== :: GetAppReplicationConfigurationResponse
-> GetAppReplicationConfigurationResponse -> Bool
Prelude.Eq, ReadPrec [GetAppReplicationConfigurationResponse]
ReadPrec GetAppReplicationConfigurationResponse
Int -> ReadS GetAppReplicationConfigurationResponse
ReadS [GetAppReplicationConfigurationResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetAppReplicationConfigurationResponse]
$creadListPrec :: ReadPrec [GetAppReplicationConfigurationResponse]
readPrec :: ReadPrec GetAppReplicationConfigurationResponse
$creadPrec :: ReadPrec GetAppReplicationConfigurationResponse
readList :: ReadS [GetAppReplicationConfigurationResponse]
$creadList :: ReadS [GetAppReplicationConfigurationResponse]
readsPrec :: Int -> ReadS GetAppReplicationConfigurationResponse
$creadsPrec :: Int -> ReadS GetAppReplicationConfigurationResponse
Prelude.Read, Int -> GetAppReplicationConfigurationResponse -> ShowS
[GetAppReplicationConfigurationResponse] -> ShowS
GetAppReplicationConfigurationResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetAppReplicationConfigurationResponse] -> ShowS
$cshowList :: [GetAppReplicationConfigurationResponse] -> ShowS
show :: GetAppReplicationConfigurationResponse -> String
$cshow :: GetAppReplicationConfigurationResponse -> String
showsPrec :: Int -> GetAppReplicationConfigurationResponse -> ShowS
$cshowsPrec :: Int -> GetAppReplicationConfigurationResponse -> ShowS
Prelude.Show, forall x.
Rep GetAppReplicationConfigurationResponse x
-> GetAppReplicationConfigurationResponse
forall x.
GetAppReplicationConfigurationResponse
-> Rep GetAppReplicationConfigurationResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetAppReplicationConfigurationResponse x
-> GetAppReplicationConfigurationResponse
$cfrom :: forall x.
GetAppReplicationConfigurationResponse
-> Rep GetAppReplicationConfigurationResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetAppReplicationConfigurationResponse' 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:
--
-- 'serverGroupReplicationConfigurations', 'getAppReplicationConfigurationResponse_serverGroupReplicationConfigurations' - The replication configurations associated with server groups in this
-- application.
--
-- 'httpStatus', 'getAppReplicationConfigurationResponse_httpStatus' - The response's http status code.
newGetAppReplicationConfigurationResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetAppReplicationConfigurationResponse
newGetAppReplicationConfigurationResponse :: Int -> GetAppReplicationConfigurationResponse
newGetAppReplicationConfigurationResponse
  Int
pHttpStatus_ =
    GetAppReplicationConfigurationResponse'
      { $sel:serverGroupReplicationConfigurations:GetAppReplicationConfigurationResponse' :: Maybe [ServerGroupReplicationConfiguration]
serverGroupReplicationConfigurations =
          forall a. Maybe a
Prelude.Nothing,
        $sel:httpStatus:GetAppReplicationConfigurationResponse' :: Int
httpStatus = Int
pHttpStatus_
      }

-- | The replication configurations associated with server groups in this
-- application.
getAppReplicationConfigurationResponse_serverGroupReplicationConfigurations :: Lens.Lens' GetAppReplicationConfigurationResponse (Prelude.Maybe [ServerGroupReplicationConfiguration])
getAppReplicationConfigurationResponse_serverGroupReplicationConfigurations :: Lens'
  GetAppReplicationConfigurationResponse
  (Maybe [ServerGroupReplicationConfiguration])
getAppReplicationConfigurationResponse_serverGroupReplicationConfigurations = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetAppReplicationConfigurationResponse' {Maybe [ServerGroupReplicationConfiguration]
serverGroupReplicationConfigurations :: Maybe [ServerGroupReplicationConfiguration]
$sel:serverGroupReplicationConfigurations:GetAppReplicationConfigurationResponse' :: GetAppReplicationConfigurationResponse
-> Maybe [ServerGroupReplicationConfiguration]
serverGroupReplicationConfigurations} -> Maybe [ServerGroupReplicationConfiguration]
serverGroupReplicationConfigurations) (\s :: GetAppReplicationConfigurationResponse
s@GetAppReplicationConfigurationResponse' {} Maybe [ServerGroupReplicationConfiguration]
a -> GetAppReplicationConfigurationResponse
s {$sel:serverGroupReplicationConfigurations:GetAppReplicationConfigurationResponse' :: Maybe [ServerGroupReplicationConfiguration]
serverGroupReplicationConfigurations = Maybe [ServerGroupReplicationConfiguration]
a} :: GetAppReplicationConfigurationResponse) 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.
getAppReplicationConfigurationResponse_httpStatus :: Lens.Lens' GetAppReplicationConfigurationResponse Prelude.Int
getAppReplicationConfigurationResponse_httpStatus :: Lens' GetAppReplicationConfigurationResponse Int
getAppReplicationConfigurationResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetAppReplicationConfigurationResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetAppReplicationConfigurationResponse' :: GetAppReplicationConfigurationResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetAppReplicationConfigurationResponse
s@GetAppReplicationConfigurationResponse' {} Int
a -> GetAppReplicationConfigurationResponse
s {$sel:httpStatus:GetAppReplicationConfigurationResponse' :: Int
httpStatus = Int
a} :: GetAppReplicationConfigurationResponse)

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