{-# 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.UpdateSpace
-- 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 the settings of a space.
module Amazonka.SageMaker.UpdateSpace
  ( -- * Creating a Request
    UpdateSpace (..),
    newUpdateSpace,

    -- * Request Lenses
    updateSpace_spaceSettings,
    updateSpace_domainId,
    updateSpace_spaceName,

    -- * Destructuring the Response
    UpdateSpaceResponse (..),
    newUpdateSpaceResponse,

    -- * Response Lenses
    updateSpaceResponse_spaceArn,
    updateSpaceResponse_httpStatus,
  )
where

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

-- | /See:/ 'newUpdateSpace' smart constructor.
data UpdateSpace = UpdateSpace'
  { -- | A collection of space settings.
    UpdateSpace -> Maybe SpaceSettings
spaceSettings :: Prelude.Maybe SpaceSettings,
    -- | The ID of the associated Domain.
    UpdateSpace -> Text
domainId :: Prelude.Text,
    -- | The name of the space.
    UpdateSpace -> Text
spaceName :: Prelude.Text
  }
  deriving (UpdateSpace -> UpdateSpace -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateSpace -> UpdateSpace -> Bool
$c/= :: UpdateSpace -> UpdateSpace -> Bool
== :: UpdateSpace -> UpdateSpace -> Bool
$c== :: UpdateSpace -> UpdateSpace -> Bool
Prelude.Eq, ReadPrec [UpdateSpace]
ReadPrec UpdateSpace
Int -> ReadS UpdateSpace
ReadS [UpdateSpace]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateSpace]
$creadListPrec :: ReadPrec [UpdateSpace]
readPrec :: ReadPrec UpdateSpace
$creadPrec :: ReadPrec UpdateSpace
readList :: ReadS [UpdateSpace]
$creadList :: ReadS [UpdateSpace]
readsPrec :: Int -> ReadS UpdateSpace
$creadsPrec :: Int -> ReadS UpdateSpace
Prelude.Read, Int -> UpdateSpace -> ShowS
[UpdateSpace] -> ShowS
UpdateSpace -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateSpace] -> ShowS
$cshowList :: [UpdateSpace] -> ShowS
show :: UpdateSpace -> String
$cshow :: UpdateSpace -> String
showsPrec :: Int -> UpdateSpace -> ShowS
$cshowsPrec :: Int -> UpdateSpace -> ShowS
Prelude.Show, forall x. Rep UpdateSpace x -> UpdateSpace
forall x. UpdateSpace -> Rep UpdateSpace x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateSpace x -> UpdateSpace
$cfrom :: forall x. UpdateSpace -> Rep UpdateSpace x
Prelude.Generic)

-- |
-- Create a value of 'UpdateSpace' 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:
--
-- 'spaceSettings', 'updateSpace_spaceSettings' - A collection of space settings.
--
-- 'domainId', 'updateSpace_domainId' - The ID of the associated Domain.
--
-- 'spaceName', 'updateSpace_spaceName' - The name of the space.
newUpdateSpace ::
  -- | 'domainId'
  Prelude.Text ->
  -- | 'spaceName'
  Prelude.Text ->
  UpdateSpace
newUpdateSpace :: Text -> Text -> UpdateSpace
newUpdateSpace Text
pDomainId_ Text
pSpaceName_ =
  UpdateSpace'
    { $sel:spaceSettings:UpdateSpace' :: Maybe SpaceSettings
spaceSettings = forall a. Maybe a
Prelude.Nothing,
      $sel:domainId:UpdateSpace' :: Text
domainId = Text
pDomainId_,
      $sel:spaceName:UpdateSpace' :: Text
spaceName = Text
pSpaceName_
    }

-- | A collection of space settings.
updateSpace_spaceSettings :: Lens.Lens' UpdateSpace (Prelude.Maybe SpaceSettings)
updateSpace_spaceSettings :: Lens' UpdateSpace (Maybe SpaceSettings)
updateSpace_spaceSettings = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateSpace' {Maybe SpaceSettings
spaceSettings :: Maybe SpaceSettings
$sel:spaceSettings:UpdateSpace' :: UpdateSpace -> Maybe SpaceSettings
spaceSettings} -> Maybe SpaceSettings
spaceSettings) (\s :: UpdateSpace
s@UpdateSpace' {} Maybe SpaceSettings
a -> UpdateSpace
s {$sel:spaceSettings:UpdateSpace' :: Maybe SpaceSettings
spaceSettings = Maybe SpaceSettings
a} :: UpdateSpace)

-- | The ID of the associated Domain.
updateSpace_domainId :: Lens.Lens' UpdateSpace Prelude.Text
updateSpace_domainId :: Lens' UpdateSpace Text
updateSpace_domainId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateSpace' {Text
domainId :: Text
$sel:domainId:UpdateSpace' :: UpdateSpace -> Text
domainId} -> Text
domainId) (\s :: UpdateSpace
s@UpdateSpace' {} Text
a -> UpdateSpace
s {$sel:domainId:UpdateSpace' :: Text
domainId = Text
a} :: UpdateSpace)

-- | The name of the space.
updateSpace_spaceName :: Lens.Lens' UpdateSpace Prelude.Text
updateSpace_spaceName :: Lens' UpdateSpace Text
updateSpace_spaceName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateSpace' {Text
spaceName :: Text
$sel:spaceName:UpdateSpace' :: UpdateSpace -> Text
spaceName} -> Text
spaceName) (\s :: UpdateSpace
s@UpdateSpace' {} Text
a -> UpdateSpace
s {$sel:spaceName:UpdateSpace' :: Text
spaceName = Text
a} :: UpdateSpace)

instance Core.AWSRequest UpdateSpace where
  type AWSResponse UpdateSpace = UpdateSpaceResponse
  request :: (Service -> Service) -> UpdateSpace -> Request UpdateSpace
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 UpdateSpace
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateSpace)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text -> Int -> UpdateSpaceResponse
UpdateSpaceResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"SpaceArn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable UpdateSpace where
  hashWithSalt :: Int -> UpdateSpace -> Int
hashWithSalt Int
_salt UpdateSpace' {Maybe SpaceSettings
Text
spaceName :: Text
domainId :: Text
spaceSettings :: Maybe SpaceSettings
$sel:spaceName:UpdateSpace' :: UpdateSpace -> Text
$sel:domainId:UpdateSpace' :: UpdateSpace -> Text
$sel:spaceSettings:UpdateSpace' :: UpdateSpace -> Maybe SpaceSettings
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SpaceSettings
spaceSettings
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
domainId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
spaceName

instance Prelude.NFData UpdateSpace where
  rnf :: UpdateSpace -> ()
rnf UpdateSpace' {Maybe SpaceSettings
Text
spaceName :: Text
domainId :: Text
spaceSettings :: Maybe SpaceSettings
$sel:spaceName:UpdateSpace' :: UpdateSpace -> Text
$sel:domainId:UpdateSpace' :: UpdateSpace -> Text
$sel:spaceSettings:UpdateSpace' :: UpdateSpace -> Maybe SpaceSettings
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe SpaceSettings
spaceSettings
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
domainId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
spaceName

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

instance Data.ToJSON UpdateSpace where
  toJSON :: UpdateSpace -> Value
toJSON UpdateSpace' {Maybe SpaceSettings
Text
spaceName :: Text
domainId :: Text
spaceSettings :: Maybe SpaceSettings
$sel:spaceName:UpdateSpace' :: UpdateSpace -> Text
$sel:domainId:UpdateSpace' :: UpdateSpace -> Text
$sel:spaceSettings:UpdateSpace' :: UpdateSpace -> Maybe SpaceSettings
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"SpaceSettings" 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 SpaceSettings
spaceSettings,
            forall a. a -> Maybe a
Prelude.Just (Key
"DomainId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
domainId),
            forall a. a -> Maybe a
Prelude.Just (Key
"SpaceName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
spaceName)
          ]
      )

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

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

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

-- |
-- Create a value of 'UpdateSpaceResponse' 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:
--
-- 'spaceArn', 'updateSpaceResponse_spaceArn' - The space\'s Amazon Resource Name (ARN).
--
-- 'httpStatus', 'updateSpaceResponse_httpStatus' - The response's http status code.
newUpdateSpaceResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateSpaceResponse
newUpdateSpaceResponse :: Int -> UpdateSpaceResponse
newUpdateSpaceResponse Int
pHttpStatus_ =
  UpdateSpaceResponse'
    { $sel:spaceArn:UpdateSpaceResponse' :: Maybe Text
spaceArn = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdateSpaceResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The space\'s Amazon Resource Name (ARN).
updateSpaceResponse_spaceArn :: Lens.Lens' UpdateSpaceResponse (Prelude.Maybe Prelude.Text)
updateSpaceResponse_spaceArn :: Lens' UpdateSpaceResponse (Maybe Text)
updateSpaceResponse_spaceArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateSpaceResponse' {Maybe Text
spaceArn :: Maybe Text
$sel:spaceArn:UpdateSpaceResponse' :: UpdateSpaceResponse -> Maybe Text
spaceArn} -> Maybe Text
spaceArn) (\s :: UpdateSpaceResponse
s@UpdateSpaceResponse' {} Maybe Text
a -> UpdateSpaceResponse
s {$sel:spaceArn:UpdateSpaceResponse' :: Maybe Text
spaceArn = Maybe Text
a} :: UpdateSpaceResponse)

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

instance Prelude.NFData UpdateSpaceResponse where
  rnf :: UpdateSpaceResponse -> ()
rnf UpdateSpaceResponse' {Int
Maybe Text
httpStatus :: Int
spaceArn :: Maybe Text
$sel:httpStatus:UpdateSpaceResponse' :: UpdateSpaceResponse -> Int
$sel:spaceArn:UpdateSpaceResponse' :: UpdateSpaceResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
spaceArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus