{-# 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-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 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.Lens as Lens
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
(UpdateWorkspaceBundle -> UpdateWorkspaceBundle -> Bool)
-> (UpdateWorkspaceBundle -> UpdateWorkspaceBundle -> Bool)
-> Eq UpdateWorkspaceBundle
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]
(Int -> ReadS UpdateWorkspaceBundle)
-> ReadS [UpdateWorkspaceBundle]
-> ReadPrec UpdateWorkspaceBundle
-> ReadPrec [UpdateWorkspaceBundle]
-> Read 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
(Int -> UpdateWorkspaceBundle -> ShowS)
-> (UpdateWorkspaceBundle -> String)
-> ([UpdateWorkspaceBundle] -> ShowS)
-> Show UpdateWorkspaceBundle
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. UpdateWorkspaceBundle -> Rep UpdateWorkspaceBundle x)
-> (forall x. Rep UpdateWorkspaceBundle x -> UpdateWorkspaceBundle)
-> Generic UpdateWorkspaceBundle
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' :: Maybe Text -> Maybe Text -> UpdateWorkspaceBundle
UpdateWorkspaceBundle'
    { $sel:bundleId:UpdateWorkspaceBundle' :: Maybe Text
bundleId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:imageId:UpdateWorkspaceBundle' :: Maybe Text
imageId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The identifier of the bundle.
updateWorkspaceBundle_bundleId :: Lens.Lens' UpdateWorkspaceBundle (Prelude.Maybe Prelude.Text)
updateWorkspaceBundle_bundleId :: (Maybe Text -> f (Maybe Text))
-> UpdateWorkspaceBundle -> f UpdateWorkspaceBundle
updateWorkspaceBundle_bundleId = (UpdateWorkspaceBundle -> Maybe Text)
-> (UpdateWorkspaceBundle -> Maybe Text -> UpdateWorkspaceBundle)
-> Lens
     UpdateWorkspaceBundle
     UpdateWorkspaceBundle
     (Maybe Text)
     (Maybe Text)
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 :: (Maybe Text -> f (Maybe Text))
-> UpdateWorkspaceBundle -> f UpdateWorkspaceBundle
updateWorkspaceBundle_imageId = (UpdateWorkspaceBundle -> Maybe Text)
-> (UpdateWorkspaceBundle -> Maybe Text -> UpdateWorkspaceBundle)
-> Lens
     UpdateWorkspaceBundle
     UpdateWorkspaceBundle
     (Maybe Text)
     (Maybe Text)
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 :: UpdateWorkspaceBundle -> Request UpdateWorkspaceBundle
request = Service -> UpdateWorkspaceBundle -> Request UpdateWorkspaceBundle
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateWorkspaceBundle
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateWorkspaceBundle)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse UpdateWorkspaceBundle))
-> Logger
-> Service
-> Proxy UpdateWorkspaceBundle
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateWorkspaceBundle)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> UpdateWorkspaceBundleResponse
UpdateWorkspaceBundleResponse'
            (Int -> UpdateWorkspaceBundleResponse)
-> Either String Int -> Either String UpdateWorkspaceBundleResponse
forall (f :: * -> *) a b. Functor 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 UpdateWorkspaceBundle

instance Prelude.NFData UpdateWorkspaceBundle

instance Core.ToHeaders UpdateWorkspaceBundle where
  toHeaders :: UpdateWorkspaceBundle -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateWorkspaceBundle -> 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
"WorkspacesService.UpdateWorkspaceBundle" ::
                          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 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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"BundleId" 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
bundleId,
            (Text
"ImageId" 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
imageId
          ]
      )

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

instance Core.ToQuery UpdateWorkspaceBundle where
  toQuery :: UpdateWorkspaceBundle -> QueryString
toQuery = QueryString -> UpdateWorkspaceBundle -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(UpdateWorkspaceBundleResponse
 -> UpdateWorkspaceBundleResponse -> Bool)
-> (UpdateWorkspaceBundleResponse
    -> UpdateWorkspaceBundleResponse -> Bool)
-> Eq UpdateWorkspaceBundleResponse
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]
(Int -> ReadS UpdateWorkspaceBundleResponse)
-> ReadS [UpdateWorkspaceBundleResponse]
-> ReadPrec UpdateWorkspaceBundleResponse
-> ReadPrec [UpdateWorkspaceBundleResponse]
-> Read 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
(Int -> UpdateWorkspaceBundleResponse -> ShowS)
-> (UpdateWorkspaceBundleResponse -> String)
-> ([UpdateWorkspaceBundleResponse] -> ShowS)
-> Show UpdateWorkspaceBundleResponse
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.
 UpdateWorkspaceBundleResponse
 -> Rep UpdateWorkspaceBundleResponse x)
-> (forall x.
    Rep UpdateWorkspaceBundleResponse x
    -> UpdateWorkspaceBundleResponse)
-> Generic UpdateWorkspaceBundleResponse
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' :: Int -> UpdateWorkspaceBundleResponse
UpdateWorkspaceBundleResponse'
    { $sel:httpStatus:UpdateWorkspaceBundleResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
updateWorkspaceBundleResponse_httpStatus :: Lens.Lens' UpdateWorkspaceBundleResponse Prelude.Int
updateWorkspaceBundleResponse_httpStatus :: (Int -> f Int)
-> UpdateWorkspaceBundleResponse -> f UpdateWorkspaceBundleResponse
updateWorkspaceBundleResponse_httpStatus = (UpdateWorkspaceBundleResponse -> Int)
-> (UpdateWorkspaceBundleResponse
    -> Int -> UpdateWorkspaceBundleResponse)
-> Lens
     UpdateWorkspaceBundleResponse UpdateWorkspaceBundleResponse Int Int
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