{-# 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.IoT.CreateOTAUpdate
-- 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 an IoT OTA update on a target group of things or groups.
--
-- Requires permission to access the
-- <https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiot.html#awsiot-actions-as-permissions CreateOTAUpdate>
-- action.
module Amazonka.IoT.CreateOTAUpdate
  ( -- * Creating a Request
    CreateOTAUpdate (..),
    newCreateOTAUpdate,

    -- * Request Lenses
    createOTAUpdate_awsJobAbortConfig,
    createOTAUpdate_awsJobExecutionsRolloutConfig,
    createOTAUpdate_protocols,
    createOTAUpdate_awsJobPresignedUrlConfig,
    createOTAUpdate_additionalParameters,
    createOTAUpdate_awsJobTimeoutConfig,
    createOTAUpdate_description,
    createOTAUpdate_targetSelection,
    createOTAUpdate_tags,
    createOTAUpdate_otaUpdateId,
    createOTAUpdate_targets,
    createOTAUpdate_files,
    createOTAUpdate_roleArn,

    -- * Destructuring the Response
    CreateOTAUpdateResponse (..),
    newCreateOTAUpdateResponse,

    -- * Response Lenses
    createOTAUpdateResponse_awsIotJobId,
    createOTAUpdateResponse_otaUpdateStatus,
    createOTAUpdateResponse_awsIotJobArn,
    createOTAUpdateResponse_otaUpdateId,
    createOTAUpdateResponse_otaUpdateArn,
    createOTAUpdateResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.IoT.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:/ 'newCreateOTAUpdate' smart constructor.
data CreateOTAUpdate = CreateOTAUpdate'
  { -- | The criteria that determine when and how a job abort takes place.
    CreateOTAUpdate -> Maybe AwsJobAbortConfig
awsJobAbortConfig :: Prelude.Maybe AwsJobAbortConfig,
    -- | Configuration for the rollout of OTA updates.
    CreateOTAUpdate -> Maybe AwsJobExecutionsRolloutConfig
awsJobExecutionsRolloutConfig :: Prelude.Maybe AwsJobExecutionsRolloutConfig,
    -- | The protocol used to transfer the OTA update image. Valid values are
    -- [HTTP], [MQTT], [HTTP, MQTT]. When both HTTP and MQTT are specified, the
    -- target device can choose the protocol.
    CreateOTAUpdate -> Maybe (NonEmpty Protocol)
protocols :: Prelude.Maybe (Prelude.NonEmpty Protocol),
    -- | Configuration information for pre-signed URLs.
    CreateOTAUpdate -> Maybe AwsJobPresignedUrlConfig
awsJobPresignedUrlConfig :: Prelude.Maybe AwsJobPresignedUrlConfig,
    -- | A list of additional OTA update parameters which are name-value pairs.
    CreateOTAUpdate -> Maybe (HashMap Text Text)
additionalParameters :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | Specifies the amount of time each device has to finish its execution of
    -- the job. A timer is started when the job execution status is set to
    -- @IN_PROGRESS@. If the job execution status is not set to another
    -- terminal state before the timer expires, it will be automatically set to
    -- @TIMED_OUT@.
    CreateOTAUpdate -> Maybe AwsJobTimeoutConfig
awsJobTimeoutConfig :: Prelude.Maybe AwsJobTimeoutConfig,
    -- | The description of the OTA update.
    CreateOTAUpdate -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | Specifies whether the update will continue to run (CONTINUOUS), or will
    -- be complete after all the things specified as targets have completed the
    -- update (SNAPSHOT). If continuous, the update may also be run on a thing
    -- when a change is detected in a target. For example, an update will run
    -- on a thing when the thing is added to a target group, even after the
    -- update was completed by all things originally in the group. Valid
    -- values: CONTINUOUS | SNAPSHOT.
    CreateOTAUpdate -> Maybe TargetSelection
targetSelection :: Prelude.Maybe TargetSelection,
    -- | Metadata which can be used to manage updates.
    CreateOTAUpdate -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
    -- | The ID of the OTA update to be created.
    CreateOTAUpdate -> Text
otaUpdateId :: Prelude.Text,
    -- | The devices targeted to receive OTA updates.
    CreateOTAUpdate -> NonEmpty Text
targets :: Prelude.NonEmpty Prelude.Text,
    -- | The files to be streamed by the OTA update.
    CreateOTAUpdate -> NonEmpty OTAUpdateFile
files :: Prelude.NonEmpty OTAUpdateFile,
    -- | The IAM role that grants Amazon Web Services IoT Core access to the
    -- Amazon S3, IoT jobs and Amazon Web Services Code Signing resources to
    -- create an OTA update job.
    CreateOTAUpdate -> Text
roleArn :: Prelude.Text
  }
  deriving (CreateOTAUpdate -> CreateOTAUpdate -> Bool
(CreateOTAUpdate -> CreateOTAUpdate -> Bool)
-> (CreateOTAUpdate -> CreateOTAUpdate -> Bool)
-> Eq CreateOTAUpdate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateOTAUpdate -> CreateOTAUpdate -> Bool
$c/= :: CreateOTAUpdate -> CreateOTAUpdate -> Bool
== :: CreateOTAUpdate -> CreateOTAUpdate -> Bool
$c== :: CreateOTAUpdate -> CreateOTAUpdate -> Bool
Prelude.Eq, ReadPrec [CreateOTAUpdate]
ReadPrec CreateOTAUpdate
Int -> ReadS CreateOTAUpdate
ReadS [CreateOTAUpdate]
(Int -> ReadS CreateOTAUpdate)
-> ReadS [CreateOTAUpdate]
-> ReadPrec CreateOTAUpdate
-> ReadPrec [CreateOTAUpdate]
-> Read CreateOTAUpdate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateOTAUpdate]
$creadListPrec :: ReadPrec [CreateOTAUpdate]
readPrec :: ReadPrec CreateOTAUpdate
$creadPrec :: ReadPrec CreateOTAUpdate
readList :: ReadS [CreateOTAUpdate]
$creadList :: ReadS [CreateOTAUpdate]
readsPrec :: Int -> ReadS CreateOTAUpdate
$creadsPrec :: Int -> ReadS CreateOTAUpdate
Prelude.Read, Int -> CreateOTAUpdate -> ShowS
[CreateOTAUpdate] -> ShowS
CreateOTAUpdate -> String
(Int -> CreateOTAUpdate -> ShowS)
-> (CreateOTAUpdate -> String)
-> ([CreateOTAUpdate] -> ShowS)
-> Show CreateOTAUpdate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateOTAUpdate] -> ShowS
$cshowList :: [CreateOTAUpdate] -> ShowS
show :: CreateOTAUpdate -> String
$cshow :: CreateOTAUpdate -> String
showsPrec :: Int -> CreateOTAUpdate -> ShowS
$cshowsPrec :: Int -> CreateOTAUpdate -> ShowS
Prelude.Show, (forall x. CreateOTAUpdate -> Rep CreateOTAUpdate x)
-> (forall x. Rep CreateOTAUpdate x -> CreateOTAUpdate)
-> Generic CreateOTAUpdate
forall x. Rep CreateOTAUpdate x -> CreateOTAUpdate
forall x. CreateOTAUpdate -> Rep CreateOTAUpdate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateOTAUpdate x -> CreateOTAUpdate
$cfrom :: forall x. CreateOTAUpdate -> Rep CreateOTAUpdate x
Prelude.Generic)

-- |
-- Create a value of 'CreateOTAUpdate' 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:
--
-- 'awsJobAbortConfig', 'createOTAUpdate_awsJobAbortConfig' - The criteria that determine when and how a job abort takes place.
--
-- 'awsJobExecutionsRolloutConfig', 'createOTAUpdate_awsJobExecutionsRolloutConfig' - Configuration for the rollout of OTA updates.
--
-- 'protocols', 'createOTAUpdate_protocols' - The protocol used to transfer the OTA update image. Valid values are
-- [HTTP], [MQTT], [HTTP, MQTT]. When both HTTP and MQTT are specified, the
-- target device can choose the protocol.
--
-- 'awsJobPresignedUrlConfig', 'createOTAUpdate_awsJobPresignedUrlConfig' - Configuration information for pre-signed URLs.
--
-- 'additionalParameters', 'createOTAUpdate_additionalParameters' - A list of additional OTA update parameters which are name-value pairs.
--
-- 'awsJobTimeoutConfig', 'createOTAUpdate_awsJobTimeoutConfig' - Specifies the amount of time each device has to finish its execution of
-- the job. A timer is started when the job execution status is set to
-- @IN_PROGRESS@. If the job execution status is not set to another
-- terminal state before the timer expires, it will be automatically set to
-- @TIMED_OUT@.
--
-- 'description', 'createOTAUpdate_description' - The description of the OTA update.
--
-- 'targetSelection', 'createOTAUpdate_targetSelection' - Specifies whether the update will continue to run (CONTINUOUS), or will
-- be complete after all the things specified as targets have completed the
-- update (SNAPSHOT). If continuous, the update may also be run on a thing
-- when a change is detected in a target. For example, an update will run
-- on a thing when the thing is added to a target group, even after the
-- update was completed by all things originally in the group. Valid
-- values: CONTINUOUS | SNAPSHOT.
--
-- 'tags', 'createOTAUpdate_tags' - Metadata which can be used to manage updates.
--
-- 'otaUpdateId', 'createOTAUpdate_otaUpdateId' - The ID of the OTA update to be created.
--
-- 'targets', 'createOTAUpdate_targets' - The devices targeted to receive OTA updates.
--
-- 'files', 'createOTAUpdate_files' - The files to be streamed by the OTA update.
--
-- 'roleArn', 'createOTAUpdate_roleArn' - The IAM role that grants Amazon Web Services IoT Core access to the
-- Amazon S3, IoT jobs and Amazon Web Services Code Signing resources to
-- create an OTA update job.
newCreateOTAUpdate ::
  -- | 'otaUpdateId'
  Prelude.Text ->
  -- | 'targets'
  Prelude.NonEmpty Prelude.Text ->
  -- | 'files'
  Prelude.NonEmpty OTAUpdateFile ->
  -- | 'roleArn'
  Prelude.Text ->
  CreateOTAUpdate
newCreateOTAUpdate :: Text
-> NonEmpty Text
-> NonEmpty OTAUpdateFile
-> Text
-> CreateOTAUpdate
newCreateOTAUpdate
  Text
pOtaUpdateId_
  NonEmpty Text
pTargets_
  NonEmpty OTAUpdateFile
pFiles_
  Text
pRoleArn_ =
    CreateOTAUpdate' :: Maybe AwsJobAbortConfig
-> Maybe AwsJobExecutionsRolloutConfig
-> Maybe (NonEmpty Protocol)
-> Maybe AwsJobPresignedUrlConfig
-> Maybe (HashMap Text Text)
-> Maybe AwsJobTimeoutConfig
-> Maybe Text
-> Maybe TargetSelection
-> Maybe [Tag]
-> Text
-> NonEmpty Text
-> NonEmpty OTAUpdateFile
-> Text
-> CreateOTAUpdate
CreateOTAUpdate'
      { $sel:awsJobAbortConfig:CreateOTAUpdate' :: Maybe AwsJobAbortConfig
awsJobAbortConfig =
          Maybe AwsJobAbortConfig
forall a. Maybe a
Prelude.Nothing,
        $sel:awsJobExecutionsRolloutConfig:CreateOTAUpdate' :: Maybe AwsJobExecutionsRolloutConfig
awsJobExecutionsRolloutConfig = Maybe AwsJobExecutionsRolloutConfig
forall a. Maybe a
Prelude.Nothing,
        $sel:protocols:CreateOTAUpdate' :: Maybe (NonEmpty Protocol)
protocols = Maybe (NonEmpty Protocol)
forall a. Maybe a
Prelude.Nothing,
        $sel:awsJobPresignedUrlConfig:CreateOTAUpdate' :: Maybe AwsJobPresignedUrlConfig
awsJobPresignedUrlConfig = Maybe AwsJobPresignedUrlConfig
forall a. Maybe a
Prelude.Nothing,
        $sel:additionalParameters:CreateOTAUpdate' :: Maybe (HashMap Text Text)
additionalParameters = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
        $sel:awsJobTimeoutConfig:CreateOTAUpdate' :: Maybe AwsJobTimeoutConfig
awsJobTimeoutConfig = Maybe AwsJobTimeoutConfig
forall a. Maybe a
Prelude.Nothing,
        $sel:description:CreateOTAUpdate' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:targetSelection:CreateOTAUpdate' :: Maybe TargetSelection
targetSelection = Maybe TargetSelection
forall a. Maybe a
Prelude.Nothing,
        $sel:tags:CreateOTAUpdate' :: Maybe [Tag]
tags = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing,
        $sel:otaUpdateId:CreateOTAUpdate' :: Text
otaUpdateId = Text
pOtaUpdateId_,
        $sel:targets:CreateOTAUpdate' :: NonEmpty Text
targets = Tagged (NonEmpty Text) (Identity (NonEmpty Text))
-> Tagged (NonEmpty Text) (Identity (NonEmpty Text))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged (NonEmpty Text) (Identity (NonEmpty Text))
 -> Tagged (NonEmpty Text) (Identity (NonEmpty Text)))
-> NonEmpty Text -> NonEmpty Text
forall t b. AReview t b -> b -> t
Lens.# NonEmpty Text
pTargets_,
        $sel:files:CreateOTAUpdate' :: NonEmpty OTAUpdateFile
files = Tagged (NonEmpty OTAUpdateFile) (Identity (NonEmpty OTAUpdateFile))
-> Tagged
     (NonEmpty OTAUpdateFile) (Identity (NonEmpty OTAUpdateFile))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged
   (NonEmpty OTAUpdateFile) (Identity (NonEmpty OTAUpdateFile))
 -> Tagged
      (NonEmpty OTAUpdateFile) (Identity (NonEmpty OTAUpdateFile)))
-> NonEmpty OTAUpdateFile -> NonEmpty OTAUpdateFile
forall t b. AReview t b -> b -> t
Lens.# NonEmpty OTAUpdateFile
pFiles_,
        $sel:roleArn:CreateOTAUpdate' :: Text
roleArn = Text
pRoleArn_
      }

-- | The criteria that determine when and how a job abort takes place.
createOTAUpdate_awsJobAbortConfig :: Lens.Lens' CreateOTAUpdate (Prelude.Maybe AwsJobAbortConfig)
createOTAUpdate_awsJobAbortConfig :: (Maybe AwsJobAbortConfig -> f (Maybe AwsJobAbortConfig))
-> CreateOTAUpdate -> f CreateOTAUpdate
createOTAUpdate_awsJobAbortConfig = (CreateOTAUpdate -> Maybe AwsJobAbortConfig)
-> (CreateOTAUpdate -> Maybe AwsJobAbortConfig -> CreateOTAUpdate)
-> Lens
     CreateOTAUpdate
     CreateOTAUpdate
     (Maybe AwsJobAbortConfig)
     (Maybe AwsJobAbortConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateOTAUpdate' {Maybe AwsJobAbortConfig
awsJobAbortConfig :: Maybe AwsJobAbortConfig
$sel:awsJobAbortConfig:CreateOTAUpdate' :: CreateOTAUpdate -> Maybe AwsJobAbortConfig
awsJobAbortConfig} -> Maybe AwsJobAbortConfig
awsJobAbortConfig) (\s :: CreateOTAUpdate
s@CreateOTAUpdate' {} Maybe AwsJobAbortConfig
a -> CreateOTAUpdate
s {$sel:awsJobAbortConfig:CreateOTAUpdate' :: Maybe AwsJobAbortConfig
awsJobAbortConfig = Maybe AwsJobAbortConfig
a} :: CreateOTAUpdate)

-- | Configuration for the rollout of OTA updates.
createOTAUpdate_awsJobExecutionsRolloutConfig :: Lens.Lens' CreateOTAUpdate (Prelude.Maybe AwsJobExecutionsRolloutConfig)
createOTAUpdate_awsJobExecutionsRolloutConfig :: (Maybe AwsJobExecutionsRolloutConfig
 -> f (Maybe AwsJobExecutionsRolloutConfig))
-> CreateOTAUpdate -> f CreateOTAUpdate
createOTAUpdate_awsJobExecutionsRolloutConfig = (CreateOTAUpdate -> Maybe AwsJobExecutionsRolloutConfig)
-> (CreateOTAUpdate
    -> Maybe AwsJobExecutionsRolloutConfig -> CreateOTAUpdate)
-> Lens
     CreateOTAUpdate
     CreateOTAUpdate
     (Maybe AwsJobExecutionsRolloutConfig)
     (Maybe AwsJobExecutionsRolloutConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateOTAUpdate' {Maybe AwsJobExecutionsRolloutConfig
awsJobExecutionsRolloutConfig :: Maybe AwsJobExecutionsRolloutConfig
$sel:awsJobExecutionsRolloutConfig:CreateOTAUpdate' :: CreateOTAUpdate -> Maybe AwsJobExecutionsRolloutConfig
awsJobExecutionsRolloutConfig} -> Maybe AwsJobExecutionsRolloutConfig
awsJobExecutionsRolloutConfig) (\s :: CreateOTAUpdate
s@CreateOTAUpdate' {} Maybe AwsJobExecutionsRolloutConfig
a -> CreateOTAUpdate
s {$sel:awsJobExecutionsRolloutConfig:CreateOTAUpdate' :: Maybe AwsJobExecutionsRolloutConfig
awsJobExecutionsRolloutConfig = Maybe AwsJobExecutionsRolloutConfig
a} :: CreateOTAUpdate)

-- | The protocol used to transfer the OTA update image. Valid values are
-- [HTTP], [MQTT], [HTTP, MQTT]. When both HTTP and MQTT are specified, the
-- target device can choose the protocol.
createOTAUpdate_protocols :: Lens.Lens' CreateOTAUpdate (Prelude.Maybe (Prelude.NonEmpty Protocol))
createOTAUpdate_protocols :: (Maybe (NonEmpty Protocol) -> f (Maybe (NonEmpty Protocol)))
-> CreateOTAUpdate -> f CreateOTAUpdate
createOTAUpdate_protocols = (CreateOTAUpdate -> Maybe (NonEmpty Protocol))
-> (CreateOTAUpdate
    -> Maybe (NonEmpty Protocol) -> CreateOTAUpdate)
-> Lens
     CreateOTAUpdate
     CreateOTAUpdate
     (Maybe (NonEmpty Protocol))
     (Maybe (NonEmpty Protocol))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateOTAUpdate' {Maybe (NonEmpty Protocol)
protocols :: Maybe (NonEmpty Protocol)
$sel:protocols:CreateOTAUpdate' :: CreateOTAUpdate -> Maybe (NonEmpty Protocol)
protocols} -> Maybe (NonEmpty Protocol)
protocols) (\s :: CreateOTAUpdate
s@CreateOTAUpdate' {} Maybe (NonEmpty Protocol)
a -> CreateOTAUpdate
s {$sel:protocols:CreateOTAUpdate' :: Maybe (NonEmpty Protocol)
protocols = Maybe (NonEmpty Protocol)
a} :: CreateOTAUpdate) ((Maybe (NonEmpty Protocol) -> f (Maybe (NonEmpty Protocol)))
 -> CreateOTAUpdate -> f CreateOTAUpdate)
-> ((Maybe (NonEmpty Protocol) -> f (Maybe (NonEmpty Protocol)))
    -> Maybe (NonEmpty Protocol) -> f (Maybe (NonEmpty Protocol)))
-> (Maybe (NonEmpty Protocol) -> f (Maybe (NonEmpty Protocol)))
-> CreateOTAUpdate
-> f CreateOTAUpdate
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty Protocol)
  (NonEmpty Protocol)
  (NonEmpty Protocol)
  (NonEmpty Protocol)
-> Iso
     (Maybe (NonEmpty Protocol))
     (Maybe (NonEmpty Protocol))
     (Maybe (NonEmpty Protocol))
     (Maybe (NonEmpty Protocol))
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 AnIso
  (NonEmpty Protocol)
  (NonEmpty Protocol)
  (NonEmpty Protocol)
  (NonEmpty Protocol)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Configuration information for pre-signed URLs.
createOTAUpdate_awsJobPresignedUrlConfig :: Lens.Lens' CreateOTAUpdate (Prelude.Maybe AwsJobPresignedUrlConfig)
createOTAUpdate_awsJobPresignedUrlConfig :: (Maybe AwsJobPresignedUrlConfig
 -> f (Maybe AwsJobPresignedUrlConfig))
-> CreateOTAUpdate -> f CreateOTAUpdate
createOTAUpdate_awsJobPresignedUrlConfig = (CreateOTAUpdate -> Maybe AwsJobPresignedUrlConfig)
-> (CreateOTAUpdate
    -> Maybe AwsJobPresignedUrlConfig -> CreateOTAUpdate)
-> Lens
     CreateOTAUpdate
     CreateOTAUpdate
     (Maybe AwsJobPresignedUrlConfig)
     (Maybe AwsJobPresignedUrlConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateOTAUpdate' {Maybe AwsJobPresignedUrlConfig
awsJobPresignedUrlConfig :: Maybe AwsJobPresignedUrlConfig
$sel:awsJobPresignedUrlConfig:CreateOTAUpdate' :: CreateOTAUpdate -> Maybe AwsJobPresignedUrlConfig
awsJobPresignedUrlConfig} -> Maybe AwsJobPresignedUrlConfig
awsJobPresignedUrlConfig) (\s :: CreateOTAUpdate
s@CreateOTAUpdate' {} Maybe AwsJobPresignedUrlConfig
a -> CreateOTAUpdate
s {$sel:awsJobPresignedUrlConfig:CreateOTAUpdate' :: Maybe AwsJobPresignedUrlConfig
awsJobPresignedUrlConfig = Maybe AwsJobPresignedUrlConfig
a} :: CreateOTAUpdate)

-- | A list of additional OTA update parameters which are name-value pairs.
createOTAUpdate_additionalParameters :: Lens.Lens' CreateOTAUpdate (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
createOTAUpdate_additionalParameters :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateOTAUpdate -> f CreateOTAUpdate
createOTAUpdate_additionalParameters = (CreateOTAUpdate -> Maybe (HashMap Text Text))
-> (CreateOTAUpdate
    -> Maybe (HashMap Text Text) -> CreateOTAUpdate)
-> Lens
     CreateOTAUpdate
     CreateOTAUpdate
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateOTAUpdate' {Maybe (HashMap Text Text)
additionalParameters :: Maybe (HashMap Text Text)
$sel:additionalParameters:CreateOTAUpdate' :: CreateOTAUpdate -> Maybe (HashMap Text Text)
additionalParameters} -> Maybe (HashMap Text Text)
additionalParameters) (\s :: CreateOTAUpdate
s@CreateOTAUpdate' {} Maybe (HashMap Text Text)
a -> CreateOTAUpdate
s {$sel:additionalParameters:CreateOTAUpdate' :: Maybe (HashMap Text Text)
additionalParameters = Maybe (HashMap Text Text)
a} :: CreateOTAUpdate) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> CreateOTAUpdate -> f CreateOTAUpdate)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateOTAUpdate
-> f CreateOTAUpdate
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
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 AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Specifies the amount of time each device has to finish its execution of
-- the job. A timer is started when the job execution status is set to
-- @IN_PROGRESS@. If the job execution status is not set to another
-- terminal state before the timer expires, it will be automatically set to
-- @TIMED_OUT@.
createOTAUpdate_awsJobTimeoutConfig :: Lens.Lens' CreateOTAUpdate (Prelude.Maybe AwsJobTimeoutConfig)
createOTAUpdate_awsJobTimeoutConfig :: (Maybe AwsJobTimeoutConfig -> f (Maybe AwsJobTimeoutConfig))
-> CreateOTAUpdate -> f CreateOTAUpdate
createOTAUpdate_awsJobTimeoutConfig = (CreateOTAUpdate -> Maybe AwsJobTimeoutConfig)
-> (CreateOTAUpdate
    -> Maybe AwsJobTimeoutConfig -> CreateOTAUpdate)
-> Lens
     CreateOTAUpdate
     CreateOTAUpdate
     (Maybe AwsJobTimeoutConfig)
     (Maybe AwsJobTimeoutConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateOTAUpdate' {Maybe AwsJobTimeoutConfig
awsJobTimeoutConfig :: Maybe AwsJobTimeoutConfig
$sel:awsJobTimeoutConfig:CreateOTAUpdate' :: CreateOTAUpdate -> Maybe AwsJobTimeoutConfig
awsJobTimeoutConfig} -> Maybe AwsJobTimeoutConfig
awsJobTimeoutConfig) (\s :: CreateOTAUpdate
s@CreateOTAUpdate' {} Maybe AwsJobTimeoutConfig
a -> CreateOTAUpdate
s {$sel:awsJobTimeoutConfig:CreateOTAUpdate' :: Maybe AwsJobTimeoutConfig
awsJobTimeoutConfig = Maybe AwsJobTimeoutConfig
a} :: CreateOTAUpdate)

-- | The description of the OTA update.
createOTAUpdate_description :: Lens.Lens' CreateOTAUpdate (Prelude.Maybe Prelude.Text)
createOTAUpdate_description :: (Maybe Text -> f (Maybe Text))
-> CreateOTAUpdate -> f CreateOTAUpdate
createOTAUpdate_description = (CreateOTAUpdate -> Maybe Text)
-> (CreateOTAUpdate -> Maybe Text -> CreateOTAUpdate)
-> Lens CreateOTAUpdate CreateOTAUpdate (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateOTAUpdate' {Maybe Text
description :: Maybe Text
$sel:description:CreateOTAUpdate' :: CreateOTAUpdate -> Maybe Text
description} -> Maybe Text
description) (\s :: CreateOTAUpdate
s@CreateOTAUpdate' {} Maybe Text
a -> CreateOTAUpdate
s {$sel:description:CreateOTAUpdate' :: Maybe Text
description = Maybe Text
a} :: CreateOTAUpdate)

-- | Specifies whether the update will continue to run (CONTINUOUS), or will
-- be complete after all the things specified as targets have completed the
-- update (SNAPSHOT). If continuous, the update may also be run on a thing
-- when a change is detected in a target. For example, an update will run
-- on a thing when the thing is added to a target group, even after the
-- update was completed by all things originally in the group. Valid
-- values: CONTINUOUS | SNAPSHOT.
createOTAUpdate_targetSelection :: Lens.Lens' CreateOTAUpdate (Prelude.Maybe TargetSelection)
createOTAUpdate_targetSelection :: (Maybe TargetSelection -> f (Maybe TargetSelection))
-> CreateOTAUpdate -> f CreateOTAUpdate
createOTAUpdate_targetSelection = (CreateOTAUpdate -> Maybe TargetSelection)
-> (CreateOTAUpdate -> Maybe TargetSelection -> CreateOTAUpdate)
-> Lens
     CreateOTAUpdate
     CreateOTAUpdate
     (Maybe TargetSelection)
     (Maybe TargetSelection)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateOTAUpdate' {Maybe TargetSelection
targetSelection :: Maybe TargetSelection
$sel:targetSelection:CreateOTAUpdate' :: CreateOTAUpdate -> Maybe TargetSelection
targetSelection} -> Maybe TargetSelection
targetSelection) (\s :: CreateOTAUpdate
s@CreateOTAUpdate' {} Maybe TargetSelection
a -> CreateOTAUpdate
s {$sel:targetSelection:CreateOTAUpdate' :: Maybe TargetSelection
targetSelection = Maybe TargetSelection
a} :: CreateOTAUpdate)

-- | Metadata which can be used to manage updates.
createOTAUpdate_tags :: Lens.Lens' CreateOTAUpdate (Prelude.Maybe [Tag])
createOTAUpdate_tags :: (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateOTAUpdate -> f CreateOTAUpdate
createOTAUpdate_tags = (CreateOTAUpdate -> Maybe [Tag])
-> (CreateOTAUpdate -> Maybe [Tag] -> CreateOTAUpdate)
-> Lens CreateOTAUpdate CreateOTAUpdate (Maybe [Tag]) (Maybe [Tag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateOTAUpdate' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:CreateOTAUpdate' :: CreateOTAUpdate -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: CreateOTAUpdate
s@CreateOTAUpdate' {} Maybe [Tag]
a -> CreateOTAUpdate
s {$sel:tags:CreateOTAUpdate' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: CreateOTAUpdate) ((Maybe [Tag] -> f (Maybe [Tag]))
 -> CreateOTAUpdate -> f CreateOTAUpdate)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
    -> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateOTAUpdate
-> f CreateOTAUpdate
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Tag] [Tag] [Tag] [Tag]
-> Iso (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag])
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 AnIso [Tag] [Tag] [Tag] [Tag]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The ID of the OTA update to be created.
createOTAUpdate_otaUpdateId :: Lens.Lens' CreateOTAUpdate Prelude.Text
createOTAUpdate_otaUpdateId :: (Text -> f Text) -> CreateOTAUpdate -> f CreateOTAUpdate
createOTAUpdate_otaUpdateId = (CreateOTAUpdate -> Text)
-> (CreateOTAUpdate -> Text -> CreateOTAUpdate)
-> Lens CreateOTAUpdate CreateOTAUpdate Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateOTAUpdate' {Text
otaUpdateId :: Text
$sel:otaUpdateId:CreateOTAUpdate' :: CreateOTAUpdate -> Text
otaUpdateId} -> Text
otaUpdateId) (\s :: CreateOTAUpdate
s@CreateOTAUpdate' {} Text
a -> CreateOTAUpdate
s {$sel:otaUpdateId:CreateOTAUpdate' :: Text
otaUpdateId = Text
a} :: CreateOTAUpdate)

-- | The devices targeted to receive OTA updates.
createOTAUpdate_targets :: Lens.Lens' CreateOTAUpdate (Prelude.NonEmpty Prelude.Text)
createOTAUpdate_targets :: (NonEmpty Text -> f (NonEmpty Text))
-> CreateOTAUpdate -> f CreateOTAUpdate
createOTAUpdate_targets = (CreateOTAUpdate -> NonEmpty Text)
-> (CreateOTAUpdate -> NonEmpty Text -> CreateOTAUpdate)
-> Lens
     CreateOTAUpdate CreateOTAUpdate (NonEmpty Text) (NonEmpty Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateOTAUpdate' {NonEmpty Text
targets :: NonEmpty Text
$sel:targets:CreateOTAUpdate' :: CreateOTAUpdate -> NonEmpty Text
targets} -> NonEmpty Text
targets) (\s :: CreateOTAUpdate
s@CreateOTAUpdate' {} NonEmpty Text
a -> CreateOTAUpdate
s {$sel:targets:CreateOTAUpdate' :: NonEmpty Text
targets = NonEmpty Text
a} :: CreateOTAUpdate) ((NonEmpty Text -> f (NonEmpty Text))
 -> CreateOTAUpdate -> f CreateOTAUpdate)
-> ((NonEmpty Text -> f (NonEmpty Text))
    -> NonEmpty Text -> f (NonEmpty Text))
-> (NonEmpty Text -> f (NonEmpty Text))
-> CreateOTAUpdate
-> f CreateOTAUpdate
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty Text -> f (NonEmpty Text))
-> NonEmpty Text -> f (NonEmpty Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The files to be streamed by the OTA update.
createOTAUpdate_files :: Lens.Lens' CreateOTAUpdate (Prelude.NonEmpty OTAUpdateFile)
createOTAUpdate_files :: (NonEmpty OTAUpdateFile -> f (NonEmpty OTAUpdateFile))
-> CreateOTAUpdate -> f CreateOTAUpdate
createOTAUpdate_files = (CreateOTAUpdate -> NonEmpty OTAUpdateFile)
-> (CreateOTAUpdate -> NonEmpty OTAUpdateFile -> CreateOTAUpdate)
-> Lens
     CreateOTAUpdate
     CreateOTAUpdate
     (NonEmpty OTAUpdateFile)
     (NonEmpty OTAUpdateFile)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateOTAUpdate' {NonEmpty OTAUpdateFile
files :: NonEmpty OTAUpdateFile
$sel:files:CreateOTAUpdate' :: CreateOTAUpdate -> NonEmpty OTAUpdateFile
files} -> NonEmpty OTAUpdateFile
files) (\s :: CreateOTAUpdate
s@CreateOTAUpdate' {} NonEmpty OTAUpdateFile
a -> CreateOTAUpdate
s {$sel:files:CreateOTAUpdate' :: NonEmpty OTAUpdateFile
files = NonEmpty OTAUpdateFile
a} :: CreateOTAUpdate) ((NonEmpty OTAUpdateFile -> f (NonEmpty OTAUpdateFile))
 -> CreateOTAUpdate -> f CreateOTAUpdate)
-> ((NonEmpty OTAUpdateFile -> f (NonEmpty OTAUpdateFile))
    -> NonEmpty OTAUpdateFile -> f (NonEmpty OTAUpdateFile))
-> (NonEmpty OTAUpdateFile -> f (NonEmpty OTAUpdateFile))
-> CreateOTAUpdate
-> f CreateOTAUpdate
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty OTAUpdateFile -> f (NonEmpty OTAUpdateFile))
-> NonEmpty OTAUpdateFile -> f (NonEmpty OTAUpdateFile)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The IAM role that grants Amazon Web Services IoT Core access to the
-- Amazon S3, IoT jobs and Amazon Web Services Code Signing resources to
-- create an OTA update job.
createOTAUpdate_roleArn :: Lens.Lens' CreateOTAUpdate Prelude.Text
createOTAUpdate_roleArn :: (Text -> f Text) -> CreateOTAUpdate -> f CreateOTAUpdate
createOTAUpdate_roleArn = (CreateOTAUpdate -> Text)
-> (CreateOTAUpdate -> Text -> CreateOTAUpdate)
-> Lens CreateOTAUpdate CreateOTAUpdate Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateOTAUpdate' {Text
roleArn :: Text
$sel:roleArn:CreateOTAUpdate' :: CreateOTAUpdate -> Text
roleArn} -> Text
roleArn) (\s :: CreateOTAUpdate
s@CreateOTAUpdate' {} Text
a -> CreateOTAUpdate
s {$sel:roleArn:CreateOTAUpdate' :: Text
roleArn = Text
a} :: CreateOTAUpdate)

instance Core.AWSRequest CreateOTAUpdate where
  type
    AWSResponse CreateOTAUpdate =
      CreateOTAUpdateResponse
  request :: CreateOTAUpdate -> Request CreateOTAUpdate
request = Service -> CreateOTAUpdate -> Request CreateOTAUpdate
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateOTAUpdate
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateOTAUpdate)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreateOTAUpdate))
-> Logger
-> Service
-> Proxy CreateOTAUpdate
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateOTAUpdate)))
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 OTAUpdateStatus
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Int
-> CreateOTAUpdateResponse
CreateOTAUpdateResponse'
            (Maybe Text
 -> Maybe OTAUpdateStatus
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Int
 -> CreateOTAUpdateResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe OTAUpdateStatus
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Int
      -> CreateOTAUpdateResponse)
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
"awsIotJobId")
            Either
  String
  (Maybe OTAUpdateStatus
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Int
   -> CreateOTAUpdateResponse)
-> Either String (Maybe OTAUpdateStatus)
-> Either
     String
     (Maybe Text
      -> Maybe Text -> Maybe Text -> Int -> CreateOTAUpdateResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe OTAUpdateStatus)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"otaUpdateStatus")
            Either
  String
  (Maybe Text
   -> Maybe Text -> Maybe Text -> Int -> CreateOTAUpdateResponse)
-> Either String (Maybe Text)
-> Either
     String (Maybe Text -> Maybe Text -> Int -> CreateOTAUpdateResponse)
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
"awsIotJobArn")
            Either
  String (Maybe Text -> Maybe Text -> Int -> CreateOTAUpdateResponse)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> Int -> CreateOTAUpdateResponse)
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
"otaUpdateId")
            Either String (Maybe Text -> Int -> CreateOTAUpdateResponse)
-> Either String (Maybe Text)
-> Either String (Int -> CreateOTAUpdateResponse)
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
"otaUpdateArn")
            Either String (Int -> CreateOTAUpdateResponse)
-> Either String Int -> Either String CreateOTAUpdateResponse
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 CreateOTAUpdate

instance Prelude.NFData CreateOTAUpdate

instance Core.ToHeaders CreateOTAUpdate where
  toHeaders :: CreateOTAUpdate -> ResponseHeaders
toHeaders = ResponseHeaders -> CreateOTAUpdate -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

instance Core.ToJSON CreateOTAUpdate where
  toJSON :: CreateOTAUpdate -> Value
toJSON CreateOTAUpdate' {Maybe [Tag]
Maybe (NonEmpty Protocol)
Maybe Text
Maybe (HashMap Text Text)
Maybe AwsJobAbortConfig
Maybe AwsJobPresignedUrlConfig
Maybe AwsJobExecutionsRolloutConfig
Maybe AwsJobTimeoutConfig
Maybe TargetSelection
NonEmpty Text
NonEmpty OTAUpdateFile
Text
roleArn :: Text
files :: NonEmpty OTAUpdateFile
targets :: NonEmpty Text
otaUpdateId :: Text
tags :: Maybe [Tag]
targetSelection :: Maybe TargetSelection
description :: Maybe Text
awsJobTimeoutConfig :: Maybe AwsJobTimeoutConfig
additionalParameters :: Maybe (HashMap Text Text)
awsJobPresignedUrlConfig :: Maybe AwsJobPresignedUrlConfig
protocols :: Maybe (NonEmpty Protocol)
awsJobExecutionsRolloutConfig :: Maybe AwsJobExecutionsRolloutConfig
awsJobAbortConfig :: Maybe AwsJobAbortConfig
$sel:roleArn:CreateOTAUpdate' :: CreateOTAUpdate -> Text
$sel:files:CreateOTAUpdate' :: CreateOTAUpdate -> NonEmpty OTAUpdateFile
$sel:targets:CreateOTAUpdate' :: CreateOTAUpdate -> NonEmpty Text
$sel:otaUpdateId:CreateOTAUpdate' :: CreateOTAUpdate -> Text
$sel:tags:CreateOTAUpdate' :: CreateOTAUpdate -> Maybe [Tag]
$sel:targetSelection:CreateOTAUpdate' :: CreateOTAUpdate -> Maybe TargetSelection
$sel:description:CreateOTAUpdate' :: CreateOTAUpdate -> Maybe Text
$sel:awsJobTimeoutConfig:CreateOTAUpdate' :: CreateOTAUpdate -> Maybe AwsJobTimeoutConfig
$sel:additionalParameters:CreateOTAUpdate' :: CreateOTAUpdate -> Maybe (HashMap Text Text)
$sel:awsJobPresignedUrlConfig:CreateOTAUpdate' :: CreateOTAUpdate -> Maybe AwsJobPresignedUrlConfig
$sel:protocols:CreateOTAUpdate' :: CreateOTAUpdate -> Maybe (NonEmpty Protocol)
$sel:awsJobExecutionsRolloutConfig:CreateOTAUpdate' :: CreateOTAUpdate -> Maybe AwsJobExecutionsRolloutConfig
$sel:awsJobAbortConfig:CreateOTAUpdate' :: CreateOTAUpdate -> Maybe AwsJobAbortConfig
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"awsJobAbortConfig" Text -> AwsJobAbortConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (AwsJobAbortConfig -> Pair)
-> Maybe AwsJobAbortConfig -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe AwsJobAbortConfig
awsJobAbortConfig,
            (Text
"awsJobExecutionsRolloutConfig" Text -> AwsJobExecutionsRolloutConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (AwsJobExecutionsRolloutConfig -> Pair)
-> Maybe AwsJobExecutionsRolloutConfig -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe AwsJobExecutionsRolloutConfig
awsJobExecutionsRolloutConfig,
            (Text
"protocols" Text -> NonEmpty Protocol -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (NonEmpty Protocol -> Pair)
-> Maybe (NonEmpty Protocol) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Protocol)
protocols,
            (Text
"awsJobPresignedUrlConfig" Text -> AwsJobPresignedUrlConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (AwsJobPresignedUrlConfig -> Pair)
-> Maybe AwsJobPresignedUrlConfig -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe AwsJobPresignedUrlConfig
awsJobPresignedUrlConfig,
            (Text
"additionalParameters" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (HashMap Text Text -> Pair)
-> Maybe (HashMap Text Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
additionalParameters,
            (Text
"awsJobTimeoutConfig" Text -> AwsJobTimeoutConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (AwsJobTimeoutConfig -> Pair)
-> Maybe AwsJobTimeoutConfig -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe AwsJobTimeoutConfig
awsJobTimeoutConfig,
            (Text
"description" 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
description,
            (Text
"targetSelection" Text -> TargetSelection -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (TargetSelection -> Pair) -> Maybe TargetSelection -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe TargetSelection
targetSelection,
            (Text
"tags" Text -> [Tag] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Tag] -> Pair) -> Maybe [Tag] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Tag]
tags,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"targets" Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty Text
targets),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"files" Text -> NonEmpty OTAUpdateFile -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty OTAUpdateFile
files),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"roleArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
roleArn)
          ]
      )

instance Core.ToPath CreateOTAUpdate where
  toPath :: CreateOTAUpdate -> ByteString
toPath CreateOTAUpdate' {Maybe [Tag]
Maybe (NonEmpty Protocol)
Maybe Text
Maybe (HashMap Text Text)
Maybe AwsJobAbortConfig
Maybe AwsJobPresignedUrlConfig
Maybe AwsJobExecutionsRolloutConfig
Maybe AwsJobTimeoutConfig
Maybe TargetSelection
NonEmpty Text
NonEmpty OTAUpdateFile
Text
roleArn :: Text
files :: NonEmpty OTAUpdateFile
targets :: NonEmpty Text
otaUpdateId :: Text
tags :: Maybe [Tag]
targetSelection :: Maybe TargetSelection
description :: Maybe Text
awsJobTimeoutConfig :: Maybe AwsJobTimeoutConfig
additionalParameters :: Maybe (HashMap Text Text)
awsJobPresignedUrlConfig :: Maybe AwsJobPresignedUrlConfig
protocols :: Maybe (NonEmpty Protocol)
awsJobExecutionsRolloutConfig :: Maybe AwsJobExecutionsRolloutConfig
awsJobAbortConfig :: Maybe AwsJobAbortConfig
$sel:roleArn:CreateOTAUpdate' :: CreateOTAUpdate -> Text
$sel:files:CreateOTAUpdate' :: CreateOTAUpdate -> NonEmpty OTAUpdateFile
$sel:targets:CreateOTAUpdate' :: CreateOTAUpdate -> NonEmpty Text
$sel:otaUpdateId:CreateOTAUpdate' :: CreateOTAUpdate -> Text
$sel:tags:CreateOTAUpdate' :: CreateOTAUpdate -> Maybe [Tag]
$sel:targetSelection:CreateOTAUpdate' :: CreateOTAUpdate -> Maybe TargetSelection
$sel:description:CreateOTAUpdate' :: CreateOTAUpdate -> Maybe Text
$sel:awsJobTimeoutConfig:CreateOTAUpdate' :: CreateOTAUpdate -> Maybe AwsJobTimeoutConfig
$sel:additionalParameters:CreateOTAUpdate' :: CreateOTAUpdate -> Maybe (HashMap Text Text)
$sel:awsJobPresignedUrlConfig:CreateOTAUpdate' :: CreateOTAUpdate -> Maybe AwsJobPresignedUrlConfig
$sel:protocols:CreateOTAUpdate' :: CreateOTAUpdate -> Maybe (NonEmpty Protocol)
$sel:awsJobExecutionsRolloutConfig:CreateOTAUpdate' :: CreateOTAUpdate -> Maybe AwsJobExecutionsRolloutConfig
$sel:awsJobAbortConfig:CreateOTAUpdate' :: CreateOTAUpdate -> Maybe AwsJobAbortConfig
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/otaUpdates/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
otaUpdateId]

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

-- | /See:/ 'newCreateOTAUpdateResponse' smart constructor.
data CreateOTAUpdateResponse = CreateOTAUpdateResponse'
  { -- | The IoT job ID associated with the OTA update.
    CreateOTAUpdateResponse -> Maybe Text
awsIotJobId :: Prelude.Maybe Prelude.Text,
    -- | The OTA update status.
    CreateOTAUpdateResponse -> Maybe OTAUpdateStatus
otaUpdateStatus :: Prelude.Maybe OTAUpdateStatus,
    -- | The IoT job ARN associated with the OTA update.
    CreateOTAUpdateResponse -> Maybe Text
awsIotJobArn :: Prelude.Maybe Prelude.Text,
    -- | The OTA update ID.
    CreateOTAUpdateResponse -> Maybe Text
otaUpdateId :: Prelude.Maybe Prelude.Text,
    -- | The OTA update ARN.
    CreateOTAUpdateResponse -> Maybe Text
otaUpdateArn :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    CreateOTAUpdateResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateOTAUpdateResponse -> CreateOTAUpdateResponse -> Bool
(CreateOTAUpdateResponse -> CreateOTAUpdateResponse -> Bool)
-> (CreateOTAUpdateResponse -> CreateOTAUpdateResponse -> Bool)
-> Eq CreateOTAUpdateResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateOTAUpdateResponse -> CreateOTAUpdateResponse -> Bool
$c/= :: CreateOTAUpdateResponse -> CreateOTAUpdateResponse -> Bool
== :: CreateOTAUpdateResponse -> CreateOTAUpdateResponse -> Bool
$c== :: CreateOTAUpdateResponse -> CreateOTAUpdateResponse -> Bool
Prelude.Eq, ReadPrec [CreateOTAUpdateResponse]
ReadPrec CreateOTAUpdateResponse
Int -> ReadS CreateOTAUpdateResponse
ReadS [CreateOTAUpdateResponse]
(Int -> ReadS CreateOTAUpdateResponse)
-> ReadS [CreateOTAUpdateResponse]
-> ReadPrec CreateOTAUpdateResponse
-> ReadPrec [CreateOTAUpdateResponse]
-> Read CreateOTAUpdateResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateOTAUpdateResponse]
$creadListPrec :: ReadPrec [CreateOTAUpdateResponse]
readPrec :: ReadPrec CreateOTAUpdateResponse
$creadPrec :: ReadPrec CreateOTAUpdateResponse
readList :: ReadS [CreateOTAUpdateResponse]
$creadList :: ReadS [CreateOTAUpdateResponse]
readsPrec :: Int -> ReadS CreateOTAUpdateResponse
$creadsPrec :: Int -> ReadS CreateOTAUpdateResponse
Prelude.Read, Int -> CreateOTAUpdateResponse -> ShowS
[CreateOTAUpdateResponse] -> ShowS
CreateOTAUpdateResponse -> String
(Int -> CreateOTAUpdateResponse -> ShowS)
-> (CreateOTAUpdateResponse -> String)
-> ([CreateOTAUpdateResponse] -> ShowS)
-> Show CreateOTAUpdateResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateOTAUpdateResponse] -> ShowS
$cshowList :: [CreateOTAUpdateResponse] -> ShowS
show :: CreateOTAUpdateResponse -> String
$cshow :: CreateOTAUpdateResponse -> String
showsPrec :: Int -> CreateOTAUpdateResponse -> ShowS
$cshowsPrec :: Int -> CreateOTAUpdateResponse -> ShowS
Prelude.Show, (forall x.
 CreateOTAUpdateResponse -> Rep CreateOTAUpdateResponse x)
-> (forall x.
    Rep CreateOTAUpdateResponse x -> CreateOTAUpdateResponse)
-> Generic CreateOTAUpdateResponse
forall x. Rep CreateOTAUpdateResponse x -> CreateOTAUpdateResponse
forall x. CreateOTAUpdateResponse -> Rep CreateOTAUpdateResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateOTAUpdateResponse x -> CreateOTAUpdateResponse
$cfrom :: forall x. CreateOTAUpdateResponse -> Rep CreateOTAUpdateResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateOTAUpdateResponse' 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:
--
-- 'awsIotJobId', 'createOTAUpdateResponse_awsIotJobId' - The IoT job ID associated with the OTA update.
--
-- 'otaUpdateStatus', 'createOTAUpdateResponse_otaUpdateStatus' - The OTA update status.
--
-- 'awsIotJobArn', 'createOTAUpdateResponse_awsIotJobArn' - The IoT job ARN associated with the OTA update.
--
-- 'otaUpdateId', 'createOTAUpdateResponse_otaUpdateId' - The OTA update ID.
--
-- 'otaUpdateArn', 'createOTAUpdateResponse_otaUpdateArn' - The OTA update ARN.
--
-- 'httpStatus', 'createOTAUpdateResponse_httpStatus' - The response's http status code.
newCreateOTAUpdateResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateOTAUpdateResponse
newCreateOTAUpdateResponse :: Int -> CreateOTAUpdateResponse
newCreateOTAUpdateResponse Int
pHttpStatus_ =
  CreateOTAUpdateResponse' :: Maybe Text
-> Maybe OTAUpdateStatus
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Int
-> CreateOTAUpdateResponse
CreateOTAUpdateResponse'
    { $sel:awsIotJobId:CreateOTAUpdateResponse' :: Maybe Text
awsIotJobId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:otaUpdateStatus:CreateOTAUpdateResponse' :: Maybe OTAUpdateStatus
otaUpdateStatus = Maybe OTAUpdateStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:awsIotJobArn:CreateOTAUpdateResponse' :: Maybe Text
awsIotJobArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:otaUpdateId:CreateOTAUpdateResponse' :: Maybe Text
otaUpdateId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:otaUpdateArn:CreateOTAUpdateResponse' :: Maybe Text
otaUpdateArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateOTAUpdateResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The IoT job ID associated with the OTA update.
createOTAUpdateResponse_awsIotJobId :: Lens.Lens' CreateOTAUpdateResponse (Prelude.Maybe Prelude.Text)
createOTAUpdateResponse_awsIotJobId :: (Maybe Text -> f (Maybe Text))
-> CreateOTAUpdateResponse -> f CreateOTAUpdateResponse
createOTAUpdateResponse_awsIotJobId = (CreateOTAUpdateResponse -> Maybe Text)
-> (CreateOTAUpdateResponse
    -> Maybe Text -> CreateOTAUpdateResponse)
-> Lens
     CreateOTAUpdateResponse
     CreateOTAUpdateResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateOTAUpdateResponse' {Maybe Text
awsIotJobId :: Maybe Text
$sel:awsIotJobId:CreateOTAUpdateResponse' :: CreateOTAUpdateResponse -> Maybe Text
awsIotJobId} -> Maybe Text
awsIotJobId) (\s :: CreateOTAUpdateResponse
s@CreateOTAUpdateResponse' {} Maybe Text
a -> CreateOTAUpdateResponse
s {$sel:awsIotJobId:CreateOTAUpdateResponse' :: Maybe Text
awsIotJobId = Maybe Text
a} :: CreateOTAUpdateResponse)

-- | The OTA update status.
createOTAUpdateResponse_otaUpdateStatus :: Lens.Lens' CreateOTAUpdateResponse (Prelude.Maybe OTAUpdateStatus)
createOTAUpdateResponse_otaUpdateStatus :: (Maybe OTAUpdateStatus -> f (Maybe OTAUpdateStatus))
-> CreateOTAUpdateResponse -> f CreateOTAUpdateResponse
createOTAUpdateResponse_otaUpdateStatus = (CreateOTAUpdateResponse -> Maybe OTAUpdateStatus)
-> (CreateOTAUpdateResponse
    -> Maybe OTAUpdateStatus -> CreateOTAUpdateResponse)
-> Lens
     CreateOTAUpdateResponse
     CreateOTAUpdateResponse
     (Maybe OTAUpdateStatus)
     (Maybe OTAUpdateStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateOTAUpdateResponse' {Maybe OTAUpdateStatus
otaUpdateStatus :: Maybe OTAUpdateStatus
$sel:otaUpdateStatus:CreateOTAUpdateResponse' :: CreateOTAUpdateResponse -> Maybe OTAUpdateStatus
otaUpdateStatus} -> Maybe OTAUpdateStatus
otaUpdateStatus) (\s :: CreateOTAUpdateResponse
s@CreateOTAUpdateResponse' {} Maybe OTAUpdateStatus
a -> CreateOTAUpdateResponse
s {$sel:otaUpdateStatus:CreateOTAUpdateResponse' :: Maybe OTAUpdateStatus
otaUpdateStatus = Maybe OTAUpdateStatus
a} :: CreateOTAUpdateResponse)

-- | The IoT job ARN associated with the OTA update.
createOTAUpdateResponse_awsIotJobArn :: Lens.Lens' CreateOTAUpdateResponse (Prelude.Maybe Prelude.Text)
createOTAUpdateResponse_awsIotJobArn :: (Maybe Text -> f (Maybe Text))
-> CreateOTAUpdateResponse -> f CreateOTAUpdateResponse
createOTAUpdateResponse_awsIotJobArn = (CreateOTAUpdateResponse -> Maybe Text)
-> (CreateOTAUpdateResponse
    -> Maybe Text -> CreateOTAUpdateResponse)
-> Lens
     CreateOTAUpdateResponse
     CreateOTAUpdateResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateOTAUpdateResponse' {Maybe Text
awsIotJobArn :: Maybe Text
$sel:awsIotJobArn:CreateOTAUpdateResponse' :: CreateOTAUpdateResponse -> Maybe Text
awsIotJobArn} -> Maybe Text
awsIotJobArn) (\s :: CreateOTAUpdateResponse
s@CreateOTAUpdateResponse' {} Maybe Text
a -> CreateOTAUpdateResponse
s {$sel:awsIotJobArn:CreateOTAUpdateResponse' :: Maybe Text
awsIotJobArn = Maybe Text
a} :: CreateOTAUpdateResponse)

-- | The OTA update ID.
createOTAUpdateResponse_otaUpdateId :: Lens.Lens' CreateOTAUpdateResponse (Prelude.Maybe Prelude.Text)
createOTAUpdateResponse_otaUpdateId :: (Maybe Text -> f (Maybe Text))
-> CreateOTAUpdateResponse -> f CreateOTAUpdateResponse
createOTAUpdateResponse_otaUpdateId = (CreateOTAUpdateResponse -> Maybe Text)
-> (CreateOTAUpdateResponse
    -> Maybe Text -> CreateOTAUpdateResponse)
-> Lens
     CreateOTAUpdateResponse
     CreateOTAUpdateResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateOTAUpdateResponse' {Maybe Text
otaUpdateId :: Maybe Text
$sel:otaUpdateId:CreateOTAUpdateResponse' :: CreateOTAUpdateResponse -> Maybe Text
otaUpdateId} -> Maybe Text
otaUpdateId) (\s :: CreateOTAUpdateResponse
s@CreateOTAUpdateResponse' {} Maybe Text
a -> CreateOTAUpdateResponse
s {$sel:otaUpdateId:CreateOTAUpdateResponse' :: Maybe Text
otaUpdateId = Maybe Text
a} :: CreateOTAUpdateResponse)

-- | The OTA update ARN.
createOTAUpdateResponse_otaUpdateArn :: Lens.Lens' CreateOTAUpdateResponse (Prelude.Maybe Prelude.Text)
createOTAUpdateResponse_otaUpdateArn :: (Maybe Text -> f (Maybe Text))
-> CreateOTAUpdateResponse -> f CreateOTAUpdateResponse
createOTAUpdateResponse_otaUpdateArn = (CreateOTAUpdateResponse -> Maybe Text)
-> (CreateOTAUpdateResponse
    -> Maybe Text -> CreateOTAUpdateResponse)
-> Lens
     CreateOTAUpdateResponse
     CreateOTAUpdateResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateOTAUpdateResponse' {Maybe Text
otaUpdateArn :: Maybe Text
$sel:otaUpdateArn:CreateOTAUpdateResponse' :: CreateOTAUpdateResponse -> Maybe Text
otaUpdateArn} -> Maybe Text
otaUpdateArn) (\s :: CreateOTAUpdateResponse
s@CreateOTAUpdateResponse' {} Maybe Text
a -> CreateOTAUpdateResponse
s {$sel:otaUpdateArn:CreateOTAUpdateResponse' :: Maybe Text
otaUpdateArn = Maybe Text
a} :: CreateOTAUpdateResponse)

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

instance Prelude.NFData CreateOTAUpdateResponse