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

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

-- | An object that represents a virtual node service provider.
--
-- /See:/ 'newVirtualRouterServiceProvider' smart constructor.
data VirtualRouterServiceProvider = VirtualRouterServiceProvider'
  { -- | The name of the virtual router that is acting as a service provider.
    VirtualRouterServiceProvider -> Text
virtualRouterName :: Prelude.Text
  }
  deriving (VirtualRouterServiceProvider
-> VirtualRouterServiceProvider -> Bool
(VirtualRouterServiceProvider
 -> VirtualRouterServiceProvider -> Bool)
-> (VirtualRouterServiceProvider
    -> VirtualRouterServiceProvider -> Bool)
-> Eq VirtualRouterServiceProvider
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VirtualRouterServiceProvider
-> VirtualRouterServiceProvider -> Bool
$c/= :: VirtualRouterServiceProvider
-> VirtualRouterServiceProvider -> Bool
== :: VirtualRouterServiceProvider
-> VirtualRouterServiceProvider -> Bool
$c== :: VirtualRouterServiceProvider
-> VirtualRouterServiceProvider -> Bool
Prelude.Eq, ReadPrec [VirtualRouterServiceProvider]
ReadPrec VirtualRouterServiceProvider
Int -> ReadS VirtualRouterServiceProvider
ReadS [VirtualRouterServiceProvider]
(Int -> ReadS VirtualRouterServiceProvider)
-> ReadS [VirtualRouterServiceProvider]
-> ReadPrec VirtualRouterServiceProvider
-> ReadPrec [VirtualRouterServiceProvider]
-> Read VirtualRouterServiceProvider
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [VirtualRouterServiceProvider]
$creadListPrec :: ReadPrec [VirtualRouterServiceProvider]
readPrec :: ReadPrec VirtualRouterServiceProvider
$creadPrec :: ReadPrec VirtualRouterServiceProvider
readList :: ReadS [VirtualRouterServiceProvider]
$creadList :: ReadS [VirtualRouterServiceProvider]
readsPrec :: Int -> ReadS VirtualRouterServiceProvider
$creadsPrec :: Int -> ReadS VirtualRouterServiceProvider
Prelude.Read, Int -> VirtualRouterServiceProvider -> ShowS
[VirtualRouterServiceProvider] -> ShowS
VirtualRouterServiceProvider -> String
(Int -> VirtualRouterServiceProvider -> ShowS)
-> (VirtualRouterServiceProvider -> String)
-> ([VirtualRouterServiceProvider] -> ShowS)
-> Show VirtualRouterServiceProvider
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VirtualRouterServiceProvider] -> ShowS
$cshowList :: [VirtualRouterServiceProvider] -> ShowS
show :: VirtualRouterServiceProvider -> String
$cshow :: VirtualRouterServiceProvider -> String
showsPrec :: Int -> VirtualRouterServiceProvider -> ShowS
$cshowsPrec :: Int -> VirtualRouterServiceProvider -> ShowS
Prelude.Show, (forall x.
 VirtualRouterServiceProvider -> Rep VirtualRouterServiceProvider x)
-> (forall x.
    Rep VirtualRouterServiceProvider x -> VirtualRouterServiceProvider)
-> Generic VirtualRouterServiceProvider
forall x.
Rep VirtualRouterServiceProvider x -> VirtualRouterServiceProvider
forall x.
VirtualRouterServiceProvider -> Rep VirtualRouterServiceProvider x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep VirtualRouterServiceProvider x -> VirtualRouterServiceProvider
$cfrom :: forall x.
VirtualRouterServiceProvider -> Rep VirtualRouterServiceProvider x
Prelude.Generic)

-- |
-- Create a value of 'VirtualRouterServiceProvider' 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:
--
-- 'virtualRouterName', 'virtualRouterServiceProvider_virtualRouterName' - The name of the virtual router that is acting as a service provider.
newVirtualRouterServiceProvider ::
  -- | 'virtualRouterName'
  Prelude.Text ->
  VirtualRouterServiceProvider
newVirtualRouterServiceProvider :: Text -> VirtualRouterServiceProvider
newVirtualRouterServiceProvider Text
pVirtualRouterName_ =
  VirtualRouterServiceProvider' :: Text -> VirtualRouterServiceProvider
VirtualRouterServiceProvider'
    { $sel:virtualRouterName:VirtualRouterServiceProvider' :: Text
virtualRouterName =
        Text
pVirtualRouterName_
    }

-- | The name of the virtual router that is acting as a service provider.
virtualRouterServiceProvider_virtualRouterName :: Lens.Lens' VirtualRouterServiceProvider Prelude.Text
virtualRouterServiceProvider_virtualRouterName :: (Text -> f Text)
-> VirtualRouterServiceProvider -> f VirtualRouterServiceProvider
virtualRouterServiceProvider_virtualRouterName = (VirtualRouterServiceProvider -> Text)
-> (VirtualRouterServiceProvider
    -> Text -> VirtualRouterServiceProvider)
-> Lens
     VirtualRouterServiceProvider VirtualRouterServiceProvider Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VirtualRouterServiceProvider' {Text
virtualRouterName :: Text
$sel:virtualRouterName:VirtualRouterServiceProvider' :: VirtualRouterServiceProvider -> Text
virtualRouterName} -> Text
virtualRouterName) (\s :: VirtualRouterServiceProvider
s@VirtualRouterServiceProvider' {} Text
a -> VirtualRouterServiceProvider
s {$sel:virtualRouterName:VirtualRouterServiceProvider' :: Text
virtualRouterName = Text
a} :: VirtualRouterServiceProvider)

instance Core.FromJSON VirtualRouterServiceProvider where
  parseJSON :: Value -> Parser VirtualRouterServiceProvider
parseJSON =
    String
-> (Object -> Parser VirtualRouterServiceProvider)
-> Value
-> Parser VirtualRouterServiceProvider
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"VirtualRouterServiceProvider"
      ( \Object
x ->
          Text -> VirtualRouterServiceProvider
VirtualRouterServiceProvider'
            (Text -> VirtualRouterServiceProvider)
-> Parser Text -> Parser VirtualRouterServiceProvider
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
"virtualRouterName")
      )

instance
  Prelude.Hashable
    VirtualRouterServiceProvider

instance Prelude.NFData VirtualRouterServiceProvider

instance Core.ToJSON VirtualRouterServiceProvider where
  toJSON :: VirtualRouterServiceProvider -> Value
toJSON VirtualRouterServiceProvider' {Text
virtualRouterName :: Text
$sel:virtualRouterName:VirtualRouterServiceProvider' :: VirtualRouterServiceProvider -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"virtualRouterName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
virtualRouterName)
          ]
      )