{-# 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.SSOAdmin.PutInlinePolicyToPermissionSet
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Attaches an inline policy to a permission set.
--
-- If the permission set is already referenced by one or more account
-- assignments, you will need to call @ @@ProvisionPermissionSet@@ @ after
-- this action to apply the corresponding IAM policy updates to all
-- assigned accounts.
module Amazonka.SSOAdmin.PutInlinePolicyToPermissionSet
  ( -- * Creating a Request
    PutInlinePolicyToPermissionSet (..),
    newPutInlinePolicyToPermissionSet,

    -- * Request Lenses
    putInlinePolicyToPermissionSet_instanceArn,
    putInlinePolicyToPermissionSet_permissionSetArn,
    putInlinePolicyToPermissionSet_inlinePolicy,

    -- * Destructuring the Response
    PutInlinePolicyToPermissionSetResponse (..),
    newPutInlinePolicyToPermissionSetResponse,

    -- * Response Lenses
    putInlinePolicyToPermissionSetResponse_httpStatus,
  )
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 qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.SSOAdmin.Types

-- | /See:/ 'newPutInlinePolicyToPermissionSet' smart constructor.
data PutInlinePolicyToPermissionSet = PutInlinePolicyToPermissionSet'
  { -- | The ARN of the IAM Identity Center instance under which the operation
    -- will be executed. For more information about ARNs, see
    -- </general/latest/gr/aws-arns-and-namespaces.html Amazon Resource Names (ARNs) and AWS Service Namespaces>
    -- in the /AWS General Reference/.
    PutInlinePolicyToPermissionSet -> Text
instanceArn :: Prelude.Text,
    -- | The ARN of the permission set.
    PutInlinePolicyToPermissionSet -> Text
permissionSetArn :: Prelude.Text,
    -- | The inline policy to attach to a PermissionSet.
    PutInlinePolicyToPermissionSet -> Text
inlinePolicy :: Prelude.Text
  }
  deriving (PutInlinePolicyToPermissionSet
-> PutInlinePolicyToPermissionSet -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutInlinePolicyToPermissionSet
-> PutInlinePolicyToPermissionSet -> Bool
$c/= :: PutInlinePolicyToPermissionSet
-> PutInlinePolicyToPermissionSet -> Bool
== :: PutInlinePolicyToPermissionSet
-> PutInlinePolicyToPermissionSet -> Bool
$c== :: PutInlinePolicyToPermissionSet
-> PutInlinePolicyToPermissionSet -> Bool
Prelude.Eq, ReadPrec [PutInlinePolicyToPermissionSet]
ReadPrec PutInlinePolicyToPermissionSet
Int -> ReadS PutInlinePolicyToPermissionSet
ReadS [PutInlinePolicyToPermissionSet]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutInlinePolicyToPermissionSet]
$creadListPrec :: ReadPrec [PutInlinePolicyToPermissionSet]
readPrec :: ReadPrec PutInlinePolicyToPermissionSet
$creadPrec :: ReadPrec PutInlinePolicyToPermissionSet
readList :: ReadS [PutInlinePolicyToPermissionSet]
$creadList :: ReadS [PutInlinePolicyToPermissionSet]
readsPrec :: Int -> ReadS PutInlinePolicyToPermissionSet
$creadsPrec :: Int -> ReadS PutInlinePolicyToPermissionSet
Prelude.Read, Int -> PutInlinePolicyToPermissionSet -> ShowS
[PutInlinePolicyToPermissionSet] -> ShowS
PutInlinePolicyToPermissionSet -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutInlinePolicyToPermissionSet] -> ShowS
$cshowList :: [PutInlinePolicyToPermissionSet] -> ShowS
show :: PutInlinePolicyToPermissionSet -> String
$cshow :: PutInlinePolicyToPermissionSet -> String
showsPrec :: Int -> PutInlinePolicyToPermissionSet -> ShowS
$cshowsPrec :: Int -> PutInlinePolicyToPermissionSet -> ShowS
Prelude.Show, forall x.
Rep PutInlinePolicyToPermissionSet x
-> PutInlinePolicyToPermissionSet
forall x.
PutInlinePolicyToPermissionSet
-> Rep PutInlinePolicyToPermissionSet x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PutInlinePolicyToPermissionSet x
-> PutInlinePolicyToPermissionSet
$cfrom :: forall x.
PutInlinePolicyToPermissionSet
-> Rep PutInlinePolicyToPermissionSet x
Prelude.Generic)

-- |
-- Create a value of 'PutInlinePolicyToPermissionSet' 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:
--
-- 'instanceArn', 'putInlinePolicyToPermissionSet_instanceArn' - The ARN of the IAM Identity Center instance under which the operation
-- will be executed. For more information about ARNs, see
-- </general/latest/gr/aws-arns-and-namespaces.html Amazon Resource Names (ARNs) and AWS Service Namespaces>
-- in the /AWS General Reference/.
--
-- 'permissionSetArn', 'putInlinePolicyToPermissionSet_permissionSetArn' - The ARN of the permission set.
--
-- 'inlinePolicy', 'putInlinePolicyToPermissionSet_inlinePolicy' - The inline policy to attach to a PermissionSet.
newPutInlinePolicyToPermissionSet ::
  -- | 'instanceArn'
  Prelude.Text ->
  -- | 'permissionSetArn'
  Prelude.Text ->
  -- | 'inlinePolicy'
  Prelude.Text ->
  PutInlinePolicyToPermissionSet
newPutInlinePolicyToPermissionSet :: Text -> Text -> Text -> PutInlinePolicyToPermissionSet
newPutInlinePolicyToPermissionSet
  Text
pInstanceArn_
  Text
pPermissionSetArn_
  Text
pInlinePolicy_ =
    PutInlinePolicyToPermissionSet'
      { $sel:instanceArn:PutInlinePolicyToPermissionSet' :: Text
instanceArn =
          Text
pInstanceArn_,
        $sel:permissionSetArn:PutInlinePolicyToPermissionSet' :: Text
permissionSetArn = Text
pPermissionSetArn_,
        $sel:inlinePolicy:PutInlinePolicyToPermissionSet' :: Text
inlinePolicy = Text
pInlinePolicy_
      }

-- | The ARN of the IAM Identity Center instance under which the operation
-- will be executed. For more information about ARNs, see
-- </general/latest/gr/aws-arns-and-namespaces.html Amazon Resource Names (ARNs) and AWS Service Namespaces>
-- in the /AWS General Reference/.
putInlinePolicyToPermissionSet_instanceArn :: Lens.Lens' PutInlinePolicyToPermissionSet Prelude.Text
putInlinePolicyToPermissionSet_instanceArn :: Lens' PutInlinePolicyToPermissionSet Text
putInlinePolicyToPermissionSet_instanceArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutInlinePolicyToPermissionSet' {Text
instanceArn :: Text
$sel:instanceArn:PutInlinePolicyToPermissionSet' :: PutInlinePolicyToPermissionSet -> Text
instanceArn} -> Text
instanceArn) (\s :: PutInlinePolicyToPermissionSet
s@PutInlinePolicyToPermissionSet' {} Text
a -> PutInlinePolicyToPermissionSet
s {$sel:instanceArn:PutInlinePolicyToPermissionSet' :: Text
instanceArn = Text
a} :: PutInlinePolicyToPermissionSet)

-- | The ARN of the permission set.
putInlinePolicyToPermissionSet_permissionSetArn :: Lens.Lens' PutInlinePolicyToPermissionSet Prelude.Text
putInlinePolicyToPermissionSet_permissionSetArn :: Lens' PutInlinePolicyToPermissionSet Text
putInlinePolicyToPermissionSet_permissionSetArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutInlinePolicyToPermissionSet' {Text
permissionSetArn :: Text
$sel:permissionSetArn:PutInlinePolicyToPermissionSet' :: PutInlinePolicyToPermissionSet -> Text
permissionSetArn} -> Text
permissionSetArn) (\s :: PutInlinePolicyToPermissionSet
s@PutInlinePolicyToPermissionSet' {} Text
a -> PutInlinePolicyToPermissionSet
s {$sel:permissionSetArn:PutInlinePolicyToPermissionSet' :: Text
permissionSetArn = Text
a} :: PutInlinePolicyToPermissionSet)

-- | The inline policy to attach to a PermissionSet.
putInlinePolicyToPermissionSet_inlinePolicy :: Lens.Lens' PutInlinePolicyToPermissionSet Prelude.Text
putInlinePolicyToPermissionSet_inlinePolicy :: Lens' PutInlinePolicyToPermissionSet Text
putInlinePolicyToPermissionSet_inlinePolicy = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutInlinePolicyToPermissionSet' {Text
inlinePolicy :: Text
$sel:inlinePolicy:PutInlinePolicyToPermissionSet' :: PutInlinePolicyToPermissionSet -> Text
inlinePolicy} -> Text
inlinePolicy) (\s :: PutInlinePolicyToPermissionSet
s@PutInlinePolicyToPermissionSet' {} Text
a -> PutInlinePolicyToPermissionSet
s {$sel:inlinePolicy:PutInlinePolicyToPermissionSet' :: Text
inlinePolicy = Text
a} :: PutInlinePolicyToPermissionSet)

instance
  Core.AWSRequest
    PutInlinePolicyToPermissionSet
  where
  type
    AWSResponse PutInlinePolicyToPermissionSet =
      PutInlinePolicyToPermissionSetResponse
  request :: (Service -> Service)
-> PutInlinePolicyToPermissionSet
-> Request PutInlinePolicyToPermissionSet
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 PutInlinePolicyToPermissionSet
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse PutInlinePolicyToPermissionSet)))
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 -> PutInlinePolicyToPermissionSetResponse
PutInlinePolicyToPermissionSetResponse'
            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
    PutInlinePolicyToPermissionSet
  where
  hashWithSalt :: Int -> PutInlinePolicyToPermissionSet -> Int
hashWithSalt
    Int
_salt
    PutInlinePolicyToPermissionSet' {Text
inlinePolicy :: Text
permissionSetArn :: Text
instanceArn :: Text
$sel:inlinePolicy:PutInlinePolicyToPermissionSet' :: PutInlinePolicyToPermissionSet -> Text
$sel:permissionSetArn:PutInlinePolicyToPermissionSet' :: PutInlinePolicyToPermissionSet -> Text
$sel:instanceArn:PutInlinePolicyToPermissionSet' :: PutInlinePolicyToPermissionSet -> Text
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
instanceArn
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
permissionSetArn
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
inlinePolicy

instance
  Prelude.NFData
    PutInlinePolicyToPermissionSet
  where
  rnf :: PutInlinePolicyToPermissionSet -> ()
rnf PutInlinePolicyToPermissionSet' {Text
inlinePolicy :: Text
permissionSetArn :: Text
instanceArn :: Text
$sel:inlinePolicy:PutInlinePolicyToPermissionSet' :: PutInlinePolicyToPermissionSet -> Text
$sel:permissionSetArn:PutInlinePolicyToPermissionSet' :: PutInlinePolicyToPermissionSet -> Text
$sel:instanceArn:PutInlinePolicyToPermissionSet' :: PutInlinePolicyToPermissionSet -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
instanceArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
permissionSetArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
inlinePolicy

instance
  Data.ToHeaders
    PutInlinePolicyToPermissionSet
  where
  toHeaders :: PutInlinePolicyToPermissionSet -> 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
"SWBExternalService.PutInlinePolicyToPermissionSet" ::
                          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 PutInlinePolicyToPermissionSet where
  toJSON :: PutInlinePolicyToPermissionSet -> Value
toJSON PutInlinePolicyToPermissionSet' {Text
inlinePolicy :: Text
permissionSetArn :: Text
instanceArn :: Text
$sel:inlinePolicy:PutInlinePolicyToPermissionSet' :: PutInlinePolicyToPermissionSet -> Text
$sel:permissionSetArn:PutInlinePolicyToPermissionSet' :: PutInlinePolicyToPermissionSet -> Text
$sel:instanceArn:PutInlinePolicyToPermissionSet' :: PutInlinePolicyToPermissionSet -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"InstanceArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
instanceArn),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"PermissionSetArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
permissionSetArn),
            forall a. a -> Maybe a
Prelude.Just (Key
"InlinePolicy" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
inlinePolicy)
          ]
      )

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

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

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

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

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

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