{-# 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.DeleteGitHubAccountToken
-- 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 GitHub account connection.
module Amazonka.CodeDeploy.DeleteGitHubAccountToken
  ( -- * Creating a Request
    DeleteGitHubAccountToken (..),
    newDeleteGitHubAccountToken,

    -- * Request Lenses
    deleteGitHubAccountToken_tokenName,

    -- * Destructuring the Response
    DeleteGitHubAccountTokenResponse (..),
    newDeleteGitHubAccountTokenResponse,

    -- * Response Lenses
    deleteGitHubAccountTokenResponse_tokenName,
    deleteGitHubAccountTokenResponse_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 @DeleteGitHubAccount@ operation.
--
-- /See:/ 'newDeleteGitHubAccountToken' smart constructor.
data DeleteGitHubAccountToken = DeleteGitHubAccountToken'
  { -- | The name of the GitHub account connection to delete.
    DeleteGitHubAccountToken -> Maybe Text
tokenName :: Prelude.Maybe Prelude.Text
  }
  deriving (DeleteGitHubAccountToken -> DeleteGitHubAccountToken -> Bool
(DeleteGitHubAccountToken -> DeleteGitHubAccountToken -> Bool)
-> (DeleteGitHubAccountToken -> DeleteGitHubAccountToken -> Bool)
-> Eq DeleteGitHubAccountToken
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteGitHubAccountToken -> DeleteGitHubAccountToken -> Bool
$c/= :: DeleteGitHubAccountToken -> DeleteGitHubAccountToken -> Bool
== :: DeleteGitHubAccountToken -> DeleteGitHubAccountToken -> Bool
$c== :: DeleteGitHubAccountToken -> DeleteGitHubAccountToken -> Bool
Prelude.Eq, ReadPrec [DeleteGitHubAccountToken]
ReadPrec DeleteGitHubAccountToken
Int -> ReadS DeleteGitHubAccountToken
ReadS [DeleteGitHubAccountToken]
(Int -> ReadS DeleteGitHubAccountToken)
-> ReadS [DeleteGitHubAccountToken]
-> ReadPrec DeleteGitHubAccountToken
-> ReadPrec [DeleteGitHubAccountToken]
-> Read DeleteGitHubAccountToken
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteGitHubAccountToken]
$creadListPrec :: ReadPrec [DeleteGitHubAccountToken]
readPrec :: ReadPrec DeleteGitHubAccountToken
$creadPrec :: ReadPrec DeleteGitHubAccountToken
readList :: ReadS [DeleteGitHubAccountToken]
$creadList :: ReadS [DeleteGitHubAccountToken]
readsPrec :: Int -> ReadS DeleteGitHubAccountToken
$creadsPrec :: Int -> ReadS DeleteGitHubAccountToken
Prelude.Read, Int -> DeleteGitHubAccountToken -> ShowS
[DeleteGitHubAccountToken] -> ShowS
DeleteGitHubAccountToken -> String
(Int -> DeleteGitHubAccountToken -> ShowS)
-> (DeleteGitHubAccountToken -> String)
-> ([DeleteGitHubAccountToken] -> ShowS)
-> Show DeleteGitHubAccountToken
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteGitHubAccountToken] -> ShowS
$cshowList :: [DeleteGitHubAccountToken] -> ShowS
show :: DeleteGitHubAccountToken -> String
$cshow :: DeleteGitHubAccountToken -> String
showsPrec :: Int -> DeleteGitHubAccountToken -> ShowS
$cshowsPrec :: Int -> DeleteGitHubAccountToken -> ShowS
Prelude.Show, (forall x.
 DeleteGitHubAccountToken -> Rep DeleteGitHubAccountToken x)
-> (forall x.
    Rep DeleteGitHubAccountToken x -> DeleteGitHubAccountToken)
-> Generic DeleteGitHubAccountToken
forall x.
Rep DeleteGitHubAccountToken x -> DeleteGitHubAccountToken
forall x.
DeleteGitHubAccountToken -> Rep DeleteGitHubAccountToken x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeleteGitHubAccountToken x -> DeleteGitHubAccountToken
$cfrom :: forall x.
DeleteGitHubAccountToken -> Rep DeleteGitHubAccountToken x
Prelude.Generic)

-- |
-- Create a value of 'DeleteGitHubAccountToken' 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:
--
-- 'tokenName', 'deleteGitHubAccountToken_tokenName' - The name of the GitHub account connection to delete.
newDeleteGitHubAccountToken ::
  DeleteGitHubAccountToken
newDeleteGitHubAccountToken :: DeleteGitHubAccountToken
newDeleteGitHubAccountToken =
  DeleteGitHubAccountToken' :: Maybe Text -> DeleteGitHubAccountToken
DeleteGitHubAccountToken'
    { $sel:tokenName:DeleteGitHubAccountToken' :: Maybe Text
tokenName =
        Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the GitHub account connection to delete.
deleteGitHubAccountToken_tokenName :: Lens.Lens' DeleteGitHubAccountToken (Prelude.Maybe Prelude.Text)
deleteGitHubAccountToken_tokenName :: (Maybe Text -> f (Maybe Text))
-> DeleteGitHubAccountToken -> f DeleteGitHubAccountToken
deleteGitHubAccountToken_tokenName = (DeleteGitHubAccountToken -> Maybe Text)
-> (DeleteGitHubAccountToken
    -> Maybe Text -> DeleteGitHubAccountToken)
-> Lens
     DeleteGitHubAccountToken
     DeleteGitHubAccountToken
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteGitHubAccountToken' {Maybe Text
tokenName :: Maybe Text
$sel:tokenName:DeleteGitHubAccountToken' :: DeleteGitHubAccountToken -> Maybe Text
tokenName} -> Maybe Text
tokenName) (\s :: DeleteGitHubAccountToken
s@DeleteGitHubAccountToken' {} Maybe Text
a -> DeleteGitHubAccountToken
s {$sel:tokenName:DeleteGitHubAccountToken' :: Maybe Text
tokenName = Maybe Text
a} :: DeleteGitHubAccountToken)

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

instance Prelude.NFData DeleteGitHubAccountToken

instance Core.ToHeaders DeleteGitHubAccountToken where
  toHeaders :: DeleteGitHubAccountToken -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteGitHubAccountToken -> 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.DeleteGitHubAccountToken" ::
                          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 DeleteGitHubAccountToken where
  toJSON :: DeleteGitHubAccountToken -> Value
toJSON DeleteGitHubAccountToken' {Maybe Text
tokenName :: Maybe Text
$sel:tokenName:DeleteGitHubAccountToken' :: DeleteGitHubAccountToken -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Text
"tokenName" 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
tokenName]
      )

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

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

-- | Represents the output of a @DeleteGitHubAccountToken@ operation.
--
-- /See:/ 'newDeleteGitHubAccountTokenResponse' smart constructor.
data DeleteGitHubAccountTokenResponse = DeleteGitHubAccountTokenResponse'
  { -- | The name of the GitHub account connection that was deleted.
    DeleteGitHubAccountTokenResponse -> Maybe Text
tokenName :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    DeleteGitHubAccountTokenResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteGitHubAccountTokenResponse
-> DeleteGitHubAccountTokenResponse -> Bool
(DeleteGitHubAccountTokenResponse
 -> DeleteGitHubAccountTokenResponse -> Bool)
-> (DeleteGitHubAccountTokenResponse
    -> DeleteGitHubAccountTokenResponse -> Bool)
-> Eq DeleteGitHubAccountTokenResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteGitHubAccountTokenResponse
-> DeleteGitHubAccountTokenResponse -> Bool
$c/= :: DeleteGitHubAccountTokenResponse
-> DeleteGitHubAccountTokenResponse -> Bool
== :: DeleteGitHubAccountTokenResponse
-> DeleteGitHubAccountTokenResponse -> Bool
$c== :: DeleteGitHubAccountTokenResponse
-> DeleteGitHubAccountTokenResponse -> Bool
Prelude.Eq, ReadPrec [DeleteGitHubAccountTokenResponse]
ReadPrec DeleteGitHubAccountTokenResponse
Int -> ReadS DeleteGitHubAccountTokenResponse
ReadS [DeleteGitHubAccountTokenResponse]
(Int -> ReadS DeleteGitHubAccountTokenResponse)
-> ReadS [DeleteGitHubAccountTokenResponse]
-> ReadPrec DeleteGitHubAccountTokenResponse
-> ReadPrec [DeleteGitHubAccountTokenResponse]
-> Read DeleteGitHubAccountTokenResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteGitHubAccountTokenResponse]
$creadListPrec :: ReadPrec [DeleteGitHubAccountTokenResponse]
readPrec :: ReadPrec DeleteGitHubAccountTokenResponse
$creadPrec :: ReadPrec DeleteGitHubAccountTokenResponse
readList :: ReadS [DeleteGitHubAccountTokenResponse]
$creadList :: ReadS [DeleteGitHubAccountTokenResponse]
readsPrec :: Int -> ReadS DeleteGitHubAccountTokenResponse
$creadsPrec :: Int -> ReadS DeleteGitHubAccountTokenResponse
Prelude.Read, Int -> DeleteGitHubAccountTokenResponse -> ShowS
[DeleteGitHubAccountTokenResponse] -> ShowS
DeleteGitHubAccountTokenResponse -> String
(Int -> DeleteGitHubAccountTokenResponse -> ShowS)
-> (DeleteGitHubAccountTokenResponse -> String)
-> ([DeleteGitHubAccountTokenResponse] -> ShowS)
-> Show DeleteGitHubAccountTokenResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteGitHubAccountTokenResponse] -> ShowS
$cshowList :: [DeleteGitHubAccountTokenResponse] -> ShowS
show :: DeleteGitHubAccountTokenResponse -> String
$cshow :: DeleteGitHubAccountTokenResponse -> String
showsPrec :: Int -> DeleteGitHubAccountTokenResponse -> ShowS
$cshowsPrec :: Int -> DeleteGitHubAccountTokenResponse -> ShowS
Prelude.Show, (forall x.
 DeleteGitHubAccountTokenResponse
 -> Rep DeleteGitHubAccountTokenResponse x)
-> (forall x.
    Rep DeleteGitHubAccountTokenResponse x
    -> DeleteGitHubAccountTokenResponse)
-> Generic DeleteGitHubAccountTokenResponse
forall x.
Rep DeleteGitHubAccountTokenResponse x
-> DeleteGitHubAccountTokenResponse
forall x.
DeleteGitHubAccountTokenResponse
-> Rep DeleteGitHubAccountTokenResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeleteGitHubAccountTokenResponse x
-> DeleteGitHubAccountTokenResponse
$cfrom :: forall x.
DeleteGitHubAccountTokenResponse
-> Rep DeleteGitHubAccountTokenResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteGitHubAccountTokenResponse' 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:
--
-- 'tokenName', 'deleteGitHubAccountTokenResponse_tokenName' - The name of the GitHub account connection that was deleted.
--
-- 'httpStatus', 'deleteGitHubAccountTokenResponse_httpStatus' - The response's http status code.
newDeleteGitHubAccountTokenResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteGitHubAccountTokenResponse
newDeleteGitHubAccountTokenResponse :: Int -> DeleteGitHubAccountTokenResponse
newDeleteGitHubAccountTokenResponse Int
pHttpStatus_ =
  DeleteGitHubAccountTokenResponse' :: Maybe Text -> Int -> DeleteGitHubAccountTokenResponse
DeleteGitHubAccountTokenResponse'
    { $sel:tokenName:DeleteGitHubAccountTokenResponse' :: Maybe Text
tokenName =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteGitHubAccountTokenResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The name of the GitHub account connection that was deleted.
deleteGitHubAccountTokenResponse_tokenName :: Lens.Lens' DeleteGitHubAccountTokenResponse (Prelude.Maybe Prelude.Text)
deleteGitHubAccountTokenResponse_tokenName :: (Maybe Text -> f (Maybe Text))
-> DeleteGitHubAccountTokenResponse
-> f DeleteGitHubAccountTokenResponse
deleteGitHubAccountTokenResponse_tokenName = (DeleteGitHubAccountTokenResponse -> Maybe Text)
-> (DeleteGitHubAccountTokenResponse
    -> Maybe Text -> DeleteGitHubAccountTokenResponse)
-> Lens
     DeleteGitHubAccountTokenResponse
     DeleteGitHubAccountTokenResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteGitHubAccountTokenResponse' {Maybe Text
tokenName :: Maybe Text
$sel:tokenName:DeleteGitHubAccountTokenResponse' :: DeleteGitHubAccountTokenResponse -> Maybe Text
tokenName} -> Maybe Text
tokenName) (\s :: DeleteGitHubAccountTokenResponse
s@DeleteGitHubAccountTokenResponse' {} Maybe Text
a -> DeleteGitHubAccountTokenResponse
s {$sel:tokenName:DeleteGitHubAccountTokenResponse' :: Maybe Text
tokenName = Maybe Text
a} :: DeleteGitHubAccountTokenResponse)

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

instance
  Prelude.NFData
    DeleteGitHubAccountTokenResponse