{-# 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.CreateGroup
-- 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 @CreateGroup@ operation to create a group in Amazon QuickSight.
-- You can create up to 10,000 groups in a namespace. If you want to create
-- more than 10,000 groups in a namespace, contact AWS Support.
--
-- The permissions resource is
-- @arn:aws:quicksight:\<your-region>:@/@\<relevant-aws-account-id>@/@:group\/default\/@/@\<group-name>@/@ @.
--
-- The response is a group object.
module Amazonka.QuickSight.CreateGroup
  ( -- * Creating a Request
    CreateGroup (..),
    newCreateGroup,

    -- * Request Lenses
    createGroup_description,
    createGroup_groupName,
    createGroup_awsAccountId,
    createGroup_namespace,

    -- * Destructuring the Response
    CreateGroupResponse (..),
    newCreateGroupResponse,

    -- * Response Lenses
    createGroupResponse_group,
    createGroupResponse_requestId,
    createGroupResponse_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

-- | The request object for this operation.
--
-- /See:/ 'newCreateGroup' smart constructor.
data CreateGroup = CreateGroup'
  { -- | A description for the group that you want to create.
    CreateGroup -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | A name for the group that you want to create.
    CreateGroup -> 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.
    CreateGroup -> Text
awsAccountId :: Prelude.Text,
    -- | The namespace that you want the group to be a part of.
    CreateGroup -> Text
namespace :: Prelude.Text
  }
  deriving (CreateGroup -> CreateGroup -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateGroup -> CreateGroup -> Bool
$c/= :: CreateGroup -> CreateGroup -> Bool
== :: CreateGroup -> CreateGroup -> Bool
$c== :: CreateGroup -> CreateGroup -> Bool
Prelude.Eq, ReadPrec [CreateGroup]
ReadPrec CreateGroup
Int -> ReadS CreateGroup
ReadS [CreateGroup]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateGroup]
$creadListPrec :: ReadPrec [CreateGroup]
readPrec :: ReadPrec CreateGroup
$creadPrec :: ReadPrec CreateGroup
readList :: ReadS [CreateGroup]
$creadList :: ReadS [CreateGroup]
readsPrec :: Int -> ReadS CreateGroup
$creadsPrec :: Int -> ReadS CreateGroup
Prelude.Read, Int -> CreateGroup -> ShowS
[CreateGroup] -> ShowS
CreateGroup -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateGroup] -> ShowS
$cshowList :: [CreateGroup] -> ShowS
show :: CreateGroup -> String
$cshow :: CreateGroup -> String
showsPrec :: Int -> CreateGroup -> ShowS
$cshowsPrec :: Int -> CreateGroup -> ShowS
Prelude.Show, forall x. Rep CreateGroup x -> CreateGroup
forall x. CreateGroup -> Rep CreateGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateGroup x -> CreateGroup
$cfrom :: forall x. CreateGroup -> Rep CreateGroup x
Prelude.Generic)

-- |
-- Create a value of 'CreateGroup' 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', 'createGroup_description' - A description for the group that you want to create.
--
-- 'groupName', 'createGroup_groupName' - A name for the group that you want to create.
--
-- 'awsAccountId', 'createGroup_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', 'createGroup_namespace' - The namespace that you want the group to be a part of.
newCreateGroup ::
  -- | 'groupName'
  Prelude.Text ->
  -- | 'awsAccountId'
  Prelude.Text ->
  -- | 'namespace'
  Prelude.Text ->
  CreateGroup
newCreateGroup :: Text -> Text -> Text -> CreateGroup
newCreateGroup Text
pGroupName_ Text
pAwsAccountId_ Text
pNamespace_ =
  CreateGroup'
    { $sel:description:CreateGroup' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
      $sel:groupName:CreateGroup' :: Text
groupName = Text
pGroupName_,
      $sel:awsAccountId:CreateGroup' :: Text
awsAccountId = Text
pAwsAccountId_,
      $sel:namespace:CreateGroup' :: Text
namespace = Text
pNamespace_
    }

-- | A description for the group that you want to create.
createGroup_description :: Lens.Lens' CreateGroup (Prelude.Maybe Prelude.Text)
createGroup_description :: Lens' CreateGroup (Maybe Text)
createGroup_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateGroup' {Maybe Text
description :: Maybe Text
$sel:description:CreateGroup' :: CreateGroup -> Maybe Text
description} -> Maybe Text
description) (\s :: CreateGroup
s@CreateGroup' {} Maybe Text
a -> CreateGroup
s {$sel:description:CreateGroup' :: Maybe Text
description = Maybe Text
a} :: CreateGroup)

-- | A name for the group that you want to create.
createGroup_groupName :: Lens.Lens' CreateGroup Prelude.Text
createGroup_groupName :: Lens' CreateGroup Text
createGroup_groupName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateGroup' {Text
groupName :: Text
$sel:groupName:CreateGroup' :: CreateGroup -> Text
groupName} -> Text
groupName) (\s :: CreateGroup
s@CreateGroup' {} Text
a -> CreateGroup
s {$sel:groupName:CreateGroup' :: Text
groupName = Text
a} :: CreateGroup)

-- | 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.
createGroup_awsAccountId :: Lens.Lens' CreateGroup Prelude.Text
createGroup_awsAccountId :: Lens' CreateGroup Text
createGroup_awsAccountId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateGroup' {Text
awsAccountId :: Text
$sel:awsAccountId:CreateGroup' :: CreateGroup -> Text
awsAccountId} -> Text
awsAccountId) (\s :: CreateGroup
s@CreateGroup' {} Text
a -> CreateGroup
s {$sel:awsAccountId:CreateGroup' :: Text
awsAccountId = Text
a} :: CreateGroup)

-- | The namespace that you want the group to be a part of.
createGroup_namespace :: Lens.Lens' CreateGroup Prelude.Text
createGroup_namespace :: Lens' CreateGroup Text
createGroup_namespace = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateGroup' {Text
namespace :: Text
$sel:namespace:CreateGroup' :: CreateGroup -> Text
namespace} -> Text
namespace) (\s :: CreateGroup
s@CreateGroup' {} Text
a -> CreateGroup
s {$sel:namespace:CreateGroup' :: Text
namespace = Text
a} :: CreateGroup)

instance Core.AWSRequest CreateGroup where
  type AWSResponse CreateGroup = CreateGroupResponse
  request :: (Service -> Service) -> CreateGroup -> Request CreateGroup
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 CreateGroup
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateGroup)))
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 Group -> Maybe Text -> Int -> CreateGroupResponse
CreateGroupResponse'
            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
"Group")
            forall (f :: * -> *) a b. Applicative f => 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 CreateGroup where
  hashWithSalt :: Int -> CreateGroup -> Int
hashWithSalt Int
_salt CreateGroup' {Maybe Text
Text
namespace :: Text
awsAccountId :: Text
groupName :: Text
description :: Maybe Text
$sel:namespace:CreateGroup' :: CreateGroup -> Text
$sel:awsAccountId:CreateGroup' :: CreateGroup -> Text
$sel:groupName:CreateGroup' :: CreateGroup -> Text
$sel:description:CreateGroup' :: CreateGroup -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
groupName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
awsAccountId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
namespace

instance Prelude.NFData CreateGroup where
  rnf :: CreateGroup -> ()
rnf CreateGroup' {Maybe Text
Text
namespace :: Text
awsAccountId :: Text
groupName :: Text
description :: Maybe Text
$sel:namespace:CreateGroup' :: CreateGroup -> Text
$sel:awsAccountId:CreateGroup' :: CreateGroup -> Text
$sel:groupName:CreateGroup' :: CreateGroup -> Text
$sel:description:CreateGroup' :: CreateGroup -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
description
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
groupName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
awsAccountId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
namespace

instance Data.ToHeaders CreateGroup where
  toHeaders :: CreateGroup -> 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 CreateGroup where
  toJSON :: CreateGroup -> Value
toJSON CreateGroup' {Maybe Text
Text
namespace :: Text
awsAccountId :: Text
groupName :: Text
description :: Maybe Text
$sel:namespace:CreateGroup' :: CreateGroup -> Text
$sel:awsAccountId:CreateGroup' :: CreateGroup -> Text
$sel:groupName:CreateGroup' :: CreateGroup -> Text
$sel:description:CreateGroup' :: CreateGroup -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Description" 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 Text
description,
            forall a. a -> Maybe a
Prelude.Just (Key
"GroupName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
groupName)
          ]
      )

instance Data.ToPath CreateGroup where
  toPath :: CreateGroup -> ByteString
toPath CreateGroup' {Maybe Text
Text
namespace :: Text
awsAccountId :: Text
groupName :: Text
description :: Maybe Text
$sel:namespace:CreateGroup' :: CreateGroup -> Text
$sel:awsAccountId:CreateGroup' :: CreateGroup -> Text
$sel:groupName:CreateGroup' :: CreateGroup -> Text
$sel:description:CreateGroup' :: CreateGroup -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/accounts/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
awsAccountId,
        ByteString
"/namespaces/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
namespace,
        ByteString
"/groups"
      ]

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

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

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

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

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

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

instance Prelude.NFData CreateGroupResponse where
  rnf :: CreateGroupResponse -> ()
rnf CreateGroupResponse' {Int
Maybe Text
Maybe Group
status :: Int
requestId :: Maybe Text
group' :: Maybe Group
$sel:status:CreateGroupResponse' :: CreateGroupResponse -> Int
$sel:requestId:CreateGroupResponse' :: CreateGroupResponse -> Maybe Text
$sel:group':CreateGroupResponse' :: CreateGroupResponse -> Maybe Group
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Group
group'
      seq :: forall a b. a -> b -> b
`Prelude.seq` 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