{-# 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.ServerlessApplicationRepository.UnshareApplication
-- 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)
--
-- Unshares an application from an AWS Organization.
--
-- This operation can be called only from the organization\'s master
-- account.
module Amazonka.ServerlessApplicationRepository.UnshareApplication
  ( -- * Creating a Request
    UnshareApplication (..),
    newUnshareApplication,

    -- * Request Lenses
    unshareApplication_applicationId,
    unshareApplication_organizationId,

    -- * Destructuring the Response
    UnshareApplicationResponse (..),
    newUnshareApplicationResponse,
  )
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.ServerlessApplicationRepository.Types

-- | /See:/ 'newUnshareApplication' smart constructor.
data UnshareApplication = UnshareApplication'
  { -- | The Amazon Resource Name (ARN) of the application.
    UnshareApplication -> Text
applicationId :: Prelude.Text,
    -- | The AWS Organization ID to unshare the application from.
    UnshareApplication -> Text
organizationId :: Prelude.Text
  }
  deriving (UnshareApplication -> UnshareApplication -> Bool
(UnshareApplication -> UnshareApplication -> Bool)
-> (UnshareApplication -> UnshareApplication -> Bool)
-> Eq UnshareApplication
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UnshareApplication -> UnshareApplication -> Bool
$c/= :: UnshareApplication -> UnshareApplication -> Bool
== :: UnshareApplication -> UnshareApplication -> Bool
$c== :: UnshareApplication -> UnshareApplication -> Bool
Prelude.Eq, ReadPrec [UnshareApplication]
ReadPrec UnshareApplication
Int -> ReadS UnshareApplication
ReadS [UnshareApplication]
(Int -> ReadS UnshareApplication)
-> ReadS [UnshareApplication]
-> ReadPrec UnshareApplication
-> ReadPrec [UnshareApplication]
-> Read UnshareApplication
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UnshareApplication]
$creadListPrec :: ReadPrec [UnshareApplication]
readPrec :: ReadPrec UnshareApplication
$creadPrec :: ReadPrec UnshareApplication
readList :: ReadS [UnshareApplication]
$creadList :: ReadS [UnshareApplication]
readsPrec :: Int -> ReadS UnshareApplication
$creadsPrec :: Int -> ReadS UnshareApplication
Prelude.Read, Int -> UnshareApplication -> ShowS
[UnshareApplication] -> ShowS
UnshareApplication -> String
(Int -> UnshareApplication -> ShowS)
-> (UnshareApplication -> String)
-> ([UnshareApplication] -> ShowS)
-> Show UnshareApplication
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UnshareApplication] -> ShowS
$cshowList :: [UnshareApplication] -> ShowS
show :: UnshareApplication -> String
$cshow :: UnshareApplication -> String
showsPrec :: Int -> UnshareApplication -> ShowS
$cshowsPrec :: Int -> UnshareApplication -> ShowS
Prelude.Show, (forall x. UnshareApplication -> Rep UnshareApplication x)
-> (forall x. Rep UnshareApplication x -> UnshareApplication)
-> Generic UnshareApplication
forall x. Rep UnshareApplication x -> UnshareApplication
forall x. UnshareApplication -> Rep UnshareApplication x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UnshareApplication x -> UnshareApplication
$cfrom :: forall x. UnshareApplication -> Rep UnshareApplication x
Prelude.Generic)

-- |
-- Create a value of 'UnshareApplication' 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:
--
-- 'applicationId', 'unshareApplication_applicationId' - The Amazon Resource Name (ARN) of the application.
--
-- 'organizationId', 'unshareApplication_organizationId' - The AWS Organization ID to unshare the application from.
newUnshareApplication ::
  -- | 'applicationId'
  Prelude.Text ->
  -- | 'organizationId'
  Prelude.Text ->
  UnshareApplication
newUnshareApplication :: Text -> Text -> UnshareApplication
newUnshareApplication
  Text
pApplicationId_
  Text
pOrganizationId_ =
    UnshareApplication' :: Text -> Text -> UnshareApplication
UnshareApplication'
      { $sel:applicationId:UnshareApplication' :: Text
applicationId =
          Text
pApplicationId_,
        $sel:organizationId:UnshareApplication' :: Text
organizationId = Text
pOrganizationId_
      }

-- | The Amazon Resource Name (ARN) of the application.
unshareApplication_applicationId :: Lens.Lens' UnshareApplication Prelude.Text
unshareApplication_applicationId :: (Text -> f Text) -> UnshareApplication -> f UnshareApplication
unshareApplication_applicationId = (UnshareApplication -> Text)
-> (UnshareApplication -> Text -> UnshareApplication)
-> Lens UnshareApplication UnshareApplication Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UnshareApplication' {Text
applicationId :: Text
$sel:applicationId:UnshareApplication' :: UnshareApplication -> Text
applicationId} -> Text
applicationId) (\s :: UnshareApplication
s@UnshareApplication' {} Text
a -> UnshareApplication
s {$sel:applicationId:UnshareApplication' :: Text
applicationId = Text
a} :: UnshareApplication)

-- | The AWS Organization ID to unshare the application from.
unshareApplication_organizationId :: Lens.Lens' UnshareApplication Prelude.Text
unshareApplication_organizationId :: (Text -> f Text) -> UnshareApplication -> f UnshareApplication
unshareApplication_organizationId = (UnshareApplication -> Text)
-> (UnshareApplication -> Text -> UnshareApplication)
-> Lens UnshareApplication UnshareApplication Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UnshareApplication' {Text
organizationId :: Text
$sel:organizationId:UnshareApplication' :: UnshareApplication -> Text
organizationId} -> Text
organizationId) (\s :: UnshareApplication
s@UnshareApplication' {} Text
a -> UnshareApplication
s {$sel:organizationId:UnshareApplication' :: Text
organizationId = Text
a} :: UnshareApplication)

instance Core.AWSRequest UnshareApplication where
  type
    AWSResponse UnshareApplication =
      UnshareApplicationResponse
  request :: UnshareApplication -> Request UnshareApplication
request = Service -> UnshareApplication -> Request UnshareApplication
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UnshareApplication
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UnshareApplication)))
response =
    AWSResponse UnshareApplication
-> Logger
-> Service
-> Proxy UnshareApplication
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UnshareApplication)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse UnshareApplication
UnshareApplicationResponse
UnshareApplicationResponse'

instance Prelude.Hashable UnshareApplication

instance Prelude.NFData UnshareApplication

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

instance Core.ToJSON UnshareApplication where
  toJSON :: UnshareApplication -> Value
toJSON UnshareApplication' {Text
organizationId :: Text
applicationId :: Text
$sel:organizationId:UnshareApplication' :: UnshareApplication -> Text
$sel:applicationId:UnshareApplication' :: UnshareApplication -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"organizationId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
organizationId)
          ]
      )

instance Core.ToPath UnshareApplication where
  toPath :: UnshareApplication -> ByteString
toPath UnshareApplication' {Text
organizationId :: Text
applicationId :: Text
$sel:organizationId:UnshareApplication' :: UnshareApplication -> Text
$sel:applicationId:UnshareApplication' :: UnshareApplication -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/applications/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
applicationId,
        ByteString
"/unshare"
      ]

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

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

-- |
-- Create a value of 'UnshareApplicationResponse' 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.
newUnshareApplicationResponse ::
  UnshareApplicationResponse
newUnshareApplicationResponse :: UnshareApplicationResponse
newUnshareApplicationResponse =
  UnshareApplicationResponse
UnshareApplicationResponse'

instance Prelude.NFData UnshareApplicationResponse