{-# 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.BillingConductor.DeleteCustomLineItem
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Deletes the custom line item identified by the given ARN in the current,
-- or previous billing period.
module Amazonka.BillingConductor.DeleteCustomLineItem
  ( -- * Creating a Request
    DeleteCustomLineItem (..),
    newDeleteCustomLineItem,

    -- * Request Lenses
    deleteCustomLineItem_billingPeriodRange,
    deleteCustomLineItem_arn,

    -- * Destructuring the Response
    DeleteCustomLineItemResponse (..),
    newDeleteCustomLineItemResponse,

    -- * Response Lenses
    deleteCustomLineItemResponse_arn,
    deleteCustomLineItemResponse_httpStatus,
  )
where

import Amazonka.BillingConductor.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newDeleteCustomLineItem' smart constructor.
data DeleteCustomLineItem = DeleteCustomLineItem'
  { DeleteCustomLineItem -> Maybe CustomLineItemBillingPeriodRange
billingPeriodRange :: Prelude.Maybe CustomLineItemBillingPeriodRange,
    -- | The ARN of the custom line item to be deleted.
    DeleteCustomLineItem -> Text
arn :: Prelude.Text
  }
  deriving (DeleteCustomLineItem -> DeleteCustomLineItem -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteCustomLineItem -> DeleteCustomLineItem -> Bool
$c/= :: DeleteCustomLineItem -> DeleteCustomLineItem -> Bool
== :: DeleteCustomLineItem -> DeleteCustomLineItem -> Bool
$c== :: DeleteCustomLineItem -> DeleteCustomLineItem -> Bool
Prelude.Eq, ReadPrec [DeleteCustomLineItem]
ReadPrec DeleteCustomLineItem
Int -> ReadS DeleteCustomLineItem
ReadS [DeleteCustomLineItem]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteCustomLineItem]
$creadListPrec :: ReadPrec [DeleteCustomLineItem]
readPrec :: ReadPrec DeleteCustomLineItem
$creadPrec :: ReadPrec DeleteCustomLineItem
readList :: ReadS [DeleteCustomLineItem]
$creadList :: ReadS [DeleteCustomLineItem]
readsPrec :: Int -> ReadS DeleteCustomLineItem
$creadsPrec :: Int -> ReadS DeleteCustomLineItem
Prelude.Read, Int -> DeleteCustomLineItem -> ShowS
[DeleteCustomLineItem] -> ShowS
DeleteCustomLineItem -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteCustomLineItem] -> ShowS
$cshowList :: [DeleteCustomLineItem] -> ShowS
show :: DeleteCustomLineItem -> String
$cshow :: DeleteCustomLineItem -> String
showsPrec :: Int -> DeleteCustomLineItem -> ShowS
$cshowsPrec :: Int -> DeleteCustomLineItem -> ShowS
Prelude.Show, forall x. Rep DeleteCustomLineItem x -> DeleteCustomLineItem
forall x. DeleteCustomLineItem -> Rep DeleteCustomLineItem x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteCustomLineItem x -> DeleteCustomLineItem
$cfrom :: forall x. DeleteCustomLineItem -> Rep DeleteCustomLineItem x
Prelude.Generic)

-- |
-- Create a value of 'DeleteCustomLineItem' 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:
--
-- 'billingPeriodRange', 'deleteCustomLineItem_billingPeriodRange' - Undocumented member.
--
-- 'arn', 'deleteCustomLineItem_arn' - The ARN of the custom line item to be deleted.
newDeleteCustomLineItem ::
  -- | 'arn'
  Prelude.Text ->
  DeleteCustomLineItem
newDeleteCustomLineItem :: Text -> DeleteCustomLineItem
newDeleteCustomLineItem Text
pArn_ =
  DeleteCustomLineItem'
    { $sel:billingPeriodRange:DeleteCustomLineItem' :: Maybe CustomLineItemBillingPeriodRange
billingPeriodRange =
        forall a. Maybe a
Prelude.Nothing,
      $sel:arn:DeleteCustomLineItem' :: Text
arn = Text
pArn_
    }

-- | Undocumented member.
deleteCustomLineItem_billingPeriodRange :: Lens.Lens' DeleteCustomLineItem (Prelude.Maybe CustomLineItemBillingPeriodRange)
deleteCustomLineItem_billingPeriodRange :: Lens' DeleteCustomLineItem (Maybe CustomLineItemBillingPeriodRange)
deleteCustomLineItem_billingPeriodRange = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteCustomLineItem' {Maybe CustomLineItemBillingPeriodRange
billingPeriodRange :: Maybe CustomLineItemBillingPeriodRange
$sel:billingPeriodRange:DeleteCustomLineItem' :: DeleteCustomLineItem -> Maybe CustomLineItemBillingPeriodRange
billingPeriodRange} -> Maybe CustomLineItemBillingPeriodRange
billingPeriodRange) (\s :: DeleteCustomLineItem
s@DeleteCustomLineItem' {} Maybe CustomLineItemBillingPeriodRange
a -> DeleteCustomLineItem
s {$sel:billingPeriodRange:DeleteCustomLineItem' :: Maybe CustomLineItemBillingPeriodRange
billingPeriodRange = Maybe CustomLineItemBillingPeriodRange
a} :: DeleteCustomLineItem)

-- | The ARN of the custom line item to be deleted.
deleteCustomLineItem_arn :: Lens.Lens' DeleteCustomLineItem Prelude.Text
deleteCustomLineItem_arn :: Lens' DeleteCustomLineItem Text
deleteCustomLineItem_arn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteCustomLineItem' {Text
arn :: Text
$sel:arn:DeleteCustomLineItem' :: DeleteCustomLineItem -> Text
arn} -> Text
arn) (\s :: DeleteCustomLineItem
s@DeleteCustomLineItem' {} Text
a -> DeleteCustomLineItem
s {$sel:arn:DeleteCustomLineItem' :: Text
arn = Text
a} :: DeleteCustomLineItem)

instance Core.AWSRequest DeleteCustomLineItem where
  type
    AWSResponse DeleteCustomLineItem =
      DeleteCustomLineItemResponse
  request :: (Service -> Service)
-> DeleteCustomLineItem -> Request DeleteCustomLineItem
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DeleteCustomLineItem
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteCustomLineItem)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text -> Int -> DeleteCustomLineItemResponse
DeleteCustomLineItemResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"Arn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable DeleteCustomLineItem where
  hashWithSalt :: Int -> DeleteCustomLineItem -> Int
hashWithSalt Int
_salt DeleteCustomLineItem' {Maybe CustomLineItemBillingPeriodRange
Text
arn :: Text
billingPeriodRange :: Maybe CustomLineItemBillingPeriodRange
$sel:arn:DeleteCustomLineItem' :: DeleteCustomLineItem -> Text
$sel:billingPeriodRange:DeleteCustomLineItem' :: DeleteCustomLineItem -> Maybe CustomLineItemBillingPeriodRange
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe CustomLineItemBillingPeriodRange
billingPeriodRange
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
arn

instance Prelude.NFData DeleteCustomLineItem where
  rnf :: DeleteCustomLineItem -> ()
rnf DeleteCustomLineItem' {Maybe CustomLineItemBillingPeriodRange
Text
arn :: Text
billingPeriodRange :: Maybe CustomLineItemBillingPeriodRange
$sel:arn:DeleteCustomLineItem' :: DeleteCustomLineItem -> Text
$sel:billingPeriodRange:DeleteCustomLineItem' :: DeleteCustomLineItem -> Maybe CustomLineItemBillingPeriodRange
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe CustomLineItemBillingPeriodRange
billingPeriodRange
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
arn

instance Data.ToHeaders DeleteCustomLineItem where
  toHeaders :: DeleteCustomLineItem -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON DeleteCustomLineItem where
  toJSON :: DeleteCustomLineItem -> Value
toJSON DeleteCustomLineItem' {Maybe CustomLineItemBillingPeriodRange
Text
arn :: Text
billingPeriodRange :: Maybe CustomLineItemBillingPeriodRange
$sel:arn:DeleteCustomLineItem' :: DeleteCustomLineItem -> Text
$sel:billingPeriodRange:DeleteCustomLineItem' :: DeleteCustomLineItem -> Maybe CustomLineItemBillingPeriodRange
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"BillingPeriodRange" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe CustomLineItemBillingPeriodRange
billingPeriodRange,
            forall a. a -> Maybe a
Prelude.Just (Key
"Arn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
arn)
          ]
      )

instance Data.ToPath DeleteCustomLineItem where
  toPath :: DeleteCustomLineItem -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/delete-custom-line-item"

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

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

-- |
-- Create a value of 'DeleteCustomLineItemResponse' 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:
--
-- 'arn', 'deleteCustomLineItemResponse_arn' - Then ARN of the deleted custom line item.
--
-- 'httpStatus', 'deleteCustomLineItemResponse_httpStatus' - The response's http status code.
newDeleteCustomLineItemResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteCustomLineItemResponse
newDeleteCustomLineItemResponse :: Int -> DeleteCustomLineItemResponse
newDeleteCustomLineItemResponse Int
pHttpStatus_ =
  DeleteCustomLineItemResponse'
    { $sel:arn:DeleteCustomLineItemResponse' :: Maybe Text
arn =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteCustomLineItemResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Then ARN of the deleted custom line item.
deleteCustomLineItemResponse_arn :: Lens.Lens' DeleteCustomLineItemResponse (Prelude.Maybe Prelude.Text)
deleteCustomLineItemResponse_arn :: Lens' DeleteCustomLineItemResponse (Maybe Text)
deleteCustomLineItemResponse_arn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteCustomLineItemResponse' {Maybe Text
arn :: Maybe Text
$sel:arn:DeleteCustomLineItemResponse' :: DeleteCustomLineItemResponse -> Maybe Text
arn} -> Maybe Text
arn) (\s :: DeleteCustomLineItemResponse
s@DeleteCustomLineItemResponse' {} Maybe Text
a -> DeleteCustomLineItemResponse
s {$sel:arn:DeleteCustomLineItemResponse' :: Maybe Text
arn = Maybe Text
a} :: DeleteCustomLineItemResponse)

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

instance Prelude.NFData DeleteCustomLineItemResponse where
  rnf :: DeleteCustomLineItemResponse -> ()
rnf DeleteCustomLineItemResponse' {Int
Maybe Text
httpStatus :: Int
arn :: Maybe Text
$sel:httpStatus:DeleteCustomLineItemResponse' :: DeleteCustomLineItemResponse -> Int
$sel:arn:DeleteCustomLineItemResponse' :: DeleteCustomLineItemResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
arn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus