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

import Amazonka.AppMesh.Types.VirtualServiceProvider
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | An object that represents the specification of a virtual service.
--
-- /See:/ 'newVirtualServiceSpec' smart constructor.
data VirtualServiceSpec = VirtualServiceSpec'
  { -- | The App Mesh object that is acting as the provider for a virtual
    -- service. You can specify a single virtual node or virtual router.
    VirtualServiceSpec -> Maybe VirtualServiceProvider
provider :: Prelude.Maybe VirtualServiceProvider
  }
  deriving (VirtualServiceSpec -> VirtualServiceSpec -> Bool
(VirtualServiceSpec -> VirtualServiceSpec -> Bool)
-> (VirtualServiceSpec -> VirtualServiceSpec -> Bool)
-> Eq VirtualServiceSpec
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VirtualServiceSpec -> VirtualServiceSpec -> Bool
$c/= :: VirtualServiceSpec -> VirtualServiceSpec -> Bool
== :: VirtualServiceSpec -> VirtualServiceSpec -> Bool
$c== :: VirtualServiceSpec -> VirtualServiceSpec -> Bool
Prelude.Eq, ReadPrec [VirtualServiceSpec]
ReadPrec VirtualServiceSpec
Int -> ReadS VirtualServiceSpec
ReadS [VirtualServiceSpec]
(Int -> ReadS VirtualServiceSpec)
-> ReadS [VirtualServiceSpec]
-> ReadPrec VirtualServiceSpec
-> ReadPrec [VirtualServiceSpec]
-> Read VirtualServiceSpec
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [VirtualServiceSpec]
$creadListPrec :: ReadPrec [VirtualServiceSpec]
readPrec :: ReadPrec VirtualServiceSpec
$creadPrec :: ReadPrec VirtualServiceSpec
readList :: ReadS [VirtualServiceSpec]
$creadList :: ReadS [VirtualServiceSpec]
readsPrec :: Int -> ReadS VirtualServiceSpec
$creadsPrec :: Int -> ReadS VirtualServiceSpec
Prelude.Read, Int -> VirtualServiceSpec -> ShowS
[VirtualServiceSpec] -> ShowS
VirtualServiceSpec -> String
(Int -> VirtualServiceSpec -> ShowS)
-> (VirtualServiceSpec -> String)
-> ([VirtualServiceSpec] -> ShowS)
-> Show VirtualServiceSpec
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VirtualServiceSpec] -> ShowS
$cshowList :: [VirtualServiceSpec] -> ShowS
show :: VirtualServiceSpec -> String
$cshow :: VirtualServiceSpec -> String
showsPrec :: Int -> VirtualServiceSpec -> ShowS
$cshowsPrec :: Int -> VirtualServiceSpec -> ShowS
Prelude.Show, (forall x. VirtualServiceSpec -> Rep VirtualServiceSpec x)
-> (forall x. Rep VirtualServiceSpec x -> VirtualServiceSpec)
-> Generic VirtualServiceSpec
forall x. Rep VirtualServiceSpec x -> VirtualServiceSpec
forall x. VirtualServiceSpec -> Rep VirtualServiceSpec x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep VirtualServiceSpec x -> VirtualServiceSpec
$cfrom :: forall x. VirtualServiceSpec -> Rep VirtualServiceSpec x
Prelude.Generic)

-- |
-- Create a value of 'VirtualServiceSpec' 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:
--
-- 'provider', 'virtualServiceSpec_provider' - The App Mesh object that is acting as the provider for a virtual
-- service. You can specify a single virtual node or virtual router.
newVirtualServiceSpec ::
  VirtualServiceSpec
newVirtualServiceSpec :: VirtualServiceSpec
newVirtualServiceSpec =
  VirtualServiceSpec' :: Maybe VirtualServiceProvider -> VirtualServiceSpec
VirtualServiceSpec' {$sel:provider:VirtualServiceSpec' :: Maybe VirtualServiceProvider
provider = Maybe VirtualServiceProvider
forall a. Maybe a
Prelude.Nothing}

-- | The App Mesh object that is acting as the provider for a virtual
-- service. You can specify a single virtual node or virtual router.
virtualServiceSpec_provider :: Lens.Lens' VirtualServiceSpec (Prelude.Maybe VirtualServiceProvider)
virtualServiceSpec_provider :: (Maybe VirtualServiceProvider -> f (Maybe VirtualServiceProvider))
-> VirtualServiceSpec -> f VirtualServiceSpec
virtualServiceSpec_provider = (VirtualServiceSpec -> Maybe VirtualServiceProvider)
-> (VirtualServiceSpec
    -> Maybe VirtualServiceProvider -> VirtualServiceSpec)
-> Lens
     VirtualServiceSpec
     VirtualServiceSpec
     (Maybe VirtualServiceProvider)
     (Maybe VirtualServiceProvider)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VirtualServiceSpec' {Maybe VirtualServiceProvider
provider :: Maybe VirtualServiceProvider
$sel:provider:VirtualServiceSpec' :: VirtualServiceSpec -> Maybe VirtualServiceProvider
provider} -> Maybe VirtualServiceProvider
provider) (\s :: VirtualServiceSpec
s@VirtualServiceSpec' {} Maybe VirtualServiceProvider
a -> VirtualServiceSpec
s {$sel:provider:VirtualServiceSpec' :: Maybe VirtualServiceProvider
provider = Maybe VirtualServiceProvider
a} :: VirtualServiceSpec)

instance Core.FromJSON VirtualServiceSpec where
  parseJSON :: Value -> Parser VirtualServiceSpec
parseJSON =
    String
-> (Object -> Parser VirtualServiceSpec)
-> Value
-> Parser VirtualServiceSpec
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"VirtualServiceSpec"
      ( \Object
x ->
          Maybe VirtualServiceProvider -> VirtualServiceSpec
VirtualServiceSpec'
            (Maybe VirtualServiceProvider -> VirtualServiceSpec)
-> Parser (Maybe VirtualServiceProvider)
-> Parser VirtualServiceSpec
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe VirtualServiceProvider)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"provider")
      )

instance Prelude.Hashable VirtualServiceSpec

instance Prelude.NFData VirtualServiceSpec

instance Core.ToJSON VirtualServiceSpec where
  toJSON :: VirtualServiceSpec -> Value
toJSON VirtualServiceSpec' {Maybe VirtualServiceProvider
provider :: Maybe VirtualServiceProvider
$sel:provider:VirtualServiceSpec' :: VirtualServiceSpec -> Maybe VirtualServiceProvider
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Text
"provider" Text -> VirtualServiceProvider -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (VirtualServiceProvider -> Pair)
-> Maybe VirtualServiceProvider -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe VirtualServiceProvider
provider]
      )