{-# 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.ModifySelfservicePermissions
-- 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)
--
-- Modifies the self-service WorkSpace management capabilities for your
-- users. For more information, see
-- <https://docs.aws.amazon.com/workspaces/latest/adminguide/enable-user-self-service-workspace-management.html Enable Self-Service WorkSpace Management Capabilities for Your Users>.
module Amazonka.WorkSpaces.ModifySelfservicePermissions
  ( -- * Creating a Request
    ModifySelfservicePermissions (..),
    newModifySelfservicePermissions,

    -- * Request Lenses
    modifySelfservicePermissions_resourceId,
    modifySelfservicePermissions_selfservicePermissions,

    -- * Destructuring the Response
    ModifySelfservicePermissionsResponse (..),
    newModifySelfservicePermissionsResponse,

    -- * Response Lenses
    modifySelfservicePermissionsResponse_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:/ 'newModifySelfservicePermissions' smart constructor.
data ModifySelfservicePermissions = ModifySelfservicePermissions'
  { -- | The identifier of the directory.
    ModifySelfservicePermissions -> Text
resourceId :: Prelude.Text,
    -- | The permissions to enable or disable self-service capabilities.
    ModifySelfservicePermissions -> SelfservicePermissions
selfservicePermissions :: SelfservicePermissions
  }
  deriving (ModifySelfservicePermissions
-> ModifySelfservicePermissions -> Bool
(ModifySelfservicePermissions
 -> ModifySelfservicePermissions -> Bool)
-> (ModifySelfservicePermissions
    -> ModifySelfservicePermissions -> Bool)
-> Eq ModifySelfservicePermissions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ModifySelfservicePermissions
-> ModifySelfservicePermissions -> Bool
$c/= :: ModifySelfservicePermissions
-> ModifySelfservicePermissions -> Bool
== :: ModifySelfservicePermissions
-> ModifySelfservicePermissions -> Bool
$c== :: ModifySelfservicePermissions
-> ModifySelfservicePermissions -> Bool
Prelude.Eq, ReadPrec [ModifySelfservicePermissions]
ReadPrec ModifySelfservicePermissions
Int -> ReadS ModifySelfservicePermissions
ReadS [ModifySelfservicePermissions]
(Int -> ReadS ModifySelfservicePermissions)
-> ReadS [ModifySelfservicePermissions]
-> ReadPrec ModifySelfservicePermissions
-> ReadPrec [ModifySelfservicePermissions]
-> Read ModifySelfservicePermissions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ModifySelfservicePermissions]
$creadListPrec :: ReadPrec [ModifySelfservicePermissions]
readPrec :: ReadPrec ModifySelfservicePermissions
$creadPrec :: ReadPrec ModifySelfservicePermissions
readList :: ReadS [ModifySelfservicePermissions]
$creadList :: ReadS [ModifySelfservicePermissions]
readsPrec :: Int -> ReadS ModifySelfservicePermissions
$creadsPrec :: Int -> ReadS ModifySelfservicePermissions
Prelude.Read, Int -> ModifySelfservicePermissions -> ShowS
[ModifySelfservicePermissions] -> ShowS
ModifySelfservicePermissions -> String
(Int -> ModifySelfservicePermissions -> ShowS)
-> (ModifySelfservicePermissions -> String)
-> ([ModifySelfservicePermissions] -> ShowS)
-> Show ModifySelfservicePermissions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ModifySelfservicePermissions] -> ShowS
$cshowList :: [ModifySelfservicePermissions] -> ShowS
show :: ModifySelfservicePermissions -> String
$cshow :: ModifySelfservicePermissions -> String
showsPrec :: Int -> ModifySelfservicePermissions -> ShowS
$cshowsPrec :: Int -> ModifySelfservicePermissions -> ShowS
Prelude.Show, (forall x.
 ModifySelfservicePermissions -> Rep ModifySelfservicePermissions x)
-> (forall x.
    Rep ModifySelfservicePermissions x -> ModifySelfservicePermissions)
-> Generic ModifySelfservicePermissions
forall x.
Rep ModifySelfservicePermissions x -> ModifySelfservicePermissions
forall x.
ModifySelfservicePermissions -> Rep ModifySelfservicePermissions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ModifySelfservicePermissions x -> ModifySelfservicePermissions
$cfrom :: forall x.
ModifySelfservicePermissions -> Rep ModifySelfservicePermissions x
Prelude.Generic)

-- |
-- Create a value of 'ModifySelfservicePermissions' 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:
--
-- 'resourceId', 'modifySelfservicePermissions_resourceId' - The identifier of the directory.
--
-- 'selfservicePermissions', 'modifySelfservicePermissions_selfservicePermissions' - The permissions to enable or disable self-service capabilities.
newModifySelfservicePermissions ::
  -- | 'resourceId'
  Prelude.Text ->
  -- | 'selfservicePermissions'
  SelfservicePermissions ->
  ModifySelfservicePermissions
newModifySelfservicePermissions :: Text -> SelfservicePermissions -> ModifySelfservicePermissions
newModifySelfservicePermissions
  Text
pResourceId_
  SelfservicePermissions
pSelfservicePermissions_ =
    ModifySelfservicePermissions' :: Text -> SelfservicePermissions -> ModifySelfservicePermissions
ModifySelfservicePermissions'
      { $sel:resourceId:ModifySelfservicePermissions' :: Text
resourceId =
          Text
pResourceId_,
        $sel:selfservicePermissions:ModifySelfservicePermissions' :: SelfservicePermissions
selfservicePermissions =
          SelfservicePermissions
pSelfservicePermissions_
      }

-- | The identifier of the directory.
modifySelfservicePermissions_resourceId :: Lens.Lens' ModifySelfservicePermissions Prelude.Text
modifySelfservicePermissions_resourceId :: (Text -> f Text)
-> ModifySelfservicePermissions -> f ModifySelfservicePermissions
modifySelfservicePermissions_resourceId = (ModifySelfservicePermissions -> Text)
-> (ModifySelfservicePermissions
    -> Text -> ModifySelfservicePermissions)
-> Lens
     ModifySelfservicePermissions ModifySelfservicePermissions Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModifySelfservicePermissions' {Text
resourceId :: Text
$sel:resourceId:ModifySelfservicePermissions' :: ModifySelfservicePermissions -> Text
resourceId} -> Text
resourceId) (\s :: ModifySelfservicePermissions
s@ModifySelfservicePermissions' {} Text
a -> ModifySelfservicePermissions
s {$sel:resourceId:ModifySelfservicePermissions' :: Text
resourceId = Text
a} :: ModifySelfservicePermissions)

-- | The permissions to enable or disable self-service capabilities.
modifySelfservicePermissions_selfservicePermissions :: Lens.Lens' ModifySelfservicePermissions SelfservicePermissions
modifySelfservicePermissions_selfservicePermissions :: (SelfservicePermissions -> f SelfservicePermissions)
-> ModifySelfservicePermissions -> f ModifySelfservicePermissions
modifySelfservicePermissions_selfservicePermissions = (ModifySelfservicePermissions -> SelfservicePermissions)
-> (ModifySelfservicePermissions
    -> SelfservicePermissions -> ModifySelfservicePermissions)
-> Lens
     ModifySelfservicePermissions
     ModifySelfservicePermissions
     SelfservicePermissions
     SelfservicePermissions
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModifySelfservicePermissions' {SelfservicePermissions
selfservicePermissions :: SelfservicePermissions
$sel:selfservicePermissions:ModifySelfservicePermissions' :: ModifySelfservicePermissions -> SelfservicePermissions
selfservicePermissions} -> SelfservicePermissions
selfservicePermissions) (\s :: ModifySelfservicePermissions
s@ModifySelfservicePermissions' {} SelfservicePermissions
a -> ModifySelfservicePermissions
s {$sel:selfservicePermissions:ModifySelfservicePermissions' :: SelfservicePermissions
selfservicePermissions = SelfservicePermissions
a} :: ModifySelfservicePermissions)

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

instance Prelude.NFData ModifySelfservicePermissions

instance Core.ToHeaders ModifySelfservicePermissions where
  toHeaders :: ModifySelfservicePermissions -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ModifySelfservicePermissions -> 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.ModifySelfservicePermissions" ::
                          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 ModifySelfservicePermissions where
  toJSON :: ModifySelfservicePermissions -> Value
toJSON ModifySelfservicePermissions' {Text
SelfservicePermissions
selfservicePermissions :: SelfservicePermissions
resourceId :: Text
$sel:selfservicePermissions:ModifySelfservicePermissions' :: ModifySelfservicePermissions -> SelfservicePermissions
$sel:resourceId:ModifySelfservicePermissions' :: ModifySelfservicePermissions -> 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
"ResourceId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
resourceId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"SelfservicePermissions"
                  Text -> SelfservicePermissions -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= SelfservicePermissions
selfservicePermissions
              )
          ]
      )

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

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

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

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

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

instance
  Prelude.NFData
    ModifySelfservicePermissionsResponse