{-# 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.ECS.Types.ServiceRegistry
-- 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.ECS.Types.ServiceRegistry where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Details of the service registry.
--
-- /See:/ 'newServiceRegistry' smart constructor.
data ServiceRegistry = ServiceRegistry'
  { -- | The Amazon Resource Name (ARN) of the service registry. The currently
    -- supported service registry is Cloud Map. For more information, see
    -- <https://docs.aws.amazon.com/cloud-map/latest/api/API_CreateService.html CreateService>.
    ServiceRegistry -> Maybe Text
registryArn :: Prelude.Maybe Prelude.Text,
    -- | The container name value, already specified in the task definition, to
    -- be used for your service discovery service. If the task definition that
    -- your service task specifies uses the @bridge@ or @host@ network mode,
    -- you must specify a @containerName@ and @containerPort@ combination from
    -- the task definition. If the task definition that your service task
    -- specifies uses the @awsvpc@ network mode and a type SRV DNS record is
    -- used, you must specify either a @containerName@ and @containerPort@
    -- combination or a @port@ value, but not both.
    ServiceRegistry -> Maybe Text
containerName :: Prelude.Maybe Prelude.Text,
    -- | The port value, already specified in the task definition, to be used for
    -- your service discovery service. If the task definition your service task
    -- specifies uses the @bridge@ or @host@ network mode, you must specify a
    -- @containerName@ and @containerPort@ combination from the task
    -- definition. If the task definition your service task specifies uses the
    -- @awsvpc@ network mode and a type SRV DNS record is used, you must
    -- specify either a @containerName@ and @containerPort@ combination or a
    -- @port@ value, but not both.
    ServiceRegistry -> Maybe Int
containerPort :: Prelude.Maybe Prelude.Int,
    -- | The port value used if your service discovery service specified an SRV
    -- record. This field may be used if both the @awsvpc@ network mode and SRV
    -- records are used.
    ServiceRegistry -> Maybe Int
port :: Prelude.Maybe Prelude.Int
  }
  deriving (ServiceRegistry -> ServiceRegistry -> Bool
(ServiceRegistry -> ServiceRegistry -> Bool)
-> (ServiceRegistry -> ServiceRegistry -> Bool)
-> Eq ServiceRegistry
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ServiceRegistry -> ServiceRegistry -> Bool
$c/= :: ServiceRegistry -> ServiceRegistry -> Bool
== :: ServiceRegistry -> ServiceRegistry -> Bool
$c== :: ServiceRegistry -> ServiceRegistry -> Bool
Prelude.Eq, ReadPrec [ServiceRegistry]
ReadPrec ServiceRegistry
Int -> ReadS ServiceRegistry
ReadS [ServiceRegistry]
(Int -> ReadS ServiceRegistry)
-> ReadS [ServiceRegistry]
-> ReadPrec ServiceRegistry
-> ReadPrec [ServiceRegistry]
-> Read ServiceRegistry
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ServiceRegistry]
$creadListPrec :: ReadPrec [ServiceRegistry]
readPrec :: ReadPrec ServiceRegistry
$creadPrec :: ReadPrec ServiceRegistry
readList :: ReadS [ServiceRegistry]
$creadList :: ReadS [ServiceRegistry]
readsPrec :: Int -> ReadS ServiceRegistry
$creadsPrec :: Int -> ReadS ServiceRegistry
Prelude.Read, Int -> ServiceRegistry -> ShowS
[ServiceRegistry] -> ShowS
ServiceRegistry -> String
(Int -> ServiceRegistry -> ShowS)
-> (ServiceRegistry -> String)
-> ([ServiceRegistry] -> ShowS)
-> Show ServiceRegistry
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ServiceRegistry] -> ShowS
$cshowList :: [ServiceRegistry] -> ShowS
show :: ServiceRegistry -> String
$cshow :: ServiceRegistry -> String
showsPrec :: Int -> ServiceRegistry -> ShowS
$cshowsPrec :: Int -> ServiceRegistry -> ShowS
Prelude.Show, (forall x. ServiceRegistry -> Rep ServiceRegistry x)
-> (forall x. Rep ServiceRegistry x -> ServiceRegistry)
-> Generic ServiceRegistry
forall x. Rep ServiceRegistry x -> ServiceRegistry
forall x. ServiceRegistry -> Rep ServiceRegistry x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ServiceRegistry x -> ServiceRegistry
$cfrom :: forall x. ServiceRegistry -> Rep ServiceRegistry x
Prelude.Generic)

-- |
-- Create a value of 'ServiceRegistry' 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:
--
-- 'registryArn', 'serviceRegistry_registryArn' - The Amazon Resource Name (ARN) of the service registry. The currently
-- supported service registry is Cloud Map. For more information, see
-- <https://docs.aws.amazon.com/cloud-map/latest/api/API_CreateService.html CreateService>.
--
-- 'containerName', 'serviceRegistry_containerName' - The container name value, already specified in the task definition, to
-- be used for your service discovery service. If the task definition that
-- your service task specifies uses the @bridge@ or @host@ network mode,
-- you must specify a @containerName@ and @containerPort@ combination from
-- the task definition. If the task definition that your service task
-- specifies uses the @awsvpc@ network mode and a type SRV DNS record is
-- used, you must specify either a @containerName@ and @containerPort@
-- combination or a @port@ value, but not both.
--
-- 'containerPort', 'serviceRegistry_containerPort' - The port value, already specified in the task definition, to be used for
-- your service discovery service. If the task definition your service task
-- specifies uses the @bridge@ or @host@ network mode, you must specify a
-- @containerName@ and @containerPort@ combination from the task
-- definition. If the task definition your service task specifies uses the
-- @awsvpc@ network mode and a type SRV DNS record is used, you must
-- specify either a @containerName@ and @containerPort@ combination or a
-- @port@ value, but not both.
--
-- 'port', 'serviceRegistry_port' - The port value used if your service discovery service specified an SRV
-- record. This field may be used if both the @awsvpc@ network mode and SRV
-- records are used.
newServiceRegistry ::
  ServiceRegistry
newServiceRegistry :: ServiceRegistry
newServiceRegistry =
  ServiceRegistry' :: Maybe Text
-> Maybe Text -> Maybe Int -> Maybe Int -> ServiceRegistry
ServiceRegistry'
    { $sel:registryArn:ServiceRegistry' :: Maybe Text
registryArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:containerName:ServiceRegistry' :: Maybe Text
containerName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:containerPort:ServiceRegistry' :: Maybe Int
containerPort = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:port:ServiceRegistry' :: Maybe Int
port = Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Resource Name (ARN) of the service registry. The currently
-- supported service registry is Cloud Map. For more information, see
-- <https://docs.aws.amazon.com/cloud-map/latest/api/API_CreateService.html CreateService>.
serviceRegistry_registryArn :: Lens.Lens' ServiceRegistry (Prelude.Maybe Prelude.Text)
serviceRegistry_registryArn :: (Maybe Text -> f (Maybe Text))
-> ServiceRegistry -> f ServiceRegistry
serviceRegistry_registryArn = (ServiceRegistry -> Maybe Text)
-> (ServiceRegistry -> Maybe Text -> ServiceRegistry)
-> Lens ServiceRegistry ServiceRegistry (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServiceRegistry' {Maybe Text
registryArn :: Maybe Text
$sel:registryArn:ServiceRegistry' :: ServiceRegistry -> Maybe Text
registryArn} -> Maybe Text
registryArn) (\s :: ServiceRegistry
s@ServiceRegistry' {} Maybe Text
a -> ServiceRegistry
s {$sel:registryArn:ServiceRegistry' :: Maybe Text
registryArn = Maybe Text
a} :: ServiceRegistry)

-- | The container name value, already specified in the task definition, to
-- be used for your service discovery service. If the task definition that
-- your service task specifies uses the @bridge@ or @host@ network mode,
-- you must specify a @containerName@ and @containerPort@ combination from
-- the task definition. If the task definition that your service task
-- specifies uses the @awsvpc@ network mode and a type SRV DNS record is
-- used, you must specify either a @containerName@ and @containerPort@
-- combination or a @port@ value, but not both.
serviceRegistry_containerName :: Lens.Lens' ServiceRegistry (Prelude.Maybe Prelude.Text)
serviceRegistry_containerName :: (Maybe Text -> f (Maybe Text))
-> ServiceRegistry -> f ServiceRegistry
serviceRegistry_containerName = (ServiceRegistry -> Maybe Text)
-> (ServiceRegistry -> Maybe Text -> ServiceRegistry)
-> Lens ServiceRegistry ServiceRegistry (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServiceRegistry' {Maybe Text
containerName :: Maybe Text
$sel:containerName:ServiceRegistry' :: ServiceRegistry -> Maybe Text
containerName} -> Maybe Text
containerName) (\s :: ServiceRegistry
s@ServiceRegistry' {} Maybe Text
a -> ServiceRegistry
s {$sel:containerName:ServiceRegistry' :: Maybe Text
containerName = Maybe Text
a} :: ServiceRegistry)

-- | The port value, already specified in the task definition, to be used for
-- your service discovery service. If the task definition your service task
-- specifies uses the @bridge@ or @host@ network mode, you must specify a
-- @containerName@ and @containerPort@ combination from the task
-- definition. If the task definition your service task specifies uses the
-- @awsvpc@ network mode and a type SRV DNS record is used, you must
-- specify either a @containerName@ and @containerPort@ combination or a
-- @port@ value, but not both.
serviceRegistry_containerPort :: Lens.Lens' ServiceRegistry (Prelude.Maybe Prelude.Int)
serviceRegistry_containerPort :: (Maybe Int -> f (Maybe Int))
-> ServiceRegistry -> f ServiceRegistry
serviceRegistry_containerPort = (ServiceRegistry -> Maybe Int)
-> (ServiceRegistry -> Maybe Int -> ServiceRegistry)
-> Lens ServiceRegistry ServiceRegistry (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServiceRegistry' {Maybe Int
containerPort :: Maybe Int
$sel:containerPort:ServiceRegistry' :: ServiceRegistry -> Maybe Int
containerPort} -> Maybe Int
containerPort) (\s :: ServiceRegistry
s@ServiceRegistry' {} Maybe Int
a -> ServiceRegistry
s {$sel:containerPort:ServiceRegistry' :: Maybe Int
containerPort = Maybe Int
a} :: ServiceRegistry)

-- | The port value used if your service discovery service specified an SRV
-- record. This field may be used if both the @awsvpc@ network mode and SRV
-- records are used.
serviceRegistry_port :: Lens.Lens' ServiceRegistry (Prelude.Maybe Prelude.Int)
serviceRegistry_port :: (Maybe Int -> f (Maybe Int))
-> ServiceRegistry -> f ServiceRegistry
serviceRegistry_port = (ServiceRegistry -> Maybe Int)
-> (ServiceRegistry -> Maybe Int -> ServiceRegistry)
-> Lens ServiceRegistry ServiceRegistry (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServiceRegistry' {Maybe Int
port :: Maybe Int
$sel:port:ServiceRegistry' :: ServiceRegistry -> Maybe Int
port} -> Maybe Int
port) (\s :: ServiceRegistry
s@ServiceRegistry' {} Maybe Int
a -> ServiceRegistry
s {$sel:port:ServiceRegistry' :: Maybe Int
port = Maybe Int
a} :: ServiceRegistry)

instance Core.FromJSON ServiceRegistry where
  parseJSON :: Value -> Parser ServiceRegistry
parseJSON =
    String
-> (Object -> Parser ServiceRegistry)
-> Value
-> Parser ServiceRegistry
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ServiceRegistry"
      ( \Object
x ->
          Maybe Text
-> Maybe Text -> Maybe Int -> Maybe Int -> ServiceRegistry
ServiceRegistry'
            (Maybe Text
 -> Maybe Text -> Maybe Int -> Maybe Int -> ServiceRegistry)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Int -> Maybe Int -> ServiceRegistry)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"registryArn")
            Parser (Maybe Text -> Maybe Int -> Maybe Int -> ServiceRegistry)
-> Parser (Maybe Text)
-> Parser (Maybe Int -> Maybe Int -> ServiceRegistry)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"containerName")
            Parser (Maybe Int -> Maybe Int -> ServiceRegistry)
-> Parser (Maybe Int) -> Parser (Maybe Int -> ServiceRegistry)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"containerPort")
            Parser (Maybe Int -> ServiceRegistry)
-> Parser (Maybe Int) -> Parser ServiceRegistry
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"port")
      )

instance Prelude.Hashable ServiceRegistry

instance Prelude.NFData ServiceRegistry

instance Core.ToJSON ServiceRegistry where
  toJSON :: ServiceRegistry -> Value
toJSON ServiceRegistry' {Maybe Int
Maybe Text
port :: Maybe Int
containerPort :: Maybe Int
containerName :: Maybe Text
registryArn :: Maybe Text
$sel:port:ServiceRegistry' :: ServiceRegistry -> Maybe Int
$sel:containerPort:ServiceRegistry' :: ServiceRegistry -> Maybe Int
$sel:containerName:ServiceRegistry' :: ServiceRegistry -> Maybe Text
$sel:registryArn:ServiceRegistry' :: ServiceRegistry -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"registryArn" 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
registryArn,
            (Text
"containerName" 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
containerName,
            (Text
"containerPort" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
containerPort,
            (Text
"port" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
port
          ]
      )