{-# 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-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)
--
-- 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.Lens as Lens
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
(UpdateProfilingGroup -> UpdateProfilingGroup -> Bool)
-> (UpdateProfilingGroup -> UpdateProfilingGroup -> Bool)
-> Eq UpdateProfilingGroup
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]
(Int -> ReadS UpdateProfilingGroup)
-> ReadS [UpdateProfilingGroup]
-> ReadPrec UpdateProfilingGroup
-> ReadPrec [UpdateProfilingGroup]
-> Read 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
(Int -> UpdateProfilingGroup -> ShowS)
-> (UpdateProfilingGroup -> String)
-> ([UpdateProfilingGroup] -> ShowS)
-> Show UpdateProfilingGroup
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. UpdateProfilingGroup -> Rep UpdateProfilingGroup x)
-> (forall x. Rep UpdateProfilingGroup x -> UpdateProfilingGroup)
-> Generic UpdateProfilingGroup
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' :: AgentOrchestrationConfig -> Text -> UpdateProfilingGroup
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 :: (AgentOrchestrationConfig -> f AgentOrchestrationConfig)
-> UpdateProfilingGroup -> f UpdateProfilingGroup
updateProfilingGroup_agentOrchestrationConfig = (UpdateProfilingGroup -> AgentOrchestrationConfig)
-> (UpdateProfilingGroup
    -> AgentOrchestrationConfig -> UpdateProfilingGroup)
-> Lens
     UpdateProfilingGroup
     UpdateProfilingGroup
     AgentOrchestrationConfig
     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 :: (Text -> f Text) -> UpdateProfilingGroup -> f UpdateProfilingGroup
updateProfilingGroup_profilingGroupName = (UpdateProfilingGroup -> Text)
-> (UpdateProfilingGroup -> Text -> UpdateProfilingGroup)
-> Lens UpdateProfilingGroup UpdateProfilingGroup Text Text
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 :: UpdateProfilingGroup -> Request UpdateProfilingGroup
request = Service -> UpdateProfilingGroup -> Request UpdateProfilingGroup
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateProfilingGroup
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateProfilingGroup)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse UpdateProfilingGroup))
-> Logger
-> Service
-> Proxy UpdateProfilingGroup
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateProfilingGroup)))
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 ->
          Int -> ProfilingGroupDescription -> UpdateProfilingGroupResponse
UpdateProfilingGroupResponse'
            (Int -> ProfilingGroupDescription -> UpdateProfilingGroupResponse)
-> Either String Int
-> Either
     String (ProfilingGroupDescription -> UpdateProfilingGroupResponse)
forall (f :: * -> *) a b. Functor 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))
            Either
  String (ProfilingGroupDescription -> UpdateProfilingGroupResponse)
-> Either String ProfilingGroupDescription
-> Either String UpdateProfilingGroupResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object -> Either String ProfilingGroupDescription
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)
      )

instance Prelude.Hashable UpdateProfilingGroup

instance Prelude.NFData UpdateProfilingGroup

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

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"agentOrchestrationConfig"
                  Text -> AgentOrchestrationConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= AgentOrchestrationConfig
agentOrchestrationConfig
              )
          ]
      )

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

instance Core.ToQuery UpdateProfilingGroup where
  toQuery :: UpdateProfilingGroup -> QueryString
toQuery = QueryString -> UpdateProfilingGroup -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(UpdateProfilingGroupResponse
 -> UpdateProfilingGroupResponse -> Bool)
-> (UpdateProfilingGroupResponse
    -> UpdateProfilingGroupResponse -> Bool)
-> Eq UpdateProfilingGroupResponse
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]
(Int -> ReadS UpdateProfilingGroupResponse)
-> ReadS [UpdateProfilingGroupResponse]
-> ReadPrec UpdateProfilingGroupResponse
-> ReadPrec [UpdateProfilingGroupResponse]
-> Read 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
(Int -> UpdateProfilingGroupResponse -> ShowS)
-> (UpdateProfilingGroupResponse -> String)
-> ([UpdateProfilingGroupResponse] -> ShowS)
-> Show UpdateProfilingGroupResponse
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.
 UpdateProfilingGroupResponse -> Rep UpdateProfilingGroupResponse x)
-> (forall x.
    Rep UpdateProfilingGroupResponse x -> UpdateProfilingGroupResponse)
-> Generic UpdateProfilingGroupResponse
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' :: Int -> ProfilingGroupDescription -> UpdateProfilingGroupResponse
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 :: (Int -> f Int)
-> UpdateProfilingGroupResponse -> f UpdateProfilingGroupResponse
updateProfilingGroupResponse_httpStatus = (UpdateProfilingGroupResponse -> Int)
-> (UpdateProfilingGroupResponse
    -> Int -> UpdateProfilingGroupResponse)
-> Lens
     UpdateProfilingGroupResponse UpdateProfilingGroupResponse Int Int
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 :: (ProfilingGroupDescription -> f ProfilingGroupDescription)
-> UpdateProfilingGroupResponse -> f UpdateProfilingGroupResponse
updateProfilingGroupResponse_profilingGroup = (UpdateProfilingGroupResponse -> ProfilingGroupDescription)
-> (UpdateProfilingGroupResponse
    -> ProfilingGroupDescription -> UpdateProfilingGroupResponse)
-> Lens
     UpdateProfilingGroupResponse
     UpdateProfilingGroupResponse
     ProfilingGroupDescription
     ProfilingGroupDescription
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