{-# 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.ImportAppCatalog
-- 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)
--
-- Allows application import from AWS Migration Hub.
module Amazonka.SMS.ImportAppCatalog
  ( -- * Creating a Request
    ImportAppCatalog (..),
    newImportAppCatalog,

    -- * Request Lenses
    importAppCatalog_roleName,

    -- * Destructuring the Response
    ImportAppCatalogResponse (..),
    newImportAppCatalogResponse,

    -- * Response Lenses
    importAppCatalogResponse_httpStatus,
  )
where

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

-- | /See:/ 'newImportAppCatalog' smart constructor.
data ImportAppCatalog = ImportAppCatalog'
  { -- | The name of the service role. If you omit this parameter, we create a
    -- service-linked role for AWS Migration Hub in your account. Otherwise,
    -- the role that you provide must have the
    -- <https://docs.aws.amazon.com/migrationhub/latest/ug/new-customer-setup.html#sms-managed policy and trust policy>
    -- described in the /AWS Migration Hub User Guide/.
    ImportAppCatalog -> Maybe Text
roleName :: Prelude.Maybe Prelude.Text
  }
  deriving (ImportAppCatalog -> ImportAppCatalog -> Bool
(ImportAppCatalog -> ImportAppCatalog -> Bool)
-> (ImportAppCatalog -> ImportAppCatalog -> Bool)
-> Eq ImportAppCatalog
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ImportAppCatalog -> ImportAppCatalog -> Bool
$c/= :: ImportAppCatalog -> ImportAppCatalog -> Bool
== :: ImportAppCatalog -> ImportAppCatalog -> Bool
$c== :: ImportAppCatalog -> ImportAppCatalog -> Bool
Prelude.Eq, ReadPrec [ImportAppCatalog]
ReadPrec ImportAppCatalog
Int -> ReadS ImportAppCatalog
ReadS [ImportAppCatalog]
(Int -> ReadS ImportAppCatalog)
-> ReadS [ImportAppCatalog]
-> ReadPrec ImportAppCatalog
-> ReadPrec [ImportAppCatalog]
-> Read ImportAppCatalog
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ImportAppCatalog]
$creadListPrec :: ReadPrec [ImportAppCatalog]
readPrec :: ReadPrec ImportAppCatalog
$creadPrec :: ReadPrec ImportAppCatalog
readList :: ReadS [ImportAppCatalog]
$creadList :: ReadS [ImportAppCatalog]
readsPrec :: Int -> ReadS ImportAppCatalog
$creadsPrec :: Int -> ReadS ImportAppCatalog
Prelude.Read, Int -> ImportAppCatalog -> ShowS
[ImportAppCatalog] -> ShowS
ImportAppCatalog -> String
(Int -> ImportAppCatalog -> ShowS)
-> (ImportAppCatalog -> String)
-> ([ImportAppCatalog] -> ShowS)
-> Show ImportAppCatalog
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ImportAppCatalog] -> ShowS
$cshowList :: [ImportAppCatalog] -> ShowS
show :: ImportAppCatalog -> String
$cshow :: ImportAppCatalog -> String
showsPrec :: Int -> ImportAppCatalog -> ShowS
$cshowsPrec :: Int -> ImportAppCatalog -> ShowS
Prelude.Show, (forall x. ImportAppCatalog -> Rep ImportAppCatalog x)
-> (forall x. Rep ImportAppCatalog x -> ImportAppCatalog)
-> Generic ImportAppCatalog
forall x. Rep ImportAppCatalog x -> ImportAppCatalog
forall x. ImportAppCatalog -> Rep ImportAppCatalog x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ImportAppCatalog x -> ImportAppCatalog
$cfrom :: forall x. ImportAppCatalog -> Rep ImportAppCatalog x
Prelude.Generic)

-- |
-- Create a value of 'ImportAppCatalog' 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:
--
-- 'roleName', 'importAppCatalog_roleName' - The name of the service role. If you omit this parameter, we create a
-- service-linked role for AWS Migration Hub in your account. Otherwise,
-- the role that you provide must have the
-- <https://docs.aws.amazon.com/migrationhub/latest/ug/new-customer-setup.html#sms-managed policy and trust policy>
-- described in the /AWS Migration Hub User Guide/.
newImportAppCatalog ::
  ImportAppCatalog
newImportAppCatalog :: ImportAppCatalog
newImportAppCatalog =
  ImportAppCatalog' :: Maybe Text -> ImportAppCatalog
ImportAppCatalog' {$sel:roleName:ImportAppCatalog' :: Maybe Text
roleName = Maybe Text
forall a. Maybe a
Prelude.Nothing}

-- | The name of the service role. If you omit this parameter, we create a
-- service-linked role for AWS Migration Hub in your account. Otherwise,
-- the role that you provide must have the
-- <https://docs.aws.amazon.com/migrationhub/latest/ug/new-customer-setup.html#sms-managed policy and trust policy>
-- described in the /AWS Migration Hub User Guide/.
importAppCatalog_roleName :: Lens.Lens' ImportAppCatalog (Prelude.Maybe Prelude.Text)
importAppCatalog_roleName :: (Maybe Text -> f (Maybe Text))
-> ImportAppCatalog -> f ImportAppCatalog
importAppCatalog_roleName = (ImportAppCatalog -> Maybe Text)
-> (ImportAppCatalog -> Maybe Text -> ImportAppCatalog)
-> Lens ImportAppCatalog ImportAppCatalog (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImportAppCatalog' {Maybe Text
roleName :: Maybe Text
$sel:roleName:ImportAppCatalog' :: ImportAppCatalog -> Maybe Text
roleName} -> Maybe Text
roleName) (\s :: ImportAppCatalog
s@ImportAppCatalog' {} Maybe Text
a -> ImportAppCatalog
s {$sel:roleName:ImportAppCatalog' :: Maybe Text
roleName = Maybe Text
a} :: ImportAppCatalog)

instance Core.AWSRequest ImportAppCatalog where
  type
    AWSResponse ImportAppCatalog =
      ImportAppCatalogResponse
  request :: ImportAppCatalog -> Request ImportAppCatalog
request = Service -> ImportAppCatalog -> Request ImportAppCatalog
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy ImportAppCatalog
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ImportAppCatalog)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse ImportAppCatalog))
-> Logger
-> Service
-> Proxy ImportAppCatalog
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ImportAppCatalog)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> ImportAppCatalogResponse
ImportAppCatalogResponse'
            (Int -> ImportAppCatalogResponse)
-> Either String Int -> Either String ImportAppCatalogResponse
forall (f :: * -> *) a b. Functor 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 ImportAppCatalog

instance Prelude.NFData ImportAppCatalog

instance Core.ToHeaders ImportAppCatalog where
  toHeaders :: ImportAppCatalog -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ImportAppCatalog -> 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
"AWSServerMigrationService_V2016_10_24.ImportAppCatalog" ::
                          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 ImportAppCatalog where
  toJSON :: ImportAppCatalog -> Value
toJSON ImportAppCatalog' {Maybe Text
roleName :: Maybe Text
$sel:roleName:ImportAppCatalog' :: ImportAppCatalog -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Text
"roleName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
roleName]
      )

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

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

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

-- |
-- Create a value of 'ImportAppCatalogResponse' 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:
--
-- 'httpStatus', 'importAppCatalogResponse_httpStatus' - The response's http status code.
newImportAppCatalogResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ImportAppCatalogResponse
newImportAppCatalogResponse :: Int -> ImportAppCatalogResponse
newImportAppCatalogResponse Int
pHttpStatus_ =
  ImportAppCatalogResponse' :: Int -> ImportAppCatalogResponse
ImportAppCatalogResponse'
    { $sel:httpStatus:ImportAppCatalogResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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

instance Prelude.NFData ImportAppCatalogResponse