{-# 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.Greengrass.UpdateLoggerDefinition
-- 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 logger definition.
module Amazonka.Greengrass.UpdateLoggerDefinition
  ( -- * Creating a Request
    UpdateLoggerDefinition (..),
    newUpdateLoggerDefinition,

    -- * Request Lenses
    updateLoggerDefinition_name,
    updateLoggerDefinition_loggerDefinitionId,

    -- * Destructuring the Response
    UpdateLoggerDefinitionResponse (..),
    newUpdateLoggerDefinitionResponse,

    -- * Response Lenses
    updateLoggerDefinitionResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.Greengrass.Types
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newUpdateLoggerDefinition' smart constructor.
data UpdateLoggerDefinition = UpdateLoggerDefinition'
  { -- | The name of the definition.
    UpdateLoggerDefinition -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The ID of the logger definition.
    UpdateLoggerDefinition -> Text
loggerDefinitionId :: Prelude.Text
  }
  deriving (UpdateLoggerDefinition -> UpdateLoggerDefinition -> Bool
(UpdateLoggerDefinition -> UpdateLoggerDefinition -> Bool)
-> (UpdateLoggerDefinition -> UpdateLoggerDefinition -> Bool)
-> Eq UpdateLoggerDefinition
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateLoggerDefinition -> UpdateLoggerDefinition -> Bool
$c/= :: UpdateLoggerDefinition -> UpdateLoggerDefinition -> Bool
== :: UpdateLoggerDefinition -> UpdateLoggerDefinition -> Bool
$c== :: UpdateLoggerDefinition -> UpdateLoggerDefinition -> Bool
Prelude.Eq, ReadPrec [UpdateLoggerDefinition]
ReadPrec UpdateLoggerDefinition
Int -> ReadS UpdateLoggerDefinition
ReadS [UpdateLoggerDefinition]
(Int -> ReadS UpdateLoggerDefinition)
-> ReadS [UpdateLoggerDefinition]
-> ReadPrec UpdateLoggerDefinition
-> ReadPrec [UpdateLoggerDefinition]
-> Read UpdateLoggerDefinition
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateLoggerDefinition]
$creadListPrec :: ReadPrec [UpdateLoggerDefinition]
readPrec :: ReadPrec UpdateLoggerDefinition
$creadPrec :: ReadPrec UpdateLoggerDefinition
readList :: ReadS [UpdateLoggerDefinition]
$creadList :: ReadS [UpdateLoggerDefinition]
readsPrec :: Int -> ReadS UpdateLoggerDefinition
$creadsPrec :: Int -> ReadS UpdateLoggerDefinition
Prelude.Read, Int -> UpdateLoggerDefinition -> ShowS
[UpdateLoggerDefinition] -> ShowS
UpdateLoggerDefinition -> String
(Int -> UpdateLoggerDefinition -> ShowS)
-> (UpdateLoggerDefinition -> String)
-> ([UpdateLoggerDefinition] -> ShowS)
-> Show UpdateLoggerDefinition
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateLoggerDefinition] -> ShowS
$cshowList :: [UpdateLoggerDefinition] -> ShowS
show :: UpdateLoggerDefinition -> String
$cshow :: UpdateLoggerDefinition -> String
showsPrec :: Int -> UpdateLoggerDefinition -> ShowS
$cshowsPrec :: Int -> UpdateLoggerDefinition -> ShowS
Prelude.Show, (forall x. UpdateLoggerDefinition -> Rep UpdateLoggerDefinition x)
-> (forall x.
    Rep UpdateLoggerDefinition x -> UpdateLoggerDefinition)
-> Generic UpdateLoggerDefinition
forall x. Rep UpdateLoggerDefinition x -> UpdateLoggerDefinition
forall x. UpdateLoggerDefinition -> Rep UpdateLoggerDefinition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateLoggerDefinition x -> UpdateLoggerDefinition
$cfrom :: forall x. UpdateLoggerDefinition -> Rep UpdateLoggerDefinition x
Prelude.Generic)

-- |
-- Create a value of 'UpdateLoggerDefinition' 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:
--
-- 'name', 'updateLoggerDefinition_name' - The name of the definition.
--
-- 'loggerDefinitionId', 'updateLoggerDefinition_loggerDefinitionId' - The ID of the logger definition.
newUpdateLoggerDefinition ::
  -- | 'loggerDefinitionId'
  Prelude.Text ->
  UpdateLoggerDefinition
newUpdateLoggerDefinition :: Text -> UpdateLoggerDefinition
newUpdateLoggerDefinition Text
pLoggerDefinitionId_ =
  UpdateLoggerDefinition' :: Maybe Text -> Text -> UpdateLoggerDefinition
UpdateLoggerDefinition'
    { $sel:name:UpdateLoggerDefinition' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:loggerDefinitionId:UpdateLoggerDefinition' :: Text
loggerDefinitionId = Text
pLoggerDefinitionId_
    }

-- | The name of the definition.
updateLoggerDefinition_name :: Lens.Lens' UpdateLoggerDefinition (Prelude.Maybe Prelude.Text)
updateLoggerDefinition_name :: (Maybe Text -> f (Maybe Text))
-> UpdateLoggerDefinition -> f UpdateLoggerDefinition
updateLoggerDefinition_name = (UpdateLoggerDefinition -> Maybe Text)
-> (UpdateLoggerDefinition -> Maybe Text -> UpdateLoggerDefinition)
-> Lens
     UpdateLoggerDefinition
     UpdateLoggerDefinition
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateLoggerDefinition' {Maybe Text
name :: Maybe Text
$sel:name:UpdateLoggerDefinition' :: UpdateLoggerDefinition -> Maybe Text
name} -> Maybe Text
name) (\s :: UpdateLoggerDefinition
s@UpdateLoggerDefinition' {} Maybe Text
a -> UpdateLoggerDefinition
s {$sel:name:UpdateLoggerDefinition' :: Maybe Text
name = Maybe Text
a} :: UpdateLoggerDefinition)

-- | The ID of the logger definition.
updateLoggerDefinition_loggerDefinitionId :: Lens.Lens' UpdateLoggerDefinition Prelude.Text
updateLoggerDefinition_loggerDefinitionId :: (Text -> f Text)
-> UpdateLoggerDefinition -> f UpdateLoggerDefinition
updateLoggerDefinition_loggerDefinitionId = (UpdateLoggerDefinition -> Text)
-> (UpdateLoggerDefinition -> Text -> UpdateLoggerDefinition)
-> Lens UpdateLoggerDefinition UpdateLoggerDefinition Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateLoggerDefinition' {Text
loggerDefinitionId :: Text
$sel:loggerDefinitionId:UpdateLoggerDefinition' :: UpdateLoggerDefinition -> Text
loggerDefinitionId} -> Text
loggerDefinitionId) (\s :: UpdateLoggerDefinition
s@UpdateLoggerDefinition' {} Text
a -> UpdateLoggerDefinition
s {$sel:loggerDefinitionId:UpdateLoggerDefinition' :: Text
loggerDefinitionId = Text
a} :: UpdateLoggerDefinition)

instance Core.AWSRequest UpdateLoggerDefinition where
  type
    AWSResponse UpdateLoggerDefinition =
      UpdateLoggerDefinitionResponse
  request :: UpdateLoggerDefinition -> Request UpdateLoggerDefinition
request = Service -> UpdateLoggerDefinition -> Request UpdateLoggerDefinition
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateLoggerDefinition
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateLoggerDefinition)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse UpdateLoggerDefinition))
-> Logger
-> Service
-> Proxy UpdateLoggerDefinition
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateLoggerDefinition)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> UpdateLoggerDefinitionResponse
UpdateLoggerDefinitionResponse'
            (Int -> UpdateLoggerDefinitionResponse)
-> Either String Int
-> Either String UpdateLoggerDefinitionResponse
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))
      )

instance Prelude.Hashable UpdateLoggerDefinition

instance Prelude.NFData UpdateLoggerDefinition

instance Core.ToHeaders UpdateLoggerDefinition where
  toHeaders :: UpdateLoggerDefinition -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateLoggerDefinition -> 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 UpdateLoggerDefinition where
  toJSON :: UpdateLoggerDefinition -> Value
toJSON UpdateLoggerDefinition' {Maybe Text
Text
loggerDefinitionId :: Text
name :: Maybe Text
$sel:loggerDefinitionId:UpdateLoggerDefinition' :: UpdateLoggerDefinition -> Text
$sel:name:UpdateLoggerDefinition' :: UpdateLoggerDefinition -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
name]
      )

instance Core.ToPath UpdateLoggerDefinition where
  toPath :: UpdateLoggerDefinition -> ByteString
toPath UpdateLoggerDefinition' {Maybe Text
Text
loggerDefinitionId :: Text
name :: Maybe Text
$sel:loggerDefinitionId:UpdateLoggerDefinition' :: UpdateLoggerDefinition -> Text
$sel:name:UpdateLoggerDefinition' :: UpdateLoggerDefinition -> Maybe Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/greengrass/definition/loggers/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
loggerDefinitionId
      ]

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

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

-- |
-- Create a value of 'UpdateLoggerDefinitionResponse' 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', 'updateLoggerDefinitionResponse_httpStatus' - The response's http status code.
newUpdateLoggerDefinitionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateLoggerDefinitionResponse
newUpdateLoggerDefinitionResponse :: Int -> UpdateLoggerDefinitionResponse
newUpdateLoggerDefinitionResponse Int
pHttpStatus_ =
  UpdateLoggerDefinitionResponse' :: Int -> UpdateLoggerDefinitionResponse
UpdateLoggerDefinitionResponse'
    { $sel:httpStatus:UpdateLoggerDefinitionResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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

instance
  Prelude.NFData
    UpdateLoggerDefinitionResponse