{-# 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.ServiceCatalog.DeletePortfolio
-- 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 specified portfolio.
--
-- You cannot delete a portfolio if it was shared with you or if it has
-- associated products, users, constraints, or shared accounts.
--
-- A delegated admin is authorized to invoke this command.
module Amazonka.ServiceCatalog.DeletePortfolio
  ( -- * Creating a Request
    DeletePortfolio (..),
    newDeletePortfolio,

    -- * Request Lenses
    deletePortfolio_acceptLanguage,
    deletePortfolio_id,

    -- * Destructuring the Response
    DeletePortfolioResponse (..),
    newDeletePortfolioResponse,

    -- * Response Lenses
    deletePortfolioResponse_httpStatus,
  )
where

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
import Amazonka.ServiceCatalog.Types

-- | /See:/ 'newDeletePortfolio' smart constructor.
data DeletePortfolio = DeletePortfolio'
  { -- | The language code.
    --
    -- -   @en@ - English (default)
    --
    -- -   @jp@ - Japanese
    --
    -- -   @zh@ - Chinese
    DeletePortfolio -> Maybe Text
acceptLanguage :: Prelude.Maybe Prelude.Text,
    -- | The portfolio identifier.
    DeletePortfolio -> Text
id :: Prelude.Text
  }
  deriving (DeletePortfolio -> DeletePortfolio -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeletePortfolio -> DeletePortfolio -> Bool
$c/= :: DeletePortfolio -> DeletePortfolio -> Bool
== :: DeletePortfolio -> DeletePortfolio -> Bool
$c== :: DeletePortfolio -> DeletePortfolio -> Bool
Prelude.Eq, ReadPrec [DeletePortfolio]
ReadPrec DeletePortfolio
Int -> ReadS DeletePortfolio
ReadS [DeletePortfolio]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeletePortfolio]
$creadListPrec :: ReadPrec [DeletePortfolio]
readPrec :: ReadPrec DeletePortfolio
$creadPrec :: ReadPrec DeletePortfolio
readList :: ReadS [DeletePortfolio]
$creadList :: ReadS [DeletePortfolio]
readsPrec :: Int -> ReadS DeletePortfolio
$creadsPrec :: Int -> ReadS DeletePortfolio
Prelude.Read, Int -> DeletePortfolio -> ShowS
[DeletePortfolio] -> ShowS
DeletePortfolio -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeletePortfolio] -> ShowS
$cshowList :: [DeletePortfolio] -> ShowS
show :: DeletePortfolio -> String
$cshow :: DeletePortfolio -> String
showsPrec :: Int -> DeletePortfolio -> ShowS
$cshowsPrec :: Int -> DeletePortfolio -> ShowS
Prelude.Show, forall x. Rep DeletePortfolio x -> DeletePortfolio
forall x. DeletePortfolio -> Rep DeletePortfolio x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeletePortfolio x -> DeletePortfolio
$cfrom :: forall x. DeletePortfolio -> Rep DeletePortfolio x
Prelude.Generic)

-- |
-- Create a value of 'DeletePortfolio' 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:
--
-- 'acceptLanguage', 'deletePortfolio_acceptLanguage' - The language code.
--
-- -   @en@ - English (default)
--
-- -   @jp@ - Japanese
--
-- -   @zh@ - Chinese
--
-- 'id', 'deletePortfolio_id' - The portfolio identifier.
newDeletePortfolio ::
  -- | 'id'
  Prelude.Text ->
  DeletePortfolio
newDeletePortfolio :: Text -> DeletePortfolio
newDeletePortfolio Text
pId_ =
  DeletePortfolio'
    { $sel:acceptLanguage:DeletePortfolio' :: Maybe Text
acceptLanguage = forall a. Maybe a
Prelude.Nothing,
      $sel:id:DeletePortfolio' :: Text
id = Text
pId_
    }

-- | The language code.
--
-- -   @en@ - English (default)
--
-- -   @jp@ - Japanese
--
-- -   @zh@ - Chinese
deletePortfolio_acceptLanguage :: Lens.Lens' DeletePortfolio (Prelude.Maybe Prelude.Text)
deletePortfolio_acceptLanguage :: Lens' DeletePortfolio (Maybe Text)
deletePortfolio_acceptLanguage = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeletePortfolio' {Maybe Text
acceptLanguage :: Maybe Text
$sel:acceptLanguage:DeletePortfolio' :: DeletePortfolio -> Maybe Text
acceptLanguage} -> Maybe Text
acceptLanguage) (\s :: DeletePortfolio
s@DeletePortfolio' {} Maybe Text
a -> DeletePortfolio
s {$sel:acceptLanguage:DeletePortfolio' :: Maybe Text
acceptLanguage = Maybe Text
a} :: DeletePortfolio)

-- | The portfolio identifier.
deletePortfolio_id :: Lens.Lens' DeletePortfolio Prelude.Text
deletePortfolio_id :: Lens' DeletePortfolio Text
deletePortfolio_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeletePortfolio' {Text
id :: Text
$sel:id:DeletePortfolio' :: DeletePortfolio -> Text
id} -> Text
id) (\s :: DeletePortfolio
s@DeletePortfolio' {} Text
a -> DeletePortfolio
s {$sel:id:DeletePortfolio' :: Text
id = Text
a} :: DeletePortfolio)

instance Core.AWSRequest DeletePortfolio where
  type
    AWSResponse DeletePortfolio =
      DeletePortfolioResponse
  request :: (Service -> Service) -> DeletePortfolio -> Request DeletePortfolio
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 DeletePortfolio
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeletePortfolio)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> DeletePortfolioResponse
DeletePortfolioResponse'
            forall (f :: * -> *) a b. Functor 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 DeletePortfolio where
  hashWithSalt :: Int -> DeletePortfolio -> Int
hashWithSalt Int
_salt DeletePortfolio' {Maybe Text
Text
id :: Text
acceptLanguage :: Maybe Text
$sel:id:DeletePortfolio' :: DeletePortfolio -> Text
$sel:acceptLanguage:DeletePortfolio' :: DeletePortfolio -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
acceptLanguage
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
id

instance Prelude.NFData DeletePortfolio where
  rnf :: DeletePortfolio -> ()
rnf DeletePortfolio' {Maybe Text
Text
id :: Text
acceptLanguage :: Maybe Text
$sel:id:DeletePortfolio' :: DeletePortfolio -> Text
$sel:acceptLanguage:DeletePortfolio' :: DeletePortfolio -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
acceptLanguage
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
id

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

instance Data.ToJSON DeletePortfolio where
  toJSON :: DeletePortfolio -> Value
toJSON DeletePortfolio' {Maybe Text
Text
id :: Text
acceptLanguage :: Maybe Text
$sel:id:DeletePortfolio' :: DeletePortfolio -> Text
$sel:acceptLanguage:DeletePortfolio' :: DeletePortfolio -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"AcceptLanguage" 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 Text
acceptLanguage,
            forall a. a -> Maybe a
Prelude.Just (Key
"Id" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
id)
          ]
      )

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

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

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

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

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

instance Prelude.NFData DeletePortfolioResponse where
  rnf :: DeletePortfolioResponse -> ()
rnf DeletePortfolioResponse' {Int
httpStatus :: Int
$sel:httpStatus:DeletePortfolioResponse' :: DeletePortfolioResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus