{-# 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.OpsWorks.DescribeUserProfiles
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Describe specified users.
--
-- __Required Permissions__: To use this action, an IAM user must have an
-- attached policy that explicitly grants permissions. For more information
-- about user permissions, see
-- <https://docs.aws.amazon.com/opsworks/latest/userguide/opsworks-security-users.html Managing User Permissions>.
module Amazonka.OpsWorks.DescribeUserProfiles
  ( -- * Creating a Request
    DescribeUserProfiles (..),
    newDescribeUserProfiles,

    -- * Request Lenses
    describeUserProfiles_iamUserArns,

    -- * Destructuring the Response
    DescribeUserProfilesResponse (..),
    newDescribeUserProfilesResponse,

    -- * Response Lenses
    describeUserProfilesResponse_userProfiles,
    describeUserProfilesResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.OpsWorks.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newDescribeUserProfiles' smart constructor.
data DescribeUserProfiles = DescribeUserProfiles'
  { -- | An array of IAM or federated user ARNs that identify the users to be
    -- described.
    DescribeUserProfiles -> Maybe [Text]
iamUserArns :: Prelude.Maybe [Prelude.Text]
  }
  deriving (DescribeUserProfiles -> DescribeUserProfiles -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeUserProfiles -> DescribeUserProfiles -> Bool
$c/= :: DescribeUserProfiles -> DescribeUserProfiles -> Bool
== :: DescribeUserProfiles -> DescribeUserProfiles -> Bool
$c== :: DescribeUserProfiles -> DescribeUserProfiles -> Bool
Prelude.Eq, ReadPrec [DescribeUserProfiles]
ReadPrec DescribeUserProfiles
Int -> ReadS DescribeUserProfiles
ReadS [DescribeUserProfiles]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeUserProfiles]
$creadListPrec :: ReadPrec [DescribeUserProfiles]
readPrec :: ReadPrec DescribeUserProfiles
$creadPrec :: ReadPrec DescribeUserProfiles
readList :: ReadS [DescribeUserProfiles]
$creadList :: ReadS [DescribeUserProfiles]
readsPrec :: Int -> ReadS DescribeUserProfiles
$creadsPrec :: Int -> ReadS DescribeUserProfiles
Prelude.Read, Int -> DescribeUserProfiles -> ShowS
[DescribeUserProfiles] -> ShowS
DescribeUserProfiles -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeUserProfiles] -> ShowS
$cshowList :: [DescribeUserProfiles] -> ShowS
show :: DescribeUserProfiles -> String
$cshow :: DescribeUserProfiles -> String
showsPrec :: Int -> DescribeUserProfiles -> ShowS
$cshowsPrec :: Int -> DescribeUserProfiles -> ShowS
Prelude.Show, forall x. Rep DescribeUserProfiles x -> DescribeUserProfiles
forall x. DescribeUserProfiles -> Rep DescribeUserProfiles x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeUserProfiles x -> DescribeUserProfiles
$cfrom :: forall x. DescribeUserProfiles -> Rep DescribeUserProfiles x
Prelude.Generic)

-- |
-- Create a value of 'DescribeUserProfiles' 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:
--
-- 'iamUserArns', 'describeUserProfiles_iamUserArns' - An array of IAM or federated user ARNs that identify the users to be
-- described.
newDescribeUserProfiles ::
  DescribeUserProfiles
newDescribeUserProfiles :: DescribeUserProfiles
newDescribeUserProfiles =
  DescribeUserProfiles'
    { $sel:iamUserArns:DescribeUserProfiles' :: Maybe [Text]
iamUserArns =
        forall a. Maybe a
Prelude.Nothing
    }

-- | An array of IAM or federated user ARNs that identify the users to be
-- described.
describeUserProfiles_iamUserArns :: Lens.Lens' DescribeUserProfiles (Prelude.Maybe [Prelude.Text])
describeUserProfiles_iamUserArns :: Lens' DescribeUserProfiles (Maybe [Text])
describeUserProfiles_iamUserArns = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeUserProfiles' {Maybe [Text]
iamUserArns :: Maybe [Text]
$sel:iamUserArns:DescribeUserProfiles' :: DescribeUserProfiles -> Maybe [Text]
iamUserArns} -> Maybe [Text]
iamUserArns) (\s :: DescribeUserProfiles
s@DescribeUserProfiles' {} Maybe [Text]
a -> DescribeUserProfiles
s {$sel:iamUserArns:DescribeUserProfiles' :: Maybe [Text]
iamUserArns = Maybe [Text]
a} :: DescribeUserProfiles) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest DescribeUserProfiles where
  type
    AWSResponse DescribeUserProfiles =
      DescribeUserProfilesResponse
  request :: (Service -> Service)
-> DescribeUserProfiles -> Request DescribeUserProfiles
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DescribeUserProfiles
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeUserProfiles)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe [UserProfile] -> Int -> DescribeUserProfilesResponse
DescribeUserProfilesResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"UserProfiles" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable DescribeUserProfiles where
  hashWithSalt :: Int -> DescribeUserProfiles -> Int
hashWithSalt Int
_salt DescribeUserProfiles' {Maybe [Text]
iamUserArns :: Maybe [Text]
$sel:iamUserArns:DescribeUserProfiles' :: DescribeUserProfiles -> Maybe [Text]
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
iamUserArns

instance Prelude.NFData DescribeUserProfiles where
  rnf :: DescribeUserProfiles -> ()
rnf DescribeUserProfiles' {Maybe [Text]
iamUserArns :: Maybe [Text]
$sel:iamUserArns:DescribeUserProfiles' :: DescribeUserProfiles -> Maybe [Text]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
iamUserArns

instance Data.ToHeaders DescribeUserProfiles where
  toHeaders :: DescribeUserProfiles -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"OpsWorks_20130218.DescribeUserProfiles" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON DescribeUserProfiles where
  toJSON :: DescribeUserProfiles -> Value
toJSON DescribeUserProfiles' {Maybe [Text]
iamUserArns :: Maybe [Text]
$sel:iamUserArns:DescribeUserProfiles' :: DescribeUserProfiles -> Maybe [Text]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Key
"IamUserArns" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
iamUserArns]
      )

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

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

-- | Contains the response to a @DescribeUserProfiles@ request.
--
-- /See:/ 'newDescribeUserProfilesResponse' smart constructor.
data DescribeUserProfilesResponse = DescribeUserProfilesResponse'
  { -- | A @Users@ object that describes the specified users.
    DescribeUserProfilesResponse -> Maybe [UserProfile]
userProfiles :: Prelude.Maybe [UserProfile],
    -- | The response's http status code.
    DescribeUserProfilesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeUserProfilesResponse
-> DescribeUserProfilesResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeUserProfilesResponse
-> DescribeUserProfilesResponse -> Bool
$c/= :: DescribeUserProfilesResponse
-> DescribeUserProfilesResponse -> Bool
== :: DescribeUserProfilesResponse
-> DescribeUserProfilesResponse -> Bool
$c== :: DescribeUserProfilesResponse
-> DescribeUserProfilesResponse -> Bool
Prelude.Eq, ReadPrec [DescribeUserProfilesResponse]
ReadPrec DescribeUserProfilesResponse
Int -> ReadS DescribeUserProfilesResponse
ReadS [DescribeUserProfilesResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeUserProfilesResponse]
$creadListPrec :: ReadPrec [DescribeUserProfilesResponse]
readPrec :: ReadPrec DescribeUserProfilesResponse
$creadPrec :: ReadPrec DescribeUserProfilesResponse
readList :: ReadS [DescribeUserProfilesResponse]
$creadList :: ReadS [DescribeUserProfilesResponse]
readsPrec :: Int -> ReadS DescribeUserProfilesResponse
$creadsPrec :: Int -> ReadS DescribeUserProfilesResponse
Prelude.Read, Int -> DescribeUserProfilesResponse -> ShowS
[DescribeUserProfilesResponse] -> ShowS
DescribeUserProfilesResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeUserProfilesResponse] -> ShowS
$cshowList :: [DescribeUserProfilesResponse] -> ShowS
show :: DescribeUserProfilesResponse -> String
$cshow :: DescribeUserProfilesResponse -> String
showsPrec :: Int -> DescribeUserProfilesResponse -> ShowS
$cshowsPrec :: Int -> DescribeUserProfilesResponse -> ShowS
Prelude.Show, forall x.
Rep DescribeUserProfilesResponse x -> DescribeUserProfilesResponse
forall x.
DescribeUserProfilesResponse -> Rep DescribeUserProfilesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeUserProfilesResponse x -> DescribeUserProfilesResponse
$cfrom :: forall x.
DescribeUserProfilesResponse -> Rep DescribeUserProfilesResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeUserProfilesResponse' 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:
--
-- 'userProfiles', 'describeUserProfilesResponse_userProfiles' - A @Users@ object that describes the specified users.
--
-- 'httpStatus', 'describeUserProfilesResponse_httpStatus' - The response's http status code.
newDescribeUserProfilesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeUserProfilesResponse
newDescribeUserProfilesResponse :: Int -> DescribeUserProfilesResponse
newDescribeUserProfilesResponse Int
pHttpStatus_ =
  DescribeUserProfilesResponse'
    { $sel:userProfiles:DescribeUserProfilesResponse' :: Maybe [UserProfile]
userProfiles =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeUserProfilesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A @Users@ object that describes the specified users.
describeUserProfilesResponse_userProfiles :: Lens.Lens' DescribeUserProfilesResponse (Prelude.Maybe [UserProfile])
describeUserProfilesResponse_userProfiles :: Lens' DescribeUserProfilesResponse (Maybe [UserProfile])
describeUserProfilesResponse_userProfiles = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeUserProfilesResponse' {Maybe [UserProfile]
userProfiles :: Maybe [UserProfile]
$sel:userProfiles:DescribeUserProfilesResponse' :: DescribeUserProfilesResponse -> Maybe [UserProfile]
userProfiles} -> Maybe [UserProfile]
userProfiles) (\s :: DescribeUserProfilesResponse
s@DescribeUserProfilesResponse' {} Maybe [UserProfile]
a -> DescribeUserProfilesResponse
s {$sel:userProfiles:DescribeUserProfilesResponse' :: Maybe [UserProfile]
userProfiles = Maybe [UserProfile]
a} :: DescribeUserProfilesResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData DescribeUserProfilesResponse where
  rnf :: DescribeUserProfilesResponse -> ()
rnf DescribeUserProfilesResponse' {Int
Maybe [UserProfile]
httpStatus :: Int
userProfiles :: Maybe [UserProfile]
$sel:httpStatus:DescribeUserProfilesResponse' :: DescribeUserProfilesResponse -> Int
$sel:userProfiles:DescribeUserProfilesResponse' :: DescribeUserProfilesResponse -> Maybe [UserProfile]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [UserProfile]
userProfiles
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus