{-# 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.SecurityHub.Types.AwsEcsServiceServiceRegistriesDetails
-- 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.SecurityHub.Types.AwsEcsServiceServiceRegistriesDetails where

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

-- | Information about a service discovery registry to assign to the service.
--
-- /See:/ 'newAwsEcsServiceServiceRegistriesDetails' smart constructor.
data AwsEcsServiceServiceRegistriesDetails = AwsEcsServiceServiceRegistriesDetails'
  { -- | The container name value to use for the service discovery service.
    --
    -- If the task definition uses the @bridge@ or @host@ network mode, you
    -- must specify @ContainerName@ and @ContainerPort@.
    --
    -- If the task definition uses the @awsvpc@ network mode and a type SRV DNS
    -- record, you must specify either @ContainerName@ and @ContainerPort@, or
    -- @Port@ , but not both.
    AwsEcsServiceServiceRegistriesDetails -> Maybe Text
containerName :: Prelude.Maybe Prelude.Text,
    -- | The ARN of the service registry.
    AwsEcsServiceServiceRegistriesDetails -> Maybe Text
registryArn :: Prelude.Maybe Prelude.Text,
    -- | The port value to use for the service discovery service.
    --
    -- If the task definition uses the @bridge@ or @host@ network mode, you
    -- must specify @ContainerName@ and @ContainerPort@.
    --
    -- If the task definition uses the @awsvpc@ network mode and a type SRV DNS
    -- record, you must specify either @ContainerName@ and @ContainerPort@, or
    -- @Port@ , but not both.
    AwsEcsServiceServiceRegistriesDetails -> Maybe Int
containerPort :: Prelude.Maybe Prelude.Int,
    -- | The port value to use for a service discovery service that specifies an
    -- SRV record. This field can be used if both the @awsvpc@awsvpc network
    -- mode and SRV records are used.
    AwsEcsServiceServiceRegistriesDetails -> Maybe Int
port :: Prelude.Maybe Prelude.Int
  }
  deriving (AwsEcsServiceServiceRegistriesDetails
-> AwsEcsServiceServiceRegistriesDetails -> Bool
(AwsEcsServiceServiceRegistriesDetails
 -> AwsEcsServiceServiceRegistriesDetails -> Bool)
-> (AwsEcsServiceServiceRegistriesDetails
    -> AwsEcsServiceServiceRegistriesDetails -> Bool)
-> Eq AwsEcsServiceServiceRegistriesDetails
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsEcsServiceServiceRegistriesDetails
-> AwsEcsServiceServiceRegistriesDetails -> Bool
$c/= :: AwsEcsServiceServiceRegistriesDetails
-> AwsEcsServiceServiceRegistriesDetails -> Bool
== :: AwsEcsServiceServiceRegistriesDetails
-> AwsEcsServiceServiceRegistriesDetails -> Bool
$c== :: AwsEcsServiceServiceRegistriesDetails
-> AwsEcsServiceServiceRegistriesDetails -> Bool
Prelude.Eq, ReadPrec [AwsEcsServiceServiceRegistriesDetails]
ReadPrec AwsEcsServiceServiceRegistriesDetails
Int -> ReadS AwsEcsServiceServiceRegistriesDetails
ReadS [AwsEcsServiceServiceRegistriesDetails]
(Int -> ReadS AwsEcsServiceServiceRegistriesDetails)
-> ReadS [AwsEcsServiceServiceRegistriesDetails]
-> ReadPrec AwsEcsServiceServiceRegistriesDetails
-> ReadPrec [AwsEcsServiceServiceRegistriesDetails]
-> Read AwsEcsServiceServiceRegistriesDetails
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsEcsServiceServiceRegistriesDetails]
$creadListPrec :: ReadPrec [AwsEcsServiceServiceRegistriesDetails]
readPrec :: ReadPrec AwsEcsServiceServiceRegistriesDetails
$creadPrec :: ReadPrec AwsEcsServiceServiceRegistriesDetails
readList :: ReadS [AwsEcsServiceServiceRegistriesDetails]
$creadList :: ReadS [AwsEcsServiceServiceRegistriesDetails]
readsPrec :: Int -> ReadS AwsEcsServiceServiceRegistriesDetails
$creadsPrec :: Int -> ReadS AwsEcsServiceServiceRegistriesDetails
Prelude.Read, Int -> AwsEcsServiceServiceRegistriesDetails -> ShowS
[AwsEcsServiceServiceRegistriesDetails] -> ShowS
AwsEcsServiceServiceRegistriesDetails -> String
(Int -> AwsEcsServiceServiceRegistriesDetails -> ShowS)
-> (AwsEcsServiceServiceRegistriesDetails -> String)
-> ([AwsEcsServiceServiceRegistriesDetails] -> ShowS)
-> Show AwsEcsServiceServiceRegistriesDetails
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsEcsServiceServiceRegistriesDetails] -> ShowS
$cshowList :: [AwsEcsServiceServiceRegistriesDetails] -> ShowS
show :: AwsEcsServiceServiceRegistriesDetails -> String
$cshow :: AwsEcsServiceServiceRegistriesDetails -> String
showsPrec :: Int -> AwsEcsServiceServiceRegistriesDetails -> ShowS
$cshowsPrec :: Int -> AwsEcsServiceServiceRegistriesDetails -> ShowS
Prelude.Show, (forall x.
 AwsEcsServiceServiceRegistriesDetails
 -> Rep AwsEcsServiceServiceRegistriesDetails x)
-> (forall x.
    Rep AwsEcsServiceServiceRegistriesDetails x
    -> AwsEcsServiceServiceRegistriesDetails)
-> Generic AwsEcsServiceServiceRegistriesDetails
forall x.
Rep AwsEcsServiceServiceRegistriesDetails x
-> AwsEcsServiceServiceRegistriesDetails
forall x.
AwsEcsServiceServiceRegistriesDetails
-> Rep AwsEcsServiceServiceRegistriesDetails x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AwsEcsServiceServiceRegistriesDetails x
-> AwsEcsServiceServiceRegistriesDetails
$cfrom :: forall x.
AwsEcsServiceServiceRegistriesDetails
-> Rep AwsEcsServiceServiceRegistriesDetails x
Prelude.Generic)

-- |
-- Create a value of 'AwsEcsServiceServiceRegistriesDetails' 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:
--
-- 'containerName', 'awsEcsServiceServiceRegistriesDetails_containerName' - The container name value to use for the service discovery service.
--
-- If the task definition uses the @bridge@ or @host@ network mode, you
-- must specify @ContainerName@ and @ContainerPort@.
--
-- If the task definition uses the @awsvpc@ network mode and a type SRV DNS
-- record, you must specify either @ContainerName@ and @ContainerPort@, or
-- @Port@ , but not both.
--
-- 'registryArn', 'awsEcsServiceServiceRegistriesDetails_registryArn' - The ARN of the service registry.
--
-- 'containerPort', 'awsEcsServiceServiceRegistriesDetails_containerPort' - The port value to use for the service discovery service.
--
-- If the task definition uses the @bridge@ or @host@ network mode, you
-- must specify @ContainerName@ and @ContainerPort@.
--
-- If the task definition uses the @awsvpc@ network mode and a type SRV DNS
-- record, you must specify either @ContainerName@ and @ContainerPort@, or
-- @Port@ , but not both.
--
-- 'port', 'awsEcsServiceServiceRegistriesDetails_port' - The port value to use for a service discovery service that specifies an
-- SRV record. This field can be used if both the @awsvpc@awsvpc network
-- mode and SRV records are used.
newAwsEcsServiceServiceRegistriesDetails ::
  AwsEcsServiceServiceRegistriesDetails
newAwsEcsServiceServiceRegistriesDetails :: AwsEcsServiceServiceRegistriesDetails
newAwsEcsServiceServiceRegistriesDetails =
  AwsEcsServiceServiceRegistriesDetails' :: Maybe Text
-> Maybe Text
-> Maybe Int
-> Maybe Int
-> AwsEcsServiceServiceRegistriesDetails
AwsEcsServiceServiceRegistriesDetails'
    { $sel:containerName:AwsEcsServiceServiceRegistriesDetails' :: Maybe Text
containerName =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:registryArn:AwsEcsServiceServiceRegistriesDetails' :: Maybe Text
registryArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:containerPort:AwsEcsServiceServiceRegistriesDetails' :: Maybe Int
containerPort = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:port:AwsEcsServiceServiceRegistriesDetails' :: Maybe Int
port = Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | The container name value to use for the service discovery service.
--
-- If the task definition uses the @bridge@ or @host@ network mode, you
-- must specify @ContainerName@ and @ContainerPort@.
--
-- If the task definition uses the @awsvpc@ network mode and a type SRV DNS
-- record, you must specify either @ContainerName@ and @ContainerPort@, or
-- @Port@ , but not both.
awsEcsServiceServiceRegistriesDetails_containerName :: Lens.Lens' AwsEcsServiceServiceRegistriesDetails (Prelude.Maybe Prelude.Text)
awsEcsServiceServiceRegistriesDetails_containerName :: (Maybe Text -> f (Maybe Text))
-> AwsEcsServiceServiceRegistriesDetails
-> f AwsEcsServiceServiceRegistriesDetails
awsEcsServiceServiceRegistriesDetails_containerName = (AwsEcsServiceServiceRegistriesDetails -> Maybe Text)
-> (AwsEcsServiceServiceRegistriesDetails
    -> Maybe Text -> AwsEcsServiceServiceRegistriesDetails)
-> Lens
     AwsEcsServiceServiceRegistriesDetails
     AwsEcsServiceServiceRegistriesDetails
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsEcsServiceServiceRegistriesDetails' {Maybe Text
containerName :: Maybe Text
$sel:containerName:AwsEcsServiceServiceRegistriesDetails' :: AwsEcsServiceServiceRegistriesDetails -> Maybe Text
containerName} -> Maybe Text
containerName) (\s :: AwsEcsServiceServiceRegistriesDetails
s@AwsEcsServiceServiceRegistriesDetails' {} Maybe Text
a -> AwsEcsServiceServiceRegistriesDetails
s {$sel:containerName:AwsEcsServiceServiceRegistriesDetails' :: Maybe Text
containerName = Maybe Text
a} :: AwsEcsServiceServiceRegistriesDetails)

-- | The ARN of the service registry.
awsEcsServiceServiceRegistriesDetails_registryArn :: Lens.Lens' AwsEcsServiceServiceRegistriesDetails (Prelude.Maybe Prelude.Text)
awsEcsServiceServiceRegistriesDetails_registryArn :: (Maybe Text -> f (Maybe Text))
-> AwsEcsServiceServiceRegistriesDetails
-> f AwsEcsServiceServiceRegistriesDetails
awsEcsServiceServiceRegistriesDetails_registryArn = (AwsEcsServiceServiceRegistriesDetails -> Maybe Text)
-> (AwsEcsServiceServiceRegistriesDetails
    -> Maybe Text -> AwsEcsServiceServiceRegistriesDetails)
-> Lens
     AwsEcsServiceServiceRegistriesDetails
     AwsEcsServiceServiceRegistriesDetails
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsEcsServiceServiceRegistriesDetails' {Maybe Text
registryArn :: Maybe Text
$sel:registryArn:AwsEcsServiceServiceRegistriesDetails' :: AwsEcsServiceServiceRegistriesDetails -> Maybe Text
registryArn} -> Maybe Text
registryArn) (\s :: AwsEcsServiceServiceRegistriesDetails
s@AwsEcsServiceServiceRegistriesDetails' {} Maybe Text
a -> AwsEcsServiceServiceRegistriesDetails
s {$sel:registryArn:AwsEcsServiceServiceRegistriesDetails' :: Maybe Text
registryArn = Maybe Text
a} :: AwsEcsServiceServiceRegistriesDetails)

-- | The port value to use for the service discovery service.
--
-- If the task definition uses the @bridge@ or @host@ network mode, you
-- must specify @ContainerName@ and @ContainerPort@.
--
-- If the task definition uses the @awsvpc@ network mode and a type SRV DNS
-- record, you must specify either @ContainerName@ and @ContainerPort@, or
-- @Port@ , but not both.
awsEcsServiceServiceRegistriesDetails_containerPort :: Lens.Lens' AwsEcsServiceServiceRegistriesDetails (Prelude.Maybe Prelude.Int)
awsEcsServiceServiceRegistriesDetails_containerPort :: (Maybe Int -> f (Maybe Int))
-> AwsEcsServiceServiceRegistriesDetails
-> f AwsEcsServiceServiceRegistriesDetails
awsEcsServiceServiceRegistriesDetails_containerPort = (AwsEcsServiceServiceRegistriesDetails -> Maybe Int)
-> (AwsEcsServiceServiceRegistriesDetails
    -> Maybe Int -> AwsEcsServiceServiceRegistriesDetails)
-> Lens
     AwsEcsServiceServiceRegistriesDetails
     AwsEcsServiceServiceRegistriesDetails
     (Maybe Int)
     (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsEcsServiceServiceRegistriesDetails' {Maybe Int
containerPort :: Maybe Int
$sel:containerPort:AwsEcsServiceServiceRegistriesDetails' :: AwsEcsServiceServiceRegistriesDetails -> Maybe Int
containerPort} -> Maybe Int
containerPort) (\s :: AwsEcsServiceServiceRegistriesDetails
s@AwsEcsServiceServiceRegistriesDetails' {} Maybe Int
a -> AwsEcsServiceServiceRegistriesDetails
s {$sel:containerPort:AwsEcsServiceServiceRegistriesDetails' :: Maybe Int
containerPort = Maybe Int
a} :: AwsEcsServiceServiceRegistriesDetails)

-- | The port value to use for a service discovery service that specifies an
-- SRV record. This field can be used if both the @awsvpc@awsvpc network
-- mode and SRV records are used.
awsEcsServiceServiceRegistriesDetails_port :: Lens.Lens' AwsEcsServiceServiceRegistriesDetails (Prelude.Maybe Prelude.Int)
awsEcsServiceServiceRegistriesDetails_port :: (Maybe Int -> f (Maybe Int))
-> AwsEcsServiceServiceRegistriesDetails
-> f AwsEcsServiceServiceRegistriesDetails
awsEcsServiceServiceRegistriesDetails_port = (AwsEcsServiceServiceRegistriesDetails -> Maybe Int)
-> (AwsEcsServiceServiceRegistriesDetails
    -> Maybe Int -> AwsEcsServiceServiceRegistriesDetails)
-> Lens
     AwsEcsServiceServiceRegistriesDetails
     AwsEcsServiceServiceRegistriesDetails
     (Maybe Int)
     (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsEcsServiceServiceRegistriesDetails' {Maybe Int
port :: Maybe Int
$sel:port:AwsEcsServiceServiceRegistriesDetails' :: AwsEcsServiceServiceRegistriesDetails -> Maybe Int
port} -> Maybe Int
port) (\s :: AwsEcsServiceServiceRegistriesDetails
s@AwsEcsServiceServiceRegistriesDetails' {} Maybe Int
a -> AwsEcsServiceServiceRegistriesDetails
s {$sel:port:AwsEcsServiceServiceRegistriesDetails' :: Maybe Int
port = Maybe Int
a} :: AwsEcsServiceServiceRegistriesDetails)

instance
  Core.FromJSON
    AwsEcsServiceServiceRegistriesDetails
  where
  parseJSON :: Value -> Parser AwsEcsServiceServiceRegistriesDetails
parseJSON =
    String
-> (Object -> Parser AwsEcsServiceServiceRegistriesDetails)
-> Value
-> Parser AwsEcsServiceServiceRegistriesDetails
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AwsEcsServiceServiceRegistriesDetails"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Int
-> Maybe Int
-> AwsEcsServiceServiceRegistriesDetails
AwsEcsServiceServiceRegistriesDetails'
            (Maybe Text
 -> Maybe Text
 -> Maybe Int
 -> Maybe Int
 -> AwsEcsServiceServiceRegistriesDetails)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Int -> Maybe Int -> AwsEcsServiceServiceRegistriesDetails)
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
"ContainerName")
            Parser
  (Maybe Text
   -> Maybe Int -> Maybe Int -> AwsEcsServiceServiceRegistriesDetails)
-> Parser (Maybe Text)
-> Parser
     (Maybe Int -> Maybe Int -> AwsEcsServiceServiceRegistriesDetails)
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
"RegistryArn")
            Parser
  (Maybe Int -> Maybe Int -> AwsEcsServiceServiceRegistriesDetails)
-> Parser (Maybe Int)
-> Parser (Maybe Int -> AwsEcsServiceServiceRegistriesDetails)
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 -> AwsEcsServiceServiceRegistriesDetails)
-> Parser (Maybe Int)
-> Parser AwsEcsServiceServiceRegistriesDetails
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
    AwsEcsServiceServiceRegistriesDetails

instance
  Prelude.NFData
    AwsEcsServiceServiceRegistriesDetails

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