{-# 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-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)
--
-- 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.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:/ '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
(UpdateUserProfile -> UpdateUserProfile -> Bool)
-> (UpdateUserProfile -> UpdateUserProfile -> Bool)
-> Eq UpdateUserProfile
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]
(Int -> ReadS UpdateUserProfile)
-> ReadS [UpdateUserProfile]
-> ReadPrec UpdateUserProfile
-> ReadPrec [UpdateUserProfile]
-> Read 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
(Int -> UpdateUserProfile -> ShowS)
-> (UpdateUserProfile -> String)
-> ([UpdateUserProfile] -> ShowS)
-> Show UpdateUserProfile
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. UpdateUserProfile -> Rep UpdateUserProfile x)
-> (forall x. Rep UpdateUserProfile x -> UpdateUserProfile)
-> Generic UpdateUserProfile
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' :: Maybe Bool -> Maybe Text -> Maybe Text -> Text -> UpdateUserProfile
UpdateUserProfile'
    { $sel:allowSelfManagement:UpdateUserProfile' :: Maybe Bool
allowSelfManagement =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:sshPublicKey:UpdateUserProfile' :: Maybe Text
sshPublicKey = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:sshUsername:UpdateUserProfile' :: Maybe Text
sshUsername = Maybe Text
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 :: (Maybe Bool -> f (Maybe Bool))
-> UpdateUserProfile -> f UpdateUserProfile
updateUserProfile_allowSelfManagement = (UpdateUserProfile -> Maybe Bool)
-> (UpdateUserProfile -> Maybe Bool -> UpdateUserProfile)
-> Lens
     UpdateUserProfile UpdateUserProfile (Maybe Bool) (Maybe Bool)
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 :: (Maybe Text -> f (Maybe Text))
-> UpdateUserProfile -> f UpdateUserProfile
updateUserProfile_sshPublicKey = (UpdateUserProfile -> Maybe Text)
-> (UpdateUserProfile -> Maybe Text -> UpdateUserProfile)
-> Lens
     UpdateUserProfile UpdateUserProfile (Maybe Text) (Maybe Text)
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 :: (Maybe Text -> f (Maybe Text))
-> UpdateUserProfile -> f UpdateUserProfile
updateUserProfile_sshUsername = (UpdateUserProfile -> Maybe Text)
-> (UpdateUserProfile -> Maybe Text -> UpdateUserProfile)
-> Lens
     UpdateUserProfile UpdateUserProfile (Maybe Text) (Maybe Text)
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 :: (Text -> f Text) -> UpdateUserProfile -> f UpdateUserProfile
updateUserProfile_iamUserArn = (UpdateUserProfile -> Text)
-> (UpdateUserProfile -> Text -> UpdateUserProfile)
-> Lens UpdateUserProfile UpdateUserProfile Text Text
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 :: UpdateUserProfile -> Request UpdateUserProfile
request = Service -> UpdateUserProfile -> Request UpdateUserProfile
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateUserProfile
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateUserProfile)))
response =
    AWSResponse UpdateUserProfile
-> Logger
-> Service
-> Proxy UpdateUserProfile
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateUserProfile)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse UpdateUserProfile
UpdateUserProfileResponse
UpdateUserProfileResponse'

instance Prelude.Hashable UpdateUserProfile

instance Prelude.NFData UpdateUserProfile

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

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"AllowSelfManagement" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
allowSelfManagement,
            (Text
"SshPublicKey" 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
sshPublicKey,
            (Text
"SshUsername" 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
sshUsername,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"IamUserArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
iamUserArn)
          ]
      )

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

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

-- | /See:/ 'newUpdateUserProfileResponse' smart constructor.
data UpdateUserProfileResponse = UpdateUserProfileResponse'
  {
  }
  deriving (UpdateUserProfileResponse -> UpdateUserProfileResponse -> Bool
(UpdateUserProfileResponse -> UpdateUserProfileResponse -> Bool)
-> (UpdateUserProfileResponse -> UpdateUserProfileResponse -> Bool)
-> Eq UpdateUserProfileResponse
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]
(Int -> ReadS UpdateUserProfileResponse)
-> ReadS [UpdateUserProfileResponse]
-> ReadPrec UpdateUserProfileResponse
-> ReadPrec [UpdateUserProfileResponse]
-> Read 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
(Int -> UpdateUserProfileResponse -> ShowS)
-> (UpdateUserProfileResponse -> String)
-> ([UpdateUserProfileResponse] -> ShowS)
-> Show UpdateUserProfileResponse
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.
 UpdateUserProfileResponse -> Rep UpdateUserProfileResponse x)
-> (forall x.
    Rep UpdateUserProfileResponse x -> UpdateUserProfileResponse)
-> Generic UpdateUserProfileResponse
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