{-# 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.InstanceAssociation
-- 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)
module Amazonka.SSM.Types.InstanceAssociation where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | One or more association documents on the instance.
--
-- /See:/ 'newInstanceAssociation' smart constructor.
data InstanceAssociation = InstanceAssociation'
  { -- | The association ID.
    InstanceAssociation -> Maybe Text
associationId :: Prelude.Maybe Prelude.Text,
    -- | The instance ID.
    InstanceAssociation -> Maybe Text
instanceId :: Prelude.Maybe Prelude.Text,
    -- | The content of the association document for the instance(s).
    InstanceAssociation -> Maybe Text
content :: Prelude.Maybe Prelude.Text,
    -- | Version information for the association on the instance.
    InstanceAssociation -> Maybe Text
associationVersion :: Prelude.Maybe Prelude.Text
  }
  deriving (InstanceAssociation -> InstanceAssociation -> Bool
(InstanceAssociation -> InstanceAssociation -> Bool)
-> (InstanceAssociation -> InstanceAssociation -> Bool)
-> Eq InstanceAssociation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InstanceAssociation -> InstanceAssociation -> Bool
$c/= :: InstanceAssociation -> InstanceAssociation -> Bool
== :: InstanceAssociation -> InstanceAssociation -> Bool
$c== :: InstanceAssociation -> InstanceAssociation -> Bool
Prelude.Eq, ReadPrec [InstanceAssociation]
ReadPrec InstanceAssociation
Int -> ReadS InstanceAssociation
ReadS [InstanceAssociation]
(Int -> ReadS InstanceAssociation)
-> ReadS [InstanceAssociation]
-> ReadPrec InstanceAssociation
-> ReadPrec [InstanceAssociation]
-> Read InstanceAssociation
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InstanceAssociation]
$creadListPrec :: ReadPrec [InstanceAssociation]
readPrec :: ReadPrec InstanceAssociation
$creadPrec :: ReadPrec InstanceAssociation
readList :: ReadS [InstanceAssociation]
$creadList :: ReadS [InstanceAssociation]
readsPrec :: Int -> ReadS InstanceAssociation
$creadsPrec :: Int -> ReadS InstanceAssociation
Prelude.Read, Int -> InstanceAssociation -> ShowS
[InstanceAssociation] -> ShowS
InstanceAssociation -> String
(Int -> InstanceAssociation -> ShowS)
-> (InstanceAssociation -> String)
-> ([InstanceAssociation] -> ShowS)
-> Show InstanceAssociation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InstanceAssociation] -> ShowS
$cshowList :: [InstanceAssociation] -> ShowS
show :: InstanceAssociation -> String
$cshow :: InstanceAssociation -> String
showsPrec :: Int -> InstanceAssociation -> ShowS
$cshowsPrec :: Int -> InstanceAssociation -> ShowS
Prelude.Show, (forall x. InstanceAssociation -> Rep InstanceAssociation x)
-> (forall x. Rep InstanceAssociation x -> InstanceAssociation)
-> Generic InstanceAssociation
forall x. Rep InstanceAssociation x -> InstanceAssociation
forall x. InstanceAssociation -> Rep InstanceAssociation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InstanceAssociation x -> InstanceAssociation
$cfrom :: forall x. InstanceAssociation -> Rep InstanceAssociation x
Prelude.Generic)

-- |
-- Create a value of 'InstanceAssociation' 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:
--
-- 'associationId', 'instanceAssociation_associationId' - The association ID.
--
-- 'instanceId', 'instanceAssociation_instanceId' - The instance ID.
--
-- 'content', 'instanceAssociation_content' - The content of the association document for the instance(s).
--
-- 'associationVersion', 'instanceAssociation_associationVersion' - Version information for the association on the instance.
newInstanceAssociation ::
  InstanceAssociation
newInstanceAssociation :: InstanceAssociation
newInstanceAssociation =
  InstanceAssociation' :: Maybe Text
-> Maybe Text -> Maybe Text -> Maybe Text -> InstanceAssociation
InstanceAssociation'
    { $sel:associationId:InstanceAssociation' :: Maybe Text
associationId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:instanceId:InstanceAssociation' :: Maybe Text
instanceId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:content:InstanceAssociation' :: Maybe Text
content = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:associationVersion:InstanceAssociation' :: Maybe Text
associationVersion = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The association ID.
instanceAssociation_associationId :: Lens.Lens' InstanceAssociation (Prelude.Maybe Prelude.Text)
instanceAssociation_associationId :: (Maybe Text -> f (Maybe Text))
-> InstanceAssociation -> f InstanceAssociation
instanceAssociation_associationId = (InstanceAssociation -> Maybe Text)
-> (InstanceAssociation -> Maybe Text -> InstanceAssociation)
-> Lens
     InstanceAssociation InstanceAssociation (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceAssociation' {Maybe Text
associationId :: Maybe Text
$sel:associationId:InstanceAssociation' :: InstanceAssociation -> Maybe Text
associationId} -> Maybe Text
associationId) (\s :: InstanceAssociation
s@InstanceAssociation' {} Maybe Text
a -> InstanceAssociation
s {$sel:associationId:InstanceAssociation' :: Maybe Text
associationId = Maybe Text
a} :: InstanceAssociation)

-- | The instance ID.
instanceAssociation_instanceId :: Lens.Lens' InstanceAssociation (Prelude.Maybe Prelude.Text)
instanceAssociation_instanceId :: (Maybe Text -> f (Maybe Text))
-> InstanceAssociation -> f InstanceAssociation
instanceAssociation_instanceId = (InstanceAssociation -> Maybe Text)
-> (InstanceAssociation -> Maybe Text -> InstanceAssociation)
-> Lens
     InstanceAssociation InstanceAssociation (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceAssociation' {Maybe Text
instanceId :: Maybe Text
$sel:instanceId:InstanceAssociation' :: InstanceAssociation -> Maybe Text
instanceId} -> Maybe Text
instanceId) (\s :: InstanceAssociation
s@InstanceAssociation' {} Maybe Text
a -> InstanceAssociation
s {$sel:instanceId:InstanceAssociation' :: Maybe Text
instanceId = Maybe Text
a} :: InstanceAssociation)

-- | The content of the association document for the instance(s).
instanceAssociation_content :: Lens.Lens' InstanceAssociation (Prelude.Maybe Prelude.Text)
instanceAssociation_content :: (Maybe Text -> f (Maybe Text))
-> InstanceAssociation -> f InstanceAssociation
instanceAssociation_content = (InstanceAssociation -> Maybe Text)
-> (InstanceAssociation -> Maybe Text -> InstanceAssociation)
-> Lens
     InstanceAssociation InstanceAssociation (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceAssociation' {Maybe Text
content :: Maybe Text
$sel:content:InstanceAssociation' :: InstanceAssociation -> Maybe Text
content} -> Maybe Text
content) (\s :: InstanceAssociation
s@InstanceAssociation' {} Maybe Text
a -> InstanceAssociation
s {$sel:content:InstanceAssociation' :: Maybe Text
content = Maybe Text
a} :: InstanceAssociation)

-- | Version information for the association on the instance.
instanceAssociation_associationVersion :: Lens.Lens' InstanceAssociation (Prelude.Maybe Prelude.Text)
instanceAssociation_associationVersion :: (Maybe Text -> f (Maybe Text))
-> InstanceAssociation -> f InstanceAssociation
instanceAssociation_associationVersion = (InstanceAssociation -> Maybe Text)
-> (InstanceAssociation -> Maybe Text -> InstanceAssociation)
-> Lens
     InstanceAssociation InstanceAssociation (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceAssociation' {Maybe Text
associationVersion :: Maybe Text
$sel:associationVersion:InstanceAssociation' :: InstanceAssociation -> Maybe Text
associationVersion} -> Maybe Text
associationVersion) (\s :: InstanceAssociation
s@InstanceAssociation' {} Maybe Text
a -> InstanceAssociation
s {$sel:associationVersion:InstanceAssociation' :: Maybe Text
associationVersion = Maybe Text
a} :: InstanceAssociation)

instance Core.FromJSON InstanceAssociation where
  parseJSON :: Value -> Parser InstanceAssociation
parseJSON =
    String
-> (Object -> Parser InstanceAssociation)
-> Value
-> Parser InstanceAssociation
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"InstanceAssociation"
      ( \Object
x ->
          Maybe Text
-> Maybe Text -> Maybe Text -> Maybe Text -> InstanceAssociation
InstanceAssociation'
            (Maybe Text
 -> Maybe Text -> Maybe Text -> Maybe Text -> InstanceAssociation)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe Text -> Maybe Text -> InstanceAssociation)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AssociationId")
            Parser
  (Maybe Text -> Maybe Text -> Maybe Text -> InstanceAssociation)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> InstanceAssociation)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"InstanceId")
            Parser (Maybe Text -> Maybe Text -> InstanceAssociation)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> InstanceAssociation)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Content")
            Parser (Maybe Text -> InstanceAssociation)
-> Parser (Maybe Text) -> Parser InstanceAssociation
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AssociationVersion")
      )

instance Prelude.Hashable InstanceAssociation

instance Prelude.NFData InstanceAssociation