{-# 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.DMS.RefreshSchemas
-- 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)
--
-- Populates the schema for the specified endpoint. This is an asynchronous
-- operation and can take several minutes. You can check the status of this
-- operation by calling the DescribeRefreshSchemasStatus operation.
module Amazonka.DMS.RefreshSchemas
  ( -- * Creating a Request
    RefreshSchemas (..),
    newRefreshSchemas,

    -- * Request Lenses
    refreshSchemas_endpointArn,
    refreshSchemas_replicationInstanceArn,

    -- * Destructuring the Response
    RefreshSchemasResponse (..),
    newRefreshSchemasResponse,

    -- * Response Lenses
    refreshSchemasResponse_refreshSchemasStatus,
    refreshSchemasResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.DMS.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:/ 'newRefreshSchemas' smart constructor.
data RefreshSchemas = RefreshSchemas'
  { -- | The Amazon Resource Name (ARN) string that uniquely identifies the
    -- endpoint.
    RefreshSchemas -> Text
endpointArn :: Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the replication instance.
    RefreshSchemas -> Text
replicationInstanceArn :: Prelude.Text
  }
  deriving (RefreshSchemas -> RefreshSchemas -> Bool
(RefreshSchemas -> RefreshSchemas -> Bool)
-> (RefreshSchemas -> RefreshSchemas -> Bool) -> Eq RefreshSchemas
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RefreshSchemas -> RefreshSchemas -> Bool
$c/= :: RefreshSchemas -> RefreshSchemas -> Bool
== :: RefreshSchemas -> RefreshSchemas -> Bool
$c== :: RefreshSchemas -> RefreshSchemas -> Bool
Prelude.Eq, ReadPrec [RefreshSchemas]
ReadPrec RefreshSchemas
Int -> ReadS RefreshSchemas
ReadS [RefreshSchemas]
(Int -> ReadS RefreshSchemas)
-> ReadS [RefreshSchemas]
-> ReadPrec RefreshSchemas
-> ReadPrec [RefreshSchemas]
-> Read RefreshSchemas
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RefreshSchemas]
$creadListPrec :: ReadPrec [RefreshSchemas]
readPrec :: ReadPrec RefreshSchemas
$creadPrec :: ReadPrec RefreshSchemas
readList :: ReadS [RefreshSchemas]
$creadList :: ReadS [RefreshSchemas]
readsPrec :: Int -> ReadS RefreshSchemas
$creadsPrec :: Int -> ReadS RefreshSchemas
Prelude.Read, Int -> RefreshSchemas -> ShowS
[RefreshSchemas] -> ShowS
RefreshSchemas -> String
(Int -> RefreshSchemas -> ShowS)
-> (RefreshSchemas -> String)
-> ([RefreshSchemas] -> ShowS)
-> Show RefreshSchemas
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RefreshSchemas] -> ShowS
$cshowList :: [RefreshSchemas] -> ShowS
show :: RefreshSchemas -> String
$cshow :: RefreshSchemas -> String
showsPrec :: Int -> RefreshSchemas -> ShowS
$cshowsPrec :: Int -> RefreshSchemas -> ShowS
Prelude.Show, (forall x. RefreshSchemas -> Rep RefreshSchemas x)
-> (forall x. Rep RefreshSchemas x -> RefreshSchemas)
-> Generic RefreshSchemas
forall x. Rep RefreshSchemas x -> RefreshSchemas
forall x. RefreshSchemas -> Rep RefreshSchemas x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RefreshSchemas x -> RefreshSchemas
$cfrom :: forall x. RefreshSchemas -> Rep RefreshSchemas x
Prelude.Generic)

-- |
-- Create a value of 'RefreshSchemas' 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:
--
-- 'endpointArn', 'refreshSchemas_endpointArn' - The Amazon Resource Name (ARN) string that uniquely identifies the
-- endpoint.
--
-- 'replicationInstanceArn', 'refreshSchemas_replicationInstanceArn' - The Amazon Resource Name (ARN) of the replication instance.
newRefreshSchemas ::
  -- | 'endpointArn'
  Prelude.Text ->
  -- | 'replicationInstanceArn'
  Prelude.Text ->
  RefreshSchemas
newRefreshSchemas :: Text -> Text -> RefreshSchemas
newRefreshSchemas
  Text
pEndpointArn_
  Text
pReplicationInstanceArn_ =
    RefreshSchemas' :: Text -> Text -> RefreshSchemas
RefreshSchemas'
      { $sel:endpointArn:RefreshSchemas' :: Text
endpointArn = Text
pEndpointArn_,
        $sel:replicationInstanceArn:RefreshSchemas' :: Text
replicationInstanceArn = Text
pReplicationInstanceArn_
      }

-- | The Amazon Resource Name (ARN) string that uniquely identifies the
-- endpoint.
refreshSchemas_endpointArn :: Lens.Lens' RefreshSchemas Prelude.Text
refreshSchemas_endpointArn :: (Text -> f Text) -> RefreshSchemas -> f RefreshSchemas
refreshSchemas_endpointArn = (RefreshSchemas -> Text)
-> (RefreshSchemas -> Text -> RefreshSchemas)
-> Lens RefreshSchemas RefreshSchemas Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RefreshSchemas' {Text
endpointArn :: Text
$sel:endpointArn:RefreshSchemas' :: RefreshSchemas -> Text
endpointArn} -> Text
endpointArn) (\s :: RefreshSchemas
s@RefreshSchemas' {} Text
a -> RefreshSchemas
s {$sel:endpointArn:RefreshSchemas' :: Text
endpointArn = Text
a} :: RefreshSchemas)

-- | The Amazon Resource Name (ARN) of the replication instance.
refreshSchemas_replicationInstanceArn :: Lens.Lens' RefreshSchemas Prelude.Text
refreshSchemas_replicationInstanceArn :: (Text -> f Text) -> RefreshSchemas -> f RefreshSchemas
refreshSchemas_replicationInstanceArn = (RefreshSchemas -> Text)
-> (RefreshSchemas -> Text -> RefreshSchemas)
-> Lens RefreshSchemas RefreshSchemas Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RefreshSchemas' {Text
replicationInstanceArn :: Text
$sel:replicationInstanceArn:RefreshSchemas' :: RefreshSchemas -> Text
replicationInstanceArn} -> Text
replicationInstanceArn) (\s :: RefreshSchemas
s@RefreshSchemas' {} Text
a -> RefreshSchemas
s {$sel:replicationInstanceArn:RefreshSchemas' :: Text
replicationInstanceArn = Text
a} :: RefreshSchemas)

instance Core.AWSRequest RefreshSchemas where
  type
    AWSResponse RefreshSchemas =
      RefreshSchemasResponse
  request :: RefreshSchemas -> Request RefreshSchemas
request = Service -> RefreshSchemas -> Request RefreshSchemas
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy RefreshSchemas
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse RefreshSchemas)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse RefreshSchemas))
-> Logger
-> Service
-> Proxy RefreshSchemas
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse RefreshSchemas)))
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 ->
          Maybe RefreshSchemasStatus -> Int -> RefreshSchemasResponse
RefreshSchemasResponse'
            (Maybe RefreshSchemasStatus -> Int -> RefreshSchemasResponse)
-> Either String (Maybe RefreshSchemasStatus)
-> Either String (Int -> RefreshSchemasResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe RefreshSchemasStatus)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"RefreshSchemasStatus")
            Either String (Int -> RefreshSchemasResponse)
-> Either String Int -> Either String RefreshSchemasResponse
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 RefreshSchemas

instance Prelude.NFData RefreshSchemas

instance Core.ToHeaders RefreshSchemas where
  toHeaders :: RefreshSchemas -> ResponseHeaders
toHeaders =
    ResponseHeaders -> RefreshSchemas -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"AmazonDMSv20160101.RefreshSchemas" ::
                          Prelude.ByteString
                      ),
            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 RefreshSchemas where
  toJSON :: RefreshSchemas -> Value
toJSON RefreshSchemas' {Text
replicationInstanceArn :: Text
endpointArn :: Text
$sel:replicationInstanceArn:RefreshSchemas' :: RefreshSchemas -> Text
$sel:endpointArn:RefreshSchemas' :: RefreshSchemas -> 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
"EndpointArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
endpointArn),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"ReplicationInstanceArn"
                  Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
replicationInstanceArn
              )
          ]
      )

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

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

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

-- |
-- Create a value of 'RefreshSchemasResponse' 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:
--
-- 'refreshSchemasStatus', 'refreshSchemasResponse_refreshSchemasStatus' - The status of the refreshed schema.
--
-- 'httpStatus', 'refreshSchemasResponse_httpStatus' - The response's http status code.
newRefreshSchemasResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  RefreshSchemasResponse
newRefreshSchemasResponse :: Int -> RefreshSchemasResponse
newRefreshSchemasResponse Int
pHttpStatus_ =
  RefreshSchemasResponse' :: Maybe RefreshSchemasStatus -> Int -> RefreshSchemasResponse
RefreshSchemasResponse'
    { $sel:refreshSchemasStatus:RefreshSchemasResponse' :: Maybe RefreshSchemasStatus
refreshSchemasStatus =
        Maybe RefreshSchemasStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:RefreshSchemasResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The status of the refreshed schema.
refreshSchemasResponse_refreshSchemasStatus :: Lens.Lens' RefreshSchemasResponse (Prelude.Maybe RefreshSchemasStatus)
refreshSchemasResponse_refreshSchemasStatus :: (Maybe RefreshSchemasStatus -> f (Maybe RefreshSchemasStatus))
-> RefreshSchemasResponse -> f RefreshSchemasResponse
refreshSchemasResponse_refreshSchemasStatus = (RefreshSchemasResponse -> Maybe RefreshSchemasStatus)
-> (RefreshSchemasResponse
    -> Maybe RefreshSchemasStatus -> RefreshSchemasResponse)
-> Lens
     RefreshSchemasResponse
     RefreshSchemasResponse
     (Maybe RefreshSchemasStatus)
     (Maybe RefreshSchemasStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RefreshSchemasResponse' {Maybe RefreshSchemasStatus
refreshSchemasStatus :: Maybe RefreshSchemasStatus
$sel:refreshSchemasStatus:RefreshSchemasResponse' :: RefreshSchemasResponse -> Maybe RefreshSchemasStatus
refreshSchemasStatus} -> Maybe RefreshSchemasStatus
refreshSchemasStatus) (\s :: RefreshSchemasResponse
s@RefreshSchemasResponse' {} Maybe RefreshSchemasStatus
a -> RefreshSchemasResponse
s {$sel:refreshSchemasStatus:RefreshSchemasResponse' :: Maybe RefreshSchemasStatus
refreshSchemasStatus = Maybe RefreshSchemasStatus
a} :: RefreshSchemasResponse)

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

instance Prelude.NFData RefreshSchemasResponse