{-# 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.UpdateUserProfile
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Updates a specified user profile.
--
-- __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.UpdateUserProfile
  ( -- * Creating a Request
    UpdateUserProfile (..),
    newUpdateUserProfile,

    -- * Request Lenses
    updateUserProfile_allowSelfManagement,
    updateUserProfile_sshPublicKey,
    updateUserProfile_sshUsername,
    updateUserProfile_iamUserArn,

    -- * Destructuring the Response
    UpdateUserProfileResponse (..),
    newUpdateUserProfileResponse,
  )
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:/ 'newUpdateUserProfile' smart constructor.
data UpdateUserProfile = UpdateUserProfile'
  { -- | Whether users can specify their own SSH public key through the My
    -- Settings page. For more information, see
    -- <https://docs.aws.amazon.com/opsworks/latest/userguide/security-settingsshkey.html Managing User Permissions>.
    UpdateUserProfile -> Maybe Bool
allowSelfManagement :: Prelude.Maybe Prelude.Bool,
    -- | The user\'s new SSH public key.
    UpdateUserProfile -> Maybe Text
sshPublicKey :: Prelude.Maybe Prelude.Text,
    -- | The user\'s SSH user name. The allowable characters are [a-z], [A-Z],
    -- [0-9], \'-\', and \'_\'. If the specified name includes other
    -- punctuation marks, AWS OpsWorks Stacks removes them. For example,
    -- @my.name@ will be changed to @myname@. If you do not specify an SSH user
    -- name, AWS OpsWorks Stacks generates one from the IAM user name.
    UpdateUserProfile -> Maybe Text
sshUsername :: Prelude.Maybe Prelude.Text,
    -- | The user IAM ARN. This can also be a federated user\'s ARN.
    UpdateUserProfile -> Text
iamUserArn :: Prelude.Text
  }
  deriving (UpdateUserProfile -> UpdateUserProfile -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateUserProfile -> UpdateUserProfile -> Bool
$c/= :: UpdateUserProfile -> UpdateUserProfile -> Bool
== :: UpdateUserProfile -> UpdateUserProfile -> Bool
$c== :: UpdateUserProfile -> UpdateUserProfile -> Bool
Prelude.Eq, ReadPrec [UpdateUserProfile]
ReadPrec UpdateUserProfile
Int -> ReadS UpdateUserProfile
ReadS [UpdateUserProfile]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateUserProfile]
$creadListPrec :: ReadPrec [UpdateUserProfile]
readPrec :: ReadPrec UpdateUserProfile
$creadPrec :: ReadPrec UpdateUserProfile
readList :: ReadS [UpdateUserProfile]
$creadList :: ReadS [UpdateUserProfile]
readsPrec :: Int -> ReadS UpdateUserProfile
$creadsPrec :: Int -> ReadS UpdateUserProfile
Prelude.Read, Int -> UpdateUserProfile -> ShowS
[UpdateUserProfile] -> ShowS
UpdateUserProfile -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateUserProfile] -> ShowS
$cshowList :: [UpdateUserProfile] -> ShowS
show :: UpdateUserProfile -> String
$cshow :: UpdateUserProfile -> String
showsPrec :: Int -> UpdateUserProfile -> ShowS
$cshowsPrec :: Int -> UpdateUserProfile -> ShowS
Prelude.Show, forall x. Rep UpdateUserProfile x -> UpdateUserProfile
forall x. UpdateUserProfile -> Rep UpdateUserProfile x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateUserProfile x -> UpdateUserProfile
$cfrom :: forall x. UpdateUserProfile -> Rep UpdateUserProfile x
Prelude.Generic)

-- |
-- Create a value of 'UpdateUserProfile' 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:
--
-- 'allowSelfManagement', 'updateUserProfile_allowSelfManagement' - Whether users can specify their own SSH public key through the My
-- Settings page. For more information, see
-- <https://docs.aws.amazon.com/opsworks/latest/userguide/security-settingsshkey.html Managing User Permissions>.
--
-- 'sshPublicKey', 'updateUserProfile_sshPublicKey' - The user\'s new SSH public key.
--
-- 'sshUsername', 'updateUserProfile_sshUsername' - The user\'s SSH user name. The allowable characters are [a-z], [A-Z],
-- [0-9], \'-\', and \'_\'. If the specified name includes other
-- punctuation marks, AWS OpsWorks Stacks removes them. For example,
-- @my.name@ will be changed to @myname@. If you do not specify an SSH user
-- name, AWS OpsWorks Stacks generates one from the IAM user name.
--
-- 'iamUserArn', 'updateUserProfile_iamUserArn' - The user IAM ARN. This can also be a federated user\'s ARN.
newUpdateUserProfile ::
  -- | 'iamUserArn'
  Prelude.Text ->
  UpdateUserProfile
newUpdateUserProfile :: Text -> UpdateUserProfile
newUpdateUserProfile Text
pIamUserArn_ =
  UpdateUserProfile'
    { $sel:allowSelfManagement:UpdateUserProfile' :: Maybe Bool
allowSelfManagement =
        forall a. Maybe a
Prelude.Nothing,
      $sel:sshPublicKey:UpdateUserProfile' :: Maybe Text
sshPublicKey = forall a. Maybe a
Prelude.Nothing,
      $sel:sshUsername:UpdateUserProfile' :: Maybe Text
sshUsername = forall a. Maybe a
Prelude.Nothing,
      $sel:iamUserArn:UpdateUserProfile' :: Text
iamUserArn = Text
pIamUserArn_
    }

-- | Whether users can specify their own SSH public key through the My
-- Settings page. For more information, see
-- <https://docs.aws.amazon.com/opsworks/latest/userguide/security-settingsshkey.html Managing User Permissions>.
updateUserProfile_allowSelfManagement :: Lens.Lens' UpdateUserProfile (Prelude.Maybe Prelude.Bool)
updateUserProfile_allowSelfManagement :: Lens' UpdateUserProfile (Maybe Bool)
updateUserProfile_allowSelfManagement = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateUserProfile' {Maybe Bool
allowSelfManagement :: Maybe Bool
$sel:allowSelfManagement:UpdateUserProfile' :: UpdateUserProfile -> Maybe Bool
allowSelfManagement} -> Maybe Bool
allowSelfManagement) (\s :: UpdateUserProfile
s@UpdateUserProfile' {} Maybe Bool
a -> UpdateUserProfile
s {$sel:allowSelfManagement:UpdateUserProfile' :: Maybe Bool
allowSelfManagement = Maybe Bool
a} :: UpdateUserProfile)

-- | The user\'s new SSH public key.
updateUserProfile_sshPublicKey :: Lens.Lens' UpdateUserProfile (Prelude.Maybe Prelude.Text)
updateUserProfile_sshPublicKey :: Lens' UpdateUserProfile (Maybe Text)
updateUserProfile_sshPublicKey = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateUserProfile' {Maybe Text
sshPublicKey :: Maybe Text
$sel:sshPublicKey:UpdateUserProfile' :: UpdateUserProfile -> Maybe Text
sshPublicKey} -> Maybe Text
sshPublicKey) (\s :: UpdateUserProfile
s@UpdateUserProfile' {} Maybe Text
a -> UpdateUserProfile
s {$sel:sshPublicKey:UpdateUserProfile' :: Maybe Text
sshPublicKey = Maybe Text
a} :: UpdateUserProfile)

-- | The user\'s SSH user name. The allowable characters are [a-z], [A-Z],
-- [0-9], \'-\', and \'_\'. If the specified name includes other
-- punctuation marks, AWS OpsWorks Stacks removes them. For example,
-- @my.name@ will be changed to @myname@. If you do not specify an SSH user
-- name, AWS OpsWorks Stacks generates one from the IAM user name.
updateUserProfile_sshUsername :: Lens.Lens' UpdateUserProfile (Prelude.Maybe Prelude.Text)
updateUserProfile_sshUsername :: Lens' UpdateUserProfile (Maybe Text)
updateUserProfile_sshUsername = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateUserProfile' {Maybe Text
sshUsername :: Maybe Text
$sel:sshUsername:UpdateUserProfile' :: UpdateUserProfile -> Maybe Text
sshUsername} -> Maybe Text
sshUsername) (\s :: UpdateUserProfile
s@UpdateUserProfile' {} Maybe Text
a -> UpdateUserProfile
s {$sel:sshUsername:UpdateUserProfile' :: Maybe Text
sshUsername = Maybe Text
a} :: UpdateUserProfile)

-- | The user IAM ARN. This can also be a federated user\'s ARN.
updateUserProfile_iamUserArn :: Lens.Lens' UpdateUserProfile Prelude.Text
updateUserProfile_iamUserArn :: Lens' UpdateUserProfile Text
updateUserProfile_iamUserArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateUserProfile' {Text
iamUserArn :: Text
$sel:iamUserArn:UpdateUserProfile' :: UpdateUserProfile -> Text
iamUserArn} -> Text
iamUserArn) (\s :: UpdateUserProfile
s@UpdateUserProfile' {} Text
a -> UpdateUserProfile
s {$sel:iamUserArn:UpdateUserProfile' :: Text
iamUserArn = Text
a} :: UpdateUserProfile)

instance Core.AWSRequest UpdateUserProfile where
  type
    AWSResponse UpdateUserProfile =
      UpdateUserProfileResponse
  request :: (Service -> Service)
-> UpdateUserProfile -> Request UpdateUserProfile
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 UpdateUserProfile
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateUserProfile)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull UpdateUserProfileResponse
UpdateUserProfileResponse'

instance Prelude.Hashable UpdateUserProfile where
  hashWithSalt :: Int -> UpdateUserProfile -> Int
hashWithSalt Int
_salt UpdateUserProfile' {Maybe Bool
Maybe Text
Text
iamUserArn :: Text
sshUsername :: Maybe Text
sshPublicKey :: Maybe Text
allowSelfManagement :: Maybe Bool
$sel:iamUserArn:UpdateUserProfile' :: UpdateUserProfile -> Text
$sel:sshUsername:UpdateUserProfile' :: UpdateUserProfile -> Maybe Text
$sel:sshPublicKey:UpdateUserProfile' :: UpdateUserProfile -> Maybe Text
$sel:allowSelfManagement:UpdateUserProfile' :: UpdateUserProfile -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
allowSelfManagement
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
sshPublicKey
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
sshUsername
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
iamUserArn

instance Prelude.NFData UpdateUserProfile where
  rnf :: UpdateUserProfile -> ()
rnf UpdateUserProfile' {Maybe Bool
Maybe Text
Text
iamUserArn :: Text
sshUsername :: Maybe Text
sshPublicKey :: Maybe Text
allowSelfManagement :: Maybe Bool
$sel:iamUserArn:UpdateUserProfile' :: UpdateUserProfile -> Text
$sel:sshUsername:UpdateUserProfile' :: UpdateUserProfile -> Maybe Text
$sel:sshPublicKey:UpdateUserProfile' :: UpdateUserProfile -> Maybe Text
$sel:allowSelfManagement:UpdateUserProfile' :: UpdateUserProfile -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
allowSelfManagement
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
sshPublicKey
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
sshUsername
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
iamUserArn

instance Data.ToHeaders UpdateUserProfile where
  toHeaders :: UpdateUserProfile -> [Header]
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 -> [Header]
Data.=# ( ByteString
"OpsWorks_20130218.UpdateUserProfile" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> [Header]
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON UpdateUserProfile where
  toJSON :: UpdateUserProfile -> Value
toJSON UpdateUserProfile' {Maybe Bool
Maybe Text
Text
iamUserArn :: Text
sshUsername :: Maybe Text
sshPublicKey :: Maybe Text
allowSelfManagement :: Maybe Bool
$sel:iamUserArn:UpdateUserProfile' :: UpdateUserProfile -> Text
$sel:sshUsername:UpdateUserProfile' :: UpdateUserProfile -> Maybe Text
$sel:sshPublicKey:UpdateUserProfile' :: UpdateUserProfile -> Maybe Text
$sel:allowSelfManagement:UpdateUserProfile' :: UpdateUserProfile -> Maybe Bool
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"AllowSelfManagement" 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 Bool
allowSelfManagement,
            (Key
"SshPublicKey" 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
sshPublicKey,
            (Key
"SshUsername" 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
sshUsername,
            forall a. a -> Maybe a
Prelude.Just (Key
"IamUserArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
iamUserArn)
          ]
      )

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

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

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

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

instance Prelude.NFData UpdateUserProfileResponse where
  rnf :: UpdateUserProfileResponse -> ()
rnf UpdateUserProfileResponse
_ = ()