amazonka-synthetics-2.0: gen/Amazonka/Synthetics/CreateGroup.hs
{-# 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.Synthetics.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)
--
-- Creates a group which you can use to associate canaries with each other,
-- including cross-Region canaries. Using groups can help you with managing
-- and automating your canaries, and you can also view aggregated run
-- results and statistics for all canaries in a group.
--
-- Groups are global resources. When you create a group, it is replicated
-- across Amazon Web Services Regions, and you can view it and add canaries
-- to it from any Region. Although the group ARN format reflects the Region
-- name where it was created, a group is not constrained to any Region.
-- This means that you can put canaries from multiple Regions into the same
-- group, and then use that group to view and manage all of those canaries
-- in a single view.
--
-- Groups are supported in all Regions except the Regions that are disabled
-- by default. For more information about these Regions, see
-- <https://docs.aws.amazon.com/general/latest/gr/rande-manage.html#rande-manage-enable Enabling a Region>.
--
-- Each group can contain as many as 10 canaries. You can have as many as
-- 20 groups in your account. Any single canary can be a member of up to 10
-- groups.
module Amazonka.Synthetics.CreateGroup
( -- * Creating a Request
CreateGroup (..),
newCreateGroup,
-- * Request Lenses
createGroup_tags,
createGroup_name,
-- * Destructuring the Response
CreateGroupResponse (..),
newCreateGroupResponse,
-- * Response Lenses
createGroupResponse_group,
createGroupResponse_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.Synthetics.Types
-- | /See:/ 'newCreateGroup' smart constructor.
data CreateGroup = CreateGroup'
{ -- | A list of key-value pairs to associate with the group. You can associate
-- as many as 50 tags with a group.
--
-- Tags can help you organize and categorize your resources. You can also
-- use them to scope user permissions, by granting a user permission to
-- access or change only the resources that have certain tag values.
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
-- | The name for the group. It can include any Unicode characters.
--
-- The names for all groups in your account, across all Regions, must be
-- unique.
name :: Prelude.Text
}
deriving (Prelude.Eq, Prelude.Read, Prelude.Show, 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:
--
-- 'tags', 'createGroup_tags' - A list of key-value pairs to associate with the group. You can associate
-- as many as 50 tags with a group.
--
-- Tags can help you organize and categorize your resources. You can also
-- use them to scope user permissions, by granting a user permission to
-- access or change only the resources that have certain tag values.
--
-- 'name', 'createGroup_name' - The name for the group. It can include any Unicode characters.
--
-- The names for all groups in your account, across all Regions, must be
-- unique.
newCreateGroup ::
-- | 'name'
Prelude.Text ->
CreateGroup
newCreateGroup pName_ =
CreateGroup' {tags = Prelude.Nothing, name = pName_}
-- | A list of key-value pairs to associate with the group. You can associate
-- as many as 50 tags with a group.
--
-- Tags can help you organize and categorize your resources. You can also
-- use them to scope user permissions, by granting a user permission to
-- access or change only the resources that have certain tag values.
createGroup_tags :: Lens.Lens' CreateGroup (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
createGroup_tags = Lens.lens (\CreateGroup' {tags} -> tags) (\s@CreateGroup' {} a -> s {tags = a} :: CreateGroup) Prelude.. Lens.mapping Lens.coerced
-- | The name for the group. It can include any Unicode characters.
--
-- The names for all groups in your account, across all Regions, must be
-- unique.
createGroup_name :: Lens.Lens' CreateGroup Prelude.Text
createGroup_name = Lens.lens (\CreateGroup' {name} -> name) (\s@CreateGroup' {} a -> s {name = a} :: CreateGroup)
instance Core.AWSRequest CreateGroup where
type AWSResponse CreateGroup = CreateGroupResponse
request overrides =
Request.postJSON (overrides defaultService)
response =
Response.receiveJSON
( \s h x ->
CreateGroupResponse'
Prelude.<$> (x Data..?> "Group")
Prelude.<*> (Prelude.pure (Prelude.fromEnum s))
)
instance Prelude.Hashable CreateGroup where
hashWithSalt _salt CreateGroup' {..} =
_salt
`Prelude.hashWithSalt` tags
`Prelude.hashWithSalt` name
instance Prelude.NFData CreateGroup where
rnf CreateGroup' {..} =
Prelude.rnf tags `Prelude.seq` Prelude.rnf name
instance Data.ToHeaders CreateGroup where
toHeaders =
Prelude.const
( Prelude.mconcat
[ "Content-Type"
Data.=# ( "application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Data.ToJSON CreateGroup where
toJSON CreateGroup' {..} =
Data.object
( Prelude.catMaybes
[ ("Tags" Data..=) Prelude.<$> tags,
Prelude.Just ("Name" Data..= name)
]
)
instance Data.ToPath CreateGroup where
toPath = Prelude.const "/group"
instance Data.ToQuery CreateGroup where
toQuery = Prelude.const Prelude.mempty
-- | /See:/ 'newCreateGroupResponse' smart constructor.
data CreateGroupResponse = CreateGroupResponse'
{ -- | A structure that contains information about the group that was just
-- created.
group' :: Prelude.Maybe Group,
-- | The response's http status code.
httpStatus :: Prelude.Int
}
deriving (Prelude.Eq, Prelude.Read, Prelude.Show, 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' - A structure that contains information about the group that was just
-- created.
--
-- 'httpStatus', 'createGroupResponse_httpStatus' - The response's http status code.
newCreateGroupResponse ::
-- | 'httpStatus'
Prelude.Int ->
CreateGroupResponse
newCreateGroupResponse pHttpStatus_ =
CreateGroupResponse'
{ group' = Prelude.Nothing,
httpStatus = pHttpStatus_
}
-- | A structure that contains information about the group that was just
-- created.
createGroupResponse_group :: Lens.Lens' CreateGroupResponse (Prelude.Maybe Group)
createGroupResponse_group = Lens.lens (\CreateGroupResponse' {group'} -> group') (\s@CreateGroupResponse' {} a -> s {group' = a} :: CreateGroupResponse)
-- | The response's http status code.
createGroupResponse_httpStatus :: Lens.Lens' CreateGroupResponse Prelude.Int
createGroupResponse_httpStatus = Lens.lens (\CreateGroupResponse' {httpStatus} -> httpStatus) (\s@CreateGroupResponse' {} a -> s {httpStatus = a} :: CreateGroupResponse)
instance Prelude.NFData CreateGroupResponse where
rnf CreateGroupResponse' {..} =
Prelude.rnf group'
`Prelude.seq` Prelude.rnf httpStatus