{-# 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.EMR.SetVisibleToAllUsers
-- 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)
--
-- Sets the Cluster$VisibleToAllUsers value for an EMR cluster. When
-- @true@, IAM principals in the Amazon Web Services account can perform
-- EMR cluster actions that their IAM policies allow. When @false@, only
-- the IAM principal that created the cluster and the Amazon Web Services
-- account root user can perform EMR actions on the cluster, regardless of
-- IAM permissions policies attached to other IAM principals.
--
-- This action works on running clusters. When you create a cluster, use
-- the RunJobFlowInput$VisibleToAllUsers parameter.
--
-- For more information, see
-- <https://docs.aws.amazon.com/emr/latest/ManagementGuide/security_iam_emr-with-iam.html#security_set_visible_to_all_users Understanding the EMR Cluster VisibleToAllUsers Setting>
-- in the /Amazon EMRManagement Guide/.
module Amazonka.EMR.SetVisibleToAllUsers
  ( -- * Creating a Request
    SetVisibleToAllUsers (..),
    newSetVisibleToAllUsers,

    -- * Request Lenses
    setVisibleToAllUsers_jobFlowIds,
    setVisibleToAllUsers_visibleToAllUsers,

    -- * Destructuring the Response
    SetVisibleToAllUsersResponse (..),
    newSetVisibleToAllUsersResponse,
  )
where

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

-- | The input to the SetVisibleToAllUsers action.
--
-- /See:/ 'newSetVisibleToAllUsers' smart constructor.
data SetVisibleToAllUsers = SetVisibleToAllUsers'
  { -- | The unique identifier of the job flow (cluster).
    SetVisibleToAllUsers -> [Text]
jobFlowIds :: [Prelude.Text],
    -- | A value of @true@ indicates that an IAM principal in the Amazon Web
    -- Services account can perform EMR actions on the cluster that the IAM
    -- policies attached to the principal allow. A value of @false@ indicates
    -- that only the IAM principal that created the cluster and the Amazon Web
    -- Services root user can perform EMR actions on the cluster.
    SetVisibleToAllUsers -> Bool
visibleToAllUsers :: Prelude.Bool
  }
  deriving (SetVisibleToAllUsers -> SetVisibleToAllUsers -> Bool
(SetVisibleToAllUsers -> SetVisibleToAllUsers -> Bool)
-> (SetVisibleToAllUsers -> SetVisibleToAllUsers -> Bool)
-> Eq SetVisibleToAllUsers
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SetVisibleToAllUsers -> SetVisibleToAllUsers -> Bool
$c/= :: SetVisibleToAllUsers -> SetVisibleToAllUsers -> Bool
== :: SetVisibleToAllUsers -> SetVisibleToAllUsers -> Bool
$c== :: SetVisibleToAllUsers -> SetVisibleToAllUsers -> Bool
Prelude.Eq, ReadPrec [SetVisibleToAllUsers]
ReadPrec SetVisibleToAllUsers
Int -> ReadS SetVisibleToAllUsers
ReadS [SetVisibleToAllUsers]
(Int -> ReadS SetVisibleToAllUsers)
-> ReadS [SetVisibleToAllUsers]
-> ReadPrec SetVisibleToAllUsers
-> ReadPrec [SetVisibleToAllUsers]
-> Read SetVisibleToAllUsers
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SetVisibleToAllUsers]
$creadListPrec :: ReadPrec [SetVisibleToAllUsers]
readPrec :: ReadPrec SetVisibleToAllUsers
$creadPrec :: ReadPrec SetVisibleToAllUsers
readList :: ReadS [SetVisibleToAllUsers]
$creadList :: ReadS [SetVisibleToAllUsers]
readsPrec :: Int -> ReadS SetVisibleToAllUsers
$creadsPrec :: Int -> ReadS SetVisibleToAllUsers
Prelude.Read, Int -> SetVisibleToAllUsers -> ShowS
[SetVisibleToAllUsers] -> ShowS
SetVisibleToAllUsers -> String
(Int -> SetVisibleToAllUsers -> ShowS)
-> (SetVisibleToAllUsers -> String)
-> ([SetVisibleToAllUsers] -> ShowS)
-> Show SetVisibleToAllUsers
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SetVisibleToAllUsers] -> ShowS
$cshowList :: [SetVisibleToAllUsers] -> ShowS
show :: SetVisibleToAllUsers -> String
$cshow :: SetVisibleToAllUsers -> String
showsPrec :: Int -> SetVisibleToAllUsers -> ShowS
$cshowsPrec :: Int -> SetVisibleToAllUsers -> ShowS
Prelude.Show, (forall x. SetVisibleToAllUsers -> Rep SetVisibleToAllUsers x)
-> (forall x. Rep SetVisibleToAllUsers x -> SetVisibleToAllUsers)
-> Generic SetVisibleToAllUsers
forall x. Rep SetVisibleToAllUsers x -> SetVisibleToAllUsers
forall x. SetVisibleToAllUsers -> Rep SetVisibleToAllUsers x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SetVisibleToAllUsers x -> SetVisibleToAllUsers
$cfrom :: forall x. SetVisibleToAllUsers -> Rep SetVisibleToAllUsers x
Prelude.Generic)

-- |
-- Create a value of 'SetVisibleToAllUsers' 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:
--
-- 'jobFlowIds', 'setVisibleToAllUsers_jobFlowIds' - The unique identifier of the job flow (cluster).
--
-- 'visibleToAllUsers', 'setVisibleToAllUsers_visibleToAllUsers' - A value of @true@ indicates that an IAM principal in the Amazon Web
-- Services account can perform EMR actions on the cluster that the IAM
-- policies attached to the principal allow. A value of @false@ indicates
-- that only the IAM principal that created the cluster and the Amazon Web
-- Services root user can perform EMR actions on the cluster.
newSetVisibleToAllUsers ::
  -- | 'visibleToAllUsers'
  Prelude.Bool ->
  SetVisibleToAllUsers
newSetVisibleToAllUsers :: Bool -> SetVisibleToAllUsers
newSetVisibleToAllUsers Bool
pVisibleToAllUsers_ =
  SetVisibleToAllUsers' :: [Text] -> Bool -> SetVisibleToAllUsers
SetVisibleToAllUsers'
    { $sel:jobFlowIds:SetVisibleToAllUsers' :: [Text]
jobFlowIds = [Text]
forall a. Monoid a => a
Prelude.mempty,
      $sel:visibleToAllUsers:SetVisibleToAllUsers' :: Bool
visibleToAllUsers = Bool
pVisibleToAllUsers_
    }

-- | The unique identifier of the job flow (cluster).
setVisibleToAllUsers_jobFlowIds :: Lens.Lens' SetVisibleToAllUsers [Prelude.Text]
setVisibleToAllUsers_jobFlowIds :: ([Text] -> f [Text])
-> SetVisibleToAllUsers -> f SetVisibleToAllUsers
setVisibleToAllUsers_jobFlowIds = (SetVisibleToAllUsers -> [Text])
-> (SetVisibleToAllUsers -> [Text] -> SetVisibleToAllUsers)
-> Lens SetVisibleToAllUsers SetVisibleToAllUsers [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SetVisibleToAllUsers' {[Text]
jobFlowIds :: [Text]
$sel:jobFlowIds:SetVisibleToAllUsers' :: SetVisibleToAllUsers -> [Text]
jobFlowIds} -> [Text]
jobFlowIds) (\s :: SetVisibleToAllUsers
s@SetVisibleToAllUsers' {} [Text]
a -> SetVisibleToAllUsers
s {$sel:jobFlowIds:SetVisibleToAllUsers' :: [Text]
jobFlowIds = [Text]
a} :: SetVisibleToAllUsers) (([Text] -> f [Text])
 -> SetVisibleToAllUsers -> f SetVisibleToAllUsers)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> SetVisibleToAllUsers
-> f SetVisibleToAllUsers
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A value of @true@ indicates that an IAM principal in the Amazon Web
-- Services account can perform EMR actions on the cluster that the IAM
-- policies attached to the principal allow. A value of @false@ indicates
-- that only the IAM principal that created the cluster and the Amazon Web
-- Services root user can perform EMR actions on the cluster.
setVisibleToAllUsers_visibleToAllUsers :: Lens.Lens' SetVisibleToAllUsers Prelude.Bool
setVisibleToAllUsers_visibleToAllUsers :: (Bool -> f Bool) -> SetVisibleToAllUsers -> f SetVisibleToAllUsers
setVisibleToAllUsers_visibleToAllUsers = (SetVisibleToAllUsers -> Bool)
-> (SetVisibleToAllUsers -> Bool -> SetVisibleToAllUsers)
-> Lens SetVisibleToAllUsers SetVisibleToAllUsers Bool Bool
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SetVisibleToAllUsers' {Bool
visibleToAllUsers :: Bool
$sel:visibleToAllUsers:SetVisibleToAllUsers' :: SetVisibleToAllUsers -> Bool
visibleToAllUsers} -> Bool
visibleToAllUsers) (\s :: SetVisibleToAllUsers
s@SetVisibleToAllUsers' {} Bool
a -> SetVisibleToAllUsers
s {$sel:visibleToAllUsers:SetVisibleToAllUsers' :: Bool
visibleToAllUsers = Bool
a} :: SetVisibleToAllUsers)

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

instance Prelude.Hashable SetVisibleToAllUsers

instance Prelude.NFData SetVisibleToAllUsers

instance Core.ToHeaders SetVisibleToAllUsers where
  toHeaders :: SetVisibleToAllUsers -> [Header]
toHeaders =
    [Header] -> SetVisibleToAllUsers -> [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
"ElasticMapReduce.SetVisibleToAllUsers" ::
                          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 SetVisibleToAllUsers where
  toJSON :: SetVisibleToAllUsers -> Value
toJSON SetVisibleToAllUsers' {Bool
[Text]
visibleToAllUsers :: Bool
jobFlowIds :: [Text]
$sel:visibleToAllUsers:SetVisibleToAllUsers' :: SetVisibleToAllUsers -> Bool
$sel:jobFlowIds:SetVisibleToAllUsers' :: SetVisibleToAllUsers -> [Text]
..} =
    [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
"JobFlowIds" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Text]
jobFlowIds),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"VisibleToAllUsers" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Bool
visibleToAllUsers)
          ]
      )

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

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

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

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

instance Prelude.NFData SetVisibleToAllUsersResponse