{-# 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.UpdateAnalysisPermissions
-- 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)
--
-- Updates the read and write permissions for an analysis.
module Amazonka.QuickSight.UpdateAnalysisPermissions
  ( -- * Creating a Request
    UpdateAnalysisPermissions (..),
    newUpdateAnalysisPermissions,

    -- * Request Lenses
    updateAnalysisPermissions_revokePermissions,
    updateAnalysisPermissions_grantPermissions,
    updateAnalysisPermissions_awsAccountId,
    updateAnalysisPermissions_analysisId,

    -- * Destructuring the Response
    UpdateAnalysisPermissionsResponse (..),
    newUpdateAnalysisPermissionsResponse,

    -- * Response Lenses
    updateAnalysisPermissionsResponse_requestId,
    updateAnalysisPermissionsResponse_analysisId,
    updateAnalysisPermissionsResponse_analysisArn,
    updateAnalysisPermissionsResponse_permissions,
    updateAnalysisPermissionsResponse_status,
  )
where

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

-- | /See:/ 'newUpdateAnalysisPermissions' smart constructor.
data UpdateAnalysisPermissions = UpdateAnalysisPermissions'
  { -- | A structure that describes the permissions to remove and the principal
    -- to remove them from.
    UpdateAnalysisPermissions -> Maybe [ResourcePermission]
revokePermissions :: Prelude.Maybe [ResourcePermission],
    -- | A structure that describes the permissions to add and the principal to
    -- add them to.
    UpdateAnalysisPermissions -> Maybe [ResourcePermission]
grantPermissions :: Prelude.Maybe [ResourcePermission],
    -- | The ID of the Amazon Web Services account that contains the analysis
    -- whose permissions you\'re updating. You must be using the Amazon Web
    -- Services account that the analysis is in.
    UpdateAnalysisPermissions -> Text
awsAccountId :: Prelude.Text,
    -- | The ID of the analysis whose permissions you\'re updating. The ID is
    -- part of the analysis URL.
    UpdateAnalysisPermissions -> Text
analysisId :: Prelude.Text
  }
  deriving (UpdateAnalysisPermissions -> UpdateAnalysisPermissions -> Bool
(UpdateAnalysisPermissions -> UpdateAnalysisPermissions -> Bool)
-> (UpdateAnalysisPermissions -> UpdateAnalysisPermissions -> Bool)
-> Eq UpdateAnalysisPermissions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateAnalysisPermissions -> UpdateAnalysisPermissions -> Bool
$c/= :: UpdateAnalysisPermissions -> UpdateAnalysisPermissions -> Bool
== :: UpdateAnalysisPermissions -> UpdateAnalysisPermissions -> Bool
$c== :: UpdateAnalysisPermissions -> UpdateAnalysisPermissions -> Bool
Prelude.Eq, ReadPrec [UpdateAnalysisPermissions]
ReadPrec UpdateAnalysisPermissions
Int -> ReadS UpdateAnalysisPermissions
ReadS [UpdateAnalysisPermissions]
(Int -> ReadS UpdateAnalysisPermissions)
-> ReadS [UpdateAnalysisPermissions]
-> ReadPrec UpdateAnalysisPermissions
-> ReadPrec [UpdateAnalysisPermissions]
-> Read UpdateAnalysisPermissions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateAnalysisPermissions]
$creadListPrec :: ReadPrec [UpdateAnalysisPermissions]
readPrec :: ReadPrec UpdateAnalysisPermissions
$creadPrec :: ReadPrec UpdateAnalysisPermissions
readList :: ReadS [UpdateAnalysisPermissions]
$creadList :: ReadS [UpdateAnalysisPermissions]
readsPrec :: Int -> ReadS UpdateAnalysisPermissions
$creadsPrec :: Int -> ReadS UpdateAnalysisPermissions
Prelude.Read, Int -> UpdateAnalysisPermissions -> ShowS
[UpdateAnalysisPermissions] -> ShowS
UpdateAnalysisPermissions -> String
(Int -> UpdateAnalysisPermissions -> ShowS)
-> (UpdateAnalysisPermissions -> String)
-> ([UpdateAnalysisPermissions] -> ShowS)
-> Show UpdateAnalysisPermissions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateAnalysisPermissions] -> ShowS
$cshowList :: [UpdateAnalysisPermissions] -> ShowS
show :: UpdateAnalysisPermissions -> String
$cshow :: UpdateAnalysisPermissions -> String
showsPrec :: Int -> UpdateAnalysisPermissions -> ShowS
$cshowsPrec :: Int -> UpdateAnalysisPermissions -> ShowS
Prelude.Show, (forall x.
 UpdateAnalysisPermissions -> Rep UpdateAnalysisPermissions x)
-> (forall x.
    Rep UpdateAnalysisPermissions x -> UpdateAnalysisPermissions)
-> Generic UpdateAnalysisPermissions
forall x.
Rep UpdateAnalysisPermissions x -> UpdateAnalysisPermissions
forall x.
UpdateAnalysisPermissions -> Rep UpdateAnalysisPermissions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateAnalysisPermissions x -> UpdateAnalysisPermissions
$cfrom :: forall x.
UpdateAnalysisPermissions -> Rep UpdateAnalysisPermissions x
Prelude.Generic)

-- |
-- Create a value of 'UpdateAnalysisPermissions' 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:
--
-- 'revokePermissions', 'updateAnalysisPermissions_revokePermissions' - A structure that describes the permissions to remove and the principal
-- to remove them from.
--
-- 'grantPermissions', 'updateAnalysisPermissions_grantPermissions' - A structure that describes the permissions to add and the principal to
-- add them to.
--
-- 'awsAccountId', 'updateAnalysisPermissions_awsAccountId' - The ID of the Amazon Web Services account that contains the analysis
-- whose permissions you\'re updating. You must be using the Amazon Web
-- Services account that the analysis is in.
--
-- 'analysisId', 'updateAnalysisPermissions_analysisId' - The ID of the analysis whose permissions you\'re updating. The ID is
-- part of the analysis URL.
newUpdateAnalysisPermissions ::
  -- | 'awsAccountId'
  Prelude.Text ->
  -- | 'analysisId'
  Prelude.Text ->
  UpdateAnalysisPermissions
newUpdateAnalysisPermissions :: Text -> Text -> UpdateAnalysisPermissions
newUpdateAnalysisPermissions
  Text
pAwsAccountId_
  Text
pAnalysisId_ =
    UpdateAnalysisPermissions' :: Maybe [ResourcePermission]
-> Maybe [ResourcePermission]
-> Text
-> Text
-> UpdateAnalysisPermissions
UpdateAnalysisPermissions'
      { $sel:revokePermissions:UpdateAnalysisPermissions' :: Maybe [ResourcePermission]
revokePermissions =
          Maybe [ResourcePermission]
forall a. Maybe a
Prelude.Nothing,
        $sel:grantPermissions:UpdateAnalysisPermissions' :: Maybe [ResourcePermission]
grantPermissions = Maybe [ResourcePermission]
forall a. Maybe a
Prelude.Nothing,
        $sel:awsAccountId:UpdateAnalysisPermissions' :: Text
awsAccountId = Text
pAwsAccountId_,
        $sel:analysisId:UpdateAnalysisPermissions' :: Text
analysisId = Text
pAnalysisId_
      }

-- | A structure that describes the permissions to remove and the principal
-- to remove them from.
updateAnalysisPermissions_revokePermissions :: Lens.Lens' UpdateAnalysisPermissions (Prelude.Maybe [ResourcePermission])
updateAnalysisPermissions_revokePermissions :: (Maybe [ResourcePermission] -> f (Maybe [ResourcePermission]))
-> UpdateAnalysisPermissions -> f UpdateAnalysisPermissions
updateAnalysisPermissions_revokePermissions = (UpdateAnalysisPermissions -> Maybe [ResourcePermission])
-> (UpdateAnalysisPermissions
    -> Maybe [ResourcePermission] -> UpdateAnalysisPermissions)
-> Lens
     UpdateAnalysisPermissions
     UpdateAnalysisPermissions
     (Maybe [ResourcePermission])
     (Maybe [ResourcePermission])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateAnalysisPermissions' {Maybe [ResourcePermission]
revokePermissions :: Maybe [ResourcePermission]
$sel:revokePermissions:UpdateAnalysisPermissions' :: UpdateAnalysisPermissions -> Maybe [ResourcePermission]
revokePermissions} -> Maybe [ResourcePermission]
revokePermissions) (\s :: UpdateAnalysisPermissions
s@UpdateAnalysisPermissions' {} Maybe [ResourcePermission]
a -> UpdateAnalysisPermissions
s {$sel:revokePermissions:UpdateAnalysisPermissions' :: Maybe [ResourcePermission]
revokePermissions = Maybe [ResourcePermission]
a} :: UpdateAnalysisPermissions) ((Maybe [ResourcePermission] -> f (Maybe [ResourcePermission]))
 -> UpdateAnalysisPermissions -> f UpdateAnalysisPermissions)
-> ((Maybe [ResourcePermission] -> f (Maybe [ResourcePermission]))
    -> Maybe [ResourcePermission] -> f (Maybe [ResourcePermission]))
-> (Maybe [ResourcePermission] -> f (Maybe [ResourcePermission]))
-> UpdateAnalysisPermissions
-> f UpdateAnalysisPermissions
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ResourcePermission]
  [ResourcePermission]
  [ResourcePermission]
  [ResourcePermission]
-> Iso
     (Maybe [ResourcePermission])
     (Maybe [ResourcePermission])
     (Maybe [ResourcePermission])
     (Maybe [ResourcePermission])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [ResourcePermission]
  [ResourcePermission]
  [ResourcePermission]
  [ResourcePermission]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A structure that describes the permissions to add and the principal to
-- add them to.
updateAnalysisPermissions_grantPermissions :: Lens.Lens' UpdateAnalysisPermissions (Prelude.Maybe [ResourcePermission])
updateAnalysisPermissions_grantPermissions :: (Maybe [ResourcePermission] -> f (Maybe [ResourcePermission]))
-> UpdateAnalysisPermissions -> f UpdateAnalysisPermissions
updateAnalysisPermissions_grantPermissions = (UpdateAnalysisPermissions -> Maybe [ResourcePermission])
-> (UpdateAnalysisPermissions
    -> Maybe [ResourcePermission] -> UpdateAnalysisPermissions)
-> Lens
     UpdateAnalysisPermissions
     UpdateAnalysisPermissions
     (Maybe [ResourcePermission])
     (Maybe [ResourcePermission])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateAnalysisPermissions' {Maybe [ResourcePermission]
grantPermissions :: Maybe [ResourcePermission]
$sel:grantPermissions:UpdateAnalysisPermissions' :: UpdateAnalysisPermissions -> Maybe [ResourcePermission]
grantPermissions} -> Maybe [ResourcePermission]
grantPermissions) (\s :: UpdateAnalysisPermissions
s@UpdateAnalysisPermissions' {} Maybe [ResourcePermission]
a -> UpdateAnalysisPermissions
s {$sel:grantPermissions:UpdateAnalysisPermissions' :: Maybe [ResourcePermission]
grantPermissions = Maybe [ResourcePermission]
a} :: UpdateAnalysisPermissions) ((Maybe [ResourcePermission] -> f (Maybe [ResourcePermission]))
 -> UpdateAnalysisPermissions -> f UpdateAnalysisPermissions)
-> ((Maybe [ResourcePermission] -> f (Maybe [ResourcePermission]))
    -> Maybe [ResourcePermission] -> f (Maybe [ResourcePermission]))
-> (Maybe [ResourcePermission] -> f (Maybe [ResourcePermission]))
-> UpdateAnalysisPermissions
-> f UpdateAnalysisPermissions
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ResourcePermission]
  [ResourcePermission]
  [ResourcePermission]
  [ResourcePermission]
-> Iso
     (Maybe [ResourcePermission])
     (Maybe [ResourcePermission])
     (Maybe [ResourcePermission])
     (Maybe [ResourcePermission])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [ResourcePermission]
  [ResourcePermission]
  [ResourcePermission]
  [ResourcePermission]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The ID of the Amazon Web Services account that contains the analysis
-- whose permissions you\'re updating. You must be using the Amazon Web
-- Services account that the analysis is in.
updateAnalysisPermissions_awsAccountId :: Lens.Lens' UpdateAnalysisPermissions Prelude.Text
updateAnalysisPermissions_awsAccountId :: (Text -> f Text)
-> UpdateAnalysisPermissions -> f UpdateAnalysisPermissions
updateAnalysisPermissions_awsAccountId = (UpdateAnalysisPermissions -> Text)
-> (UpdateAnalysisPermissions -> Text -> UpdateAnalysisPermissions)
-> Lens
     UpdateAnalysisPermissions UpdateAnalysisPermissions Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateAnalysisPermissions' {Text
awsAccountId :: Text
$sel:awsAccountId:UpdateAnalysisPermissions' :: UpdateAnalysisPermissions -> Text
awsAccountId} -> Text
awsAccountId) (\s :: UpdateAnalysisPermissions
s@UpdateAnalysisPermissions' {} Text
a -> UpdateAnalysisPermissions
s {$sel:awsAccountId:UpdateAnalysisPermissions' :: Text
awsAccountId = Text
a} :: UpdateAnalysisPermissions)

-- | The ID of the analysis whose permissions you\'re updating. The ID is
-- part of the analysis URL.
updateAnalysisPermissions_analysisId :: Lens.Lens' UpdateAnalysisPermissions Prelude.Text
updateAnalysisPermissions_analysisId :: (Text -> f Text)
-> UpdateAnalysisPermissions -> f UpdateAnalysisPermissions
updateAnalysisPermissions_analysisId = (UpdateAnalysisPermissions -> Text)
-> (UpdateAnalysisPermissions -> Text -> UpdateAnalysisPermissions)
-> Lens
     UpdateAnalysisPermissions UpdateAnalysisPermissions Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateAnalysisPermissions' {Text
analysisId :: Text
$sel:analysisId:UpdateAnalysisPermissions' :: UpdateAnalysisPermissions -> Text
analysisId} -> Text
analysisId) (\s :: UpdateAnalysisPermissions
s@UpdateAnalysisPermissions' {} Text
a -> UpdateAnalysisPermissions
s {$sel:analysisId:UpdateAnalysisPermissions' :: Text
analysisId = Text
a} :: UpdateAnalysisPermissions)

instance Core.AWSRequest UpdateAnalysisPermissions where
  type
    AWSResponse UpdateAnalysisPermissions =
      UpdateAnalysisPermissionsResponse
  request :: UpdateAnalysisPermissions -> Request UpdateAnalysisPermissions
request = Service
-> UpdateAnalysisPermissions -> Request UpdateAnalysisPermissions
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateAnalysisPermissions
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateAnalysisPermissions)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse UpdateAnalysisPermissions))
-> Logger
-> Service
-> Proxy UpdateAnalysisPermissions
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateAnalysisPermissions)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe (NonEmpty ResourcePermission)
-> Int
-> UpdateAnalysisPermissionsResponse
UpdateAnalysisPermissionsResponse'
            (Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe (NonEmpty ResourcePermission)
 -> Int
 -> UpdateAnalysisPermissionsResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Text
      -> Maybe Text
      -> Maybe (NonEmpty ResourcePermission)
      -> Int
      -> UpdateAnalysisPermissionsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"RequestId")
            Either
  String
  (Maybe Text
   -> Maybe Text
   -> Maybe (NonEmpty ResourcePermission)
   -> Int
   -> UpdateAnalysisPermissionsResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Text
      -> Maybe (NonEmpty ResourcePermission)
      -> Int
      -> UpdateAnalysisPermissionsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"AnalysisId")
            Either
  String
  (Maybe Text
   -> Maybe (NonEmpty ResourcePermission)
   -> Int
   -> UpdateAnalysisPermissionsResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe (NonEmpty ResourcePermission)
      -> Int -> UpdateAnalysisPermissionsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"AnalysisArn")
            Either
  String
  (Maybe (NonEmpty ResourcePermission)
   -> Int -> UpdateAnalysisPermissionsResponse)
-> Either String (Maybe (NonEmpty ResourcePermission))
-> Either String (Int -> UpdateAnalysisPermissionsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object
-> Text -> Either String (Maybe (NonEmpty ResourcePermission))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Permissions")
            Either String (Int -> UpdateAnalysisPermissionsResponse)
-> Either String Int
-> Either String UpdateAnalysisPermissionsResponse
forall (f :: * -> *) a b. Applicative f => 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 UpdateAnalysisPermissions

instance Prelude.NFData UpdateAnalysisPermissions

instance Core.ToHeaders UpdateAnalysisPermissions where
  toHeaders :: UpdateAnalysisPermissions -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateAnalysisPermissions -> 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.0" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON UpdateAnalysisPermissions where
  toJSON :: UpdateAnalysisPermissions -> Value
toJSON UpdateAnalysisPermissions' {Maybe [ResourcePermission]
Text
analysisId :: Text
awsAccountId :: Text
grantPermissions :: Maybe [ResourcePermission]
revokePermissions :: Maybe [ResourcePermission]
$sel:analysisId:UpdateAnalysisPermissions' :: UpdateAnalysisPermissions -> Text
$sel:awsAccountId:UpdateAnalysisPermissions' :: UpdateAnalysisPermissions -> Text
$sel:grantPermissions:UpdateAnalysisPermissions' :: UpdateAnalysisPermissions -> Maybe [ResourcePermission]
$sel:revokePermissions:UpdateAnalysisPermissions' :: UpdateAnalysisPermissions -> Maybe [ResourcePermission]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"RevokePermissions" Text -> [ResourcePermission] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([ResourcePermission] -> Pair)
-> Maybe [ResourcePermission] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [ResourcePermission]
revokePermissions,
            (Text
"GrantPermissions" Text -> [ResourcePermission] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([ResourcePermission] -> Pair)
-> Maybe [ResourcePermission] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [ResourcePermission]
grantPermissions
          ]
      )

instance Core.ToPath UpdateAnalysisPermissions where
  toPath :: UpdateAnalysisPermissions -> ByteString
toPath UpdateAnalysisPermissions' {Maybe [ResourcePermission]
Text
analysisId :: Text
awsAccountId :: Text
grantPermissions :: Maybe [ResourcePermission]
revokePermissions :: Maybe [ResourcePermission]
$sel:analysisId:UpdateAnalysisPermissions' :: UpdateAnalysisPermissions -> Text
$sel:awsAccountId:UpdateAnalysisPermissions' :: UpdateAnalysisPermissions -> Text
$sel:grantPermissions:UpdateAnalysisPermissions' :: UpdateAnalysisPermissions -> Maybe [ResourcePermission]
$sel:revokePermissions:UpdateAnalysisPermissions' :: UpdateAnalysisPermissions -> Maybe [ResourcePermission]
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/accounts/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
awsAccountId,
        ByteString
"/analyses/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
analysisId,
        ByteString
"/permissions"
      ]

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

-- | /See:/ 'newUpdateAnalysisPermissionsResponse' smart constructor.
data UpdateAnalysisPermissionsResponse = UpdateAnalysisPermissionsResponse'
  { -- | The Amazon Web Services request ID for this operation.
    UpdateAnalysisPermissionsResponse -> Maybe Text
requestId :: Prelude.Maybe Prelude.Text,
    -- | The ID of the analysis that you updated permissions for.
    UpdateAnalysisPermissionsResponse -> Maybe Text
analysisId :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the analysis that you updated.
    UpdateAnalysisPermissionsResponse -> Maybe Text
analysisArn :: Prelude.Maybe Prelude.Text,
    -- | A structure that describes the principals and the resource-level
    -- permissions on an analysis.
    UpdateAnalysisPermissionsResponse
-> Maybe (NonEmpty ResourcePermission)
permissions :: Prelude.Maybe (Prelude.NonEmpty ResourcePermission),
    -- | The HTTP status of the request.
    UpdateAnalysisPermissionsResponse -> Int
status :: Prelude.Int
  }
  deriving (UpdateAnalysisPermissionsResponse
-> UpdateAnalysisPermissionsResponse -> Bool
(UpdateAnalysisPermissionsResponse
 -> UpdateAnalysisPermissionsResponse -> Bool)
-> (UpdateAnalysisPermissionsResponse
    -> UpdateAnalysisPermissionsResponse -> Bool)
-> Eq UpdateAnalysisPermissionsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateAnalysisPermissionsResponse
-> UpdateAnalysisPermissionsResponse -> Bool
$c/= :: UpdateAnalysisPermissionsResponse
-> UpdateAnalysisPermissionsResponse -> Bool
== :: UpdateAnalysisPermissionsResponse
-> UpdateAnalysisPermissionsResponse -> Bool
$c== :: UpdateAnalysisPermissionsResponse
-> UpdateAnalysisPermissionsResponse -> Bool
Prelude.Eq, ReadPrec [UpdateAnalysisPermissionsResponse]
ReadPrec UpdateAnalysisPermissionsResponse
Int -> ReadS UpdateAnalysisPermissionsResponse
ReadS [UpdateAnalysisPermissionsResponse]
(Int -> ReadS UpdateAnalysisPermissionsResponse)
-> ReadS [UpdateAnalysisPermissionsResponse]
-> ReadPrec UpdateAnalysisPermissionsResponse
-> ReadPrec [UpdateAnalysisPermissionsResponse]
-> Read UpdateAnalysisPermissionsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateAnalysisPermissionsResponse]
$creadListPrec :: ReadPrec [UpdateAnalysisPermissionsResponse]
readPrec :: ReadPrec UpdateAnalysisPermissionsResponse
$creadPrec :: ReadPrec UpdateAnalysisPermissionsResponse
readList :: ReadS [UpdateAnalysisPermissionsResponse]
$creadList :: ReadS [UpdateAnalysisPermissionsResponse]
readsPrec :: Int -> ReadS UpdateAnalysisPermissionsResponse
$creadsPrec :: Int -> ReadS UpdateAnalysisPermissionsResponse
Prelude.Read, Int -> UpdateAnalysisPermissionsResponse -> ShowS
[UpdateAnalysisPermissionsResponse] -> ShowS
UpdateAnalysisPermissionsResponse -> String
(Int -> UpdateAnalysisPermissionsResponse -> ShowS)
-> (UpdateAnalysisPermissionsResponse -> String)
-> ([UpdateAnalysisPermissionsResponse] -> ShowS)
-> Show UpdateAnalysisPermissionsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateAnalysisPermissionsResponse] -> ShowS
$cshowList :: [UpdateAnalysisPermissionsResponse] -> ShowS
show :: UpdateAnalysisPermissionsResponse -> String
$cshow :: UpdateAnalysisPermissionsResponse -> String
showsPrec :: Int -> UpdateAnalysisPermissionsResponse -> ShowS
$cshowsPrec :: Int -> UpdateAnalysisPermissionsResponse -> ShowS
Prelude.Show, (forall x.
 UpdateAnalysisPermissionsResponse
 -> Rep UpdateAnalysisPermissionsResponse x)
-> (forall x.
    Rep UpdateAnalysisPermissionsResponse x
    -> UpdateAnalysisPermissionsResponse)
-> Generic UpdateAnalysisPermissionsResponse
forall x.
Rep UpdateAnalysisPermissionsResponse x
-> UpdateAnalysisPermissionsResponse
forall x.
UpdateAnalysisPermissionsResponse
-> Rep UpdateAnalysisPermissionsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateAnalysisPermissionsResponse x
-> UpdateAnalysisPermissionsResponse
$cfrom :: forall x.
UpdateAnalysisPermissionsResponse
-> Rep UpdateAnalysisPermissionsResponse x
Prelude.Generic)

-- |
-- Create a value of 'UpdateAnalysisPermissionsResponse' 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', 'updateAnalysisPermissionsResponse_requestId' - The Amazon Web Services request ID for this operation.
--
-- 'analysisId', 'updateAnalysisPermissionsResponse_analysisId' - The ID of the analysis that you updated permissions for.
--
-- 'analysisArn', 'updateAnalysisPermissionsResponse_analysisArn' - The Amazon Resource Name (ARN) of the analysis that you updated.
--
-- 'permissions', 'updateAnalysisPermissionsResponse_permissions' - A structure that describes the principals and the resource-level
-- permissions on an analysis.
--
-- 'status', 'updateAnalysisPermissionsResponse_status' - The HTTP status of the request.
newUpdateAnalysisPermissionsResponse ::
  -- | 'status'
  Prelude.Int ->
  UpdateAnalysisPermissionsResponse
newUpdateAnalysisPermissionsResponse :: Int -> UpdateAnalysisPermissionsResponse
newUpdateAnalysisPermissionsResponse Int
pStatus_ =
  UpdateAnalysisPermissionsResponse' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe (NonEmpty ResourcePermission)
-> Int
-> UpdateAnalysisPermissionsResponse
UpdateAnalysisPermissionsResponse'
    { $sel:requestId:UpdateAnalysisPermissionsResponse' :: Maybe Text
requestId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:analysisId:UpdateAnalysisPermissionsResponse' :: Maybe Text
analysisId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:analysisArn:UpdateAnalysisPermissionsResponse' :: Maybe Text
analysisArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:permissions:UpdateAnalysisPermissionsResponse' :: Maybe (NonEmpty ResourcePermission)
permissions = Maybe (NonEmpty ResourcePermission)
forall a. Maybe a
Prelude.Nothing,
      $sel:status:UpdateAnalysisPermissionsResponse' :: Int
status = Int
pStatus_
    }

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

-- | The ID of the analysis that you updated permissions for.
updateAnalysisPermissionsResponse_analysisId :: Lens.Lens' UpdateAnalysisPermissionsResponse (Prelude.Maybe Prelude.Text)
updateAnalysisPermissionsResponse_analysisId :: (Maybe Text -> f (Maybe Text))
-> UpdateAnalysisPermissionsResponse
-> f UpdateAnalysisPermissionsResponse
updateAnalysisPermissionsResponse_analysisId = (UpdateAnalysisPermissionsResponse -> Maybe Text)
-> (UpdateAnalysisPermissionsResponse
    -> Maybe Text -> UpdateAnalysisPermissionsResponse)
-> Lens
     UpdateAnalysisPermissionsResponse
     UpdateAnalysisPermissionsResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateAnalysisPermissionsResponse' {Maybe Text
analysisId :: Maybe Text
$sel:analysisId:UpdateAnalysisPermissionsResponse' :: UpdateAnalysisPermissionsResponse -> Maybe Text
analysisId} -> Maybe Text
analysisId) (\s :: UpdateAnalysisPermissionsResponse
s@UpdateAnalysisPermissionsResponse' {} Maybe Text
a -> UpdateAnalysisPermissionsResponse
s {$sel:analysisId:UpdateAnalysisPermissionsResponse' :: Maybe Text
analysisId = Maybe Text
a} :: UpdateAnalysisPermissionsResponse)

-- | The Amazon Resource Name (ARN) of the analysis that you updated.
updateAnalysisPermissionsResponse_analysisArn :: Lens.Lens' UpdateAnalysisPermissionsResponse (Prelude.Maybe Prelude.Text)
updateAnalysisPermissionsResponse_analysisArn :: (Maybe Text -> f (Maybe Text))
-> UpdateAnalysisPermissionsResponse
-> f UpdateAnalysisPermissionsResponse
updateAnalysisPermissionsResponse_analysisArn = (UpdateAnalysisPermissionsResponse -> Maybe Text)
-> (UpdateAnalysisPermissionsResponse
    -> Maybe Text -> UpdateAnalysisPermissionsResponse)
-> Lens
     UpdateAnalysisPermissionsResponse
     UpdateAnalysisPermissionsResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateAnalysisPermissionsResponse' {Maybe Text
analysisArn :: Maybe Text
$sel:analysisArn:UpdateAnalysisPermissionsResponse' :: UpdateAnalysisPermissionsResponse -> Maybe Text
analysisArn} -> Maybe Text
analysisArn) (\s :: UpdateAnalysisPermissionsResponse
s@UpdateAnalysisPermissionsResponse' {} Maybe Text
a -> UpdateAnalysisPermissionsResponse
s {$sel:analysisArn:UpdateAnalysisPermissionsResponse' :: Maybe Text
analysisArn = Maybe Text
a} :: UpdateAnalysisPermissionsResponse)

-- | A structure that describes the principals and the resource-level
-- permissions on an analysis.
updateAnalysisPermissionsResponse_permissions :: Lens.Lens' UpdateAnalysisPermissionsResponse (Prelude.Maybe (Prelude.NonEmpty ResourcePermission))
updateAnalysisPermissionsResponse_permissions :: (Maybe (NonEmpty ResourcePermission)
 -> f (Maybe (NonEmpty ResourcePermission)))
-> UpdateAnalysisPermissionsResponse
-> f UpdateAnalysisPermissionsResponse
updateAnalysisPermissionsResponse_permissions = (UpdateAnalysisPermissionsResponse
 -> Maybe (NonEmpty ResourcePermission))
-> (UpdateAnalysisPermissionsResponse
    -> Maybe (NonEmpty ResourcePermission)
    -> UpdateAnalysisPermissionsResponse)
-> Lens
     UpdateAnalysisPermissionsResponse
     UpdateAnalysisPermissionsResponse
     (Maybe (NonEmpty ResourcePermission))
     (Maybe (NonEmpty ResourcePermission))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateAnalysisPermissionsResponse' {Maybe (NonEmpty ResourcePermission)
permissions :: Maybe (NonEmpty ResourcePermission)
$sel:permissions:UpdateAnalysisPermissionsResponse' :: UpdateAnalysisPermissionsResponse
-> Maybe (NonEmpty ResourcePermission)
permissions} -> Maybe (NonEmpty ResourcePermission)
permissions) (\s :: UpdateAnalysisPermissionsResponse
s@UpdateAnalysisPermissionsResponse' {} Maybe (NonEmpty ResourcePermission)
a -> UpdateAnalysisPermissionsResponse
s {$sel:permissions:UpdateAnalysisPermissionsResponse' :: Maybe (NonEmpty ResourcePermission)
permissions = Maybe (NonEmpty ResourcePermission)
a} :: UpdateAnalysisPermissionsResponse) ((Maybe (NonEmpty ResourcePermission)
  -> f (Maybe (NonEmpty ResourcePermission)))
 -> UpdateAnalysisPermissionsResponse
 -> f UpdateAnalysisPermissionsResponse)
-> ((Maybe (NonEmpty ResourcePermission)
     -> f (Maybe (NonEmpty ResourcePermission)))
    -> Maybe (NonEmpty ResourcePermission)
    -> f (Maybe (NonEmpty ResourcePermission)))
-> (Maybe (NonEmpty ResourcePermission)
    -> f (Maybe (NonEmpty ResourcePermission)))
-> UpdateAnalysisPermissionsResponse
-> f UpdateAnalysisPermissionsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty ResourcePermission)
  (NonEmpty ResourcePermission)
  (NonEmpty ResourcePermission)
  (NonEmpty ResourcePermission)
-> Iso
     (Maybe (NonEmpty ResourcePermission))
     (Maybe (NonEmpty ResourcePermission))
     (Maybe (NonEmpty ResourcePermission))
     (Maybe (NonEmpty ResourcePermission))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  (NonEmpty ResourcePermission)
  (NonEmpty ResourcePermission)
  (NonEmpty ResourcePermission)
  (NonEmpty ResourcePermission)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance
  Prelude.NFData
    UpdateAnalysisPermissionsResponse