{-# 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.DescribeUserHierarchyStructure
-- 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)
--
-- Describes the hierarchy structure of the specified Amazon Connect
-- instance.
module Amazonka.Connect.DescribeUserHierarchyStructure
  ( -- * Creating a Request
    DescribeUserHierarchyStructure (..),
    newDescribeUserHierarchyStructure,

    -- * Request Lenses
    describeUserHierarchyStructure_instanceId,

    -- * Destructuring the Response
    DescribeUserHierarchyStructureResponse (..),
    newDescribeUserHierarchyStructureResponse,

    -- * Response Lenses
    describeUserHierarchyStructureResponse_hierarchyStructure,
    describeUserHierarchyStructureResponse_httpStatus,
  )
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:/ 'newDescribeUserHierarchyStructure' smart constructor.
data DescribeUserHierarchyStructure = DescribeUserHierarchyStructure'
  { -- | The identifier of the Amazon Connect instance. You can find the
    -- instanceId in the ARN of the instance.
    DescribeUserHierarchyStructure -> Text
instanceId :: Prelude.Text
  }
  deriving (DescribeUserHierarchyStructure
-> DescribeUserHierarchyStructure -> Bool
(DescribeUserHierarchyStructure
 -> DescribeUserHierarchyStructure -> Bool)
-> (DescribeUserHierarchyStructure
    -> DescribeUserHierarchyStructure -> Bool)
-> Eq DescribeUserHierarchyStructure
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeUserHierarchyStructure
-> DescribeUserHierarchyStructure -> Bool
$c/= :: DescribeUserHierarchyStructure
-> DescribeUserHierarchyStructure -> Bool
== :: DescribeUserHierarchyStructure
-> DescribeUserHierarchyStructure -> Bool
$c== :: DescribeUserHierarchyStructure
-> DescribeUserHierarchyStructure -> Bool
Prelude.Eq, ReadPrec [DescribeUserHierarchyStructure]
ReadPrec DescribeUserHierarchyStructure
Int -> ReadS DescribeUserHierarchyStructure
ReadS [DescribeUserHierarchyStructure]
(Int -> ReadS DescribeUserHierarchyStructure)
-> ReadS [DescribeUserHierarchyStructure]
-> ReadPrec DescribeUserHierarchyStructure
-> ReadPrec [DescribeUserHierarchyStructure]
-> Read DescribeUserHierarchyStructure
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeUserHierarchyStructure]
$creadListPrec :: ReadPrec [DescribeUserHierarchyStructure]
readPrec :: ReadPrec DescribeUserHierarchyStructure
$creadPrec :: ReadPrec DescribeUserHierarchyStructure
readList :: ReadS [DescribeUserHierarchyStructure]
$creadList :: ReadS [DescribeUserHierarchyStructure]
readsPrec :: Int -> ReadS DescribeUserHierarchyStructure
$creadsPrec :: Int -> ReadS DescribeUserHierarchyStructure
Prelude.Read, Int -> DescribeUserHierarchyStructure -> ShowS
[DescribeUserHierarchyStructure] -> ShowS
DescribeUserHierarchyStructure -> String
(Int -> DescribeUserHierarchyStructure -> ShowS)
-> (DescribeUserHierarchyStructure -> String)
-> ([DescribeUserHierarchyStructure] -> ShowS)
-> Show DescribeUserHierarchyStructure
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeUserHierarchyStructure] -> ShowS
$cshowList :: [DescribeUserHierarchyStructure] -> ShowS
show :: DescribeUserHierarchyStructure -> String
$cshow :: DescribeUserHierarchyStructure -> String
showsPrec :: Int -> DescribeUserHierarchyStructure -> ShowS
$cshowsPrec :: Int -> DescribeUserHierarchyStructure -> ShowS
Prelude.Show, (forall x.
 DescribeUserHierarchyStructure
 -> Rep DescribeUserHierarchyStructure x)
-> (forall x.
    Rep DescribeUserHierarchyStructure x
    -> DescribeUserHierarchyStructure)
-> Generic DescribeUserHierarchyStructure
forall x.
Rep DescribeUserHierarchyStructure x
-> DescribeUserHierarchyStructure
forall x.
DescribeUserHierarchyStructure
-> Rep DescribeUserHierarchyStructure x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeUserHierarchyStructure x
-> DescribeUserHierarchyStructure
$cfrom :: forall x.
DescribeUserHierarchyStructure
-> Rep DescribeUserHierarchyStructure x
Prelude.Generic)

-- |
-- Create a value of 'DescribeUserHierarchyStructure' 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:
--
-- 'instanceId', 'describeUserHierarchyStructure_instanceId' - The identifier of the Amazon Connect instance. You can find the
-- instanceId in the ARN of the instance.
newDescribeUserHierarchyStructure ::
  -- | 'instanceId'
  Prelude.Text ->
  DescribeUserHierarchyStructure
newDescribeUserHierarchyStructure :: Text -> DescribeUserHierarchyStructure
newDescribeUserHierarchyStructure Text
pInstanceId_ =
  DescribeUserHierarchyStructure' :: Text -> DescribeUserHierarchyStructure
DescribeUserHierarchyStructure'
    { $sel:instanceId:DescribeUserHierarchyStructure' :: Text
instanceId =
        Text
pInstanceId_
    }

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

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

instance
  Prelude.Hashable
    DescribeUserHierarchyStructure

instance
  Prelude.NFData
    DescribeUserHierarchyStructure

instance
  Core.ToHeaders
    DescribeUserHierarchyStructure
  where
  toHeaders :: DescribeUserHierarchyStructure -> ResponseHeaders
toHeaders =
    ResponseHeaders
-> DescribeUserHierarchyStructure -> 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.ToPath DescribeUserHierarchyStructure where
  toPath :: DescribeUserHierarchyStructure -> ByteString
toPath DescribeUserHierarchyStructure' {Text
instanceId :: Text
$sel:instanceId:DescribeUserHierarchyStructure' :: DescribeUserHierarchyStructure -> Text
..} =
    [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 DescribeUserHierarchyStructure where
  toQuery :: DescribeUserHierarchyStructure -> QueryString
toQuery = QueryString -> DescribeUserHierarchyStructure -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

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

-- |
-- Create a value of 'DescribeUserHierarchyStructureResponse' 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', 'describeUserHierarchyStructureResponse_hierarchyStructure' - Information about the hierarchy structure.
--
-- 'httpStatus', 'describeUserHierarchyStructureResponse_httpStatus' - The response's http status code.
newDescribeUserHierarchyStructureResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeUserHierarchyStructureResponse
newDescribeUserHierarchyStructureResponse :: Int -> DescribeUserHierarchyStructureResponse
newDescribeUserHierarchyStructureResponse
  Int
pHttpStatus_ =
    DescribeUserHierarchyStructureResponse' :: Maybe HierarchyStructure
-> Int -> DescribeUserHierarchyStructureResponse
DescribeUserHierarchyStructureResponse'
      { $sel:hierarchyStructure:DescribeUserHierarchyStructureResponse' :: Maybe HierarchyStructure
hierarchyStructure =
          Maybe HierarchyStructure
forall a. Maybe a
Prelude.Nothing,
        $sel:httpStatus:DescribeUserHierarchyStructureResponse' :: Int
httpStatus = Int
pHttpStatus_
      }

-- | Information about the hierarchy structure.
describeUserHierarchyStructureResponse_hierarchyStructure :: Lens.Lens' DescribeUserHierarchyStructureResponse (Prelude.Maybe HierarchyStructure)
describeUserHierarchyStructureResponse_hierarchyStructure :: (Maybe HierarchyStructure -> f (Maybe HierarchyStructure))
-> DescribeUserHierarchyStructureResponse
-> f DescribeUserHierarchyStructureResponse
describeUserHierarchyStructureResponse_hierarchyStructure = (DescribeUserHierarchyStructureResponse
 -> Maybe HierarchyStructure)
-> (DescribeUserHierarchyStructureResponse
    -> Maybe HierarchyStructure
    -> DescribeUserHierarchyStructureResponse)
-> Lens
     DescribeUserHierarchyStructureResponse
     DescribeUserHierarchyStructureResponse
     (Maybe HierarchyStructure)
     (Maybe HierarchyStructure)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeUserHierarchyStructureResponse' {Maybe HierarchyStructure
hierarchyStructure :: Maybe HierarchyStructure
$sel:hierarchyStructure:DescribeUserHierarchyStructureResponse' :: DescribeUserHierarchyStructureResponse -> Maybe HierarchyStructure
hierarchyStructure} -> Maybe HierarchyStructure
hierarchyStructure) (\s :: DescribeUserHierarchyStructureResponse
s@DescribeUserHierarchyStructureResponse' {} Maybe HierarchyStructure
a -> DescribeUserHierarchyStructureResponse
s {$sel:hierarchyStructure:DescribeUserHierarchyStructureResponse' :: Maybe HierarchyStructure
hierarchyStructure = Maybe HierarchyStructure
a} :: DescribeUserHierarchyStructureResponse)

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

instance
  Prelude.NFData
    DescribeUserHierarchyStructureResponse