{-# 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.WorkSpaces.UpdateWorkspaceBundle
-- 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 a WorkSpace bundle with a new image. For more information about
-- updating WorkSpace bundles, see
-- <https://docs.aws.amazon.com/workspaces/latest/adminguide/update-custom-bundle.html Update a Custom WorkSpaces Bundle>.
--
-- Existing WorkSpaces aren\'t automatically updated when you update the
-- bundle that they\'re based on. To update existing WorkSpaces that are
-- based on a bundle that you\'ve updated, you must either rebuild the
-- WorkSpaces or delete and recreate them.
module Amazonka.WorkSpaces.UpdateWorkspaceBundle
  ( -- * Creating a Request
    UpdateWorkspaceBundle (..),
    newUpdateWorkspaceBundle,

    -- * Request Lenses
    updateWorkspaceBundle_bundleId,
    updateWorkspaceBundle_imageId,

    -- * Destructuring the Response
    UpdateWorkspaceBundleResponse (..),
    newUpdateWorkspaceBundleResponse,

    -- * Response Lenses
    updateWorkspaceBundleResponse_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.WorkSpaces.Types

-- | /See:/ 'newUpdateWorkspaceBundle' smart constructor.
data UpdateWorkspaceBundle = UpdateWorkspaceBundle'
  { -- | The identifier of the bundle.
    UpdateWorkspaceBundle -> Maybe Text
bundleId :: Prelude.Maybe Prelude.Text,
    -- | The identifier of the image.
    UpdateWorkspaceBundle -> Maybe Text
imageId :: Prelude.Maybe Prelude.Text
  }
  deriving (UpdateWorkspaceBundle -> UpdateWorkspaceBundle -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateWorkspaceBundle -> UpdateWorkspaceBundle -> Bool
$c/= :: UpdateWorkspaceBundle -> UpdateWorkspaceBundle -> Bool
== :: UpdateWorkspaceBundle -> UpdateWorkspaceBundle -> Bool
$c== :: UpdateWorkspaceBundle -> UpdateWorkspaceBundle -> Bool
Prelude.Eq, ReadPrec [UpdateWorkspaceBundle]
ReadPrec UpdateWorkspaceBundle
Int -> ReadS UpdateWorkspaceBundle
ReadS [UpdateWorkspaceBundle]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateWorkspaceBundle]
$creadListPrec :: ReadPrec [UpdateWorkspaceBundle]
readPrec :: ReadPrec UpdateWorkspaceBundle
$creadPrec :: ReadPrec UpdateWorkspaceBundle
readList :: ReadS [UpdateWorkspaceBundle]
$creadList :: ReadS [UpdateWorkspaceBundle]
readsPrec :: Int -> ReadS UpdateWorkspaceBundle
$creadsPrec :: Int -> ReadS UpdateWorkspaceBundle
Prelude.Read, Int -> UpdateWorkspaceBundle -> ShowS
[UpdateWorkspaceBundle] -> ShowS
UpdateWorkspaceBundle -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateWorkspaceBundle] -> ShowS
$cshowList :: [UpdateWorkspaceBundle] -> ShowS
show :: UpdateWorkspaceBundle -> String
$cshow :: UpdateWorkspaceBundle -> String
showsPrec :: Int -> UpdateWorkspaceBundle -> ShowS
$cshowsPrec :: Int -> UpdateWorkspaceBundle -> ShowS
Prelude.Show, forall x. Rep UpdateWorkspaceBundle x -> UpdateWorkspaceBundle
forall x. UpdateWorkspaceBundle -> Rep UpdateWorkspaceBundle x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateWorkspaceBundle x -> UpdateWorkspaceBundle
$cfrom :: forall x. UpdateWorkspaceBundle -> Rep UpdateWorkspaceBundle x
Prelude.Generic)

-- |
-- Create a value of 'UpdateWorkspaceBundle' 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:
--
-- 'bundleId', 'updateWorkspaceBundle_bundleId' - The identifier of the bundle.
--
-- 'imageId', 'updateWorkspaceBundle_imageId' - The identifier of the image.
newUpdateWorkspaceBundle ::
  UpdateWorkspaceBundle
newUpdateWorkspaceBundle :: UpdateWorkspaceBundle
newUpdateWorkspaceBundle =
  UpdateWorkspaceBundle'
    { $sel:bundleId:UpdateWorkspaceBundle' :: Maybe Text
bundleId = forall a. Maybe a
Prelude.Nothing,
      $sel:imageId:UpdateWorkspaceBundle' :: Maybe Text
imageId = forall a. Maybe a
Prelude.Nothing
    }

-- | The identifier of the bundle.
updateWorkspaceBundle_bundleId :: Lens.Lens' UpdateWorkspaceBundle (Prelude.Maybe Prelude.Text)
updateWorkspaceBundle_bundleId :: Lens' UpdateWorkspaceBundle (Maybe Text)
updateWorkspaceBundle_bundleId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateWorkspaceBundle' {Maybe Text
bundleId :: Maybe Text
$sel:bundleId:UpdateWorkspaceBundle' :: UpdateWorkspaceBundle -> Maybe Text
bundleId} -> Maybe Text
bundleId) (\s :: UpdateWorkspaceBundle
s@UpdateWorkspaceBundle' {} Maybe Text
a -> UpdateWorkspaceBundle
s {$sel:bundleId:UpdateWorkspaceBundle' :: Maybe Text
bundleId = Maybe Text
a} :: UpdateWorkspaceBundle)

-- | The identifier of the image.
updateWorkspaceBundle_imageId :: Lens.Lens' UpdateWorkspaceBundle (Prelude.Maybe Prelude.Text)
updateWorkspaceBundle_imageId :: Lens' UpdateWorkspaceBundle (Maybe Text)
updateWorkspaceBundle_imageId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateWorkspaceBundle' {Maybe Text
imageId :: Maybe Text
$sel:imageId:UpdateWorkspaceBundle' :: UpdateWorkspaceBundle -> Maybe Text
imageId} -> Maybe Text
imageId) (\s :: UpdateWorkspaceBundle
s@UpdateWorkspaceBundle' {} Maybe Text
a -> UpdateWorkspaceBundle
s {$sel:imageId:UpdateWorkspaceBundle' :: Maybe Text
imageId = Maybe Text
a} :: UpdateWorkspaceBundle)

instance Core.AWSRequest UpdateWorkspaceBundle where
  type
    AWSResponse UpdateWorkspaceBundle =
      UpdateWorkspaceBundleResponse
  request :: (Service -> Service)
-> UpdateWorkspaceBundle -> Request UpdateWorkspaceBundle
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 UpdateWorkspaceBundle
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateWorkspaceBundle)))
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 -> UpdateWorkspaceBundleResponse
UpdateWorkspaceBundleResponse'
            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 UpdateWorkspaceBundle where
  hashWithSalt :: Int -> UpdateWorkspaceBundle -> Int
hashWithSalt Int
_salt UpdateWorkspaceBundle' {Maybe Text
imageId :: Maybe Text
bundleId :: Maybe Text
$sel:imageId:UpdateWorkspaceBundle' :: UpdateWorkspaceBundle -> Maybe Text
$sel:bundleId:UpdateWorkspaceBundle' :: UpdateWorkspaceBundle -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
bundleId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
imageId

instance Prelude.NFData UpdateWorkspaceBundle where
  rnf :: UpdateWorkspaceBundle -> ()
rnf UpdateWorkspaceBundle' {Maybe Text
imageId :: Maybe Text
bundleId :: Maybe Text
$sel:imageId:UpdateWorkspaceBundle' :: UpdateWorkspaceBundle -> Maybe Text
$sel:bundleId:UpdateWorkspaceBundle' :: UpdateWorkspaceBundle -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
bundleId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
imageId

instance Data.ToHeaders UpdateWorkspaceBundle where
  toHeaders :: UpdateWorkspaceBundle -> 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
"WorkspacesService.UpdateWorkspaceBundle" ::
                          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 UpdateWorkspaceBundle where
  toJSON :: UpdateWorkspaceBundle -> Value
toJSON UpdateWorkspaceBundle' {Maybe Text
imageId :: Maybe Text
bundleId :: Maybe Text
$sel:imageId:UpdateWorkspaceBundle' :: UpdateWorkspaceBundle -> Maybe Text
$sel:bundleId:UpdateWorkspaceBundle' :: UpdateWorkspaceBundle -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"BundleId" 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
bundleId,
            (Key
"ImageId" 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
imageId
          ]
      )

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

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

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

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

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

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