{-# 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.Greengrass.CreateSoftwareUpdateJob
-- 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)
--
-- Creates a software update for a core or group of cores (specified as an
-- IoT thing group.) Use this to update the OTA Agent as well as the
-- Greengrass core software. It makes use of the IoT Jobs feature which
-- provides additional commands to manage a Greengrass core software update
-- job.
module Amazonka.Greengrass.CreateSoftwareUpdateJob
  ( -- * Creating a Request
    CreateSoftwareUpdateJob (..),
    newCreateSoftwareUpdateJob,

    -- * Request Lenses
    createSoftwareUpdateJob_updateAgentLogLevel,
    createSoftwareUpdateJob_amznClientToken,
    createSoftwareUpdateJob_s3UrlSignerRole,
    createSoftwareUpdateJob_updateTargetsArchitecture,
    createSoftwareUpdateJob_softwareToUpdate,
    createSoftwareUpdateJob_updateTargets,
    createSoftwareUpdateJob_updateTargetsOperatingSystem,

    -- * Destructuring the Response
    CreateSoftwareUpdateJobResponse (..),
    newCreateSoftwareUpdateJobResponse,

    -- * Response Lenses
    createSoftwareUpdateJobResponse_platformSoftwareVersion,
    createSoftwareUpdateJobResponse_iotJobArn,
    createSoftwareUpdateJobResponse_iotJobId,
    createSoftwareUpdateJobResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.Greengrass.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:/ 'newCreateSoftwareUpdateJob' smart constructor.
data CreateSoftwareUpdateJob = CreateSoftwareUpdateJob'
  { CreateSoftwareUpdateJob -> Maybe UpdateAgentLogLevel
updateAgentLogLevel :: Prelude.Maybe UpdateAgentLogLevel,
    -- | A client token used to correlate requests and responses.
    CreateSoftwareUpdateJob -> Maybe Text
amznClientToken :: Prelude.Maybe Prelude.Text,
    CreateSoftwareUpdateJob -> Text
s3UrlSignerRole :: Prelude.Text,
    CreateSoftwareUpdateJob -> UpdateTargetsArchitecture
updateTargetsArchitecture :: UpdateTargetsArchitecture,
    CreateSoftwareUpdateJob -> SoftwareToUpdate
softwareToUpdate :: SoftwareToUpdate,
    CreateSoftwareUpdateJob -> [Text]
updateTargets :: [Prelude.Text],
    CreateSoftwareUpdateJob -> UpdateTargetsOperatingSystem
updateTargetsOperatingSystem :: UpdateTargetsOperatingSystem
  }
  deriving (CreateSoftwareUpdateJob -> CreateSoftwareUpdateJob -> Bool
(CreateSoftwareUpdateJob -> CreateSoftwareUpdateJob -> Bool)
-> (CreateSoftwareUpdateJob -> CreateSoftwareUpdateJob -> Bool)
-> Eq CreateSoftwareUpdateJob
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateSoftwareUpdateJob -> CreateSoftwareUpdateJob -> Bool
$c/= :: CreateSoftwareUpdateJob -> CreateSoftwareUpdateJob -> Bool
== :: CreateSoftwareUpdateJob -> CreateSoftwareUpdateJob -> Bool
$c== :: CreateSoftwareUpdateJob -> CreateSoftwareUpdateJob -> Bool
Prelude.Eq, ReadPrec [CreateSoftwareUpdateJob]
ReadPrec CreateSoftwareUpdateJob
Int -> ReadS CreateSoftwareUpdateJob
ReadS [CreateSoftwareUpdateJob]
(Int -> ReadS CreateSoftwareUpdateJob)
-> ReadS [CreateSoftwareUpdateJob]
-> ReadPrec CreateSoftwareUpdateJob
-> ReadPrec [CreateSoftwareUpdateJob]
-> Read CreateSoftwareUpdateJob
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateSoftwareUpdateJob]
$creadListPrec :: ReadPrec [CreateSoftwareUpdateJob]
readPrec :: ReadPrec CreateSoftwareUpdateJob
$creadPrec :: ReadPrec CreateSoftwareUpdateJob
readList :: ReadS [CreateSoftwareUpdateJob]
$creadList :: ReadS [CreateSoftwareUpdateJob]
readsPrec :: Int -> ReadS CreateSoftwareUpdateJob
$creadsPrec :: Int -> ReadS CreateSoftwareUpdateJob
Prelude.Read, Int -> CreateSoftwareUpdateJob -> ShowS
[CreateSoftwareUpdateJob] -> ShowS
CreateSoftwareUpdateJob -> String
(Int -> CreateSoftwareUpdateJob -> ShowS)
-> (CreateSoftwareUpdateJob -> String)
-> ([CreateSoftwareUpdateJob] -> ShowS)
-> Show CreateSoftwareUpdateJob
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateSoftwareUpdateJob] -> ShowS
$cshowList :: [CreateSoftwareUpdateJob] -> ShowS
show :: CreateSoftwareUpdateJob -> String
$cshow :: CreateSoftwareUpdateJob -> String
showsPrec :: Int -> CreateSoftwareUpdateJob -> ShowS
$cshowsPrec :: Int -> CreateSoftwareUpdateJob -> ShowS
Prelude.Show, (forall x.
 CreateSoftwareUpdateJob -> Rep CreateSoftwareUpdateJob x)
-> (forall x.
    Rep CreateSoftwareUpdateJob x -> CreateSoftwareUpdateJob)
-> Generic CreateSoftwareUpdateJob
forall x. Rep CreateSoftwareUpdateJob x -> CreateSoftwareUpdateJob
forall x. CreateSoftwareUpdateJob -> Rep CreateSoftwareUpdateJob x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateSoftwareUpdateJob x -> CreateSoftwareUpdateJob
$cfrom :: forall x. CreateSoftwareUpdateJob -> Rep CreateSoftwareUpdateJob x
Prelude.Generic)

-- |
-- Create a value of 'CreateSoftwareUpdateJob' 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:
--
-- 'updateAgentLogLevel', 'createSoftwareUpdateJob_updateAgentLogLevel' - Undocumented member.
--
-- 'amznClientToken', 'createSoftwareUpdateJob_amznClientToken' - A client token used to correlate requests and responses.
--
-- 's3UrlSignerRole', 'createSoftwareUpdateJob_s3UrlSignerRole' - Undocumented member.
--
-- 'updateTargetsArchitecture', 'createSoftwareUpdateJob_updateTargetsArchitecture' - Undocumented member.
--
-- 'softwareToUpdate', 'createSoftwareUpdateJob_softwareToUpdate' - Undocumented member.
--
-- 'updateTargets', 'createSoftwareUpdateJob_updateTargets' - Undocumented member.
--
-- 'updateTargetsOperatingSystem', 'createSoftwareUpdateJob_updateTargetsOperatingSystem' - Undocumented member.
newCreateSoftwareUpdateJob ::
  -- | 's3UrlSignerRole'
  Prelude.Text ->
  -- | 'updateTargetsArchitecture'
  UpdateTargetsArchitecture ->
  -- | 'softwareToUpdate'
  SoftwareToUpdate ->
  -- | 'updateTargetsOperatingSystem'
  UpdateTargetsOperatingSystem ->
  CreateSoftwareUpdateJob
newCreateSoftwareUpdateJob :: Text
-> UpdateTargetsArchitecture
-> SoftwareToUpdate
-> UpdateTargetsOperatingSystem
-> CreateSoftwareUpdateJob
newCreateSoftwareUpdateJob
  Text
pS3UrlSignerRole_
  UpdateTargetsArchitecture
pUpdateTargetsArchitecture_
  SoftwareToUpdate
pSoftwareToUpdate_
  UpdateTargetsOperatingSystem
pUpdateTargetsOperatingSystem_ =
    CreateSoftwareUpdateJob' :: Maybe UpdateAgentLogLevel
-> Maybe Text
-> Text
-> UpdateTargetsArchitecture
-> SoftwareToUpdate
-> [Text]
-> UpdateTargetsOperatingSystem
-> CreateSoftwareUpdateJob
CreateSoftwareUpdateJob'
      { $sel:updateAgentLogLevel:CreateSoftwareUpdateJob' :: Maybe UpdateAgentLogLevel
updateAgentLogLevel =
          Maybe UpdateAgentLogLevel
forall a. Maybe a
Prelude.Nothing,
        $sel:amznClientToken:CreateSoftwareUpdateJob' :: Maybe Text
amznClientToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:s3UrlSignerRole:CreateSoftwareUpdateJob' :: Text
s3UrlSignerRole = Text
pS3UrlSignerRole_,
        $sel:updateTargetsArchitecture:CreateSoftwareUpdateJob' :: UpdateTargetsArchitecture
updateTargetsArchitecture =
          UpdateTargetsArchitecture
pUpdateTargetsArchitecture_,
        $sel:softwareToUpdate:CreateSoftwareUpdateJob' :: SoftwareToUpdate
softwareToUpdate = SoftwareToUpdate
pSoftwareToUpdate_,
        $sel:updateTargets:CreateSoftwareUpdateJob' :: [Text]
updateTargets = [Text]
forall a. Monoid a => a
Prelude.mempty,
        $sel:updateTargetsOperatingSystem:CreateSoftwareUpdateJob' :: UpdateTargetsOperatingSystem
updateTargetsOperatingSystem =
          UpdateTargetsOperatingSystem
pUpdateTargetsOperatingSystem_
      }

-- | Undocumented member.
createSoftwareUpdateJob_updateAgentLogLevel :: Lens.Lens' CreateSoftwareUpdateJob (Prelude.Maybe UpdateAgentLogLevel)
createSoftwareUpdateJob_updateAgentLogLevel :: (Maybe UpdateAgentLogLevel -> f (Maybe UpdateAgentLogLevel))
-> CreateSoftwareUpdateJob -> f CreateSoftwareUpdateJob
createSoftwareUpdateJob_updateAgentLogLevel = (CreateSoftwareUpdateJob -> Maybe UpdateAgentLogLevel)
-> (CreateSoftwareUpdateJob
    -> Maybe UpdateAgentLogLevel -> CreateSoftwareUpdateJob)
-> Lens
     CreateSoftwareUpdateJob
     CreateSoftwareUpdateJob
     (Maybe UpdateAgentLogLevel)
     (Maybe UpdateAgentLogLevel)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateSoftwareUpdateJob' {Maybe UpdateAgentLogLevel
updateAgentLogLevel :: Maybe UpdateAgentLogLevel
$sel:updateAgentLogLevel:CreateSoftwareUpdateJob' :: CreateSoftwareUpdateJob -> Maybe UpdateAgentLogLevel
updateAgentLogLevel} -> Maybe UpdateAgentLogLevel
updateAgentLogLevel) (\s :: CreateSoftwareUpdateJob
s@CreateSoftwareUpdateJob' {} Maybe UpdateAgentLogLevel
a -> CreateSoftwareUpdateJob
s {$sel:updateAgentLogLevel:CreateSoftwareUpdateJob' :: Maybe UpdateAgentLogLevel
updateAgentLogLevel = Maybe UpdateAgentLogLevel
a} :: CreateSoftwareUpdateJob)

-- | A client token used to correlate requests and responses.
createSoftwareUpdateJob_amznClientToken :: Lens.Lens' CreateSoftwareUpdateJob (Prelude.Maybe Prelude.Text)
createSoftwareUpdateJob_amznClientToken :: (Maybe Text -> f (Maybe Text))
-> CreateSoftwareUpdateJob -> f CreateSoftwareUpdateJob
createSoftwareUpdateJob_amznClientToken = (CreateSoftwareUpdateJob -> Maybe Text)
-> (CreateSoftwareUpdateJob
    -> Maybe Text -> CreateSoftwareUpdateJob)
-> Lens
     CreateSoftwareUpdateJob
     CreateSoftwareUpdateJob
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateSoftwareUpdateJob' {Maybe Text
amznClientToken :: Maybe Text
$sel:amznClientToken:CreateSoftwareUpdateJob' :: CreateSoftwareUpdateJob -> Maybe Text
amznClientToken} -> Maybe Text
amznClientToken) (\s :: CreateSoftwareUpdateJob
s@CreateSoftwareUpdateJob' {} Maybe Text
a -> CreateSoftwareUpdateJob
s {$sel:amznClientToken:CreateSoftwareUpdateJob' :: Maybe Text
amznClientToken = Maybe Text
a} :: CreateSoftwareUpdateJob)

-- | Undocumented member.
createSoftwareUpdateJob_s3UrlSignerRole :: Lens.Lens' CreateSoftwareUpdateJob Prelude.Text
createSoftwareUpdateJob_s3UrlSignerRole :: (Text -> f Text)
-> CreateSoftwareUpdateJob -> f CreateSoftwareUpdateJob
createSoftwareUpdateJob_s3UrlSignerRole = (CreateSoftwareUpdateJob -> Text)
-> (CreateSoftwareUpdateJob -> Text -> CreateSoftwareUpdateJob)
-> Lens CreateSoftwareUpdateJob CreateSoftwareUpdateJob Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateSoftwareUpdateJob' {Text
s3UrlSignerRole :: Text
$sel:s3UrlSignerRole:CreateSoftwareUpdateJob' :: CreateSoftwareUpdateJob -> Text
s3UrlSignerRole} -> Text
s3UrlSignerRole) (\s :: CreateSoftwareUpdateJob
s@CreateSoftwareUpdateJob' {} Text
a -> CreateSoftwareUpdateJob
s {$sel:s3UrlSignerRole:CreateSoftwareUpdateJob' :: Text
s3UrlSignerRole = Text
a} :: CreateSoftwareUpdateJob)

-- | Undocumented member.
createSoftwareUpdateJob_updateTargetsArchitecture :: Lens.Lens' CreateSoftwareUpdateJob UpdateTargetsArchitecture
createSoftwareUpdateJob_updateTargetsArchitecture :: (UpdateTargetsArchitecture -> f UpdateTargetsArchitecture)
-> CreateSoftwareUpdateJob -> f CreateSoftwareUpdateJob
createSoftwareUpdateJob_updateTargetsArchitecture = (CreateSoftwareUpdateJob -> UpdateTargetsArchitecture)
-> (CreateSoftwareUpdateJob
    -> UpdateTargetsArchitecture -> CreateSoftwareUpdateJob)
-> Lens
     CreateSoftwareUpdateJob
     CreateSoftwareUpdateJob
     UpdateTargetsArchitecture
     UpdateTargetsArchitecture
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateSoftwareUpdateJob' {UpdateTargetsArchitecture
updateTargetsArchitecture :: UpdateTargetsArchitecture
$sel:updateTargetsArchitecture:CreateSoftwareUpdateJob' :: CreateSoftwareUpdateJob -> UpdateTargetsArchitecture
updateTargetsArchitecture} -> UpdateTargetsArchitecture
updateTargetsArchitecture) (\s :: CreateSoftwareUpdateJob
s@CreateSoftwareUpdateJob' {} UpdateTargetsArchitecture
a -> CreateSoftwareUpdateJob
s {$sel:updateTargetsArchitecture:CreateSoftwareUpdateJob' :: UpdateTargetsArchitecture
updateTargetsArchitecture = UpdateTargetsArchitecture
a} :: CreateSoftwareUpdateJob)

-- | Undocumented member.
createSoftwareUpdateJob_softwareToUpdate :: Lens.Lens' CreateSoftwareUpdateJob SoftwareToUpdate
createSoftwareUpdateJob_softwareToUpdate :: (SoftwareToUpdate -> f SoftwareToUpdate)
-> CreateSoftwareUpdateJob -> f CreateSoftwareUpdateJob
createSoftwareUpdateJob_softwareToUpdate = (CreateSoftwareUpdateJob -> SoftwareToUpdate)
-> (CreateSoftwareUpdateJob
    -> SoftwareToUpdate -> CreateSoftwareUpdateJob)
-> Lens
     CreateSoftwareUpdateJob
     CreateSoftwareUpdateJob
     SoftwareToUpdate
     SoftwareToUpdate
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateSoftwareUpdateJob' {SoftwareToUpdate
softwareToUpdate :: SoftwareToUpdate
$sel:softwareToUpdate:CreateSoftwareUpdateJob' :: CreateSoftwareUpdateJob -> SoftwareToUpdate
softwareToUpdate} -> SoftwareToUpdate
softwareToUpdate) (\s :: CreateSoftwareUpdateJob
s@CreateSoftwareUpdateJob' {} SoftwareToUpdate
a -> CreateSoftwareUpdateJob
s {$sel:softwareToUpdate:CreateSoftwareUpdateJob' :: SoftwareToUpdate
softwareToUpdate = SoftwareToUpdate
a} :: CreateSoftwareUpdateJob)

-- | Undocumented member.
createSoftwareUpdateJob_updateTargets :: Lens.Lens' CreateSoftwareUpdateJob [Prelude.Text]
createSoftwareUpdateJob_updateTargets :: ([Text] -> f [Text])
-> CreateSoftwareUpdateJob -> f CreateSoftwareUpdateJob
createSoftwareUpdateJob_updateTargets = (CreateSoftwareUpdateJob -> [Text])
-> (CreateSoftwareUpdateJob -> [Text] -> CreateSoftwareUpdateJob)
-> Lens
     CreateSoftwareUpdateJob CreateSoftwareUpdateJob [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateSoftwareUpdateJob' {[Text]
updateTargets :: [Text]
$sel:updateTargets:CreateSoftwareUpdateJob' :: CreateSoftwareUpdateJob -> [Text]
updateTargets} -> [Text]
updateTargets) (\s :: CreateSoftwareUpdateJob
s@CreateSoftwareUpdateJob' {} [Text]
a -> CreateSoftwareUpdateJob
s {$sel:updateTargets:CreateSoftwareUpdateJob' :: [Text]
updateTargets = [Text]
a} :: CreateSoftwareUpdateJob) (([Text] -> f [Text])
 -> CreateSoftwareUpdateJob -> f CreateSoftwareUpdateJob)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> CreateSoftwareUpdateJob
-> f CreateSoftwareUpdateJob
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Undocumented member.
createSoftwareUpdateJob_updateTargetsOperatingSystem :: Lens.Lens' CreateSoftwareUpdateJob UpdateTargetsOperatingSystem
createSoftwareUpdateJob_updateTargetsOperatingSystem :: (UpdateTargetsOperatingSystem -> f UpdateTargetsOperatingSystem)
-> CreateSoftwareUpdateJob -> f CreateSoftwareUpdateJob
createSoftwareUpdateJob_updateTargetsOperatingSystem = (CreateSoftwareUpdateJob -> UpdateTargetsOperatingSystem)
-> (CreateSoftwareUpdateJob
    -> UpdateTargetsOperatingSystem -> CreateSoftwareUpdateJob)
-> Lens
     CreateSoftwareUpdateJob
     CreateSoftwareUpdateJob
     UpdateTargetsOperatingSystem
     UpdateTargetsOperatingSystem
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateSoftwareUpdateJob' {UpdateTargetsOperatingSystem
updateTargetsOperatingSystem :: UpdateTargetsOperatingSystem
$sel:updateTargetsOperatingSystem:CreateSoftwareUpdateJob' :: CreateSoftwareUpdateJob -> UpdateTargetsOperatingSystem
updateTargetsOperatingSystem} -> UpdateTargetsOperatingSystem
updateTargetsOperatingSystem) (\s :: CreateSoftwareUpdateJob
s@CreateSoftwareUpdateJob' {} UpdateTargetsOperatingSystem
a -> CreateSoftwareUpdateJob
s {$sel:updateTargetsOperatingSystem:CreateSoftwareUpdateJob' :: UpdateTargetsOperatingSystem
updateTargetsOperatingSystem = UpdateTargetsOperatingSystem
a} :: CreateSoftwareUpdateJob)

instance Core.AWSRequest CreateSoftwareUpdateJob where
  type
    AWSResponse CreateSoftwareUpdateJob =
      CreateSoftwareUpdateJobResponse
  request :: CreateSoftwareUpdateJob -> Request CreateSoftwareUpdateJob
request = Service
-> CreateSoftwareUpdateJob -> Request CreateSoftwareUpdateJob
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateSoftwareUpdateJob
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateSoftwareUpdateJob)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreateSoftwareUpdateJob))
-> Logger
-> Service
-> Proxy CreateSoftwareUpdateJob
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateSoftwareUpdateJob)))
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 Text
-> Maybe Text
-> Maybe Text
-> Int
-> CreateSoftwareUpdateJobResponse
CreateSoftwareUpdateJobResponse'
            (Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Int
 -> CreateSoftwareUpdateJobResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Text
      -> Maybe Text -> Int -> CreateSoftwareUpdateJobResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"PlatformSoftwareVersion")
            Either
  String
  (Maybe Text
   -> Maybe Text -> Int -> CreateSoftwareUpdateJobResponse)
-> Either String (Maybe Text)
-> Either
     String (Maybe Text -> Int -> CreateSoftwareUpdateJobResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"IotJobArn")
            Either
  String (Maybe Text -> Int -> CreateSoftwareUpdateJobResponse)
-> Either String (Maybe Text)
-> Either String (Int -> CreateSoftwareUpdateJobResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"IotJobId")
            Either String (Int -> CreateSoftwareUpdateJobResponse)
-> Either String Int
-> Either String CreateSoftwareUpdateJobResponse
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 CreateSoftwareUpdateJob

instance Prelude.NFData CreateSoftwareUpdateJob

instance Core.ToHeaders CreateSoftwareUpdateJob where
  toHeaders :: CreateSoftwareUpdateJob -> ResponseHeaders
toHeaders CreateSoftwareUpdateJob' {[Text]
Maybe Text
Maybe UpdateAgentLogLevel
Text
SoftwareToUpdate
UpdateTargetsArchitecture
UpdateTargetsOperatingSystem
updateTargetsOperatingSystem :: UpdateTargetsOperatingSystem
updateTargets :: [Text]
softwareToUpdate :: SoftwareToUpdate
updateTargetsArchitecture :: UpdateTargetsArchitecture
s3UrlSignerRole :: Text
amznClientToken :: Maybe Text
updateAgentLogLevel :: Maybe UpdateAgentLogLevel
$sel:updateTargetsOperatingSystem:CreateSoftwareUpdateJob' :: CreateSoftwareUpdateJob -> UpdateTargetsOperatingSystem
$sel:updateTargets:CreateSoftwareUpdateJob' :: CreateSoftwareUpdateJob -> [Text]
$sel:softwareToUpdate:CreateSoftwareUpdateJob' :: CreateSoftwareUpdateJob -> SoftwareToUpdate
$sel:updateTargetsArchitecture:CreateSoftwareUpdateJob' :: CreateSoftwareUpdateJob -> UpdateTargetsArchitecture
$sel:s3UrlSignerRole:CreateSoftwareUpdateJob' :: CreateSoftwareUpdateJob -> Text
$sel:amznClientToken:CreateSoftwareUpdateJob' :: CreateSoftwareUpdateJob -> Maybe Text
$sel:updateAgentLogLevel:CreateSoftwareUpdateJob' :: CreateSoftwareUpdateJob -> Maybe UpdateAgentLogLevel
..} =
    [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ HeaderName
"X-Amzn-Client-Token" HeaderName -> Maybe Text -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# Maybe Text
amznClientToken,
        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 CreateSoftwareUpdateJob where
  toJSON :: CreateSoftwareUpdateJob -> Value
toJSON CreateSoftwareUpdateJob' {[Text]
Maybe Text
Maybe UpdateAgentLogLevel
Text
SoftwareToUpdate
UpdateTargetsArchitecture
UpdateTargetsOperatingSystem
updateTargetsOperatingSystem :: UpdateTargetsOperatingSystem
updateTargets :: [Text]
softwareToUpdate :: SoftwareToUpdate
updateTargetsArchitecture :: UpdateTargetsArchitecture
s3UrlSignerRole :: Text
amznClientToken :: Maybe Text
updateAgentLogLevel :: Maybe UpdateAgentLogLevel
$sel:updateTargetsOperatingSystem:CreateSoftwareUpdateJob' :: CreateSoftwareUpdateJob -> UpdateTargetsOperatingSystem
$sel:updateTargets:CreateSoftwareUpdateJob' :: CreateSoftwareUpdateJob -> [Text]
$sel:softwareToUpdate:CreateSoftwareUpdateJob' :: CreateSoftwareUpdateJob -> SoftwareToUpdate
$sel:updateTargetsArchitecture:CreateSoftwareUpdateJob' :: CreateSoftwareUpdateJob -> UpdateTargetsArchitecture
$sel:s3UrlSignerRole:CreateSoftwareUpdateJob' :: CreateSoftwareUpdateJob -> Text
$sel:amznClientToken:CreateSoftwareUpdateJob' :: CreateSoftwareUpdateJob -> Maybe Text
$sel:updateAgentLogLevel:CreateSoftwareUpdateJob' :: CreateSoftwareUpdateJob -> Maybe UpdateAgentLogLevel
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"UpdateAgentLogLevel" Text -> UpdateAgentLogLevel -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (UpdateAgentLogLevel -> Pair)
-> Maybe UpdateAgentLogLevel -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe UpdateAgentLogLevel
updateAgentLogLevel,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"S3UrlSignerRole" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
s3UrlSignerRole),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"UpdateTargetsArchitecture"
                  Text -> UpdateTargetsArchitecture -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= UpdateTargetsArchitecture
updateTargetsArchitecture
              ),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"SoftwareToUpdate" Text -> SoftwareToUpdate -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= SoftwareToUpdate
softwareToUpdate),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"UpdateTargets" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Text]
updateTargets),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"UpdateTargetsOperatingSystem"
                  Text -> UpdateTargetsOperatingSystem -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= UpdateTargetsOperatingSystem
updateTargetsOperatingSystem
              )
          ]
      )

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

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

-- | /See:/ 'newCreateSoftwareUpdateJobResponse' smart constructor.
data CreateSoftwareUpdateJobResponse = CreateSoftwareUpdateJobResponse'
  { -- | The software version installed on the device or devices after the
    -- update.
    CreateSoftwareUpdateJobResponse -> Maybe Text
platformSoftwareVersion :: Prelude.Maybe Prelude.Text,
    -- | The IoT Job ARN corresponding to this update.
    CreateSoftwareUpdateJobResponse -> Maybe Text
iotJobArn :: Prelude.Maybe Prelude.Text,
    -- | The IoT Job Id corresponding to this update.
    CreateSoftwareUpdateJobResponse -> Maybe Text
iotJobId :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    CreateSoftwareUpdateJobResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateSoftwareUpdateJobResponse
-> CreateSoftwareUpdateJobResponse -> Bool
(CreateSoftwareUpdateJobResponse
 -> CreateSoftwareUpdateJobResponse -> Bool)
-> (CreateSoftwareUpdateJobResponse
    -> CreateSoftwareUpdateJobResponse -> Bool)
-> Eq CreateSoftwareUpdateJobResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateSoftwareUpdateJobResponse
-> CreateSoftwareUpdateJobResponse -> Bool
$c/= :: CreateSoftwareUpdateJobResponse
-> CreateSoftwareUpdateJobResponse -> Bool
== :: CreateSoftwareUpdateJobResponse
-> CreateSoftwareUpdateJobResponse -> Bool
$c== :: CreateSoftwareUpdateJobResponse
-> CreateSoftwareUpdateJobResponse -> Bool
Prelude.Eq, ReadPrec [CreateSoftwareUpdateJobResponse]
ReadPrec CreateSoftwareUpdateJobResponse
Int -> ReadS CreateSoftwareUpdateJobResponse
ReadS [CreateSoftwareUpdateJobResponse]
(Int -> ReadS CreateSoftwareUpdateJobResponse)
-> ReadS [CreateSoftwareUpdateJobResponse]
-> ReadPrec CreateSoftwareUpdateJobResponse
-> ReadPrec [CreateSoftwareUpdateJobResponse]
-> Read CreateSoftwareUpdateJobResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateSoftwareUpdateJobResponse]
$creadListPrec :: ReadPrec [CreateSoftwareUpdateJobResponse]
readPrec :: ReadPrec CreateSoftwareUpdateJobResponse
$creadPrec :: ReadPrec CreateSoftwareUpdateJobResponse
readList :: ReadS [CreateSoftwareUpdateJobResponse]
$creadList :: ReadS [CreateSoftwareUpdateJobResponse]
readsPrec :: Int -> ReadS CreateSoftwareUpdateJobResponse
$creadsPrec :: Int -> ReadS CreateSoftwareUpdateJobResponse
Prelude.Read, Int -> CreateSoftwareUpdateJobResponse -> ShowS
[CreateSoftwareUpdateJobResponse] -> ShowS
CreateSoftwareUpdateJobResponse -> String
(Int -> CreateSoftwareUpdateJobResponse -> ShowS)
-> (CreateSoftwareUpdateJobResponse -> String)
-> ([CreateSoftwareUpdateJobResponse] -> ShowS)
-> Show CreateSoftwareUpdateJobResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateSoftwareUpdateJobResponse] -> ShowS
$cshowList :: [CreateSoftwareUpdateJobResponse] -> ShowS
show :: CreateSoftwareUpdateJobResponse -> String
$cshow :: CreateSoftwareUpdateJobResponse -> String
showsPrec :: Int -> CreateSoftwareUpdateJobResponse -> ShowS
$cshowsPrec :: Int -> CreateSoftwareUpdateJobResponse -> ShowS
Prelude.Show, (forall x.
 CreateSoftwareUpdateJobResponse
 -> Rep CreateSoftwareUpdateJobResponse x)
-> (forall x.
    Rep CreateSoftwareUpdateJobResponse x
    -> CreateSoftwareUpdateJobResponse)
-> Generic CreateSoftwareUpdateJobResponse
forall x.
Rep CreateSoftwareUpdateJobResponse x
-> CreateSoftwareUpdateJobResponse
forall x.
CreateSoftwareUpdateJobResponse
-> Rep CreateSoftwareUpdateJobResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateSoftwareUpdateJobResponse x
-> CreateSoftwareUpdateJobResponse
$cfrom :: forall x.
CreateSoftwareUpdateJobResponse
-> Rep CreateSoftwareUpdateJobResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateSoftwareUpdateJobResponse' 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:
--
-- 'platformSoftwareVersion', 'createSoftwareUpdateJobResponse_platformSoftwareVersion' - The software version installed on the device or devices after the
-- update.
--
-- 'iotJobArn', 'createSoftwareUpdateJobResponse_iotJobArn' - The IoT Job ARN corresponding to this update.
--
-- 'iotJobId', 'createSoftwareUpdateJobResponse_iotJobId' - The IoT Job Id corresponding to this update.
--
-- 'httpStatus', 'createSoftwareUpdateJobResponse_httpStatus' - The response's http status code.
newCreateSoftwareUpdateJobResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateSoftwareUpdateJobResponse
newCreateSoftwareUpdateJobResponse :: Int -> CreateSoftwareUpdateJobResponse
newCreateSoftwareUpdateJobResponse Int
pHttpStatus_ =
  CreateSoftwareUpdateJobResponse' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Int
-> CreateSoftwareUpdateJobResponse
CreateSoftwareUpdateJobResponse'
    { $sel:platformSoftwareVersion:CreateSoftwareUpdateJobResponse' :: Maybe Text
platformSoftwareVersion =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:iotJobArn:CreateSoftwareUpdateJobResponse' :: Maybe Text
iotJobArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:iotJobId:CreateSoftwareUpdateJobResponse' :: Maybe Text
iotJobId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateSoftwareUpdateJobResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The software version installed on the device or devices after the
-- update.
createSoftwareUpdateJobResponse_platformSoftwareVersion :: Lens.Lens' CreateSoftwareUpdateJobResponse (Prelude.Maybe Prelude.Text)
createSoftwareUpdateJobResponse_platformSoftwareVersion :: (Maybe Text -> f (Maybe Text))
-> CreateSoftwareUpdateJobResponse
-> f CreateSoftwareUpdateJobResponse
createSoftwareUpdateJobResponse_platformSoftwareVersion = (CreateSoftwareUpdateJobResponse -> Maybe Text)
-> (CreateSoftwareUpdateJobResponse
    -> Maybe Text -> CreateSoftwareUpdateJobResponse)
-> Lens
     CreateSoftwareUpdateJobResponse
     CreateSoftwareUpdateJobResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateSoftwareUpdateJobResponse' {Maybe Text
platformSoftwareVersion :: Maybe Text
$sel:platformSoftwareVersion:CreateSoftwareUpdateJobResponse' :: CreateSoftwareUpdateJobResponse -> Maybe Text
platformSoftwareVersion} -> Maybe Text
platformSoftwareVersion) (\s :: CreateSoftwareUpdateJobResponse
s@CreateSoftwareUpdateJobResponse' {} Maybe Text
a -> CreateSoftwareUpdateJobResponse
s {$sel:platformSoftwareVersion:CreateSoftwareUpdateJobResponse' :: Maybe Text
platformSoftwareVersion = Maybe Text
a} :: CreateSoftwareUpdateJobResponse)

-- | The IoT Job ARN corresponding to this update.
createSoftwareUpdateJobResponse_iotJobArn :: Lens.Lens' CreateSoftwareUpdateJobResponse (Prelude.Maybe Prelude.Text)
createSoftwareUpdateJobResponse_iotJobArn :: (Maybe Text -> f (Maybe Text))
-> CreateSoftwareUpdateJobResponse
-> f CreateSoftwareUpdateJobResponse
createSoftwareUpdateJobResponse_iotJobArn = (CreateSoftwareUpdateJobResponse -> Maybe Text)
-> (CreateSoftwareUpdateJobResponse
    -> Maybe Text -> CreateSoftwareUpdateJobResponse)
-> Lens
     CreateSoftwareUpdateJobResponse
     CreateSoftwareUpdateJobResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateSoftwareUpdateJobResponse' {Maybe Text
iotJobArn :: Maybe Text
$sel:iotJobArn:CreateSoftwareUpdateJobResponse' :: CreateSoftwareUpdateJobResponse -> Maybe Text
iotJobArn} -> Maybe Text
iotJobArn) (\s :: CreateSoftwareUpdateJobResponse
s@CreateSoftwareUpdateJobResponse' {} Maybe Text
a -> CreateSoftwareUpdateJobResponse
s {$sel:iotJobArn:CreateSoftwareUpdateJobResponse' :: Maybe Text
iotJobArn = Maybe Text
a} :: CreateSoftwareUpdateJobResponse)

-- | The IoT Job Id corresponding to this update.
createSoftwareUpdateJobResponse_iotJobId :: Lens.Lens' CreateSoftwareUpdateJobResponse (Prelude.Maybe Prelude.Text)
createSoftwareUpdateJobResponse_iotJobId :: (Maybe Text -> f (Maybe Text))
-> CreateSoftwareUpdateJobResponse
-> f CreateSoftwareUpdateJobResponse
createSoftwareUpdateJobResponse_iotJobId = (CreateSoftwareUpdateJobResponse -> Maybe Text)
-> (CreateSoftwareUpdateJobResponse
    -> Maybe Text -> CreateSoftwareUpdateJobResponse)
-> Lens
     CreateSoftwareUpdateJobResponse
     CreateSoftwareUpdateJobResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateSoftwareUpdateJobResponse' {Maybe Text
iotJobId :: Maybe Text
$sel:iotJobId:CreateSoftwareUpdateJobResponse' :: CreateSoftwareUpdateJobResponse -> Maybe Text
iotJobId} -> Maybe Text
iotJobId) (\s :: CreateSoftwareUpdateJobResponse
s@CreateSoftwareUpdateJobResponse' {} Maybe Text
a -> CreateSoftwareUpdateJobResponse
s {$sel:iotJobId:CreateSoftwareUpdateJobResponse' :: Maybe Text
iotJobId = Maybe Text
a} :: CreateSoftwareUpdateJobResponse)

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

instance
  Prelude.NFData
    CreateSoftwareUpdateJobResponse