{-# 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.Organizations.EnableAllFeatures
-- 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 all features in an organization. This enables the use of
-- organization policies that can restrict the services and actions that
-- can be called in each account. Until you enable all features, you have
-- access only to consolidated billing, and you can\'t use any of the
-- advanced account administration features that AWS Organizations
-- supports. For more information, see
-- <https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_org_support-all-features.html Enabling All Features in Your Organization>
-- in the /AWS Organizations User Guide./
--
-- This operation is required only for organizations that were created
-- explicitly with only the consolidated billing features enabled. Calling
-- this operation sends a handshake to every invited account in the
-- organization. The feature set change can be finalized and the additional
-- features enabled only after all administrators in the invited accounts
-- approve the change by accepting the handshake.
--
-- After you enable all features, you can separately enable or disable
-- individual policy types in a root using EnablePolicyType and
-- DisablePolicyType. To see the status of policy types in a root, use
-- ListRoots.
--
-- After all invited member accounts accept the handshake, you finalize the
-- feature set change by accepting the handshake that contains
-- @\"Action\": \"ENABLE_ALL_FEATURES\"@. This completes the change.
--
-- After you enable all features in your organization, the management
-- account in the organization can apply policies on all member accounts.
-- These policies can restrict what users and even administrators in those
-- accounts can do. The management account can apply policies that prevent
-- accounts from leaving the organization. Ensure that your account
-- administrators are aware of this.
--
-- This operation can be called only from the organization\'s management
-- account.
module Amazonka.Organizations.EnableAllFeatures
  ( -- * Creating a Request
    EnableAllFeatures (..),
    newEnableAllFeatures,

    -- * Destructuring the Response
    EnableAllFeaturesResponse (..),
    newEnableAllFeaturesResponse,

    -- * Response Lenses
    enableAllFeaturesResponse_handshake,
    enableAllFeaturesResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Organizations.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

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

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

instance Core.AWSRequest EnableAllFeatures where
  type
    AWSResponse EnableAllFeatures =
      EnableAllFeaturesResponse
  request :: EnableAllFeatures -> Request EnableAllFeatures
request = Service -> EnableAllFeatures -> Request EnableAllFeatures
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy EnableAllFeatures
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse EnableAllFeatures)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse EnableAllFeatures))
-> Logger
-> Service
-> Proxy EnableAllFeatures
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse EnableAllFeatures)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Handshake -> Int -> EnableAllFeaturesResponse
EnableAllFeaturesResponse'
            (Maybe Handshake -> Int -> EnableAllFeaturesResponse)
-> Either String (Maybe Handshake)
-> Either String (Int -> EnableAllFeaturesResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Key -> Either String (Maybe Handshake)
forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Core..?> Key
"Handshake")
            Either String (Int -> EnableAllFeaturesResponse)
-> Either String Int -> Either String EnableAllFeaturesResponse
forall (f :: * -> *) a b. Applicative f => 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 EnableAllFeatures

instance Prelude.NFData EnableAllFeatures

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

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

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

-- | /See:/ 'newEnableAllFeaturesResponse' smart constructor.
data EnableAllFeaturesResponse = EnableAllFeaturesResponse'
  { -- | A structure that contains details about the handshake created to support
    -- this request to enable all features in the organization.
    EnableAllFeaturesResponse -> Maybe Handshake
handshake :: Prelude.Maybe Handshake,
    -- | The response's http status code.
    EnableAllFeaturesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (EnableAllFeaturesResponse -> EnableAllFeaturesResponse -> Bool
(EnableAllFeaturesResponse -> EnableAllFeaturesResponse -> Bool)
-> (EnableAllFeaturesResponse -> EnableAllFeaturesResponse -> Bool)
-> Eq EnableAllFeaturesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EnableAllFeaturesResponse -> EnableAllFeaturesResponse -> Bool
$c/= :: EnableAllFeaturesResponse -> EnableAllFeaturesResponse -> Bool
== :: EnableAllFeaturesResponse -> EnableAllFeaturesResponse -> Bool
$c== :: EnableAllFeaturesResponse -> EnableAllFeaturesResponse -> Bool
Prelude.Eq, Int -> EnableAllFeaturesResponse -> ShowS
[EnableAllFeaturesResponse] -> ShowS
EnableAllFeaturesResponse -> String
(Int -> EnableAllFeaturesResponse -> ShowS)
-> (EnableAllFeaturesResponse -> String)
-> ([EnableAllFeaturesResponse] -> ShowS)
-> Show EnableAllFeaturesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EnableAllFeaturesResponse] -> ShowS
$cshowList :: [EnableAllFeaturesResponse] -> ShowS
show :: EnableAllFeaturesResponse -> String
$cshow :: EnableAllFeaturesResponse -> String
showsPrec :: Int -> EnableAllFeaturesResponse -> ShowS
$cshowsPrec :: Int -> EnableAllFeaturesResponse -> ShowS
Prelude.Show, (forall x.
 EnableAllFeaturesResponse -> Rep EnableAllFeaturesResponse x)
-> (forall x.
    Rep EnableAllFeaturesResponse x -> EnableAllFeaturesResponse)
-> Generic EnableAllFeaturesResponse
forall x.
Rep EnableAllFeaturesResponse x -> EnableAllFeaturesResponse
forall x.
EnableAllFeaturesResponse -> Rep EnableAllFeaturesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep EnableAllFeaturesResponse x -> EnableAllFeaturesResponse
$cfrom :: forall x.
EnableAllFeaturesResponse -> Rep EnableAllFeaturesResponse x
Prelude.Generic)

-- |
-- Create a value of 'EnableAllFeaturesResponse' 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:
--
-- 'handshake', 'enableAllFeaturesResponse_handshake' - A structure that contains details about the handshake created to support
-- this request to enable all features in the organization.
--
-- 'httpStatus', 'enableAllFeaturesResponse_httpStatus' - The response's http status code.
newEnableAllFeaturesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  EnableAllFeaturesResponse
newEnableAllFeaturesResponse :: Int -> EnableAllFeaturesResponse
newEnableAllFeaturesResponse Int
pHttpStatus_ =
  EnableAllFeaturesResponse' :: Maybe Handshake -> Int -> EnableAllFeaturesResponse
EnableAllFeaturesResponse'
    { $sel:handshake:EnableAllFeaturesResponse' :: Maybe Handshake
handshake =
        Maybe Handshake
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:EnableAllFeaturesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A structure that contains details about the handshake created to support
-- this request to enable all features in the organization.
enableAllFeaturesResponse_handshake :: Lens.Lens' EnableAllFeaturesResponse (Prelude.Maybe Handshake)
enableAllFeaturesResponse_handshake :: (Maybe Handshake -> f (Maybe Handshake))
-> EnableAllFeaturesResponse -> f EnableAllFeaturesResponse
enableAllFeaturesResponse_handshake = (EnableAllFeaturesResponse -> Maybe Handshake)
-> (EnableAllFeaturesResponse
    -> Maybe Handshake -> EnableAllFeaturesResponse)
-> Lens
     EnableAllFeaturesResponse
     EnableAllFeaturesResponse
     (Maybe Handshake)
     (Maybe Handshake)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnableAllFeaturesResponse' {Maybe Handshake
handshake :: Maybe Handshake
$sel:handshake:EnableAllFeaturesResponse' :: EnableAllFeaturesResponse -> Maybe Handshake
handshake} -> Maybe Handshake
handshake) (\s :: EnableAllFeaturesResponse
s@EnableAllFeaturesResponse' {} Maybe Handshake
a -> EnableAllFeaturesResponse
s {$sel:handshake:EnableAllFeaturesResponse' :: Maybe Handshake
handshake = Maybe Handshake
a} :: EnableAllFeaturesResponse)

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

instance Prelude.NFData EnableAllFeaturesResponse