{-# 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.CodeGuruProfiler.UpdateProfilingGroup
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Updates a profiling group.
module Amazonka.CodeGuruProfiler.UpdateProfilingGroup
  ( -- * Creating a Request
    UpdateProfilingGroup (..),
    newUpdateProfilingGroup,

    -- * Request Lenses
    updateProfilingGroup_agentOrchestrationConfig,
    updateProfilingGroup_profilingGroupName,

    -- * Destructuring the Response
    UpdateProfilingGroupResponse (..),
    newUpdateProfilingGroupResponse,

    -- * Response Lenses
    updateProfilingGroupResponse_httpStatus,
    updateProfilingGroupResponse_profilingGroup,
  )
where

import Amazonka.CodeGuruProfiler.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

-- | The structure representing the updateProfilingGroupRequest.
--
-- /See:/ 'newUpdateProfilingGroup' smart constructor.
data UpdateProfilingGroup = UpdateProfilingGroup'
  { -- | Specifies whether profiling is enabled or disabled for a profiling
    -- group.
    UpdateProfilingGroup -> AgentOrchestrationConfig
agentOrchestrationConfig :: AgentOrchestrationConfig,
    -- | The name of the profiling group to update.
    UpdateProfilingGroup -> Text
profilingGroupName :: Prelude.Text
  }
  deriving (UpdateProfilingGroup -> UpdateProfilingGroup -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateProfilingGroup -> UpdateProfilingGroup -> Bool
$c/= :: UpdateProfilingGroup -> UpdateProfilingGroup -> Bool
== :: UpdateProfilingGroup -> UpdateProfilingGroup -> Bool
$c== :: UpdateProfilingGroup -> UpdateProfilingGroup -> Bool
Prelude.Eq, ReadPrec [UpdateProfilingGroup]
ReadPrec UpdateProfilingGroup
Int -> ReadS UpdateProfilingGroup
ReadS [UpdateProfilingGroup]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateProfilingGroup]
$creadListPrec :: ReadPrec [UpdateProfilingGroup]
readPrec :: ReadPrec UpdateProfilingGroup
$creadPrec :: ReadPrec UpdateProfilingGroup
readList :: ReadS [UpdateProfilingGroup]
$creadList :: ReadS [UpdateProfilingGroup]
readsPrec :: Int -> ReadS UpdateProfilingGroup
$creadsPrec :: Int -> ReadS UpdateProfilingGroup
Prelude.Read, Int -> UpdateProfilingGroup -> ShowS
[UpdateProfilingGroup] -> ShowS
UpdateProfilingGroup -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateProfilingGroup] -> ShowS
$cshowList :: [UpdateProfilingGroup] -> ShowS
show :: UpdateProfilingGroup -> String
$cshow :: UpdateProfilingGroup -> String
showsPrec :: Int -> UpdateProfilingGroup -> ShowS
$cshowsPrec :: Int -> UpdateProfilingGroup -> ShowS
Prelude.Show, forall x. Rep UpdateProfilingGroup x -> UpdateProfilingGroup
forall x. UpdateProfilingGroup -> Rep UpdateProfilingGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateProfilingGroup x -> UpdateProfilingGroup
$cfrom :: forall x. UpdateProfilingGroup -> Rep UpdateProfilingGroup x
Prelude.Generic)

-- |
-- Create a value of 'UpdateProfilingGroup' 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:
--
-- 'agentOrchestrationConfig', 'updateProfilingGroup_agentOrchestrationConfig' - Specifies whether profiling is enabled or disabled for a profiling
-- group.
--
-- 'profilingGroupName', 'updateProfilingGroup_profilingGroupName' - The name of the profiling group to update.
newUpdateProfilingGroup ::
  -- | 'agentOrchestrationConfig'
  AgentOrchestrationConfig ->
  -- | 'profilingGroupName'
  Prelude.Text ->
  UpdateProfilingGroup
newUpdateProfilingGroup :: AgentOrchestrationConfig -> Text -> UpdateProfilingGroup
newUpdateProfilingGroup
  AgentOrchestrationConfig
pAgentOrchestrationConfig_
  Text
pProfilingGroupName_ =
    UpdateProfilingGroup'
      { $sel:agentOrchestrationConfig:UpdateProfilingGroup' :: AgentOrchestrationConfig
agentOrchestrationConfig =
          AgentOrchestrationConfig
pAgentOrchestrationConfig_,
        $sel:profilingGroupName:UpdateProfilingGroup' :: Text
profilingGroupName = Text
pProfilingGroupName_
      }

-- | Specifies whether profiling is enabled or disabled for a profiling
-- group.
updateProfilingGroup_agentOrchestrationConfig :: Lens.Lens' UpdateProfilingGroup AgentOrchestrationConfig
updateProfilingGroup_agentOrchestrationConfig :: Lens' UpdateProfilingGroup AgentOrchestrationConfig
updateProfilingGroup_agentOrchestrationConfig = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateProfilingGroup' {AgentOrchestrationConfig
agentOrchestrationConfig :: AgentOrchestrationConfig
$sel:agentOrchestrationConfig:UpdateProfilingGroup' :: UpdateProfilingGroup -> AgentOrchestrationConfig
agentOrchestrationConfig} -> AgentOrchestrationConfig
agentOrchestrationConfig) (\s :: UpdateProfilingGroup
s@UpdateProfilingGroup' {} AgentOrchestrationConfig
a -> UpdateProfilingGroup
s {$sel:agentOrchestrationConfig:UpdateProfilingGroup' :: AgentOrchestrationConfig
agentOrchestrationConfig = AgentOrchestrationConfig
a} :: UpdateProfilingGroup)

-- | The name of the profiling group to update.
updateProfilingGroup_profilingGroupName :: Lens.Lens' UpdateProfilingGroup Prelude.Text
updateProfilingGroup_profilingGroupName :: Lens' UpdateProfilingGroup Text
updateProfilingGroup_profilingGroupName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateProfilingGroup' {Text
profilingGroupName :: Text
$sel:profilingGroupName:UpdateProfilingGroup' :: UpdateProfilingGroup -> Text
profilingGroupName} -> Text
profilingGroupName) (\s :: UpdateProfilingGroup
s@UpdateProfilingGroup' {} Text
a -> UpdateProfilingGroup
s {$sel:profilingGroupName:UpdateProfilingGroup' :: Text
profilingGroupName = Text
a} :: UpdateProfilingGroup)

instance Core.AWSRequest UpdateProfilingGroup where
  type
    AWSResponse UpdateProfilingGroup =
      UpdateProfilingGroupResponse
  request :: (Service -> Service)
-> UpdateProfilingGroup -> Request UpdateProfilingGroup
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy UpdateProfilingGroup
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateProfilingGroup)))
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 ->
          Int -> ProfilingGroupDescription -> UpdateProfilingGroupResponse
UpdateProfilingGroupResponse'
            forall (f :: * -> *) a b. Functor 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))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall a. FromJSON a => Object -> Either String a
Data.eitherParseJSON Object
x)
      )

instance Prelude.Hashable UpdateProfilingGroup where
  hashWithSalt :: Int -> UpdateProfilingGroup -> Int
hashWithSalt Int
_salt UpdateProfilingGroup' {Text
AgentOrchestrationConfig
profilingGroupName :: Text
agentOrchestrationConfig :: AgentOrchestrationConfig
$sel:profilingGroupName:UpdateProfilingGroup' :: UpdateProfilingGroup -> Text
$sel:agentOrchestrationConfig:UpdateProfilingGroup' :: UpdateProfilingGroup -> AgentOrchestrationConfig
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` AgentOrchestrationConfig
agentOrchestrationConfig
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
profilingGroupName

instance Prelude.NFData UpdateProfilingGroup where
  rnf :: UpdateProfilingGroup -> ()
rnf UpdateProfilingGroup' {Text
AgentOrchestrationConfig
profilingGroupName :: Text
agentOrchestrationConfig :: AgentOrchestrationConfig
$sel:profilingGroupName:UpdateProfilingGroup' :: UpdateProfilingGroup -> Text
$sel:agentOrchestrationConfig:UpdateProfilingGroup' :: UpdateProfilingGroup -> AgentOrchestrationConfig
..} =
    forall a. NFData a => a -> ()
Prelude.rnf AgentOrchestrationConfig
agentOrchestrationConfig
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
profilingGroupName

instance Data.ToHeaders UpdateProfilingGroup where
  toHeaders :: UpdateProfilingGroup -> 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.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON UpdateProfilingGroup where
  toJSON :: UpdateProfilingGroup -> Value
toJSON UpdateProfilingGroup' {Text
AgentOrchestrationConfig
profilingGroupName :: Text
agentOrchestrationConfig :: AgentOrchestrationConfig
$sel:profilingGroupName:UpdateProfilingGroup' :: UpdateProfilingGroup -> Text
$sel:agentOrchestrationConfig:UpdateProfilingGroup' :: UpdateProfilingGroup -> AgentOrchestrationConfig
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              ( Key
"agentOrchestrationConfig"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= AgentOrchestrationConfig
agentOrchestrationConfig
              )
          ]
      )

instance Data.ToPath UpdateProfilingGroup where
  toPath :: UpdateProfilingGroup -> ByteString
toPath UpdateProfilingGroup' {Text
AgentOrchestrationConfig
profilingGroupName :: Text
agentOrchestrationConfig :: AgentOrchestrationConfig
$sel:profilingGroupName:UpdateProfilingGroup' :: UpdateProfilingGroup -> Text
$sel:agentOrchestrationConfig:UpdateProfilingGroup' :: UpdateProfilingGroup -> AgentOrchestrationConfig
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/profilingGroups/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
profilingGroupName]

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

-- | The structure representing the updateProfilingGroupResponse.
--
-- /See:/ 'newUpdateProfilingGroupResponse' smart constructor.
data UpdateProfilingGroupResponse = UpdateProfilingGroupResponse'
  { -- | The response's http status code.
    UpdateProfilingGroupResponse -> Int
httpStatus :: Prelude.Int,
    -- | A
    -- <https://docs.aws.amazon.com/codeguru/latest/profiler-api/API_ProfilingGroupDescription.html ProfilingGroupDescription>
    -- that contains information about the returned updated profiling group.
    UpdateProfilingGroupResponse -> ProfilingGroupDescription
profilingGroup :: ProfilingGroupDescription
  }
  deriving (UpdateProfilingGroupResponse
-> UpdateProfilingGroupResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateProfilingGroupResponse
-> UpdateProfilingGroupResponse -> Bool
$c/= :: UpdateProfilingGroupResponse
-> UpdateProfilingGroupResponse -> Bool
== :: UpdateProfilingGroupResponse
-> UpdateProfilingGroupResponse -> Bool
$c== :: UpdateProfilingGroupResponse
-> UpdateProfilingGroupResponse -> Bool
Prelude.Eq, ReadPrec [UpdateProfilingGroupResponse]
ReadPrec UpdateProfilingGroupResponse
Int -> ReadS UpdateProfilingGroupResponse
ReadS [UpdateProfilingGroupResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateProfilingGroupResponse]
$creadListPrec :: ReadPrec [UpdateProfilingGroupResponse]
readPrec :: ReadPrec UpdateProfilingGroupResponse
$creadPrec :: ReadPrec UpdateProfilingGroupResponse
readList :: ReadS [UpdateProfilingGroupResponse]
$creadList :: ReadS [UpdateProfilingGroupResponse]
readsPrec :: Int -> ReadS UpdateProfilingGroupResponse
$creadsPrec :: Int -> ReadS UpdateProfilingGroupResponse
Prelude.Read, Int -> UpdateProfilingGroupResponse -> ShowS
[UpdateProfilingGroupResponse] -> ShowS
UpdateProfilingGroupResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateProfilingGroupResponse] -> ShowS
$cshowList :: [UpdateProfilingGroupResponse] -> ShowS
show :: UpdateProfilingGroupResponse -> String
$cshow :: UpdateProfilingGroupResponse -> String
showsPrec :: Int -> UpdateProfilingGroupResponse -> ShowS
$cshowsPrec :: Int -> UpdateProfilingGroupResponse -> ShowS
Prelude.Show, forall x.
Rep UpdateProfilingGroupResponse x -> UpdateProfilingGroupResponse
forall x.
UpdateProfilingGroupResponse -> Rep UpdateProfilingGroupResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateProfilingGroupResponse x -> UpdateProfilingGroupResponse
$cfrom :: forall x.
UpdateProfilingGroupResponse -> Rep UpdateProfilingGroupResponse x
Prelude.Generic)

-- |
-- Create a value of 'UpdateProfilingGroupResponse' 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:
--
-- 'httpStatus', 'updateProfilingGroupResponse_httpStatus' - The response's http status code.
--
-- 'profilingGroup', 'updateProfilingGroupResponse_profilingGroup' - A
-- <https://docs.aws.amazon.com/codeguru/latest/profiler-api/API_ProfilingGroupDescription.html ProfilingGroupDescription>
-- that contains information about the returned updated profiling group.
newUpdateProfilingGroupResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'profilingGroup'
  ProfilingGroupDescription ->
  UpdateProfilingGroupResponse
newUpdateProfilingGroupResponse :: Int -> ProfilingGroupDescription -> UpdateProfilingGroupResponse
newUpdateProfilingGroupResponse
  Int
pHttpStatus_
  ProfilingGroupDescription
pProfilingGroup_ =
    UpdateProfilingGroupResponse'
      { $sel:httpStatus:UpdateProfilingGroupResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:profilingGroup:UpdateProfilingGroupResponse' :: ProfilingGroupDescription
profilingGroup = ProfilingGroupDescription
pProfilingGroup_
      }

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

-- | A
-- <https://docs.aws.amazon.com/codeguru/latest/profiler-api/API_ProfilingGroupDescription.html ProfilingGroupDescription>
-- that contains information about the returned updated profiling group.
updateProfilingGroupResponse_profilingGroup :: Lens.Lens' UpdateProfilingGroupResponse ProfilingGroupDescription
updateProfilingGroupResponse_profilingGroup :: Lens' UpdateProfilingGroupResponse ProfilingGroupDescription
updateProfilingGroupResponse_profilingGroup = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateProfilingGroupResponse' {ProfilingGroupDescription
profilingGroup :: ProfilingGroupDescription
$sel:profilingGroup:UpdateProfilingGroupResponse' :: UpdateProfilingGroupResponse -> ProfilingGroupDescription
profilingGroup} -> ProfilingGroupDescription
profilingGroup) (\s :: UpdateProfilingGroupResponse
s@UpdateProfilingGroupResponse' {} ProfilingGroupDescription
a -> UpdateProfilingGroupResponse
s {$sel:profilingGroup:UpdateProfilingGroupResponse' :: ProfilingGroupDescription
profilingGroup = ProfilingGroupDescription
a} :: UpdateProfilingGroupResponse)

instance Prelude.NFData UpdateProfilingGroupResponse where
  rnf :: UpdateProfilingGroupResponse -> ()
rnf UpdateProfilingGroupResponse' {Int
ProfilingGroupDescription
profilingGroup :: ProfilingGroupDescription
httpStatus :: Int
$sel:profilingGroup:UpdateProfilingGroupResponse' :: UpdateProfilingGroupResponse -> ProfilingGroupDescription
$sel:httpStatus:UpdateProfilingGroupResponse' :: UpdateProfilingGroupResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ProfilingGroupDescription
profilingGroup