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

    -- * Request Lenses
    createLoggingConfiguration_clientToken,
    createLoggingConfiguration_logGroupArn,
    createLoggingConfiguration_workspaceId,

    -- * Destructuring the Response
    CreateLoggingConfigurationResponse (..),
    newCreateLoggingConfigurationResponse,

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

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

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

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

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

instance Core.AWSRequest CreateLoggingConfiguration where
  type
    AWSResponse CreateLoggingConfiguration =
      CreateLoggingConfigurationResponse
  request :: (Service -> Service)
-> CreateLoggingConfiguration -> Request CreateLoggingConfiguration
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 CreateLoggingConfiguration
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateLoggingConfiguration)))
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 -> CreateLoggingConfigurationResponse
CreateLoggingConfigurationResponse'
            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 CreateLoggingConfiguration where
  hashWithSalt :: Int -> CreateLoggingConfiguration -> Int
hashWithSalt Int
_salt CreateLoggingConfiguration' {Maybe Text
Text
workspaceId :: Text
logGroupArn :: Text
clientToken :: Maybe Text
$sel:workspaceId:CreateLoggingConfiguration' :: CreateLoggingConfiguration -> Text
$sel:logGroupArn:CreateLoggingConfiguration' :: CreateLoggingConfiguration -> Text
$sel:clientToken:CreateLoggingConfiguration' :: CreateLoggingConfiguration -> 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 CreateLoggingConfiguration where
  rnf :: CreateLoggingConfiguration -> ()
rnf CreateLoggingConfiguration' {Maybe Text
Text
workspaceId :: Text
logGroupArn :: Text
clientToken :: Maybe Text
$sel:workspaceId:CreateLoggingConfiguration' :: CreateLoggingConfiguration -> Text
$sel:logGroupArn:CreateLoggingConfiguration' :: CreateLoggingConfiguration -> Text
$sel:clientToken:CreateLoggingConfiguration' :: CreateLoggingConfiguration -> 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 CreateLoggingConfiguration where
  toHeaders :: CreateLoggingConfiguration -> 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 CreateLoggingConfiguration where
  toJSON :: CreateLoggingConfiguration -> Value
toJSON CreateLoggingConfiguration' {Maybe Text
Text
workspaceId :: Text
logGroupArn :: Text
clientToken :: Maybe Text
$sel:workspaceId:CreateLoggingConfiguration' :: CreateLoggingConfiguration -> Text
$sel:logGroupArn:CreateLoggingConfiguration' :: CreateLoggingConfiguration -> Text
$sel:clientToken:CreateLoggingConfiguration' :: CreateLoggingConfiguration -> 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 CreateLoggingConfiguration where
  toPath :: CreateLoggingConfiguration -> ByteString
toPath CreateLoggingConfiguration' {Maybe Text
Text
workspaceId :: Text
logGroupArn :: Text
clientToken :: Maybe Text
$sel:workspaceId:CreateLoggingConfiguration' :: CreateLoggingConfiguration -> Text
$sel:logGroupArn:CreateLoggingConfiguration' :: CreateLoggingConfiguration -> Text
$sel:clientToken:CreateLoggingConfiguration' :: CreateLoggingConfiguration -> 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 CreateLoggingConfiguration where
  toQuery :: CreateLoggingConfiguration -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

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

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

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

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

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