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

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

-- | An object that represents the Cloud Map service discovery information
-- for your virtual node.
--
-- Cloud Map is not available in the eu-south-1 Region.
--
-- /See:/ 'newAwsCloudMapServiceDiscovery' smart constructor.
data AwsCloudMapServiceDiscovery = AwsCloudMapServiceDiscovery'
  { -- | A string map that contains attributes with values that you can use to
    -- filter instances by any custom attribute that you specified when you
    -- registered the instance. Only instances that match all of the specified
    -- key\/value pairs will be returned.
    AwsCloudMapServiceDiscovery -> Maybe [AwsCloudMapInstanceAttribute]
attributes :: Prelude.Maybe [AwsCloudMapInstanceAttribute],
    -- | The name of the Cloud Map namespace to use.
    AwsCloudMapServiceDiscovery -> Text
namespaceName :: Prelude.Text,
    -- | The name of the Cloud Map service to use.
    AwsCloudMapServiceDiscovery -> Text
serviceName :: Prelude.Text
  }
  deriving (AwsCloudMapServiceDiscovery -> AwsCloudMapServiceDiscovery -> Bool
(AwsCloudMapServiceDiscovery
 -> AwsCloudMapServiceDiscovery -> Bool)
-> (AwsCloudMapServiceDiscovery
    -> AwsCloudMapServiceDiscovery -> Bool)
-> Eq AwsCloudMapServiceDiscovery
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsCloudMapServiceDiscovery -> AwsCloudMapServiceDiscovery -> Bool
$c/= :: AwsCloudMapServiceDiscovery -> AwsCloudMapServiceDiscovery -> Bool
== :: AwsCloudMapServiceDiscovery -> AwsCloudMapServiceDiscovery -> Bool
$c== :: AwsCloudMapServiceDiscovery -> AwsCloudMapServiceDiscovery -> Bool
Prelude.Eq, ReadPrec [AwsCloudMapServiceDiscovery]
ReadPrec AwsCloudMapServiceDiscovery
Int -> ReadS AwsCloudMapServiceDiscovery
ReadS [AwsCloudMapServiceDiscovery]
(Int -> ReadS AwsCloudMapServiceDiscovery)
-> ReadS [AwsCloudMapServiceDiscovery]
-> ReadPrec AwsCloudMapServiceDiscovery
-> ReadPrec [AwsCloudMapServiceDiscovery]
-> Read AwsCloudMapServiceDiscovery
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsCloudMapServiceDiscovery]
$creadListPrec :: ReadPrec [AwsCloudMapServiceDiscovery]
readPrec :: ReadPrec AwsCloudMapServiceDiscovery
$creadPrec :: ReadPrec AwsCloudMapServiceDiscovery
readList :: ReadS [AwsCloudMapServiceDiscovery]
$creadList :: ReadS [AwsCloudMapServiceDiscovery]
readsPrec :: Int -> ReadS AwsCloudMapServiceDiscovery
$creadsPrec :: Int -> ReadS AwsCloudMapServiceDiscovery
Prelude.Read, Int -> AwsCloudMapServiceDiscovery -> ShowS
[AwsCloudMapServiceDiscovery] -> ShowS
AwsCloudMapServiceDiscovery -> String
(Int -> AwsCloudMapServiceDiscovery -> ShowS)
-> (AwsCloudMapServiceDiscovery -> String)
-> ([AwsCloudMapServiceDiscovery] -> ShowS)
-> Show AwsCloudMapServiceDiscovery
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsCloudMapServiceDiscovery] -> ShowS
$cshowList :: [AwsCloudMapServiceDiscovery] -> ShowS
show :: AwsCloudMapServiceDiscovery -> String
$cshow :: AwsCloudMapServiceDiscovery -> String
showsPrec :: Int -> AwsCloudMapServiceDiscovery -> ShowS
$cshowsPrec :: Int -> AwsCloudMapServiceDiscovery -> ShowS
Prelude.Show, (forall x.
 AwsCloudMapServiceDiscovery -> Rep AwsCloudMapServiceDiscovery x)
-> (forall x.
    Rep AwsCloudMapServiceDiscovery x -> AwsCloudMapServiceDiscovery)
-> Generic AwsCloudMapServiceDiscovery
forall x.
Rep AwsCloudMapServiceDiscovery x -> AwsCloudMapServiceDiscovery
forall x.
AwsCloudMapServiceDiscovery -> Rep AwsCloudMapServiceDiscovery x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AwsCloudMapServiceDiscovery x -> AwsCloudMapServiceDiscovery
$cfrom :: forall x.
AwsCloudMapServiceDiscovery -> Rep AwsCloudMapServiceDiscovery x
Prelude.Generic)

-- |
-- Create a value of 'AwsCloudMapServiceDiscovery' 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:
--
-- 'attributes', 'awsCloudMapServiceDiscovery_attributes' - A string map that contains attributes with values that you can use to
-- filter instances by any custom attribute that you specified when you
-- registered the instance. Only instances that match all of the specified
-- key\/value pairs will be returned.
--
-- 'namespaceName', 'awsCloudMapServiceDiscovery_namespaceName' - The name of the Cloud Map namespace to use.
--
-- 'serviceName', 'awsCloudMapServiceDiscovery_serviceName' - The name of the Cloud Map service to use.
newAwsCloudMapServiceDiscovery ::
  -- | 'namespaceName'
  Prelude.Text ->
  -- | 'serviceName'
  Prelude.Text ->
  AwsCloudMapServiceDiscovery
newAwsCloudMapServiceDiscovery :: Text -> Text -> AwsCloudMapServiceDiscovery
newAwsCloudMapServiceDiscovery
  Text
pNamespaceName_
  Text
pServiceName_ =
    AwsCloudMapServiceDiscovery' :: Maybe [AwsCloudMapInstanceAttribute]
-> Text -> Text -> AwsCloudMapServiceDiscovery
AwsCloudMapServiceDiscovery'
      { $sel:attributes:AwsCloudMapServiceDiscovery' :: Maybe [AwsCloudMapInstanceAttribute]
attributes =
          Maybe [AwsCloudMapInstanceAttribute]
forall a. Maybe a
Prelude.Nothing,
        $sel:namespaceName:AwsCloudMapServiceDiscovery' :: Text
namespaceName = Text
pNamespaceName_,
        $sel:serviceName:AwsCloudMapServiceDiscovery' :: Text
serviceName = Text
pServiceName_
      }

-- | A string map that contains attributes with values that you can use to
-- filter instances by any custom attribute that you specified when you
-- registered the instance. Only instances that match all of the specified
-- key\/value pairs will be returned.
awsCloudMapServiceDiscovery_attributes :: Lens.Lens' AwsCloudMapServiceDiscovery (Prelude.Maybe [AwsCloudMapInstanceAttribute])
awsCloudMapServiceDiscovery_attributes :: (Maybe [AwsCloudMapInstanceAttribute]
 -> f (Maybe [AwsCloudMapInstanceAttribute]))
-> AwsCloudMapServiceDiscovery -> f AwsCloudMapServiceDiscovery
awsCloudMapServiceDiscovery_attributes = (AwsCloudMapServiceDiscovery
 -> Maybe [AwsCloudMapInstanceAttribute])
-> (AwsCloudMapServiceDiscovery
    -> Maybe [AwsCloudMapInstanceAttribute]
    -> AwsCloudMapServiceDiscovery)
-> Lens
     AwsCloudMapServiceDiscovery
     AwsCloudMapServiceDiscovery
     (Maybe [AwsCloudMapInstanceAttribute])
     (Maybe [AwsCloudMapInstanceAttribute])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsCloudMapServiceDiscovery' {Maybe [AwsCloudMapInstanceAttribute]
attributes :: Maybe [AwsCloudMapInstanceAttribute]
$sel:attributes:AwsCloudMapServiceDiscovery' :: AwsCloudMapServiceDiscovery -> Maybe [AwsCloudMapInstanceAttribute]
attributes} -> Maybe [AwsCloudMapInstanceAttribute]
attributes) (\s :: AwsCloudMapServiceDiscovery
s@AwsCloudMapServiceDiscovery' {} Maybe [AwsCloudMapInstanceAttribute]
a -> AwsCloudMapServiceDiscovery
s {$sel:attributes:AwsCloudMapServiceDiscovery' :: Maybe [AwsCloudMapInstanceAttribute]
attributes = Maybe [AwsCloudMapInstanceAttribute]
a} :: AwsCloudMapServiceDiscovery) ((Maybe [AwsCloudMapInstanceAttribute]
  -> f (Maybe [AwsCloudMapInstanceAttribute]))
 -> AwsCloudMapServiceDiscovery -> f AwsCloudMapServiceDiscovery)
-> ((Maybe [AwsCloudMapInstanceAttribute]
     -> f (Maybe [AwsCloudMapInstanceAttribute]))
    -> Maybe [AwsCloudMapInstanceAttribute]
    -> f (Maybe [AwsCloudMapInstanceAttribute]))
-> (Maybe [AwsCloudMapInstanceAttribute]
    -> f (Maybe [AwsCloudMapInstanceAttribute]))
-> AwsCloudMapServiceDiscovery
-> f AwsCloudMapServiceDiscovery
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [AwsCloudMapInstanceAttribute]
  [AwsCloudMapInstanceAttribute]
  [AwsCloudMapInstanceAttribute]
  [AwsCloudMapInstanceAttribute]
-> Iso
     (Maybe [AwsCloudMapInstanceAttribute])
     (Maybe [AwsCloudMapInstanceAttribute])
     (Maybe [AwsCloudMapInstanceAttribute])
     (Maybe [AwsCloudMapInstanceAttribute])
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
  [AwsCloudMapInstanceAttribute]
  [AwsCloudMapInstanceAttribute]
  [AwsCloudMapInstanceAttribute]
  [AwsCloudMapInstanceAttribute]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of the Cloud Map namespace to use.
awsCloudMapServiceDiscovery_namespaceName :: Lens.Lens' AwsCloudMapServiceDiscovery Prelude.Text
awsCloudMapServiceDiscovery_namespaceName :: (Text -> f Text)
-> AwsCloudMapServiceDiscovery -> f AwsCloudMapServiceDiscovery
awsCloudMapServiceDiscovery_namespaceName = (AwsCloudMapServiceDiscovery -> Text)
-> (AwsCloudMapServiceDiscovery
    -> Text -> AwsCloudMapServiceDiscovery)
-> Lens
     AwsCloudMapServiceDiscovery AwsCloudMapServiceDiscovery Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsCloudMapServiceDiscovery' {Text
namespaceName :: Text
$sel:namespaceName:AwsCloudMapServiceDiscovery' :: AwsCloudMapServiceDiscovery -> Text
namespaceName} -> Text
namespaceName) (\s :: AwsCloudMapServiceDiscovery
s@AwsCloudMapServiceDiscovery' {} Text
a -> AwsCloudMapServiceDiscovery
s {$sel:namespaceName:AwsCloudMapServiceDiscovery' :: Text
namespaceName = Text
a} :: AwsCloudMapServiceDiscovery)

-- | The name of the Cloud Map service to use.
awsCloudMapServiceDiscovery_serviceName :: Lens.Lens' AwsCloudMapServiceDiscovery Prelude.Text
awsCloudMapServiceDiscovery_serviceName :: (Text -> f Text)
-> AwsCloudMapServiceDiscovery -> f AwsCloudMapServiceDiscovery
awsCloudMapServiceDiscovery_serviceName = (AwsCloudMapServiceDiscovery -> Text)
-> (AwsCloudMapServiceDiscovery
    -> Text -> AwsCloudMapServiceDiscovery)
-> Lens
     AwsCloudMapServiceDiscovery AwsCloudMapServiceDiscovery Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsCloudMapServiceDiscovery' {Text
serviceName :: Text
$sel:serviceName:AwsCloudMapServiceDiscovery' :: AwsCloudMapServiceDiscovery -> Text
serviceName} -> Text
serviceName) (\s :: AwsCloudMapServiceDiscovery
s@AwsCloudMapServiceDiscovery' {} Text
a -> AwsCloudMapServiceDiscovery
s {$sel:serviceName:AwsCloudMapServiceDiscovery' :: Text
serviceName = Text
a} :: AwsCloudMapServiceDiscovery)

instance Core.FromJSON AwsCloudMapServiceDiscovery where
  parseJSON :: Value -> Parser AwsCloudMapServiceDiscovery
parseJSON =
    String
-> (Object -> Parser AwsCloudMapServiceDiscovery)
-> Value
-> Parser AwsCloudMapServiceDiscovery
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AwsCloudMapServiceDiscovery"
      ( \Object
x ->
          Maybe [AwsCloudMapInstanceAttribute]
-> Text -> Text -> AwsCloudMapServiceDiscovery
AwsCloudMapServiceDiscovery'
            (Maybe [AwsCloudMapInstanceAttribute]
 -> Text -> Text -> AwsCloudMapServiceDiscovery)
-> Parser (Maybe [AwsCloudMapInstanceAttribute])
-> Parser (Text -> Text -> AwsCloudMapServiceDiscovery)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object
-> Text -> Parser (Maybe (Maybe [AwsCloudMapInstanceAttribute]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"attributes" Parser (Maybe (Maybe [AwsCloudMapInstanceAttribute]))
-> Maybe [AwsCloudMapInstanceAttribute]
-> Parser (Maybe [AwsCloudMapInstanceAttribute])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [AwsCloudMapInstanceAttribute]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Text -> Text -> AwsCloudMapServiceDiscovery)
-> Parser Text -> Parser (Text -> AwsCloudMapServiceDiscovery)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"namespaceName")
            Parser (Text -> AwsCloudMapServiceDiscovery)
-> Parser Text -> Parser AwsCloudMapServiceDiscovery
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"serviceName")
      )

instance Prelude.Hashable AwsCloudMapServiceDiscovery

instance Prelude.NFData AwsCloudMapServiceDiscovery

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