{-# 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.LicenseManager.UpdateServiceSettings
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Updates License Manager settings for the current Region.
module Amazonka.LicenseManager.UpdateServiceSettings
  ( -- * Creating a Request
    UpdateServiceSettings (..),
    newUpdateServiceSettings,

    -- * Request Lenses
    updateServiceSettings_enableCrossAccountsDiscovery,
    updateServiceSettings_organizationConfiguration,
    updateServiceSettings_s3BucketArn,
    updateServiceSettings_snsTopicArn,

    -- * Destructuring the Response
    UpdateServiceSettingsResponse (..),
    newUpdateServiceSettingsResponse,

    -- * Response Lenses
    updateServiceSettingsResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.LicenseManager.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newUpdateServiceSettings' smart constructor.
data UpdateServiceSettings = UpdateServiceSettings'
  { -- | Activates cross-account discovery.
    UpdateServiceSettings -> Maybe Bool
enableCrossAccountsDiscovery :: Prelude.Maybe Prelude.Bool,
    -- | Enables integration with Organizations for cross-account discovery.
    UpdateServiceSettings -> Maybe OrganizationConfiguration
organizationConfiguration :: Prelude.Maybe OrganizationConfiguration,
    -- | Amazon Resource Name (ARN) of the Amazon S3 bucket where the License
    -- Manager information is stored.
    UpdateServiceSettings -> Maybe Text
s3BucketArn :: Prelude.Maybe Prelude.Text,
    -- | Amazon Resource Name (ARN) of the Amazon SNS topic used for License
    -- Manager alerts.
    UpdateServiceSettings -> Maybe Text
snsTopicArn :: Prelude.Maybe Prelude.Text
  }
  deriving (UpdateServiceSettings -> UpdateServiceSettings -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateServiceSettings -> UpdateServiceSettings -> Bool
$c/= :: UpdateServiceSettings -> UpdateServiceSettings -> Bool
== :: UpdateServiceSettings -> UpdateServiceSettings -> Bool
$c== :: UpdateServiceSettings -> UpdateServiceSettings -> Bool
Prelude.Eq, ReadPrec [UpdateServiceSettings]
ReadPrec UpdateServiceSettings
Int -> ReadS UpdateServiceSettings
ReadS [UpdateServiceSettings]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateServiceSettings]
$creadListPrec :: ReadPrec [UpdateServiceSettings]
readPrec :: ReadPrec UpdateServiceSettings
$creadPrec :: ReadPrec UpdateServiceSettings
readList :: ReadS [UpdateServiceSettings]
$creadList :: ReadS [UpdateServiceSettings]
readsPrec :: Int -> ReadS UpdateServiceSettings
$creadsPrec :: Int -> ReadS UpdateServiceSettings
Prelude.Read, Int -> UpdateServiceSettings -> ShowS
[UpdateServiceSettings] -> ShowS
UpdateServiceSettings -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateServiceSettings] -> ShowS
$cshowList :: [UpdateServiceSettings] -> ShowS
show :: UpdateServiceSettings -> String
$cshow :: UpdateServiceSettings -> String
showsPrec :: Int -> UpdateServiceSettings -> ShowS
$cshowsPrec :: Int -> UpdateServiceSettings -> ShowS
Prelude.Show, forall x. Rep UpdateServiceSettings x -> UpdateServiceSettings
forall x. UpdateServiceSettings -> Rep UpdateServiceSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateServiceSettings x -> UpdateServiceSettings
$cfrom :: forall x. UpdateServiceSettings -> Rep UpdateServiceSettings x
Prelude.Generic)

-- |
-- Create a value of 'UpdateServiceSettings' 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:
--
-- 'enableCrossAccountsDiscovery', 'updateServiceSettings_enableCrossAccountsDiscovery' - Activates cross-account discovery.
--
-- 'organizationConfiguration', 'updateServiceSettings_organizationConfiguration' - Enables integration with Organizations for cross-account discovery.
--
-- 's3BucketArn', 'updateServiceSettings_s3BucketArn' - Amazon Resource Name (ARN) of the Amazon S3 bucket where the License
-- Manager information is stored.
--
-- 'snsTopicArn', 'updateServiceSettings_snsTopicArn' - Amazon Resource Name (ARN) of the Amazon SNS topic used for License
-- Manager alerts.
newUpdateServiceSettings ::
  UpdateServiceSettings
newUpdateServiceSettings :: UpdateServiceSettings
newUpdateServiceSettings =
  UpdateServiceSettings'
    { $sel:enableCrossAccountsDiscovery:UpdateServiceSettings' :: Maybe Bool
enableCrossAccountsDiscovery =
        forall a. Maybe a
Prelude.Nothing,
      $sel:organizationConfiguration:UpdateServiceSettings' :: Maybe OrganizationConfiguration
organizationConfiguration = forall a. Maybe a
Prelude.Nothing,
      $sel:s3BucketArn:UpdateServiceSettings' :: Maybe Text
s3BucketArn = forall a. Maybe a
Prelude.Nothing,
      $sel:snsTopicArn:UpdateServiceSettings' :: Maybe Text
snsTopicArn = forall a. Maybe a
Prelude.Nothing
    }

-- | Activates cross-account discovery.
updateServiceSettings_enableCrossAccountsDiscovery :: Lens.Lens' UpdateServiceSettings (Prelude.Maybe Prelude.Bool)
updateServiceSettings_enableCrossAccountsDiscovery :: Lens' UpdateServiceSettings (Maybe Bool)
updateServiceSettings_enableCrossAccountsDiscovery = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateServiceSettings' {Maybe Bool
enableCrossAccountsDiscovery :: Maybe Bool
$sel:enableCrossAccountsDiscovery:UpdateServiceSettings' :: UpdateServiceSettings -> Maybe Bool
enableCrossAccountsDiscovery} -> Maybe Bool
enableCrossAccountsDiscovery) (\s :: UpdateServiceSettings
s@UpdateServiceSettings' {} Maybe Bool
a -> UpdateServiceSettings
s {$sel:enableCrossAccountsDiscovery:UpdateServiceSettings' :: Maybe Bool
enableCrossAccountsDiscovery = Maybe Bool
a} :: UpdateServiceSettings)

-- | Enables integration with Organizations for cross-account discovery.
updateServiceSettings_organizationConfiguration :: Lens.Lens' UpdateServiceSettings (Prelude.Maybe OrganizationConfiguration)
updateServiceSettings_organizationConfiguration :: Lens' UpdateServiceSettings (Maybe OrganizationConfiguration)
updateServiceSettings_organizationConfiguration = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateServiceSettings' {Maybe OrganizationConfiguration
organizationConfiguration :: Maybe OrganizationConfiguration
$sel:organizationConfiguration:UpdateServiceSettings' :: UpdateServiceSettings -> Maybe OrganizationConfiguration
organizationConfiguration} -> Maybe OrganizationConfiguration
organizationConfiguration) (\s :: UpdateServiceSettings
s@UpdateServiceSettings' {} Maybe OrganizationConfiguration
a -> UpdateServiceSettings
s {$sel:organizationConfiguration:UpdateServiceSettings' :: Maybe OrganizationConfiguration
organizationConfiguration = Maybe OrganizationConfiguration
a} :: UpdateServiceSettings)

-- | Amazon Resource Name (ARN) of the Amazon S3 bucket where the License
-- Manager information is stored.
updateServiceSettings_s3BucketArn :: Lens.Lens' UpdateServiceSettings (Prelude.Maybe Prelude.Text)
updateServiceSettings_s3BucketArn :: Lens' UpdateServiceSettings (Maybe Text)
updateServiceSettings_s3BucketArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateServiceSettings' {Maybe Text
s3BucketArn :: Maybe Text
$sel:s3BucketArn:UpdateServiceSettings' :: UpdateServiceSettings -> Maybe Text
s3BucketArn} -> Maybe Text
s3BucketArn) (\s :: UpdateServiceSettings
s@UpdateServiceSettings' {} Maybe Text
a -> UpdateServiceSettings
s {$sel:s3BucketArn:UpdateServiceSettings' :: Maybe Text
s3BucketArn = Maybe Text
a} :: UpdateServiceSettings)

-- | Amazon Resource Name (ARN) of the Amazon SNS topic used for License
-- Manager alerts.
updateServiceSettings_snsTopicArn :: Lens.Lens' UpdateServiceSettings (Prelude.Maybe Prelude.Text)
updateServiceSettings_snsTopicArn :: Lens' UpdateServiceSettings (Maybe Text)
updateServiceSettings_snsTopicArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateServiceSettings' {Maybe Text
snsTopicArn :: Maybe Text
$sel:snsTopicArn:UpdateServiceSettings' :: UpdateServiceSettings -> Maybe Text
snsTopicArn} -> Maybe Text
snsTopicArn) (\s :: UpdateServiceSettings
s@UpdateServiceSettings' {} Maybe Text
a -> UpdateServiceSettings
s {$sel:snsTopicArn:UpdateServiceSettings' :: Maybe Text
snsTopicArn = Maybe Text
a} :: UpdateServiceSettings)

instance Core.AWSRequest UpdateServiceSettings where
  type
    AWSResponse UpdateServiceSettings =
      UpdateServiceSettingsResponse
  request :: (Service -> Service)
-> UpdateServiceSettings -> Request UpdateServiceSettings
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy UpdateServiceSettings
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateServiceSettings)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> UpdateServiceSettingsResponse
UpdateServiceSettingsResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable UpdateServiceSettings where
  hashWithSalt :: Int -> UpdateServiceSettings -> Int
hashWithSalt Int
_salt UpdateServiceSettings' {Maybe Bool
Maybe Text
Maybe OrganizationConfiguration
snsTopicArn :: Maybe Text
s3BucketArn :: Maybe Text
organizationConfiguration :: Maybe OrganizationConfiguration
enableCrossAccountsDiscovery :: Maybe Bool
$sel:snsTopicArn:UpdateServiceSettings' :: UpdateServiceSettings -> Maybe Text
$sel:s3BucketArn:UpdateServiceSettings' :: UpdateServiceSettings -> Maybe Text
$sel:organizationConfiguration:UpdateServiceSettings' :: UpdateServiceSettings -> Maybe OrganizationConfiguration
$sel:enableCrossAccountsDiscovery:UpdateServiceSettings' :: UpdateServiceSettings -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
enableCrossAccountsDiscovery
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe OrganizationConfiguration
organizationConfiguration
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
s3BucketArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
snsTopicArn

instance Prelude.NFData UpdateServiceSettings where
  rnf :: UpdateServiceSettings -> ()
rnf UpdateServiceSettings' {Maybe Bool
Maybe Text
Maybe OrganizationConfiguration
snsTopicArn :: Maybe Text
s3BucketArn :: Maybe Text
organizationConfiguration :: Maybe OrganizationConfiguration
enableCrossAccountsDiscovery :: Maybe Bool
$sel:snsTopicArn:UpdateServiceSettings' :: UpdateServiceSettings -> Maybe Text
$sel:s3BucketArn:UpdateServiceSettings' :: UpdateServiceSettings -> Maybe Text
$sel:organizationConfiguration:UpdateServiceSettings' :: UpdateServiceSettings -> Maybe OrganizationConfiguration
$sel:enableCrossAccountsDiscovery:UpdateServiceSettings' :: UpdateServiceSettings -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
enableCrossAccountsDiscovery
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe OrganizationConfiguration
organizationConfiguration
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
s3BucketArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
snsTopicArn

instance Data.ToHeaders UpdateServiceSettings where
  toHeaders :: UpdateServiceSettings -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"AWSLicenseManager.UpdateServiceSettings" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON UpdateServiceSettings where
  toJSON :: UpdateServiceSettings -> Value
toJSON UpdateServiceSettings' {Maybe Bool
Maybe Text
Maybe OrganizationConfiguration
snsTopicArn :: Maybe Text
s3BucketArn :: Maybe Text
organizationConfiguration :: Maybe OrganizationConfiguration
enableCrossAccountsDiscovery :: Maybe Bool
$sel:snsTopicArn:UpdateServiceSettings' :: UpdateServiceSettings -> Maybe Text
$sel:s3BucketArn:UpdateServiceSettings' :: UpdateServiceSettings -> Maybe Text
$sel:organizationConfiguration:UpdateServiceSettings' :: UpdateServiceSettings -> Maybe OrganizationConfiguration
$sel:enableCrossAccountsDiscovery:UpdateServiceSettings' :: UpdateServiceSettings -> Maybe Bool
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"EnableCrossAccountsDiscovery" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
enableCrossAccountsDiscovery,
            (Key
"OrganizationConfiguration" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe OrganizationConfiguration
organizationConfiguration,
            (Key
"S3BucketArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
s3BucketArn,
            (Key
"SnsTopicArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
snsTopicArn
          ]
      )

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

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

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

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

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

instance Prelude.NFData UpdateServiceSettingsResponse where
  rnf :: UpdateServiceSettingsResponse -> ()
rnf UpdateServiceSettingsResponse' {Int
httpStatus :: Int
$sel:httpStatus:UpdateServiceSettingsResponse' :: UpdateServiceSettingsResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus