{-# 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.Route53AutoNaming.Types.HttpInstanceSummary
-- 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.Route53AutoNaming.Types.HttpInstanceSummary where

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
import Amazonka.Route53AutoNaming.Types.HealthStatus

-- | In a response to a
-- <https://docs.aws.amazon.com/cloud-map/latest/api/API_DiscoverInstances.html DiscoverInstances>
-- request, @HttpInstanceSummary@ contains information about one instance
-- that matches the values that you specified in the request.
--
-- /See:/ 'newHttpInstanceSummary' smart constructor.
data HttpInstanceSummary = HttpInstanceSummary'
  { -- | If you included any attributes when you registered the instance, the
    -- values of those attributes.
    HttpInstanceSummary -> Maybe (HashMap Text Text)
attributes :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | If you configured health checking in the service, the current health
    -- status of the service instance.
    HttpInstanceSummary -> Maybe HealthStatus
healthStatus :: Prelude.Maybe HealthStatus,
    -- | The ID of an instance that matches the values that you specified in the
    -- request.
    HttpInstanceSummary -> Maybe Text
instanceId :: Prelude.Maybe Prelude.Text,
    -- | The @HttpName@ name of the namespace. It\'s found in the
    -- @HttpProperties@ member of the @Properties@ member of the namespace.
    HttpInstanceSummary -> Maybe Text
namespaceName :: Prelude.Maybe Prelude.Text,
    -- | The name of the service that you specified when you registered the
    -- instance.
    HttpInstanceSummary -> Maybe Text
serviceName :: Prelude.Maybe Prelude.Text
  }
  deriving (HttpInstanceSummary -> HttpInstanceSummary -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HttpInstanceSummary -> HttpInstanceSummary -> Bool
$c/= :: HttpInstanceSummary -> HttpInstanceSummary -> Bool
== :: HttpInstanceSummary -> HttpInstanceSummary -> Bool
$c== :: HttpInstanceSummary -> HttpInstanceSummary -> Bool
Prelude.Eq, ReadPrec [HttpInstanceSummary]
ReadPrec HttpInstanceSummary
Int -> ReadS HttpInstanceSummary
ReadS [HttpInstanceSummary]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HttpInstanceSummary]
$creadListPrec :: ReadPrec [HttpInstanceSummary]
readPrec :: ReadPrec HttpInstanceSummary
$creadPrec :: ReadPrec HttpInstanceSummary
readList :: ReadS [HttpInstanceSummary]
$creadList :: ReadS [HttpInstanceSummary]
readsPrec :: Int -> ReadS HttpInstanceSummary
$creadsPrec :: Int -> ReadS HttpInstanceSummary
Prelude.Read, Int -> HttpInstanceSummary -> ShowS
[HttpInstanceSummary] -> ShowS
HttpInstanceSummary -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HttpInstanceSummary] -> ShowS
$cshowList :: [HttpInstanceSummary] -> ShowS
show :: HttpInstanceSummary -> String
$cshow :: HttpInstanceSummary -> String
showsPrec :: Int -> HttpInstanceSummary -> ShowS
$cshowsPrec :: Int -> HttpInstanceSummary -> ShowS
Prelude.Show, forall x. Rep HttpInstanceSummary x -> HttpInstanceSummary
forall x. HttpInstanceSummary -> Rep HttpInstanceSummary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep HttpInstanceSummary x -> HttpInstanceSummary
$cfrom :: forall x. HttpInstanceSummary -> Rep HttpInstanceSummary x
Prelude.Generic)

-- |
-- Create a value of 'HttpInstanceSummary' 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', 'httpInstanceSummary_attributes' - If you included any attributes when you registered the instance, the
-- values of those attributes.
--
-- 'healthStatus', 'httpInstanceSummary_healthStatus' - If you configured health checking in the service, the current health
-- status of the service instance.
--
-- 'instanceId', 'httpInstanceSummary_instanceId' - The ID of an instance that matches the values that you specified in the
-- request.
--
-- 'namespaceName', 'httpInstanceSummary_namespaceName' - The @HttpName@ name of the namespace. It\'s found in the
-- @HttpProperties@ member of the @Properties@ member of the namespace.
--
-- 'serviceName', 'httpInstanceSummary_serviceName' - The name of the service that you specified when you registered the
-- instance.
newHttpInstanceSummary ::
  HttpInstanceSummary
newHttpInstanceSummary :: HttpInstanceSummary
newHttpInstanceSummary =
  HttpInstanceSummary'
    { $sel:attributes:HttpInstanceSummary' :: Maybe (HashMap Text Text)
attributes = forall a. Maybe a
Prelude.Nothing,
      $sel:healthStatus:HttpInstanceSummary' :: Maybe HealthStatus
healthStatus = forall a. Maybe a
Prelude.Nothing,
      $sel:instanceId:HttpInstanceSummary' :: Maybe Text
instanceId = forall a. Maybe a
Prelude.Nothing,
      $sel:namespaceName:HttpInstanceSummary' :: Maybe Text
namespaceName = forall a. Maybe a
Prelude.Nothing,
      $sel:serviceName:HttpInstanceSummary' :: Maybe Text
serviceName = forall a. Maybe a
Prelude.Nothing
    }

-- | If you included any attributes when you registered the instance, the
-- values of those attributes.
httpInstanceSummary_attributes :: Lens.Lens' HttpInstanceSummary (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
httpInstanceSummary_attributes :: Lens' HttpInstanceSummary (Maybe (HashMap Text Text))
httpInstanceSummary_attributes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HttpInstanceSummary' {Maybe (HashMap Text Text)
attributes :: Maybe (HashMap Text Text)
$sel:attributes:HttpInstanceSummary' :: HttpInstanceSummary -> Maybe (HashMap Text Text)
attributes} -> Maybe (HashMap Text Text)
attributes) (\s :: HttpInstanceSummary
s@HttpInstanceSummary' {} Maybe (HashMap Text Text)
a -> HttpInstanceSummary
s {$sel:attributes:HttpInstanceSummary' :: Maybe (HashMap Text Text)
attributes = Maybe (HashMap Text Text)
a} :: HttpInstanceSummary) 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

-- | If you configured health checking in the service, the current health
-- status of the service instance.
httpInstanceSummary_healthStatus :: Lens.Lens' HttpInstanceSummary (Prelude.Maybe HealthStatus)
httpInstanceSummary_healthStatus :: Lens' HttpInstanceSummary (Maybe HealthStatus)
httpInstanceSummary_healthStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HttpInstanceSummary' {Maybe HealthStatus
healthStatus :: Maybe HealthStatus
$sel:healthStatus:HttpInstanceSummary' :: HttpInstanceSummary -> Maybe HealthStatus
healthStatus} -> Maybe HealthStatus
healthStatus) (\s :: HttpInstanceSummary
s@HttpInstanceSummary' {} Maybe HealthStatus
a -> HttpInstanceSummary
s {$sel:healthStatus:HttpInstanceSummary' :: Maybe HealthStatus
healthStatus = Maybe HealthStatus
a} :: HttpInstanceSummary)

-- | The ID of an instance that matches the values that you specified in the
-- request.
httpInstanceSummary_instanceId :: Lens.Lens' HttpInstanceSummary (Prelude.Maybe Prelude.Text)
httpInstanceSummary_instanceId :: Lens' HttpInstanceSummary (Maybe Text)
httpInstanceSummary_instanceId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HttpInstanceSummary' {Maybe Text
instanceId :: Maybe Text
$sel:instanceId:HttpInstanceSummary' :: HttpInstanceSummary -> Maybe Text
instanceId} -> Maybe Text
instanceId) (\s :: HttpInstanceSummary
s@HttpInstanceSummary' {} Maybe Text
a -> HttpInstanceSummary
s {$sel:instanceId:HttpInstanceSummary' :: Maybe Text
instanceId = Maybe Text
a} :: HttpInstanceSummary)

-- | The @HttpName@ name of the namespace. It\'s found in the
-- @HttpProperties@ member of the @Properties@ member of the namespace.
httpInstanceSummary_namespaceName :: Lens.Lens' HttpInstanceSummary (Prelude.Maybe Prelude.Text)
httpInstanceSummary_namespaceName :: Lens' HttpInstanceSummary (Maybe Text)
httpInstanceSummary_namespaceName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HttpInstanceSummary' {Maybe Text
namespaceName :: Maybe Text
$sel:namespaceName:HttpInstanceSummary' :: HttpInstanceSummary -> Maybe Text
namespaceName} -> Maybe Text
namespaceName) (\s :: HttpInstanceSummary
s@HttpInstanceSummary' {} Maybe Text
a -> HttpInstanceSummary
s {$sel:namespaceName:HttpInstanceSummary' :: Maybe Text
namespaceName = Maybe Text
a} :: HttpInstanceSummary)

-- | The name of the service that you specified when you registered the
-- instance.
httpInstanceSummary_serviceName :: Lens.Lens' HttpInstanceSummary (Prelude.Maybe Prelude.Text)
httpInstanceSummary_serviceName :: Lens' HttpInstanceSummary (Maybe Text)
httpInstanceSummary_serviceName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HttpInstanceSummary' {Maybe Text
serviceName :: Maybe Text
$sel:serviceName:HttpInstanceSummary' :: HttpInstanceSummary -> Maybe Text
serviceName} -> Maybe Text
serviceName) (\s :: HttpInstanceSummary
s@HttpInstanceSummary' {} Maybe Text
a -> HttpInstanceSummary
s {$sel:serviceName:HttpInstanceSummary' :: Maybe Text
serviceName = Maybe Text
a} :: HttpInstanceSummary)

instance Data.FromJSON HttpInstanceSummary where
  parseJSON :: Value -> Parser HttpInstanceSummary
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"HttpInstanceSummary"
      ( \Object
x ->
          Maybe (HashMap Text Text)
-> Maybe HealthStatus
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> HttpInstanceSummary
HttpInstanceSummary'
            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
"HealthStatus")
            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
"InstanceId")
            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
"NamespaceName")
            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
"ServiceName")
      )

instance Prelude.Hashable HttpInstanceSummary where
  hashWithSalt :: Int -> HttpInstanceSummary -> Int
hashWithSalt Int
_salt HttpInstanceSummary' {Maybe Text
Maybe (HashMap Text Text)
Maybe HealthStatus
serviceName :: Maybe Text
namespaceName :: Maybe Text
instanceId :: Maybe Text
healthStatus :: Maybe HealthStatus
attributes :: Maybe (HashMap Text Text)
$sel:serviceName:HttpInstanceSummary' :: HttpInstanceSummary -> Maybe Text
$sel:namespaceName:HttpInstanceSummary' :: HttpInstanceSummary -> Maybe Text
$sel:instanceId:HttpInstanceSummary' :: HttpInstanceSummary -> Maybe Text
$sel:healthStatus:HttpInstanceSummary' :: HttpInstanceSummary -> Maybe HealthStatus
$sel:attributes:HttpInstanceSummary' :: HttpInstanceSummary -> Maybe (HashMap Text Text)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
attributes
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe HealthStatus
healthStatus
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
instanceId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
namespaceName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
serviceName

instance Prelude.NFData HttpInstanceSummary where
  rnf :: HttpInstanceSummary -> ()
rnf HttpInstanceSummary' {Maybe Text
Maybe (HashMap Text Text)
Maybe HealthStatus
serviceName :: Maybe Text
namespaceName :: Maybe Text
instanceId :: Maybe Text
healthStatus :: Maybe HealthStatus
attributes :: Maybe (HashMap Text Text)
$sel:serviceName:HttpInstanceSummary' :: HttpInstanceSummary -> Maybe Text
$sel:namespaceName:HttpInstanceSummary' :: HttpInstanceSummary -> Maybe Text
$sel:instanceId:HttpInstanceSummary' :: HttpInstanceSummary -> Maybe Text
$sel:healthStatus:HttpInstanceSummary' :: HttpInstanceSummary -> Maybe HealthStatus
$sel:attributes:HttpInstanceSummary' :: HttpInstanceSummary -> Maybe (HashMap Text Text)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
attributes
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe HealthStatus
healthStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
instanceId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
namespaceName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
serviceName