{-# 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.APIGateway.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.APIGateway.Types.Deployment where

import Amazonka.APIGateway.Types.MethodSnapshot
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | An immutable representation of a RestApi resource that can be called by
-- users using Stages. A deployment must be associated with a Stage for it
-- to be callable over the Internet.
--
-- To create a deployment, call @POST@ on the Deployments resource of a
-- RestApi. To view, update, or delete a deployment, call @GET@, @PATCH@,
-- or @DELETE@ on the specified deployment resource
-- (@\/restapis\/{restapi_id}\/deployments\/{deployment_id}@).
--
-- RestApi, Deployments, Stage,
-- <https://docs.aws.amazon.com/cli/latest/reference/apigateway/get-deployment.html AWS CLI>,
-- <https://aws.amazon.com/tools/ AWS SDKs>
--
-- /See:/ 'newDeployment' smart constructor.
data Deployment = Deployment'
  { -- | A summary of the RestApi at the date and time that the deployment
    -- resource was created.
    Deployment -> Maybe (HashMap Text (HashMap Text MethodSnapshot))
apiSummary :: Prelude.Maybe (Prelude.HashMap Prelude.Text (Prelude.HashMap Prelude.Text MethodSnapshot)),
    -- | The date and time that the deployment resource was created.
    Deployment -> Maybe POSIX
createdDate :: Prelude.Maybe Core.POSIX,
    -- | The identifier for the deployment resource.
    Deployment -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
    -- | The description for the deployment resource.
    Deployment -> Maybe Text
description :: 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:
--
-- 'apiSummary', 'deployment_apiSummary' - A summary of the RestApi at the date and time that the deployment
-- resource was created.
--
-- 'createdDate', 'deployment_createdDate' - The date and time that the deployment resource was created.
--
-- 'id', 'deployment_id' - The identifier for the deployment resource.
--
-- 'description', 'deployment_description' - The description for the deployment resource.
newDeployment ::
  Deployment
newDeployment :: Deployment
newDeployment =
  Deployment' :: Maybe (HashMap Text (HashMap Text MethodSnapshot))
-> Maybe POSIX -> Maybe Text -> Maybe Text -> Deployment
Deployment'
    { $sel:apiSummary:Deployment' :: Maybe (HashMap Text (HashMap Text MethodSnapshot))
apiSummary = Maybe (HashMap Text (HashMap Text MethodSnapshot))
forall a. Maybe a
Prelude.Nothing,
      $sel:createdDate:Deployment' :: Maybe POSIX
createdDate = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:id:Deployment' :: Maybe Text
id = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:description:Deployment' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | A summary of the RestApi at the date and time that the deployment
-- resource was created.
deployment_apiSummary :: Lens.Lens' Deployment (Prelude.Maybe (Prelude.HashMap Prelude.Text (Prelude.HashMap Prelude.Text MethodSnapshot)))
deployment_apiSummary :: (Maybe (HashMap Text (HashMap Text MethodSnapshot))
 -> f (Maybe (HashMap Text (HashMap Text MethodSnapshot))))
-> Deployment -> f Deployment
deployment_apiSummary = (Deployment -> Maybe (HashMap Text (HashMap Text MethodSnapshot)))
-> (Deployment
    -> Maybe (HashMap Text (HashMap Text MethodSnapshot))
    -> Deployment)
-> Lens
     Deployment
     Deployment
     (Maybe (HashMap Text (HashMap Text MethodSnapshot)))
     (Maybe (HashMap Text (HashMap Text MethodSnapshot)))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Deployment' {Maybe (HashMap Text (HashMap Text MethodSnapshot))
apiSummary :: Maybe (HashMap Text (HashMap Text MethodSnapshot))
$sel:apiSummary:Deployment' :: Deployment -> Maybe (HashMap Text (HashMap Text MethodSnapshot))
apiSummary} -> Maybe (HashMap Text (HashMap Text MethodSnapshot))
apiSummary) (\s :: Deployment
s@Deployment' {} Maybe (HashMap Text (HashMap Text MethodSnapshot))
a -> Deployment
s {$sel:apiSummary:Deployment' :: Maybe (HashMap Text (HashMap Text MethodSnapshot))
apiSummary = Maybe (HashMap Text (HashMap Text MethodSnapshot))
a} :: Deployment) ((Maybe (HashMap Text (HashMap Text MethodSnapshot))
  -> f (Maybe (HashMap Text (HashMap Text MethodSnapshot))))
 -> Deployment -> f Deployment)
-> ((Maybe (HashMap Text (HashMap Text MethodSnapshot))
     -> f (Maybe (HashMap Text (HashMap Text MethodSnapshot))))
    -> Maybe (HashMap Text (HashMap Text MethodSnapshot))
    -> f (Maybe (HashMap Text (HashMap Text MethodSnapshot))))
-> (Maybe (HashMap Text (HashMap Text MethodSnapshot))
    -> f (Maybe (HashMap Text (HashMap Text MethodSnapshot))))
-> Deployment
-> f Deployment
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text (HashMap Text MethodSnapshot))
  (HashMap Text (HashMap Text MethodSnapshot))
  (HashMap Text (HashMap Text MethodSnapshot))
  (HashMap Text (HashMap Text MethodSnapshot))
-> Iso
     (Maybe (HashMap Text (HashMap Text MethodSnapshot)))
     (Maybe (HashMap Text (HashMap Text MethodSnapshot)))
     (Maybe (HashMap Text (HashMap Text MethodSnapshot)))
     (Maybe (HashMap Text (HashMap Text MethodSnapshot)))
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 (HashMap Text MethodSnapshot))
  (HashMap Text (HashMap Text MethodSnapshot))
  (HashMap Text (HashMap Text MethodSnapshot))
  (HashMap Text (HashMap Text MethodSnapshot))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The date and time that the deployment resource was created.
deployment_createdDate :: Lens.Lens' Deployment (Prelude.Maybe Prelude.UTCTime)
deployment_createdDate :: (Maybe UTCTime -> f (Maybe UTCTime)) -> Deployment -> f Deployment
deployment_createdDate = (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
createdDate :: Maybe POSIX
$sel:createdDate:Deployment' :: Deployment -> Maybe POSIX
createdDate} -> Maybe POSIX
createdDate) (\s :: Deployment
s@Deployment' {} Maybe POSIX
a -> Deployment
s {$sel:createdDate:Deployment' :: Maybe POSIX
createdDate = 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 identifier for the deployment resource.
deployment_id :: Lens.Lens' Deployment (Prelude.Maybe Prelude.Text)
deployment_id :: (Maybe Text -> f (Maybe Text)) -> Deployment -> f Deployment
deployment_id = (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
id :: Maybe Text
$sel:id:Deployment' :: Deployment -> Maybe Text
id} -> Maybe Text
id) (\s :: Deployment
s@Deployment' {} Maybe Text
a -> Deployment
s {$sel:id:Deployment' :: Maybe Text
id = Maybe Text
a} :: Deployment)

-- | The description for the deployment resource.
deployment_description :: Lens.Lens' Deployment (Prelude.Maybe Prelude.Text)
deployment_description :: (Maybe Text -> f (Maybe Text)) -> Deployment -> f Deployment
deployment_description = (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
description :: Maybe Text
$sel:description:Deployment' :: Deployment -> Maybe Text
description} -> Maybe Text
description) (\s :: Deployment
s@Deployment' {} Maybe Text
a -> Deployment
s {$sel:description:Deployment' :: Maybe Text
description = 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 (HashMap Text (HashMap Text MethodSnapshot))
-> Maybe POSIX -> Maybe Text -> Maybe Text -> Deployment
Deployment'
            (Maybe (HashMap Text (HashMap Text MethodSnapshot))
 -> Maybe POSIX -> Maybe Text -> Maybe Text -> Deployment)
-> Parser (Maybe (HashMap Text (HashMap Text MethodSnapshot)))
-> Parser (Maybe POSIX -> Maybe Text -> Maybe Text -> Deployment)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object
-> Text
-> Parser
     (Maybe (Maybe (HashMap Text (HashMap Text MethodSnapshot))))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"apiSummary" Parser (Maybe (Maybe (HashMap Text (HashMap Text MethodSnapshot))))
-> Maybe (HashMap Text (HashMap Text MethodSnapshot))
-> Parser (Maybe (HashMap Text (HashMap Text MethodSnapshot)))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text (HashMap Text MethodSnapshot))
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe POSIX -> Maybe Text -> Maybe Text -> Deployment)
-> Parser (Maybe POSIX)
-> 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 POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"createdDate")
            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
"id")
            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
"description")
      )

instance Prelude.Hashable Deployment

instance Prelude.NFData Deployment