{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# 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.Types.DocumentRequires
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.SSM.Types.DocumentRequires where

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

-- | An SSM document required by the current document.
--
-- /See:/ 'newDocumentRequires' smart constructor.
data DocumentRequires = DocumentRequires'
  { -- | The document type of the required SSM document.
    DocumentRequires -> Maybe Text
requireType :: Prelude.Maybe Prelude.Text,
    -- | The document version required by the current document.
    DocumentRequires -> Maybe Text
version :: Prelude.Maybe Prelude.Text,
    -- | 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.
    DocumentRequires -> Maybe Text
versionName :: Prelude.Maybe Prelude.Text,
    -- | The name of the required SSM document. The name can be an Amazon
    -- Resource Name (ARN).
    DocumentRequires -> Text
name :: Prelude.Text
  }
  deriving (DocumentRequires -> DocumentRequires -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DocumentRequires -> DocumentRequires -> Bool
$c/= :: DocumentRequires -> DocumentRequires -> Bool
== :: DocumentRequires -> DocumentRequires -> Bool
$c== :: DocumentRequires -> DocumentRequires -> Bool
Prelude.Eq, ReadPrec [DocumentRequires]
ReadPrec DocumentRequires
Int -> ReadS DocumentRequires
ReadS [DocumentRequires]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DocumentRequires]
$creadListPrec :: ReadPrec [DocumentRequires]
readPrec :: ReadPrec DocumentRequires
$creadPrec :: ReadPrec DocumentRequires
readList :: ReadS [DocumentRequires]
$creadList :: ReadS [DocumentRequires]
readsPrec :: Int -> ReadS DocumentRequires
$creadsPrec :: Int -> ReadS DocumentRequires
Prelude.Read, Int -> DocumentRequires -> ShowS
[DocumentRequires] -> ShowS
DocumentRequires -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DocumentRequires] -> ShowS
$cshowList :: [DocumentRequires] -> ShowS
show :: DocumentRequires -> String
$cshow :: DocumentRequires -> String
showsPrec :: Int -> DocumentRequires -> ShowS
$cshowsPrec :: Int -> DocumentRequires -> ShowS
Prelude.Show, forall x. Rep DocumentRequires x -> DocumentRequires
forall x. DocumentRequires -> Rep DocumentRequires x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DocumentRequires x -> DocumentRequires
$cfrom :: forall x. DocumentRequires -> Rep DocumentRequires x
Prelude.Generic)

-- |
-- Create a value of 'DocumentRequires' 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:
--
-- 'requireType', 'documentRequires_requireType' - The document type of the required SSM document.
--
-- 'version', 'documentRequires_version' - The document version required by the current document.
--
-- 'versionName', 'documentRequires_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.
--
-- 'name', 'documentRequires_name' - The name of the required SSM document. The name can be an Amazon
-- Resource Name (ARN).
newDocumentRequires ::
  -- | 'name'
  Prelude.Text ->
  DocumentRequires
newDocumentRequires :: Text -> DocumentRequires
newDocumentRequires Text
pName_ =
  DocumentRequires'
    { $sel:requireType:DocumentRequires' :: Maybe Text
requireType = forall a. Maybe a
Prelude.Nothing,
      $sel:version:DocumentRequires' :: Maybe Text
version = forall a. Maybe a
Prelude.Nothing,
      $sel:versionName:DocumentRequires' :: Maybe Text
versionName = forall a. Maybe a
Prelude.Nothing,
      $sel:name:DocumentRequires' :: Text
name = Text
pName_
    }

-- | The document type of the required SSM document.
documentRequires_requireType :: Lens.Lens' DocumentRequires (Prelude.Maybe Prelude.Text)
documentRequires_requireType :: Lens' DocumentRequires (Maybe Text)
documentRequires_requireType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DocumentRequires' {Maybe Text
requireType :: Maybe Text
$sel:requireType:DocumentRequires' :: DocumentRequires -> Maybe Text
requireType} -> Maybe Text
requireType) (\s :: DocumentRequires
s@DocumentRequires' {} Maybe Text
a -> DocumentRequires
s {$sel:requireType:DocumentRequires' :: Maybe Text
requireType = Maybe Text
a} :: DocumentRequires)

-- | The document version required by the current document.
documentRequires_version :: Lens.Lens' DocumentRequires (Prelude.Maybe Prelude.Text)
documentRequires_version :: Lens' DocumentRequires (Maybe Text)
documentRequires_version = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DocumentRequires' {Maybe Text
version :: Maybe Text
$sel:version:DocumentRequires' :: DocumentRequires -> Maybe Text
version} -> Maybe Text
version) (\s :: DocumentRequires
s@DocumentRequires' {} Maybe Text
a -> DocumentRequires
s {$sel:version:DocumentRequires' :: Maybe Text
version = Maybe Text
a} :: DocumentRequires)

-- | 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.
documentRequires_versionName :: Lens.Lens' DocumentRequires (Prelude.Maybe Prelude.Text)
documentRequires_versionName :: Lens' DocumentRequires (Maybe Text)
documentRequires_versionName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DocumentRequires' {Maybe Text
versionName :: Maybe Text
$sel:versionName:DocumentRequires' :: DocumentRequires -> Maybe Text
versionName} -> Maybe Text
versionName) (\s :: DocumentRequires
s@DocumentRequires' {} Maybe Text
a -> DocumentRequires
s {$sel:versionName:DocumentRequires' :: Maybe Text
versionName = Maybe Text
a} :: DocumentRequires)

-- | The name of the required SSM document. The name can be an Amazon
-- Resource Name (ARN).
documentRequires_name :: Lens.Lens' DocumentRequires Prelude.Text
documentRequires_name :: Lens' DocumentRequires Text
documentRequires_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DocumentRequires' {Text
name :: Text
$sel:name:DocumentRequires' :: DocumentRequires -> Text
name} -> Text
name) (\s :: DocumentRequires
s@DocumentRequires' {} Text
a -> DocumentRequires
s {$sel:name:DocumentRequires' :: Text
name = Text
a} :: DocumentRequires)

instance Data.FromJSON DocumentRequires where
  parseJSON :: Value -> Parser DocumentRequires
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"DocumentRequires"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Maybe Text -> Text -> DocumentRequires
DocumentRequires'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"RequireType")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Version")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"VersionName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Name")
      )

instance Prelude.Hashable DocumentRequires where
  hashWithSalt :: Int -> DocumentRequires -> Int
hashWithSalt Int
_salt DocumentRequires' {Maybe Text
Text
name :: Text
versionName :: Maybe Text
version :: Maybe Text
requireType :: Maybe Text
$sel:name:DocumentRequires' :: DocumentRequires -> Text
$sel:versionName:DocumentRequires' :: DocumentRequires -> Maybe Text
$sel:version:DocumentRequires' :: DocumentRequires -> Maybe Text
$sel:requireType:DocumentRequires' :: DocumentRequires -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
requireType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
version
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
versionName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name

instance Prelude.NFData DocumentRequires where
  rnf :: DocumentRequires -> ()
rnf DocumentRequires' {Maybe Text
Text
name :: Text
versionName :: Maybe Text
version :: Maybe Text
requireType :: Maybe Text
$sel:name:DocumentRequires' :: DocumentRequires -> Text
$sel:versionName:DocumentRequires' :: DocumentRequires -> Maybe Text
$sel:version:DocumentRequires' :: DocumentRequires -> Maybe Text
$sel:requireType:DocumentRequires' :: DocumentRequires -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
requireType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
version
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
versionName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name

instance Data.ToJSON DocumentRequires where
  toJSON :: DocumentRequires -> Value
toJSON DocumentRequires' {Maybe Text
Text
name :: Text
versionName :: Maybe Text
version :: Maybe Text
requireType :: Maybe Text
$sel:name:DocumentRequires' :: DocumentRequires -> Text
$sel:versionName:DocumentRequires' :: DocumentRequires -> Maybe Text
$sel:version:DocumentRequires' :: DocumentRequires -> Maybe Text
$sel:requireType:DocumentRequires' :: DocumentRequires -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"RequireType" 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
requireType,
            (Key
"Version" 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
version,
            (Key
"VersionName" 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
versionName,
            forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name)
          ]
      )