{-# 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.Amplify.DeleteBranch
-- 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)
--
-- Deletes a branch for an Amplify app.
module Amazonka.Amplify.DeleteBranch
  ( -- * Creating a Request
    DeleteBranch (..),
    newDeleteBranch,

    -- * Request Lenses
    deleteBranch_appId,
    deleteBranch_branchName,

    -- * Destructuring the Response
    DeleteBranchResponse (..),
    newDeleteBranchResponse,

    -- * Response Lenses
    deleteBranchResponse_httpStatus,
    deleteBranchResponse_branch,
  )
where

import Amazonka.Amplify.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

-- | The request structure for the delete branch request.
--
-- /See:/ 'newDeleteBranch' smart constructor.
data DeleteBranch = DeleteBranch'
  { -- | The unique ID for an Amplify app.
    DeleteBranch -> Text
appId :: Prelude.Text,
    -- | The name for the branch.
    DeleteBranch -> Text
branchName :: Prelude.Text
  }
  deriving (DeleteBranch -> DeleteBranch -> Bool
(DeleteBranch -> DeleteBranch -> Bool)
-> (DeleteBranch -> DeleteBranch -> Bool) -> Eq DeleteBranch
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteBranch -> DeleteBranch -> Bool
$c/= :: DeleteBranch -> DeleteBranch -> Bool
== :: DeleteBranch -> DeleteBranch -> Bool
$c== :: DeleteBranch -> DeleteBranch -> Bool
Prelude.Eq, ReadPrec [DeleteBranch]
ReadPrec DeleteBranch
Int -> ReadS DeleteBranch
ReadS [DeleteBranch]
(Int -> ReadS DeleteBranch)
-> ReadS [DeleteBranch]
-> ReadPrec DeleteBranch
-> ReadPrec [DeleteBranch]
-> Read DeleteBranch
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteBranch]
$creadListPrec :: ReadPrec [DeleteBranch]
readPrec :: ReadPrec DeleteBranch
$creadPrec :: ReadPrec DeleteBranch
readList :: ReadS [DeleteBranch]
$creadList :: ReadS [DeleteBranch]
readsPrec :: Int -> ReadS DeleteBranch
$creadsPrec :: Int -> ReadS DeleteBranch
Prelude.Read, Int -> DeleteBranch -> ShowS
[DeleteBranch] -> ShowS
DeleteBranch -> String
(Int -> DeleteBranch -> ShowS)
-> (DeleteBranch -> String)
-> ([DeleteBranch] -> ShowS)
-> Show DeleteBranch
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteBranch] -> ShowS
$cshowList :: [DeleteBranch] -> ShowS
show :: DeleteBranch -> String
$cshow :: DeleteBranch -> String
showsPrec :: Int -> DeleteBranch -> ShowS
$cshowsPrec :: Int -> DeleteBranch -> ShowS
Prelude.Show, (forall x. DeleteBranch -> Rep DeleteBranch x)
-> (forall x. Rep DeleteBranch x -> DeleteBranch)
-> Generic DeleteBranch
forall x. Rep DeleteBranch x -> DeleteBranch
forall x. DeleteBranch -> Rep DeleteBranch x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteBranch x -> DeleteBranch
$cfrom :: forall x. DeleteBranch -> Rep DeleteBranch x
Prelude.Generic)

-- |
-- Create a value of 'DeleteBranch' 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:
--
-- 'appId', 'deleteBranch_appId' - The unique ID for an Amplify app.
--
-- 'branchName', 'deleteBranch_branchName' - The name for the branch.
newDeleteBranch ::
  -- | 'appId'
  Prelude.Text ->
  -- | 'branchName'
  Prelude.Text ->
  DeleteBranch
newDeleteBranch :: Text -> Text -> DeleteBranch
newDeleteBranch Text
pAppId_ Text
pBranchName_ =
  DeleteBranch' :: Text -> Text -> DeleteBranch
DeleteBranch'
    { $sel:appId:DeleteBranch' :: Text
appId = Text
pAppId_,
      $sel:branchName:DeleteBranch' :: Text
branchName = Text
pBranchName_
    }

-- | The unique ID for an Amplify app.
deleteBranch_appId :: Lens.Lens' DeleteBranch Prelude.Text
deleteBranch_appId :: (Text -> f Text) -> DeleteBranch -> f DeleteBranch
deleteBranch_appId = (DeleteBranch -> Text)
-> (DeleteBranch -> Text -> DeleteBranch)
-> Lens DeleteBranch DeleteBranch Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteBranch' {Text
appId :: Text
$sel:appId:DeleteBranch' :: DeleteBranch -> Text
appId} -> Text
appId) (\s :: DeleteBranch
s@DeleteBranch' {} Text
a -> DeleteBranch
s {$sel:appId:DeleteBranch' :: Text
appId = Text
a} :: DeleteBranch)

-- | The name for the branch.
deleteBranch_branchName :: Lens.Lens' DeleteBranch Prelude.Text
deleteBranch_branchName :: (Text -> f Text) -> DeleteBranch -> f DeleteBranch
deleteBranch_branchName = (DeleteBranch -> Text)
-> (DeleteBranch -> Text -> DeleteBranch)
-> Lens DeleteBranch DeleteBranch Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteBranch' {Text
branchName :: Text
$sel:branchName:DeleteBranch' :: DeleteBranch -> Text
branchName} -> Text
branchName) (\s :: DeleteBranch
s@DeleteBranch' {} Text
a -> DeleteBranch
s {$sel:branchName:DeleteBranch' :: Text
branchName = Text
a} :: DeleteBranch)

instance Core.AWSRequest DeleteBranch where
  type AWSResponse DeleteBranch = DeleteBranchResponse
  request :: DeleteBranch -> Request DeleteBranch
request = Service -> DeleteBranch -> Request DeleteBranch
forall a. ToRequest a => Service -> a -> Request a
Request.delete Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteBranch
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteBranch)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DeleteBranch))
-> Logger
-> Service
-> Proxy DeleteBranch
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteBranch)))
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 ->
          Int -> Branch -> DeleteBranchResponse
DeleteBranchResponse'
            (Int -> Branch -> DeleteBranchResponse)
-> Either String Int
-> Either String (Branch -> DeleteBranchResponse)
forall (f :: * -> *) a b. Functor 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))
            Either String (Branch -> DeleteBranchResponse)
-> Either String Branch -> Either String DeleteBranchResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String Branch
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"branch")
      )

instance Prelude.Hashable DeleteBranch

instance Prelude.NFData DeleteBranch

instance Core.ToHeaders DeleteBranch where
  toHeaders :: DeleteBranch -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteBranch -> 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.ToPath DeleteBranch where
  toPath :: DeleteBranch -> ByteString
toPath DeleteBranch' {Text
branchName :: Text
appId :: Text
$sel:branchName:DeleteBranch' :: DeleteBranch -> Text
$sel:appId:DeleteBranch' :: DeleteBranch -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/apps/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
appId,
        ByteString
"/branches/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
branchName
      ]

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

-- | The result structure for the delete branch request.
--
-- /See:/ 'newDeleteBranchResponse' smart constructor.
data DeleteBranchResponse = DeleteBranchResponse'
  { -- | The response's http status code.
    DeleteBranchResponse -> Int
httpStatus :: Prelude.Int,
    -- | The branch for an Amplify app, which maps to a third-party repository
    -- branch.
    DeleteBranchResponse -> Branch
branch :: Branch
  }
  deriving (DeleteBranchResponse -> DeleteBranchResponse -> Bool
(DeleteBranchResponse -> DeleteBranchResponse -> Bool)
-> (DeleteBranchResponse -> DeleteBranchResponse -> Bool)
-> Eq DeleteBranchResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteBranchResponse -> DeleteBranchResponse -> Bool
$c/= :: DeleteBranchResponse -> DeleteBranchResponse -> Bool
== :: DeleteBranchResponse -> DeleteBranchResponse -> Bool
$c== :: DeleteBranchResponse -> DeleteBranchResponse -> Bool
Prelude.Eq, Int -> DeleteBranchResponse -> ShowS
[DeleteBranchResponse] -> ShowS
DeleteBranchResponse -> String
(Int -> DeleteBranchResponse -> ShowS)
-> (DeleteBranchResponse -> String)
-> ([DeleteBranchResponse] -> ShowS)
-> Show DeleteBranchResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteBranchResponse] -> ShowS
$cshowList :: [DeleteBranchResponse] -> ShowS
show :: DeleteBranchResponse -> String
$cshow :: DeleteBranchResponse -> String
showsPrec :: Int -> DeleteBranchResponse -> ShowS
$cshowsPrec :: Int -> DeleteBranchResponse -> ShowS
Prelude.Show, (forall x. DeleteBranchResponse -> Rep DeleteBranchResponse x)
-> (forall x. Rep DeleteBranchResponse x -> DeleteBranchResponse)
-> Generic DeleteBranchResponse
forall x. Rep DeleteBranchResponse x -> DeleteBranchResponse
forall x. DeleteBranchResponse -> Rep DeleteBranchResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteBranchResponse x -> DeleteBranchResponse
$cfrom :: forall x. DeleteBranchResponse -> Rep DeleteBranchResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteBranchResponse' 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:
--
-- 'httpStatus', 'deleteBranchResponse_httpStatus' - The response's http status code.
--
-- 'branch', 'deleteBranchResponse_branch' - The branch for an Amplify app, which maps to a third-party repository
-- branch.
newDeleteBranchResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'branch'
  Branch ->
  DeleteBranchResponse
newDeleteBranchResponse :: Int -> Branch -> DeleteBranchResponse
newDeleteBranchResponse Int
pHttpStatus_ Branch
pBranch_ =
  DeleteBranchResponse' :: Int -> Branch -> DeleteBranchResponse
DeleteBranchResponse'
    { $sel:httpStatus:DeleteBranchResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:branch:DeleteBranchResponse' :: Branch
branch = Branch
pBranch_
    }

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

-- | The branch for an Amplify app, which maps to a third-party repository
-- branch.
deleteBranchResponse_branch :: Lens.Lens' DeleteBranchResponse Branch
deleteBranchResponse_branch :: (Branch -> f Branch)
-> DeleteBranchResponse -> f DeleteBranchResponse
deleteBranchResponse_branch = (DeleteBranchResponse -> Branch)
-> (DeleteBranchResponse -> Branch -> DeleteBranchResponse)
-> Lens DeleteBranchResponse DeleteBranchResponse Branch Branch
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteBranchResponse' {Branch
branch :: Branch
$sel:branch:DeleteBranchResponse' :: DeleteBranchResponse -> Branch
branch} -> Branch
branch) (\s :: DeleteBranchResponse
s@DeleteBranchResponse' {} Branch
a -> DeleteBranchResponse
s {$sel:branch:DeleteBranchResponse' :: Branch
branch = Branch
a} :: DeleteBranchResponse)

instance Prelude.NFData DeleteBranchResponse