{-# 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.EMR.UpdateStudio
-- 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 an Amazon EMR Studio configuration, including attributes such as
-- name, description, and subnets.
module Amazonka.EMR.UpdateStudio
  ( -- * Creating a Request
    UpdateStudio (..),
    newUpdateStudio,

    -- * Request Lenses
    updateStudio_subnetIds,
    updateStudio_defaultS3Location,
    updateStudio_name,
    updateStudio_description,
    updateStudio_studioId,

    -- * Destructuring the Response
    UpdateStudioResponse (..),
    newUpdateStudioResponse,
  )
where

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

-- | /See:/ 'newUpdateStudio' smart constructor.
data UpdateStudio = UpdateStudio'
  { -- | A list of subnet IDs to associate with the Amazon EMR Studio. The list
    -- can include new subnet IDs, but must also include all of the subnet IDs
    -- previously associated with the Studio. The list order does not matter. A
    -- Studio can have a maximum of 5 subnets. The subnets must belong to the
    -- same VPC as the Studio.
    UpdateStudio -> Maybe [Text]
subnetIds :: Prelude.Maybe [Prelude.Text],
    -- | The Amazon S3 location to back up Workspaces and notebook files for the
    -- Amazon EMR Studio.
    UpdateStudio -> Maybe Text
defaultS3Location :: Prelude.Maybe Prelude.Text,
    -- | A descriptive name for the Amazon EMR Studio.
    UpdateStudio -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | A detailed description to assign to the Amazon EMR Studio.
    UpdateStudio -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The ID of the Amazon EMR Studio to update.
    UpdateStudio -> Text
studioId :: Prelude.Text
  }
  deriving (UpdateStudio -> UpdateStudio -> Bool
(UpdateStudio -> UpdateStudio -> Bool)
-> (UpdateStudio -> UpdateStudio -> Bool) -> Eq UpdateStudio
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateStudio -> UpdateStudio -> Bool
$c/= :: UpdateStudio -> UpdateStudio -> Bool
== :: UpdateStudio -> UpdateStudio -> Bool
$c== :: UpdateStudio -> UpdateStudio -> Bool
Prelude.Eq, ReadPrec [UpdateStudio]
ReadPrec UpdateStudio
Int -> ReadS UpdateStudio
ReadS [UpdateStudio]
(Int -> ReadS UpdateStudio)
-> ReadS [UpdateStudio]
-> ReadPrec UpdateStudio
-> ReadPrec [UpdateStudio]
-> Read UpdateStudio
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateStudio]
$creadListPrec :: ReadPrec [UpdateStudio]
readPrec :: ReadPrec UpdateStudio
$creadPrec :: ReadPrec UpdateStudio
readList :: ReadS [UpdateStudio]
$creadList :: ReadS [UpdateStudio]
readsPrec :: Int -> ReadS UpdateStudio
$creadsPrec :: Int -> ReadS UpdateStudio
Prelude.Read, Int -> UpdateStudio -> ShowS
[UpdateStudio] -> ShowS
UpdateStudio -> String
(Int -> UpdateStudio -> ShowS)
-> (UpdateStudio -> String)
-> ([UpdateStudio] -> ShowS)
-> Show UpdateStudio
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateStudio] -> ShowS
$cshowList :: [UpdateStudio] -> ShowS
show :: UpdateStudio -> String
$cshow :: UpdateStudio -> String
showsPrec :: Int -> UpdateStudio -> ShowS
$cshowsPrec :: Int -> UpdateStudio -> ShowS
Prelude.Show, (forall x. UpdateStudio -> Rep UpdateStudio x)
-> (forall x. Rep UpdateStudio x -> UpdateStudio)
-> Generic UpdateStudio
forall x. Rep UpdateStudio x -> UpdateStudio
forall x. UpdateStudio -> Rep UpdateStudio x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateStudio x -> UpdateStudio
$cfrom :: forall x. UpdateStudio -> Rep UpdateStudio x
Prelude.Generic)

-- |
-- Create a value of 'UpdateStudio' 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:
--
-- 'subnetIds', 'updateStudio_subnetIds' - A list of subnet IDs to associate with the Amazon EMR Studio. The list
-- can include new subnet IDs, but must also include all of the subnet IDs
-- previously associated with the Studio. The list order does not matter. A
-- Studio can have a maximum of 5 subnets. The subnets must belong to the
-- same VPC as the Studio.
--
-- 'defaultS3Location', 'updateStudio_defaultS3Location' - The Amazon S3 location to back up Workspaces and notebook files for the
-- Amazon EMR Studio.
--
-- 'name', 'updateStudio_name' - A descriptive name for the Amazon EMR Studio.
--
-- 'description', 'updateStudio_description' - A detailed description to assign to the Amazon EMR Studio.
--
-- 'studioId', 'updateStudio_studioId' - The ID of the Amazon EMR Studio to update.
newUpdateStudio ::
  -- | 'studioId'
  Prelude.Text ->
  UpdateStudio
newUpdateStudio :: Text -> UpdateStudio
newUpdateStudio Text
pStudioId_ =
  UpdateStudio' :: Maybe [Text]
-> Maybe Text -> Maybe Text -> Maybe Text -> Text -> UpdateStudio
UpdateStudio'
    { $sel:subnetIds:UpdateStudio' :: Maybe [Text]
subnetIds = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:defaultS3Location:UpdateStudio' :: Maybe Text
defaultS3Location = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:UpdateStudio' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:description:UpdateStudio' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:studioId:UpdateStudio' :: Text
studioId = Text
pStudioId_
    }

-- | A list of subnet IDs to associate with the Amazon EMR Studio. The list
-- can include new subnet IDs, but must also include all of the subnet IDs
-- previously associated with the Studio. The list order does not matter. A
-- Studio can have a maximum of 5 subnets. The subnets must belong to the
-- same VPC as the Studio.
updateStudio_subnetIds :: Lens.Lens' UpdateStudio (Prelude.Maybe [Prelude.Text])
updateStudio_subnetIds :: (Maybe [Text] -> f (Maybe [Text]))
-> UpdateStudio -> f UpdateStudio
updateStudio_subnetIds = (UpdateStudio -> Maybe [Text])
-> (UpdateStudio -> Maybe [Text] -> UpdateStudio)
-> Lens UpdateStudio UpdateStudio (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateStudio' {Maybe [Text]
subnetIds :: Maybe [Text]
$sel:subnetIds:UpdateStudio' :: UpdateStudio -> Maybe [Text]
subnetIds} -> Maybe [Text]
subnetIds) (\s :: UpdateStudio
s@UpdateStudio' {} Maybe [Text]
a -> UpdateStudio
s {$sel:subnetIds:UpdateStudio' :: Maybe [Text]
subnetIds = Maybe [Text]
a} :: UpdateStudio) ((Maybe [Text] -> f (Maybe [Text]))
 -> UpdateStudio -> f UpdateStudio)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> UpdateStudio
-> f UpdateStudio
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The Amazon S3 location to back up Workspaces and notebook files for the
-- Amazon EMR Studio.
updateStudio_defaultS3Location :: Lens.Lens' UpdateStudio (Prelude.Maybe Prelude.Text)
updateStudio_defaultS3Location :: (Maybe Text -> f (Maybe Text)) -> UpdateStudio -> f UpdateStudio
updateStudio_defaultS3Location = (UpdateStudio -> Maybe Text)
-> (UpdateStudio -> Maybe Text -> UpdateStudio)
-> Lens UpdateStudio UpdateStudio (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateStudio' {Maybe Text
defaultS3Location :: Maybe Text
$sel:defaultS3Location:UpdateStudio' :: UpdateStudio -> Maybe Text
defaultS3Location} -> Maybe Text
defaultS3Location) (\s :: UpdateStudio
s@UpdateStudio' {} Maybe Text
a -> UpdateStudio
s {$sel:defaultS3Location:UpdateStudio' :: Maybe Text
defaultS3Location = Maybe Text
a} :: UpdateStudio)

-- | A descriptive name for the Amazon EMR Studio.
updateStudio_name :: Lens.Lens' UpdateStudio (Prelude.Maybe Prelude.Text)
updateStudio_name :: (Maybe Text -> f (Maybe Text)) -> UpdateStudio -> f UpdateStudio
updateStudio_name = (UpdateStudio -> Maybe Text)
-> (UpdateStudio -> Maybe Text -> UpdateStudio)
-> Lens UpdateStudio UpdateStudio (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateStudio' {Maybe Text
name :: Maybe Text
$sel:name:UpdateStudio' :: UpdateStudio -> Maybe Text
name} -> Maybe Text
name) (\s :: UpdateStudio
s@UpdateStudio' {} Maybe Text
a -> UpdateStudio
s {$sel:name:UpdateStudio' :: Maybe Text
name = Maybe Text
a} :: UpdateStudio)

-- | A detailed description to assign to the Amazon EMR Studio.
updateStudio_description :: Lens.Lens' UpdateStudio (Prelude.Maybe Prelude.Text)
updateStudio_description :: (Maybe Text -> f (Maybe Text)) -> UpdateStudio -> f UpdateStudio
updateStudio_description = (UpdateStudio -> Maybe Text)
-> (UpdateStudio -> Maybe Text -> UpdateStudio)
-> Lens UpdateStudio UpdateStudio (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateStudio' {Maybe Text
description :: Maybe Text
$sel:description:UpdateStudio' :: UpdateStudio -> Maybe Text
description} -> Maybe Text
description) (\s :: UpdateStudio
s@UpdateStudio' {} Maybe Text
a -> UpdateStudio
s {$sel:description:UpdateStudio' :: Maybe Text
description = Maybe Text
a} :: UpdateStudio)

-- | The ID of the Amazon EMR Studio to update.
updateStudio_studioId :: Lens.Lens' UpdateStudio Prelude.Text
updateStudio_studioId :: (Text -> f Text) -> UpdateStudio -> f UpdateStudio
updateStudio_studioId = (UpdateStudio -> Text)
-> (UpdateStudio -> Text -> UpdateStudio)
-> Lens UpdateStudio UpdateStudio Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateStudio' {Text
studioId :: Text
$sel:studioId:UpdateStudio' :: UpdateStudio -> Text
studioId} -> Text
studioId) (\s :: UpdateStudio
s@UpdateStudio' {} Text
a -> UpdateStudio
s {$sel:studioId:UpdateStudio' :: Text
studioId = Text
a} :: UpdateStudio)

instance Core.AWSRequest UpdateStudio where
  type AWSResponse UpdateStudio = UpdateStudioResponse
  request :: UpdateStudio -> Request UpdateStudio
request = Service -> UpdateStudio -> Request UpdateStudio
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateStudio
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateStudio)))
response = AWSResponse UpdateStudio
-> Logger
-> Service
-> Proxy UpdateStudio
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateStudio)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse UpdateStudio
UpdateStudioResponse
UpdateStudioResponse'

instance Prelude.Hashable UpdateStudio

instance Prelude.NFData UpdateStudio

instance Core.ToHeaders UpdateStudio where
  toHeaders :: UpdateStudio -> [Header]
toHeaders =
    [Header] -> UpdateStudio -> [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
"ElasticMapReduce.UpdateStudio" ::
                          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 UpdateStudio where
  toJSON :: UpdateStudio -> Value
toJSON UpdateStudio' {Maybe [Text]
Maybe Text
Text
studioId :: Text
description :: Maybe Text
name :: Maybe Text
defaultS3Location :: Maybe Text
subnetIds :: Maybe [Text]
$sel:studioId:UpdateStudio' :: UpdateStudio -> Text
$sel:description:UpdateStudio' :: UpdateStudio -> Maybe Text
$sel:name:UpdateStudio' :: UpdateStudio -> Maybe Text
$sel:defaultS3Location:UpdateStudio' :: UpdateStudio -> Maybe Text
$sel:subnetIds:UpdateStudio' :: UpdateStudio -> Maybe [Text]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"SubnetIds" 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]
subnetIds,
            (Text
"DefaultS3Location" 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
defaultS3Location,
            (Text
"Name" 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
name,
            (Text
"Description" 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
description,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"StudioId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
studioId)
          ]
      )

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

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

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

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

instance Prelude.NFData UpdateStudioResponse