{-# 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.UpdateGroup
-- 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)
--
-- Changes a group description.
module Amazonka.QuickSight.UpdateGroup
  ( -- * Creating a Request
    UpdateGroup (..),
    newUpdateGroup,

    -- * Request Lenses
    updateGroup_description,
    updateGroup_groupName,
    updateGroup_awsAccountId,
    updateGroup_namespace,

    -- * Destructuring the Response
    UpdateGroupResponse (..),
    newUpdateGroupResponse,

    -- * Response Lenses
    updateGroupResponse_requestId,
    updateGroupResponse_group,
    updateGroupResponse_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:/ 'newUpdateGroup' smart constructor.
data UpdateGroup = UpdateGroup'
  { -- | The description for the group that you want to update.
    UpdateGroup -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The name of the group that you want to update.
    UpdateGroup -> Text
groupName :: Prelude.Text,
    -- | The ID for the Amazon Web Services account that the group is in.
    -- Currently, you use the ID for the Amazon Web Services account that
    -- contains your Amazon QuickSight account.
    UpdateGroup -> Text
awsAccountId :: Prelude.Text,
    -- | The namespace. Currently, you should set this to @default@.
    UpdateGroup -> Text
namespace :: Prelude.Text
  }
  deriving (UpdateGroup -> UpdateGroup -> Bool
(UpdateGroup -> UpdateGroup -> Bool)
-> (UpdateGroup -> UpdateGroup -> Bool) -> Eq UpdateGroup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateGroup -> UpdateGroup -> Bool
$c/= :: UpdateGroup -> UpdateGroup -> Bool
== :: UpdateGroup -> UpdateGroup -> Bool
$c== :: UpdateGroup -> UpdateGroup -> Bool
Prelude.Eq, ReadPrec [UpdateGroup]
ReadPrec UpdateGroup
Int -> ReadS UpdateGroup
ReadS [UpdateGroup]
(Int -> ReadS UpdateGroup)
-> ReadS [UpdateGroup]
-> ReadPrec UpdateGroup
-> ReadPrec [UpdateGroup]
-> Read UpdateGroup
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateGroup]
$creadListPrec :: ReadPrec [UpdateGroup]
readPrec :: ReadPrec UpdateGroup
$creadPrec :: ReadPrec UpdateGroup
readList :: ReadS [UpdateGroup]
$creadList :: ReadS [UpdateGroup]
readsPrec :: Int -> ReadS UpdateGroup
$creadsPrec :: Int -> ReadS UpdateGroup
Prelude.Read, Int -> UpdateGroup -> ShowS
[UpdateGroup] -> ShowS
UpdateGroup -> String
(Int -> UpdateGroup -> ShowS)
-> (UpdateGroup -> String)
-> ([UpdateGroup] -> ShowS)
-> Show UpdateGroup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateGroup] -> ShowS
$cshowList :: [UpdateGroup] -> ShowS
show :: UpdateGroup -> String
$cshow :: UpdateGroup -> String
showsPrec :: Int -> UpdateGroup -> ShowS
$cshowsPrec :: Int -> UpdateGroup -> ShowS
Prelude.Show, (forall x. UpdateGroup -> Rep UpdateGroup x)
-> (forall x. Rep UpdateGroup x -> UpdateGroup)
-> Generic UpdateGroup
forall x. Rep UpdateGroup x -> UpdateGroup
forall x. UpdateGroup -> Rep UpdateGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateGroup x -> UpdateGroup
$cfrom :: forall x. UpdateGroup -> Rep UpdateGroup x
Prelude.Generic)

-- |
-- Create a value of 'UpdateGroup' 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:
--
-- 'description', 'updateGroup_description' - The description for the group that you want to update.
--
-- 'groupName', 'updateGroup_groupName' - The name of the group that you want to update.
--
-- 'awsAccountId', 'updateGroup_awsAccountId' - The ID for the Amazon Web Services account that the group is in.
-- Currently, you use the ID for the Amazon Web Services account that
-- contains your Amazon QuickSight account.
--
-- 'namespace', 'updateGroup_namespace' - The namespace. Currently, you should set this to @default@.
newUpdateGroup ::
  -- | 'groupName'
  Prelude.Text ->
  -- | 'awsAccountId'
  Prelude.Text ->
  -- | 'namespace'
  Prelude.Text ->
  UpdateGroup
newUpdateGroup :: Text -> Text -> Text -> UpdateGroup
newUpdateGroup Text
pGroupName_ Text
pAwsAccountId_ Text
pNamespace_ =
  UpdateGroup' :: Maybe Text -> Text -> Text -> Text -> UpdateGroup
UpdateGroup'
    { $sel:description:UpdateGroup' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:groupName:UpdateGroup' :: Text
groupName = Text
pGroupName_,
      $sel:awsAccountId:UpdateGroup' :: Text
awsAccountId = Text
pAwsAccountId_,
      $sel:namespace:UpdateGroup' :: Text
namespace = Text
pNamespace_
    }

-- | The description for the group that you want to update.
updateGroup_description :: Lens.Lens' UpdateGroup (Prelude.Maybe Prelude.Text)
updateGroup_description :: (Maybe Text -> f (Maybe Text)) -> UpdateGroup -> f UpdateGroup
updateGroup_description = (UpdateGroup -> Maybe Text)
-> (UpdateGroup -> Maybe Text -> UpdateGroup)
-> Lens UpdateGroup UpdateGroup (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateGroup' {Maybe Text
description :: Maybe Text
$sel:description:UpdateGroup' :: UpdateGroup -> Maybe Text
description} -> Maybe Text
description) (\s :: UpdateGroup
s@UpdateGroup' {} Maybe Text
a -> UpdateGroup
s {$sel:description:UpdateGroup' :: Maybe Text
description = Maybe Text
a} :: UpdateGroup)

-- | The name of the group that you want to update.
updateGroup_groupName :: Lens.Lens' UpdateGroup Prelude.Text
updateGroup_groupName :: (Text -> f Text) -> UpdateGroup -> f UpdateGroup
updateGroup_groupName = (UpdateGroup -> Text)
-> (UpdateGroup -> Text -> UpdateGroup)
-> Lens UpdateGroup UpdateGroup Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateGroup' {Text
groupName :: Text
$sel:groupName:UpdateGroup' :: UpdateGroup -> Text
groupName} -> Text
groupName) (\s :: UpdateGroup
s@UpdateGroup' {} Text
a -> UpdateGroup
s {$sel:groupName:UpdateGroup' :: Text
groupName = Text
a} :: UpdateGroup)

-- | The ID for the Amazon Web Services account that the group is in.
-- Currently, you use the ID for the Amazon Web Services account that
-- contains your Amazon QuickSight account.
updateGroup_awsAccountId :: Lens.Lens' UpdateGroup Prelude.Text
updateGroup_awsAccountId :: (Text -> f Text) -> UpdateGroup -> f UpdateGroup
updateGroup_awsAccountId = (UpdateGroup -> Text)
-> (UpdateGroup -> Text -> UpdateGroup)
-> Lens UpdateGroup UpdateGroup Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateGroup' {Text
awsAccountId :: Text
$sel:awsAccountId:UpdateGroup' :: UpdateGroup -> Text
awsAccountId} -> Text
awsAccountId) (\s :: UpdateGroup
s@UpdateGroup' {} Text
a -> UpdateGroup
s {$sel:awsAccountId:UpdateGroup' :: Text
awsAccountId = Text
a} :: UpdateGroup)

-- | The namespace. Currently, you should set this to @default@.
updateGroup_namespace :: Lens.Lens' UpdateGroup Prelude.Text
updateGroup_namespace :: (Text -> f Text) -> UpdateGroup -> f UpdateGroup
updateGroup_namespace = (UpdateGroup -> Text)
-> (UpdateGroup -> Text -> UpdateGroup)
-> Lens UpdateGroup UpdateGroup Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateGroup' {Text
namespace :: Text
$sel:namespace:UpdateGroup' :: UpdateGroup -> Text
namespace} -> Text
namespace) (\s :: UpdateGroup
s@UpdateGroup' {} Text
a -> UpdateGroup
s {$sel:namespace:UpdateGroup' :: Text
namespace = Text
a} :: UpdateGroup)

instance Core.AWSRequest UpdateGroup where
  type AWSResponse UpdateGroup = UpdateGroupResponse
  request :: UpdateGroup -> Request UpdateGroup
request = Service -> UpdateGroup -> Request UpdateGroup
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateGroup
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateGroup)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse UpdateGroup))
-> Logger
-> Service
-> Proxy UpdateGroup
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateGroup)))
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 Group -> Int -> UpdateGroupResponse
UpdateGroupResponse'
            (Maybe Text -> Maybe Group -> Int -> UpdateGroupResponse)
-> Either String (Maybe Text)
-> Either String (Maybe Group -> Int -> UpdateGroupResponse)
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 Group -> Int -> UpdateGroupResponse)
-> Either String (Maybe Group)
-> Either String (Int -> UpdateGroupResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Group)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Group")
            Either String (Int -> UpdateGroupResponse)
-> Either String Int -> Either String UpdateGroupResponse
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 UpdateGroup

instance Prelude.NFData UpdateGroup

instance Core.ToHeaders UpdateGroup where
  toHeaders :: UpdateGroup -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateGroup -> 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 UpdateGroup where
  toJSON :: UpdateGroup -> Value
toJSON UpdateGroup' {Maybe Text
Text
namespace :: Text
awsAccountId :: Text
groupName :: Text
description :: Maybe Text
$sel:namespace:UpdateGroup' :: UpdateGroup -> Text
$sel:awsAccountId:UpdateGroup' :: UpdateGroup -> Text
$sel:groupName:UpdateGroup' :: UpdateGroup -> Text
$sel:description:UpdateGroup' :: UpdateGroup -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Text
"Description" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
description]
      )

instance Core.ToPath UpdateGroup where
  toPath :: UpdateGroup -> ByteString
toPath UpdateGroup' {Maybe Text
Text
namespace :: Text
awsAccountId :: Text
groupName :: Text
description :: Maybe Text
$sel:namespace:UpdateGroup' :: UpdateGroup -> Text
$sel:awsAccountId:UpdateGroup' :: UpdateGroup -> Text
$sel:groupName:UpdateGroup' :: UpdateGroup -> Text
$sel:description:UpdateGroup' :: UpdateGroup -> Maybe Text
..} =
    [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
"/namespaces/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
namespace,
        ByteString
"/groups/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
groupName
      ]

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

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

-- |
-- Create a value of 'UpdateGroupResponse' 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', 'updateGroupResponse_requestId' - The Amazon Web Services request ID for this operation.
--
-- 'group'', 'updateGroupResponse_group' - The name of the group.
--
-- 'status', 'updateGroupResponse_status' - The HTTP status of the request.
newUpdateGroupResponse ::
  -- | 'status'
  Prelude.Int ->
  UpdateGroupResponse
newUpdateGroupResponse :: Int -> UpdateGroupResponse
newUpdateGroupResponse Int
pStatus_ =
  UpdateGroupResponse' :: Maybe Text -> Maybe Group -> Int -> UpdateGroupResponse
UpdateGroupResponse'
    { $sel:requestId:UpdateGroupResponse' :: Maybe Text
requestId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:group':UpdateGroupResponse' :: Maybe Group
group' = Maybe Group
forall a. Maybe a
Prelude.Nothing,
      $sel:status:UpdateGroupResponse' :: Int
status = Int
pStatus_
    }

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

-- | The name of the group.
updateGroupResponse_group :: Lens.Lens' UpdateGroupResponse (Prelude.Maybe Group)
updateGroupResponse_group :: (Maybe Group -> f (Maybe Group))
-> UpdateGroupResponse -> f UpdateGroupResponse
updateGroupResponse_group = (UpdateGroupResponse -> Maybe Group)
-> (UpdateGroupResponse -> Maybe Group -> UpdateGroupResponse)
-> Lens
     UpdateGroupResponse UpdateGroupResponse (Maybe Group) (Maybe Group)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateGroupResponse' {Maybe Group
group' :: Maybe Group
$sel:group':UpdateGroupResponse' :: UpdateGroupResponse -> Maybe Group
group'} -> Maybe Group
group') (\s :: UpdateGroupResponse
s@UpdateGroupResponse' {} Maybe Group
a -> UpdateGroupResponse
s {$sel:group':UpdateGroupResponse' :: Maybe Group
group' = Maybe Group
a} :: UpdateGroupResponse)

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

instance Prelude.NFData UpdateGroupResponse