{-# 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.DeleteResourcesByExternalId
-- 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 resources linked to an external ID.
module Amazonka.CodeDeploy.DeleteResourcesByExternalId
  ( -- * Creating a Request
    DeleteResourcesByExternalId (..),
    newDeleteResourcesByExternalId,

    -- * Request Lenses
    deleteResourcesByExternalId_externalId,

    -- * Destructuring the Response
    DeleteResourcesByExternalIdResponse (..),
    newDeleteResourcesByExternalIdResponse,

    -- * Response Lenses
    deleteResourcesByExternalIdResponse_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

-- | /See:/ 'newDeleteResourcesByExternalId' smart constructor.
data DeleteResourcesByExternalId = DeleteResourcesByExternalId'
  { -- | The unique ID of an external resource (for example, a CloudFormation
    -- stack ID) that is linked to one or more CodeDeploy resources.
    DeleteResourcesByExternalId -> Maybe Text
externalId :: Prelude.Maybe Prelude.Text
  }
  deriving (DeleteResourcesByExternalId -> DeleteResourcesByExternalId -> Bool
(DeleteResourcesByExternalId
 -> DeleteResourcesByExternalId -> Bool)
-> (DeleteResourcesByExternalId
    -> DeleteResourcesByExternalId -> Bool)
-> Eq DeleteResourcesByExternalId
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteResourcesByExternalId -> DeleteResourcesByExternalId -> Bool
$c/= :: DeleteResourcesByExternalId -> DeleteResourcesByExternalId -> Bool
== :: DeleteResourcesByExternalId -> DeleteResourcesByExternalId -> Bool
$c== :: DeleteResourcesByExternalId -> DeleteResourcesByExternalId -> Bool
Prelude.Eq, ReadPrec [DeleteResourcesByExternalId]
ReadPrec DeleteResourcesByExternalId
Int -> ReadS DeleteResourcesByExternalId
ReadS [DeleteResourcesByExternalId]
(Int -> ReadS DeleteResourcesByExternalId)
-> ReadS [DeleteResourcesByExternalId]
-> ReadPrec DeleteResourcesByExternalId
-> ReadPrec [DeleteResourcesByExternalId]
-> Read DeleteResourcesByExternalId
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteResourcesByExternalId]
$creadListPrec :: ReadPrec [DeleteResourcesByExternalId]
readPrec :: ReadPrec DeleteResourcesByExternalId
$creadPrec :: ReadPrec DeleteResourcesByExternalId
readList :: ReadS [DeleteResourcesByExternalId]
$creadList :: ReadS [DeleteResourcesByExternalId]
readsPrec :: Int -> ReadS DeleteResourcesByExternalId
$creadsPrec :: Int -> ReadS DeleteResourcesByExternalId
Prelude.Read, Int -> DeleteResourcesByExternalId -> ShowS
[DeleteResourcesByExternalId] -> ShowS
DeleteResourcesByExternalId -> String
(Int -> DeleteResourcesByExternalId -> ShowS)
-> (DeleteResourcesByExternalId -> String)
-> ([DeleteResourcesByExternalId] -> ShowS)
-> Show DeleteResourcesByExternalId
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteResourcesByExternalId] -> ShowS
$cshowList :: [DeleteResourcesByExternalId] -> ShowS
show :: DeleteResourcesByExternalId -> String
$cshow :: DeleteResourcesByExternalId -> String
showsPrec :: Int -> DeleteResourcesByExternalId -> ShowS
$cshowsPrec :: Int -> DeleteResourcesByExternalId -> ShowS
Prelude.Show, (forall x.
 DeleteResourcesByExternalId -> Rep DeleteResourcesByExternalId x)
-> (forall x.
    Rep DeleteResourcesByExternalId x -> DeleteResourcesByExternalId)
-> Generic DeleteResourcesByExternalId
forall x.
Rep DeleteResourcesByExternalId x -> DeleteResourcesByExternalId
forall x.
DeleteResourcesByExternalId -> Rep DeleteResourcesByExternalId x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeleteResourcesByExternalId x -> DeleteResourcesByExternalId
$cfrom :: forall x.
DeleteResourcesByExternalId -> Rep DeleteResourcesByExternalId x
Prelude.Generic)

-- |
-- Create a value of 'DeleteResourcesByExternalId' 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:
--
-- 'externalId', 'deleteResourcesByExternalId_externalId' - The unique ID of an external resource (for example, a CloudFormation
-- stack ID) that is linked to one or more CodeDeploy resources.
newDeleteResourcesByExternalId ::
  DeleteResourcesByExternalId
newDeleteResourcesByExternalId :: DeleteResourcesByExternalId
newDeleteResourcesByExternalId =
  DeleteResourcesByExternalId' :: Maybe Text -> DeleteResourcesByExternalId
DeleteResourcesByExternalId'
    { $sel:externalId:DeleteResourcesByExternalId' :: Maybe Text
externalId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The unique ID of an external resource (for example, a CloudFormation
-- stack ID) that is linked to one or more CodeDeploy resources.
deleteResourcesByExternalId_externalId :: Lens.Lens' DeleteResourcesByExternalId (Prelude.Maybe Prelude.Text)
deleteResourcesByExternalId_externalId :: (Maybe Text -> f (Maybe Text))
-> DeleteResourcesByExternalId -> f DeleteResourcesByExternalId
deleteResourcesByExternalId_externalId = (DeleteResourcesByExternalId -> Maybe Text)
-> (DeleteResourcesByExternalId
    -> Maybe Text -> DeleteResourcesByExternalId)
-> Lens
     DeleteResourcesByExternalId
     DeleteResourcesByExternalId
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteResourcesByExternalId' {Maybe Text
externalId :: Maybe Text
$sel:externalId:DeleteResourcesByExternalId' :: DeleteResourcesByExternalId -> Maybe Text
externalId} -> Maybe Text
externalId) (\s :: DeleteResourcesByExternalId
s@DeleteResourcesByExternalId' {} Maybe Text
a -> DeleteResourcesByExternalId
s {$sel:externalId:DeleteResourcesByExternalId' :: Maybe Text
externalId = Maybe Text
a} :: DeleteResourcesByExternalId)

instance Core.AWSRequest DeleteResourcesByExternalId where
  type
    AWSResponse DeleteResourcesByExternalId =
      DeleteResourcesByExternalIdResponse
  request :: DeleteResourcesByExternalId -> Request DeleteResourcesByExternalId
request = Service
-> DeleteResourcesByExternalId
-> Request DeleteResourcesByExternalId
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteResourcesByExternalId
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteResourcesByExternalId)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DeleteResourcesByExternalId))
-> Logger
-> Service
-> Proxy DeleteResourcesByExternalId
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteResourcesByExternalId)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> DeleteResourcesByExternalIdResponse
DeleteResourcesByExternalIdResponse'
            (Int -> DeleteResourcesByExternalIdResponse)
-> Either String Int
-> Either String DeleteResourcesByExternalIdResponse
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))
      )

instance Prelude.Hashable DeleteResourcesByExternalId

instance Prelude.NFData DeleteResourcesByExternalId

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

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

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

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

-- |
-- Create a value of 'DeleteResourcesByExternalIdResponse' 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', 'deleteResourcesByExternalIdResponse_httpStatus' - The response's http status code.
newDeleteResourcesByExternalIdResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteResourcesByExternalIdResponse
newDeleteResourcesByExternalIdResponse :: Int -> DeleteResourcesByExternalIdResponse
newDeleteResourcesByExternalIdResponse Int
pHttpStatus_ =
  DeleteResourcesByExternalIdResponse' :: Int -> DeleteResourcesByExternalIdResponse
DeleteResourcesByExternalIdResponse'
    { $sel:httpStatus:DeleteResourcesByExternalIdResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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

instance
  Prelude.NFData
    DeleteResourcesByExternalIdResponse