{-# 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.OpsEntity
-- 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.OpsEntity where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SSM.Types.OpsEntityItem

-- | The result of the query.
--
-- /See:/ 'newOpsEntity' smart constructor.
data OpsEntity = OpsEntity'
  { -- | The data returned by the query.
    OpsEntity -> Maybe (HashMap Text OpsEntityItem)
data' :: Prelude.Maybe (Prelude.HashMap Prelude.Text OpsEntityItem),
    -- | The query ID.
    OpsEntity -> Maybe Text
id :: Prelude.Maybe Prelude.Text
  }
  deriving (OpsEntity -> OpsEntity -> Bool
(OpsEntity -> OpsEntity -> Bool)
-> (OpsEntity -> OpsEntity -> Bool) -> Eq OpsEntity
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OpsEntity -> OpsEntity -> Bool
$c/= :: OpsEntity -> OpsEntity -> Bool
== :: OpsEntity -> OpsEntity -> Bool
$c== :: OpsEntity -> OpsEntity -> Bool
Prelude.Eq, ReadPrec [OpsEntity]
ReadPrec OpsEntity
Int -> ReadS OpsEntity
ReadS [OpsEntity]
(Int -> ReadS OpsEntity)
-> ReadS [OpsEntity]
-> ReadPrec OpsEntity
-> ReadPrec [OpsEntity]
-> Read OpsEntity
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OpsEntity]
$creadListPrec :: ReadPrec [OpsEntity]
readPrec :: ReadPrec OpsEntity
$creadPrec :: ReadPrec OpsEntity
readList :: ReadS [OpsEntity]
$creadList :: ReadS [OpsEntity]
readsPrec :: Int -> ReadS OpsEntity
$creadsPrec :: Int -> ReadS OpsEntity
Prelude.Read, Int -> OpsEntity -> ShowS
[OpsEntity] -> ShowS
OpsEntity -> String
(Int -> OpsEntity -> ShowS)
-> (OpsEntity -> String)
-> ([OpsEntity] -> ShowS)
-> Show OpsEntity
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OpsEntity] -> ShowS
$cshowList :: [OpsEntity] -> ShowS
show :: OpsEntity -> String
$cshow :: OpsEntity -> String
showsPrec :: Int -> OpsEntity -> ShowS
$cshowsPrec :: Int -> OpsEntity -> ShowS
Prelude.Show, (forall x. OpsEntity -> Rep OpsEntity x)
-> (forall x. Rep OpsEntity x -> OpsEntity) -> Generic OpsEntity
forall x. Rep OpsEntity x -> OpsEntity
forall x. OpsEntity -> Rep OpsEntity x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OpsEntity x -> OpsEntity
$cfrom :: forall x. OpsEntity -> Rep OpsEntity x
Prelude.Generic)

-- |
-- Create a value of 'OpsEntity' 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:
--
-- 'data'', 'opsEntity_data' - The data returned by the query.
--
-- 'id', 'opsEntity_id' - The query ID.
newOpsEntity ::
  OpsEntity
newOpsEntity :: OpsEntity
newOpsEntity =
  OpsEntity' :: Maybe (HashMap Text OpsEntityItem) -> Maybe Text -> OpsEntity
OpsEntity'
    { $sel:data':OpsEntity' :: Maybe (HashMap Text OpsEntityItem)
data' = Maybe (HashMap Text OpsEntityItem)
forall a. Maybe a
Prelude.Nothing,
      $sel:id:OpsEntity' :: Maybe Text
id = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The data returned by the query.
opsEntity_data :: Lens.Lens' OpsEntity (Prelude.Maybe (Prelude.HashMap Prelude.Text OpsEntityItem))
opsEntity_data :: (Maybe (HashMap Text OpsEntityItem)
 -> f (Maybe (HashMap Text OpsEntityItem)))
-> OpsEntity -> f OpsEntity
opsEntity_data = (OpsEntity -> Maybe (HashMap Text OpsEntityItem))
-> (OpsEntity -> Maybe (HashMap Text OpsEntityItem) -> OpsEntity)
-> Lens
     OpsEntity
     OpsEntity
     (Maybe (HashMap Text OpsEntityItem))
     (Maybe (HashMap Text OpsEntityItem))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OpsEntity' {Maybe (HashMap Text OpsEntityItem)
data' :: Maybe (HashMap Text OpsEntityItem)
$sel:data':OpsEntity' :: OpsEntity -> Maybe (HashMap Text OpsEntityItem)
data'} -> Maybe (HashMap Text OpsEntityItem)
data') (\s :: OpsEntity
s@OpsEntity' {} Maybe (HashMap Text OpsEntityItem)
a -> OpsEntity
s {$sel:data':OpsEntity' :: Maybe (HashMap Text OpsEntityItem)
data' = Maybe (HashMap Text OpsEntityItem)
a} :: OpsEntity) ((Maybe (HashMap Text OpsEntityItem)
  -> f (Maybe (HashMap Text OpsEntityItem)))
 -> OpsEntity -> f OpsEntity)
-> ((Maybe (HashMap Text OpsEntityItem)
     -> f (Maybe (HashMap Text OpsEntityItem)))
    -> Maybe (HashMap Text OpsEntityItem)
    -> f (Maybe (HashMap Text OpsEntityItem)))
-> (Maybe (HashMap Text OpsEntityItem)
    -> f (Maybe (HashMap Text OpsEntityItem)))
-> OpsEntity
-> f OpsEntity
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text OpsEntityItem)
  (HashMap Text OpsEntityItem)
  (HashMap Text OpsEntityItem)
  (HashMap Text OpsEntityItem)
-> Iso
     (Maybe (HashMap Text OpsEntityItem))
     (Maybe (HashMap Text OpsEntityItem))
     (Maybe (HashMap Text OpsEntityItem))
     (Maybe (HashMap Text OpsEntityItem))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  (HashMap Text OpsEntityItem)
  (HashMap Text OpsEntityItem)
  (HashMap Text OpsEntityItem)
  (HashMap Text OpsEntityItem)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The query ID.
opsEntity_id :: Lens.Lens' OpsEntity (Prelude.Maybe Prelude.Text)
opsEntity_id :: (Maybe Text -> f (Maybe Text)) -> OpsEntity -> f OpsEntity
opsEntity_id = (OpsEntity -> Maybe Text)
-> (OpsEntity -> Maybe Text -> OpsEntity)
-> Lens OpsEntity OpsEntity (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OpsEntity' {Maybe Text
id :: Maybe Text
$sel:id:OpsEntity' :: OpsEntity -> Maybe Text
id} -> Maybe Text
id) (\s :: OpsEntity
s@OpsEntity' {} Maybe Text
a -> OpsEntity
s {$sel:id:OpsEntity' :: Maybe Text
id = Maybe Text
a} :: OpsEntity)

instance Core.FromJSON OpsEntity where
  parseJSON :: Value -> Parser OpsEntity
parseJSON =
    String -> (Object -> Parser OpsEntity) -> Value -> Parser OpsEntity
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"OpsEntity"
      ( \Object
x ->
          Maybe (HashMap Text OpsEntityItem) -> Maybe Text -> OpsEntity
OpsEntity'
            (Maybe (HashMap Text OpsEntityItem) -> Maybe Text -> OpsEntity)
-> Parser (Maybe (HashMap Text OpsEntityItem))
-> Parser (Maybe Text -> OpsEntity)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object
-> Text -> Parser (Maybe (Maybe (HashMap Text OpsEntityItem)))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Data" Parser (Maybe (Maybe (HashMap Text OpsEntityItem)))
-> Maybe (HashMap Text OpsEntityItem)
-> Parser (Maybe (HashMap Text OpsEntityItem))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text OpsEntityItem)
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe Text -> OpsEntity)
-> Parser (Maybe Text) -> Parser OpsEntity
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
"Id")
      )

instance Prelude.Hashable OpsEntity

instance Prelude.NFData OpsEntity