{-# 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.QuickSight.UpdatePublicSharingSettings
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Use the @UpdatePublicSharingSettings@ operation to turn on or turn off
-- the public sharing settings of an Amazon QuickSight dashboard.
--
-- To use this operation, turn on session capacity pricing for your Amazon
-- QuickSight account.
--
-- Before you can turn on public sharing on your account, make sure to give
-- public sharing permissions to an administrative user in the Identity and
-- Access Management (IAM) console. For more information on using IAM with
-- Amazon QuickSight, see
-- <https://docs.aws.amazon.com/quicksight/latest/user/security_iam_service-with-iam.html Using Amazon QuickSight with IAM>
-- in the /Amazon QuickSight User Guide/.
module Amazonka.QuickSight.UpdatePublicSharingSettings
  ( -- * Creating a Request
    UpdatePublicSharingSettings (..),
    newUpdatePublicSharingSettings,

    -- * Request Lenses
    updatePublicSharingSettings_publicSharingEnabled,
    updatePublicSharingSettings_awsAccountId,

    -- * Destructuring the Response
    UpdatePublicSharingSettingsResponse (..),
    newUpdatePublicSharingSettingsResponse,

    -- * Response Lenses
    updatePublicSharingSettingsResponse_requestId,
    updatePublicSharingSettingsResponse_status,
  )
where

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

-- | /See:/ 'newUpdatePublicSharingSettings' smart constructor.
data UpdatePublicSharingSettings = UpdatePublicSharingSettings'
  { -- | A Boolean value that indicates whether public sharing is turned on for
    -- an Amazon QuickSight account.
    UpdatePublicSharingSettings -> Maybe Bool
publicSharingEnabled :: Prelude.Maybe Prelude.Bool,
    -- | The Amazon Web Services account ID associated with your Amazon
    -- QuickSight subscription.
    UpdatePublicSharingSettings -> Text
awsAccountId :: Prelude.Text
  }
  deriving (UpdatePublicSharingSettings -> UpdatePublicSharingSettings -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdatePublicSharingSettings -> UpdatePublicSharingSettings -> Bool
$c/= :: UpdatePublicSharingSettings -> UpdatePublicSharingSettings -> Bool
== :: UpdatePublicSharingSettings -> UpdatePublicSharingSettings -> Bool
$c== :: UpdatePublicSharingSettings -> UpdatePublicSharingSettings -> Bool
Prelude.Eq, ReadPrec [UpdatePublicSharingSettings]
ReadPrec UpdatePublicSharingSettings
Int -> ReadS UpdatePublicSharingSettings
ReadS [UpdatePublicSharingSettings]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdatePublicSharingSettings]
$creadListPrec :: ReadPrec [UpdatePublicSharingSettings]
readPrec :: ReadPrec UpdatePublicSharingSettings
$creadPrec :: ReadPrec UpdatePublicSharingSettings
readList :: ReadS [UpdatePublicSharingSettings]
$creadList :: ReadS [UpdatePublicSharingSettings]
readsPrec :: Int -> ReadS UpdatePublicSharingSettings
$creadsPrec :: Int -> ReadS UpdatePublicSharingSettings
Prelude.Read, Int -> UpdatePublicSharingSettings -> ShowS
[UpdatePublicSharingSettings] -> ShowS
UpdatePublicSharingSettings -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdatePublicSharingSettings] -> ShowS
$cshowList :: [UpdatePublicSharingSettings] -> ShowS
show :: UpdatePublicSharingSettings -> String
$cshow :: UpdatePublicSharingSettings -> String
showsPrec :: Int -> UpdatePublicSharingSettings -> ShowS
$cshowsPrec :: Int -> UpdatePublicSharingSettings -> ShowS
Prelude.Show, forall x.
Rep UpdatePublicSharingSettings x -> UpdatePublicSharingSettings
forall x.
UpdatePublicSharingSettings -> Rep UpdatePublicSharingSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdatePublicSharingSettings x -> UpdatePublicSharingSettings
$cfrom :: forall x.
UpdatePublicSharingSettings -> Rep UpdatePublicSharingSettings x
Prelude.Generic)

-- |
-- Create a value of 'UpdatePublicSharingSettings' 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:
--
-- 'publicSharingEnabled', 'updatePublicSharingSettings_publicSharingEnabled' - A Boolean value that indicates whether public sharing is turned on for
-- an Amazon QuickSight account.
--
-- 'awsAccountId', 'updatePublicSharingSettings_awsAccountId' - The Amazon Web Services account ID associated with your Amazon
-- QuickSight subscription.
newUpdatePublicSharingSettings ::
  -- | 'awsAccountId'
  Prelude.Text ->
  UpdatePublicSharingSettings
newUpdatePublicSharingSettings :: Text -> UpdatePublicSharingSettings
newUpdatePublicSharingSettings Text
pAwsAccountId_ =
  UpdatePublicSharingSettings'
    { $sel:publicSharingEnabled:UpdatePublicSharingSettings' :: Maybe Bool
publicSharingEnabled =
        forall a. Maybe a
Prelude.Nothing,
      $sel:awsAccountId:UpdatePublicSharingSettings' :: Text
awsAccountId = Text
pAwsAccountId_
    }

-- | A Boolean value that indicates whether public sharing is turned on for
-- an Amazon QuickSight account.
updatePublicSharingSettings_publicSharingEnabled :: Lens.Lens' UpdatePublicSharingSettings (Prelude.Maybe Prelude.Bool)
updatePublicSharingSettings_publicSharingEnabled :: Lens' UpdatePublicSharingSettings (Maybe Bool)
updatePublicSharingSettings_publicSharingEnabled = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdatePublicSharingSettings' {Maybe Bool
publicSharingEnabled :: Maybe Bool
$sel:publicSharingEnabled:UpdatePublicSharingSettings' :: UpdatePublicSharingSettings -> Maybe Bool
publicSharingEnabled} -> Maybe Bool
publicSharingEnabled) (\s :: UpdatePublicSharingSettings
s@UpdatePublicSharingSettings' {} Maybe Bool
a -> UpdatePublicSharingSettings
s {$sel:publicSharingEnabled:UpdatePublicSharingSettings' :: Maybe Bool
publicSharingEnabled = Maybe Bool
a} :: UpdatePublicSharingSettings)

-- | The Amazon Web Services account ID associated with your Amazon
-- QuickSight subscription.
updatePublicSharingSettings_awsAccountId :: Lens.Lens' UpdatePublicSharingSettings Prelude.Text
updatePublicSharingSettings_awsAccountId :: Lens' UpdatePublicSharingSettings Text
updatePublicSharingSettings_awsAccountId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdatePublicSharingSettings' {Text
awsAccountId :: Text
$sel:awsAccountId:UpdatePublicSharingSettings' :: UpdatePublicSharingSettings -> Text
awsAccountId} -> Text
awsAccountId) (\s :: UpdatePublicSharingSettings
s@UpdatePublicSharingSettings' {} Text
a -> UpdatePublicSharingSettings
s {$sel:awsAccountId:UpdatePublicSharingSettings' :: Text
awsAccountId = Text
a} :: UpdatePublicSharingSettings)

instance Core.AWSRequest UpdatePublicSharingSettings where
  type
    AWSResponse UpdatePublicSharingSettings =
      UpdatePublicSharingSettingsResponse
  request :: (Service -> Service)
-> UpdatePublicSharingSettings
-> Request UpdatePublicSharingSettings
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy UpdatePublicSharingSettings
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdatePublicSharingSettings)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text -> Int -> UpdatePublicSharingSettingsResponse
UpdatePublicSharingSettingsResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"RequestId")
            forall (f :: * -> *) a b. Applicative f => 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 UpdatePublicSharingSettings where
  hashWithSalt :: Int -> UpdatePublicSharingSettings -> Int
hashWithSalt Int
_salt UpdatePublicSharingSettings' {Maybe Bool
Text
awsAccountId :: Text
publicSharingEnabled :: Maybe Bool
$sel:awsAccountId:UpdatePublicSharingSettings' :: UpdatePublicSharingSettings -> Text
$sel:publicSharingEnabled:UpdatePublicSharingSettings' :: UpdatePublicSharingSettings -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
publicSharingEnabled
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
awsAccountId

instance Prelude.NFData UpdatePublicSharingSettings where
  rnf :: UpdatePublicSharingSettings -> ()
rnf UpdatePublicSharingSettings' {Maybe Bool
Text
awsAccountId :: Text
publicSharingEnabled :: Maybe Bool
$sel:awsAccountId:UpdatePublicSharingSettings' :: UpdatePublicSharingSettings -> Text
$sel:publicSharingEnabled:UpdatePublicSharingSettings' :: UpdatePublicSharingSettings -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
publicSharingEnabled
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
awsAccountId

instance Data.ToHeaders UpdatePublicSharingSettings where
  toHeaders :: UpdatePublicSharingSettings -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.0" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON UpdatePublicSharingSettings where
  toJSON :: UpdatePublicSharingSettings -> Value
toJSON UpdatePublicSharingSettings' {Maybe Bool
Text
awsAccountId :: Text
publicSharingEnabled :: Maybe Bool
$sel:awsAccountId:UpdatePublicSharingSettings' :: UpdatePublicSharingSettings -> Text
$sel:publicSharingEnabled:UpdatePublicSharingSettings' :: UpdatePublicSharingSettings -> Maybe Bool
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"PublicSharingEnabled" 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
publicSharingEnabled
          ]
      )

instance Data.ToPath UpdatePublicSharingSettings where
  toPath :: UpdatePublicSharingSettings -> ByteString
toPath UpdatePublicSharingSettings' {Maybe Bool
Text
awsAccountId :: Text
publicSharingEnabled :: Maybe Bool
$sel:awsAccountId:UpdatePublicSharingSettings' :: UpdatePublicSharingSettings -> Text
$sel:publicSharingEnabled:UpdatePublicSharingSettings' :: UpdatePublicSharingSettings -> Maybe Bool
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/accounts/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
awsAccountId,
        ByteString
"/public-sharing-settings"
      ]

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

-- | /See:/ 'newUpdatePublicSharingSettingsResponse' smart constructor.
data UpdatePublicSharingSettingsResponse = UpdatePublicSharingSettingsResponse'
  { -- | The Amazon Web Services request ID for this operation.
    UpdatePublicSharingSettingsResponse -> Maybe Text
requestId :: Prelude.Maybe Prelude.Text,
    -- | The HTTP status of the request.
    UpdatePublicSharingSettingsResponse -> Int
status :: Prelude.Int
  }
  deriving (UpdatePublicSharingSettingsResponse
-> UpdatePublicSharingSettingsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdatePublicSharingSettingsResponse
-> UpdatePublicSharingSettingsResponse -> Bool
$c/= :: UpdatePublicSharingSettingsResponse
-> UpdatePublicSharingSettingsResponse -> Bool
== :: UpdatePublicSharingSettingsResponse
-> UpdatePublicSharingSettingsResponse -> Bool
$c== :: UpdatePublicSharingSettingsResponse
-> UpdatePublicSharingSettingsResponse -> Bool
Prelude.Eq, ReadPrec [UpdatePublicSharingSettingsResponse]
ReadPrec UpdatePublicSharingSettingsResponse
Int -> ReadS UpdatePublicSharingSettingsResponse
ReadS [UpdatePublicSharingSettingsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdatePublicSharingSettingsResponse]
$creadListPrec :: ReadPrec [UpdatePublicSharingSettingsResponse]
readPrec :: ReadPrec UpdatePublicSharingSettingsResponse
$creadPrec :: ReadPrec UpdatePublicSharingSettingsResponse
readList :: ReadS [UpdatePublicSharingSettingsResponse]
$creadList :: ReadS [UpdatePublicSharingSettingsResponse]
readsPrec :: Int -> ReadS UpdatePublicSharingSettingsResponse
$creadsPrec :: Int -> ReadS UpdatePublicSharingSettingsResponse
Prelude.Read, Int -> UpdatePublicSharingSettingsResponse -> ShowS
[UpdatePublicSharingSettingsResponse] -> ShowS
UpdatePublicSharingSettingsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdatePublicSharingSettingsResponse] -> ShowS
$cshowList :: [UpdatePublicSharingSettingsResponse] -> ShowS
show :: UpdatePublicSharingSettingsResponse -> String
$cshow :: UpdatePublicSharingSettingsResponse -> String
showsPrec :: Int -> UpdatePublicSharingSettingsResponse -> ShowS
$cshowsPrec :: Int -> UpdatePublicSharingSettingsResponse -> ShowS
Prelude.Show, forall x.
Rep UpdatePublicSharingSettingsResponse x
-> UpdatePublicSharingSettingsResponse
forall x.
UpdatePublicSharingSettingsResponse
-> Rep UpdatePublicSharingSettingsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdatePublicSharingSettingsResponse x
-> UpdatePublicSharingSettingsResponse
$cfrom :: forall x.
UpdatePublicSharingSettingsResponse
-> Rep UpdatePublicSharingSettingsResponse x
Prelude.Generic)

-- |
-- Create a value of 'UpdatePublicSharingSettingsResponse' 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:
--
-- 'requestId', 'updatePublicSharingSettingsResponse_requestId' - The Amazon Web Services request ID for this operation.
--
-- 'status', 'updatePublicSharingSettingsResponse_status' - The HTTP status of the request.
newUpdatePublicSharingSettingsResponse ::
  -- | 'status'
  Prelude.Int ->
  UpdatePublicSharingSettingsResponse
newUpdatePublicSharingSettingsResponse :: Int -> UpdatePublicSharingSettingsResponse
newUpdatePublicSharingSettingsResponse Int
pStatus_ =
  UpdatePublicSharingSettingsResponse'
    { $sel:requestId:UpdatePublicSharingSettingsResponse' :: Maybe Text
requestId =
        forall a. Maybe a
Prelude.Nothing,
      $sel:status:UpdatePublicSharingSettingsResponse' :: Int
status = Int
pStatus_
    }

-- | The Amazon Web Services request ID for this operation.
updatePublicSharingSettingsResponse_requestId :: Lens.Lens' UpdatePublicSharingSettingsResponse (Prelude.Maybe Prelude.Text)
updatePublicSharingSettingsResponse_requestId :: Lens' UpdatePublicSharingSettingsResponse (Maybe Text)
updatePublicSharingSettingsResponse_requestId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdatePublicSharingSettingsResponse' {Maybe Text
requestId :: Maybe Text
$sel:requestId:UpdatePublicSharingSettingsResponse' :: UpdatePublicSharingSettingsResponse -> Maybe Text
requestId} -> Maybe Text
requestId) (\s :: UpdatePublicSharingSettingsResponse
s@UpdatePublicSharingSettingsResponse' {} Maybe Text
a -> UpdatePublicSharingSettingsResponse
s {$sel:requestId:UpdatePublicSharingSettingsResponse' :: Maybe Text
requestId = Maybe Text
a} :: UpdatePublicSharingSettingsResponse)

-- | The HTTP status of the request.
updatePublicSharingSettingsResponse_status :: Lens.Lens' UpdatePublicSharingSettingsResponse Prelude.Int
updatePublicSharingSettingsResponse_status :: Lens' UpdatePublicSharingSettingsResponse Int
updatePublicSharingSettingsResponse_status = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdatePublicSharingSettingsResponse' {Int
status :: Int
$sel:status:UpdatePublicSharingSettingsResponse' :: UpdatePublicSharingSettingsResponse -> Int
status} -> Int
status) (\s :: UpdatePublicSharingSettingsResponse
s@UpdatePublicSharingSettingsResponse' {} Int
a -> UpdatePublicSharingSettingsResponse
s {$sel:status:UpdatePublicSharingSettingsResponse' :: Int
status = Int
a} :: UpdatePublicSharingSettingsResponse)

instance
  Prelude.NFData
    UpdatePublicSharingSettingsResponse
  where
  rnf :: UpdatePublicSharingSettingsResponse -> ()
rnf UpdatePublicSharingSettingsResponse' {Int
Maybe Text
status :: Int
requestId :: Maybe Text
$sel:status:UpdatePublicSharingSettingsResponse' :: UpdatePublicSharingSettingsResponse -> Int
$sel:requestId:UpdatePublicSharingSettingsResponse' :: UpdatePublicSharingSettingsResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
requestId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
status