{-# 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.Pinpoint.DeleteCampaign
-- 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 campaign from an application.
module Amazonka.Pinpoint.DeleteCampaign
  ( -- * Creating a Request
    DeleteCampaign (..),
    newDeleteCampaign,

    -- * Request Lenses
    deleteCampaign_campaignId,
    deleteCampaign_applicationId,

    -- * Destructuring the Response
    DeleteCampaignResponse (..),
    newDeleteCampaignResponse,

    -- * Response Lenses
    deleteCampaignResponse_httpStatus,
    deleteCampaignResponse_campaignResponse,
  )
where

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

-- | /See:/ 'newDeleteCampaign' smart constructor.
data DeleteCampaign = DeleteCampaign'
  { -- | The unique identifier for the campaign.
    DeleteCampaign -> Text
campaignId :: Prelude.Text,
    -- | The unique identifier for the application. This identifier is displayed
    -- as the __Project ID__ on the Amazon Pinpoint console.
    DeleteCampaign -> Text
applicationId :: Prelude.Text
  }
  deriving (DeleteCampaign -> DeleteCampaign -> Bool
(DeleteCampaign -> DeleteCampaign -> Bool)
-> (DeleteCampaign -> DeleteCampaign -> Bool) -> Eq DeleteCampaign
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteCampaign -> DeleteCampaign -> Bool
$c/= :: DeleteCampaign -> DeleteCampaign -> Bool
== :: DeleteCampaign -> DeleteCampaign -> Bool
$c== :: DeleteCampaign -> DeleteCampaign -> Bool
Prelude.Eq, ReadPrec [DeleteCampaign]
ReadPrec DeleteCampaign
Int -> ReadS DeleteCampaign
ReadS [DeleteCampaign]
(Int -> ReadS DeleteCampaign)
-> ReadS [DeleteCampaign]
-> ReadPrec DeleteCampaign
-> ReadPrec [DeleteCampaign]
-> Read DeleteCampaign
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteCampaign]
$creadListPrec :: ReadPrec [DeleteCampaign]
readPrec :: ReadPrec DeleteCampaign
$creadPrec :: ReadPrec DeleteCampaign
readList :: ReadS [DeleteCampaign]
$creadList :: ReadS [DeleteCampaign]
readsPrec :: Int -> ReadS DeleteCampaign
$creadsPrec :: Int -> ReadS DeleteCampaign
Prelude.Read, Int -> DeleteCampaign -> ShowS
[DeleteCampaign] -> ShowS
DeleteCampaign -> String
(Int -> DeleteCampaign -> ShowS)
-> (DeleteCampaign -> String)
-> ([DeleteCampaign] -> ShowS)
-> Show DeleteCampaign
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteCampaign] -> ShowS
$cshowList :: [DeleteCampaign] -> ShowS
show :: DeleteCampaign -> String
$cshow :: DeleteCampaign -> String
showsPrec :: Int -> DeleteCampaign -> ShowS
$cshowsPrec :: Int -> DeleteCampaign -> ShowS
Prelude.Show, (forall x. DeleteCampaign -> Rep DeleteCampaign x)
-> (forall x. Rep DeleteCampaign x -> DeleteCampaign)
-> Generic DeleteCampaign
forall x. Rep DeleteCampaign x -> DeleteCampaign
forall x. DeleteCampaign -> Rep DeleteCampaign x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteCampaign x -> DeleteCampaign
$cfrom :: forall x. DeleteCampaign -> Rep DeleteCampaign x
Prelude.Generic)

-- |
-- Create a value of 'DeleteCampaign' 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:
--
-- 'campaignId', 'deleteCampaign_campaignId' - The unique identifier for the campaign.
--
-- 'applicationId', 'deleteCampaign_applicationId' - The unique identifier for the application. This identifier is displayed
-- as the __Project ID__ on the Amazon Pinpoint console.
newDeleteCampaign ::
  -- | 'campaignId'
  Prelude.Text ->
  -- | 'applicationId'
  Prelude.Text ->
  DeleteCampaign
newDeleteCampaign :: Text -> Text -> DeleteCampaign
newDeleteCampaign Text
pCampaignId_ Text
pApplicationId_ =
  DeleteCampaign' :: Text -> Text -> DeleteCampaign
DeleteCampaign'
    { $sel:campaignId:DeleteCampaign' :: Text
campaignId = Text
pCampaignId_,
      $sel:applicationId:DeleteCampaign' :: Text
applicationId = Text
pApplicationId_
    }

-- | The unique identifier for the campaign.
deleteCampaign_campaignId :: Lens.Lens' DeleteCampaign Prelude.Text
deleteCampaign_campaignId :: (Text -> f Text) -> DeleteCampaign -> f DeleteCampaign
deleteCampaign_campaignId = (DeleteCampaign -> Text)
-> (DeleteCampaign -> Text -> DeleteCampaign)
-> Lens DeleteCampaign DeleteCampaign Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteCampaign' {Text
campaignId :: Text
$sel:campaignId:DeleteCampaign' :: DeleteCampaign -> Text
campaignId} -> Text
campaignId) (\s :: DeleteCampaign
s@DeleteCampaign' {} Text
a -> DeleteCampaign
s {$sel:campaignId:DeleteCampaign' :: Text
campaignId = Text
a} :: DeleteCampaign)

-- | The unique identifier for the application. This identifier is displayed
-- as the __Project ID__ on the Amazon Pinpoint console.
deleteCampaign_applicationId :: Lens.Lens' DeleteCampaign Prelude.Text
deleteCampaign_applicationId :: (Text -> f Text) -> DeleteCampaign -> f DeleteCampaign
deleteCampaign_applicationId = (DeleteCampaign -> Text)
-> (DeleteCampaign -> Text -> DeleteCampaign)
-> Lens DeleteCampaign DeleteCampaign Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteCampaign' {Text
applicationId :: Text
$sel:applicationId:DeleteCampaign' :: DeleteCampaign -> Text
applicationId} -> Text
applicationId) (\s :: DeleteCampaign
s@DeleteCampaign' {} Text
a -> DeleteCampaign
s {$sel:applicationId:DeleteCampaign' :: Text
applicationId = Text
a} :: DeleteCampaign)

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

instance Prelude.Hashable DeleteCampaign

instance Prelude.NFData DeleteCampaign

instance Core.ToHeaders DeleteCampaign where
  toHeaders :: DeleteCampaign -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteCampaign -> 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 DeleteCampaign where
  toPath :: DeleteCampaign -> ByteString
toPath DeleteCampaign' {Text
applicationId :: Text
campaignId :: Text
$sel:applicationId:DeleteCampaign' :: DeleteCampaign -> Text
$sel:campaignId:DeleteCampaign' :: DeleteCampaign -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/v1/apps/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
applicationId,
        ByteString
"/campaigns/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
campaignId
      ]

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

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

-- |
-- Create a value of 'DeleteCampaignResponse' 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', 'deleteCampaignResponse_httpStatus' - The response's http status code.
--
-- 'campaignResponse', 'deleteCampaignResponse_campaignResponse' - Undocumented member.
newDeleteCampaignResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'campaignResponse'
  CampaignResponse ->
  DeleteCampaignResponse
newDeleteCampaignResponse :: Int -> CampaignResponse -> DeleteCampaignResponse
newDeleteCampaignResponse
  Int
pHttpStatus_
  CampaignResponse
pCampaignResponse_ =
    DeleteCampaignResponse' :: Int -> CampaignResponse -> DeleteCampaignResponse
DeleteCampaignResponse'
      { $sel:httpStatus:DeleteCampaignResponse' :: Int
httpStatus = Int
pHttpStatus_,
        $sel:campaignResponse:DeleteCampaignResponse' :: CampaignResponse
campaignResponse = CampaignResponse
pCampaignResponse_
      }

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

-- | Undocumented member.
deleteCampaignResponse_campaignResponse :: Lens.Lens' DeleteCampaignResponse CampaignResponse
deleteCampaignResponse_campaignResponse :: (CampaignResponse -> f CampaignResponse)
-> DeleteCampaignResponse -> f DeleteCampaignResponse
deleteCampaignResponse_campaignResponse = (DeleteCampaignResponse -> CampaignResponse)
-> (DeleteCampaignResponse
    -> CampaignResponse -> DeleteCampaignResponse)
-> Lens
     DeleteCampaignResponse
     DeleteCampaignResponse
     CampaignResponse
     CampaignResponse
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteCampaignResponse' {CampaignResponse
campaignResponse :: CampaignResponse
$sel:campaignResponse:DeleteCampaignResponse' :: DeleteCampaignResponse -> CampaignResponse
campaignResponse} -> CampaignResponse
campaignResponse) (\s :: DeleteCampaignResponse
s@DeleteCampaignResponse' {} CampaignResponse
a -> DeleteCampaignResponse
s {$sel:campaignResponse:DeleteCampaignResponse' :: CampaignResponse
campaignResponse = CampaignResponse
a} :: DeleteCampaignResponse)

instance Prelude.NFData DeleteCampaignResponse