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

    -- * Request Lenses
    deleteSegment_segmentId,
    deleteSegment_applicationId,

    -- * Destructuring the Response
    DeleteSegmentResponse (..),
    newDeleteSegmentResponse,

    -- * Response Lenses
    deleteSegmentResponse_httpStatus,
    deleteSegmentResponse_segmentResponse,
  )
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:/ 'newDeleteSegment' smart constructor.
data DeleteSegment = DeleteSegment'
  { -- | The unique identifier for the segment.
    DeleteSegment -> Text
segmentId :: Prelude.Text,
    -- | The unique identifier for the application. This identifier is displayed
    -- as the __Project ID__ on the Amazon Pinpoint console.
    DeleteSegment -> Text
applicationId :: Prelude.Text
  }
  deriving (DeleteSegment -> DeleteSegment -> Bool
(DeleteSegment -> DeleteSegment -> Bool)
-> (DeleteSegment -> DeleteSegment -> Bool) -> Eq DeleteSegment
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteSegment -> DeleteSegment -> Bool
$c/= :: DeleteSegment -> DeleteSegment -> Bool
== :: DeleteSegment -> DeleteSegment -> Bool
$c== :: DeleteSegment -> DeleteSegment -> Bool
Prelude.Eq, ReadPrec [DeleteSegment]
ReadPrec DeleteSegment
Int -> ReadS DeleteSegment
ReadS [DeleteSegment]
(Int -> ReadS DeleteSegment)
-> ReadS [DeleteSegment]
-> ReadPrec DeleteSegment
-> ReadPrec [DeleteSegment]
-> Read DeleteSegment
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteSegment]
$creadListPrec :: ReadPrec [DeleteSegment]
readPrec :: ReadPrec DeleteSegment
$creadPrec :: ReadPrec DeleteSegment
readList :: ReadS [DeleteSegment]
$creadList :: ReadS [DeleteSegment]
readsPrec :: Int -> ReadS DeleteSegment
$creadsPrec :: Int -> ReadS DeleteSegment
Prelude.Read, Int -> DeleteSegment -> ShowS
[DeleteSegment] -> ShowS
DeleteSegment -> String
(Int -> DeleteSegment -> ShowS)
-> (DeleteSegment -> String)
-> ([DeleteSegment] -> ShowS)
-> Show DeleteSegment
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteSegment] -> ShowS
$cshowList :: [DeleteSegment] -> ShowS
show :: DeleteSegment -> String
$cshow :: DeleteSegment -> String
showsPrec :: Int -> DeleteSegment -> ShowS
$cshowsPrec :: Int -> DeleteSegment -> ShowS
Prelude.Show, (forall x. DeleteSegment -> Rep DeleteSegment x)
-> (forall x. Rep DeleteSegment x -> DeleteSegment)
-> Generic DeleteSegment
forall x. Rep DeleteSegment x -> DeleteSegment
forall x. DeleteSegment -> Rep DeleteSegment x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteSegment x -> DeleteSegment
$cfrom :: forall x. DeleteSegment -> Rep DeleteSegment x
Prelude.Generic)

-- |
-- Create a value of 'DeleteSegment' 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:
--
-- 'segmentId', 'deleteSegment_segmentId' - The unique identifier for the segment.
--
-- 'applicationId', 'deleteSegment_applicationId' - The unique identifier for the application. This identifier is displayed
-- as the __Project ID__ on the Amazon Pinpoint console.
newDeleteSegment ::
  -- | 'segmentId'
  Prelude.Text ->
  -- | 'applicationId'
  Prelude.Text ->
  DeleteSegment
newDeleteSegment :: Text -> Text -> DeleteSegment
newDeleteSegment Text
pSegmentId_ Text
pApplicationId_ =
  DeleteSegment' :: Text -> Text -> DeleteSegment
DeleteSegment'
    { $sel:segmentId:DeleteSegment' :: Text
segmentId = Text
pSegmentId_,
      $sel:applicationId:DeleteSegment' :: Text
applicationId = Text
pApplicationId_
    }

-- | The unique identifier for the segment.
deleteSegment_segmentId :: Lens.Lens' DeleteSegment Prelude.Text
deleteSegment_segmentId :: (Text -> f Text) -> DeleteSegment -> f DeleteSegment
deleteSegment_segmentId = (DeleteSegment -> Text)
-> (DeleteSegment -> Text -> DeleteSegment)
-> Lens DeleteSegment DeleteSegment Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteSegment' {Text
segmentId :: Text
$sel:segmentId:DeleteSegment' :: DeleteSegment -> Text
segmentId} -> Text
segmentId) (\s :: DeleteSegment
s@DeleteSegment' {} Text
a -> DeleteSegment
s {$sel:segmentId:DeleteSegment' :: Text
segmentId = Text
a} :: DeleteSegment)

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

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

instance Prelude.Hashable DeleteSegment

instance Prelude.NFData DeleteSegment

instance Core.ToHeaders DeleteSegment where
  toHeaders :: DeleteSegment -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteSegment -> 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 DeleteSegment where
  toPath :: DeleteSegment -> ByteString
toPath DeleteSegment' {Text
applicationId :: Text
segmentId :: Text
$sel:applicationId:DeleteSegment' :: DeleteSegment -> Text
$sel:segmentId:DeleteSegment' :: DeleteSegment -> 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
"/segments/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
segmentId
      ]

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

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

-- |
-- Create a value of 'DeleteSegmentResponse' 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', 'deleteSegmentResponse_httpStatus' - The response's http status code.
--
-- 'segmentResponse', 'deleteSegmentResponse_segmentResponse' - Undocumented member.
newDeleteSegmentResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'segmentResponse'
  SegmentResponse ->
  DeleteSegmentResponse
newDeleteSegmentResponse :: Int -> SegmentResponse -> DeleteSegmentResponse
newDeleteSegmentResponse
  Int
pHttpStatus_
  SegmentResponse
pSegmentResponse_ =
    DeleteSegmentResponse' :: Int -> SegmentResponse -> DeleteSegmentResponse
DeleteSegmentResponse'
      { $sel:httpStatus:DeleteSegmentResponse' :: Int
httpStatus = Int
pHttpStatus_,
        $sel:segmentResponse:DeleteSegmentResponse' :: SegmentResponse
segmentResponse = SegmentResponse
pSegmentResponse_
      }

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

-- | Undocumented member.
deleteSegmentResponse_segmentResponse :: Lens.Lens' DeleteSegmentResponse SegmentResponse
deleteSegmentResponse_segmentResponse :: (SegmentResponse -> f SegmentResponse)
-> DeleteSegmentResponse -> f DeleteSegmentResponse
deleteSegmentResponse_segmentResponse = (DeleteSegmentResponse -> SegmentResponse)
-> (DeleteSegmentResponse
    -> SegmentResponse -> DeleteSegmentResponse)
-> Lens
     DeleteSegmentResponse
     DeleteSegmentResponse
     SegmentResponse
     SegmentResponse
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteSegmentResponse' {SegmentResponse
segmentResponse :: SegmentResponse
$sel:segmentResponse:DeleteSegmentResponse' :: DeleteSegmentResponse -> SegmentResponse
segmentResponse} -> SegmentResponse
segmentResponse) (\s :: DeleteSegmentResponse
s@DeleteSegmentResponse' {} SegmentResponse
a -> DeleteSegmentResponse
s {$sel:segmentResponse:DeleteSegmentResponse' :: SegmentResponse
segmentResponse = SegmentResponse
a} :: DeleteSegmentResponse)

instance Prelude.NFData DeleteSegmentResponse