{-# 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.SageMaker.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 user profile.
module Amazonka.SageMaker.UpdateUserProfile
  ( -- * Creating a Request
    UpdateUserProfile (..),
    newUpdateUserProfile,

    -- * Request Lenses
    updateUserProfile_userSettings,
    updateUserProfile_domainId,
    updateUserProfile_userProfileName,

    -- * Destructuring the Response
    UpdateUserProfileResponse (..),
    newUpdateUserProfileResponse,

    -- * Response Lenses
    updateUserProfileResponse_userProfileArn,
    updateUserProfileResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.SageMaker.Types

-- | /See:/ 'newUpdateUserProfile' smart constructor.
data UpdateUserProfile = UpdateUserProfile'
  { -- | A collection of settings.
    UpdateUserProfile -> Maybe UserSettings
userSettings :: Prelude.Maybe UserSettings,
    -- | The domain ID.
    UpdateUserProfile -> Text
domainId :: Prelude.Text,
    -- | The user profile name.
    UpdateUserProfile -> Text
userProfileName :: 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:
--
-- 'userSettings', 'updateUserProfile_userSettings' - A collection of settings.
--
-- 'domainId', 'updateUserProfile_domainId' - The domain ID.
--
-- 'userProfileName', 'updateUserProfile_userProfileName' - The user profile name.
newUpdateUserProfile ::
  -- | 'domainId'
  Prelude.Text ->
  -- | 'userProfileName'
  Prelude.Text ->
  UpdateUserProfile
newUpdateUserProfile :: Text -> Text -> UpdateUserProfile
newUpdateUserProfile Text
pDomainId_ Text
pUserProfileName_ =
  UpdateUserProfile' :: Maybe UserSettings -> Text -> Text -> UpdateUserProfile
UpdateUserProfile'
    { $sel:userSettings:UpdateUserProfile' :: Maybe UserSettings
userSettings = Maybe UserSettings
forall a. Maybe a
Prelude.Nothing,
      $sel:domainId:UpdateUserProfile' :: Text
domainId = Text
pDomainId_,
      $sel:userProfileName:UpdateUserProfile' :: Text
userProfileName = Text
pUserProfileName_
    }

-- | A collection of settings.
updateUserProfile_userSettings :: Lens.Lens' UpdateUserProfile (Prelude.Maybe UserSettings)
updateUserProfile_userSettings :: (Maybe UserSettings -> f (Maybe UserSettings))
-> UpdateUserProfile -> f UpdateUserProfile
updateUserProfile_userSettings = (UpdateUserProfile -> Maybe UserSettings)
-> (UpdateUserProfile -> Maybe UserSettings -> UpdateUserProfile)
-> Lens
     UpdateUserProfile
     UpdateUserProfile
     (Maybe UserSettings)
     (Maybe UserSettings)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateUserProfile' {Maybe UserSettings
userSettings :: Maybe UserSettings
$sel:userSettings:UpdateUserProfile' :: UpdateUserProfile -> Maybe UserSettings
userSettings} -> Maybe UserSettings
userSettings) (\s :: UpdateUserProfile
s@UpdateUserProfile' {} Maybe UserSettings
a -> UpdateUserProfile
s {$sel:userSettings:UpdateUserProfile' :: Maybe UserSettings
userSettings = Maybe UserSettings
a} :: UpdateUserProfile)

-- | The domain ID.
updateUserProfile_domainId :: Lens.Lens' UpdateUserProfile Prelude.Text
updateUserProfile_domainId :: (Text -> f Text) -> UpdateUserProfile -> f UpdateUserProfile
updateUserProfile_domainId = (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
domainId :: Text
$sel:domainId:UpdateUserProfile' :: UpdateUserProfile -> Text
domainId} -> Text
domainId) (\s :: UpdateUserProfile
s@UpdateUserProfile' {} Text
a -> UpdateUserProfile
s {$sel:domainId:UpdateUserProfile' :: Text
domainId = Text
a} :: UpdateUserProfile)

-- | The user profile name.
updateUserProfile_userProfileName :: Lens.Lens' UpdateUserProfile Prelude.Text
updateUserProfile_userProfileName :: (Text -> f Text) -> UpdateUserProfile -> f UpdateUserProfile
updateUserProfile_userProfileName = (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
userProfileName :: Text
$sel:userProfileName:UpdateUserProfile' :: UpdateUserProfile -> Text
userProfileName} -> Text
userProfileName) (\s :: UpdateUserProfile
s@UpdateUserProfile' {} Text
a -> UpdateUserProfile
s {$sel:userProfileName:UpdateUserProfile' :: Text
userProfileName = 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 =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse UpdateUserProfile))
-> Logger
-> Service
-> Proxy UpdateUserProfile
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateUserProfile)))
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 Text -> Int -> UpdateUserProfileResponse
UpdateUserProfileResponse'
            (Maybe Text -> Int -> UpdateUserProfileResponse)
-> Either String (Maybe Text)
-> Either String (Int -> UpdateUserProfileResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"UserProfileArn")
            Either String (Int -> UpdateUserProfileResponse)
-> Either String Int -> Either String UpdateUserProfileResponse
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 UpdateUserProfile

instance Prelude.NFData UpdateUserProfile

instance Core.ToHeaders UpdateUserProfile where
  toHeaders :: UpdateUserProfile -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateUserProfile -> 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
"SageMaker.UpdateUserProfile" ::
                          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 UpdateUserProfile where
  toJSON :: UpdateUserProfile -> Value
toJSON UpdateUserProfile' {Maybe UserSettings
Text
userProfileName :: Text
domainId :: Text
userSettings :: Maybe UserSettings
$sel:userProfileName:UpdateUserProfile' :: UpdateUserProfile -> Text
$sel:domainId:UpdateUserProfile' :: UpdateUserProfile -> Text
$sel:userSettings:UpdateUserProfile' :: UpdateUserProfile -> Maybe UserSettings
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"UserSettings" Text -> UserSettings -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (UserSettings -> Pair) -> Maybe UserSettings -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe UserSettings
userSettings,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"DomainId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
domainId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"UserProfileName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
userProfileName)
          ]
      )

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'
  { -- | The user profile Amazon Resource Name (ARN).
    UpdateUserProfileResponse -> Maybe Text
userProfileArn :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    UpdateUserProfileResponse -> Int
httpStatus :: Prelude.Int
  }
  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.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'userProfileArn', 'updateUserProfileResponse_userProfileArn' - The user profile Amazon Resource Name (ARN).
--
-- 'httpStatus', 'updateUserProfileResponse_httpStatus' - The response's http status code.
newUpdateUserProfileResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateUserProfileResponse
newUpdateUserProfileResponse :: Int -> UpdateUserProfileResponse
newUpdateUserProfileResponse Int
pHttpStatus_ =
  UpdateUserProfileResponse' :: Maybe Text -> Int -> UpdateUserProfileResponse
UpdateUserProfileResponse'
    { $sel:userProfileArn:UpdateUserProfileResponse' :: Maybe Text
userProfileArn =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdateUserProfileResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The user profile Amazon Resource Name (ARN).
updateUserProfileResponse_userProfileArn :: Lens.Lens' UpdateUserProfileResponse (Prelude.Maybe Prelude.Text)
updateUserProfileResponse_userProfileArn :: (Maybe Text -> f (Maybe Text))
-> UpdateUserProfileResponse -> f UpdateUserProfileResponse
updateUserProfileResponse_userProfileArn = (UpdateUserProfileResponse -> Maybe Text)
-> (UpdateUserProfileResponse
    -> Maybe Text -> UpdateUserProfileResponse)
-> Lens
     UpdateUserProfileResponse
     UpdateUserProfileResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateUserProfileResponse' {Maybe Text
userProfileArn :: Maybe Text
$sel:userProfileArn:UpdateUserProfileResponse' :: UpdateUserProfileResponse -> Maybe Text
userProfileArn} -> Maybe Text
userProfileArn) (\s :: UpdateUserProfileResponse
s@UpdateUserProfileResponse' {} Maybe Text
a -> UpdateUserProfileResponse
s {$sel:userProfileArn:UpdateUserProfileResponse' :: Maybe Text
userProfileArn = Maybe Text
a} :: UpdateUserProfileResponse)

-- | The response's http status code.
updateUserProfileResponse_httpStatus :: Lens.Lens' UpdateUserProfileResponse Prelude.Int
updateUserProfileResponse_httpStatus :: (Int -> f Int)
-> UpdateUserProfileResponse -> f UpdateUserProfileResponse
updateUserProfileResponse_httpStatus = (UpdateUserProfileResponse -> Int)
-> (UpdateUserProfileResponse -> Int -> UpdateUserProfileResponse)
-> Lens UpdateUserProfileResponse UpdateUserProfileResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateUserProfileResponse' {Int
httpStatus :: Int
$sel:httpStatus:UpdateUserProfileResponse' :: UpdateUserProfileResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: UpdateUserProfileResponse
s@UpdateUserProfileResponse' {} Int
a -> UpdateUserProfileResponse
s {$sel:httpStatus:UpdateUserProfileResponse' :: Int
httpStatus = Int
a} :: UpdateUserProfileResponse)

instance Prelude.NFData UpdateUserProfileResponse