{-# 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-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)
--
-- 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.Lens as Lens
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
(DescribeUserProfiles -> DescribeUserProfiles -> Bool)
-> (DescribeUserProfiles -> DescribeUserProfiles -> Bool)
-> Eq DescribeUserProfiles
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]
(Int -> ReadS DescribeUserProfiles)
-> ReadS [DescribeUserProfiles]
-> ReadPrec DescribeUserProfiles
-> ReadPrec [DescribeUserProfiles]
-> Read 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
(Int -> DescribeUserProfiles -> ShowS)
-> (DescribeUserProfiles -> String)
-> ([DescribeUserProfiles] -> ShowS)
-> Show DescribeUserProfiles
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. DescribeUserProfiles -> Rep DescribeUserProfiles x)
-> (forall x. Rep DescribeUserProfiles x -> DescribeUserProfiles)
-> Generic DescribeUserProfiles
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' :: Maybe [Text] -> DescribeUserProfiles
DescribeUserProfiles'
    { $sel:iamUserArns:DescribeUserProfiles' :: Maybe [Text]
iamUserArns =
        Maybe [Text]
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 :: (Maybe [Text] -> f (Maybe [Text]))
-> DescribeUserProfiles -> f DescribeUserProfiles
describeUserProfiles_iamUserArns = (DescribeUserProfiles -> Maybe [Text])
-> (DescribeUserProfiles -> Maybe [Text] -> DescribeUserProfiles)
-> Lens
     DescribeUserProfiles
     DescribeUserProfiles
     (Maybe [Text])
     (Maybe [Text])
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) ((Maybe [Text] -> f (Maybe [Text]))
 -> DescribeUserProfiles -> f DescribeUserProfiles)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> DescribeUserProfiles
-> f DescribeUserProfiles
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 AnIso [Text] [Text] [Text] [Text]
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 :: DescribeUserProfiles -> Request DescribeUserProfiles
request = Service -> DescribeUserProfiles -> Request DescribeUserProfiles
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeUserProfiles
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeUserProfiles)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeUserProfiles))
-> Logger
-> Service
-> Proxy DescribeUserProfiles
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeUserProfiles)))
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 [UserProfile] -> Int -> DescribeUserProfilesResponse
DescribeUserProfilesResponse'
            (Maybe [UserProfile] -> Int -> DescribeUserProfilesResponse)
-> Either String (Maybe [UserProfile])
-> Either String (Int -> DescribeUserProfilesResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [UserProfile]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"UserProfiles" Either String (Maybe (Maybe [UserProfile]))
-> Maybe [UserProfile] -> Either String (Maybe [UserProfile])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [UserProfile]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Int -> DescribeUserProfilesResponse)
-> Either String Int -> Either String DescribeUserProfilesResponse
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 DescribeUserProfiles

instance Prelude.NFData DescribeUserProfiles

instance Core.ToHeaders DescribeUserProfiles where
  toHeaders :: DescribeUserProfiles -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeUserProfiles -> 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
"OpsWorks_20130218.DescribeUserProfiles" ::
                          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 DescribeUserProfiles where
  toJSON :: DescribeUserProfiles -> Value
toJSON DescribeUserProfiles' {Maybe [Text]
iamUserArns :: Maybe [Text]
$sel:iamUserArns:DescribeUserProfiles' :: DescribeUserProfiles -> Maybe [Text]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Text
"IamUserArns" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Text] -> Pair) -> Maybe [Text] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
iamUserArns]
      )

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

instance Core.ToQuery DescribeUserProfiles where
  toQuery :: DescribeUserProfiles -> QueryString
toQuery = QueryString -> DescribeUserProfiles -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(DescribeUserProfilesResponse
 -> DescribeUserProfilesResponse -> Bool)
-> (DescribeUserProfilesResponse
    -> DescribeUserProfilesResponse -> Bool)
-> Eq DescribeUserProfilesResponse
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]
(Int -> ReadS DescribeUserProfilesResponse)
-> ReadS [DescribeUserProfilesResponse]
-> ReadPrec DescribeUserProfilesResponse
-> ReadPrec [DescribeUserProfilesResponse]
-> Read 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
(Int -> DescribeUserProfilesResponse -> ShowS)
-> (DescribeUserProfilesResponse -> String)
-> ([DescribeUserProfilesResponse] -> ShowS)
-> Show DescribeUserProfilesResponse
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.
 DescribeUserProfilesResponse -> Rep DescribeUserProfilesResponse x)
-> (forall x.
    Rep DescribeUserProfilesResponse x -> DescribeUserProfilesResponse)
-> Generic DescribeUserProfilesResponse
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' :: Maybe [UserProfile] -> Int -> DescribeUserProfilesResponse
DescribeUserProfilesResponse'
    { $sel:userProfiles:DescribeUserProfilesResponse' :: Maybe [UserProfile]
userProfiles =
        Maybe [UserProfile]
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 :: (Maybe [UserProfile] -> f (Maybe [UserProfile]))
-> DescribeUserProfilesResponse -> f DescribeUserProfilesResponse
describeUserProfilesResponse_userProfiles = (DescribeUserProfilesResponse -> Maybe [UserProfile])
-> (DescribeUserProfilesResponse
    -> Maybe [UserProfile] -> DescribeUserProfilesResponse)
-> Lens
     DescribeUserProfilesResponse
     DescribeUserProfilesResponse
     (Maybe [UserProfile])
     (Maybe [UserProfile])
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) ((Maybe [UserProfile] -> f (Maybe [UserProfile]))
 -> DescribeUserProfilesResponse -> f DescribeUserProfilesResponse)
-> ((Maybe [UserProfile] -> f (Maybe [UserProfile]))
    -> Maybe [UserProfile] -> f (Maybe [UserProfile]))
-> (Maybe [UserProfile] -> f (Maybe [UserProfile]))
-> DescribeUserProfilesResponse
-> f DescribeUserProfilesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [UserProfile] [UserProfile] [UserProfile] [UserProfile]
-> Iso
     (Maybe [UserProfile])
     (Maybe [UserProfile])
     (Maybe [UserProfile])
     (Maybe [UserProfile])
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 AnIso [UserProfile] [UserProfile] [UserProfile] [UserProfile]
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 :: (Int -> f Int)
-> DescribeUserProfilesResponse -> f DescribeUserProfilesResponse
describeUserProfilesResponse_httpStatus = (DescribeUserProfilesResponse -> Int)
-> (DescribeUserProfilesResponse
    -> Int -> DescribeUserProfilesResponse)
-> Lens
     DescribeUserProfilesResponse DescribeUserProfilesResponse Int Int
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