{-# 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.WorkSpaces.ModifyWorkspaceState
-- 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)
--
-- Sets the state of the specified WorkSpace.
--
-- To maintain a WorkSpace without being interrupted, set the WorkSpace
-- state to @ADMIN_MAINTENANCE@. WorkSpaces in this state do not respond to
-- requests to reboot, stop, start, rebuild, or restore. An AutoStop
-- WorkSpace in this state is not stopped. Users cannot log into a
-- WorkSpace in the @ADMIN_MAINTENANCE@ state.
module Amazonka.WorkSpaces.ModifyWorkspaceState
  ( -- * Creating a Request
    ModifyWorkspaceState (..),
    newModifyWorkspaceState,

    -- * Request Lenses
    modifyWorkspaceState_workspaceId,
    modifyWorkspaceState_workspaceState,

    -- * Destructuring the Response
    ModifyWorkspaceStateResponse (..),
    newModifyWorkspaceStateResponse,

    -- * Response Lenses
    modifyWorkspaceStateResponse_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.WorkSpaces.Types

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

-- |
-- Create a value of 'ModifyWorkspaceState' 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:
--
-- 'workspaceId', 'modifyWorkspaceState_workspaceId' - The identifier of the WorkSpace.
--
-- 'workspaceState', 'modifyWorkspaceState_workspaceState' - The WorkSpace state.
newModifyWorkspaceState ::
  -- | 'workspaceId'
  Prelude.Text ->
  -- | 'workspaceState'
  TargetWorkspaceState ->
  ModifyWorkspaceState
newModifyWorkspaceState :: Text -> TargetWorkspaceState -> ModifyWorkspaceState
newModifyWorkspaceState
  Text
pWorkspaceId_
  TargetWorkspaceState
pWorkspaceState_ =
    ModifyWorkspaceState' :: Text -> TargetWorkspaceState -> ModifyWorkspaceState
ModifyWorkspaceState'
      { $sel:workspaceId:ModifyWorkspaceState' :: Text
workspaceId = Text
pWorkspaceId_,
        $sel:workspaceState:ModifyWorkspaceState' :: TargetWorkspaceState
workspaceState = TargetWorkspaceState
pWorkspaceState_
      }

-- | The identifier of the WorkSpace.
modifyWorkspaceState_workspaceId :: Lens.Lens' ModifyWorkspaceState Prelude.Text
modifyWorkspaceState_workspaceId :: (Text -> f Text) -> ModifyWorkspaceState -> f ModifyWorkspaceState
modifyWorkspaceState_workspaceId = (ModifyWorkspaceState -> Text)
-> (ModifyWorkspaceState -> Text -> ModifyWorkspaceState)
-> Lens ModifyWorkspaceState ModifyWorkspaceState Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModifyWorkspaceState' {Text
workspaceId :: Text
$sel:workspaceId:ModifyWorkspaceState' :: ModifyWorkspaceState -> Text
workspaceId} -> Text
workspaceId) (\s :: ModifyWorkspaceState
s@ModifyWorkspaceState' {} Text
a -> ModifyWorkspaceState
s {$sel:workspaceId:ModifyWorkspaceState' :: Text
workspaceId = Text
a} :: ModifyWorkspaceState)

-- | The WorkSpace state.
modifyWorkspaceState_workspaceState :: Lens.Lens' ModifyWorkspaceState TargetWorkspaceState
modifyWorkspaceState_workspaceState :: (TargetWorkspaceState -> f TargetWorkspaceState)
-> ModifyWorkspaceState -> f ModifyWorkspaceState
modifyWorkspaceState_workspaceState = (ModifyWorkspaceState -> TargetWorkspaceState)
-> (ModifyWorkspaceState
    -> TargetWorkspaceState -> ModifyWorkspaceState)
-> Lens
     ModifyWorkspaceState
     ModifyWorkspaceState
     TargetWorkspaceState
     TargetWorkspaceState
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModifyWorkspaceState' {TargetWorkspaceState
workspaceState :: TargetWorkspaceState
$sel:workspaceState:ModifyWorkspaceState' :: ModifyWorkspaceState -> TargetWorkspaceState
workspaceState} -> TargetWorkspaceState
workspaceState) (\s :: ModifyWorkspaceState
s@ModifyWorkspaceState' {} TargetWorkspaceState
a -> ModifyWorkspaceState
s {$sel:workspaceState:ModifyWorkspaceState' :: TargetWorkspaceState
workspaceState = TargetWorkspaceState
a} :: ModifyWorkspaceState)

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

instance Prelude.NFData ModifyWorkspaceState

instance Core.ToHeaders ModifyWorkspaceState where
  toHeaders :: ModifyWorkspaceState -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ModifyWorkspaceState -> 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
"WorkspacesService.ModifyWorkspaceState" ::
                          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 ModifyWorkspaceState where
  toJSON :: ModifyWorkspaceState -> Value
toJSON ModifyWorkspaceState' {Text
TargetWorkspaceState
workspaceState :: TargetWorkspaceState
workspaceId :: Text
$sel:workspaceState:ModifyWorkspaceState' :: ModifyWorkspaceState -> TargetWorkspaceState
$sel:workspaceId:ModifyWorkspaceState' :: ModifyWorkspaceState -> 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
"WorkspaceId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
workspaceId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"WorkspaceState" Text -> TargetWorkspaceState -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= TargetWorkspaceState
workspaceState)
          ]
      )

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

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

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

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

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

instance Prelude.NFData ModifyWorkspaceStateResponse