{-# 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.CodeDeploy.GetDeployment
-- 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)
--
-- Gets information about a deployment.
--
-- The @content@ property of the @appSpecContent@ object in the returned
-- revision is always null. Use @GetApplicationRevision@ and the @sha256@
-- property of the returned @appSpecContent@ object to get the content of
-- the deployment’s AppSpec file.
module Amazonka.CodeDeploy.GetDeployment
  ( -- * Creating a Request
    GetDeployment (..),
    newGetDeployment,

    -- * Request Lenses
    getDeployment_deploymentId,

    -- * Destructuring the Response
    GetDeploymentResponse (..),
    newGetDeploymentResponse,

    -- * Response Lenses
    getDeploymentResponse_deploymentInfo,
    getDeploymentResponse_httpStatus,
  )
where

import Amazonka.CodeDeploy.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | Represents the input of a @GetDeployment@ operation.
--
-- /See:/ 'newGetDeployment' smart constructor.
data GetDeployment = GetDeployment'
  { -- | The unique ID of a deployment associated with the IAM user or AWS
    -- account.
    GetDeployment -> Text
deploymentId :: Prelude.Text
  }
  deriving (GetDeployment -> GetDeployment -> Bool
(GetDeployment -> GetDeployment -> Bool)
-> (GetDeployment -> GetDeployment -> Bool) -> Eq GetDeployment
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDeployment -> GetDeployment -> Bool
$c/= :: GetDeployment -> GetDeployment -> Bool
== :: GetDeployment -> GetDeployment -> Bool
$c== :: GetDeployment -> GetDeployment -> Bool
Prelude.Eq, ReadPrec [GetDeployment]
ReadPrec GetDeployment
Int -> ReadS GetDeployment
ReadS [GetDeployment]
(Int -> ReadS GetDeployment)
-> ReadS [GetDeployment]
-> ReadPrec GetDeployment
-> ReadPrec [GetDeployment]
-> Read GetDeployment
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetDeployment]
$creadListPrec :: ReadPrec [GetDeployment]
readPrec :: ReadPrec GetDeployment
$creadPrec :: ReadPrec GetDeployment
readList :: ReadS [GetDeployment]
$creadList :: ReadS [GetDeployment]
readsPrec :: Int -> ReadS GetDeployment
$creadsPrec :: Int -> ReadS GetDeployment
Prelude.Read, Int -> GetDeployment -> ShowS
[GetDeployment] -> ShowS
GetDeployment -> String
(Int -> GetDeployment -> ShowS)
-> (GetDeployment -> String)
-> ([GetDeployment] -> ShowS)
-> Show GetDeployment
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDeployment] -> ShowS
$cshowList :: [GetDeployment] -> ShowS
show :: GetDeployment -> String
$cshow :: GetDeployment -> String
showsPrec :: Int -> GetDeployment -> ShowS
$cshowsPrec :: Int -> GetDeployment -> ShowS
Prelude.Show, (forall x. GetDeployment -> Rep GetDeployment x)
-> (forall x. Rep GetDeployment x -> GetDeployment)
-> Generic GetDeployment
forall x. Rep GetDeployment x -> GetDeployment
forall x. GetDeployment -> Rep GetDeployment x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetDeployment x -> GetDeployment
$cfrom :: forall x. GetDeployment -> Rep GetDeployment x
Prelude.Generic)

-- |
-- Create a value of 'GetDeployment' 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', 'getDeployment_deploymentId' - The unique ID of a deployment associated with the IAM user or AWS
-- account.
newGetDeployment ::
  -- | 'deploymentId'
  Prelude.Text ->
  GetDeployment
newGetDeployment :: Text -> GetDeployment
newGetDeployment Text
pDeploymentId_ =
  GetDeployment' :: Text -> GetDeployment
GetDeployment' {$sel:deploymentId:GetDeployment' :: Text
deploymentId = Text
pDeploymentId_}

-- | The unique ID of a deployment associated with the IAM user or AWS
-- account.
getDeployment_deploymentId :: Lens.Lens' GetDeployment Prelude.Text
getDeployment_deploymentId :: (Text -> f Text) -> GetDeployment -> f GetDeployment
getDeployment_deploymentId = (GetDeployment -> Text)
-> (GetDeployment -> Text -> GetDeployment)
-> Lens GetDeployment GetDeployment Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDeployment' {Text
deploymentId :: Text
$sel:deploymentId:GetDeployment' :: GetDeployment -> Text
deploymentId} -> Text
deploymentId) (\s :: GetDeployment
s@GetDeployment' {} Text
a -> GetDeployment
s {$sel:deploymentId:GetDeployment' :: Text
deploymentId = Text
a} :: GetDeployment)

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

instance Prelude.NFData GetDeployment

instance Core.ToHeaders GetDeployment where
  toHeaders :: GetDeployment -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetDeployment -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"CodeDeploy_20141006.GetDeployment" ::
                          Prelude.ByteString
                      ),
            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 GetDeployment where
  toJSON :: GetDeployment -> Value
toJSON GetDeployment' {Text
deploymentId :: Text
$sel:deploymentId:GetDeployment' :: GetDeployment -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"deploymentId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
deploymentId)]
      )

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

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

-- | Represents the output of a @GetDeployment@ operation.
--
-- /See:/ 'newGetDeploymentResponse' smart constructor.
data GetDeploymentResponse = GetDeploymentResponse'
  { -- | Information about the deployment.
    GetDeploymentResponse -> Maybe DeploymentInfo
deploymentInfo :: Prelude.Maybe DeploymentInfo,
    -- | The response's http status code.
    GetDeploymentResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetDeploymentResponse -> GetDeploymentResponse -> Bool
(GetDeploymentResponse -> GetDeploymentResponse -> Bool)
-> (GetDeploymentResponse -> GetDeploymentResponse -> Bool)
-> Eq GetDeploymentResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDeploymentResponse -> GetDeploymentResponse -> Bool
$c/= :: GetDeploymentResponse -> GetDeploymentResponse -> Bool
== :: GetDeploymentResponse -> GetDeploymentResponse -> Bool
$c== :: GetDeploymentResponse -> GetDeploymentResponse -> Bool
Prelude.Eq, ReadPrec [GetDeploymentResponse]
ReadPrec GetDeploymentResponse
Int -> ReadS GetDeploymentResponse
ReadS [GetDeploymentResponse]
(Int -> ReadS GetDeploymentResponse)
-> ReadS [GetDeploymentResponse]
-> ReadPrec GetDeploymentResponse
-> ReadPrec [GetDeploymentResponse]
-> Read GetDeploymentResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetDeploymentResponse]
$creadListPrec :: ReadPrec [GetDeploymentResponse]
readPrec :: ReadPrec GetDeploymentResponse
$creadPrec :: ReadPrec GetDeploymentResponse
readList :: ReadS [GetDeploymentResponse]
$creadList :: ReadS [GetDeploymentResponse]
readsPrec :: Int -> ReadS GetDeploymentResponse
$creadsPrec :: Int -> ReadS GetDeploymentResponse
Prelude.Read, Int -> GetDeploymentResponse -> ShowS
[GetDeploymentResponse] -> ShowS
GetDeploymentResponse -> String
(Int -> GetDeploymentResponse -> ShowS)
-> (GetDeploymentResponse -> String)
-> ([GetDeploymentResponse] -> ShowS)
-> Show GetDeploymentResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDeploymentResponse] -> ShowS
$cshowList :: [GetDeploymentResponse] -> ShowS
show :: GetDeploymentResponse -> String
$cshow :: GetDeploymentResponse -> String
showsPrec :: Int -> GetDeploymentResponse -> ShowS
$cshowsPrec :: Int -> GetDeploymentResponse -> ShowS
Prelude.Show, (forall x. GetDeploymentResponse -> Rep GetDeploymentResponse x)
-> (forall x. Rep GetDeploymentResponse x -> GetDeploymentResponse)
-> Generic GetDeploymentResponse
forall x. Rep GetDeploymentResponse x -> GetDeploymentResponse
forall x. GetDeploymentResponse -> Rep GetDeploymentResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetDeploymentResponse x -> GetDeploymentResponse
$cfrom :: forall x. GetDeploymentResponse -> Rep GetDeploymentResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetDeploymentResponse' 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:
--
-- 'deploymentInfo', 'getDeploymentResponse_deploymentInfo' - Information about the deployment.
--
-- 'httpStatus', 'getDeploymentResponse_httpStatus' - The response's http status code.
newGetDeploymentResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetDeploymentResponse
newGetDeploymentResponse :: Int -> GetDeploymentResponse
newGetDeploymentResponse Int
pHttpStatus_ =
  GetDeploymentResponse' :: Maybe DeploymentInfo -> Int -> GetDeploymentResponse
GetDeploymentResponse'
    { $sel:deploymentInfo:GetDeploymentResponse' :: Maybe DeploymentInfo
deploymentInfo =
        Maybe DeploymentInfo
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetDeploymentResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the deployment.
getDeploymentResponse_deploymentInfo :: Lens.Lens' GetDeploymentResponse (Prelude.Maybe DeploymentInfo)
getDeploymentResponse_deploymentInfo :: (Maybe DeploymentInfo -> f (Maybe DeploymentInfo))
-> GetDeploymentResponse -> f GetDeploymentResponse
getDeploymentResponse_deploymentInfo = (GetDeploymentResponse -> Maybe DeploymentInfo)
-> (GetDeploymentResponse
    -> Maybe DeploymentInfo -> GetDeploymentResponse)
-> Lens
     GetDeploymentResponse
     GetDeploymentResponse
     (Maybe DeploymentInfo)
     (Maybe DeploymentInfo)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDeploymentResponse' {Maybe DeploymentInfo
deploymentInfo :: Maybe DeploymentInfo
$sel:deploymentInfo:GetDeploymentResponse' :: GetDeploymentResponse -> Maybe DeploymentInfo
deploymentInfo} -> Maybe DeploymentInfo
deploymentInfo) (\s :: GetDeploymentResponse
s@GetDeploymentResponse' {} Maybe DeploymentInfo
a -> GetDeploymentResponse
s {$sel:deploymentInfo:GetDeploymentResponse' :: Maybe DeploymentInfo
deploymentInfo = Maybe DeploymentInfo
a} :: GetDeploymentResponse)

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

instance Prelude.NFData GetDeploymentResponse