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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Route53AutoNaming.Types.DnsConfigChange
import Amazonka.Route53AutoNaming.Types.HealthCheckConfig

-- | A complex type that contains changes to an existing service.
--
-- /See:/ 'newServiceChange' smart constructor.
data ServiceChange = ServiceChange'
  { -- | /Public DNS and HTTP namespaces only./ Settings for an optional health
    -- check. If you specify settings for a health check, Cloud Map associates
    -- the health check with the records that you specify in @DnsConfig@.
    ServiceChange -> Maybe HealthCheckConfig
healthCheckConfig :: Prelude.Maybe HealthCheckConfig,
    -- | Information about the Route 53 DNS records that you want Cloud Map to
    -- create when you register an instance.
    ServiceChange -> Maybe DnsConfigChange
dnsConfig :: Prelude.Maybe DnsConfigChange,
    -- | A description for the service.
    ServiceChange -> Maybe Text
description :: Prelude.Maybe Prelude.Text
  }
  deriving (ServiceChange -> ServiceChange -> Bool
(ServiceChange -> ServiceChange -> Bool)
-> (ServiceChange -> ServiceChange -> Bool) -> Eq ServiceChange
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ServiceChange -> ServiceChange -> Bool
$c/= :: ServiceChange -> ServiceChange -> Bool
== :: ServiceChange -> ServiceChange -> Bool
$c== :: ServiceChange -> ServiceChange -> Bool
Prelude.Eq, ReadPrec [ServiceChange]
ReadPrec ServiceChange
Int -> ReadS ServiceChange
ReadS [ServiceChange]
(Int -> ReadS ServiceChange)
-> ReadS [ServiceChange]
-> ReadPrec ServiceChange
-> ReadPrec [ServiceChange]
-> Read ServiceChange
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ServiceChange]
$creadListPrec :: ReadPrec [ServiceChange]
readPrec :: ReadPrec ServiceChange
$creadPrec :: ReadPrec ServiceChange
readList :: ReadS [ServiceChange]
$creadList :: ReadS [ServiceChange]
readsPrec :: Int -> ReadS ServiceChange
$creadsPrec :: Int -> ReadS ServiceChange
Prelude.Read, Int -> ServiceChange -> ShowS
[ServiceChange] -> ShowS
ServiceChange -> String
(Int -> ServiceChange -> ShowS)
-> (ServiceChange -> String)
-> ([ServiceChange] -> ShowS)
-> Show ServiceChange
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ServiceChange] -> ShowS
$cshowList :: [ServiceChange] -> ShowS
show :: ServiceChange -> String
$cshow :: ServiceChange -> String
showsPrec :: Int -> ServiceChange -> ShowS
$cshowsPrec :: Int -> ServiceChange -> ShowS
Prelude.Show, (forall x. ServiceChange -> Rep ServiceChange x)
-> (forall x. Rep ServiceChange x -> ServiceChange)
-> Generic ServiceChange
forall x. Rep ServiceChange x -> ServiceChange
forall x. ServiceChange -> Rep ServiceChange x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ServiceChange x -> ServiceChange
$cfrom :: forall x. ServiceChange -> Rep ServiceChange x
Prelude.Generic)

-- |
-- Create a value of 'ServiceChange' 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:
--
-- 'healthCheckConfig', 'serviceChange_healthCheckConfig' - /Public DNS and HTTP namespaces only./ Settings for an optional health
-- check. If you specify settings for a health check, Cloud Map associates
-- the health check with the records that you specify in @DnsConfig@.
--
-- 'dnsConfig', 'serviceChange_dnsConfig' - Information about the Route 53 DNS records that you want Cloud Map to
-- create when you register an instance.
--
-- 'description', 'serviceChange_description' - A description for the service.
newServiceChange ::
  ServiceChange
newServiceChange :: ServiceChange
newServiceChange =
  ServiceChange' :: Maybe HealthCheckConfig
-> Maybe DnsConfigChange -> Maybe Text -> ServiceChange
ServiceChange'
    { $sel:healthCheckConfig:ServiceChange' :: Maybe HealthCheckConfig
healthCheckConfig = Maybe HealthCheckConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:dnsConfig:ServiceChange' :: Maybe DnsConfigChange
dnsConfig = Maybe DnsConfigChange
forall a. Maybe a
Prelude.Nothing,
      $sel:description:ServiceChange' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | /Public DNS and HTTP namespaces only./ Settings for an optional health
-- check. If you specify settings for a health check, Cloud Map associates
-- the health check with the records that you specify in @DnsConfig@.
serviceChange_healthCheckConfig :: Lens.Lens' ServiceChange (Prelude.Maybe HealthCheckConfig)
serviceChange_healthCheckConfig :: (Maybe HealthCheckConfig -> f (Maybe HealthCheckConfig))
-> ServiceChange -> f ServiceChange
serviceChange_healthCheckConfig = (ServiceChange -> Maybe HealthCheckConfig)
-> (ServiceChange -> Maybe HealthCheckConfig -> ServiceChange)
-> Lens
     ServiceChange
     ServiceChange
     (Maybe HealthCheckConfig)
     (Maybe HealthCheckConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServiceChange' {Maybe HealthCheckConfig
healthCheckConfig :: Maybe HealthCheckConfig
$sel:healthCheckConfig:ServiceChange' :: ServiceChange -> Maybe HealthCheckConfig
healthCheckConfig} -> Maybe HealthCheckConfig
healthCheckConfig) (\s :: ServiceChange
s@ServiceChange' {} Maybe HealthCheckConfig
a -> ServiceChange
s {$sel:healthCheckConfig:ServiceChange' :: Maybe HealthCheckConfig
healthCheckConfig = Maybe HealthCheckConfig
a} :: ServiceChange)

-- | Information about the Route 53 DNS records that you want Cloud Map to
-- create when you register an instance.
serviceChange_dnsConfig :: Lens.Lens' ServiceChange (Prelude.Maybe DnsConfigChange)
serviceChange_dnsConfig :: (Maybe DnsConfigChange -> f (Maybe DnsConfigChange))
-> ServiceChange -> f ServiceChange
serviceChange_dnsConfig = (ServiceChange -> Maybe DnsConfigChange)
-> (ServiceChange -> Maybe DnsConfigChange -> ServiceChange)
-> Lens
     ServiceChange
     ServiceChange
     (Maybe DnsConfigChange)
     (Maybe DnsConfigChange)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServiceChange' {Maybe DnsConfigChange
dnsConfig :: Maybe DnsConfigChange
$sel:dnsConfig:ServiceChange' :: ServiceChange -> Maybe DnsConfigChange
dnsConfig} -> Maybe DnsConfigChange
dnsConfig) (\s :: ServiceChange
s@ServiceChange' {} Maybe DnsConfigChange
a -> ServiceChange
s {$sel:dnsConfig:ServiceChange' :: Maybe DnsConfigChange
dnsConfig = Maybe DnsConfigChange
a} :: ServiceChange)

-- | A description for the service.
serviceChange_description :: Lens.Lens' ServiceChange (Prelude.Maybe Prelude.Text)
serviceChange_description :: (Maybe Text -> f (Maybe Text)) -> ServiceChange -> f ServiceChange
serviceChange_description = (ServiceChange -> Maybe Text)
-> (ServiceChange -> Maybe Text -> ServiceChange)
-> Lens ServiceChange ServiceChange (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServiceChange' {Maybe Text
description :: Maybe Text
$sel:description:ServiceChange' :: ServiceChange -> Maybe Text
description} -> Maybe Text
description) (\s :: ServiceChange
s@ServiceChange' {} Maybe Text
a -> ServiceChange
s {$sel:description:ServiceChange' :: Maybe Text
description = Maybe Text
a} :: ServiceChange)

instance Prelude.Hashable ServiceChange

instance Prelude.NFData ServiceChange

instance Core.ToJSON ServiceChange where
  toJSON :: ServiceChange -> Value
toJSON ServiceChange' {Maybe Text
Maybe HealthCheckConfig
Maybe DnsConfigChange
description :: Maybe Text
dnsConfig :: Maybe DnsConfigChange
healthCheckConfig :: Maybe HealthCheckConfig
$sel:description:ServiceChange' :: ServiceChange -> Maybe Text
$sel:dnsConfig:ServiceChange' :: ServiceChange -> Maybe DnsConfigChange
$sel:healthCheckConfig:ServiceChange' :: ServiceChange -> Maybe HealthCheckConfig
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"HealthCheckConfig" Text -> HealthCheckConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (HealthCheckConfig -> Pair)
-> Maybe HealthCheckConfig -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe HealthCheckConfig
healthCheckConfig,
            (Text
"DnsConfig" Text -> DnsConfigChange -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (DnsConfigChange -> Pair) -> Maybe DnsConfigChange -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe DnsConfigChange
dnsConfig,
            (Text
"Description" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
description
          ]
      )