{-# 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.AppMesh.Types.MeshData
-- 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.AppMesh.Types.MeshData where

import Amazonka.AppMesh.Types.MeshSpec
import Amazonka.AppMesh.Types.MeshStatus
import Amazonka.AppMesh.Types.ResourceMetadata
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | An object that represents a service mesh returned by a describe
-- operation.
--
-- /See:/ 'newMeshData' smart constructor.
data MeshData = MeshData'
  { -- | The name of the service mesh.
    MeshData -> Text
meshName :: Prelude.Text,
    -- | The associated metadata for the service mesh.
    MeshData -> ResourceMetadata
metadata :: ResourceMetadata,
    -- | The associated specification for the service mesh.
    MeshData -> MeshSpec
spec :: MeshSpec,
    -- | The status of the service mesh.
    MeshData -> MeshStatus
status :: MeshStatus
  }
  deriving (MeshData -> MeshData -> Bool
(MeshData -> MeshData -> Bool)
-> (MeshData -> MeshData -> Bool) -> Eq MeshData
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MeshData -> MeshData -> Bool
$c/= :: MeshData -> MeshData -> Bool
== :: MeshData -> MeshData -> Bool
$c== :: MeshData -> MeshData -> Bool
Prelude.Eq, ReadPrec [MeshData]
ReadPrec MeshData
Int -> ReadS MeshData
ReadS [MeshData]
(Int -> ReadS MeshData)
-> ReadS [MeshData]
-> ReadPrec MeshData
-> ReadPrec [MeshData]
-> Read MeshData
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MeshData]
$creadListPrec :: ReadPrec [MeshData]
readPrec :: ReadPrec MeshData
$creadPrec :: ReadPrec MeshData
readList :: ReadS [MeshData]
$creadList :: ReadS [MeshData]
readsPrec :: Int -> ReadS MeshData
$creadsPrec :: Int -> ReadS MeshData
Prelude.Read, Int -> MeshData -> ShowS
[MeshData] -> ShowS
MeshData -> String
(Int -> MeshData -> ShowS)
-> (MeshData -> String) -> ([MeshData] -> ShowS) -> Show MeshData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MeshData] -> ShowS
$cshowList :: [MeshData] -> ShowS
show :: MeshData -> String
$cshow :: MeshData -> String
showsPrec :: Int -> MeshData -> ShowS
$cshowsPrec :: Int -> MeshData -> ShowS
Prelude.Show, (forall x. MeshData -> Rep MeshData x)
-> (forall x. Rep MeshData x -> MeshData) -> Generic MeshData
forall x. Rep MeshData x -> MeshData
forall x. MeshData -> Rep MeshData x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MeshData x -> MeshData
$cfrom :: forall x. MeshData -> Rep MeshData x
Prelude.Generic)

-- |
-- Create a value of 'MeshData' 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:
--
-- 'meshName', 'meshData_meshName' - The name of the service mesh.
--
-- 'metadata', 'meshData_metadata' - The associated metadata for the service mesh.
--
-- 'spec', 'meshData_spec' - The associated specification for the service mesh.
--
-- 'status', 'meshData_status' - The status of the service mesh.
newMeshData ::
  -- | 'meshName'
  Prelude.Text ->
  -- | 'metadata'
  ResourceMetadata ->
  -- | 'spec'
  MeshSpec ->
  -- | 'status'
  MeshStatus ->
  MeshData
newMeshData :: Text -> ResourceMetadata -> MeshSpec -> MeshStatus -> MeshData
newMeshData Text
pMeshName_ ResourceMetadata
pMetadata_ MeshSpec
pSpec_ MeshStatus
pStatus_ =
  MeshData' :: Text -> ResourceMetadata -> MeshSpec -> MeshStatus -> MeshData
MeshData'
    { $sel:meshName:MeshData' :: Text
meshName = Text
pMeshName_,
      $sel:metadata:MeshData' :: ResourceMetadata
metadata = ResourceMetadata
pMetadata_,
      $sel:spec:MeshData' :: MeshSpec
spec = MeshSpec
pSpec_,
      $sel:status:MeshData' :: MeshStatus
status = MeshStatus
pStatus_
    }

-- | The name of the service mesh.
meshData_meshName :: Lens.Lens' MeshData Prelude.Text
meshData_meshName :: (Text -> f Text) -> MeshData -> f MeshData
meshData_meshName = (MeshData -> Text)
-> (MeshData -> Text -> MeshData)
-> Lens MeshData MeshData Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MeshData' {Text
meshName :: Text
$sel:meshName:MeshData' :: MeshData -> Text
meshName} -> Text
meshName) (\s :: MeshData
s@MeshData' {} Text
a -> MeshData
s {$sel:meshName:MeshData' :: Text
meshName = Text
a} :: MeshData)

-- | The associated metadata for the service mesh.
meshData_metadata :: Lens.Lens' MeshData ResourceMetadata
meshData_metadata :: (ResourceMetadata -> f ResourceMetadata) -> MeshData -> f MeshData
meshData_metadata = (MeshData -> ResourceMetadata)
-> (MeshData -> ResourceMetadata -> MeshData)
-> Lens MeshData MeshData ResourceMetadata ResourceMetadata
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MeshData' {ResourceMetadata
metadata :: ResourceMetadata
$sel:metadata:MeshData' :: MeshData -> ResourceMetadata
metadata} -> ResourceMetadata
metadata) (\s :: MeshData
s@MeshData' {} ResourceMetadata
a -> MeshData
s {$sel:metadata:MeshData' :: ResourceMetadata
metadata = ResourceMetadata
a} :: MeshData)

-- | The associated specification for the service mesh.
meshData_spec :: Lens.Lens' MeshData MeshSpec
meshData_spec :: (MeshSpec -> f MeshSpec) -> MeshData -> f MeshData
meshData_spec = (MeshData -> MeshSpec)
-> (MeshData -> MeshSpec -> MeshData)
-> Lens MeshData MeshData MeshSpec MeshSpec
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MeshData' {MeshSpec
spec :: MeshSpec
$sel:spec:MeshData' :: MeshData -> MeshSpec
spec} -> MeshSpec
spec) (\s :: MeshData
s@MeshData' {} MeshSpec
a -> MeshData
s {$sel:spec:MeshData' :: MeshSpec
spec = MeshSpec
a} :: MeshData)

-- | The status of the service mesh.
meshData_status :: Lens.Lens' MeshData MeshStatus
meshData_status :: (MeshStatus -> f MeshStatus) -> MeshData -> f MeshData
meshData_status = (MeshData -> MeshStatus)
-> (MeshData -> MeshStatus -> MeshData)
-> Lens MeshData MeshData MeshStatus MeshStatus
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MeshData' {MeshStatus
status :: MeshStatus
$sel:status:MeshData' :: MeshData -> MeshStatus
status} -> MeshStatus
status) (\s :: MeshData
s@MeshData' {} MeshStatus
a -> MeshData
s {$sel:status:MeshData' :: MeshStatus
status = MeshStatus
a} :: MeshData)

instance Core.FromJSON MeshData where
  parseJSON :: Value -> Parser MeshData
parseJSON =
    String -> (Object -> Parser MeshData) -> Value -> Parser MeshData
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"MeshData"
      ( \Object
x ->
          Text -> ResourceMetadata -> MeshSpec -> MeshStatus -> MeshData
MeshData'
            (Text -> ResourceMetadata -> MeshSpec -> MeshStatus -> MeshData)
-> Parser Text
-> Parser (ResourceMetadata -> MeshSpec -> MeshStatus -> MeshData)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"meshName")
            Parser (ResourceMetadata -> MeshSpec -> MeshStatus -> MeshData)
-> Parser ResourceMetadata
-> Parser (MeshSpec -> MeshStatus -> MeshData)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser ResourceMetadata
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"metadata")
            Parser (MeshSpec -> MeshStatus -> MeshData)
-> Parser MeshSpec -> Parser (MeshStatus -> MeshData)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser MeshSpec
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"spec")
            Parser (MeshStatus -> MeshData)
-> Parser MeshStatus -> Parser MeshData
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser MeshStatus
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"status")
      )

instance Prelude.Hashable MeshData

instance Prelude.NFData MeshData