{-# 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.Connect.UpdateUserHierarchyStructure
-- 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)
--
-- Updates the user hierarchy structure: add, remove, and rename user
-- hierarchy levels.
module Amazonka.Connect.UpdateUserHierarchyStructure
  ( -- * Creating a Request
    UpdateUserHierarchyStructure (..),
    newUpdateUserHierarchyStructure,

    -- * Request Lenses
    updateUserHierarchyStructure_hierarchyStructure,
    updateUserHierarchyStructure_instanceId,

    -- * Destructuring the Response
    UpdateUserHierarchyStructureResponse (..),
    newUpdateUserHierarchyStructureResponse,
  )
where

import Amazonka.Connect.Types
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

-- | /See:/ 'newUpdateUserHierarchyStructure' smart constructor.
data UpdateUserHierarchyStructure = UpdateUserHierarchyStructure'
  { -- | The hierarchy levels to update.
    UpdateUserHierarchyStructure -> HierarchyStructureUpdate
hierarchyStructure :: HierarchyStructureUpdate,
    -- | The identifier of the Amazon Connect instance. You can find the
    -- instanceId in the ARN of the instance.
    UpdateUserHierarchyStructure -> Text
instanceId :: Prelude.Text
  }
  deriving (UpdateUserHierarchyStructure
-> UpdateUserHierarchyStructure -> Bool
(UpdateUserHierarchyStructure
 -> UpdateUserHierarchyStructure -> Bool)
-> (UpdateUserHierarchyStructure
    -> UpdateUserHierarchyStructure -> Bool)
-> Eq UpdateUserHierarchyStructure
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateUserHierarchyStructure
-> UpdateUserHierarchyStructure -> Bool
$c/= :: UpdateUserHierarchyStructure
-> UpdateUserHierarchyStructure -> Bool
== :: UpdateUserHierarchyStructure
-> UpdateUserHierarchyStructure -> Bool
$c== :: UpdateUserHierarchyStructure
-> UpdateUserHierarchyStructure -> Bool
Prelude.Eq, ReadPrec [UpdateUserHierarchyStructure]
ReadPrec UpdateUserHierarchyStructure
Int -> ReadS UpdateUserHierarchyStructure
ReadS [UpdateUserHierarchyStructure]
(Int -> ReadS UpdateUserHierarchyStructure)
-> ReadS [UpdateUserHierarchyStructure]
-> ReadPrec UpdateUserHierarchyStructure
-> ReadPrec [UpdateUserHierarchyStructure]
-> Read UpdateUserHierarchyStructure
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateUserHierarchyStructure]
$creadListPrec :: ReadPrec [UpdateUserHierarchyStructure]
readPrec :: ReadPrec UpdateUserHierarchyStructure
$creadPrec :: ReadPrec UpdateUserHierarchyStructure
readList :: ReadS [UpdateUserHierarchyStructure]
$creadList :: ReadS [UpdateUserHierarchyStructure]
readsPrec :: Int -> ReadS UpdateUserHierarchyStructure
$creadsPrec :: Int -> ReadS UpdateUserHierarchyStructure
Prelude.Read, Int -> UpdateUserHierarchyStructure -> ShowS
[UpdateUserHierarchyStructure] -> ShowS
UpdateUserHierarchyStructure -> String
(Int -> UpdateUserHierarchyStructure -> ShowS)
-> (UpdateUserHierarchyStructure -> String)
-> ([UpdateUserHierarchyStructure] -> ShowS)
-> Show UpdateUserHierarchyStructure
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateUserHierarchyStructure] -> ShowS
$cshowList :: [UpdateUserHierarchyStructure] -> ShowS
show :: UpdateUserHierarchyStructure -> String
$cshow :: UpdateUserHierarchyStructure -> String
showsPrec :: Int -> UpdateUserHierarchyStructure -> ShowS
$cshowsPrec :: Int -> UpdateUserHierarchyStructure -> ShowS
Prelude.Show, (forall x.
 UpdateUserHierarchyStructure -> Rep UpdateUserHierarchyStructure x)
-> (forall x.
    Rep UpdateUserHierarchyStructure x -> UpdateUserHierarchyStructure)
-> Generic UpdateUserHierarchyStructure
forall x.
Rep UpdateUserHierarchyStructure x -> UpdateUserHierarchyStructure
forall x.
UpdateUserHierarchyStructure -> Rep UpdateUserHierarchyStructure x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateUserHierarchyStructure x -> UpdateUserHierarchyStructure
$cfrom :: forall x.
UpdateUserHierarchyStructure -> Rep UpdateUserHierarchyStructure x
Prelude.Generic)

-- |
-- Create a value of 'UpdateUserHierarchyStructure' 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:
--
-- 'hierarchyStructure', 'updateUserHierarchyStructure_hierarchyStructure' - The hierarchy levels to update.
--
-- 'instanceId', 'updateUserHierarchyStructure_instanceId' - The identifier of the Amazon Connect instance. You can find the
-- instanceId in the ARN of the instance.
newUpdateUserHierarchyStructure ::
  -- | 'hierarchyStructure'
  HierarchyStructureUpdate ->
  -- | 'instanceId'
  Prelude.Text ->
  UpdateUserHierarchyStructure
newUpdateUserHierarchyStructure :: HierarchyStructureUpdate -> Text -> UpdateUserHierarchyStructure
newUpdateUserHierarchyStructure
  HierarchyStructureUpdate
pHierarchyStructure_
  Text
pInstanceId_ =
    UpdateUserHierarchyStructure' :: HierarchyStructureUpdate -> Text -> UpdateUserHierarchyStructure
UpdateUserHierarchyStructure'
      { $sel:hierarchyStructure:UpdateUserHierarchyStructure' :: HierarchyStructureUpdate
hierarchyStructure =
          HierarchyStructureUpdate
pHierarchyStructure_,
        $sel:instanceId:UpdateUserHierarchyStructure' :: Text
instanceId = Text
pInstanceId_
      }

-- | The hierarchy levels to update.
updateUserHierarchyStructure_hierarchyStructure :: Lens.Lens' UpdateUserHierarchyStructure HierarchyStructureUpdate
updateUserHierarchyStructure_hierarchyStructure :: (HierarchyStructureUpdate -> f HierarchyStructureUpdate)
-> UpdateUserHierarchyStructure -> f UpdateUserHierarchyStructure
updateUserHierarchyStructure_hierarchyStructure = (UpdateUserHierarchyStructure -> HierarchyStructureUpdate)
-> (UpdateUserHierarchyStructure
    -> HierarchyStructureUpdate -> UpdateUserHierarchyStructure)
-> Lens
     UpdateUserHierarchyStructure
     UpdateUserHierarchyStructure
     HierarchyStructureUpdate
     HierarchyStructureUpdate
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateUserHierarchyStructure' {HierarchyStructureUpdate
hierarchyStructure :: HierarchyStructureUpdate
$sel:hierarchyStructure:UpdateUserHierarchyStructure' :: UpdateUserHierarchyStructure -> HierarchyStructureUpdate
hierarchyStructure} -> HierarchyStructureUpdate
hierarchyStructure) (\s :: UpdateUserHierarchyStructure
s@UpdateUserHierarchyStructure' {} HierarchyStructureUpdate
a -> UpdateUserHierarchyStructure
s {$sel:hierarchyStructure:UpdateUserHierarchyStructure' :: HierarchyStructureUpdate
hierarchyStructure = HierarchyStructureUpdate
a} :: UpdateUserHierarchyStructure)

-- | The identifier of the Amazon Connect instance. You can find the
-- instanceId in the ARN of the instance.
updateUserHierarchyStructure_instanceId :: Lens.Lens' UpdateUserHierarchyStructure Prelude.Text
updateUserHierarchyStructure_instanceId :: (Text -> f Text)
-> UpdateUserHierarchyStructure -> f UpdateUserHierarchyStructure
updateUserHierarchyStructure_instanceId = (UpdateUserHierarchyStructure -> Text)
-> (UpdateUserHierarchyStructure
    -> Text -> UpdateUserHierarchyStructure)
-> Lens
     UpdateUserHierarchyStructure UpdateUserHierarchyStructure Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateUserHierarchyStructure' {Text
instanceId :: Text
$sel:instanceId:UpdateUserHierarchyStructure' :: UpdateUserHierarchyStructure -> Text
instanceId} -> Text
instanceId) (\s :: UpdateUserHierarchyStructure
s@UpdateUserHierarchyStructure' {} Text
a -> UpdateUserHierarchyStructure
s {$sel:instanceId:UpdateUserHierarchyStructure' :: Text
instanceId = Text
a} :: UpdateUserHierarchyStructure)

instance Core.AWSRequest UpdateUserHierarchyStructure where
  type
    AWSResponse UpdateUserHierarchyStructure =
      UpdateUserHierarchyStructureResponse
  request :: UpdateUserHierarchyStructure
-> Request UpdateUserHierarchyStructure
request = Service
-> UpdateUserHierarchyStructure
-> Request UpdateUserHierarchyStructure
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateUserHierarchyStructure
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateUserHierarchyStructure)))
response =
    AWSResponse UpdateUserHierarchyStructure
-> Logger
-> Service
-> Proxy UpdateUserHierarchyStructure
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateUserHierarchyStructure)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull
      AWSResponse UpdateUserHierarchyStructure
UpdateUserHierarchyStructureResponse
UpdateUserHierarchyStructureResponse'

instance
  Prelude.Hashable
    UpdateUserHierarchyStructure

instance Prelude.NFData UpdateUserHierarchyStructure

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

instance Core.ToJSON UpdateUserHierarchyStructure where
  toJSON :: UpdateUserHierarchyStructure -> Value
toJSON UpdateUserHierarchyStructure' {Text
HierarchyStructureUpdate
instanceId :: Text
hierarchyStructure :: HierarchyStructureUpdate
$sel:instanceId:UpdateUserHierarchyStructure' :: UpdateUserHierarchyStructure -> Text
$sel:hierarchyStructure:UpdateUserHierarchyStructure' :: UpdateUserHierarchyStructure -> HierarchyStructureUpdate
..} =
    [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
"HierarchyStructure" Text -> HierarchyStructureUpdate -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= HierarchyStructureUpdate
hierarchyStructure)
          ]
      )

instance Core.ToPath UpdateUserHierarchyStructure where
  toPath :: UpdateUserHierarchyStructure -> ByteString
toPath UpdateUserHierarchyStructure' {Text
HierarchyStructureUpdate
instanceId :: Text
hierarchyStructure :: HierarchyStructureUpdate
$sel:instanceId:UpdateUserHierarchyStructure' :: UpdateUserHierarchyStructure -> Text
$sel:hierarchyStructure:UpdateUserHierarchyStructure' :: UpdateUserHierarchyStructure -> HierarchyStructureUpdate
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/user-hierarchy-structure/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
instanceId]

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

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

-- |
-- Create a value of 'UpdateUserHierarchyStructureResponse' 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.
newUpdateUserHierarchyStructureResponse ::
  UpdateUserHierarchyStructureResponse
newUpdateUserHierarchyStructureResponse :: UpdateUserHierarchyStructureResponse
newUpdateUserHierarchyStructureResponse =
  UpdateUserHierarchyStructureResponse
UpdateUserHierarchyStructureResponse'

instance
  Prelude.NFData
    UpdateUserHierarchyStructureResponse