{-# 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.UpdateSubscriptionDefinition
-- 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 subscription definition.
module Amazonka.Greengrass.UpdateSubscriptionDefinition
  ( -- * Creating a Request
    UpdateSubscriptionDefinition (..),
    newUpdateSubscriptionDefinition,

    -- * Request Lenses
    updateSubscriptionDefinition_name,
    updateSubscriptionDefinition_subscriptionDefinitionId,

    -- * Destructuring the Response
    UpdateSubscriptionDefinitionResponse (..),
    newUpdateSubscriptionDefinitionResponse,

    -- * Response Lenses
    updateSubscriptionDefinitionResponse_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:/ 'newUpdateSubscriptionDefinition' smart constructor.
data UpdateSubscriptionDefinition = UpdateSubscriptionDefinition'
  { -- | The name of the definition.
    UpdateSubscriptionDefinition -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The ID of the subscription definition.
    UpdateSubscriptionDefinition -> Text
subscriptionDefinitionId :: Prelude.Text
  }
  deriving (UpdateSubscriptionDefinition
-> UpdateSubscriptionDefinition -> Bool
(UpdateSubscriptionDefinition
 -> UpdateSubscriptionDefinition -> Bool)
-> (UpdateSubscriptionDefinition
    -> UpdateSubscriptionDefinition -> Bool)
-> Eq UpdateSubscriptionDefinition
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateSubscriptionDefinition
-> UpdateSubscriptionDefinition -> Bool
$c/= :: UpdateSubscriptionDefinition
-> UpdateSubscriptionDefinition -> Bool
== :: UpdateSubscriptionDefinition
-> UpdateSubscriptionDefinition -> Bool
$c== :: UpdateSubscriptionDefinition
-> UpdateSubscriptionDefinition -> Bool
Prelude.Eq, ReadPrec [UpdateSubscriptionDefinition]
ReadPrec UpdateSubscriptionDefinition
Int -> ReadS UpdateSubscriptionDefinition
ReadS [UpdateSubscriptionDefinition]
(Int -> ReadS UpdateSubscriptionDefinition)
-> ReadS [UpdateSubscriptionDefinition]
-> ReadPrec UpdateSubscriptionDefinition
-> ReadPrec [UpdateSubscriptionDefinition]
-> Read UpdateSubscriptionDefinition
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateSubscriptionDefinition]
$creadListPrec :: ReadPrec [UpdateSubscriptionDefinition]
readPrec :: ReadPrec UpdateSubscriptionDefinition
$creadPrec :: ReadPrec UpdateSubscriptionDefinition
readList :: ReadS [UpdateSubscriptionDefinition]
$creadList :: ReadS [UpdateSubscriptionDefinition]
readsPrec :: Int -> ReadS UpdateSubscriptionDefinition
$creadsPrec :: Int -> ReadS UpdateSubscriptionDefinition
Prelude.Read, Int -> UpdateSubscriptionDefinition -> ShowS
[UpdateSubscriptionDefinition] -> ShowS
UpdateSubscriptionDefinition -> String
(Int -> UpdateSubscriptionDefinition -> ShowS)
-> (UpdateSubscriptionDefinition -> String)
-> ([UpdateSubscriptionDefinition] -> ShowS)
-> Show UpdateSubscriptionDefinition
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateSubscriptionDefinition] -> ShowS
$cshowList :: [UpdateSubscriptionDefinition] -> ShowS
show :: UpdateSubscriptionDefinition -> String
$cshow :: UpdateSubscriptionDefinition -> String
showsPrec :: Int -> UpdateSubscriptionDefinition -> ShowS
$cshowsPrec :: Int -> UpdateSubscriptionDefinition -> ShowS
Prelude.Show, (forall x.
 UpdateSubscriptionDefinition -> Rep UpdateSubscriptionDefinition x)
-> (forall x.
    Rep UpdateSubscriptionDefinition x -> UpdateSubscriptionDefinition)
-> Generic UpdateSubscriptionDefinition
forall x.
Rep UpdateSubscriptionDefinition x -> UpdateSubscriptionDefinition
forall x.
UpdateSubscriptionDefinition -> Rep UpdateSubscriptionDefinition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateSubscriptionDefinition x -> UpdateSubscriptionDefinition
$cfrom :: forall x.
UpdateSubscriptionDefinition -> Rep UpdateSubscriptionDefinition x
Prelude.Generic)

-- |
-- Create a value of 'UpdateSubscriptionDefinition' 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', 'updateSubscriptionDefinition_name' - The name of the definition.
--
-- 'subscriptionDefinitionId', 'updateSubscriptionDefinition_subscriptionDefinitionId' - The ID of the subscription definition.
newUpdateSubscriptionDefinition ::
  -- | 'subscriptionDefinitionId'
  Prelude.Text ->
  UpdateSubscriptionDefinition
newUpdateSubscriptionDefinition :: Text -> UpdateSubscriptionDefinition
newUpdateSubscriptionDefinition
  Text
pSubscriptionDefinitionId_ =
    UpdateSubscriptionDefinition' :: Maybe Text -> Text -> UpdateSubscriptionDefinition
UpdateSubscriptionDefinition'
      { $sel:name:UpdateSubscriptionDefinition' :: Maybe Text
name =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:subscriptionDefinitionId:UpdateSubscriptionDefinition' :: Text
subscriptionDefinitionId =
          Text
pSubscriptionDefinitionId_
      }

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

-- | The ID of the subscription definition.
updateSubscriptionDefinition_subscriptionDefinitionId :: Lens.Lens' UpdateSubscriptionDefinition Prelude.Text
updateSubscriptionDefinition_subscriptionDefinitionId :: (Text -> f Text)
-> UpdateSubscriptionDefinition -> f UpdateSubscriptionDefinition
updateSubscriptionDefinition_subscriptionDefinitionId = (UpdateSubscriptionDefinition -> Text)
-> (UpdateSubscriptionDefinition
    -> Text -> UpdateSubscriptionDefinition)
-> Lens
     UpdateSubscriptionDefinition UpdateSubscriptionDefinition Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateSubscriptionDefinition' {Text
subscriptionDefinitionId :: Text
$sel:subscriptionDefinitionId:UpdateSubscriptionDefinition' :: UpdateSubscriptionDefinition -> Text
subscriptionDefinitionId} -> Text
subscriptionDefinitionId) (\s :: UpdateSubscriptionDefinition
s@UpdateSubscriptionDefinition' {} Text
a -> UpdateSubscriptionDefinition
s {$sel:subscriptionDefinitionId:UpdateSubscriptionDefinition' :: Text
subscriptionDefinitionId = Text
a} :: UpdateSubscriptionDefinition)

instance Core.AWSRequest UpdateSubscriptionDefinition where
  type
    AWSResponse UpdateSubscriptionDefinition =
      UpdateSubscriptionDefinitionResponse
  request :: UpdateSubscriptionDefinition
-> Request UpdateSubscriptionDefinition
request = Service
-> UpdateSubscriptionDefinition
-> Request UpdateSubscriptionDefinition
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateSubscriptionDefinition
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateSubscriptionDefinition)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse UpdateSubscriptionDefinition))
-> Logger
-> Service
-> Proxy UpdateSubscriptionDefinition
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateSubscriptionDefinition)))
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 -> UpdateSubscriptionDefinitionResponse
UpdateSubscriptionDefinitionResponse'
            (Int -> UpdateSubscriptionDefinitionResponse)
-> Either String Int
-> Either String UpdateSubscriptionDefinitionResponse
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
    UpdateSubscriptionDefinition

instance Prelude.NFData UpdateSubscriptionDefinition

instance Core.ToHeaders UpdateSubscriptionDefinition where
  toHeaders :: UpdateSubscriptionDefinition -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateSubscriptionDefinition -> 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 UpdateSubscriptionDefinition where
  toJSON :: UpdateSubscriptionDefinition -> Value
toJSON UpdateSubscriptionDefinition' {Maybe Text
Text
subscriptionDefinitionId :: Text
name :: Maybe Text
$sel:subscriptionDefinitionId:UpdateSubscriptionDefinition' :: UpdateSubscriptionDefinition -> Text
$sel:name:UpdateSubscriptionDefinition' :: UpdateSubscriptionDefinition -> 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 UpdateSubscriptionDefinition where
  toPath :: UpdateSubscriptionDefinition -> ByteString
toPath UpdateSubscriptionDefinition' {Maybe Text
Text
subscriptionDefinitionId :: Text
name :: Maybe Text
$sel:subscriptionDefinitionId:UpdateSubscriptionDefinition' :: UpdateSubscriptionDefinition -> Text
$sel:name:UpdateSubscriptionDefinition' :: UpdateSubscriptionDefinition -> Maybe Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/greengrass/definition/subscriptions/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
subscriptionDefinitionId
      ]

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

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

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

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

instance
  Prelude.NFData
    UpdateSubscriptionDefinitionResponse