{-# 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.RegisterApplicationRevision
-- 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)
--
-- Registers with AWS CodeDeploy a revision for the specified application.
module Amazonka.CodeDeploy.RegisterApplicationRevision
  ( -- * Creating a Request
    RegisterApplicationRevision (..),
    newRegisterApplicationRevision,

    -- * Request Lenses
    registerApplicationRevision_description,
    registerApplicationRevision_applicationName,
    registerApplicationRevision_revision,

    -- * Destructuring the Response
    RegisterApplicationRevisionResponse (..),
    newRegisterApplicationRevisionResponse,
  )
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 RegisterApplicationRevision operation.
--
-- /See:/ 'newRegisterApplicationRevision' smart constructor.
data RegisterApplicationRevision = RegisterApplicationRevision'
  { -- | A comment about the revision.
    RegisterApplicationRevision -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The name of an AWS CodeDeploy application associated with the IAM user
    -- or AWS account.
    RegisterApplicationRevision -> Text
applicationName :: Prelude.Text,
    -- | Information about the application revision to register, including type
    -- and location.
    RegisterApplicationRevision -> RevisionLocation
revision :: RevisionLocation
  }
  deriving (RegisterApplicationRevision -> RegisterApplicationRevision -> Bool
(RegisterApplicationRevision
 -> RegisterApplicationRevision -> Bool)
-> (RegisterApplicationRevision
    -> RegisterApplicationRevision -> Bool)
-> Eq RegisterApplicationRevision
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RegisterApplicationRevision -> RegisterApplicationRevision -> Bool
$c/= :: RegisterApplicationRevision -> RegisterApplicationRevision -> Bool
== :: RegisterApplicationRevision -> RegisterApplicationRevision -> Bool
$c== :: RegisterApplicationRevision -> RegisterApplicationRevision -> Bool
Prelude.Eq, ReadPrec [RegisterApplicationRevision]
ReadPrec RegisterApplicationRevision
Int -> ReadS RegisterApplicationRevision
ReadS [RegisterApplicationRevision]
(Int -> ReadS RegisterApplicationRevision)
-> ReadS [RegisterApplicationRevision]
-> ReadPrec RegisterApplicationRevision
-> ReadPrec [RegisterApplicationRevision]
-> Read RegisterApplicationRevision
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RegisterApplicationRevision]
$creadListPrec :: ReadPrec [RegisterApplicationRevision]
readPrec :: ReadPrec RegisterApplicationRevision
$creadPrec :: ReadPrec RegisterApplicationRevision
readList :: ReadS [RegisterApplicationRevision]
$creadList :: ReadS [RegisterApplicationRevision]
readsPrec :: Int -> ReadS RegisterApplicationRevision
$creadsPrec :: Int -> ReadS RegisterApplicationRevision
Prelude.Read, Int -> RegisterApplicationRevision -> ShowS
[RegisterApplicationRevision] -> ShowS
RegisterApplicationRevision -> String
(Int -> RegisterApplicationRevision -> ShowS)
-> (RegisterApplicationRevision -> String)
-> ([RegisterApplicationRevision] -> ShowS)
-> Show RegisterApplicationRevision
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RegisterApplicationRevision] -> ShowS
$cshowList :: [RegisterApplicationRevision] -> ShowS
show :: RegisterApplicationRevision -> String
$cshow :: RegisterApplicationRevision -> String
showsPrec :: Int -> RegisterApplicationRevision -> ShowS
$cshowsPrec :: Int -> RegisterApplicationRevision -> ShowS
Prelude.Show, (forall x.
 RegisterApplicationRevision -> Rep RegisterApplicationRevision x)
-> (forall x.
    Rep RegisterApplicationRevision x -> RegisterApplicationRevision)
-> Generic RegisterApplicationRevision
forall x.
Rep RegisterApplicationRevision x -> RegisterApplicationRevision
forall x.
RegisterApplicationRevision -> Rep RegisterApplicationRevision x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep RegisterApplicationRevision x -> RegisterApplicationRevision
$cfrom :: forall x.
RegisterApplicationRevision -> Rep RegisterApplicationRevision x
Prelude.Generic)

-- |
-- Create a value of 'RegisterApplicationRevision' 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:
--
-- 'description', 'registerApplicationRevision_description' - A comment about the revision.
--
-- 'applicationName', 'registerApplicationRevision_applicationName' - The name of an AWS CodeDeploy application associated with the IAM user
-- or AWS account.
--
-- 'revision', 'registerApplicationRevision_revision' - Information about the application revision to register, including type
-- and location.
newRegisterApplicationRevision ::
  -- | 'applicationName'
  Prelude.Text ->
  -- | 'revision'
  RevisionLocation ->
  RegisterApplicationRevision
newRegisterApplicationRevision :: Text -> RevisionLocation -> RegisterApplicationRevision
newRegisterApplicationRevision
  Text
pApplicationName_
  RevisionLocation
pRevision_ =
    RegisterApplicationRevision' :: Maybe Text
-> Text -> RevisionLocation -> RegisterApplicationRevision
RegisterApplicationRevision'
      { $sel:description:RegisterApplicationRevision' :: Maybe Text
description =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:applicationName:RegisterApplicationRevision' :: Text
applicationName = Text
pApplicationName_,
        $sel:revision:RegisterApplicationRevision' :: RevisionLocation
revision = RevisionLocation
pRevision_
      }

-- | A comment about the revision.
registerApplicationRevision_description :: Lens.Lens' RegisterApplicationRevision (Prelude.Maybe Prelude.Text)
registerApplicationRevision_description :: (Maybe Text -> f (Maybe Text))
-> RegisterApplicationRevision -> f RegisterApplicationRevision
registerApplicationRevision_description = (RegisterApplicationRevision -> Maybe Text)
-> (RegisterApplicationRevision
    -> Maybe Text -> RegisterApplicationRevision)
-> Lens
     RegisterApplicationRevision
     RegisterApplicationRevision
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegisterApplicationRevision' {Maybe Text
description :: Maybe Text
$sel:description:RegisterApplicationRevision' :: RegisterApplicationRevision -> Maybe Text
description} -> Maybe Text
description) (\s :: RegisterApplicationRevision
s@RegisterApplicationRevision' {} Maybe Text
a -> RegisterApplicationRevision
s {$sel:description:RegisterApplicationRevision' :: Maybe Text
description = Maybe Text
a} :: RegisterApplicationRevision)

-- | The name of an AWS CodeDeploy application associated with the IAM user
-- or AWS account.
registerApplicationRevision_applicationName :: Lens.Lens' RegisterApplicationRevision Prelude.Text
registerApplicationRevision_applicationName :: (Text -> f Text)
-> RegisterApplicationRevision -> f RegisterApplicationRevision
registerApplicationRevision_applicationName = (RegisterApplicationRevision -> Text)
-> (RegisterApplicationRevision
    -> Text -> RegisterApplicationRevision)
-> Lens
     RegisterApplicationRevision RegisterApplicationRevision Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegisterApplicationRevision' {Text
applicationName :: Text
$sel:applicationName:RegisterApplicationRevision' :: RegisterApplicationRevision -> Text
applicationName} -> Text
applicationName) (\s :: RegisterApplicationRevision
s@RegisterApplicationRevision' {} Text
a -> RegisterApplicationRevision
s {$sel:applicationName:RegisterApplicationRevision' :: Text
applicationName = Text
a} :: RegisterApplicationRevision)

-- | Information about the application revision to register, including type
-- and location.
registerApplicationRevision_revision :: Lens.Lens' RegisterApplicationRevision RevisionLocation
registerApplicationRevision_revision :: (RevisionLocation -> f RevisionLocation)
-> RegisterApplicationRevision -> f RegisterApplicationRevision
registerApplicationRevision_revision = (RegisterApplicationRevision -> RevisionLocation)
-> (RegisterApplicationRevision
    -> RevisionLocation -> RegisterApplicationRevision)
-> Lens
     RegisterApplicationRevision
     RegisterApplicationRevision
     RevisionLocation
     RevisionLocation
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegisterApplicationRevision' {RevisionLocation
revision :: RevisionLocation
$sel:revision:RegisterApplicationRevision' :: RegisterApplicationRevision -> RevisionLocation
revision} -> RevisionLocation
revision) (\s :: RegisterApplicationRevision
s@RegisterApplicationRevision' {} RevisionLocation
a -> RegisterApplicationRevision
s {$sel:revision:RegisterApplicationRevision' :: RevisionLocation
revision = RevisionLocation
a} :: RegisterApplicationRevision)

instance Core.AWSRequest RegisterApplicationRevision where
  type
    AWSResponse RegisterApplicationRevision =
      RegisterApplicationRevisionResponse
  request :: RegisterApplicationRevision -> Request RegisterApplicationRevision
request = Service
-> RegisterApplicationRevision
-> Request RegisterApplicationRevision
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy RegisterApplicationRevision
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse RegisterApplicationRevision)))
response =
    AWSResponse RegisterApplicationRevision
-> Logger
-> Service
-> Proxy RegisterApplicationRevision
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse RegisterApplicationRevision)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull
      AWSResponse RegisterApplicationRevision
RegisterApplicationRevisionResponse
RegisterApplicationRevisionResponse'

instance Prelude.Hashable RegisterApplicationRevision

instance Prelude.NFData RegisterApplicationRevision

instance Core.ToHeaders RegisterApplicationRevision where
  toHeaders :: RegisterApplicationRevision -> [Header]
toHeaders =
    [Header] -> RegisterApplicationRevision -> [Header]
forall a b. a -> b -> a
Prelude.const
      ( [[Header]] -> [Header]
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"CodeDeploy_20141006.RegisterApplicationRevision" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON RegisterApplicationRevision where
  toJSON :: RegisterApplicationRevision -> Value
toJSON RegisterApplicationRevision' {Maybe Text
Text
RevisionLocation
revision :: RevisionLocation
applicationName :: Text
description :: Maybe Text
$sel:revision:RegisterApplicationRevision' :: RegisterApplicationRevision -> RevisionLocation
$sel:applicationName:RegisterApplicationRevision' :: RegisterApplicationRevision -> Text
$sel:description:RegisterApplicationRevision' :: RegisterApplicationRevision -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (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,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"applicationName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
applicationName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"revision" Text -> RevisionLocation -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= RevisionLocation
revision)
          ]
      )

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

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

-- | /See:/ 'newRegisterApplicationRevisionResponse' smart constructor.
data RegisterApplicationRevisionResponse = RegisterApplicationRevisionResponse'
  {
  }
  deriving (RegisterApplicationRevisionResponse
-> RegisterApplicationRevisionResponse -> Bool
(RegisterApplicationRevisionResponse
 -> RegisterApplicationRevisionResponse -> Bool)
-> (RegisterApplicationRevisionResponse
    -> RegisterApplicationRevisionResponse -> Bool)
-> Eq RegisterApplicationRevisionResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RegisterApplicationRevisionResponse
-> RegisterApplicationRevisionResponse -> Bool
$c/= :: RegisterApplicationRevisionResponse
-> RegisterApplicationRevisionResponse -> Bool
== :: RegisterApplicationRevisionResponse
-> RegisterApplicationRevisionResponse -> Bool
$c== :: RegisterApplicationRevisionResponse
-> RegisterApplicationRevisionResponse -> Bool
Prelude.Eq, ReadPrec [RegisterApplicationRevisionResponse]
ReadPrec RegisterApplicationRevisionResponse
Int -> ReadS RegisterApplicationRevisionResponse
ReadS [RegisterApplicationRevisionResponse]
(Int -> ReadS RegisterApplicationRevisionResponse)
-> ReadS [RegisterApplicationRevisionResponse]
-> ReadPrec RegisterApplicationRevisionResponse
-> ReadPrec [RegisterApplicationRevisionResponse]
-> Read RegisterApplicationRevisionResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RegisterApplicationRevisionResponse]
$creadListPrec :: ReadPrec [RegisterApplicationRevisionResponse]
readPrec :: ReadPrec RegisterApplicationRevisionResponse
$creadPrec :: ReadPrec RegisterApplicationRevisionResponse
readList :: ReadS [RegisterApplicationRevisionResponse]
$creadList :: ReadS [RegisterApplicationRevisionResponse]
readsPrec :: Int -> ReadS RegisterApplicationRevisionResponse
$creadsPrec :: Int -> ReadS RegisterApplicationRevisionResponse
Prelude.Read, Int -> RegisterApplicationRevisionResponse -> ShowS
[RegisterApplicationRevisionResponse] -> ShowS
RegisterApplicationRevisionResponse -> String
(Int -> RegisterApplicationRevisionResponse -> ShowS)
-> (RegisterApplicationRevisionResponse -> String)
-> ([RegisterApplicationRevisionResponse] -> ShowS)
-> Show RegisterApplicationRevisionResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RegisterApplicationRevisionResponse] -> ShowS
$cshowList :: [RegisterApplicationRevisionResponse] -> ShowS
show :: RegisterApplicationRevisionResponse -> String
$cshow :: RegisterApplicationRevisionResponse -> String
showsPrec :: Int -> RegisterApplicationRevisionResponse -> ShowS
$cshowsPrec :: Int -> RegisterApplicationRevisionResponse -> ShowS
Prelude.Show, (forall x.
 RegisterApplicationRevisionResponse
 -> Rep RegisterApplicationRevisionResponse x)
-> (forall x.
    Rep RegisterApplicationRevisionResponse x
    -> RegisterApplicationRevisionResponse)
-> Generic RegisterApplicationRevisionResponse
forall x.
Rep RegisterApplicationRevisionResponse x
-> RegisterApplicationRevisionResponse
forall x.
RegisterApplicationRevisionResponse
-> Rep RegisterApplicationRevisionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep RegisterApplicationRevisionResponse x
-> RegisterApplicationRevisionResponse
$cfrom :: forall x.
RegisterApplicationRevisionResponse
-> Rep RegisterApplicationRevisionResponse x
Prelude.Generic)

-- |
-- Create a value of 'RegisterApplicationRevisionResponse' 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.
newRegisterApplicationRevisionResponse ::
  RegisterApplicationRevisionResponse
newRegisterApplicationRevisionResponse :: RegisterApplicationRevisionResponse
newRegisterApplicationRevisionResponse =
  RegisterApplicationRevisionResponse
RegisterApplicationRevisionResponse'

instance
  Prelude.NFData
    RegisterApplicationRevisionResponse