{-# 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.IoT.DeleteBillingGroup
-- 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 the billing group.
--
-- Requires permission to access the
-- <https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiot.html#awsiot-actions-as-permissions DeleteBillingGroup>
-- action.
module Amazonka.IoT.DeleteBillingGroup
  ( -- * Creating a Request
    DeleteBillingGroup (..),
    newDeleteBillingGroup,

    -- * Request Lenses
    deleteBillingGroup_expectedVersion,
    deleteBillingGroup_billingGroupName,

    -- * Destructuring the Response
    DeleteBillingGroupResponse (..),
    newDeleteBillingGroupResponse,

    -- * Response Lenses
    deleteBillingGroupResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.IoT.Types
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:/ 'newDeleteBillingGroup' smart constructor.
data DeleteBillingGroup = DeleteBillingGroup'
  { -- | The expected version of the billing group. If the version of the billing
    -- group does not match the expected version specified in the request, the
    -- @DeleteBillingGroup@ request is rejected with a
    -- @VersionConflictException@.
    DeleteBillingGroup -> Maybe Integer
expectedVersion :: Prelude.Maybe Prelude.Integer,
    -- | The name of the billing group.
    DeleteBillingGroup -> Text
billingGroupName :: Prelude.Text
  }
  deriving (DeleteBillingGroup -> DeleteBillingGroup -> Bool
(DeleteBillingGroup -> DeleteBillingGroup -> Bool)
-> (DeleteBillingGroup -> DeleteBillingGroup -> Bool)
-> Eq DeleteBillingGroup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteBillingGroup -> DeleteBillingGroup -> Bool
$c/= :: DeleteBillingGroup -> DeleteBillingGroup -> Bool
== :: DeleteBillingGroup -> DeleteBillingGroup -> Bool
$c== :: DeleteBillingGroup -> DeleteBillingGroup -> Bool
Prelude.Eq, ReadPrec [DeleteBillingGroup]
ReadPrec DeleteBillingGroup
Int -> ReadS DeleteBillingGroup
ReadS [DeleteBillingGroup]
(Int -> ReadS DeleteBillingGroup)
-> ReadS [DeleteBillingGroup]
-> ReadPrec DeleteBillingGroup
-> ReadPrec [DeleteBillingGroup]
-> Read DeleteBillingGroup
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteBillingGroup]
$creadListPrec :: ReadPrec [DeleteBillingGroup]
readPrec :: ReadPrec DeleteBillingGroup
$creadPrec :: ReadPrec DeleteBillingGroup
readList :: ReadS [DeleteBillingGroup]
$creadList :: ReadS [DeleteBillingGroup]
readsPrec :: Int -> ReadS DeleteBillingGroup
$creadsPrec :: Int -> ReadS DeleteBillingGroup
Prelude.Read, Int -> DeleteBillingGroup -> ShowS
[DeleteBillingGroup] -> ShowS
DeleteBillingGroup -> String
(Int -> DeleteBillingGroup -> ShowS)
-> (DeleteBillingGroup -> String)
-> ([DeleteBillingGroup] -> ShowS)
-> Show DeleteBillingGroup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteBillingGroup] -> ShowS
$cshowList :: [DeleteBillingGroup] -> ShowS
show :: DeleteBillingGroup -> String
$cshow :: DeleteBillingGroup -> String
showsPrec :: Int -> DeleteBillingGroup -> ShowS
$cshowsPrec :: Int -> DeleteBillingGroup -> ShowS
Prelude.Show, (forall x. DeleteBillingGroup -> Rep DeleteBillingGroup x)
-> (forall x. Rep DeleteBillingGroup x -> DeleteBillingGroup)
-> Generic DeleteBillingGroup
forall x. Rep DeleteBillingGroup x -> DeleteBillingGroup
forall x. DeleteBillingGroup -> Rep DeleteBillingGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteBillingGroup x -> DeleteBillingGroup
$cfrom :: forall x. DeleteBillingGroup -> Rep DeleteBillingGroup x
Prelude.Generic)

-- |
-- Create a value of 'DeleteBillingGroup' 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:
--
-- 'expectedVersion', 'deleteBillingGroup_expectedVersion' - The expected version of the billing group. If the version of the billing
-- group does not match the expected version specified in the request, the
-- @DeleteBillingGroup@ request is rejected with a
-- @VersionConflictException@.
--
-- 'billingGroupName', 'deleteBillingGroup_billingGroupName' - The name of the billing group.
newDeleteBillingGroup ::
  -- | 'billingGroupName'
  Prelude.Text ->
  DeleteBillingGroup
newDeleteBillingGroup :: Text -> DeleteBillingGroup
newDeleteBillingGroup Text
pBillingGroupName_ =
  DeleteBillingGroup' :: Maybe Integer -> Text -> DeleteBillingGroup
DeleteBillingGroup'
    { $sel:expectedVersion:DeleteBillingGroup' :: Maybe Integer
expectedVersion =
        Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:billingGroupName:DeleteBillingGroup' :: Text
billingGroupName = Text
pBillingGroupName_
    }

-- | The expected version of the billing group. If the version of the billing
-- group does not match the expected version specified in the request, the
-- @DeleteBillingGroup@ request is rejected with a
-- @VersionConflictException@.
deleteBillingGroup_expectedVersion :: Lens.Lens' DeleteBillingGroup (Prelude.Maybe Prelude.Integer)
deleteBillingGroup_expectedVersion :: (Maybe Integer -> f (Maybe Integer))
-> DeleteBillingGroup -> f DeleteBillingGroup
deleteBillingGroup_expectedVersion = (DeleteBillingGroup -> Maybe Integer)
-> (DeleteBillingGroup -> Maybe Integer -> DeleteBillingGroup)
-> Lens
     DeleteBillingGroup
     DeleteBillingGroup
     (Maybe Integer)
     (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteBillingGroup' {Maybe Integer
expectedVersion :: Maybe Integer
$sel:expectedVersion:DeleteBillingGroup' :: DeleteBillingGroup -> Maybe Integer
expectedVersion} -> Maybe Integer
expectedVersion) (\s :: DeleteBillingGroup
s@DeleteBillingGroup' {} Maybe Integer
a -> DeleteBillingGroup
s {$sel:expectedVersion:DeleteBillingGroup' :: Maybe Integer
expectedVersion = Maybe Integer
a} :: DeleteBillingGroup)

-- | The name of the billing group.
deleteBillingGroup_billingGroupName :: Lens.Lens' DeleteBillingGroup Prelude.Text
deleteBillingGroup_billingGroupName :: (Text -> f Text) -> DeleteBillingGroup -> f DeleteBillingGroup
deleteBillingGroup_billingGroupName = (DeleteBillingGroup -> Text)
-> (DeleteBillingGroup -> Text -> DeleteBillingGroup)
-> Lens DeleteBillingGroup DeleteBillingGroup Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteBillingGroup' {Text
billingGroupName :: Text
$sel:billingGroupName:DeleteBillingGroup' :: DeleteBillingGroup -> Text
billingGroupName} -> Text
billingGroupName) (\s :: DeleteBillingGroup
s@DeleteBillingGroup' {} Text
a -> DeleteBillingGroup
s {$sel:billingGroupName:DeleteBillingGroup' :: Text
billingGroupName = Text
a} :: DeleteBillingGroup)

instance Core.AWSRequest DeleteBillingGroup where
  type
    AWSResponse DeleteBillingGroup =
      DeleteBillingGroupResponse
  request :: DeleteBillingGroup -> Request DeleteBillingGroup
request = Service -> DeleteBillingGroup -> Request DeleteBillingGroup
forall a. ToRequest a => Service -> a -> Request a
Request.delete Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteBillingGroup
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteBillingGroup)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DeleteBillingGroup))
-> Logger
-> Service
-> Proxy DeleteBillingGroup
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteBillingGroup)))
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 -> DeleteBillingGroupResponse
DeleteBillingGroupResponse'
            (Int -> DeleteBillingGroupResponse)
-> Either String Int -> Either String DeleteBillingGroupResponse
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 DeleteBillingGroup

instance Prelude.NFData DeleteBillingGroup

instance Core.ToHeaders DeleteBillingGroup where
  toHeaders :: DeleteBillingGroup -> ResponseHeaders
toHeaders = ResponseHeaders -> DeleteBillingGroup -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

instance Core.ToPath DeleteBillingGroup where
  toPath :: DeleteBillingGroup -> ByteString
toPath DeleteBillingGroup' {Maybe Integer
Text
billingGroupName :: Text
expectedVersion :: Maybe Integer
$sel:billingGroupName:DeleteBillingGroup' :: DeleteBillingGroup -> Text
$sel:expectedVersion:DeleteBillingGroup' :: DeleteBillingGroup -> Maybe Integer
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/billing-groups/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
billingGroupName]

instance Core.ToQuery DeleteBillingGroup where
  toQuery :: DeleteBillingGroup -> QueryString
toQuery DeleteBillingGroup' {Maybe Integer
Text
billingGroupName :: Text
expectedVersion :: Maybe Integer
$sel:billingGroupName:DeleteBillingGroup' :: DeleteBillingGroup -> Text
$sel:expectedVersion:DeleteBillingGroup' :: DeleteBillingGroup -> Maybe Integer
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"expectedVersion" ByteString -> Maybe Integer -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Integer
expectedVersion]

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

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

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

instance Prelude.NFData DeleteBillingGroupResponse