{-# 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.AppStream.StartImageBuilder
-- 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)
--
-- Starts the specified image builder.
module Amazonka.AppStream.StartImageBuilder
  ( -- * Creating a Request
    StartImageBuilder (..),
    newStartImageBuilder,

    -- * Request Lenses
    startImageBuilder_appstreamAgentVersion,
    startImageBuilder_name,

    -- * Destructuring the Response
    StartImageBuilderResponse (..),
    newStartImageBuilderResponse,

    -- * Response Lenses
    startImageBuilderResponse_imageBuilder,
    startImageBuilderResponse_httpStatus,
  )
where

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

-- | /See:/ 'newStartImageBuilder' smart constructor.
data StartImageBuilder = StartImageBuilder'
  { -- | The version of the AppStream 2.0 agent to use for this image builder. To
    -- use the latest version of the AppStream 2.0 agent, specify [LATEST].
    StartImageBuilder -> Maybe Text
appstreamAgentVersion :: Prelude.Maybe Prelude.Text,
    -- | The name of the image builder.
    StartImageBuilder -> Text
name :: Prelude.Text
  }
  deriving (StartImageBuilder -> StartImageBuilder -> Bool
(StartImageBuilder -> StartImageBuilder -> Bool)
-> (StartImageBuilder -> StartImageBuilder -> Bool)
-> Eq StartImageBuilder
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StartImageBuilder -> StartImageBuilder -> Bool
$c/= :: StartImageBuilder -> StartImageBuilder -> Bool
== :: StartImageBuilder -> StartImageBuilder -> Bool
$c== :: StartImageBuilder -> StartImageBuilder -> Bool
Prelude.Eq, ReadPrec [StartImageBuilder]
ReadPrec StartImageBuilder
Int -> ReadS StartImageBuilder
ReadS [StartImageBuilder]
(Int -> ReadS StartImageBuilder)
-> ReadS [StartImageBuilder]
-> ReadPrec StartImageBuilder
-> ReadPrec [StartImageBuilder]
-> Read StartImageBuilder
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StartImageBuilder]
$creadListPrec :: ReadPrec [StartImageBuilder]
readPrec :: ReadPrec StartImageBuilder
$creadPrec :: ReadPrec StartImageBuilder
readList :: ReadS [StartImageBuilder]
$creadList :: ReadS [StartImageBuilder]
readsPrec :: Int -> ReadS StartImageBuilder
$creadsPrec :: Int -> ReadS StartImageBuilder
Prelude.Read, Int -> StartImageBuilder -> ShowS
[StartImageBuilder] -> ShowS
StartImageBuilder -> String
(Int -> StartImageBuilder -> ShowS)
-> (StartImageBuilder -> String)
-> ([StartImageBuilder] -> ShowS)
-> Show StartImageBuilder
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StartImageBuilder] -> ShowS
$cshowList :: [StartImageBuilder] -> ShowS
show :: StartImageBuilder -> String
$cshow :: StartImageBuilder -> String
showsPrec :: Int -> StartImageBuilder -> ShowS
$cshowsPrec :: Int -> StartImageBuilder -> ShowS
Prelude.Show, (forall x. StartImageBuilder -> Rep StartImageBuilder x)
-> (forall x. Rep StartImageBuilder x -> StartImageBuilder)
-> Generic StartImageBuilder
forall x. Rep StartImageBuilder x -> StartImageBuilder
forall x. StartImageBuilder -> Rep StartImageBuilder x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StartImageBuilder x -> StartImageBuilder
$cfrom :: forall x. StartImageBuilder -> Rep StartImageBuilder x
Prelude.Generic)

-- |
-- Create a value of 'StartImageBuilder' 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:
--
-- 'appstreamAgentVersion', 'startImageBuilder_appstreamAgentVersion' - The version of the AppStream 2.0 agent to use for this image builder. To
-- use the latest version of the AppStream 2.0 agent, specify [LATEST].
--
-- 'name', 'startImageBuilder_name' - The name of the image builder.
newStartImageBuilder ::
  -- | 'name'
  Prelude.Text ->
  StartImageBuilder
newStartImageBuilder :: Text -> StartImageBuilder
newStartImageBuilder Text
pName_ =
  StartImageBuilder' :: Maybe Text -> Text -> StartImageBuilder
StartImageBuilder'
    { $sel:appstreamAgentVersion:StartImageBuilder' :: Maybe Text
appstreamAgentVersion =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:StartImageBuilder' :: Text
name = Text
pName_
    }

-- | The version of the AppStream 2.0 agent to use for this image builder. To
-- use the latest version of the AppStream 2.0 agent, specify [LATEST].
startImageBuilder_appstreamAgentVersion :: Lens.Lens' StartImageBuilder (Prelude.Maybe Prelude.Text)
startImageBuilder_appstreamAgentVersion :: (Maybe Text -> f (Maybe Text))
-> StartImageBuilder -> f StartImageBuilder
startImageBuilder_appstreamAgentVersion = (StartImageBuilder -> Maybe Text)
-> (StartImageBuilder -> Maybe Text -> StartImageBuilder)
-> Lens
     StartImageBuilder StartImageBuilder (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartImageBuilder' {Maybe Text
appstreamAgentVersion :: Maybe Text
$sel:appstreamAgentVersion:StartImageBuilder' :: StartImageBuilder -> Maybe Text
appstreamAgentVersion} -> Maybe Text
appstreamAgentVersion) (\s :: StartImageBuilder
s@StartImageBuilder' {} Maybe Text
a -> StartImageBuilder
s {$sel:appstreamAgentVersion:StartImageBuilder' :: Maybe Text
appstreamAgentVersion = Maybe Text
a} :: StartImageBuilder)

-- | The name of the image builder.
startImageBuilder_name :: Lens.Lens' StartImageBuilder Prelude.Text
startImageBuilder_name :: (Text -> f Text) -> StartImageBuilder -> f StartImageBuilder
startImageBuilder_name = (StartImageBuilder -> Text)
-> (StartImageBuilder -> Text -> StartImageBuilder)
-> Lens StartImageBuilder StartImageBuilder Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartImageBuilder' {Text
name :: Text
$sel:name:StartImageBuilder' :: StartImageBuilder -> Text
name} -> Text
name) (\s :: StartImageBuilder
s@StartImageBuilder' {} Text
a -> StartImageBuilder
s {$sel:name:StartImageBuilder' :: Text
name = Text
a} :: StartImageBuilder)

instance Core.AWSRequest StartImageBuilder where
  type
    AWSResponse StartImageBuilder =
      StartImageBuilderResponse
  request :: StartImageBuilder -> Request StartImageBuilder
request = Service -> StartImageBuilder -> Request StartImageBuilder
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy StartImageBuilder
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StartImageBuilder)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse StartImageBuilder))
-> Logger
-> Service
-> Proxy StartImageBuilder
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StartImageBuilder)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe ImageBuilder -> Int -> StartImageBuilderResponse
StartImageBuilderResponse'
            (Maybe ImageBuilder -> Int -> StartImageBuilderResponse)
-> Either String (Maybe ImageBuilder)
-> Either String (Int -> StartImageBuilderResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe ImageBuilder)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ImageBuilder")
            Either String (Int -> StartImageBuilderResponse)
-> Either String Int -> Either String StartImageBuilderResponse
forall (f :: * -> *) a b. Applicative f => 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 StartImageBuilder

instance Prelude.NFData StartImageBuilder

instance Core.ToHeaders StartImageBuilder where
  toHeaders :: StartImageBuilder -> ResponseHeaders
toHeaders =
    ResponseHeaders -> StartImageBuilder -> 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
"PhotonAdminProxyService.StartImageBuilder" ::
                          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 StartImageBuilder where
  toJSON :: StartImageBuilder -> Value
toJSON StartImageBuilder' {Maybe Text
Text
name :: Text
appstreamAgentVersion :: Maybe Text
$sel:name:StartImageBuilder' :: StartImageBuilder -> Text
$sel:appstreamAgentVersion:StartImageBuilder' :: StartImageBuilder -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"AppstreamAgentVersion" 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
appstreamAgentVersion,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name)
          ]
      )

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

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

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

-- |
-- Create a value of 'StartImageBuilderResponse' 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:
--
-- 'imageBuilder', 'startImageBuilderResponse_imageBuilder' - Information about the image builder.
--
-- 'httpStatus', 'startImageBuilderResponse_httpStatus' - The response's http status code.
newStartImageBuilderResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  StartImageBuilderResponse
newStartImageBuilderResponse :: Int -> StartImageBuilderResponse
newStartImageBuilderResponse Int
pHttpStatus_ =
  StartImageBuilderResponse' :: Maybe ImageBuilder -> Int -> StartImageBuilderResponse
StartImageBuilderResponse'
    { $sel:imageBuilder:StartImageBuilderResponse' :: Maybe ImageBuilder
imageBuilder =
        Maybe ImageBuilder
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:StartImageBuilderResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the image builder.
startImageBuilderResponse_imageBuilder :: Lens.Lens' StartImageBuilderResponse (Prelude.Maybe ImageBuilder)
startImageBuilderResponse_imageBuilder :: (Maybe ImageBuilder -> f (Maybe ImageBuilder))
-> StartImageBuilderResponse -> f StartImageBuilderResponse
startImageBuilderResponse_imageBuilder = (StartImageBuilderResponse -> Maybe ImageBuilder)
-> (StartImageBuilderResponse
    -> Maybe ImageBuilder -> StartImageBuilderResponse)
-> Lens
     StartImageBuilderResponse
     StartImageBuilderResponse
     (Maybe ImageBuilder)
     (Maybe ImageBuilder)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartImageBuilderResponse' {Maybe ImageBuilder
imageBuilder :: Maybe ImageBuilder
$sel:imageBuilder:StartImageBuilderResponse' :: StartImageBuilderResponse -> Maybe ImageBuilder
imageBuilder} -> Maybe ImageBuilder
imageBuilder) (\s :: StartImageBuilderResponse
s@StartImageBuilderResponse' {} Maybe ImageBuilder
a -> StartImageBuilderResponse
s {$sel:imageBuilder:StartImageBuilderResponse' :: Maybe ImageBuilder
imageBuilder = Maybe ImageBuilder
a} :: StartImageBuilderResponse)

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

instance Prelude.NFData StartImageBuilderResponse