{-# 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-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 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.Lens as Lens
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
(DeletePortfolio -> DeletePortfolio -> Bool)
-> (DeletePortfolio -> DeletePortfolio -> Bool)
-> Eq DeletePortfolio
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]
(Int -> ReadS DeletePortfolio)
-> ReadS [DeletePortfolio]
-> ReadPrec DeletePortfolio
-> ReadPrec [DeletePortfolio]
-> Read 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
(Int -> DeletePortfolio -> ShowS)
-> (DeletePortfolio -> String)
-> ([DeletePortfolio] -> ShowS)
-> Show DeletePortfolio
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. DeletePortfolio -> Rep DeletePortfolio x)
-> (forall x. Rep DeletePortfolio x -> DeletePortfolio)
-> Generic DeletePortfolio
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' :: Maybe Text -> Text -> DeletePortfolio
DeletePortfolio'
    { $sel:acceptLanguage:DeletePortfolio' :: Maybe Text
acceptLanguage = Maybe Text
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 :: (Maybe Text -> f (Maybe Text))
-> DeletePortfolio -> f DeletePortfolio
deletePortfolio_acceptLanguage = (DeletePortfolio -> Maybe Text)
-> (DeletePortfolio -> Maybe Text -> DeletePortfolio)
-> Lens DeletePortfolio DeletePortfolio (Maybe Text) (Maybe Text)
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 :: (Text -> f Text) -> DeletePortfolio -> f DeletePortfolio
deletePortfolio_id = (DeletePortfolio -> Text)
-> (DeletePortfolio -> Text -> DeletePortfolio)
-> Lens DeletePortfolio DeletePortfolio Text Text
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 :: DeletePortfolio -> Request DeletePortfolio
request = Service -> DeletePortfolio -> Request DeletePortfolio
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeletePortfolio
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeletePortfolio)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DeletePortfolio))
-> Logger
-> Service
-> Proxy DeletePortfolio
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeletePortfolio)))
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 -> DeletePortfolioResponse
DeletePortfolioResponse'
            (Int -> DeletePortfolioResponse)
-> Either String Int -> Either String DeletePortfolioResponse
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 DeletePortfolio

instance Prelude.NFData DeletePortfolio

instance Core.ToHeaders DeletePortfolio where
  toHeaders :: DeletePortfolio -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeletePortfolio -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"AWS242ServiceCatalogService.DeletePortfolio" ::
                          Prelude.ByteString
                      ),
            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.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"AcceptLanguage" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
acceptLanguage,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Id" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
id)
          ]
      )

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

instance Core.ToQuery DeletePortfolio where
  toQuery :: DeletePortfolio -> QueryString
toQuery = QueryString -> DeletePortfolio -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(DeletePortfolioResponse -> DeletePortfolioResponse -> Bool)
-> (DeletePortfolioResponse -> DeletePortfolioResponse -> Bool)
-> Eq DeletePortfolioResponse
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]
(Int -> ReadS DeletePortfolioResponse)
-> ReadS [DeletePortfolioResponse]
-> ReadPrec DeletePortfolioResponse
-> ReadPrec [DeletePortfolioResponse]
-> Read 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
(Int -> DeletePortfolioResponse -> ShowS)
-> (DeletePortfolioResponse -> String)
-> ([DeletePortfolioResponse] -> ShowS)
-> Show DeletePortfolioResponse
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.
 DeletePortfolioResponse -> Rep DeletePortfolioResponse x)
-> (forall x.
    Rep DeletePortfolioResponse x -> DeletePortfolioResponse)
-> Generic DeletePortfolioResponse
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' :: Int -> DeletePortfolioResponse
DeletePortfolioResponse' {$sel:httpStatus:DeletePortfolioResponse' :: Int
httpStatus = Int
pHttpStatus_}

-- | The response's http status code.
deletePortfolioResponse_httpStatus :: Lens.Lens' DeletePortfolioResponse Prelude.Int
deletePortfolioResponse_httpStatus :: (Int -> f Int)
-> DeletePortfolioResponse -> f DeletePortfolioResponse
deletePortfolioResponse_httpStatus = (DeletePortfolioResponse -> Int)
-> (DeletePortfolioResponse -> Int -> DeletePortfolioResponse)
-> Lens DeletePortfolioResponse DeletePortfolioResponse Int Int
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