{-# 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.RejectPortfolioShare
-- 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)
--
-- Rejects an offer to share the specified portfolio.
module Amazonka.ServiceCatalog.RejectPortfolioShare
  ( -- * Creating a Request
    RejectPortfolioShare (..),
    newRejectPortfolioShare,

    -- * Request Lenses
    rejectPortfolioShare_portfolioShareType,
    rejectPortfolioShare_acceptLanguage,
    rejectPortfolioShare_portfolioId,

    -- * Destructuring the Response
    RejectPortfolioShareResponse (..),
    newRejectPortfolioShareResponse,

    -- * Response Lenses
    rejectPortfolioShareResponse_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:/ 'newRejectPortfolioShare' smart constructor.
data RejectPortfolioShare = RejectPortfolioShare'
  { -- | The type of shared portfolios to reject. The default is to reject
    -- imported portfolios.
    --
    -- -   @AWS_ORGANIZATIONS@ - Reject portfolios shared by the management
    --     account of your organization.
    --
    -- -   @IMPORTED@ - Reject imported portfolios.
    --
    -- -   @AWS_SERVICECATALOG@ - Not supported. (Throws
    --     ResourceNotFoundException.)
    --
    -- For example,
    -- @aws servicecatalog reject-portfolio-share --portfolio-id \"port-2qwzkwxt3y5fk\" --portfolio-share-type AWS_ORGANIZATIONS@
    RejectPortfolioShare -> Maybe PortfolioShareType
portfolioShareType :: Prelude.Maybe PortfolioShareType,
    -- | The language code.
    --
    -- -   @en@ - English (default)
    --
    -- -   @jp@ - Japanese
    --
    -- -   @zh@ - Chinese
    RejectPortfolioShare -> Maybe Text
acceptLanguage :: Prelude.Maybe Prelude.Text,
    -- | The portfolio identifier.
    RejectPortfolioShare -> Text
portfolioId :: Prelude.Text
  }
  deriving (RejectPortfolioShare -> RejectPortfolioShare -> Bool
(RejectPortfolioShare -> RejectPortfolioShare -> Bool)
-> (RejectPortfolioShare -> RejectPortfolioShare -> Bool)
-> Eq RejectPortfolioShare
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RejectPortfolioShare -> RejectPortfolioShare -> Bool
$c/= :: RejectPortfolioShare -> RejectPortfolioShare -> Bool
== :: RejectPortfolioShare -> RejectPortfolioShare -> Bool
$c== :: RejectPortfolioShare -> RejectPortfolioShare -> Bool
Prelude.Eq, ReadPrec [RejectPortfolioShare]
ReadPrec RejectPortfolioShare
Int -> ReadS RejectPortfolioShare
ReadS [RejectPortfolioShare]
(Int -> ReadS RejectPortfolioShare)
-> ReadS [RejectPortfolioShare]
-> ReadPrec RejectPortfolioShare
-> ReadPrec [RejectPortfolioShare]
-> Read RejectPortfolioShare
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RejectPortfolioShare]
$creadListPrec :: ReadPrec [RejectPortfolioShare]
readPrec :: ReadPrec RejectPortfolioShare
$creadPrec :: ReadPrec RejectPortfolioShare
readList :: ReadS [RejectPortfolioShare]
$creadList :: ReadS [RejectPortfolioShare]
readsPrec :: Int -> ReadS RejectPortfolioShare
$creadsPrec :: Int -> ReadS RejectPortfolioShare
Prelude.Read, Int -> RejectPortfolioShare -> ShowS
[RejectPortfolioShare] -> ShowS
RejectPortfolioShare -> String
(Int -> RejectPortfolioShare -> ShowS)
-> (RejectPortfolioShare -> String)
-> ([RejectPortfolioShare] -> ShowS)
-> Show RejectPortfolioShare
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RejectPortfolioShare] -> ShowS
$cshowList :: [RejectPortfolioShare] -> ShowS
show :: RejectPortfolioShare -> String
$cshow :: RejectPortfolioShare -> String
showsPrec :: Int -> RejectPortfolioShare -> ShowS
$cshowsPrec :: Int -> RejectPortfolioShare -> ShowS
Prelude.Show, (forall x. RejectPortfolioShare -> Rep RejectPortfolioShare x)
-> (forall x. Rep RejectPortfolioShare x -> RejectPortfolioShare)
-> Generic RejectPortfolioShare
forall x. Rep RejectPortfolioShare x -> RejectPortfolioShare
forall x. RejectPortfolioShare -> Rep RejectPortfolioShare x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RejectPortfolioShare x -> RejectPortfolioShare
$cfrom :: forall x. RejectPortfolioShare -> Rep RejectPortfolioShare x
Prelude.Generic)

-- |
-- Create a value of 'RejectPortfolioShare' 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:
--
-- 'portfolioShareType', 'rejectPortfolioShare_portfolioShareType' - The type of shared portfolios to reject. The default is to reject
-- imported portfolios.
--
-- -   @AWS_ORGANIZATIONS@ - Reject portfolios shared by the management
--     account of your organization.
--
-- -   @IMPORTED@ - Reject imported portfolios.
--
-- -   @AWS_SERVICECATALOG@ - Not supported. (Throws
--     ResourceNotFoundException.)
--
-- For example,
-- @aws servicecatalog reject-portfolio-share --portfolio-id \"port-2qwzkwxt3y5fk\" --portfolio-share-type AWS_ORGANIZATIONS@
--
-- 'acceptLanguage', 'rejectPortfolioShare_acceptLanguage' - The language code.
--
-- -   @en@ - English (default)
--
-- -   @jp@ - Japanese
--
-- -   @zh@ - Chinese
--
-- 'portfolioId', 'rejectPortfolioShare_portfolioId' - The portfolio identifier.
newRejectPortfolioShare ::
  -- | 'portfolioId'
  Prelude.Text ->
  RejectPortfolioShare
newRejectPortfolioShare :: Text -> RejectPortfolioShare
newRejectPortfolioShare Text
pPortfolioId_ =
  RejectPortfolioShare' :: Maybe PortfolioShareType
-> Maybe Text -> Text -> RejectPortfolioShare
RejectPortfolioShare'
    { $sel:portfolioShareType:RejectPortfolioShare' :: Maybe PortfolioShareType
portfolioShareType =
        Maybe PortfolioShareType
forall a. Maybe a
Prelude.Nothing,
      $sel:acceptLanguage:RejectPortfolioShare' :: Maybe Text
acceptLanguage = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:portfolioId:RejectPortfolioShare' :: Text
portfolioId = Text
pPortfolioId_
    }

-- | The type of shared portfolios to reject. The default is to reject
-- imported portfolios.
--
-- -   @AWS_ORGANIZATIONS@ - Reject portfolios shared by the management
--     account of your organization.
--
-- -   @IMPORTED@ - Reject imported portfolios.
--
-- -   @AWS_SERVICECATALOG@ - Not supported. (Throws
--     ResourceNotFoundException.)
--
-- For example,
-- @aws servicecatalog reject-portfolio-share --portfolio-id \"port-2qwzkwxt3y5fk\" --portfolio-share-type AWS_ORGANIZATIONS@
rejectPortfolioShare_portfolioShareType :: Lens.Lens' RejectPortfolioShare (Prelude.Maybe PortfolioShareType)
rejectPortfolioShare_portfolioShareType :: (Maybe PortfolioShareType -> f (Maybe PortfolioShareType))
-> RejectPortfolioShare -> f RejectPortfolioShare
rejectPortfolioShare_portfolioShareType = (RejectPortfolioShare -> Maybe PortfolioShareType)
-> (RejectPortfolioShare
    -> Maybe PortfolioShareType -> RejectPortfolioShare)
-> Lens
     RejectPortfolioShare
     RejectPortfolioShare
     (Maybe PortfolioShareType)
     (Maybe PortfolioShareType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RejectPortfolioShare' {Maybe PortfolioShareType
portfolioShareType :: Maybe PortfolioShareType
$sel:portfolioShareType:RejectPortfolioShare' :: RejectPortfolioShare -> Maybe PortfolioShareType
portfolioShareType} -> Maybe PortfolioShareType
portfolioShareType) (\s :: RejectPortfolioShare
s@RejectPortfolioShare' {} Maybe PortfolioShareType
a -> RejectPortfolioShare
s {$sel:portfolioShareType:RejectPortfolioShare' :: Maybe PortfolioShareType
portfolioShareType = Maybe PortfolioShareType
a} :: RejectPortfolioShare)

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

-- | The portfolio identifier.
rejectPortfolioShare_portfolioId :: Lens.Lens' RejectPortfolioShare Prelude.Text
rejectPortfolioShare_portfolioId :: (Text -> f Text) -> RejectPortfolioShare -> f RejectPortfolioShare
rejectPortfolioShare_portfolioId = (RejectPortfolioShare -> Text)
-> (RejectPortfolioShare -> Text -> RejectPortfolioShare)
-> Lens RejectPortfolioShare RejectPortfolioShare Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RejectPortfolioShare' {Text
portfolioId :: Text
$sel:portfolioId:RejectPortfolioShare' :: RejectPortfolioShare -> Text
portfolioId} -> Text
portfolioId) (\s :: RejectPortfolioShare
s@RejectPortfolioShare' {} Text
a -> RejectPortfolioShare
s {$sel:portfolioId:RejectPortfolioShare' :: Text
portfolioId = Text
a} :: RejectPortfolioShare)

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

instance Prelude.NFData RejectPortfolioShare

instance Core.ToHeaders RejectPortfolioShare where
  toHeaders :: RejectPortfolioShare -> ResponseHeaders
toHeaders =
    ResponseHeaders -> RejectPortfolioShare -> 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.RejectPortfolioShare" ::
                          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 RejectPortfolioShare where
  toJSON :: RejectPortfolioShare -> Value
toJSON RejectPortfolioShare' {Maybe Text
Maybe PortfolioShareType
Text
portfolioId :: Text
acceptLanguage :: Maybe Text
portfolioShareType :: Maybe PortfolioShareType
$sel:portfolioId:RejectPortfolioShare' :: RejectPortfolioShare -> Text
$sel:acceptLanguage:RejectPortfolioShare' :: RejectPortfolioShare -> Maybe Text
$sel:portfolioShareType:RejectPortfolioShare' :: RejectPortfolioShare -> Maybe PortfolioShareType
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"PortfolioShareType" Text -> PortfolioShareType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (PortfolioShareType -> Pair)
-> Maybe PortfolioShareType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe PortfolioShareType
portfolioShareType,
            (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
"PortfolioId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
portfolioId)
          ]
      )

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

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

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

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

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

instance Prelude.NFData RejectPortfolioShareResponse