{-# 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.CodeBuild.CreateReportGroup
-- 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 report group. A report group contains a collection of reports.
module Amazonka.CodeBuild.CreateReportGroup
  ( -- * Creating a Request
    CreateReportGroup (..),
    newCreateReportGroup,

    -- * Request Lenses
    createReportGroup_tags,
    createReportGroup_name,
    createReportGroup_type,
    createReportGroup_exportConfig,

    -- * Destructuring the Response
    CreateReportGroupResponse (..),
    newCreateReportGroupResponse,

    -- * Response Lenses
    createReportGroupResponse_reportGroup,
    createReportGroupResponse_httpStatus,
  )
where

import Amazonka.CodeBuild.Types
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

-- | /See:/ 'newCreateReportGroup' smart constructor.
data CreateReportGroup = CreateReportGroup'
  { -- | A list of tag key and value pairs associated with this report group.
    --
    -- These tags are available for use by Amazon Web Services services that
    -- support CodeBuild report group tags.
    CreateReportGroup -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
    -- | The name of the report group.
    CreateReportGroup -> Text
name :: Prelude.Text,
    -- | The type of report group.
    CreateReportGroup -> ReportType
type' :: ReportType,
    -- | A @ReportExportConfig@ object that contains information about where the
    -- report group test results are exported.
    CreateReportGroup -> ReportExportConfig
exportConfig :: ReportExportConfig
  }
  deriving (CreateReportGroup -> CreateReportGroup -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateReportGroup -> CreateReportGroup -> Bool
$c/= :: CreateReportGroup -> CreateReportGroup -> Bool
== :: CreateReportGroup -> CreateReportGroup -> Bool
$c== :: CreateReportGroup -> CreateReportGroup -> Bool
Prelude.Eq, ReadPrec [CreateReportGroup]
ReadPrec CreateReportGroup
Int -> ReadS CreateReportGroup
ReadS [CreateReportGroup]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateReportGroup]
$creadListPrec :: ReadPrec [CreateReportGroup]
readPrec :: ReadPrec CreateReportGroup
$creadPrec :: ReadPrec CreateReportGroup
readList :: ReadS [CreateReportGroup]
$creadList :: ReadS [CreateReportGroup]
readsPrec :: Int -> ReadS CreateReportGroup
$creadsPrec :: Int -> ReadS CreateReportGroup
Prelude.Read, Int -> CreateReportGroup -> ShowS
[CreateReportGroup] -> ShowS
CreateReportGroup -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateReportGroup] -> ShowS
$cshowList :: [CreateReportGroup] -> ShowS
show :: CreateReportGroup -> String
$cshow :: CreateReportGroup -> String
showsPrec :: Int -> CreateReportGroup -> ShowS
$cshowsPrec :: Int -> CreateReportGroup -> ShowS
Prelude.Show, forall x. Rep CreateReportGroup x -> CreateReportGroup
forall x. CreateReportGroup -> Rep CreateReportGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateReportGroup x -> CreateReportGroup
$cfrom :: forall x. CreateReportGroup -> Rep CreateReportGroup x
Prelude.Generic)

-- |
-- Create a value of 'CreateReportGroup' 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', 'createReportGroup_tags' - A list of tag key and value pairs associated with this report group.
--
-- These tags are available for use by Amazon Web Services services that
-- support CodeBuild report group tags.
--
-- 'name', 'createReportGroup_name' - The name of the report group.
--
-- 'type'', 'createReportGroup_type' - The type of report group.
--
-- 'exportConfig', 'createReportGroup_exportConfig' - A @ReportExportConfig@ object that contains information about where the
-- report group test results are exported.
newCreateReportGroup ::
  -- | 'name'
  Prelude.Text ->
  -- | 'type''
  ReportType ->
  -- | 'exportConfig'
  ReportExportConfig ->
  CreateReportGroup
newCreateReportGroup :: Text -> ReportType -> ReportExportConfig -> CreateReportGroup
newCreateReportGroup Text
pName_ ReportType
pType_ ReportExportConfig
pExportConfig_ =
  CreateReportGroup'
    { $sel:tags:CreateReportGroup' :: Maybe [Tag]
tags = forall a. Maybe a
Prelude.Nothing,
      $sel:name:CreateReportGroup' :: Text
name = Text
pName_,
      $sel:type':CreateReportGroup' :: ReportType
type' = ReportType
pType_,
      $sel:exportConfig:CreateReportGroup' :: ReportExportConfig
exportConfig = ReportExportConfig
pExportConfig_
    }

-- | A list of tag key and value pairs associated with this report group.
--
-- These tags are available for use by Amazon Web Services services that
-- support CodeBuild report group tags.
createReportGroup_tags :: Lens.Lens' CreateReportGroup (Prelude.Maybe [Tag])
createReportGroup_tags :: Lens' CreateReportGroup (Maybe [Tag])
createReportGroup_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateReportGroup' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:CreateReportGroup' :: CreateReportGroup -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: CreateReportGroup
s@CreateReportGroup' {} Maybe [Tag]
a -> CreateReportGroup
s {$sel:tags:CreateReportGroup' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: CreateReportGroup) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of the report group.
createReportGroup_name :: Lens.Lens' CreateReportGroup Prelude.Text
createReportGroup_name :: Lens' CreateReportGroup Text
createReportGroup_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateReportGroup' {Text
name :: Text
$sel:name:CreateReportGroup' :: CreateReportGroup -> Text
name} -> Text
name) (\s :: CreateReportGroup
s@CreateReportGroup' {} Text
a -> CreateReportGroup
s {$sel:name:CreateReportGroup' :: Text
name = Text
a} :: CreateReportGroup)

-- | The type of report group.
createReportGroup_type :: Lens.Lens' CreateReportGroup ReportType
createReportGroup_type :: Lens' CreateReportGroup ReportType
createReportGroup_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateReportGroup' {ReportType
type' :: ReportType
$sel:type':CreateReportGroup' :: CreateReportGroup -> ReportType
type'} -> ReportType
type') (\s :: CreateReportGroup
s@CreateReportGroup' {} ReportType
a -> CreateReportGroup
s {$sel:type':CreateReportGroup' :: ReportType
type' = ReportType
a} :: CreateReportGroup)

-- | A @ReportExportConfig@ object that contains information about where the
-- report group test results are exported.
createReportGroup_exportConfig :: Lens.Lens' CreateReportGroup ReportExportConfig
createReportGroup_exportConfig :: Lens' CreateReportGroup ReportExportConfig
createReportGroup_exportConfig = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateReportGroup' {ReportExportConfig
exportConfig :: ReportExportConfig
$sel:exportConfig:CreateReportGroup' :: CreateReportGroup -> ReportExportConfig
exportConfig} -> ReportExportConfig
exportConfig) (\s :: CreateReportGroup
s@CreateReportGroup' {} ReportExportConfig
a -> CreateReportGroup
s {$sel:exportConfig:CreateReportGroup' :: ReportExportConfig
exportConfig = ReportExportConfig
a} :: CreateReportGroup)

instance Core.AWSRequest CreateReportGroup where
  type
    AWSResponse CreateReportGroup =
      CreateReportGroupResponse
  request :: (Service -> Service)
-> CreateReportGroup -> Request CreateReportGroup
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 CreateReportGroup
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateReportGroup)))
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 ReportGroup -> Int -> CreateReportGroupResponse
CreateReportGroupResponse'
            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
"reportGroup")
            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 CreateReportGroup where
  hashWithSalt :: Int -> CreateReportGroup -> Int
hashWithSalt Int
_salt CreateReportGroup' {Maybe [Tag]
Text
ReportType
ReportExportConfig
exportConfig :: ReportExportConfig
type' :: ReportType
name :: Text
tags :: Maybe [Tag]
$sel:exportConfig:CreateReportGroup' :: CreateReportGroup -> ReportExportConfig
$sel:type':CreateReportGroup' :: CreateReportGroup -> ReportType
$sel:name:CreateReportGroup' :: CreateReportGroup -> Text
$sel:tags:CreateReportGroup' :: CreateReportGroup -> Maybe [Tag]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Tag]
tags
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ReportType
type'
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ReportExportConfig
exportConfig

instance Prelude.NFData CreateReportGroup where
  rnf :: CreateReportGroup -> ()
rnf CreateReportGroup' {Maybe [Tag]
Text
ReportType
ReportExportConfig
exportConfig :: ReportExportConfig
type' :: ReportType
name :: Text
tags :: Maybe [Tag]
$sel:exportConfig:CreateReportGroup' :: CreateReportGroup -> ReportExportConfig
$sel:type':CreateReportGroup' :: CreateReportGroup -> ReportType
$sel:name:CreateReportGroup' :: CreateReportGroup -> Text
$sel:tags:CreateReportGroup' :: CreateReportGroup -> Maybe [Tag]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Tag]
tags
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ReportType
type'
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ReportExportConfig
exportConfig

instance Data.ToHeaders CreateReportGroup where
  toHeaders :: CreateReportGroup -> 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
"CodeBuild_20161006.CreateReportGroup" ::
                          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 CreateReportGroup where
  toJSON :: CreateReportGroup -> Value
toJSON CreateReportGroup' {Maybe [Tag]
Text
ReportType
ReportExportConfig
exportConfig :: ReportExportConfig
type' :: ReportType
name :: Text
tags :: Maybe [Tag]
$sel:exportConfig:CreateReportGroup' :: CreateReportGroup -> ReportExportConfig
$sel:type':CreateReportGroup' :: CreateReportGroup -> ReportType
$sel:name:CreateReportGroup' :: CreateReportGroup -> Text
$sel:tags:CreateReportGroup' :: CreateReportGroup -> Maybe [Tag]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"tags" 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 [Tag]
tags,
            forall a. a -> Maybe a
Prelude.Just (Key
"name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name),
            forall a. a -> Maybe a
Prelude.Just (Key
"type" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ReportType
type'),
            forall a. a -> Maybe a
Prelude.Just (Key
"exportConfig" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ReportExportConfig
exportConfig)
          ]
      )

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

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

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

-- |
-- Create a value of 'CreateReportGroupResponse' 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:
--
-- 'reportGroup', 'createReportGroupResponse_reportGroup' - Information about the report group that was created.
--
-- 'httpStatus', 'createReportGroupResponse_httpStatus' - The response's http status code.
newCreateReportGroupResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateReportGroupResponse
newCreateReportGroupResponse :: Int -> CreateReportGroupResponse
newCreateReportGroupResponse Int
pHttpStatus_ =
  CreateReportGroupResponse'
    { $sel:reportGroup:CreateReportGroupResponse' :: Maybe ReportGroup
reportGroup =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateReportGroupResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the report group that was created.
createReportGroupResponse_reportGroup :: Lens.Lens' CreateReportGroupResponse (Prelude.Maybe ReportGroup)
createReportGroupResponse_reportGroup :: Lens' CreateReportGroupResponse (Maybe ReportGroup)
createReportGroupResponse_reportGroup = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateReportGroupResponse' {Maybe ReportGroup
reportGroup :: Maybe ReportGroup
$sel:reportGroup:CreateReportGroupResponse' :: CreateReportGroupResponse -> Maybe ReportGroup
reportGroup} -> Maybe ReportGroup
reportGroup) (\s :: CreateReportGroupResponse
s@CreateReportGroupResponse' {} Maybe ReportGroup
a -> CreateReportGroupResponse
s {$sel:reportGroup:CreateReportGroupResponse' :: Maybe ReportGroup
reportGroup = Maybe ReportGroup
a} :: CreateReportGroupResponse)

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

instance Prelude.NFData CreateReportGroupResponse where
  rnf :: CreateReportGroupResponse -> ()
rnf CreateReportGroupResponse' {Int
Maybe ReportGroup
httpStatus :: Int
reportGroup :: Maybe ReportGroup
$sel:httpStatus:CreateReportGroupResponse' :: CreateReportGroupResponse -> Int
$sel:reportGroup:CreateReportGroupResponse' :: CreateReportGroupResponse -> Maybe ReportGroup
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ReportGroup
reportGroup
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus