{-# 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.SecurityHub.UpdateOrganizationConfiguration
-- 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)
--
-- Used to update the configuration related to Organizations. Can only be
-- called from a Security Hub administrator account.
module Amazonka.SecurityHub.UpdateOrganizationConfiguration
  ( -- * Creating a Request
    UpdateOrganizationConfiguration (..),
    newUpdateOrganizationConfiguration,

    -- * Request Lenses
    updateOrganizationConfiguration_autoEnable,

    -- * Destructuring the Response
    UpdateOrganizationConfigurationResponse (..),
    newUpdateOrganizationConfigurationResponse,

    -- * Response Lenses
    updateOrganizationConfigurationResponse_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.SecurityHub.Types

-- | /See:/ 'newUpdateOrganizationConfiguration' smart constructor.
data UpdateOrganizationConfiguration = UpdateOrganizationConfiguration'
  { -- | Whether to automatically enable Security Hub for new accounts in the
    -- organization.
    --
    -- By default, this is @false@, and new accounts are not added
    -- automatically.
    --
    -- To automatically enable Security Hub for new accounts, set this to
    -- @true@.
    UpdateOrganizationConfiguration -> Bool
autoEnable :: Prelude.Bool
  }
  deriving (UpdateOrganizationConfiguration
-> UpdateOrganizationConfiguration -> Bool
(UpdateOrganizationConfiguration
 -> UpdateOrganizationConfiguration -> Bool)
-> (UpdateOrganizationConfiguration
    -> UpdateOrganizationConfiguration -> Bool)
-> Eq UpdateOrganizationConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateOrganizationConfiguration
-> UpdateOrganizationConfiguration -> Bool
$c/= :: UpdateOrganizationConfiguration
-> UpdateOrganizationConfiguration -> Bool
== :: UpdateOrganizationConfiguration
-> UpdateOrganizationConfiguration -> Bool
$c== :: UpdateOrganizationConfiguration
-> UpdateOrganizationConfiguration -> Bool
Prelude.Eq, ReadPrec [UpdateOrganizationConfiguration]
ReadPrec UpdateOrganizationConfiguration
Int -> ReadS UpdateOrganizationConfiguration
ReadS [UpdateOrganizationConfiguration]
(Int -> ReadS UpdateOrganizationConfiguration)
-> ReadS [UpdateOrganizationConfiguration]
-> ReadPrec UpdateOrganizationConfiguration
-> ReadPrec [UpdateOrganizationConfiguration]
-> Read UpdateOrganizationConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateOrganizationConfiguration]
$creadListPrec :: ReadPrec [UpdateOrganizationConfiguration]
readPrec :: ReadPrec UpdateOrganizationConfiguration
$creadPrec :: ReadPrec UpdateOrganizationConfiguration
readList :: ReadS [UpdateOrganizationConfiguration]
$creadList :: ReadS [UpdateOrganizationConfiguration]
readsPrec :: Int -> ReadS UpdateOrganizationConfiguration
$creadsPrec :: Int -> ReadS UpdateOrganizationConfiguration
Prelude.Read, Int -> UpdateOrganizationConfiguration -> ShowS
[UpdateOrganizationConfiguration] -> ShowS
UpdateOrganizationConfiguration -> String
(Int -> UpdateOrganizationConfiguration -> ShowS)
-> (UpdateOrganizationConfiguration -> String)
-> ([UpdateOrganizationConfiguration] -> ShowS)
-> Show UpdateOrganizationConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateOrganizationConfiguration] -> ShowS
$cshowList :: [UpdateOrganizationConfiguration] -> ShowS
show :: UpdateOrganizationConfiguration -> String
$cshow :: UpdateOrganizationConfiguration -> String
showsPrec :: Int -> UpdateOrganizationConfiguration -> ShowS
$cshowsPrec :: Int -> UpdateOrganizationConfiguration -> ShowS
Prelude.Show, (forall x.
 UpdateOrganizationConfiguration
 -> Rep UpdateOrganizationConfiguration x)
-> (forall x.
    Rep UpdateOrganizationConfiguration x
    -> UpdateOrganizationConfiguration)
-> Generic UpdateOrganizationConfiguration
forall x.
Rep UpdateOrganizationConfiguration x
-> UpdateOrganizationConfiguration
forall x.
UpdateOrganizationConfiguration
-> Rep UpdateOrganizationConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateOrganizationConfiguration x
-> UpdateOrganizationConfiguration
$cfrom :: forall x.
UpdateOrganizationConfiguration
-> Rep UpdateOrganizationConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'UpdateOrganizationConfiguration' 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:
--
-- 'autoEnable', 'updateOrganizationConfiguration_autoEnable' - Whether to automatically enable Security Hub for new accounts in the
-- organization.
--
-- By default, this is @false@, and new accounts are not added
-- automatically.
--
-- To automatically enable Security Hub for new accounts, set this to
-- @true@.
newUpdateOrganizationConfiguration ::
  -- | 'autoEnable'
  Prelude.Bool ->
  UpdateOrganizationConfiguration
newUpdateOrganizationConfiguration :: Bool -> UpdateOrganizationConfiguration
newUpdateOrganizationConfiguration Bool
pAutoEnable_ =
  UpdateOrganizationConfiguration' :: Bool -> UpdateOrganizationConfiguration
UpdateOrganizationConfiguration'
    { $sel:autoEnable:UpdateOrganizationConfiguration' :: Bool
autoEnable =
        Bool
pAutoEnable_
    }

-- | Whether to automatically enable Security Hub for new accounts in the
-- organization.
--
-- By default, this is @false@, and new accounts are not added
-- automatically.
--
-- To automatically enable Security Hub for new accounts, set this to
-- @true@.
updateOrganizationConfiguration_autoEnable :: Lens.Lens' UpdateOrganizationConfiguration Prelude.Bool
updateOrganizationConfiguration_autoEnable :: (Bool -> f Bool)
-> UpdateOrganizationConfiguration
-> f UpdateOrganizationConfiguration
updateOrganizationConfiguration_autoEnable = (UpdateOrganizationConfiguration -> Bool)
-> (UpdateOrganizationConfiguration
    -> Bool -> UpdateOrganizationConfiguration)
-> Lens
     UpdateOrganizationConfiguration
     UpdateOrganizationConfiguration
     Bool
     Bool
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateOrganizationConfiguration' {Bool
autoEnable :: Bool
$sel:autoEnable:UpdateOrganizationConfiguration' :: UpdateOrganizationConfiguration -> Bool
autoEnable} -> Bool
autoEnable) (\s :: UpdateOrganizationConfiguration
s@UpdateOrganizationConfiguration' {} Bool
a -> UpdateOrganizationConfiguration
s {$sel:autoEnable:UpdateOrganizationConfiguration' :: Bool
autoEnable = Bool
a} :: UpdateOrganizationConfiguration)

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

instance
  Prelude.NFData
    UpdateOrganizationConfiguration

instance
  Core.ToHeaders
    UpdateOrganizationConfiguration
  where
  toHeaders :: UpdateOrganizationConfiguration -> ResponseHeaders
toHeaders =
    ResponseHeaders
-> UpdateOrganizationConfiguration -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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 UpdateOrganizationConfiguration where
  toJSON :: UpdateOrganizationConfiguration -> Value
toJSON UpdateOrganizationConfiguration' {Bool
autoEnable :: Bool
$sel:autoEnable:UpdateOrganizationConfiguration' :: UpdateOrganizationConfiguration -> Bool
..} =
    [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
"AutoEnable" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Bool
autoEnable)]
      )

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

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

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

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

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

instance
  Prelude.NFData
    UpdateOrganizationConfigurationResponse