{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.AppMesh.Types.AwsCloudMapServiceDiscovery where

import Amazonka.AppMesh.Types.AwsCloudMapInstanceAttribute
import Amazonka.AppMesh.Types.IpPreference
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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 preferred IP version that this virtual node uses. Setting the IP
    -- preference on the virtual node only overrides the IP preference set for
    -- the mesh on this specific node.
    AwsCloudMapServiceDiscovery -> Maybe IpPreference
ipPreference :: Prelude.Maybe IpPreference,
    -- | 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
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]
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
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.
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.
--
-- 'ipPreference', 'awsCloudMapServiceDiscovery_ipPreference' - The preferred IP version that this virtual node uses. Setting the IP
-- preference on the virtual node only overrides the IP preference set for
-- the mesh on this specific node.
--
-- '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'
      { $sel:attributes:AwsCloudMapServiceDiscovery' :: Maybe [AwsCloudMapInstanceAttribute]
attributes =
          forall a. Maybe a
Prelude.Nothing,
        $sel:ipPreference:AwsCloudMapServiceDiscovery' :: Maybe IpPreference
ipPreference = 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 :: Lens'
  AwsCloudMapServiceDiscovery (Maybe [AwsCloudMapInstanceAttribute])
awsCloudMapServiceDiscovery_attributes = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The preferred IP version that this virtual node uses. Setting the IP
-- preference on the virtual node only overrides the IP preference set for
-- the mesh on this specific node.
awsCloudMapServiceDiscovery_ipPreference :: Lens.Lens' AwsCloudMapServiceDiscovery (Prelude.Maybe IpPreference)
awsCloudMapServiceDiscovery_ipPreference :: Lens' AwsCloudMapServiceDiscovery (Maybe IpPreference)
awsCloudMapServiceDiscovery_ipPreference = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsCloudMapServiceDiscovery' {Maybe IpPreference
ipPreference :: Maybe IpPreference
$sel:ipPreference:AwsCloudMapServiceDiscovery' :: AwsCloudMapServiceDiscovery -> Maybe IpPreference
ipPreference} -> Maybe IpPreference
ipPreference) (\s :: AwsCloudMapServiceDiscovery
s@AwsCloudMapServiceDiscovery' {} Maybe IpPreference
a -> AwsCloudMapServiceDiscovery
s {$sel:ipPreference:AwsCloudMapServiceDiscovery' :: Maybe IpPreference
ipPreference = Maybe IpPreference
a} :: AwsCloudMapServiceDiscovery)

-- | The name of the Cloud Map namespace to use.
awsCloudMapServiceDiscovery_namespaceName :: Lens.Lens' AwsCloudMapServiceDiscovery Prelude.Text
awsCloudMapServiceDiscovery_namespaceName :: Lens' AwsCloudMapServiceDiscovery Text
awsCloudMapServiceDiscovery_namespaceName = 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 :: Lens' AwsCloudMapServiceDiscovery Text
awsCloudMapServiceDiscovery_serviceName = 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 Data.FromJSON AwsCloudMapServiceDiscovery where
  parseJSON :: Value -> Parser AwsCloudMapServiceDiscovery
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AwsCloudMapServiceDiscovery"
      ( \Object
x ->
          Maybe [AwsCloudMapInstanceAttribute]
-> Maybe IpPreference
-> Text
-> Text
-> AwsCloudMapServiceDiscovery
AwsCloudMapServiceDiscovery'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"attributes" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ipPreference")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"namespaceName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"serviceName")
      )

instance Prelude.Hashable AwsCloudMapServiceDiscovery where
  hashWithSalt :: Int -> AwsCloudMapServiceDiscovery -> Int
hashWithSalt Int
_salt AwsCloudMapServiceDiscovery' {Maybe [AwsCloudMapInstanceAttribute]
Maybe IpPreference
Text
serviceName :: Text
namespaceName :: Text
ipPreference :: Maybe IpPreference
attributes :: Maybe [AwsCloudMapInstanceAttribute]
$sel:serviceName:AwsCloudMapServiceDiscovery' :: AwsCloudMapServiceDiscovery -> Text
$sel:namespaceName:AwsCloudMapServiceDiscovery' :: AwsCloudMapServiceDiscovery -> Text
$sel:ipPreference:AwsCloudMapServiceDiscovery' :: AwsCloudMapServiceDiscovery -> Maybe IpPreference
$sel:attributes:AwsCloudMapServiceDiscovery' :: AwsCloudMapServiceDiscovery -> Maybe [AwsCloudMapInstanceAttribute]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [AwsCloudMapInstanceAttribute]
attributes
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe IpPreference
ipPreference
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
namespaceName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
serviceName

instance Prelude.NFData AwsCloudMapServiceDiscovery where
  rnf :: AwsCloudMapServiceDiscovery -> ()
rnf AwsCloudMapServiceDiscovery' {Maybe [AwsCloudMapInstanceAttribute]
Maybe IpPreference
Text
serviceName :: Text
namespaceName :: Text
ipPreference :: Maybe IpPreference
attributes :: Maybe [AwsCloudMapInstanceAttribute]
$sel:serviceName:AwsCloudMapServiceDiscovery' :: AwsCloudMapServiceDiscovery -> Text
$sel:namespaceName:AwsCloudMapServiceDiscovery' :: AwsCloudMapServiceDiscovery -> Text
$sel:ipPreference:AwsCloudMapServiceDiscovery' :: AwsCloudMapServiceDiscovery -> Maybe IpPreference
$sel:attributes:AwsCloudMapServiceDiscovery' :: AwsCloudMapServiceDiscovery -> Maybe [AwsCloudMapInstanceAttribute]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [AwsCloudMapInstanceAttribute]
attributes
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe IpPreference
ipPreference
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
namespaceName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
serviceName

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