{-# 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.DataBrew.StartProjectSession
-- 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 an interactive session, enabling you to manipulate data in a
-- DataBrew project.
module Amazonka.DataBrew.StartProjectSession
  ( -- * Creating a Request
    StartProjectSession (..),
    newStartProjectSession,

    -- * Request Lenses
    startProjectSession_assumeControl,
    startProjectSession_name,

    -- * Destructuring the Response
    StartProjectSessionResponse (..),
    newStartProjectSessionResponse,

    -- * Response Lenses
    startProjectSessionResponse_clientSessionId,
    startProjectSessionResponse_httpStatus,
    startProjectSessionResponse_name,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.DataBrew.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:/ 'newStartProjectSession' smart constructor.
data StartProjectSession = StartProjectSession'
  { -- | A value that, if true, enables you to take control of a session, even if
    -- a different client is currently accessing the project.
    StartProjectSession -> Maybe Bool
assumeControl :: Prelude.Maybe Prelude.Bool,
    -- | The name of the project to act upon.
    StartProjectSession -> Text
name :: Prelude.Text
  }
  deriving (StartProjectSession -> StartProjectSession -> Bool
(StartProjectSession -> StartProjectSession -> Bool)
-> (StartProjectSession -> StartProjectSession -> Bool)
-> Eq StartProjectSession
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StartProjectSession -> StartProjectSession -> Bool
$c/= :: StartProjectSession -> StartProjectSession -> Bool
== :: StartProjectSession -> StartProjectSession -> Bool
$c== :: StartProjectSession -> StartProjectSession -> Bool
Prelude.Eq, ReadPrec [StartProjectSession]
ReadPrec StartProjectSession
Int -> ReadS StartProjectSession
ReadS [StartProjectSession]
(Int -> ReadS StartProjectSession)
-> ReadS [StartProjectSession]
-> ReadPrec StartProjectSession
-> ReadPrec [StartProjectSession]
-> Read StartProjectSession
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StartProjectSession]
$creadListPrec :: ReadPrec [StartProjectSession]
readPrec :: ReadPrec StartProjectSession
$creadPrec :: ReadPrec StartProjectSession
readList :: ReadS [StartProjectSession]
$creadList :: ReadS [StartProjectSession]
readsPrec :: Int -> ReadS StartProjectSession
$creadsPrec :: Int -> ReadS StartProjectSession
Prelude.Read, Int -> StartProjectSession -> ShowS
[StartProjectSession] -> ShowS
StartProjectSession -> String
(Int -> StartProjectSession -> ShowS)
-> (StartProjectSession -> String)
-> ([StartProjectSession] -> ShowS)
-> Show StartProjectSession
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StartProjectSession] -> ShowS
$cshowList :: [StartProjectSession] -> ShowS
show :: StartProjectSession -> String
$cshow :: StartProjectSession -> String
showsPrec :: Int -> StartProjectSession -> ShowS
$cshowsPrec :: Int -> StartProjectSession -> ShowS
Prelude.Show, (forall x. StartProjectSession -> Rep StartProjectSession x)
-> (forall x. Rep StartProjectSession x -> StartProjectSession)
-> Generic StartProjectSession
forall x. Rep StartProjectSession x -> StartProjectSession
forall x. StartProjectSession -> Rep StartProjectSession x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StartProjectSession x -> StartProjectSession
$cfrom :: forall x. StartProjectSession -> Rep StartProjectSession x
Prelude.Generic)

-- |
-- Create a value of 'StartProjectSession' 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:
--
-- 'assumeControl', 'startProjectSession_assumeControl' - A value that, if true, enables you to take control of a session, even if
-- a different client is currently accessing the project.
--
-- 'name', 'startProjectSession_name' - The name of the project to act upon.
newStartProjectSession ::
  -- | 'name'
  Prelude.Text ->
  StartProjectSession
newStartProjectSession :: Text -> StartProjectSession
newStartProjectSession Text
pName_ =
  StartProjectSession' :: Maybe Bool -> Text -> StartProjectSession
StartProjectSession'
    { $sel:assumeControl:StartProjectSession' :: Maybe Bool
assumeControl =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:name:StartProjectSession' :: Text
name = Text
pName_
    }

-- | A value that, if true, enables you to take control of a session, even if
-- a different client is currently accessing the project.
startProjectSession_assumeControl :: Lens.Lens' StartProjectSession (Prelude.Maybe Prelude.Bool)
startProjectSession_assumeControl :: (Maybe Bool -> f (Maybe Bool))
-> StartProjectSession -> f StartProjectSession
startProjectSession_assumeControl = (StartProjectSession -> Maybe Bool)
-> (StartProjectSession -> Maybe Bool -> StartProjectSession)
-> Lens
     StartProjectSession StartProjectSession (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartProjectSession' {Maybe Bool
assumeControl :: Maybe Bool
$sel:assumeControl:StartProjectSession' :: StartProjectSession -> Maybe Bool
assumeControl} -> Maybe Bool
assumeControl) (\s :: StartProjectSession
s@StartProjectSession' {} Maybe Bool
a -> StartProjectSession
s {$sel:assumeControl:StartProjectSession' :: Maybe Bool
assumeControl = Maybe Bool
a} :: StartProjectSession)

-- | The name of the project to act upon.
startProjectSession_name :: Lens.Lens' StartProjectSession Prelude.Text
startProjectSession_name :: (Text -> f Text) -> StartProjectSession -> f StartProjectSession
startProjectSession_name = (StartProjectSession -> Text)
-> (StartProjectSession -> Text -> StartProjectSession)
-> Lens StartProjectSession StartProjectSession Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartProjectSession' {Text
name :: Text
$sel:name:StartProjectSession' :: StartProjectSession -> Text
name} -> Text
name) (\s :: StartProjectSession
s@StartProjectSession' {} Text
a -> StartProjectSession
s {$sel:name:StartProjectSession' :: Text
name = Text
a} :: StartProjectSession)

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

instance Prelude.Hashable StartProjectSession

instance Prelude.NFData StartProjectSession

instance Core.ToHeaders StartProjectSession where
  toHeaders :: StartProjectSession -> ResponseHeaders
toHeaders =
    ResponseHeaders -> StartProjectSession -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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 StartProjectSession where
  toJSON :: StartProjectSession -> Value
toJSON StartProjectSession' {Maybe Bool
Text
name :: Text
assumeControl :: Maybe Bool
$sel:name:StartProjectSession' :: StartProjectSession -> Text
$sel:assumeControl:StartProjectSession' :: StartProjectSession -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"AssumeControl" 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
assumeControl
          ]
      )

instance Core.ToPath StartProjectSession where
  toPath :: StartProjectSession -> ByteString
toPath StartProjectSession' {Maybe Bool
Text
name :: Text
assumeControl :: Maybe Bool
$sel:name:StartProjectSession' :: StartProjectSession -> Text
$sel:assumeControl:StartProjectSession' :: StartProjectSession -> Maybe Bool
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/projects/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
name,
        ByteString
"/startProjectSession"
      ]

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

-- | /See:/ 'newStartProjectSessionResponse' smart constructor.
data StartProjectSessionResponse = StartProjectSessionResponse'
  { -- | A system-generated identifier for the session.
    StartProjectSessionResponse -> Maybe Text
clientSessionId :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    StartProjectSessionResponse -> Int
httpStatus :: Prelude.Int,
    -- | The name of the project to be acted upon.
    StartProjectSessionResponse -> Text
name :: Prelude.Text
  }
  deriving (StartProjectSessionResponse -> StartProjectSessionResponse -> Bool
(StartProjectSessionResponse
 -> StartProjectSessionResponse -> Bool)
-> (StartProjectSessionResponse
    -> StartProjectSessionResponse -> Bool)
-> Eq StartProjectSessionResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StartProjectSessionResponse -> StartProjectSessionResponse -> Bool
$c/= :: StartProjectSessionResponse -> StartProjectSessionResponse -> Bool
== :: StartProjectSessionResponse -> StartProjectSessionResponse -> Bool
$c== :: StartProjectSessionResponse -> StartProjectSessionResponse -> Bool
Prelude.Eq, ReadPrec [StartProjectSessionResponse]
ReadPrec StartProjectSessionResponse
Int -> ReadS StartProjectSessionResponse
ReadS [StartProjectSessionResponse]
(Int -> ReadS StartProjectSessionResponse)
-> ReadS [StartProjectSessionResponse]
-> ReadPrec StartProjectSessionResponse
-> ReadPrec [StartProjectSessionResponse]
-> Read StartProjectSessionResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StartProjectSessionResponse]
$creadListPrec :: ReadPrec [StartProjectSessionResponse]
readPrec :: ReadPrec StartProjectSessionResponse
$creadPrec :: ReadPrec StartProjectSessionResponse
readList :: ReadS [StartProjectSessionResponse]
$creadList :: ReadS [StartProjectSessionResponse]
readsPrec :: Int -> ReadS StartProjectSessionResponse
$creadsPrec :: Int -> ReadS StartProjectSessionResponse
Prelude.Read, Int -> StartProjectSessionResponse -> ShowS
[StartProjectSessionResponse] -> ShowS
StartProjectSessionResponse -> String
(Int -> StartProjectSessionResponse -> ShowS)
-> (StartProjectSessionResponse -> String)
-> ([StartProjectSessionResponse] -> ShowS)
-> Show StartProjectSessionResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StartProjectSessionResponse] -> ShowS
$cshowList :: [StartProjectSessionResponse] -> ShowS
show :: StartProjectSessionResponse -> String
$cshow :: StartProjectSessionResponse -> String
showsPrec :: Int -> StartProjectSessionResponse -> ShowS
$cshowsPrec :: Int -> StartProjectSessionResponse -> ShowS
Prelude.Show, (forall x.
 StartProjectSessionResponse -> Rep StartProjectSessionResponse x)
-> (forall x.
    Rep StartProjectSessionResponse x -> StartProjectSessionResponse)
-> Generic StartProjectSessionResponse
forall x.
Rep StartProjectSessionResponse x -> StartProjectSessionResponse
forall x.
StartProjectSessionResponse -> Rep StartProjectSessionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep StartProjectSessionResponse x -> StartProjectSessionResponse
$cfrom :: forall x.
StartProjectSessionResponse -> Rep StartProjectSessionResponse x
Prelude.Generic)

-- |
-- Create a value of 'StartProjectSessionResponse' 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:
--
-- 'clientSessionId', 'startProjectSessionResponse_clientSessionId' - A system-generated identifier for the session.
--
-- 'httpStatus', 'startProjectSessionResponse_httpStatus' - The response's http status code.
--
-- 'name', 'startProjectSessionResponse_name' - The name of the project to be acted upon.
newStartProjectSessionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'name'
  Prelude.Text ->
  StartProjectSessionResponse
newStartProjectSessionResponse :: Int -> Text -> StartProjectSessionResponse
newStartProjectSessionResponse Int
pHttpStatus_ Text
pName_ =
  StartProjectSessionResponse' :: Maybe Text -> Int -> Text -> StartProjectSessionResponse
StartProjectSessionResponse'
    { $sel:clientSessionId:StartProjectSessionResponse' :: Maybe Text
clientSessionId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:StartProjectSessionResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:name:StartProjectSessionResponse' :: Text
name = Text
pName_
    }

-- | A system-generated identifier for the session.
startProjectSessionResponse_clientSessionId :: Lens.Lens' StartProjectSessionResponse (Prelude.Maybe Prelude.Text)
startProjectSessionResponse_clientSessionId :: (Maybe Text -> f (Maybe Text))
-> StartProjectSessionResponse -> f StartProjectSessionResponse
startProjectSessionResponse_clientSessionId = (StartProjectSessionResponse -> Maybe Text)
-> (StartProjectSessionResponse
    -> Maybe Text -> StartProjectSessionResponse)
-> Lens
     StartProjectSessionResponse
     StartProjectSessionResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartProjectSessionResponse' {Maybe Text
clientSessionId :: Maybe Text
$sel:clientSessionId:StartProjectSessionResponse' :: StartProjectSessionResponse -> Maybe Text
clientSessionId} -> Maybe Text
clientSessionId) (\s :: StartProjectSessionResponse
s@StartProjectSessionResponse' {} Maybe Text
a -> StartProjectSessionResponse
s {$sel:clientSessionId:StartProjectSessionResponse' :: Maybe Text
clientSessionId = Maybe Text
a} :: StartProjectSessionResponse)

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

-- | The name of the project to be acted upon.
startProjectSessionResponse_name :: Lens.Lens' StartProjectSessionResponse Prelude.Text
startProjectSessionResponse_name :: (Text -> f Text)
-> StartProjectSessionResponse -> f StartProjectSessionResponse
startProjectSessionResponse_name = (StartProjectSessionResponse -> Text)
-> (StartProjectSessionResponse
    -> Text -> StartProjectSessionResponse)
-> Lens
     StartProjectSessionResponse StartProjectSessionResponse Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartProjectSessionResponse' {Text
name :: Text
$sel:name:StartProjectSessionResponse' :: StartProjectSessionResponse -> Text
name} -> Text
name) (\s :: StartProjectSessionResponse
s@StartProjectSessionResponse' {} Text
a -> StartProjectSessionResponse
s {$sel:name:StartProjectSessionResponse' :: Text
name = Text
a} :: StartProjectSessionResponse)

instance Prelude.NFData StartProjectSessionResponse