{-# 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.SSM.UpdateDocumentMetadata
-- 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 information related to approval reviews for a specific version
-- of a change template in Change Manager.
module Amazonka.SSM.UpdateDocumentMetadata
  ( -- * Creating a Request
    UpdateDocumentMetadata (..),
    newUpdateDocumentMetadata,

    -- * Request Lenses
    updateDocumentMetadata_documentVersion,
    updateDocumentMetadata_name,
    updateDocumentMetadata_documentReviews,

    -- * Destructuring the Response
    UpdateDocumentMetadataResponse (..),
    newUpdateDocumentMetadataResponse,

    -- * Response Lenses
    updateDocumentMetadataResponse_httpStatus,
  )
where

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
import Amazonka.SSM.Types

-- | /See:/ 'newUpdateDocumentMetadata' smart constructor.
data UpdateDocumentMetadata = UpdateDocumentMetadata'
  { -- | The version of a change template in which to update approval metadata.
    UpdateDocumentMetadata -> Maybe Text
documentVersion :: Prelude.Maybe Prelude.Text,
    -- | The name of the change template for which a version\'s metadata is to be
    -- updated.
    UpdateDocumentMetadata -> Text
name :: Prelude.Text,
    -- | The change template review details to update.
    UpdateDocumentMetadata -> DocumentReviews
documentReviews :: DocumentReviews
  }
  deriving (UpdateDocumentMetadata -> UpdateDocumentMetadata -> Bool
(UpdateDocumentMetadata -> UpdateDocumentMetadata -> Bool)
-> (UpdateDocumentMetadata -> UpdateDocumentMetadata -> Bool)
-> Eq UpdateDocumentMetadata
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateDocumentMetadata -> UpdateDocumentMetadata -> Bool
$c/= :: UpdateDocumentMetadata -> UpdateDocumentMetadata -> Bool
== :: UpdateDocumentMetadata -> UpdateDocumentMetadata -> Bool
$c== :: UpdateDocumentMetadata -> UpdateDocumentMetadata -> Bool
Prelude.Eq, ReadPrec [UpdateDocumentMetadata]
ReadPrec UpdateDocumentMetadata
Int -> ReadS UpdateDocumentMetadata
ReadS [UpdateDocumentMetadata]
(Int -> ReadS UpdateDocumentMetadata)
-> ReadS [UpdateDocumentMetadata]
-> ReadPrec UpdateDocumentMetadata
-> ReadPrec [UpdateDocumentMetadata]
-> Read UpdateDocumentMetadata
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateDocumentMetadata]
$creadListPrec :: ReadPrec [UpdateDocumentMetadata]
readPrec :: ReadPrec UpdateDocumentMetadata
$creadPrec :: ReadPrec UpdateDocumentMetadata
readList :: ReadS [UpdateDocumentMetadata]
$creadList :: ReadS [UpdateDocumentMetadata]
readsPrec :: Int -> ReadS UpdateDocumentMetadata
$creadsPrec :: Int -> ReadS UpdateDocumentMetadata
Prelude.Read, Int -> UpdateDocumentMetadata -> ShowS
[UpdateDocumentMetadata] -> ShowS
UpdateDocumentMetadata -> String
(Int -> UpdateDocumentMetadata -> ShowS)
-> (UpdateDocumentMetadata -> String)
-> ([UpdateDocumentMetadata] -> ShowS)
-> Show UpdateDocumentMetadata
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateDocumentMetadata] -> ShowS
$cshowList :: [UpdateDocumentMetadata] -> ShowS
show :: UpdateDocumentMetadata -> String
$cshow :: UpdateDocumentMetadata -> String
showsPrec :: Int -> UpdateDocumentMetadata -> ShowS
$cshowsPrec :: Int -> UpdateDocumentMetadata -> ShowS
Prelude.Show, (forall x. UpdateDocumentMetadata -> Rep UpdateDocumentMetadata x)
-> (forall x.
    Rep UpdateDocumentMetadata x -> UpdateDocumentMetadata)
-> Generic UpdateDocumentMetadata
forall x. Rep UpdateDocumentMetadata x -> UpdateDocumentMetadata
forall x. UpdateDocumentMetadata -> Rep UpdateDocumentMetadata x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateDocumentMetadata x -> UpdateDocumentMetadata
$cfrom :: forall x. UpdateDocumentMetadata -> Rep UpdateDocumentMetadata x
Prelude.Generic)

-- |
-- Create a value of 'UpdateDocumentMetadata' 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:
--
-- 'documentVersion', 'updateDocumentMetadata_documentVersion' - The version of a change template in which to update approval metadata.
--
-- 'name', 'updateDocumentMetadata_name' - The name of the change template for which a version\'s metadata is to be
-- updated.
--
-- 'documentReviews', 'updateDocumentMetadata_documentReviews' - The change template review details to update.
newUpdateDocumentMetadata ::
  -- | 'name'
  Prelude.Text ->
  -- | 'documentReviews'
  DocumentReviews ->
  UpdateDocumentMetadata
newUpdateDocumentMetadata :: Text -> DocumentReviews -> UpdateDocumentMetadata
newUpdateDocumentMetadata Text
pName_ DocumentReviews
pDocumentReviews_ =
  UpdateDocumentMetadata' :: Maybe Text -> Text -> DocumentReviews -> UpdateDocumentMetadata
UpdateDocumentMetadata'
    { $sel:documentVersion:UpdateDocumentMetadata' :: Maybe Text
documentVersion =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:UpdateDocumentMetadata' :: Text
name = Text
pName_,
      $sel:documentReviews:UpdateDocumentMetadata' :: DocumentReviews
documentReviews = DocumentReviews
pDocumentReviews_
    }

-- | The version of a change template in which to update approval metadata.
updateDocumentMetadata_documentVersion :: Lens.Lens' UpdateDocumentMetadata (Prelude.Maybe Prelude.Text)
updateDocumentMetadata_documentVersion :: (Maybe Text -> f (Maybe Text))
-> UpdateDocumentMetadata -> f UpdateDocumentMetadata
updateDocumentMetadata_documentVersion = (UpdateDocumentMetadata -> Maybe Text)
-> (UpdateDocumentMetadata -> Maybe Text -> UpdateDocumentMetadata)
-> Lens
     UpdateDocumentMetadata
     UpdateDocumentMetadata
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDocumentMetadata' {Maybe Text
documentVersion :: Maybe Text
$sel:documentVersion:UpdateDocumentMetadata' :: UpdateDocumentMetadata -> Maybe Text
documentVersion} -> Maybe Text
documentVersion) (\s :: UpdateDocumentMetadata
s@UpdateDocumentMetadata' {} Maybe Text
a -> UpdateDocumentMetadata
s {$sel:documentVersion:UpdateDocumentMetadata' :: Maybe Text
documentVersion = Maybe Text
a} :: UpdateDocumentMetadata)

-- | The name of the change template for which a version\'s metadata is to be
-- updated.
updateDocumentMetadata_name :: Lens.Lens' UpdateDocumentMetadata Prelude.Text
updateDocumentMetadata_name :: (Text -> f Text)
-> UpdateDocumentMetadata -> f UpdateDocumentMetadata
updateDocumentMetadata_name = (UpdateDocumentMetadata -> Text)
-> (UpdateDocumentMetadata -> Text -> UpdateDocumentMetadata)
-> Lens UpdateDocumentMetadata UpdateDocumentMetadata Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDocumentMetadata' {Text
name :: Text
$sel:name:UpdateDocumentMetadata' :: UpdateDocumentMetadata -> Text
name} -> Text
name) (\s :: UpdateDocumentMetadata
s@UpdateDocumentMetadata' {} Text
a -> UpdateDocumentMetadata
s {$sel:name:UpdateDocumentMetadata' :: Text
name = Text
a} :: UpdateDocumentMetadata)

-- | The change template review details to update.
updateDocumentMetadata_documentReviews :: Lens.Lens' UpdateDocumentMetadata DocumentReviews
updateDocumentMetadata_documentReviews :: (DocumentReviews -> f DocumentReviews)
-> UpdateDocumentMetadata -> f UpdateDocumentMetadata
updateDocumentMetadata_documentReviews = (UpdateDocumentMetadata -> DocumentReviews)
-> (UpdateDocumentMetadata
    -> DocumentReviews -> UpdateDocumentMetadata)
-> Lens
     UpdateDocumentMetadata
     UpdateDocumentMetadata
     DocumentReviews
     DocumentReviews
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDocumentMetadata' {DocumentReviews
documentReviews :: DocumentReviews
$sel:documentReviews:UpdateDocumentMetadata' :: UpdateDocumentMetadata -> DocumentReviews
documentReviews} -> DocumentReviews
documentReviews) (\s :: UpdateDocumentMetadata
s@UpdateDocumentMetadata' {} DocumentReviews
a -> UpdateDocumentMetadata
s {$sel:documentReviews:UpdateDocumentMetadata' :: DocumentReviews
documentReviews = DocumentReviews
a} :: UpdateDocumentMetadata)

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

instance Prelude.NFData UpdateDocumentMetadata

instance Core.ToHeaders UpdateDocumentMetadata where
  toHeaders :: UpdateDocumentMetadata -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateDocumentMetadata -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"AmazonSSM.UpdateDocumentMetadata" ::
                          Prelude.ByteString
                      ),
            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 UpdateDocumentMetadata where
  toJSON :: UpdateDocumentMetadata -> Value
toJSON UpdateDocumentMetadata' {Maybe Text
Text
DocumentReviews
documentReviews :: DocumentReviews
name :: Text
documentVersion :: Maybe Text
$sel:documentReviews:UpdateDocumentMetadata' :: UpdateDocumentMetadata -> DocumentReviews
$sel:name:UpdateDocumentMetadata' :: UpdateDocumentMetadata -> Text
$sel:documentVersion:UpdateDocumentMetadata' :: UpdateDocumentMetadata -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"DocumentVersion" 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
documentVersion,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"DocumentReviews" Text -> DocumentReviews -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= DocumentReviews
documentReviews)
          ]
      )

instance Core.ToPath UpdateDocumentMetadata where
  toPath :: UpdateDocumentMetadata -> ByteString
toPath = ByteString -> UpdateDocumentMetadata -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

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

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

instance
  Prelude.NFData
    UpdateDocumentMetadataResponse