{-# 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.AMP.UpdateLoggingConfiguration
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Update logging configuration.
module Amazonka.AMP.UpdateLoggingConfiguration
  ( -- * Creating a Request
    UpdateLoggingConfiguration (..),
    newUpdateLoggingConfiguration,

    -- * Request Lenses
    updateLoggingConfiguration_clientToken,
    updateLoggingConfiguration_logGroupArn,
    updateLoggingConfiguration_workspaceId,

    -- * Destructuring the Response
    UpdateLoggingConfigurationResponse (..),
    newUpdateLoggingConfigurationResponse,

    -- * Response Lenses
    updateLoggingConfigurationResponse_httpStatus,
    updateLoggingConfigurationResponse_status,
  )
where

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

-- | Represents the input of an UpdateLoggingConfiguration operation.
--
-- /See:/ 'newUpdateLoggingConfiguration' smart constructor.
data UpdateLoggingConfiguration = UpdateLoggingConfiguration'
  { -- | Optional, unique, case-sensitive, user-provided identifier to ensure the
    -- idempotency of the request.
    UpdateLoggingConfiguration -> Maybe Text
clientToken :: Prelude.Maybe Prelude.Text,
    -- | The ARN of the CW log group to which the vended log data will be
    -- published.
    UpdateLoggingConfiguration -> Text
logGroupArn :: Prelude.Text,
    -- | The ID of the workspace to vend logs to.
    UpdateLoggingConfiguration -> Text
workspaceId :: Prelude.Text
  }
  deriving (UpdateLoggingConfiguration -> UpdateLoggingConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateLoggingConfiguration -> UpdateLoggingConfiguration -> Bool
$c/= :: UpdateLoggingConfiguration -> UpdateLoggingConfiguration -> Bool
== :: UpdateLoggingConfiguration -> UpdateLoggingConfiguration -> Bool
$c== :: UpdateLoggingConfiguration -> UpdateLoggingConfiguration -> Bool
Prelude.Eq, ReadPrec [UpdateLoggingConfiguration]
ReadPrec UpdateLoggingConfiguration
Int -> ReadS UpdateLoggingConfiguration
ReadS [UpdateLoggingConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateLoggingConfiguration]
$creadListPrec :: ReadPrec [UpdateLoggingConfiguration]
readPrec :: ReadPrec UpdateLoggingConfiguration
$creadPrec :: ReadPrec UpdateLoggingConfiguration
readList :: ReadS [UpdateLoggingConfiguration]
$creadList :: ReadS [UpdateLoggingConfiguration]
readsPrec :: Int -> ReadS UpdateLoggingConfiguration
$creadsPrec :: Int -> ReadS UpdateLoggingConfiguration
Prelude.Read, Int -> UpdateLoggingConfiguration -> ShowS
[UpdateLoggingConfiguration] -> ShowS
UpdateLoggingConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateLoggingConfiguration] -> ShowS
$cshowList :: [UpdateLoggingConfiguration] -> ShowS
show :: UpdateLoggingConfiguration -> String
$cshow :: UpdateLoggingConfiguration -> String
showsPrec :: Int -> UpdateLoggingConfiguration -> ShowS
$cshowsPrec :: Int -> UpdateLoggingConfiguration -> ShowS
Prelude.Show, forall x.
Rep UpdateLoggingConfiguration x -> UpdateLoggingConfiguration
forall x.
UpdateLoggingConfiguration -> Rep UpdateLoggingConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateLoggingConfiguration x -> UpdateLoggingConfiguration
$cfrom :: forall x.
UpdateLoggingConfiguration -> Rep UpdateLoggingConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'UpdateLoggingConfiguration' 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:
--
-- 'clientToken', 'updateLoggingConfiguration_clientToken' - Optional, unique, case-sensitive, user-provided identifier to ensure the
-- idempotency of the request.
--
-- 'logGroupArn', 'updateLoggingConfiguration_logGroupArn' - The ARN of the CW log group to which the vended log data will be
-- published.
--
-- 'workspaceId', 'updateLoggingConfiguration_workspaceId' - The ID of the workspace to vend logs to.
newUpdateLoggingConfiguration ::
  -- | 'logGroupArn'
  Prelude.Text ->
  -- | 'workspaceId'
  Prelude.Text ->
  UpdateLoggingConfiguration
newUpdateLoggingConfiguration :: Text -> Text -> UpdateLoggingConfiguration
newUpdateLoggingConfiguration
  Text
pLogGroupArn_
  Text
pWorkspaceId_ =
    UpdateLoggingConfiguration'
      { $sel:clientToken:UpdateLoggingConfiguration' :: Maybe Text
clientToken =
          forall a. Maybe a
Prelude.Nothing,
        $sel:logGroupArn:UpdateLoggingConfiguration' :: Text
logGroupArn = Text
pLogGroupArn_,
        $sel:workspaceId:UpdateLoggingConfiguration' :: Text
workspaceId = Text
pWorkspaceId_
      }

-- | Optional, unique, case-sensitive, user-provided identifier to ensure the
-- idempotency of the request.
updateLoggingConfiguration_clientToken :: Lens.Lens' UpdateLoggingConfiguration (Prelude.Maybe Prelude.Text)
updateLoggingConfiguration_clientToken :: Lens' UpdateLoggingConfiguration (Maybe Text)
updateLoggingConfiguration_clientToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateLoggingConfiguration' {Maybe Text
clientToken :: Maybe Text
$sel:clientToken:UpdateLoggingConfiguration' :: UpdateLoggingConfiguration -> Maybe Text
clientToken} -> Maybe Text
clientToken) (\s :: UpdateLoggingConfiguration
s@UpdateLoggingConfiguration' {} Maybe Text
a -> UpdateLoggingConfiguration
s {$sel:clientToken:UpdateLoggingConfiguration' :: Maybe Text
clientToken = Maybe Text
a} :: UpdateLoggingConfiguration)

-- | The ARN of the CW log group to which the vended log data will be
-- published.
updateLoggingConfiguration_logGroupArn :: Lens.Lens' UpdateLoggingConfiguration Prelude.Text
updateLoggingConfiguration_logGroupArn :: Lens' UpdateLoggingConfiguration Text
updateLoggingConfiguration_logGroupArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateLoggingConfiguration' {Text
logGroupArn :: Text
$sel:logGroupArn:UpdateLoggingConfiguration' :: UpdateLoggingConfiguration -> Text
logGroupArn} -> Text
logGroupArn) (\s :: UpdateLoggingConfiguration
s@UpdateLoggingConfiguration' {} Text
a -> UpdateLoggingConfiguration
s {$sel:logGroupArn:UpdateLoggingConfiguration' :: Text
logGroupArn = Text
a} :: UpdateLoggingConfiguration)

-- | The ID of the workspace to vend logs to.
updateLoggingConfiguration_workspaceId :: Lens.Lens' UpdateLoggingConfiguration Prelude.Text
updateLoggingConfiguration_workspaceId :: Lens' UpdateLoggingConfiguration Text
updateLoggingConfiguration_workspaceId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateLoggingConfiguration' {Text
workspaceId :: Text
$sel:workspaceId:UpdateLoggingConfiguration' :: UpdateLoggingConfiguration -> Text
workspaceId} -> Text
workspaceId) (\s :: UpdateLoggingConfiguration
s@UpdateLoggingConfiguration' {} Text
a -> UpdateLoggingConfiguration
s {$sel:workspaceId:UpdateLoggingConfiguration' :: Text
workspaceId = Text
a} :: UpdateLoggingConfiguration)

instance Core.AWSRequest UpdateLoggingConfiguration where
  type
    AWSResponse UpdateLoggingConfiguration =
      UpdateLoggingConfigurationResponse
  request :: (Service -> Service)
-> UpdateLoggingConfiguration -> Request UpdateLoggingConfiguration
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 UpdateLoggingConfiguration
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateLoggingConfiguration)))
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
-> LoggingConfigurationStatus -> UpdateLoggingConfigurationResponse
UpdateLoggingConfigurationResponse'
            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.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"status")
      )

instance Prelude.Hashable UpdateLoggingConfiguration where
  hashWithSalt :: Int -> UpdateLoggingConfiguration -> Int
hashWithSalt Int
_salt UpdateLoggingConfiguration' {Maybe Text
Text
workspaceId :: Text
logGroupArn :: Text
clientToken :: Maybe Text
$sel:workspaceId:UpdateLoggingConfiguration' :: UpdateLoggingConfiguration -> Text
$sel:logGroupArn:UpdateLoggingConfiguration' :: UpdateLoggingConfiguration -> Text
$sel:clientToken:UpdateLoggingConfiguration' :: UpdateLoggingConfiguration -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
clientToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
logGroupArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
workspaceId

instance Prelude.NFData UpdateLoggingConfiguration where
  rnf :: UpdateLoggingConfiguration -> ()
rnf UpdateLoggingConfiguration' {Maybe Text
Text
workspaceId :: Text
logGroupArn :: Text
clientToken :: Maybe Text
$sel:workspaceId:UpdateLoggingConfiguration' :: UpdateLoggingConfiguration -> Text
$sel:logGroupArn:UpdateLoggingConfiguration' :: UpdateLoggingConfiguration -> Text
$sel:clientToken:UpdateLoggingConfiguration' :: UpdateLoggingConfiguration -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
clientToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
logGroupArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
workspaceId

instance Data.ToHeaders UpdateLoggingConfiguration where
  toHeaders :: UpdateLoggingConfiguration -> 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 UpdateLoggingConfiguration where
  toJSON :: UpdateLoggingConfiguration -> Value
toJSON UpdateLoggingConfiguration' {Maybe Text
Text
workspaceId :: Text
logGroupArn :: Text
clientToken :: Maybe Text
$sel:workspaceId:UpdateLoggingConfiguration' :: UpdateLoggingConfiguration -> Text
$sel:logGroupArn:UpdateLoggingConfiguration' :: UpdateLoggingConfiguration -> Text
$sel:clientToken:UpdateLoggingConfiguration' :: UpdateLoggingConfiguration -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"clientToken" 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
clientToken,
            forall a. a -> Maybe a
Prelude.Just (Key
"logGroupArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
logGroupArn)
          ]
      )

instance Data.ToPath UpdateLoggingConfiguration where
  toPath :: UpdateLoggingConfiguration -> ByteString
toPath UpdateLoggingConfiguration' {Maybe Text
Text
workspaceId :: Text
logGroupArn :: Text
clientToken :: Maybe Text
$sel:workspaceId:UpdateLoggingConfiguration' :: UpdateLoggingConfiguration -> Text
$sel:logGroupArn:UpdateLoggingConfiguration' :: UpdateLoggingConfiguration -> Text
$sel:clientToken:UpdateLoggingConfiguration' :: UpdateLoggingConfiguration -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/workspaces/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
workspaceId, ByteString
"/logging"]

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

-- | Represents the output of an UpdateLoggingConfiguration operation.
--
-- /See:/ 'newUpdateLoggingConfigurationResponse' smart constructor.
data UpdateLoggingConfigurationResponse = UpdateLoggingConfigurationResponse'
  { -- | The response's http status code.
    UpdateLoggingConfigurationResponse -> Int
httpStatus :: Prelude.Int,
    -- | The status of the logging configuration.
    UpdateLoggingConfigurationResponse -> LoggingConfigurationStatus
status :: LoggingConfigurationStatus
  }
  deriving (UpdateLoggingConfigurationResponse
-> UpdateLoggingConfigurationResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateLoggingConfigurationResponse
-> UpdateLoggingConfigurationResponse -> Bool
$c/= :: UpdateLoggingConfigurationResponse
-> UpdateLoggingConfigurationResponse -> Bool
== :: UpdateLoggingConfigurationResponse
-> UpdateLoggingConfigurationResponse -> Bool
$c== :: UpdateLoggingConfigurationResponse
-> UpdateLoggingConfigurationResponse -> Bool
Prelude.Eq, ReadPrec [UpdateLoggingConfigurationResponse]
ReadPrec UpdateLoggingConfigurationResponse
Int -> ReadS UpdateLoggingConfigurationResponse
ReadS [UpdateLoggingConfigurationResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateLoggingConfigurationResponse]
$creadListPrec :: ReadPrec [UpdateLoggingConfigurationResponse]
readPrec :: ReadPrec UpdateLoggingConfigurationResponse
$creadPrec :: ReadPrec UpdateLoggingConfigurationResponse
readList :: ReadS [UpdateLoggingConfigurationResponse]
$creadList :: ReadS [UpdateLoggingConfigurationResponse]
readsPrec :: Int -> ReadS UpdateLoggingConfigurationResponse
$creadsPrec :: Int -> ReadS UpdateLoggingConfigurationResponse
Prelude.Read, Int -> UpdateLoggingConfigurationResponse -> ShowS
[UpdateLoggingConfigurationResponse] -> ShowS
UpdateLoggingConfigurationResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateLoggingConfigurationResponse] -> ShowS
$cshowList :: [UpdateLoggingConfigurationResponse] -> ShowS
show :: UpdateLoggingConfigurationResponse -> String
$cshow :: UpdateLoggingConfigurationResponse -> String
showsPrec :: Int -> UpdateLoggingConfigurationResponse -> ShowS
$cshowsPrec :: Int -> UpdateLoggingConfigurationResponse -> ShowS
Prelude.Show, forall x.
Rep UpdateLoggingConfigurationResponse x
-> UpdateLoggingConfigurationResponse
forall x.
UpdateLoggingConfigurationResponse
-> Rep UpdateLoggingConfigurationResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateLoggingConfigurationResponse x
-> UpdateLoggingConfigurationResponse
$cfrom :: forall x.
UpdateLoggingConfigurationResponse
-> Rep UpdateLoggingConfigurationResponse x
Prelude.Generic)

-- |
-- Create a value of 'UpdateLoggingConfigurationResponse' 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', 'updateLoggingConfigurationResponse_httpStatus' - The response's http status code.
--
-- 'status', 'updateLoggingConfigurationResponse_status' - The status of the logging configuration.
newUpdateLoggingConfigurationResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'status'
  LoggingConfigurationStatus ->
  UpdateLoggingConfigurationResponse
newUpdateLoggingConfigurationResponse :: Int
-> LoggingConfigurationStatus -> UpdateLoggingConfigurationResponse
newUpdateLoggingConfigurationResponse
  Int
pHttpStatus_
  LoggingConfigurationStatus
pStatus_ =
    UpdateLoggingConfigurationResponse'
      { $sel:httpStatus:UpdateLoggingConfigurationResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:status:UpdateLoggingConfigurationResponse' :: LoggingConfigurationStatus
status = LoggingConfigurationStatus
pStatus_
      }

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

-- | The status of the logging configuration.
updateLoggingConfigurationResponse_status :: Lens.Lens' UpdateLoggingConfigurationResponse LoggingConfigurationStatus
updateLoggingConfigurationResponse_status :: Lens' UpdateLoggingConfigurationResponse LoggingConfigurationStatus
updateLoggingConfigurationResponse_status = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateLoggingConfigurationResponse' {LoggingConfigurationStatus
status :: LoggingConfigurationStatus
$sel:status:UpdateLoggingConfigurationResponse' :: UpdateLoggingConfigurationResponse -> LoggingConfigurationStatus
status} -> LoggingConfigurationStatus
status) (\s :: UpdateLoggingConfigurationResponse
s@UpdateLoggingConfigurationResponse' {} LoggingConfigurationStatus
a -> UpdateLoggingConfigurationResponse
s {$sel:status:UpdateLoggingConfigurationResponse' :: LoggingConfigurationStatus
status = LoggingConfigurationStatus
a} :: UpdateLoggingConfigurationResponse)

instance
  Prelude.NFData
    UpdateLoggingConfigurationResponse
  where
  rnf :: UpdateLoggingConfigurationResponse -> ()
rnf UpdateLoggingConfigurationResponse' {Int
LoggingConfigurationStatus
status :: LoggingConfigurationStatus
httpStatus :: Int
$sel:status:UpdateLoggingConfigurationResponse' :: UpdateLoggingConfigurationResponse -> LoggingConfigurationStatus
$sel:httpStatus:UpdateLoggingConfigurationResponse' :: UpdateLoggingConfigurationResponse -> 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 LoggingConfigurationStatus
status