{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# 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.Types.Deployment
-- 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)
module Amazonka.GreengrassV2.Types.Deployment where

import qualified Amazonka.Core as Core
import Amazonka.GreengrassV2.Types.DeploymentStatus
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains information about a deployment.
--
-- /See:/ 'newDeployment' smart constructor.
data Deployment = Deployment'
  { -- | The
    -- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html ARN>
    -- of the target IoT thing or thing group.
    Deployment -> Maybe Text
targetArn :: Prelude.Maybe Prelude.Text,
    -- | The ID of the deployment.
    Deployment -> Maybe Text
deploymentId :: Prelude.Maybe Prelude.Text,
    -- | The time at which the deployment was created, expressed in ISO 8601
    -- format.
    Deployment -> Maybe POSIX
creationTimestamp :: Prelude.Maybe Core.POSIX,
    -- | The status of the deployment.
    Deployment -> Maybe DeploymentStatus
deploymentStatus :: Prelude.Maybe DeploymentStatus,
    -- | Whether or not the deployment is the latest revision for its target.
    Deployment -> Maybe Bool
isLatestForTarget :: Prelude.Maybe Prelude.Bool,
    -- | The revision number of the deployment.
    Deployment -> Maybe Text
revisionId :: Prelude.Maybe Prelude.Text,
    -- | The name of the deployment.
    Deployment -> Maybe Text
deploymentName :: Prelude.Maybe Prelude.Text
  }
  deriving (Deployment -> Deployment -> Bool
(Deployment -> Deployment -> Bool)
-> (Deployment -> Deployment -> Bool) -> Eq Deployment
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Deployment -> Deployment -> Bool
$c/= :: Deployment -> Deployment -> Bool
== :: Deployment -> Deployment -> Bool
$c== :: Deployment -> Deployment -> Bool
Prelude.Eq, ReadPrec [Deployment]
ReadPrec Deployment
Int -> ReadS Deployment
ReadS [Deployment]
(Int -> ReadS Deployment)
-> ReadS [Deployment]
-> ReadPrec Deployment
-> ReadPrec [Deployment]
-> Read Deployment
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Deployment]
$creadListPrec :: ReadPrec [Deployment]
readPrec :: ReadPrec Deployment
$creadPrec :: ReadPrec Deployment
readList :: ReadS [Deployment]
$creadList :: ReadS [Deployment]
readsPrec :: Int -> ReadS Deployment
$creadsPrec :: Int -> ReadS Deployment
Prelude.Read, Int -> Deployment -> ShowS
[Deployment] -> ShowS
Deployment -> String
(Int -> Deployment -> ShowS)
-> (Deployment -> String)
-> ([Deployment] -> ShowS)
-> Show Deployment
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Deployment] -> ShowS
$cshowList :: [Deployment] -> ShowS
show :: Deployment -> String
$cshow :: Deployment -> String
showsPrec :: Int -> Deployment -> ShowS
$cshowsPrec :: Int -> Deployment -> ShowS
Prelude.Show, (forall x. Deployment -> Rep Deployment x)
-> (forall x. Rep Deployment x -> Deployment) -> Generic Deployment
forall x. Rep Deployment x -> Deployment
forall x. Deployment -> Rep Deployment x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Deployment x -> Deployment
$cfrom :: forall x. Deployment -> Rep Deployment x
Prelude.Generic)

-- |
-- Create a value of 'Deployment' 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:
--
-- 'targetArn', 'deployment_targetArn' - The
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html ARN>
-- of the target IoT thing or thing group.
--
-- 'deploymentId', 'deployment_deploymentId' - The ID of the deployment.
--
-- 'creationTimestamp', 'deployment_creationTimestamp' - The time at which the deployment was created, expressed in ISO 8601
-- format.
--
-- 'deploymentStatus', 'deployment_deploymentStatus' - The status of the deployment.
--
-- 'isLatestForTarget', 'deployment_isLatestForTarget' - Whether or not the deployment is the latest revision for its target.
--
-- 'revisionId', 'deployment_revisionId' - The revision number of the deployment.
--
-- 'deploymentName', 'deployment_deploymentName' - The name of the deployment.
newDeployment ::
  Deployment
newDeployment :: Deployment
newDeployment =
  Deployment' :: Maybe Text
-> Maybe Text
-> Maybe POSIX
-> Maybe DeploymentStatus
-> Maybe Bool
-> Maybe Text
-> Maybe Text
-> Deployment
Deployment'
    { $sel:targetArn:Deployment' :: Maybe Text
targetArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:deploymentId:Deployment' :: Maybe Text
deploymentId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:creationTimestamp:Deployment' :: Maybe POSIX
creationTimestamp = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:deploymentStatus:Deployment' :: Maybe DeploymentStatus
deploymentStatus = Maybe DeploymentStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:isLatestForTarget:Deployment' :: Maybe Bool
isLatestForTarget = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:revisionId:Deployment' :: Maybe Text
revisionId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:deploymentName:Deployment' :: Maybe Text
deploymentName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

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

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

-- | The time at which the deployment was created, expressed in ISO 8601
-- format.
deployment_creationTimestamp :: Lens.Lens' Deployment (Prelude.Maybe Prelude.UTCTime)
deployment_creationTimestamp :: (Maybe UTCTime -> f (Maybe UTCTime)) -> Deployment -> f Deployment
deployment_creationTimestamp = (Deployment -> Maybe POSIX)
-> (Deployment -> Maybe POSIX -> Deployment)
-> Lens Deployment Deployment (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Deployment' {Maybe POSIX
creationTimestamp :: Maybe POSIX
$sel:creationTimestamp:Deployment' :: Deployment -> Maybe POSIX
creationTimestamp} -> Maybe POSIX
creationTimestamp) (\s :: Deployment
s@Deployment' {} Maybe POSIX
a -> Deployment
s {$sel:creationTimestamp:Deployment' :: Maybe POSIX
creationTimestamp = Maybe POSIX
a} :: Deployment) ((Maybe POSIX -> f (Maybe POSIX)) -> Deployment -> f Deployment)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> Deployment
-> f Deployment
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The status of the deployment.
deployment_deploymentStatus :: Lens.Lens' Deployment (Prelude.Maybe DeploymentStatus)
deployment_deploymentStatus :: (Maybe DeploymentStatus -> f (Maybe DeploymentStatus))
-> Deployment -> f Deployment
deployment_deploymentStatus = (Deployment -> Maybe DeploymentStatus)
-> (Deployment -> Maybe DeploymentStatus -> Deployment)
-> Lens
     Deployment
     Deployment
     (Maybe DeploymentStatus)
     (Maybe DeploymentStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Deployment' {Maybe DeploymentStatus
deploymentStatus :: Maybe DeploymentStatus
$sel:deploymentStatus:Deployment' :: Deployment -> Maybe DeploymentStatus
deploymentStatus} -> Maybe DeploymentStatus
deploymentStatus) (\s :: Deployment
s@Deployment' {} Maybe DeploymentStatus
a -> Deployment
s {$sel:deploymentStatus:Deployment' :: Maybe DeploymentStatus
deploymentStatus = Maybe DeploymentStatus
a} :: Deployment)

-- | Whether or not the deployment is the latest revision for its target.
deployment_isLatestForTarget :: Lens.Lens' Deployment (Prelude.Maybe Prelude.Bool)
deployment_isLatestForTarget :: (Maybe Bool -> f (Maybe Bool)) -> Deployment -> f Deployment
deployment_isLatestForTarget = (Deployment -> Maybe Bool)
-> (Deployment -> Maybe Bool -> Deployment)
-> Lens Deployment Deployment (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Deployment' {Maybe Bool
isLatestForTarget :: Maybe Bool
$sel:isLatestForTarget:Deployment' :: Deployment -> Maybe Bool
isLatestForTarget} -> Maybe Bool
isLatestForTarget) (\s :: Deployment
s@Deployment' {} Maybe Bool
a -> Deployment
s {$sel:isLatestForTarget:Deployment' :: Maybe Bool
isLatestForTarget = Maybe Bool
a} :: Deployment)

-- | The revision number of the deployment.
deployment_revisionId :: Lens.Lens' Deployment (Prelude.Maybe Prelude.Text)
deployment_revisionId :: (Maybe Text -> f (Maybe Text)) -> Deployment -> f Deployment
deployment_revisionId = (Deployment -> Maybe Text)
-> (Deployment -> Maybe Text -> Deployment)
-> Lens Deployment Deployment (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Deployment' {Maybe Text
revisionId :: Maybe Text
$sel:revisionId:Deployment' :: Deployment -> Maybe Text
revisionId} -> Maybe Text
revisionId) (\s :: Deployment
s@Deployment' {} Maybe Text
a -> Deployment
s {$sel:revisionId:Deployment' :: Maybe Text
revisionId = Maybe Text
a} :: Deployment)

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

instance Core.FromJSON Deployment where
  parseJSON :: Value -> Parser Deployment
parseJSON =
    String
-> (Object -> Parser Deployment) -> Value -> Parser Deployment
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Deployment"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe POSIX
-> Maybe DeploymentStatus
-> Maybe Bool
-> Maybe Text
-> Maybe Text
-> Deployment
Deployment'
            (Maybe Text
 -> Maybe Text
 -> Maybe POSIX
 -> Maybe DeploymentStatus
 -> Maybe Bool
 -> Maybe Text
 -> Maybe Text
 -> Deployment)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe POSIX
      -> Maybe DeploymentStatus
      -> Maybe Bool
      -> Maybe Text
      -> Maybe Text
      -> Deployment)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"targetArn")
            Parser
  (Maybe Text
   -> Maybe POSIX
   -> Maybe DeploymentStatus
   -> Maybe Bool
   -> Maybe Text
   -> Maybe Text
   -> Deployment)
-> Parser (Maybe Text)
-> Parser
     (Maybe POSIX
      -> Maybe DeploymentStatus
      -> Maybe Bool
      -> Maybe Text
      -> Maybe Text
      -> Deployment)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"deploymentId")
            Parser
  (Maybe POSIX
   -> Maybe DeploymentStatus
   -> Maybe Bool
   -> Maybe Text
   -> Maybe Text
   -> Deployment)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe DeploymentStatus
      -> Maybe Bool -> Maybe Text -> Maybe Text -> Deployment)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"creationTimestamp")
            Parser
  (Maybe DeploymentStatus
   -> Maybe Bool -> Maybe Text -> Maybe Text -> Deployment)
-> Parser (Maybe DeploymentStatus)
-> Parser (Maybe Bool -> Maybe Text -> Maybe Text -> Deployment)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe DeploymentStatus)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"deploymentStatus")
            Parser (Maybe Bool -> Maybe Text -> Maybe Text -> Deployment)
-> Parser (Maybe Bool)
-> Parser (Maybe Text -> Maybe Text -> Deployment)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"isLatestForTarget")
            Parser (Maybe Text -> Maybe Text -> Deployment)
-> Parser (Maybe Text) -> Parser (Maybe Text -> Deployment)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"revisionId")
            Parser (Maybe Text -> Deployment)
-> Parser (Maybe Text) -> Parser Deployment
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"deploymentName")
      )

instance Prelude.Hashable Deployment

instance Prelude.NFData Deployment