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

-- | The Service Connect resource. Each configuration maps a discovery name
-- to a Cloud Map service name. The data is stored in Cloud Map as part of
-- the Service Connect configuration for each discovery name of this Amazon
-- ECS service.
--
-- A task can resolve the @dnsName@ for each of the @clientAliases@ of a
-- service. However a task can\'t resolve the discovery names. If you want
-- to connect to a service, refer to the @ServiceConnectConfiguration@ of
-- that service for the list of @clientAliases@ that you can use.
--
-- /See:/ 'newServiceConnectServiceResource' smart constructor.
data ServiceConnectServiceResource = ServiceConnectServiceResource'
  { -- | The Amazon Resource Name (ARN) for the namespace in Cloud Map that
    -- matches the discovery name for this Service Connect resource. You can
    -- use this ARN in other integrations with Cloud Map. However, Service
    -- Connect can\'t ensure connectivity outside of Amazon ECS.
    ServiceConnectServiceResource -> Maybe Text
discoveryArn :: Prelude.Maybe Prelude.Text,
    -- | The discovery name of this Service Connect resource.
    --
    -- The @discoveryName@ is the name of the new Cloud Map service that Amazon
    -- ECS creates for this Amazon ECS service. This must be unique within the
    -- Cloud Map namespace. The name can contain up to 64 characters. The name
    -- can include lowercase letters, numbers, underscores (_), and hyphens
    -- (-). The name can\'t start with a hyphen.
    --
    -- If this parameter isn\'t specified, the default value of
    -- @discoveryName.namespace@ is used. If the @discoveryName@ isn\'t
    -- specified, the port mapping name from the task definition is used in
    -- @portName.namespace@.
    ServiceConnectServiceResource -> Maybe Text
discoveryName :: Prelude.Maybe Prelude.Text
  }
  deriving (ServiceConnectServiceResource
-> ServiceConnectServiceResource -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ServiceConnectServiceResource
-> ServiceConnectServiceResource -> Bool
$c/= :: ServiceConnectServiceResource
-> ServiceConnectServiceResource -> Bool
== :: ServiceConnectServiceResource
-> ServiceConnectServiceResource -> Bool
$c== :: ServiceConnectServiceResource
-> ServiceConnectServiceResource -> Bool
Prelude.Eq, ReadPrec [ServiceConnectServiceResource]
ReadPrec ServiceConnectServiceResource
Int -> ReadS ServiceConnectServiceResource
ReadS [ServiceConnectServiceResource]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ServiceConnectServiceResource]
$creadListPrec :: ReadPrec [ServiceConnectServiceResource]
readPrec :: ReadPrec ServiceConnectServiceResource
$creadPrec :: ReadPrec ServiceConnectServiceResource
readList :: ReadS [ServiceConnectServiceResource]
$creadList :: ReadS [ServiceConnectServiceResource]
readsPrec :: Int -> ReadS ServiceConnectServiceResource
$creadsPrec :: Int -> ReadS ServiceConnectServiceResource
Prelude.Read, Int -> ServiceConnectServiceResource -> ShowS
[ServiceConnectServiceResource] -> ShowS
ServiceConnectServiceResource -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ServiceConnectServiceResource] -> ShowS
$cshowList :: [ServiceConnectServiceResource] -> ShowS
show :: ServiceConnectServiceResource -> String
$cshow :: ServiceConnectServiceResource -> String
showsPrec :: Int -> ServiceConnectServiceResource -> ShowS
$cshowsPrec :: Int -> ServiceConnectServiceResource -> ShowS
Prelude.Show, forall x.
Rep ServiceConnectServiceResource x
-> ServiceConnectServiceResource
forall x.
ServiceConnectServiceResource
-> Rep ServiceConnectServiceResource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ServiceConnectServiceResource x
-> ServiceConnectServiceResource
$cfrom :: forall x.
ServiceConnectServiceResource
-> Rep ServiceConnectServiceResource x
Prelude.Generic)

-- |
-- Create a value of 'ServiceConnectServiceResource' 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:
--
-- 'discoveryArn', 'serviceConnectServiceResource_discoveryArn' - The Amazon Resource Name (ARN) for the namespace in Cloud Map that
-- matches the discovery name for this Service Connect resource. You can
-- use this ARN in other integrations with Cloud Map. However, Service
-- Connect can\'t ensure connectivity outside of Amazon ECS.
--
-- 'discoveryName', 'serviceConnectServiceResource_discoveryName' - The discovery name of this Service Connect resource.
--
-- The @discoveryName@ is the name of the new Cloud Map service that Amazon
-- ECS creates for this Amazon ECS service. This must be unique within the
-- Cloud Map namespace. The name can contain up to 64 characters. The name
-- can include lowercase letters, numbers, underscores (_), and hyphens
-- (-). The name can\'t start with a hyphen.
--
-- If this parameter isn\'t specified, the default value of
-- @discoveryName.namespace@ is used. If the @discoveryName@ isn\'t
-- specified, the port mapping name from the task definition is used in
-- @portName.namespace@.
newServiceConnectServiceResource ::
  ServiceConnectServiceResource
newServiceConnectServiceResource :: ServiceConnectServiceResource
newServiceConnectServiceResource =
  ServiceConnectServiceResource'
    { $sel:discoveryArn:ServiceConnectServiceResource' :: Maybe Text
discoveryArn =
        forall a. Maybe a
Prelude.Nothing,
      $sel:discoveryName:ServiceConnectServiceResource' :: Maybe Text
discoveryName = forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Resource Name (ARN) for the namespace in Cloud Map that
-- matches the discovery name for this Service Connect resource. You can
-- use this ARN in other integrations with Cloud Map. However, Service
-- Connect can\'t ensure connectivity outside of Amazon ECS.
serviceConnectServiceResource_discoveryArn :: Lens.Lens' ServiceConnectServiceResource (Prelude.Maybe Prelude.Text)
serviceConnectServiceResource_discoveryArn :: Lens' ServiceConnectServiceResource (Maybe Text)
serviceConnectServiceResource_discoveryArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServiceConnectServiceResource' {Maybe Text
discoveryArn :: Maybe Text
$sel:discoveryArn:ServiceConnectServiceResource' :: ServiceConnectServiceResource -> Maybe Text
discoveryArn} -> Maybe Text
discoveryArn) (\s :: ServiceConnectServiceResource
s@ServiceConnectServiceResource' {} Maybe Text
a -> ServiceConnectServiceResource
s {$sel:discoveryArn:ServiceConnectServiceResource' :: Maybe Text
discoveryArn = Maybe Text
a} :: ServiceConnectServiceResource)

-- | The discovery name of this Service Connect resource.
--
-- The @discoveryName@ is the name of the new Cloud Map service that Amazon
-- ECS creates for this Amazon ECS service. This must be unique within the
-- Cloud Map namespace. The name can contain up to 64 characters. The name
-- can include lowercase letters, numbers, underscores (_), and hyphens
-- (-). The name can\'t start with a hyphen.
--
-- If this parameter isn\'t specified, the default value of
-- @discoveryName.namespace@ is used. If the @discoveryName@ isn\'t
-- specified, the port mapping name from the task definition is used in
-- @portName.namespace@.
serviceConnectServiceResource_discoveryName :: Lens.Lens' ServiceConnectServiceResource (Prelude.Maybe Prelude.Text)
serviceConnectServiceResource_discoveryName :: Lens' ServiceConnectServiceResource (Maybe Text)
serviceConnectServiceResource_discoveryName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServiceConnectServiceResource' {Maybe Text
discoveryName :: Maybe Text
$sel:discoveryName:ServiceConnectServiceResource' :: ServiceConnectServiceResource -> Maybe Text
discoveryName} -> Maybe Text
discoveryName) (\s :: ServiceConnectServiceResource
s@ServiceConnectServiceResource' {} Maybe Text
a -> ServiceConnectServiceResource
s {$sel:discoveryName:ServiceConnectServiceResource' :: Maybe Text
discoveryName = Maybe Text
a} :: ServiceConnectServiceResource)

instance Data.FromJSON ServiceConnectServiceResource where
  parseJSON :: Value -> Parser ServiceConnectServiceResource
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ServiceConnectServiceResource"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> ServiceConnectServiceResource
ServiceConnectServiceResource'
            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
"discoveryArn")
            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
"discoveryName")
      )

instance
  Prelude.Hashable
    ServiceConnectServiceResource
  where
  hashWithSalt :: Int -> ServiceConnectServiceResource -> Int
hashWithSalt Int
_salt ServiceConnectServiceResource' {Maybe Text
discoveryName :: Maybe Text
discoveryArn :: Maybe Text
$sel:discoveryName:ServiceConnectServiceResource' :: ServiceConnectServiceResource -> Maybe Text
$sel:discoveryArn:ServiceConnectServiceResource' :: ServiceConnectServiceResource -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
discoveryArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
discoveryName

instance Prelude.NFData ServiceConnectServiceResource where
  rnf :: ServiceConnectServiceResource -> ()
rnf ServiceConnectServiceResource' {Maybe Text
discoveryName :: Maybe Text
discoveryArn :: Maybe Text
$sel:discoveryName:ServiceConnectServiceResource' :: ServiceConnectServiceResource -> Maybe Text
$sel:discoveryArn:ServiceConnectServiceResource' :: ServiceConnectServiceResource -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
discoveryArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
discoveryName