{-# 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.Pipes.StartPipe
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Start an existing pipe.
module Amazonka.Pipes.StartPipe
  ( -- * Creating a Request
    StartPipe (..),
    newStartPipe,

    -- * Request Lenses
    startPipe_name,

    -- * Destructuring the Response
    StartPipeResponse (..),
    newStartPipeResponse,

    -- * Response Lenses
    startPipeResponse_arn,
    startPipeResponse_creationTime,
    startPipeResponse_currentState,
    startPipeResponse_desiredState,
    startPipeResponse_lastModifiedTime,
    startPipeResponse_name,
    startPipeResponse_httpStatus,
  )
where

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

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

-- |
-- Create a value of 'StartPipe' 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:
--
-- 'name', 'startPipe_name' - The name of the pipe.
newStartPipe ::
  -- | 'name'
  Prelude.Text ->
  StartPipe
newStartPipe :: Text -> StartPipe
newStartPipe Text
pName_ = StartPipe' {$sel:name:StartPipe' :: Text
name = Text
pName_}

-- | The name of the pipe.
startPipe_name :: Lens.Lens' StartPipe Prelude.Text
startPipe_name :: Lens' StartPipe Text
startPipe_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartPipe' {Text
name :: Text
$sel:name:StartPipe' :: StartPipe -> Text
name} -> Text
name) (\s :: StartPipe
s@StartPipe' {} Text
a -> StartPipe
s {$sel:name:StartPipe' :: Text
name = Text
a} :: StartPipe)

instance Core.AWSRequest StartPipe where
  type AWSResponse StartPipe = StartPipeResponse
  request :: (Service -> Service) -> StartPipe -> Request StartPipe
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 StartPipe
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse StartPipe)))
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 Text
-> Maybe POSIX
-> Maybe PipeState
-> Maybe RequestedPipeState
-> Maybe POSIX
-> Maybe Text
-> Int
-> StartPipeResponse
StartPipeResponse'
            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
"Arn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"CreationTime")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"CurrentState")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"DesiredState")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"LastModifiedTime")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"Name")
            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 StartPipe where
  hashWithSalt :: Int -> StartPipe -> Int
hashWithSalt Int
_salt StartPipe' {Text
name :: Text
$sel:name:StartPipe' :: StartPipe -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name

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

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

instance Data.ToJSON StartPipe where
  toJSON :: StartPipe -> Value
toJSON = forall a b. a -> b -> a
Prelude.const (Object -> Value
Data.Object forall a. Monoid a => a
Prelude.mempty)

instance Data.ToPath StartPipe where
  toPath :: StartPipe -> ByteString
toPath StartPipe' {Text
name :: Text
$sel:name:StartPipe' :: StartPipe -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/v1/pipes/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
name, ByteString
"/start"]

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

-- | /See:/ 'newStartPipeResponse' smart constructor.
data StartPipeResponse = StartPipeResponse'
  { -- | The ARN of the pipe.
    StartPipeResponse -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The time the pipe was created.
    StartPipeResponse -> Maybe POSIX
creationTime :: Prelude.Maybe Data.POSIX,
    -- | The state the pipe is in.
    StartPipeResponse -> Maybe PipeState
currentState :: Prelude.Maybe PipeState,
    -- | The state the pipe should be in.
    StartPipeResponse -> Maybe RequestedPipeState
desiredState :: Prelude.Maybe RequestedPipeState,
    -- | When the pipe was last updated, in
    -- <https://www.w3.org/TR/NOTE-datetime ISO-8601 format>
    -- (YYYY-MM-DDThh:mm:ss.sTZD).
    StartPipeResponse -> Maybe POSIX
lastModifiedTime :: Prelude.Maybe Data.POSIX,
    -- | The name of the pipe.
    StartPipeResponse -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    StartPipeResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (StartPipeResponse -> StartPipeResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StartPipeResponse -> StartPipeResponse -> Bool
$c/= :: StartPipeResponse -> StartPipeResponse -> Bool
== :: StartPipeResponse -> StartPipeResponse -> Bool
$c== :: StartPipeResponse -> StartPipeResponse -> Bool
Prelude.Eq, ReadPrec [StartPipeResponse]
ReadPrec StartPipeResponse
Int -> ReadS StartPipeResponse
ReadS [StartPipeResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StartPipeResponse]
$creadListPrec :: ReadPrec [StartPipeResponse]
readPrec :: ReadPrec StartPipeResponse
$creadPrec :: ReadPrec StartPipeResponse
readList :: ReadS [StartPipeResponse]
$creadList :: ReadS [StartPipeResponse]
readsPrec :: Int -> ReadS StartPipeResponse
$creadsPrec :: Int -> ReadS StartPipeResponse
Prelude.Read, Int -> StartPipeResponse -> ShowS
[StartPipeResponse] -> ShowS
StartPipeResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StartPipeResponse] -> ShowS
$cshowList :: [StartPipeResponse] -> ShowS
show :: StartPipeResponse -> String
$cshow :: StartPipeResponse -> String
showsPrec :: Int -> StartPipeResponse -> ShowS
$cshowsPrec :: Int -> StartPipeResponse -> ShowS
Prelude.Show, forall x. Rep StartPipeResponse x -> StartPipeResponse
forall x. StartPipeResponse -> Rep StartPipeResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StartPipeResponse x -> StartPipeResponse
$cfrom :: forall x. StartPipeResponse -> Rep StartPipeResponse x
Prelude.Generic)

-- |
-- Create a value of 'StartPipeResponse' 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:
--
-- 'arn', 'startPipeResponse_arn' - The ARN of the pipe.
--
-- 'creationTime', 'startPipeResponse_creationTime' - The time the pipe was created.
--
-- 'currentState', 'startPipeResponse_currentState' - The state the pipe is in.
--
-- 'desiredState', 'startPipeResponse_desiredState' - The state the pipe should be in.
--
-- 'lastModifiedTime', 'startPipeResponse_lastModifiedTime' - When the pipe was last updated, in
-- <https://www.w3.org/TR/NOTE-datetime ISO-8601 format>
-- (YYYY-MM-DDThh:mm:ss.sTZD).
--
-- 'name', 'startPipeResponse_name' - The name of the pipe.
--
-- 'httpStatus', 'startPipeResponse_httpStatus' - The response's http status code.
newStartPipeResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  StartPipeResponse
newStartPipeResponse :: Int -> StartPipeResponse
newStartPipeResponse Int
pHttpStatus_ =
  StartPipeResponse'
    { $sel:arn:StartPipeResponse' :: Maybe Text
arn = forall a. Maybe a
Prelude.Nothing,
      $sel:creationTime:StartPipeResponse' :: Maybe POSIX
creationTime = forall a. Maybe a
Prelude.Nothing,
      $sel:currentState:StartPipeResponse' :: Maybe PipeState
currentState = forall a. Maybe a
Prelude.Nothing,
      $sel:desiredState:StartPipeResponse' :: Maybe RequestedPipeState
desiredState = forall a. Maybe a
Prelude.Nothing,
      $sel:lastModifiedTime:StartPipeResponse' :: Maybe POSIX
lastModifiedTime = forall a. Maybe a
Prelude.Nothing,
      $sel:name:StartPipeResponse' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:StartPipeResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The ARN of the pipe.
startPipeResponse_arn :: Lens.Lens' StartPipeResponse (Prelude.Maybe Prelude.Text)
startPipeResponse_arn :: Lens' StartPipeResponse (Maybe Text)
startPipeResponse_arn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartPipeResponse' {Maybe Text
arn :: Maybe Text
$sel:arn:StartPipeResponse' :: StartPipeResponse -> Maybe Text
arn} -> Maybe Text
arn) (\s :: StartPipeResponse
s@StartPipeResponse' {} Maybe Text
a -> StartPipeResponse
s {$sel:arn:StartPipeResponse' :: Maybe Text
arn = Maybe Text
a} :: StartPipeResponse)

-- | The time the pipe was created.
startPipeResponse_creationTime :: Lens.Lens' StartPipeResponse (Prelude.Maybe Prelude.UTCTime)
startPipeResponse_creationTime :: Lens' StartPipeResponse (Maybe UTCTime)
startPipeResponse_creationTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartPipeResponse' {Maybe POSIX
creationTime :: Maybe POSIX
$sel:creationTime:StartPipeResponse' :: StartPipeResponse -> Maybe POSIX
creationTime} -> Maybe POSIX
creationTime) (\s :: StartPipeResponse
s@StartPipeResponse' {} Maybe POSIX
a -> StartPipeResponse
s {$sel:creationTime:StartPipeResponse' :: Maybe POSIX
creationTime = Maybe POSIX
a} :: StartPipeResponse) 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 (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The state the pipe is in.
startPipeResponse_currentState :: Lens.Lens' StartPipeResponse (Prelude.Maybe PipeState)
startPipeResponse_currentState :: Lens' StartPipeResponse (Maybe PipeState)
startPipeResponse_currentState = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartPipeResponse' {Maybe PipeState
currentState :: Maybe PipeState
$sel:currentState:StartPipeResponse' :: StartPipeResponse -> Maybe PipeState
currentState} -> Maybe PipeState
currentState) (\s :: StartPipeResponse
s@StartPipeResponse' {} Maybe PipeState
a -> StartPipeResponse
s {$sel:currentState:StartPipeResponse' :: Maybe PipeState
currentState = Maybe PipeState
a} :: StartPipeResponse)

-- | The state the pipe should be in.
startPipeResponse_desiredState :: Lens.Lens' StartPipeResponse (Prelude.Maybe RequestedPipeState)
startPipeResponse_desiredState :: Lens' StartPipeResponse (Maybe RequestedPipeState)
startPipeResponse_desiredState = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartPipeResponse' {Maybe RequestedPipeState
desiredState :: Maybe RequestedPipeState
$sel:desiredState:StartPipeResponse' :: StartPipeResponse -> Maybe RequestedPipeState
desiredState} -> Maybe RequestedPipeState
desiredState) (\s :: StartPipeResponse
s@StartPipeResponse' {} Maybe RequestedPipeState
a -> StartPipeResponse
s {$sel:desiredState:StartPipeResponse' :: Maybe RequestedPipeState
desiredState = Maybe RequestedPipeState
a} :: StartPipeResponse)

-- | When the pipe was last updated, in
-- <https://www.w3.org/TR/NOTE-datetime ISO-8601 format>
-- (YYYY-MM-DDThh:mm:ss.sTZD).
startPipeResponse_lastModifiedTime :: Lens.Lens' StartPipeResponse (Prelude.Maybe Prelude.UTCTime)
startPipeResponse_lastModifiedTime :: Lens' StartPipeResponse (Maybe UTCTime)
startPipeResponse_lastModifiedTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartPipeResponse' {Maybe POSIX
lastModifiedTime :: Maybe POSIX
$sel:lastModifiedTime:StartPipeResponse' :: StartPipeResponse -> Maybe POSIX
lastModifiedTime} -> Maybe POSIX
lastModifiedTime) (\s :: StartPipeResponse
s@StartPipeResponse' {} Maybe POSIX
a -> StartPipeResponse
s {$sel:lastModifiedTime:StartPipeResponse' :: Maybe POSIX
lastModifiedTime = Maybe POSIX
a} :: StartPipeResponse) 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 (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The name of the pipe.
startPipeResponse_name :: Lens.Lens' StartPipeResponse (Prelude.Maybe Prelude.Text)
startPipeResponse_name :: Lens' StartPipeResponse (Maybe Text)
startPipeResponse_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartPipeResponse' {Maybe Text
name :: Maybe Text
$sel:name:StartPipeResponse' :: StartPipeResponse -> Maybe Text
name} -> Maybe Text
name) (\s :: StartPipeResponse
s@StartPipeResponse' {} Maybe Text
a -> StartPipeResponse
s {$sel:name:StartPipeResponse' :: Maybe Text
name = Maybe Text
a} :: StartPipeResponse)

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

instance Prelude.NFData StartPipeResponse where
  rnf :: StartPipeResponse -> ()
rnf StartPipeResponse' {Int
Maybe Text
Maybe POSIX
Maybe PipeState
Maybe RequestedPipeState
httpStatus :: Int
name :: Maybe Text
lastModifiedTime :: Maybe POSIX
desiredState :: Maybe RequestedPipeState
currentState :: Maybe PipeState
creationTime :: Maybe POSIX
arn :: Maybe Text
$sel:httpStatus:StartPipeResponse' :: StartPipeResponse -> Int
$sel:name:StartPipeResponse' :: StartPipeResponse -> Maybe Text
$sel:lastModifiedTime:StartPipeResponse' :: StartPipeResponse -> Maybe POSIX
$sel:desiredState:StartPipeResponse' :: StartPipeResponse -> Maybe RequestedPipeState
$sel:currentState:StartPipeResponse' :: StartPipeResponse -> Maybe PipeState
$sel:creationTime:StartPipeResponse' :: StartPipeResponse -> Maybe POSIX
$sel:arn:StartPipeResponse' :: StartPipeResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
arn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
creationTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe PipeState
currentState
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe RequestedPipeState
desiredState
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
lastModifiedTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus