{-# 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.MigrationHub.CreateProgressUpdateStream
-- 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)
--
-- Creates a progress update stream which is an AWS resource used for
-- access control as well as a namespace for migration task names that is
-- implicitly linked to your AWS account. It must uniquely identify the
-- migration tool as it is used for all updates made by the tool; however,
-- it does not need to be unique for each AWS account because it is scoped
-- to the AWS account.
module Amazonka.MigrationHub.CreateProgressUpdateStream
  ( -- * Creating a Request
    CreateProgressUpdateStream (..),
    newCreateProgressUpdateStream,

    -- * Request Lenses
    createProgressUpdateStream_dryRun,
    createProgressUpdateStream_progressUpdateStreamName,

    -- * Destructuring the Response
    CreateProgressUpdateStreamResponse (..),
    newCreateProgressUpdateStreamResponse,

    -- * Response Lenses
    createProgressUpdateStreamResponse_httpStatus,
  )
where

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

-- | /See:/ 'newCreateProgressUpdateStream' smart constructor.
data CreateProgressUpdateStream = CreateProgressUpdateStream'
  { -- | Optional boolean flag to indicate whether any effect should take place.
    -- Used to test if the caller has permission to make the call.
    CreateProgressUpdateStream -> Maybe Bool
dryRun :: Prelude.Maybe Prelude.Bool,
    -- | The name of the ProgressUpdateStream. /Do not store personal data in
    -- this field./
    CreateProgressUpdateStream -> Text
progressUpdateStreamName :: Prelude.Text
  }
  deriving (CreateProgressUpdateStream -> CreateProgressUpdateStream -> Bool
(CreateProgressUpdateStream -> CreateProgressUpdateStream -> Bool)
-> (CreateProgressUpdateStream
    -> CreateProgressUpdateStream -> Bool)
-> Eq CreateProgressUpdateStream
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateProgressUpdateStream -> CreateProgressUpdateStream -> Bool
$c/= :: CreateProgressUpdateStream -> CreateProgressUpdateStream -> Bool
== :: CreateProgressUpdateStream -> CreateProgressUpdateStream -> Bool
$c== :: CreateProgressUpdateStream -> CreateProgressUpdateStream -> Bool
Prelude.Eq, ReadPrec [CreateProgressUpdateStream]
ReadPrec CreateProgressUpdateStream
Int -> ReadS CreateProgressUpdateStream
ReadS [CreateProgressUpdateStream]
(Int -> ReadS CreateProgressUpdateStream)
-> ReadS [CreateProgressUpdateStream]
-> ReadPrec CreateProgressUpdateStream
-> ReadPrec [CreateProgressUpdateStream]
-> Read CreateProgressUpdateStream
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateProgressUpdateStream]
$creadListPrec :: ReadPrec [CreateProgressUpdateStream]
readPrec :: ReadPrec CreateProgressUpdateStream
$creadPrec :: ReadPrec CreateProgressUpdateStream
readList :: ReadS [CreateProgressUpdateStream]
$creadList :: ReadS [CreateProgressUpdateStream]
readsPrec :: Int -> ReadS CreateProgressUpdateStream
$creadsPrec :: Int -> ReadS CreateProgressUpdateStream
Prelude.Read, Int -> CreateProgressUpdateStream -> ShowS
[CreateProgressUpdateStream] -> ShowS
CreateProgressUpdateStream -> String
(Int -> CreateProgressUpdateStream -> ShowS)
-> (CreateProgressUpdateStream -> String)
-> ([CreateProgressUpdateStream] -> ShowS)
-> Show CreateProgressUpdateStream
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateProgressUpdateStream] -> ShowS
$cshowList :: [CreateProgressUpdateStream] -> ShowS
show :: CreateProgressUpdateStream -> String
$cshow :: CreateProgressUpdateStream -> String
showsPrec :: Int -> CreateProgressUpdateStream -> ShowS
$cshowsPrec :: Int -> CreateProgressUpdateStream -> ShowS
Prelude.Show, (forall x.
 CreateProgressUpdateStream -> Rep CreateProgressUpdateStream x)
-> (forall x.
    Rep CreateProgressUpdateStream x -> CreateProgressUpdateStream)
-> Generic CreateProgressUpdateStream
forall x.
Rep CreateProgressUpdateStream x -> CreateProgressUpdateStream
forall x.
CreateProgressUpdateStream -> Rep CreateProgressUpdateStream x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateProgressUpdateStream x -> CreateProgressUpdateStream
$cfrom :: forall x.
CreateProgressUpdateStream -> Rep CreateProgressUpdateStream x
Prelude.Generic)

-- |
-- Create a value of 'CreateProgressUpdateStream' 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:
--
-- 'dryRun', 'createProgressUpdateStream_dryRun' - Optional boolean flag to indicate whether any effect should take place.
-- Used to test if the caller has permission to make the call.
--
-- 'progressUpdateStreamName', 'createProgressUpdateStream_progressUpdateStreamName' - The name of the ProgressUpdateStream. /Do not store personal data in
-- this field./
newCreateProgressUpdateStream ::
  -- | 'progressUpdateStreamName'
  Prelude.Text ->
  CreateProgressUpdateStream
newCreateProgressUpdateStream :: Text -> CreateProgressUpdateStream
newCreateProgressUpdateStream
  Text
pProgressUpdateStreamName_ =
    CreateProgressUpdateStream' :: Maybe Bool -> Text -> CreateProgressUpdateStream
CreateProgressUpdateStream'
      { $sel:dryRun:CreateProgressUpdateStream' :: Maybe Bool
dryRun =
          Maybe Bool
forall a. Maybe a
Prelude.Nothing,
        $sel:progressUpdateStreamName:CreateProgressUpdateStream' :: Text
progressUpdateStreamName =
          Text
pProgressUpdateStreamName_
      }

-- | Optional boolean flag to indicate whether any effect should take place.
-- Used to test if the caller has permission to make the call.
createProgressUpdateStream_dryRun :: Lens.Lens' CreateProgressUpdateStream (Prelude.Maybe Prelude.Bool)
createProgressUpdateStream_dryRun :: (Maybe Bool -> f (Maybe Bool))
-> CreateProgressUpdateStream -> f CreateProgressUpdateStream
createProgressUpdateStream_dryRun = (CreateProgressUpdateStream -> Maybe Bool)
-> (CreateProgressUpdateStream
    -> Maybe Bool -> CreateProgressUpdateStream)
-> Lens
     CreateProgressUpdateStream
     CreateProgressUpdateStream
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateProgressUpdateStream' {Maybe Bool
dryRun :: Maybe Bool
$sel:dryRun:CreateProgressUpdateStream' :: CreateProgressUpdateStream -> Maybe Bool
dryRun} -> Maybe Bool
dryRun) (\s :: CreateProgressUpdateStream
s@CreateProgressUpdateStream' {} Maybe Bool
a -> CreateProgressUpdateStream
s {$sel:dryRun:CreateProgressUpdateStream' :: Maybe Bool
dryRun = Maybe Bool
a} :: CreateProgressUpdateStream)

-- | The name of the ProgressUpdateStream. /Do not store personal data in
-- this field./
createProgressUpdateStream_progressUpdateStreamName :: Lens.Lens' CreateProgressUpdateStream Prelude.Text
createProgressUpdateStream_progressUpdateStreamName :: (Text -> f Text)
-> CreateProgressUpdateStream -> f CreateProgressUpdateStream
createProgressUpdateStream_progressUpdateStreamName = (CreateProgressUpdateStream -> Text)
-> (CreateProgressUpdateStream
    -> Text -> CreateProgressUpdateStream)
-> Lens
     CreateProgressUpdateStream CreateProgressUpdateStream Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateProgressUpdateStream' {Text
progressUpdateStreamName :: Text
$sel:progressUpdateStreamName:CreateProgressUpdateStream' :: CreateProgressUpdateStream -> Text
progressUpdateStreamName} -> Text
progressUpdateStreamName) (\s :: CreateProgressUpdateStream
s@CreateProgressUpdateStream' {} Text
a -> CreateProgressUpdateStream
s {$sel:progressUpdateStreamName:CreateProgressUpdateStream' :: Text
progressUpdateStreamName = Text
a} :: CreateProgressUpdateStream)

instance Core.AWSRequest CreateProgressUpdateStream where
  type
    AWSResponse CreateProgressUpdateStream =
      CreateProgressUpdateStreamResponse
  request :: CreateProgressUpdateStream -> Request CreateProgressUpdateStream
request = Service
-> CreateProgressUpdateStream -> Request CreateProgressUpdateStream
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateProgressUpdateStream
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateProgressUpdateStream)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse CreateProgressUpdateStream))
-> Logger
-> Service
-> Proxy CreateProgressUpdateStream
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateProgressUpdateStream)))
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 -> CreateProgressUpdateStreamResponse
CreateProgressUpdateStreamResponse'
            (Int -> CreateProgressUpdateStreamResponse)
-> Either String Int
-> Either String CreateProgressUpdateStreamResponse
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 CreateProgressUpdateStream

instance Prelude.NFData CreateProgressUpdateStream

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

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

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

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

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

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

instance
  Prelude.NFData
    CreateProgressUpdateStreamResponse