{-# 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.DescribeDocument
-- 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)
--
-- Describes the specified Amazon Web Services Systems Manager document
-- (SSM document).
module Amazonka.SSM.DescribeDocument
  ( -- * Creating a Request
    DescribeDocument (..),
    newDescribeDocument,

    -- * Request Lenses
    describeDocument_versionName,
    describeDocument_documentVersion,
    describeDocument_name,

    -- * Destructuring the Response
    DescribeDocumentResponse (..),
    newDescribeDocumentResponse,

    -- * Response Lenses
    describeDocumentResponse_document,
    describeDocumentResponse_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:/ 'newDescribeDocument' smart constructor.
data DescribeDocument = DescribeDocument'
  { -- | An optional field specifying the version of the artifact associated with
    -- the document. For example, \"Release 12, Update 6\". This value is
    -- unique across all versions of a document, and can\'t be changed.
    DescribeDocument -> Maybe Text
versionName :: Prelude.Maybe Prelude.Text,
    -- | The document version for which you want information. Can be a specific
    -- version or the default version.
    DescribeDocument -> Maybe Text
documentVersion :: Prelude.Maybe Prelude.Text,
    -- | The name of the SSM document.
    DescribeDocument -> Text
name :: Prelude.Text
  }
  deriving (DescribeDocument -> DescribeDocument -> Bool
(DescribeDocument -> DescribeDocument -> Bool)
-> (DescribeDocument -> DescribeDocument -> Bool)
-> Eq DescribeDocument
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeDocument -> DescribeDocument -> Bool
$c/= :: DescribeDocument -> DescribeDocument -> Bool
== :: DescribeDocument -> DescribeDocument -> Bool
$c== :: DescribeDocument -> DescribeDocument -> Bool
Prelude.Eq, ReadPrec [DescribeDocument]
ReadPrec DescribeDocument
Int -> ReadS DescribeDocument
ReadS [DescribeDocument]
(Int -> ReadS DescribeDocument)
-> ReadS [DescribeDocument]
-> ReadPrec DescribeDocument
-> ReadPrec [DescribeDocument]
-> Read DescribeDocument
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeDocument]
$creadListPrec :: ReadPrec [DescribeDocument]
readPrec :: ReadPrec DescribeDocument
$creadPrec :: ReadPrec DescribeDocument
readList :: ReadS [DescribeDocument]
$creadList :: ReadS [DescribeDocument]
readsPrec :: Int -> ReadS DescribeDocument
$creadsPrec :: Int -> ReadS DescribeDocument
Prelude.Read, Int -> DescribeDocument -> ShowS
[DescribeDocument] -> ShowS
DescribeDocument -> String
(Int -> DescribeDocument -> ShowS)
-> (DescribeDocument -> String)
-> ([DescribeDocument] -> ShowS)
-> Show DescribeDocument
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeDocument] -> ShowS
$cshowList :: [DescribeDocument] -> ShowS
show :: DescribeDocument -> String
$cshow :: DescribeDocument -> String
showsPrec :: Int -> DescribeDocument -> ShowS
$cshowsPrec :: Int -> DescribeDocument -> ShowS
Prelude.Show, (forall x. DescribeDocument -> Rep DescribeDocument x)
-> (forall x. Rep DescribeDocument x -> DescribeDocument)
-> Generic DescribeDocument
forall x. Rep DescribeDocument x -> DescribeDocument
forall x. DescribeDocument -> Rep DescribeDocument x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeDocument x -> DescribeDocument
$cfrom :: forall x. DescribeDocument -> Rep DescribeDocument x
Prelude.Generic)

-- |
-- Create a value of 'DescribeDocument' 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:
--
-- 'versionName', 'describeDocument_versionName' - An optional field specifying the version of the artifact associated with
-- the document. For example, \"Release 12, Update 6\". This value is
-- unique across all versions of a document, and can\'t be changed.
--
-- 'documentVersion', 'describeDocument_documentVersion' - The document version for which you want information. Can be a specific
-- version or the default version.
--
-- 'name', 'describeDocument_name' - The name of the SSM document.
newDescribeDocument ::
  -- | 'name'
  Prelude.Text ->
  DescribeDocument
newDescribeDocument :: Text -> DescribeDocument
newDescribeDocument Text
pName_ =
  DescribeDocument' :: Maybe Text -> Maybe Text -> Text -> DescribeDocument
DescribeDocument'
    { $sel:versionName:DescribeDocument' :: Maybe Text
versionName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:documentVersion:DescribeDocument' :: Maybe Text
documentVersion = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:DescribeDocument' :: Text
name = Text
pName_
    }

-- | An optional field specifying the version of the artifact associated with
-- the document. For example, \"Release 12, Update 6\". This value is
-- unique across all versions of a document, and can\'t be changed.
describeDocument_versionName :: Lens.Lens' DescribeDocument (Prelude.Maybe Prelude.Text)
describeDocument_versionName :: (Maybe Text -> f (Maybe Text))
-> DescribeDocument -> f DescribeDocument
describeDocument_versionName = (DescribeDocument -> Maybe Text)
-> (DescribeDocument -> Maybe Text -> DescribeDocument)
-> Lens DescribeDocument DescribeDocument (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeDocument' {Maybe Text
versionName :: Maybe Text
$sel:versionName:DescribeDocument' :: DescribeDocument -> Maybe Text
versionName} -> Maybe Text
versionName) (\s :: DescribeDocument
s@DescribeDocument' {} Maybe Text
a -> DescribeDocument
s {$sel:versionName:DescribeDocument' :: Maybe Text
versionName = Maybe Text
a} :: DescribeDocument)

-- | The document version for which you want information. Can be a specific
-- version or the default version.
describeDocument_documentVersion :: Lens.Lens' DescribeDocument (Prelude.Maybe Prelude.Text)
describeDocument_documentVersion :: (Maybe Text -> f (Maybe Text))
-> DescribeDocument -> f DescribeDocument
describeDocument_documentVersion = (DescribeDocument -> Maybe Text)
-> (DescribeDocument -> Maybe Text -> DescribeDocument)
-> Lens DescribeDocument DescribeDocument (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeDocument' {Maybe Text
documentVersion :: Maybe Text
$sel:documentVersion:DescribeDocument' :: DescribeDocument -> Maybe Text
documentVersion} -> Maybe Text
documentVersion) (\s :: DescribeDocument
s@DescribeDocument' {} Maybe Text
a -> DescribeDocument
s {$sel:documentVersion:DescribeDocument' :: Maybe Text
documentVersion = Maybe Text
a} :: DescribeDocument)

-- | The name of the SSM document.
describeDocument_name :: Lens.Lens' DescribeDocument Prelude.Text
describeDocument_name :: (Text -> f Text) -> DescribeDocument -> f DescribeDocument
describeDocument_name = (DescribeDocument -> Text)
-> (DescribeDocument -> Text -> DescribeDocument)
-> Lens DescribeDocument DescribeDocument Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeDocument' {Text
name :: Text
$sel:name:DescribeDocument' :: DescribeDocument -> Text
name} -> Text
name) (\s :: DescribeDocument
s@DescribeDocument' {} Text
a -> DescribeDocument
s {$sel:name:DescribeDocument' :: Text
name = Text
a} :: DescribeDocument)

instance Core.AWSRequest DescribeDocument where
  type
    AWSResponse DescribeDocument =
      DescribeDocumentResponse
  request :: DescribeDocument -> Request DescribeDocument
request = Service -> DescribeDocument -> Request DescribeDocument
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeDocument
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeDocument)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeDocument))
-> Logger
-> Service
-> Proxy DescribeDocument
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeDocument)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe DocumentDescription -> Int -> DescribeDocumentResponse
DescribeDocumentResponse'
            (Maybe DocumentDescription -> Int -> DescribeDocumentResponse)
-> Either String (Maybe DocumentDescription)
-> Either String (Int -> DescribeDocumentResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe DocumentDescription)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Document")
            Either String (Int -> DescribeDocumentResponse)
-> Either String Int -> Either String DescribeDocumentResponse
forall (f :: * -> *) a b. Applicative f => 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 DescribeDocument

instance Prelude.NFData DescribeDocument

instance Core.ToHeaders DescribeDocument where
  toHeaders :: DescribeDocument -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeDocument -> 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.DescribeDocument" :: 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 DescribeDocument where
  toJSON :: DescribeDocument -> Value
toJSON DescribeDocument' {Maybe Text
Text
name :: Text
documentVersion :: Maybe Text
versionName :: Maybe Text
$sel:name:DescribeDocument' :: DescribeDocument -> Text
$sel:documentVersion:DescribeDocument' :: DescribeDocument -> Maybe Text
$sel:versionName:DescribeDocument' :: DescribeDocument -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"VersionName" 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
versionName,
            (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)
          ]
      )

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

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

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

-- |
-- Create a value of 'DescribeDocumentResponse' 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:
--
-- 'document', 'describeDocumentResponse_document' - Information about the SSM document.
--
-- 'httpStatus', 'describeDocumentResponse_httpStatus' - The response's http status code.
newDescribeDocumentResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeDocumentResponse
newDescribeDocumentResponse :: Int -> DescribeDocumentResponse
newDescribeDocumentResponse Int
pHttpStatus_ =
  DescribeDocumentResponse' :: Maybe DocumentDescription -> Int -> DescribeDocumentResponse
DescribeDocumentResponse'
    { $sel:document:DescribeDocumentResponse' :: Maybe DocumentDescription
document =
        Maybe DocumentDescription
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeDocumentResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the SSM document.
describeDocumentResponse_document :: Lens.Lens' DescribeDocumentResponse (Prelude.Maybe DocumentDescription)
describeDocumentResponse_document :: (Maybe DocumentDescription -> f (Maybe DocumentDescription))
-> DescribeDocumentResponse -> f DescribeDocumentResponse
describeDocumentResponse_document = (DescribeDocumentResponse -> Maybe DocumentDescription)
-> (DescribeDocumentResponse
    -> Maybe DocumentDescription -> DescribeDocumentResponse)
-> Lens
     DescribeDocumentResponse
     DescribeDocumentResponse
     (Maybe DocumentDescription)
     (Maybe DocumentDescription)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeDocumentResponse' {Maybe DocumentDescription
document :: Maybe DocumentDescription
$sel:document:DescribeDocumentResponse' :: DescribeDocumentResponse -> Maybe DocumentDescription
document} -> Maybe DocumentDescription
document) (\s :: DescribeDocumentResponse
s@DescribeDocumentResponse' {} Maybe DocumentDescription
a -> DescribeDocumentResponse
s {$sel:document:DescribeDocumentResponse' :: Maybe DocumentDescription
document = Maybe DocumentDescription
a} :: DescribeDocumentResponse)

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

instance Prelude.NFData DescribeDocumentResponse