{-# 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.GreengrassV2.CreateDeployment
-- 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 continuous deployment for a target, which is a Greengrass core
-- device or group of core devices. When you add a new core device to a
-- group of core devices that has a deployment, IoT Greengrass deploys that
-- group\'s deployment to the new device.
--
-- You can define one deployment for each target. When you create a new
-- deployment for a target that has an existing deployment, you replace the
-- previous deployment. IoT Greengrass applies the new deployment to the
-- target devices.
--
-- Every deployment has a revision number that indicates how many
-- deployment revisions you define for a target. Use this operation to
-- create a new revision of an existing deployment. This operation returns
-- the revision number of the new deployment when you create it.
--
-- For more information, see the
-- <https://docs.aws.amazon.com/greengrass/v2/developerguide/create-deployments.html Create deployments>
-- in the /IoT Greengrass V2 Developer Guide/.
module Amazonka.GreengrassV2.CreateDeployment
  ( -- * Creating a Request
    CreateDeployment (..),
    newCreateDeployment,

    -- * Request Lenses
    createDeployment_components,
    createDeployment_clientToken,
    createDeployment_deploymentPolicies,
    createDeployment_iotJobConfiguration,
    createDeployment_deploymentName,
    createDeployment_tags,
    createDeployment_targetArn,

    -- * Destructuring the Response
    CreateDeploymentResponse (..),
    newCreateDeploymentResponse,

    -- * Response Lenses
    createDeploymentResponse_deploymentId,
    createDeploymentResponse_iotJobId,
    createDeploymentResponse_iotJobArn,
    createDeploymentResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.GreengrassV2.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:/ 'newCreateDeployment' smart constructor.
data CreateDeployment = CreateDeployment'
  { -- | The components to deploy. This is a dictionary, where each key is the
    -- name of a component, and each key\'s value is the version and
    -- configuration to deploy for that component.
    CreateDeployment
-> Maybe (HashMap Text ComponentDeploymentSpecification)
components :: Prelude.Maybe (Prelude.HashMap Prelude.Text ComponentDeploymentSpecification),
    -- | A unique, case-sensitive identifier that you can provide to ensure that
    -- the request is idempotent. Idempotency means that the request is
    -- successfully processed only once, even if you send the request multiple
    -- times. When a request succeeds, and you specify the same client token
    -- for subsequent successful requests, the IoT Greengrass V2 service
    -- returns the successful response that it caches from the previous
    -- request. IoT Greengrass V2 caches successful responses for idempotent
    -- requests for up to 8 hours.
    CreateDeployment -> Maybe Text
clientToken :: Prelude.Maybe Prelude.Text,
    -- | The deployment policies for the deployment. These policies define how
    -- the deployment updates components and handles failure.
    CreateDeployment -> Maybe DeploymentPolicies
deploymentPolicies :: Prelude.Maybe DeploymentPolicies,
    -- | The job configuration for the deployment configuration. The job
    -- configuration specifies the rollout, timeout, and stop configurations
    -- for the deployment configuration.
    CreateDeployment -> Maybe DeploymentIoTJobConfiguration
iotJobConfiguration :: Prelude.Maybe DeploymentIoTJobConfiguration,
    -- | The name of the deployment.
    CreateDeployment -> Maybe Text
deploymentName :: Prelude.Maybe Prelude.Text,
    -- | A list of key-value pairs that contain metadata for the resource. For
    -- more information, see
    -- <https://docs.aws.amazon.com/greengrass/v2/developerguide/tag-resources.html Tag your resources>
    -- in the /IoT Greengrass V2 Developer Guide/.
    CreateDeployment -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The
    -- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html ARN>
    -- of the target IoT thing or thing group.
    CreateDeployment -> Text
targetArn :: Prelude.Text
  }
  deriving (CreateDeployment -> CreateDeployment -> Bool
(CreateDeployment -> CreateDeployment -> Bool)
-> (CreateDeployment -> CreateDeployment -> Bool)
-> Eq CreateDeployment
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateDeployment -> CreateDeployment -> Bool
$c/= :: CreateDeployment -> CreateDeployment -> Bool
== :: CreateDeployment -> CreateDeployment -> Bool
$c== :: CreateDeployment -> CreateDeployment -> Bool
Prelude.Eq, ReadPrec [CreateDeployment]
ReadPrec CreateDeployment
Int -> ReadS CreateDeployment
ReadS [CreateDeployment]
(Int -> ReadS CreateDeployment)
-> ReadS [CreateDeployment]
-> ReadPrec CreateDeployment
-> ReadPrec [CreateDeployment]
-> Read CreateDeployment
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateDeployment]
$creadListPrec :: ReadPrec [CreateDeployment]
readPrec :: ReadPrec CreateDeployment
$creadPrec :: ReadPrec CreateDeployment
readList :: ReadS [CreateDeployment]
$creadList :: ReadS [CreateDeployment]
readsPrec :: Int -> ReadS CreateDeployment
$creadsPrec :: Int -> ReadS CreateDeployment
Prelude.Read, Int -> CreateDeployment -> ShowS
[CreateDeployment] -> ShowS
CreateDeployment -> String
(Int -> CreateDeployment -> ShowS)
-> (CreateDeployment -> String)
-> ([CreateDeployment] -> ShowS)
-> Show CreateDeployment
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateDeployment] -> ShowS
$cshowList :: [CreateDeployment] -> ShowS
show :: CreateDeployment -> String
$cshow :: CreateDeployment -> String
showsPrec :: Int -> CreateDeployment -> ShowS
$cshowsPrec :: Int -> CreateDeployment -> ShowS
Prelude.Show, (forall x. CreateDeployment -> Rep CreateDeployment x)
-> (forall x. Rep CreateDeployment x -> CreateDeployment)
-> Generic CreateDeployment
forall x. Rep CreateDeployment x -> CreateDeployment
forall x. CreateDeployment -> Rep CreateDeployment x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateDeployment x -> CreateDeployment
$cfrom :: forall x. CreateDeployment -> Rep CreateDeployment x
Prelude.Generic)

-- |
-- Create a value of 'CreateDeployment' 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:
--
-- 'components', 'createDeployment_components' - The components to deploy. This is a dictionary, where each key is the
-- name of a component, and each key\'s value is the version and
-- configuration to deploy for that component.
--
-- 'clientToken', 'createDeployment_clientToken' - A unique, case-sensitive identifier that you can provide to ensure that
-- the request is idempotent. Idempotency means that the request is
-- successfully processed only once, even if you send the request multiple
-- times. When a request succeeds, and you specify the same client token
-- for subsequent successful requests, the IoT Greengrass V2 service
-- returns the successful response that it caches from the previous
-- request. IoT Greengrass V2 caches successful responses for idempotent
-- requests for up to 8 hours.
--
-- 'deploymentPolicies', 'createDeployment_deploymentPolicies' - The deployment policies for the deployment. These policies define how
-- the deployment updates components and handles failure.
--
-- 'iotJobConfiguration', 'createDeployment_iotJobConfiguration' - The job configuration for the deployment configuration. The job
-- configuration specifies the rollout, timeout, and stop configurations
-- for the deployment configuration.
--
-- 'deploymentName', 'createDeployment_deploymentName' - The name of the deployment.
--
-- 'tags', 'createDeployment_tags' - A list of key-value pairs that contain metadata for the resource. For
-- more information, see
-- <https://docs.aws.amazon.com/greengrass/v2/developerguide/tag-resources.html Tag your resources>
-- in the /IoT Greengrass V2 Developer Guide/.
--
-- 'targetArn', 'createDeployment_targetArn' - The
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html ARN>
-- of the target IoT thing or thing group.
newCreateDeployment ::
  -- | 'targetArn'
  Prelude.Text ->
  CreateDeployment
newCreateDeployment :: Text -> CreateDeployment
newCreateDeployment Text
pTargetArn_ =
  CreateDeployment' :: Maybe (HashMap Text ComponentDeploymentSpecification)
-> Maybe Text
-> Maybe DeploymentPolicies
-> Maybe DeploymentIoTJobConfiguration
-> Maybe Text
-> Maybe (HashMap Text Text)
-> Text
-> CreateDeployment
CreateDeployment'
    { $sel:components:CreateDeployment' :: Maybe (HashMap Text ComponentDeploymentSpecification)
components = Maybe (HashMap Text ComponentDeploymentSpecification)
forall a. Maybe a
Prelude.Nothing,
      $sel:clientToken:CreateDeployment' :: Maybe Text
clientToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:deploymentPolicies:CreateDeployment' :: Maybe DeploymentPolicies
deploymentPolicies = Maybe DeploymentPolicies
forall a. Maybe a
Prelude.Nothing,
      $sel:iotJobConfiguration:CreateDeployment' :: Maybe DeploymentIoTJobConfiguration
iotJobConfiguration = Maybe DeploymentIoTJobConfiguration
forall a. Maybe a
Prelude.Nothing,
      $sel:deploymentName:CreateDeployment' :: Maybe Text
deploymentName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:tags:CreateDeployment' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:targetArn:CreateDeployment' :: Text
targetArn = Text
pTargetArn_
    }

-- | The components to deploy. This is a dictionary, where each key is the
-- name of a component, and each key\'s value is the version and
-- configuration to deploy for that component.
createDeployment_components :: Lens.Lens' CreateDeployment (Prelude.Maybe (Prelude.HashMap Prelude.Text ComponentDeploymentSpecification))
createDeployment_components :: (Maybe (HashMap Text ComponentDeploymentSpecification)
 -> f (Maybe (HashMap Text ComponentDeploymentSpecification)))
-> CreateDeployment -> f CreateDeployment
createDeployment_components = (CreateDeployment
 -> Maybe (HashMap Text ComponentDeploymentSpecification))
-> (CreateDeployment
    -> Maybe (HashMap Text ComponentDeploymentSpecification)
    -> CreateDeployment)
-> Lens
     CreateDeployment
     CreateDeployment
     (Maybe (HashMap Text ComponentDeploymentSpecification))
     (Maybe (HashMap Text ComponentDeploymentSpecification))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDeployment' {Maybe (HashMap Text ComponentDeploymentSpecification)
components :: Maybe (HashMap Text ComponentDeploymentSpecification)
$sel:components:CreateDeployment' :: CreateDeployment
-> Maybe (HashMap Text ComponentDeploymentSpecification)
components} -> Maybe (HashMap Text ComponentDeploymentSpecification)
components) (\s :: CreateDeployment
s@CreateDeployment' {} Maybe (HashMap Text ComponentDeploymentSpecification)
a -> CreateDeployment
s {$sel:components:CreateDeployment' :: Maybe (HashMap Text ComponentDeploymentSpecification)
components = Maybe (HashMap Text ComponentDeploymentSpecification)
a} :: CreateDeployment) ((Maybe (HashMap Text ComponentDeploymentSpecification)
  -> f (Maybe (HashMap Text ComponentDeploymentSpecification)))
 -> CreateDeployment -> f CreateDeployment)
-> ((Maybe (HashMap Text ComponentDeploymentSpecification)
     -> f (Maybe (HashMap Text ComponentDeploymentSpecification)))
    -> Maybe (HashMap Text ComponentDeploymentSpecification)
    -> f (Maybe (HashMap Text ComponentDeploymentSpecification)))
-> (Maybe (HashMap Text ComponentDeploymentSpecification)
    -> f (Maybe (HashMap Text ComponentDeploymentSpecification)))
-> CreateDeployment
-> f CreateDeployment
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text ComponentDeploymentSpecification)
  (HashMap Text ComponentDeploymentSpecification)
  (HashMap Text ComponentDeploymentSpecification)
  (HashMap Text ComponentDeploymentSpecification)
-> Iso
     (Maybe (HashMap Text ComponentDeploymentSpecification))
     (Maybe (HashMap Text ComponentDeploymentSpecification))
     (Maybe (HashMap Text ComponentDeploymentSpecification))
     (Maybe (HashMap Text ComponentDeploymentSpecification))
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 ComponentDeploymentSpecification)
  (HashMap Text ComponentDeploymentSpecification)
  (HashMap Text ComponentDeploymentSpecification)
  (HashMap Text ComponentDeploymentSpecification)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A unique, case-sensitive identifier that you can provide to ensure that
-- the request is idempotent. Idempotency means that the request is
-- successfully processed only once, even if you send the request multiple
-- times. When a request succeeds, and you specify the same client token
-- for subsequent successful requests, the IoT Greengrass V2 service
-- returns the successful response that it caches from the previous
-- request. IoT Greengrass V2 caches successful responses for idempotent
-- requests for up to 8 hours.
createDeployment_clientToken :: Lens.Lens' CreateDeployment (Prelude.Maybe Prelude.Text)
createDeployment_clientToken :: (Maybe Text -> f (Maybe Text))
-> CreateDeployment -> f CreateDeployment
createDeployment_clientToken = (CreateDeployment -> Maybe Text)
-> (CreateDeployment -> Maybe Text -> CreateDeployment)
-> Lens CreateDeployment CreateDeployment (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDeployment' {Maybe Text
clientToken :: Maybe Text
$sel:clientToken:CreateDeployment' :: CreateDeployment -> Maybe Text
clientToken} -> Maybe Text
clientToken) (\s :: CreateDeployment
s@CreateDeployment' {} Maybe Text
a -> CreateDeployment
s {$sel:clientToken:CreateDeployment' :: Maybe Text
clientToken = Maybe Text
a} :: CreateDeployment)

-- | The deployment policies for the deployment. These policies define how
-- the deployment updates components and handles failure.
createDeployment_deploymentPolicies :: Lens.Lens' CreateDeployment (Prelude.Maybe DeploymentPolicies)
createDeployment_deploymentPolicies :: (Maybe DeploymentPolicies -> f (Maybe DeploymentPolicies))
-> CreateDeployment -> f CreateDeployment
createDeployment_deploymentPolicies = (CreateDeployment -> Maybe DeploymentPolicies)
-> (CreateDeployment
    -> Maybe DeploymentPolicies -> CreateDeployment)
-> Lens
     CreateDeployment
     CreateDeployment
     (Maybe DeploymentPolicies)
     (Maybe DeploymentPolicies)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDeployment' {Maybe DeploymentPolicies
deploymentPolicies :: Maybe DeploymentPolicies
$sel:deploymentPolicies:CreateDeployment' :: CreateDeployment -> Maybe DeploymentPolicies
deploymentPolicies} -> Maybe DeploymentPolicies
deploymentPolicies) (\s :: CreateDeployment
s@CreateDeployment' {} Maybe DeploymentPolicies
a -> CreateDeployment
s {$sel:deploymentPolicies:CreateDeployment' :: Maybe DeploymentPolicies
deploymentPolicies = Maybe DeploymentPolicies
a} :: CreateDeployment)

-- | The job configuration for the deployment configuration. The job
-- configuration specifies the rollout, timeout, and stop configurations
-- for the deployment configuration.
createDeployment_iotJobConfiguration :: Lens.Lens' CreateDeployment (Prelude.Maybe DeploymentIoTJobConfiguration)
createDeployment_iotJobConfiguration :: (Maybe DeploymentIoTJobConfiguration
 -> f (Maybe DeploymentIoTJobConfiguration))
-> CreateDeployment -> f CreateDeployment
createDeployment_iotJobConfiguration = (CreateDeployment -> Maybe DeploymentIoTJobConfiguration)
-> (CreateDeployment
    -> Maybe DeploymentIoTJobConfiguration -> CreateDeployment)
-> Lens
     CreateDeployment
     CreateDeployment
     (Maybe DeploymentIoTJobConfiguration)
     (Maybe DeploymentIoTJobConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDeployment' {Maybe DeploymentIoTJobConfiguration
iotJobConfiguration :: Maybe DeploymentIoTJobConfiguration
$sel:iotJobConfiguration:CreateDeployment' :: CreateDeployment -> Maybe DeploymentIoTJobConfiguration
iotJobConfiguration} -> Maybe DeploymentIoTJobConfiguration
iotJobConfiguration) (\s :: CreateDeployment
s@CreateDeployment' {} Maybe DeploymentIoTJobConfiguration
a -> CreateDeployment
s {$sel:iotJobConfiguration:CreateDeployment' :: Maybe DeploymentIoTJobConfiguration
iotJobConfiguration = Maybe DeploymentIoTJobConfiguration
a} :: CreateDeployment)

-- | The name of the deployment.
createDeployment_deploymentName :: Lens.Lens' CreateDeployment (Prelude.Maybe Prelude.Text)
createDeployment_deploymentName :: (Maybe Text -> f (Maybe Text))
-> CreateDeployment -> f CreateDeployment
createDeployment_deploymentName = (CreateDeployment -> Maybe Text)
-> (CreateDeployment -> Maybe Text -> CreateDeployment)
-> Lens CreateDeployment CreateDeployment (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDeployment' {Maybe Text
deploymentName :: Maybe Text
$sel:deploymentName:CreateDeployment' :: CreateDeployment -> Maybe Text
deploymentName} -> Maybe Text
deploymentName) (\s :: CreateDeployment
s@CreateDeployment' {} Maybe Text
a -> CreateDeployment
s {$sel:deploymentName:CreateDeployment' :: Maybe Text
deploymentName = Maybe Text
a} :: CreateDeployment)

-- | A list of key-value pairs that contain metadata for the resource. For
-- more information, see
-- <https://docs.aws.amazon.com/greengrass/v2/developerguide/tag-resources.html Tag your resources>
-- in the /IoT Greengrass V2 Developer Guide/.
createDeployment_tags :: Lens.Lens' CreateDeployment (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
createDeployment_tags :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateDeployment -> f CreateDeployment
createDeployment_tags = (CreateDeployment -> Maybe (HashMap Text Text))
-> (CreateDeployment
    -> Maybe (HashMap Text Text) -> CreateDeployment)
-> Lens
     CreateDeployment
     CreateDeployment
     (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 (\CreateDeployment' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:CreateDeployment' :: CreateDeployment -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: CreateDeployment
s@CreateDeployment' {} Maybe (HashMap Text Text)
a -> CreateDeployment
s {$sel:tags:CreateDeployment' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
a} :: CreateDeployment) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> CreateDeployment -> f CreateDeployment)
-> ((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)))
-> CreateDeployment
-> f CreateDeployment
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

-- | The
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html ARN>
-- of the target IoT thing or thing group.
createDeployment_targetArn :: Lens.Lens' CreateDeployment Prelude.Text
createDeployment_targetArn :: (Text -> f Text) -> CreateDeployment -> f CreateDeployment
createDeployment_targetArn = (CreateDeployment -> Text)
-> (CreateDeployment -> Text -> CreateDeployment)
-> Lens CreateDeployment CreateDeployment Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDeployment' {Text
targetArn :: Text
$sel:targetArn:CreateDeployment' :: CreateDeployment -> Text
targetArn} -> Text
targetArn) (\s :: CreateDeployment
s@CreateDeployment' {} Text
a -> CreateDeployment
s {$sel:targetArn:CreateDeployment' :: Text
targetArn = Text
a} :: CreateDeployment)

instance Core.AWSRequest CreateDeployment where
  type
    AWSResponse CreateDeployment =
      CreateDeploymentResponse
  request :: CreateDeployment -> Request CreateDeployment
request = Service -> CreateDeployment -> Request CreateDeployment
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateDeployment
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateDeployment)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreateDeployment))
-> Logger
-> Service
-> Proxy CreateDeployment
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateDeployment)))
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 -> CreateDeploymentResponse
CreateDeploymentResponse'
            (Maybe Text
 -> Maybe Text -> Maybe Text -> Int -> CreateDeploymentResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Text -> Maybe Text -> Int -> CreateDeploymentResponse)
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
"deploymentId")
            Either
  String
  (Maybe Text -> Maybe Text -> Int -> CreateDeploymentResponse)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> Int -> CreateDeploymentResponse)
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 (Maybe Text -> Int -> CreateDeploymentResponse)
-> Either String (Maybe Text)
-> Either String (Int -> CreateDeploymentResponse)
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 (Int -> CreateDeploymentResponse)
-> Either String Int -> Either String CreateDeploymentResponse
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 CreateDeployment

instance Prelude.NFData CreateDeployment

instance Core.ToHeaders CreateDeployment where
  toHeaders :: CreateDeployment -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateDeployment -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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 CreateDeployment where
  toJSON :: CreateDeployment -> Value
toJSON CreateDeployment' {Maybe Text
Maybe (HashMap Text Text)
Maybe (HashMap Text ComponentDeploymentSpecification)
Maybe DeploymentPolicies
Maybe DeploymentIoTJobConfiguration
Text
targetArn :: Text
tags :: Maybe (HashMap Text Text)
deploymentName :: Maybe Text
iotJobConfiguration :: Maybe DeploymentIoTJobConfiguration
deploymentPolicies :: Maybe DeploymentPolicies
clientToken :: Maybe Text
components :: Maybe (HashMap Text ComponentDeploymentSpecification)
$sel:targetArn:CreateDeployment' :: CreateDeployment -> Text
$sel:tags:CreateDeployment' :: CreateDeployment -> Maybe (HashMap Text Text)
$sel:deploymentName:CreateDeployment' :: CreateDeployment -> Maybe Text
$sel:iotJobConfiguration:CreateDeployment' :: CreateDeployment -> Maybe DeploymentIoTJobConfiguration
$sel:deploymentPolicies:CreateDeployment' :: CreateDeployment -> Maybe DeploymentPolicies
$sel:clientToken:CreateDeployment' :: CreateDeployment -> Maybe Text
$sel:components:CreateDeployment' :: CreateDeployment
-> Maybe (HashMap Text ComponentDeploymentSpecification)
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"components" Text -> HashMap Text ComponentDeploymentSpecification -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HashMap Text ComponentDeploymentSpecification -> Pair)
-> Maybe (HashMap Text ComponentDeploymentSpecification)
-> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text ComponentDeploymentSpecification)
components,
            (Text
"clientToken" 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
clientToken,
            (Text
"deploymentPolicies" Text -> DeploymentPolicies -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (DeploymentPolicies -> Pair)
-> Maybe DeploymentPolicies -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe DeploymentPolicies
deploymentPolicies,
            (Text
"iotJobConfiguration" Text -> DeploymentIoTJobConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (DeploymentIoTJobConfiguration -> Pair)
-> Maybe DeploymentIoTJobConfiguration -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe DeploymentIoTJobConfiguration
iotJobConfiguration,
            (Text
"deploymentName" 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
deploymentName,
            (Text
"tags" 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)
tags,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"targetArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
targetArn)
          ]
      )

instance Core.ToPath CreateDeployment where
  toPath :: CreateDeployment -> ByteString
toPath = ByteString -> CreateDeployment -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/greengrass/v2/deployments"

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

-- | /See:/ 'newCreateDeploymentResponse' smart constructor.
data CreateDeploymentResponse = CreateDeploymentResponse'
  { -- | The ID of the deployment.
    CreateDeploymentResponse -> Maybe Text
deploymentId :: Prelude.Maybe Prelude.Text,
    -- | The ID of the IoT job that applies the deployment to target devices.
    CreateDeploymentResponse -> Maybe Text
iotJobId :: Prelude.Maybe Prelude.Text,
    -- | The
    -- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html ARN>
    -- of the IoT job that applies the deployment to target devices.
    CreateDeploymentResponse -> Maybe Text
iotJobArn :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    CreateDeploymentResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateDeploymentResponse -> CreateDeploymentResponse -> Bool
(CreateDeploymentResponse -> CreateDeploymentResponse -> Bool)
-> (CreateDeploymentResponse -> CreateDeploymentResponse -> Bool)
-> Eq CreateDeploymentResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateDeploymentResponse -> CreateDeploymentResponse -> Bool
$c/= :: CreateDeploymentResponse -> CreateDeploymentResponse -> Bool
== :: CreateDeploymentResponse -> CreateDeploymentResponse -> Bool
$c== :: CreateDeploymentResponse -> CreateDeploymentResponse -> Bool
Prelude.Eq, ReadPrec [CreateDeploymentResponse]
ReadPrec CreateDeploymentResponse
Int -> ReadS CreateDeploymentResponse
ReadS [CreateDeploymentResponse]
(Int -> ReadS CreateDeploymentResponse)
-> ReadS [CreateDeploymentResponse]
-> ReadPrec CreateDeploymentResponse
-> ReadPrec [CreateDeploymentResponse]
-> Read CreateDeploymentResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateDeploymentResponse]
$creadListPrec :: ReadPrec [CreateDeploymentResponse]
readPrec :: ReadPrec CreateDeploymentResponse
$creadPrec :: ReadPrec CreateDeploymentResponse
readList :: ReadS [CreateDeploymentResponse]
$creadList :: ReadS [CreateDeploymentResponse]
readsPrec :: Int -> ReadS CreateDeploymentResponse
$creadsPrec :: Int -> ReadS CreateDeploymentResponse
Prelude.Read, Int -> CreateDeploymentResponse -> ShowS
[CreateDeploymentResponse] -> ShowS
CreateDeploymentResponse -> String
(Int -> CreateDeploymentResponse -> ShowS)
-> (CreateDeploymentResponse -> String)
-> ([CreateDeploymentResponse] -> ShowS)
-> Show CreateDeploymentResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateDeploymentResponse] -> ShowS
$cshowList :: [CreateDeploymentResponse] -> ShowS
show :: CreateDeploymentResponse -> String
$cshow :: CreateDeploymentResponse -> String
showsPrec :: Int -> CreateDeploymentResponse -> ShowS
$cshowsPrec :: Int -> CreateDeploymentResponse -> ShowS
Prelude.Show, (forall x.
 CreateDeploymentResponse -> Rep CreateDeploymentResponse x)
-> (forall x.
    Rep CreateDeploymentResponse x -> CreateDeploymentResponse)
-> Generic CreateDeploymentResponse
forall x.
Rep CreateDeploymentResponse x -> CreateDeploymentResponse
forall x.
CreateDeploymentResponse -> Rep CreateDeploymentResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateDeploymentResponse x -> CreateDeploymentResponse
$cfrom :: forall x.
CreateDeploymentResponse -> Rep CreateDeploymentResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateDeploymentResponse' 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:
--
-- 'deploymentId', 'createDeploymentResponse_deploymentId' - The ID of the deployment.
--
-- 'iotJobId', 'createDeploymentResponse_iotJobId' - The ID of the IoT job that applies the deployment to target devices.
--
-- 'iotJobArn', 'createDeploymentResponse_iotJobArn' - The
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html ARN>
-- of the IoT job that applies the deployment to target devices.
--
-- 'httpStatus', 'createDeploymentResponse_httpStatus' - The response's http status code.
newCreateDeploymentResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateDeploymentResponse
newCreateDeploymentResponse :: Int -> CreateDeploymentResponse
newCreateDeploymentResponse Int
pHttpStatus_ =
  CreateDeploymentResponse' :: Maybe Text
-> Maybe Text -> Maybe Text -> Int -> CreateDeploymentResponse
CreateDeploymentResponse'
    { $sel:deploymentId:CreateDeploymentResponse' :: Maybe Text
deploymentId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:iotJobId:CreateDeploymentResponse' :: Maybe Text
iotJobId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:iotJobArn:CreateDeploymentResponse' :: Maybe Text
iotJobArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateDeploymentResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The ID of the deployment.
createDeploymentResponse_deploymentId :: Lens.Lens' CreateDeploymentResponse (Prelude.Maybe Prelude.Text)
createDeploymentResponse_deploymentId :: (Maybe Text -> f (Maybe Text))
-> CreateDeploymentResponse -> f CreateDeploymentResponse
createDeploymentResponse_deploymentId = (CreateDeploymentResponse -> Maybe Text)
-> (CreateDeploymentResponse
    -> Maybe Text -> CreateDeploymentResponse)
-> Lens
     CreateDeploymentResponse
     CreateDeploymentResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDeploymentResponse' {Maybe Text
deploymentId :: Maybe Text
$sel:deploymentId:CreateDeploymentResponse' :: CreateDeploymentResponse -> Maybe Text
deploymentId} -> Maybe Text
deploymentId) (\s :: CreateDeploymentResponse
s@CreateDeploymentResponse' {} Maybe Text
a -> CreateDeploymentResponse
s {$sel:deploymentId:CreateDeploymentResponse' :: Maybe Text
deploymentId = Maybe Text
a} :: CreateDeploymentResponse)

-- | The ID of the IoT job that applies the deployment to target devices.
createDeploymentResponse_iotJobId :: Lens.Lens' CreateDeploymentResponse (Prelude.Maybe Prelude.Text)
createDeploymentResponse_iotJobId :: (Maybe Text -> f (Maybe Text))
-> CreateDeploymentResponse -> f CreateDeploymentResponse
createDeploymentResponse_iotJobId = (CreateDeploymentResponse -> Maybe Text)
-> (CreateDeploymentResponse
    -> Maybe Text -> CreateDeploymentResponse)
-> Lens
     CreateDeploymentResponse
     CreateDeploymentResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDeploymentResponse' {Maybe Text
iotJobId :: Maybe Text
$sel:iotJobId:CreateDeploymentResponse' :: CreateDeploymentResponse -> Maybe Text
iotJobId} -> Maybe Text
iotJobId) (\s :: CreateDeploymentResponse
s@CreateDeploymentResponse' {} Maybe Text
a -> CreateDeploymentResponse
s {$sel:iotJobId:CreateDeploymentResponse' :: Maybe Text
iotJobId = Maybe Text
a} :: CreateDeploymentResponse)

-- | The
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html ARN>
-- of the IoT job that applies the deployment to target devices.
createDeploymentResponse_iotJobArn :: Lens.Lens' CreateDeploymentResponse (Prelude.Maybe Prelude.Text)
createDeploymentResponse_iotJobArn :: (Maybe Text -> f (Maybe Text))
-> CreateDeploymentResponse -> f CreateDeploymentResponse
createDeploymentResponse_iotJobArn = (CreateDeploymentResponse -> Maybe Text)
-> (CreateDeploymentResponse
    -> Maybe Text -> CreateDeploymentResponse)
-> Lens
     CreateDeploymentResponse
     CreateDeploymentResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDeploymentResponse' {Maybe Text
iotJobArn :: Maybe Text
$sel:iotJobArn:CreateDeploymentResponse' :: CreateDeploymentResponse -> Maybe Text
iotJobArn} -> Maybe Text
iotJobArn) (\s :: CreateDeploymentResponse
s@CreateDeploymentResponse' {} Maybe Text
a -> CreateDeploymentResponse
s {$sel:iotJobArn:CreateDeploymentResponse' :: Maybe Text
iotJobArn = Maybe Text
a} :: CreateDeploymentResponse)

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

instance Prelude.NFData CreateDeploymentResponse