{-# 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.UpdateDomain
-- 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 the default settings for new user profiles in the domain.
module Amazonka.SageMaker.UpdateDomain
  ( -- * Creating a Request
    UpdateDomain (..),
    newUpdateDomain,

    -- * Request Lenses
    updateDomain_defaultUserSettings,
    updateDomain_domainId,

    -- * Destructuring the Response
    UpdateDomainResponse (..),
    newUpdateDomainResponse,

    -- * Response Lenses
    updateDomainResponse_domainArn,
    updateDomainResponse_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:/ 'newUpdateDomain' smart constructor.
data UpdateDomain = UpdateDomain'
  { -- | A collection of settings.
    UpdateDomain -> Maybe UserSettings
defaultUserSettings :: Prelude.Maybe UserSettings,
    -- | The ID of the domain to be updated.
    UpdateDomain -> Text
domainId :: Prelude.Text
  }
  deriving (UpdateDomain -> UpdateDomain -> Bool
(UpdateDomain -> UpdateDomain -> Bool)
-> (UpdateDomain -> UpdateDomain -> Bool) -> Eq UpdateDomain
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateDomain -> UpdateDomain -> Bool
$c/= :: UpdateDomain -> UpdateDomain -> Bool
== :: UpdateDomain -> UpdateDomain -> Bool
$c== :: UpdateDomain -> UpdateDomain -> Bool
Prelude.Eq, ReadPrec [UpdateDomain]
ReadPrec UpdateDomain
Int -> ReadS UpdateDomain
ReadS [UpdateDomain]
(Int -> ReadS UpdateDomain)
-> ReadS [UpdateDomain]
-> ReadPrec UpdateDomain
-> ReadPrec [UpdateDomain]
-> Read UpdateDomain
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateDomain]
$creadListPrec :: ReadPrec [UpdateDomain]
readPrec :: ReadPrec UpdateDomain
$creadPrec :: ReadPrec UpdateDomain
readList :: ReadS [UpdateDomain]
$creadList :: ReadS [UpdateDomain]
readsPrec :: Int -> ReadS UpdateDomain
$creadsPrec :: Int -> ReadS UpdateDomain
Prelude.Read, Int -> UpdateDomain -> ShowS
[UpdateDomain] -> ShowS
UpdateDomain -> String
(Int -> UpdateDomain -> ShowS)
-> (UpdateDomain -> String)
-> ([UpdateDomain] -> ShowS)
-> Show UpdateDomain
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateDomain] -> ShowS
$cshowList :: [UpdateDomain] -> ShowS
show :: UpdateDomain -> String
$cshow :: UpdateDomain -> String
showsPrec :: Int -> UpdateDomain -> ShowS
$cshowsPrec :: Int -> UpdateDomain -> ShowS
Prelude.Show, (forall x. UpdateDomain -> Rep UpdateDomain x)
-> (forall x. Rep UpdateDomain x -> UpdateDomain)
-> Generic UpdateDomain
forall x. Rep UpdateDomain x -> UpdateDomain
forall x. UpdateDomain -> Rep UpdateDomain x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateDomain x -> UpdateDomain
$cfrom :: forall x. UpdateDomain -> Rep UpdateDomain x
Prelude.Generic)

-- |
-- Create a value of 'UpdateDomain' 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:
--
-- 'defaultUserSettings', 'updateDomain_defaultUserSettings' - A collection of settings.
--
-- 'domainId', 'updateDomain_domainId' - The ID of the domain to be updated.
newUpdateDomain ::
  -- | 'domainId'
  Prelude.Text ->
  UpdateDomain
newUpdateDomain :: Text -> UpdateDomain
newUpdateDomain Text
pDomainId_ =
  UpdateDomain' :: Maybe UserSettings -> Text -> UpdateDomain
UpdateDomain'
    { $sel:defaultUserSettings:UpdateDomain' :: Maybe UserSettings
defaultUserSettings =
        Maybe UserSettings
forall a. Maybe a
Prelude.Nothing,
      $sel:domainId:UpdateDomain' :: Text
domainId = Text
pDomainId_
    }

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

-- | The ID of the domain to be updated.
updateDomain_domainId :: Lens.Lens' UpdateDomain Prelude.Text
updateDomain_domainId :: (Text -> f Text) -> UpdateDomain -> f UpdateDomain
updateDomain_domainId = (UpdateDomain -> Text)
-> (UpdateDomain -> Text -> UpdateDomain)
-> Lens UpdateDomain UpdateDomain Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDomain' {Text
domainId :: Text
$sel:domainId:UpdateDomain' :: UpdateDomain -> Text
domainId} -> Text
domainId) (\s :: UpdateDomain
s@UpdateDomain' {} Text
a -> UpdateDomain
s {$sel:domainId:UpdateDomain' :: Text
domainId = Text
a} :: UpdateDomain)

instance Core.AWSRequest UpdateDomain where
  type AWSResponse UpdateDomain = UpdateDomainResponse
  request :: UpdateDomain -> Request UpdateDomain
request = Service -> UpdateDomain -> Request UpdateDomain
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateDomain
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateDomain)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse UpdateDomain))
-> Logger
-> Service
-> Proxy UpdateDomain
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateDomain)))
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 -> UpdateDomainResponse
UpdateDomainResponse'
            (Maybe Text -> Int -> UpdateDomainResponse)
-> Either String (Maybe Text)
-> Either String (Int -> UpdateDomainResponse)
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
"DomainArn")
            Either String (Int -> UpdateDomainResponse)
-> Either String Int -> Either String UpdateDomainResponse
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 UpdateDomain

instance Prelude.NFData UpdateDomain

instance Core.ToHeaders UpdateDomain where
  toHeaders :: UpdateDomain -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateDomain -> 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.UpdateDomain" :: 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 UpdateDomain where
  toJSON :: UpdateDomain -> Value
toJSON UpdateDomain' {Maybe UserSettings
Text
domainId :: Text
defaultUserSettings :: Maybe UserSettings
$sel:domainId:UpdateDomain' :: UpdateDomain -> Text
$sel:defaultUserSettings:UpdateDomain' :: UpdateDomain -> Maybe UserSettings
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"DefaultUserSettings" 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
defaultUserSettings,
            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)
          ]
      )

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

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

-- | /See:/ 'newUpdateDomainResponse' smart constructor.
data UpdateDomainResponse = UpdateDomainResponse'
  { -- | The Amazon Resource Name (ARN) of the domain.
    UpdateDomainResponse -> Maybe Text
domainArn :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    UpdateDomainResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (UpdateDomainResponse -> UpdateDomainResponse -> Bool
(UpdateDomainResponse -> UpdateDomainResponse -> Bool)
-> (UpdateDomainResponse -> UpdateDomainResponse -> Bool)
-> Eq UpdateDomainResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateDomainResponse -> UpdateDomainResponse -> Bool
$c/= :: UpdateDomainResponse -> UpdateDomainResponse -> Bool
== :: UpdateDomainResponse -> UpdateDomainResponse -> Bool
$c== :: UpdateDomainResponse -> UpdateDomainResponse -> Bool
Prelude.Eq, ReadPrec [UpdateDomainResponse]
ReadPrec UpdateDomainResponse
Int -> ReadS UpdateDomainResponse
ReadS [UpdateDomainResponse]
(Int -> ReadS UpdateDomainResponse)
-> ReadS [UpdateDomainResponse]
-> ReadPrec UpdateDomainResponse
-> ReadPrec [UpdateDomainResponse]
-> Read UpdateDomainResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateDomainResponse]
$creadListPrec :: ReadPrec [UpdateDomainResponse]
readPrec :: ReadPrec UpdateDomainResponse
$creadPrec :: ReadPrec UpdateDomainResponse
readList :: ReadS [UpdateDomainResponse]
$creadList :: ReadS [UpdateDomainResponse]
readsPrec :: Int -> ReadS UpdateDomainResponse
$creadsPrec :: Int -> ReadS UpdateDomainResponse
Prelude.Read, Int -> UpdateDomainResponse -> ShowS
[UpdateDomainResponse] -> ShowS
UpdateDomainResponse -> String
(Int -> UpdateDomainResponse -> ShowS)
-> (UpdateDomainResponse -> String)
-> ([UpdateDomainResponse] -> ShowS)
-> Show UpdateDomainResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateDomainResponse] -> ShowS
$cshowList :: [UpdateDomainResponse] -> ShowS
show :: UpdateDomainResponse -> String
$cshow :: UpdateDomainResponse -> String
showsPrec :: Int -> UpdateDomainResponse -> ShowS
$cshowsPrec :: Int -> UpdateDomainResponse -> ShowS
Prelude.Show, (forall x. UpdateDomainResponse -> Rep UpdateDomainResponse x)
-> (forall x. Rep UpdateDomainResponse x -> UpdateDomainResponse)
-> Generic UpdateDomainResponse
forall x. Rep UpdateDomainResponse x -> UpdateDomainResponse
forall x. UpdateDomainResponse -> Rep UpdateDomainResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateDomainResponse x -> UpdateDomainResponse
$cfrom :: forall x. UpdateDomainResponse -> Rep UpdateDomainResponse x
Prelude.Generic)

-- |
-- Create a value of 'UpdateDomainResponse' 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:
--
-- 'domainArn', 'updateDomainResponse_domainArn' - The Amazon Resource Name (ARN) of the domain.
--
-- 'httpStatus', 'updateDomainResponse_httpStatus' - The response's http status code.
newUpdateDomainResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateDomainResponse
newUpdateDomainResponse :: Int -> UpdateDomainResponse
newUpdateDomainResponse Int
pHttpStatus_ =
  UpdateDomainResponse' :: Maybe Text -> Int -> UpdateDomainResponse
UpdateDomainResponse'
    { $sel:domainArn:UpdateDomainResponse' :: Maybe Text
domainArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdateDomainResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The Amazon Resource Name (ARN) of the domain.
updateDomainResponse_domainArn :: Lens.Lens' UpdateDomainResponse (Prelude.Maybe Prelude.Text)
updateDomainResponse_domainArn :: (Maybe Text -> f (Maybe Text))
-> UpdateDomainResponse -> f UpdateDomainResponse
updateDomainResponse_domainArn = (UpdateDomainResponse -> Maybe Text)
-> (UpdateDomainResponse -> Maybe Text -> UpdateDomainResponse)
-> Lens
     UpdateDomainResponse UpdateDomainResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDomainResponse' {Maybe Text
domainArn :: Maybe Text
$sel:domainArn:UpdateDomainResponse' :: UpdateDomainResponse -> Maybe Text
domainArn} -> Maybe Text
domainArn) (\s :: UpdateDomainResponse
s@UpdateDomainResponse' {} Maybe Text
a -> UpdateDomainResponse
s {$sel:domainArn:UpdateDomainResponse' :: Maybe Text
domainArn = Maybe Text
a} :: UpdateDomainResponse)

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

instance Prelude.NFData UpdateDomainResponse