{-# 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.EnableAWSOrganizationsAccess
-- 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)
--
-- Enable portfolio sharing feature through AWS Organizations. This API
-- will allow Service Catalog to receive updates on your organization in
-- order to sync your shares with the current structure. This API can only
-- be called by the management account in the organization.
--
-- By calling this API Service Catalog will make a call to
-- organizations:EnableAWSServiceAccess on your behalf so that your shares
-- can be in sync with any changes in your AWS Organizations structure.
--
-- Note that a delegated administrator is not authorized to invoke
-- @EnableAWSOrganizationsAccess@.
module Amazonka.ServiceCatalog.EnableAWSOrganizationsAccess
  ( -- * Creating a Request
    EnableAWSOrganizationsAccess (..),
    newEnableAWSOrganizationsAccess,

    -- * Destructuring the Response
    EnableAWSOrganizationsAccessResponse (..),
    newEnableAWSOrganizationsAccessResponse,

    -- * Response Lenses
    enableAWSOrganizationsAccessResponse_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:/ 'newEnableAWSOrganizationsAccess' smart constructor.
data EnableAWSOrganizationsAccess = EnableAWSOrganizationsAccess'
  {
  }
  deriving (EnableAWSOrganizationsAccess
-> EnableAWSOrganizationsAccess -> Bool
(EnableAWSOrganizationsAccess
 -> EnableAWSOrganizationsAccess -> Bool)
-> (EnableAWSOrganizationsAccess
    -> EnableAWSOrganizationsAccess -> Bool)
-> Eq EnableAWSOrganizationsAccess
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EnableAWSOrganizationsAccess
-> EnableAWSOrganizationsAccess -> Bool
$c/= :: EnableAWSOrganizationsAccess
-> EnableAWSOrganizationsAccess -> Bool
== :: EnableAWSOrganizationsAccess
-> EnableAWSOrganizationsAccess -> Bool
$c== :: EnableAWSOrganizationsAccess
-> EnableAWSOrganizationsAccess -> Bool
Prelude.Eq, ReadPrec [EnableAWSOrganizationsAccess]
ReadPrec EnableAWSOrganizationsAccess
Int -> ReadS EnableAWSOrganizationsAccess
ReadS [EnableAWSOrganizationsAccess]
(Int -> ReadS EnableAWSOrganizationsAccess)
-> ReadS [EnableAWSOrganizationsAccess]
-> ReadPrec EnableAWSOrganizationsAccess
-> ReadPrec [EnableAWSOrganizationsAccess]
-> Read EnableAWSOrganizationsAccess
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EnableAWSOrganizationsAccess]
$creadListPrec :: ReadPrec [EnableAWSOrganizationsAccess]
readPrec :: ReadPrec EnableAWSOrganizationsAccess
$creadPrec :: ReadPrec EnableAWSOrganizationsAccess
readList :: ReadS [EnableAWSOrganizationsAccess]
$creadList :: ReadS [EnableAWSOrganizationsAccess]
readsPrec :: Int -> ReadS EnableAWSOrganizationsAccess
$creadsPrec :: Int -> ReadS EnableAWSOrganizationsAccess
Prelude.Read, Int -> EnableAWSOrganizationsAccess -> ShowS
[EnableAWSOrganizationsAccess] -> ShowS
EnableAWSOrganizationsAccess -> String
(Int -> EnableAWSOrganizationsAccess -> ShowS)
-> (EnableAWSOrganizationsAccess -> String)
-> ([EnableAWSOrganizationsAccess] -> ShowS)
-> Show EnableAWSOrganizationsAccess
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EnableAWSOrganizationsAccess] -> ShowS
$cshowList :: [EnableAWSOrganizationsAccess] -> ShowS
show :: EnableAWSOrganizationsAccess -> String
$cshow :: EnableAWSOrganizationsAccess -> String
showsPrec :: Int -> EnableAWSOrganizationsAccess -> ShowS
$cshowsPrec :: Int -> EnableAWSOrganizationsAccess -> ShowS
Prelude.Show, (forall x.
 EnableAWSOrganizationsAccess -> Rep EnableAWSOrganizationsAccess x)
-> (forall x.
    Rep EnableAWSOrganizationsAccess x -> EnableAWSOrganizationsAccess)
-> Generic EnableAWSOrganizationsAccess
forall x.
Rep EnableAWSOrganizationsAccess x -> EnableAWSOrganizationsAccess
forall x.
EnableAWSOrganizationsAccess -> Rep EnableAWSOrganizationsAccess x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep EnableAWSOrganizationsAccess x -> EnableAWSOrganizationsAccess
$cfrom :: forall x.
EnableAWSOrganizationsAccess -> Rep EnableAWSOrganizationsAccess x
Prelude.Generic)

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

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

instance Prelude.NFData EnableAWSOrganizationsAccess

instance Core.ToHeaders EnableAWSOrganizationsAccess where
  toHeaders :: EnableAWSOrganizationsAccess -> ResponseHeaders
toHeaders =
    ResponseHeaders -> EnableAWSOrganizationsAccess -> 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.EnableAWSOrganizationsAccess" ::
                          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 EnableAWSOrganizationsAccess where
  toJSON :: EnableAWSOrganizationsAccess -> Value
toJSON = Value -> EnableAWSOrganizationsAccess -> Value
forall a b. a -> b -> a
Prelude.const (Object -> Value
Core.Object Object
forall a. Monoid a => a
Prelude.mempty)

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

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

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

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

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

instance
  Prelude.NFData
    EnableAWSOrganizationsAccessResponse