{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric      #-}
{-# LANGUAGE OverloadedStrings  #-}
{-# LANGUAGE RecordWildCards    #-}
{-# LANGUAGE TypeFamilies       #-}

{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-binds   #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Network.AWS.CognitoIdentityProvider.AdminUpdateUserAttributes
-- Copyright   : (c) 2013-2016 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Updates the specified user\'s attributes, including developer attributes, as an administrator. Works on any user.
module Network.AWS.CognitoIdentityProvider.AdminUpdateUserAttributes
    (
    -- * Creating a Request
      adminUpdateUserAttributes
    , AdminUpdateUserAttributes
    -- * Request Lenses
    , auuaUserPoolId
    , auuaUsername
    , auuaUserAttributes

    -- * Destructuring the Response
    , adminUpdateUserAttributesResponse
    , AdminUpdateUserAttributesResponse
    -- * Response Lenses
    , auuarsResponseStatus
    ) where

import           Network.AWS.CognitoIdentityProvider.Types
import           Network.AWS.CognitoIdentityProvider.Types.Product
import           Network.AWS.Lens
import           Network.AWS.Prelude
import           Network.AWS.Request
import           Network.AWS.Response

-- | Represents the request to update the user\'s attributes as an administrator.
--
-- /See:/ 'adminUpdateUserAttributes' smart constructor.
data AdminUpdateUserAttributes = AdminUpdateUserAttributes'
    { _auuaUserPoolId     :: !Text
    , _auuaUsername       :: !(Sensitive Text)
    , _auuaUserAttributes :: ![AttributeType]
    } deriving (Eq,Read,Show,Data,Typeable,Generic)

-- | Creates a value of 'AdminUpdateUserAttributes' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'auuaUserPoolId'
--
-- * 'auuaUsername'
--
-- * 'auuaUserAttributes'
adminUpdateUserAttributes
    :: Text -- ^ 'auuaUserPoolId'
    -> Text -- ^ 'auuaUsername'
    -> AdminUpdateUserAttributes
adminUpdateUserAttributes pUserPoolId_ pUsername_ =
    AdminUpdateUserAttributes'
    { _auuaUserPoolId = pUserPoolId_
    , _auuaUsername = _Sensitive # pUsername_
    , _auuaUserAttributes = mempty
    }

-- | The user pool ID for the user pool where you want to update user attributes.
auuaUserPoolId :: Lens' AdminUpdateUserAttributes Text
auuaUserPoolId = lens _auuaUserPoolId (\ s a -> s{_auuaUserPoolId = a});

-- | The user name of the user for whom you want to update user attributes.
auuaUsername :: Lens' AdminUpdateUserAttributes Text
auuaUsername = lens _auuaUsername (\ s a -> s{_auuaUsername = a}) . _Sensitive;

-- | An array of name-value pairs representing user attributes.
auuaUserAttributes :: Lens' AdminUpdateUserAttributes [AttributeType]
auuaUserAttributes = lens _auuaUserAttributes (\ s a -> s{_auuaUserAttributes = a}) . _Coerce;

instance AWSRequest AdminUpdateUserAttributes where
        type Rs AdminUpdateUserAttributes =
             AdminUpdateUserAttributesResponse
        request = postJSON cognitoIdentityProvider
        response
          = receiveEmpty
              (\ s h x ->
                 AdminUpdateUserAttributesResponse' <$>
                   (pure (fromEnum s)))

instance Hashable AdminUpdateUserAttributes

instance NFData AdminUpdateUserAttributes

instance ToHeaders AdminUpdateUserAttributes where
        toHeaders
          = const
              (mconcat
                 ["X-Amz-Target" =#
                    ("AWSCognitoIdentityProviderService.AdminUpdateUserAttributes"
                       :: ByteString),
                  "Content-Type" =#
                    ("application/x-amz-json-1.1" :: ByteString)])

instance ToJSON AdminUpdateUserAttributes where
        toJSON AdminUpdateUserAttributes'{..}
          = object
              (catMaybes
                 [Just ("UserPoolId" .= _auuaUserPoolId),
                  Just ("Username" .= _auuaUsername),
                  Just ("UserAttributes" .= _auuaUserAttributes)])

instance ToPath AdminUpdateUserAttributes where
        toPath = const "/"

instance ToQuery AdminUpdateUserAttributes where
        toQuery = const mempty

-- | Represents the response from the server for the request to update user attributes as an administrator.
--
-- /See:/ 'adminUpdateUserAttributesResponse' smart constructor.
newtype AdminUpdateUserAttributesResponse = AdminUpdateUserAttributesResponse'
    { _auuarsResponseStatus :: Int
    } deriving (Eq,Read,Show,Data,Typeable,Generic)

-- | Creates a value of 'AdminUpdateUserAttributesResponse' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'auuarsResponseStatus'
adminUpdateUserAttributesResponse
    :: Int -- ^ 'auuarsResponseStatus'
    -> AdminUpdateUserAttributesResponse
adminUpdateUserAttributesResponse pResponseStatus_ =
    AdminUpdateUserAttributesResponse'
    { _auuarsResponseStatus = pResponseStatus_
    }

-- | The response status code.
auuarsResponseStatus :: Lens' AdminUpdateUserAttributesResponse Int
auuarsResponseStatus = lens _auuarsResponseStatus (\ s a -> s{_auuarsResponseStatus = a});

instance NFData AdminUpdateUserAttributesResponse