{-# 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.UpdateMyUserProfile
-- 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 user\'s SSH public key.
--
-- __Required Permissions__: To use this action, an IAM user must have
-- self-management enabled or 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.UpdateMyUserProfile
  ( -- * Creating a Request
    UpdateMyUserProfile (..),
    newUpdateMyUserProfile,

    -- * Request Lenses
    updateMyUserProfile_sshPublicKey,

    -- * Destructuring the Response
    UpdateMyUserProfileResponse (..),
    newUpdateMyUserProfileResponse,
  )
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:/ 'newUpdateMyUserProfile' smart constructor.
data UpdateMyUserProfile = UpdateMyUserProfile'
  { -- | The user\'s SSH public key.
    UpdateMyUserProfile -> Maybe Text
sshPublicKey :: Prelude.Maybe Prelude.Text
  }
  deriving (UpdateMyUserProfile -> UpdateMyUserProfile -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateMyUserProfile -> UpdateMyUserProfile -> Bool
$c/= :: UpdateMyUserProfile -> UpdateMyUserProfile -> Bool
== :: UpdateMyUserProfile -> UpdateMyUserProfile -> Bool
$c== :: UpdateMyUserProfile -> UpdateMyUserProfile -> Bool
Prelude.Eq, ReadPrec [UpdateMyUserProfile]
ReadPrec UpdateMyUserProfile
Int -> ReadS UpdateMyUserProfile
ReadS [UpdateMyUserProfile]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateMyUserProfile]
$creadListPrec :: ReadPrec [UpdateMyUserProfile]
readPrec :: ReadPrec UpdateMyUserProfile
$creadPrec :: ReadPrec UpdateMyUserProfile
readList :: ReadS [UpdateMyUserProfile]
$creadList :: ReadS [UpdateMyUserProfile]
readsPrec :: Int -> ReadS UpdateMyUserProfile
$creadsPrec :: Int -> ReadS UpdateMyUserProfile
Prelude.Read, Int -> UpdateMyUserProfile -> ShowS
[UpdateMyUserProfile] -> ShowS
UpdateMyUserProfile -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateMyUserProfile] -> ShowS
$cshowList :: [UpdateMyUserProfile] -> ShowS
show :: UpdateMyUserProfile -> String
$cshow :: UpdateMyUserProfile -> String
showsPrec :: Int -> UpdateMyUserProfile -> ShowS
$cshowsPrec :: Int -> UpdateMyUserProfile -> ShowS
Prelude.Show, forall x. Rep UpdateMyUserProfile x -> UpdateMyUserProfile
forall x. UpdateMyUserProfile -> Rep UpdateMyUserProfile x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateMyUserProfile x -> UpdateMyUserProfile
$cfrom :: forall x. UpdateMyUserProfile -> Rep UpdateMyUserProfile x
Prelude.Generic)

-- |
-- Create a value of 'UpdateMyUserProfile' 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:
--
-- 'sshPublicKey', 'updateMyUserProfile_sshPublicKey' - The user\'s SSH public key.
newUpdateMyUserProfile ::
  UpdateMyUserProfile
newUpdateMyUserProfile :: UpdateMyUserProfile
newUpdateMyUserProfile =
  UpdateMyUserProfile'
    { $sel:sshPublicKey:UpdateMyUserProfile' :: Maybe Text
sshPublicKey =
        forall a. Maybe a
Prelude.Nothing
    }

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

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

instance Prelude.Hashable UpdateMyUserProfile where
  hashWithSalt :: Int -> UpdateMyUserProfile -> Int
hashWithSalt Int
_salt UpdateMyUserProfile' {Maybe Text
sshPublicKey :: Maybe Text
$sel:sshPublicKey:UpdateMyUserProfile' :: UpdateMyUserProfile -> Maybe Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
sshPublicKey

instance Prelude.NFData UpdateMyUserProfile where
  rnf :: UpdateMyUserProfile -> ()
rnf UpdateMyUserProfile' {Maybe Text
sshPublicKey :: Maybe Text
$sel:sshPublicKey:UpdateMyUserProfile' :: UpdateMyUserProfile -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
sshPublicKey

instance Data.ToHeaders UpdateMyUserProfile where
  toHeaders :: UpdateMyUserProfile -> [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.UpdateMyUserProfile" ::
                          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 UpdateMyUserProfile where
  toJSON :: UpdateMyUserProfile -> Value
toJSON UpdateMyUserProfile' {Maybe Text
sshPublicKey :: Maybe Text
$sel:sshPublicKey:UpdateMyUserProfile' :: UpdateMyUserProfile -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(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]
      )

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

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

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

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

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