{-# 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.Cloud9.UpdateEnvironment
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Changes the settings of an existing Cloud9 development environment.
module Amazonka.Cloud9.UpdateEnvironment
  ( -- * Creating a Request
    UpdateEnvironment (..),
    newUpdateEnvironment,

    -- * Request Lenses
    updateEnvironment_description,
    updateEnvironment_managedCredentialsAction,
    updateEnvironment_name,
    updateEnvironment_environmentId,

    -- * Destructuring the Response
    UpdateEnvironmentResponse (..),
    newUpdateEnvironmentResponse,

    -- * Response Lenses
    updateEnvironmentResponse_httpStatus,
  )
where

import Amazonka.Cloud9.Types
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

-- | /See:/ 'newUpdateEnvironment' smart constructor.
data UpdateEnvironment = UpdateEnvironment'
  { -- | Any new or replacement description for the environment.
    UpdateEnvironment -> Maybe (Sensitive Text)
description :: Prelude.Maybe (Data.Sensitive Prelude.Text),
    -- | Allows the environment owner to turn on or turn off the Amazon Web
    -- Services managed temporary credentials for an Cloud9 environment by
    -- using one of the following values:
    --
    -- -   @ENABLE@
    --
    -- -   @DISABLE@
    --
    -- Only the environment owner can change the status of managed temporary
    -- credentials. An @AccessDeniedException@ is thrown if an attempt to turn
    -- on or turn off managed temporary credentials is made by an account
    -- that\'s not the environment owner.
    UpdateEnvironment -> Maybe ManagedCredentialsAction
managedCredentialsAction :: Prelude.Maybe ManagedCredentialsAction,
    -- | A replacement name for the environment.
    UpdateEnvironment -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The ID of the environment to change settings.
    UpdateEnvironment -> Text
environmentId :: Prelude.Text
  }
  deriving (UpdateEnvironment -> UpdateEnvironment -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateEnvironment -> UpdateEnvironment -> Bool
$c/= :: UpdateEnvironment -> UpdateEnvironment -> Bool
== :: UpdateEnvironment -> UpdateEnvironment -> Bool
$c== :: UpdateEnvironment -> UpdateEnvironment -> Bool
Prelude.Eq, Int -> UpdateEnvironment -> ShowS
[UpdateEnvironment] -> ShowS
UpdateEnvironment -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateEnvironment] -> ShowS
$cshowList :: [UpdateEnvironment] -> ShowS
show :: UpdateEnvironment -> String
$cshow :: UpdateEnvironment -> String
showsPrec :: Int -> UpdateEnvironment -> ShowS
$cshowsPrec :: Int -> UpdateEnvironment -> ShowS
Prelude.Show, forall x. Rep UpdateEnvironment x -> UpdateEnvironment
forall x. UpdateEnvironment -> Rep UpdateEnvironment x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateEnvironment x -> UpdateEnvironment
$cfrom :: forall x. UpdateEnvironment -> Rep UpdateEnvironment x
Prelude.Generic)

-- |
-- Create a value of 'UpdateEnvironment' 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:
--
-- 'description', 'updateEnvironment_description' - Any new or replacement description for the environment.
--
-- 'managedCredentialsAction', 'updateEnvironment_managedCredentialsAction' - Allows the environment owner to turn on or turn off the Amazon Web
-- Services managed temporary credentials for an Cloud9 environment by
-- using one of the following values:
--
-- -   @ENABLE@
--
-- -   @DISABLE@
--
-- Only the environment owner can change the status of managed temporary
-- credentials. An @AccessDeniedException@ is thrown if an attempt to turn
-- on or turn off managed temporary credentials is made by an account
-- that\'s not the environment owner.
--
-- 'name', 'updateEnvironment_name' - A replacement name for the environment.
--
-- 'environmentId', 'updateEnvironment_environmentId' - The ID of the environment to change settings.
newUpdateEnvironment ::
  -- | 'environmentId'
  Prelude.Text ->
  UpdateEnvironment
newUpdateEnvironment :: Text -> UpdateEnvironment
newUpdateEnvironment Text
pEnvironmentId_ =
  UpdateEnvironment'
    { $sel:description:UpdateEnvironment' :: Maybe (Sensitive Text)
description = forall a. Maybe a
Prelude.Nothing,
      $sel:managedCredentialsAction:UpdateEnvironment' :: Maybe ManagedCredentialsAction
managedCredentialsAction = forall a. Maybe a
Prelude.Nothing,
      $sel:name:UpdateEnvironment' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:environmentId:UpdateEnvironment' :: Text
environmentId = Text
pEnvironmentId_
    }

-- | Any new or replacement description for the environment.
updateEnvironment_description :: Lens.Lens' UpdateEnvironment (Prelude.Maybe Prelude.Text)
updateEnvironment_description :: Lens' UpdateEnvironment (Maybe Text)
updateEnvironment_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateEnvironment' {Maybe (Sensitive Text)
description :: Maybe (Sensitive Text)
$sel:description:UpdateEnvironment' :: UpdateEnvironment -> Maybe (Sensitive Text)
description} -> Maybe (Sensitive Text)
description) (\s :: UpdateEnvironment
s@UpdateEnvironment' {} Maybe (Sensitive Text)
a -> UpdateEnvironment
s {$sel:description:UpdateEnvironment' :: Maybe (Sensitive Text)
description = Maybe (Sensitive Text)
a} :: UpdateEnvironment) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall a. Iso' (Sensitive a) a
Data._Sensitive

-- | Allows the environment owner to turn on or turn off the Amazon Web
-- Services managed temporary credentials for an Cloud9 environment by
-- using one of the following values:
--
-- -   @ENABLE@
--
-- -   @DISABLE@
--
-- Only the environment owner can change the status of managed temporary
-- credentials. An @AccessDeniedException@ is thrown if an attempt to turn
-- on or turn off managed temporary credentials is made by an account
-- that\'s not the environment owner.
updateEnvironment_managedCredentialsAction :: Lens.Lens' UpdateEnvironment (Prelude.Maybe ManagedCredentialsAction)
updateEnvironment_managedCredentialsAction :: Lens' UpdateEnvironment (Maybe ManagedCredentialsAction)
updateEnvironment_managedCredentialsAction = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateEnvironment' {Maybe ManagedCredentialsAction
managedCredentialsAction :: Maybe ManagedCredentialsAction
$sel:managedCredentialsAction:UpdateEnvironment' :: UpdateEnvironment -> Maybe ManagedCredentialsAction
managedCredentialsAction} -> Maybe ManagedCredentialsAction
managedCredentialsAction) (\s :: UpdateEnvironment
s@UpdateEnvironment' {} Maybe ManagedCredentialsAction
a -> UpdateEnvironment
s {$sel:managedCredentialsAction:UpdateEnvironment' :: Maybe ManagedCredentialsAction
managedCredentialsAction = Maybe ManagedCredentialsAction
a} :: UpdateEnvironment)

-- | A replacement name for the environment.
updateEnvironment_name :: Lens.Lens' UpdateEnvironment (Prelude.Maybe Prelude.Text)
updateEnvironment_name :: Lens' UpdateEnvironment (Maybe Text)
updateEnvironment_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateEnvironment' {Maybe Text
name :: Maybe Text
$sel:name:UpdateEnvironment' :: UpdateEnvironment -> Maybe Text
name} -> Maybe Text
name) (\s :: UpdateEnvironment
s@UpdateEnvironment' {} Maybe Text
a -> UpdateEnvironment
s {$sel:name:UpdateEnvironment' :: Maybe Text
name = Maybe Text
a} :: UpdateEnvironment)

-- | The ID of the environment to change settings.
updateEnvironment_environmentId :: Lens.Lens' UpdateEnvironment Prelude.Text
updateEnvironment_environmentId :: Lens' UpdateEnvironment Text
updateEnvironment_environmentId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateEnvironment' {Text
environmentId :: Text
$sel:environmentId:UpdateEnvironment' :: UpdateEnvironment -> Text
environmentId} -> Text
environmentId) (\s :: UpdateEnvironment
s@UpdateEnvironment' {} Text
a -> UpdateEnvironment
s {$sel:environmentId:UpdateEnvironment' :: Text
environmentId = Text
a} :: UpdateEnvironment)

instance Core.AWSRequest UpdateEnvironment where
  type
    AWSResponse UpdateEnvironment =
      UpdateEnvironmentResponse
  request :: (Service -> Service)
-> UpdateEnvironment -> Request UpdateEnvironment
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 UpdateEnvironment
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateEnvironment)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> UpdateEnvironmentResponse
UpdateEnvironmentResponse'
            forall (f :: * -> *) a b. Functor 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 UpdateEnvironment where
  hashWithSalt :: Int -> UpdateEnvironment -> Int
hashWithSalt Int
_salt UpdateEnvironment' {Maybe Text
Maybe (Sensitive Text)
Maybe ManagedCredentialsAction
Text
environmentId :: Text
name :: Maybe Text
managedCredentialsAction :: Maybe ManagedCredentialsAction
description :: Maybe (Sensitive Text)
$sel:environmentId:UpdateEnvironment' :: UpdateEnvironment -> Text
$sel:name:UpdateEnvironment' :: UpdateEnvironment -> Maybe Text
$sel:managedCredentialsAction:UpdateEnvironment' :: UpdateEnvironment -> Maybe ManagedCredentialsAction
$sel:description:UpdateEnvironment' :: UpdateEnvironment -> Maybe (Sensitive Text)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (Sensitive Text)
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ManagedCredentialsAction
managedCredentialsAction
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
environmentId

instance Prelude.NFData UpdateEnvironment where
  rnf :: UpdateEnvironment -> ()
rnf UpdateEnvironment' {Maybe Text
Maybe (Sensitive Text)
Maybe ManagedCredentialsAction
Text
environmentId :: Text
name :: Maybe Text
managedCredentialsAction :: Maybe ManagedCredentialsAction
description :: Maybe (Sensitive Text)
$sel:environmentId:UpdateEnvironment' :: UpdateEnvironment -> Text
$sel:name:UpdateEnvironment' :: UpdateEnvironment -> Maybe Text
$sel:managedCredentialsAction:UpdateEnvironment' :: UpdateEnvironment -> Maybe ManagedCredentialsAction
$sel:description:UpdateEnvironment' :: UpdateEnvironment -> Maybe (Sensitive Text)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (Sensitive Text)
description
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ManagedCredentialsAction
managedCredentialsAction
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
environmentId

instance Data.ToHeaders UpdateEnvironment where
  toHeaders :: UpdateEnvironment -> 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
"AWSCloud9WorkspaceManagementService.UpdateEnvironment" ::
                          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 UpdateEnvironment where
  toJSON :: UpdateEnvironment -> Value
toJSON UpdateEnvironment' {Maybe Text
Maybe (Sensitive Text)
Maybe ManagedCredentialsAction
Text
environmentId :: Text
name :: Maybe Text
managedCredentialsAction :: Maybe ManagedCredentialsAction
description :: Maybe (Sensitive Text)
$sel:environmentId:UpdateEnvironment' :: UpdateEnvironment -> Text
$sel:name:UpdateEnvironment' :: UpdateEnvironment -> Maybe Text
$sel:managedCredentialsAction:UpdateEnvironment' :: UpdateEnvironment -> Maybe ManagedCredentialsAction
$sel:description:UpdateEnvironment' :: UpdateEnvironment -> Maybe (Sensitive Text)
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"description" 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 (Sensitive Text)
description,
            (Key
"managedCredentialsAction" 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 ManagedCredentialsAction
managedCredentialsAction,
            (Key
"name" 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
name,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"environmentId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
environmentId)
          ]
      )

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

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

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

-- |
-- Create a value of 'UpdateEnvironmentResponse' 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:
--
-- 'httpStatus', 'updateEnvironmentResponse_httpStatus' - The response's http status code.
newUpdateEnvironmentResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateEnvironmentResponse
newUpdateEnvironmentResponse :: Int -> UpdateEnvironmentResponse
newUpdateEnvironmentResponse Int
pHttpStatus_ =
  UpdateEnvironmentResponse'
    { $sel:httpStatus:UpdateEnvironmentResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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

instance Prelude.NFData UpdateEnvironmentResponse where
  rnf :: UpdateEnvironmentResponse -> ()
rnf UpdateEnvironmentResponse' {Int
httpStatus :: Int
$sel:httpStatus:UpdateEnvironmentResponse' :: UpdateEnvironmentResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus