{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.DiscoverInstances
-- 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)
--
-- Discovers registered instances for a specified namespace and service.
-- You can use @DiscoverInstances@ to discover instances for any type of
-- namespace. For public and private DNS namespaces, you can also use DNS
-- queries to discover instances.
module Amazonka.Route53AutoNaming.DiscoverInstances
  ( -- * Creating a Request
    DiscoverInstances (..),
    newDiscoverInstances,

    -- * Request Lenses
    discoverInstances_queryParameters,
    discoverInstances_optionalParameters,
    discoverInstances_healthStatus,
    discoverInstances_maxResults,
    discoverInstances_namespaceName,
    discoverInstances_serviceName,

    -- * Destructuring the Response
    DiscoverInstancesResponse (..),
    newDiscoverInstancesResponse,

    -- * Response Lenses
    discoverInstancesResponse_instances,
    discoverInstancesResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.Route53AutoNaming.Types

-- | /See:/ 'newDiscoverInstances' smart constructor.
data DiscoverInstances = DiscoverInstances'
  { -- | Filters to scope the results based on custom attributes for the instance
    -- (for example, @{version=v1, az=1a}@). Only instances that match all the
    -- specified key-value pairs are returned.
    DiscoverInstances -> Maybe (HashMap Text Text)
queryParameters :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | Opportunistic filters to scope the results based on custom attributes.
    -- If there are instances that match both the filters specified in both the
    -- @QueryParameters@ parameter and this parameter, all of these instances
    -- are returned. Otherwise, the filters are ignored, and only instances
    -- that match the filters that are specified in the @QueryParameters@
    -- parameter are returned.
    DiscoverInstances -> Maybe (HashMap Text Text)
optionalParameters :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The health status of the instances that you want to discover. This
    -- parameter is ignored for services that don\'t have a health check
    -- configured, and all instances are returned.
    --
    -- [HEALTHY]
    --     Returns healthy instances.
    --
    -- [UNHEALTHY]
    --     Returns unhealthy instances.
    --
    -- [ALL]
    --     Returns all instances.
    --
    -- [HEALTHY_OR_ELSE_ALL]
    --     Returns healthy instances, unless none are reporting a healthy
    --     state. In that case, return all instances. This is also called
    --     failing open.
    DiscoverInstances -> Maybe HealthStatusFilter
healthStatus :: Prelude.Maybe HealthStatusFilter,
    -- | The maximum number of instances that you want Cloud Map to return in the
    -- response to a @DiscoverInstances@ request. If you don\'t specify a value
    -- for @MaxResults@, Cloud Map returns up to 100 instances.
    DiscoverInstances -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The @HttpName@ name of the namespace. It\'s found in the
    -- @HttpProperties@ member of the @Properties@ member of the namespace.
    DiscoverInstances -> Text
namespaceName :: Prelude.Text,
    -- | The name of the service that you specified when you registered the
    -- instance.
    DiscoverInstances -> Text
serviceName :: Prelude.Text
  }
  deriving (DiscoverInstances -> DiscoverInstances -> Bool
(DiscoverInstances -> DiscoverInstances -> Bool)
-> (DiscoverInstances -> DiscoverInstances -> Bool)
-> Eq DiscoverInstances
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DiscoverInstances -> DiscoverInstances -> Bool
$c/= :: DiscoverInstances -> DiscoverInstances -> Bool
== :: DiscoverInstances -> DiscoverInstances -> Bool
$c== :: DiscoverInstances -> DiscoverInstances -> Bool
Prelude.Eq, ReadPrec [DiscoverInstances]
ReadPrec DiscoverInstances
Int -> ReadS DiscoverInstances
ReadS [DiscoverInstances]
(Int -> ReadS DiscoverInstances)
-> ReadS [DiscoverInstances]
-> ReadPrec DiscoverInstances
-> ReadPrec [DiscoverInstances]
-> Read DiscoverInstances
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DiscoverInstances]
$creadListPrec :: ReadPrec [DiscoverInstances]
readPrec :: ReadPrec DiscoverInstances
$creadPrec :: ReadPrec DiscoverInstances
readList :: ReadS [DiscoverInstances]
$creadList :: ReadS [DiscoverInstances]
readsPrec :: Int -> ReadS DiscoverInstances
$creadsPrec :: Int -> ReadS DiscoverInstances
Prelude.Read, Int -> DiscoverInstances -> ShowS
[DiscoverInstances] -> ShowS
DiscoverInstances -> String
(Int -> DiscoverInstances -> ShowS)
-> (DiscoverInstances -> String)
-> ([DiscoverInstances] -> ShowS)
-> Show DiscoverInstances
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DiscoverInstances] -> ShowS
$cshowList :: [DiscoverInstances] -> ShowS
show :: DiscoverInstances -> String
$cshow :: DiscoverInstances -> String
showsPrec :: Int -> DiscoverInstances -> ShowS
$cshowsPrec :: Int -> DiscoverInstances -> ShowS
Prelude.Show, (forall x. DiscoverInstances -> Rep DiscoverInstances x)
-> (forall x. Rep DiscoverInstances x -> DiscoverInstances)
-> Generic DiscoverInstances
forall x. Rep DiscoverInstances x -> DiscoverInstances
forall x. DiscoverInstances -> Rep DiscoverInstances x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DiscoverInstances x -> DiscoverInstances
$cfrom :: forall x. DiscoverInstances -> Rep DiscoverInstances x
Prelude.Generic)

-- |
-- Create a value of 'DiscoverInstances' 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:
--
-- 'queryParameters', 'discoverInstances_queryParameters' - Filters to scope the results based on custom attributes for the instance
-- (for example, @{version=v1, az=1a}@). Only instances that match all the
-- specified key-value pairs are returned.
--
-- 'optionalParameters', 'discoverInstances_optionalParameters' - Opportunistic filters to scope the results based on custom attributes.
-- If there are instances that match both the filters specified in both the
-- @QueryParameters@ parameter and this parameter, all of these instances
-- are returned. Otherwise, the filters are ignored, and only instances
-- that match the filters that are specified in the @QueryParameters@
-- parameter are returned.
--
-- 'healthStatus', 'discoverInstances_healthStatus' - The health status of the instances that you want to discover. This
-- parameter is ignored for services that don\'t have a health check
-- configured, and all instances are returned.
--
-- [HEALTHY]
--     Returns healthy instances.
--
-- [UNHEALTHY]
--     Returns unhealthy instances.
--
-- [ALL]
--     Returns all instances.
--
-- [HEALTHY_OR_ELSE_ALL]
--     Returns healthy instances, unless none are reporting a healthy
--     state. In that case, return all instances. This is also called
--     failing open.
--
-- 'maxResults', 'discoverInstances_maxResults' - The maximum number of instances that you want Cloud Map to return in the
-- response to a @DiscoverInstances@ request. If you don\'t specify a value
-- for @MaxResults@, Cloud Map returns up to 100 instances.
--
-- 'namespaceName', 'discoverInstances_namespaceName' - The @HttpName@ name of the namespace. It\'s found in the
-- @HttpProperties@ member of the @Properties@ member of the namespace.
--
-- 'serviceName', 'discoverInstances_serviceName' - The name of the service that you specified when you registered the
-- instance.
newDiscoverInstances ::
  -- | 'namespaceName'
  Prelude.Text ->
  -- | 'serviceName'
  Prelude.Text ->
  DiscoverInstances
newDiscoverInstances :: Text -> Text -> DiscoverInstances
newDiscoverInstances Text
pNamespaceName_ Text
pServiceName_ =
  DiscoverInstances' :: Maybe (HashMap Text Text)
-> Maybe (HashMap Text Text)
-> Maybe HealthStatusFilter
-> Maybe Natural
-> Text
-> Text
-> DiscoverInstances
DiscoverInstances'
    { $sel:queryParameters:DiscoverInstances' :: Maybe (HashMap Text Text)
queryParameters =
        Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:optionalParameters:DiscoverInstances' :: Maybe (HashMap Text Text)
optionalParameters = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:healthStatus:DiscoverInstances' :: Maybe HealthStatusFilter
healthStatus = Maybe HealthStatusFilter
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:DiscoverInstances' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:namespaceName:DiscoverInstances' :: Text
namespaceName = Text
pNamespaceName_,
      $sel:serviceName:DiscoverInstances' :: Text
serviceName = Text
pServiceName_
    }

-- | Filters to scope the results based on custom attributes for the instance
-- (for example, @{version=v1, az=1a}@). Only instances that match all the
-- specified key-value pairs are returned.
discoverInstances_queryParameters :: Lens.Lens' DiscoverInstances (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
discoverInstances_queryParameters :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> DiscoverInstances -> f DiscoverInstances
discoverInstances_queryParameters = (DiscoverInstances -> Maybe (HashMap Text Text))
-> (DiscoverInstances
    -> Maybe (HashMap Text Text) -> DiscoverInstances)
-> Lens
     DiscoverInstances
     DiscoverInstances
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DiscoverInstances' {Maybe (HashMap Text Text)
queryParameters :: Maybe (HashMap Text Text)
$sel:queryParameters:DiscoverInstances' :: DiscoverInstances -> Maybe (HashMap Text Text)
queryParameters} -> Maybe (HashMap Text Text)
queryParameters) (\s :: DiscoverInstances
s@DiscoverInstances' {} Maybe (HashMap Text Text)
a -> DiscoverInstances
s {$sel:queryParameters:DiscoverInstances' :: Maybe (HashMap Text Text)
queryParameters = Maybe (HashMap Text Text)
a} :: DiscoverInstances) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> DiscoverInstances -> f DiscoverInstances)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> DiscoverInstances
-> f DiscoverInstances
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
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
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Opportunistic filters to scope the results based on custom attributes.
-- If there are instances that match both the filters specified in both the
-- @QueryParameters@ parameter and this parameter, all of these instances
-- are returned. Otherwise, the filters are ignored, and only instances
-- that match the filters that are specified in the @QueryParameters@
-- parameter are returned.
discoverInstances_optionalParameters :: Lens.Lens' DiscoverInstances (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
discoverInstances_optionalParameters :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> DiscoverInstances -> f DiscoverInstances
discoverInstances_optionalParameters = (DiscoverInstances -> Maybe (HashMap Text Text))
-> (DiscoverInstances
    -> Maybe (HashMap Text Text) -> DiscoverInstances)
-> Lens
     DiscoverInstances
     DiscoverInstances
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DiscoverInstances' {Maybe (HashMap Text Text)
optionalParameters :: Maybe (HashMap Text Text)
$sel:optionalParameters:DiscoverInstances' :: DiscoverInstances -> Maybe (HashMap Text Text)
optionalParameters} -> Maybe (HashMap Text Text)
optionalParameters) (\s :: DiscoverInstances
s@DiscoverInstances' {} Maybe (HashMap Text Text)
a -> DiscoverInstances
s {$sel:optionalParameters:DiscoverInstances' :: Maybe (HashMap Text Text)
optionalParameters = Maybe (HashMap Text Text)
a} :: DiscoverInstances) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> DiscoverInstances -> f DiscoverInstances)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> DiscoverInstances
-> f DiscoverInstances
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
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
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The health status of the instances that you want to discover. This
-- parameter is ignored for services that don\'t have a health check
-- configured, and all instances are returned.
--
-- [HEALTHY]
--     Returns healthy instances.
--
-- [UNHEALTHY]
--     Returns unhealthy instances.
--
-- [ALL]
--     Returns all instances.
--
-- [HEALTHY_OR_ELSE_ALL]
--     Returns healthy instances, unless none are reporting a healthy
--     state. In that case, return all instances. This is also called
--     failing open.
discoverInstances_healthStatus :: Lens.Lens' DiscoverInstances (Prelude.Maybe HealthStatusFilter)
discoverInstances_healthStatus :: (Maybe HealthStatusFilter -> f (Maybe HealthStatusFilter))
-> DiscoverInstances -> f DiscoverInstances
discoverInstances_healthStatus = (DiscoverInstances -> Maybe HealthStatusFilter)
-> (DiscoverInstances
    -> Maybe HealthStatusFilter -> DiscoverInstances)
-> Lens
     DiscoverInstances
     DiscoverInstances
     (Maybe HealthStatusFilter)
     (Maybe HealthStatusFilter)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DiscoverInstances' {Maybe HealthStatusFilter
healthStatus :: Maybe HealthStatusFilter
$sel:healthStatus:DiscoverInstances' :: DiscoverInstances -> Maybe HealthStatusFilter
healthStatus} -> Maybe HealthStatusFilter
healthStatus) (\s :: DiscoverInstances
s@DiscoverInstances' {} Maybe HealthStatusFilter
a -> DiscoverInstances
s {$sel:healthStatus:DiscoverInstances' :: Maybe HealthStatusFilter
healthStatus = Maybe HealthStatusFilter
a} :: DiscoverInstances)

-- | The maximum number of instances that you want Cloud Map to return in the
-- response to a @DiscoverInstances@ request. If you don\'t specify a value
-- for @MaxResults@, Cloud Map returns up to 100 instances.
discoverInstances_maxResults :: Lens.Lens' DiscoverInstances (Prelude.Maybe Prelude.Natural)
discoverInstances_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> DiscoverInstances -> f DiscoverInstances
discoverInstances_maxResults = (DiscoverInstances -> Maybe Natural)
-> (DiscoverInstances -> Maybe Natural -> DiscoverInstances)
-> Lens
     DiscoverInstances DiscoverInstances (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DiscoverInstances' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:DiscoverInstances' :: DiscoverInstances -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: DiscoverInstances
s@DiscoverInstances' {} Maybe Natural
a -> DiscoverInstances
s {$sel:maxResults:DiscoverInstances' :: Maybe Natural
maxResults = Maybe Natural
a} :: DiscoverInstances)

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

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

instance Core.AWSRequest DiscoverInstances where
  type
    AWSResponse DiscoverInstances =
      DiscoverInstancesResponse
  request :: DiscoverInstances -> Request DiscoverInstances
request = Service -> DiscoverInstances -> Request DiscoverInstances
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DiscoverInstances
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DiscoverInstances)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DiscoverInstances))
-> Logger
-> Service
-> Proxy DiscoverInstances
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DiscoverInstances)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe [HttpInstanceSummary] -> Int -> DiscoverInstancesResponse
DiscoverInstancesResponse'
            (Maybe [HttpInstanceSummary] -> Int -> DiscoverInstancesResponse)
-> Either String (Maybe [HttpInstanceSummary])
-> Either String (Int -> DiscoverInstancesResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object
-> Text -> Either String (Maybe (Maybe [HttpInstanceSummary]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Instances" Either String (Maybe (Maybe [HttpInstanceSummary]))
-> Maybe [HttpInstanceSummary]
-> Either String (Maybe [HttpInstanceSummary])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [HttpInstanceSummary]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Int -> DiscoverInstancesResponse)
-> Either String Int -> Either String DiscoverInstancesResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable DiscoverInstances

instance Prelude.NFData DiscoverInstances

instance Core.ToHeaders DiscoverInstances where
  toHeaders :: DiscoverInstances -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DiscoverInstances -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"Route53AutoNaming_v20170314.DiscoverInstances" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON DiscoverInstances where
  toJSON :: DiscoverInstances -> Value
toJSON DiscoverInstances' {Maybe Natural
Maybe (HashMap Text Text)
Maybe HealthStatusFilter
Text
serviceName :: Text
namespaceName :: Text
maxResults :: Maybe Natural
healthStatus :: Maybe HealthStatusFilter
optionalParameters :: Maybe (HashMap Text Text)
queryParameters :: Maybe (HashMap Text Text)
$sel:serviceName:DiscoverInstances' :: DiscoverInstances -> Text
$sel:namespaceName:DiscoverInstances' :: DiscoverInstances -> Text
$sel:maxResults:DiscoverInstances' :: DiscoverInstances -> Maybe Natural
$sel:healthStatus:DiscoverInstances' :: DiscoverInstances -> Maybe HealthStatusFilter
$sel:optionalParameters:DiscoverInstances' :: DiscoverInstances -> Maybe (HashMap Text Text)
$sel:queryParameters:DiscoverInstances' :: DiscoverInstances -> Maybe (HashMap Text Text)
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"QueryParameters" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (HashMap Text Text -> Pair)
-> Maybe (HashMap Text Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
queryParameters,
            (Text
"OptionalParameters" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (HashMap Text Text -> Pair)
-> Maybe (HashMap Text Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
optionalParameters,
            (Text
"HealthStatus" Text -> HealthStatusFilter -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HealthStatusFilter -> Pair)
-> Maybe HealthStatusFilter -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe HealthStatusFilter
healthStatus,
            (Text
"MaxResults" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxResults,
            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)
          ]
      )

instance Core.ToPath DiscoverInstances where
  toPath :: DiscoverInstances -> ByteString
toPath = ByteString -> DiscoverInstances -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery DiscoverInstances where
  toQuery :: DiscoverInstances -> QueryString
toQuery = QueryString -> DiscoverInstances -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newDiscoverInstancesResponse' smart constructor.
data DiscoverInstancesResponse = DiscoverInstancesResponse'
  { -- | A complex type that contains one @HttpInstanceSummary@ for each
    -- registered instance.
    DiscoverInstancesResponse -> Maybe [HttpInstanceSummary]
instances :: Prelude.Maybe [HttpInstanceSummary],
    -- | The response's http status code.
    DiscoverInstancesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DiscoverInstancesResponse -> DiscoverInstancesResponse -> Bool
(DiscoverInstancesResponse -> DiscoverInstancesResponse -> Bool)
-> (DiscoverInstancesResponse -> DiscoverInstancesResponse -> Bool)
-> Eq DiscoverInstancesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DiscoverInstancesResponse -> DiscoverInstancesResponse -> Bool
$c/= :: DiscoverInstancesResponse -> DiscoverInstancesResponse -> Bool
== :: DiscoverInstancesResponse -> DiscoverInstancesResponse -> Bool
$c== :: DiscoverInstancesResponse -> DiscoverInstancesResponse -> Bool
Prelude.Eq, ReadPrec [DiscoverInstancesResponse]
ReadPrec DiscoverInstancesResponse
Int -> ReadS DiscoverInstancesResponse
ReadS [DiscoverInstancesResponse]
(Int -> ReadS DiscoverInstancesResponse)
-> ReadS [DiscoverInstancesResponse]
-> ReadPrec DiscoverInstancesResponse
-> ReadPrec [DiscoverInstancesResponse]
-> Read DiscoverInstancesResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DiscoverInstancesResponse]
$creadListPrec :: ReadPrec [DiscoverInstancesResponse]
readPrec :: ReadPrec DiscoverInstancesResponse
$creadPrec :: ReadPrec DiscoverInstancesResponse
readList :: ReadS [DiscoverInstancesResponse]
$creadList :: ReadS [DiscoverInstancesResponse]
readsPrec :: Int -> ReadS DiscoverInstancesResponse
$creadsPrec :: Int -> ReadS DiscoverInstancesResponse
Prelude.Read, Int -> DiscoverInstancesResponse -> ShowS
[DiscoverInstancesResponse] -> ShowS
DiscoverInstancesResponse -> String
(Int -> DiscoverInstancesResponse -> ShowS)
-> (DiscoverInstancesResponse -> String)
-> ([DiscoverInstancesResponse] -> ShowS)
-> Show DiscoverInstancesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DiscoverInstancesResponse] -> ShowS
$cshowList :: [DiscoverInstancesResponse] -> ShowS
show :: DiscoverInstancesResponse -> String
$cshow :: DiscoverInstancesResponse -> String
showsPrec :: Int -> DiscoverInstancesResponse -> ShowS
$cshowsPrec :: Int -> DiscoverInstancesResponse -> ShowS
Prelude.Show, (forall x.
 DiscoverInstancesResponse -> Rep DiscoverInstancesResponse x)
-> (forall x.
    Rep DiscoverInstancesResponse x -> DiscoverInstancesResponse)
-> Generic DiscoverInstancesResponse
forall x.
Rep DiscoverInstancesResponse x -> DiscoverInstancesResponse
forall x.
DiscoverInstancesResponse -> Rep DiscoverInstancesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DiscoverInstancesResponse x -> DiscoverInstancesResponse
$cfrom :: forall x.
DiscoverInstancesResponse -> Rep DiscoverInstancesResponse x
Prelude.Generic)

-- |
-- Create a value of 'DiscoverInstancesResponse' 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:
--
-- 'instances', 'discoverInstancesResponse_instances' - A complex type that contains one @HttpInstanceSummary@ for each
-- registered instance.
--
-- 'httpStatus', 'discoverInstancesResponse_httpStatus' - The response's http status code.
newDiscoverInstancesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DiscoverInstancesResponse
newDiscoverInstancesResponse :: Int -> DiscoverInstancesResponse
newDiscoverInstancesResponse Int
pHttpStatus_ =
  DiscoverInstancesResponse' :: Maybe [HttpInstanceSummary] -> Int -> DiscoverInstancesResponse
DiscoverInstancesResponse'
    { $sel:instances:DiscoverInstancesResponse' :: Maybe [HttpInstanceSummary]
instances =
        Maybe [HttpInstanceSummary]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DiscoverInstancesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A complex type that contains one @HttpInstanceSummary@ for each
-- registered instance.
discoverInstancesResponse_instances :: Lens.Lens' DiscoverInstancesResponse (Prelude.Maybe [HttpInstanceSummary])
discoverInstancesResponse_instances :: (Maybe [HttpInstanceSummary] -> f (Maybe [HttpInstanceSummary]))
-> DiscoverInstancesResponse -> f DiscoverInstancesResponse
discoverInstancesResponse_instances = (DiscoverInstancesResponse -> Maybe [HttpInstanceSummary])
-> (DiscoverInstancesResponse
    -> Maybe [HttpInstanceSummary] -> DiscoverInstancesResponse)
-> Lens
     DiscoverInstancesResponse
     DiscoverInstancesResponse
     (Maybe [HttpInstanceSummary])
     (Maybe [HttpInstanceSummary])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DiscoverInstancesResponse' {Maybe [HttpInstanceSummary]
instances :: Maybe [HttpInstanceSummary]
$sel:instances:DiscoverInstancesResponse' :: DiscoverInstancesResponse -> Maybe [HttpInstanceSummary]
instances} -> Maybe [HttpInstanceSummary]
instances) (\s :: DiscoverInstancesResponse
s@DiscoverInstancesResponse' {} Maybe [HttpInstanceSummary]
a -> DiscoverInstancesResponse
s {$sel:instances:DiscoverInstancesResponse' :: Maybe [HttpInstanceSummary]
instances = Maybe [HttpInstanceSummary]
a} :: DiscoverInstancesResponse) ((Maybe [HttpInstanceSummary] -> f (Maybe [HttpInstanceSummary]))
 -> DiscoverInstancesResponse -> f DiscoverInstancesResponse)
-> ((Maybe [HttpInstanceSummary]
     -> f (Maybe [HttpInstanceSummary]))
    -> Maybe [HttpInstanceSummary] -> f (Maybe [HttpInstanceSummary]))
-> (Maybe [HttpInstanceSummary] -> f (Maybe [HttpInstanceSummary]))
-> DiscoverInstancesResponse
-> f DiscoverInstancesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [HttpInstanceSummary]
  [HttpInstanceSummary]
  [HttpInstanceSummary]
  [HttpInstanceSummary]
-> Iso
     (Maybe [HttpInstanceSummary])
     (Maybe [HttpInstanceSummary])
     (Maybe [HttpInstanceSummary])
     (Maybe [HttpInstanceSummary])
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
  [HttpInstanceSummary]
  [HttpInstanceSummary]
  [HttpInstanceSummary]
  [HttpInstanceSummary]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The response's http status code.
discoverInstancesResponse_httpStatus :: Lens.Lens' DiscoverInstancesResponse Prelude.Int
discoverInstancesResponse_httpStatus :: (Int -> f Int)
-> DiscoverInstancesResponse -> f DiscoverInstancesResponse
discoverInstancesResponse_httpStatus = (DiscoverInstancesResponse -> Int)
-> (DiscoverInstancesResponse -> Int -> DiscoverInstancesResponse)
-> Lens DiscoverInstancesResponse DiscoverInstancesResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DiscoverInstancesResponse' {Int
httpStatus :: Int
$sel:httpStatus:DiscoverInstancesResponse' :: DiscoverInstancesResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: DiscoverInstancesResponse
s@DiscoverInstancesResponse' {} Int
a -> DiscoverInstancesResponse
s {$sel:httpStatus:DiscoverInstancesResponse' :: Int
httpStatus = Int
a} :: DiscoverInstancesResponse)

instance Prelude.NFData DiscoverInstancesResponse