{-# 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.AWSHealth.EnableHealthServiceAccessForOrganization
-- 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)
--
-- Enables AWS Health to work with AWS Organizations. You can use the
-- organizational view feature to aggregate events from all AWS accounts in
-- your organization in a centralized location.
--
-- This operation also creates a service-linked role for the management
-- account in the organization.
--
-- To call this operation, you must meet the following requirements:
--
-- -   You must have a Business or Enterprise Support plan from
--     <http://aws.amazon.com/premiumsupport/ AWS Support> to use the AWS
--     Health API. If you call the AWS Health API from an AWS account that
--     doesn\'t have a Business or Enterprise Support plan, you receive a
--     @SubscriptionRequiredException@ error.
--
-- -   You must have permission to call this operation from the
--     organization\'s management account. For example IAM policies, see
--     <https://docs.aws.amazon.com/health/latest/ug/security_iam_id-based-policy-examples.html AWS Health identity-based policy examples>.
--
-- If you don\'t have the required support plan, you can instead use the
-- AWS Health console to enable the organizational view feature. For more
-- information, see
-- <https://docs.aws.amazon.com/health/latest/ug/aggregate-events.html Aggregating AWS Health events>
-- in the /AWS Health User Guide/.
module Amazonka.AWSHealth.EnableHealthServiceAccessForOrganization
  ( -- * Creating a Request
    EnableHealthServiceAccessForOrganization (..),
    newEnableHealthServiceAccessForOrganization,

    -- * Destructuring the Response
    EnableHealthServiceAccessForOrganizationResponse (..),
    newEnableHealthServiceAccessForOrganizationResponse,
  )
where

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

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

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

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

instance
  Prelude.Hashable
    EnableHealthServiceAccessForOrganization

instance
  Prelude.NFData
    EnableHealthServiceAccessForOrganization

instance
  Core.ToHeaders
    EnableHealthServiceAccessForOrganization
  where
  toHeaders :: EnableHealthServiceAccessForOrganization -> [Header]
toHeaders =
    [Header] -> EnableHealthServiceAccessForOrganization -> [Header]
forall a b. a -> b -> a
Prelude.const
      ( [[Header]] -> [Header]
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"AWSHealth_20160804.EnableHealthServiceAccessForOrganization" ::
                          Prelude.ByteString
                      ),
            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
    EnableHealthServiceAccessForOrganization
  where
  toJSON :: EnableHealthServiceAccessForOrganization -> Value
toJSON = Value -> EnableHealthServiceAccessForOrganization -> Value
forall a b. a -> b -> a
Prelude.const (Object -> Value
Core.Object Object
forall a. Monoid a => a
Prelude.mempty)

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

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

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

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

instance
  Prelude.NFData
    EnableHealthServiceAccessForOrganizationResponse