{-# 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.CodeDeploy.Types.ECSService
-- 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.CodeDeploy.Types.ECSService where

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

-- | Contains the service and cluster names used to identify an Amazon ECS
-- deployment\'s target.
--
-- /See:/ 'newECSService' smart constructor.
data ECSService = ECSService'
  { -- | The name of the target Amazon ECS service.
    ECSService -> Maybe Text
serviceName :: Prelude.Maybe Prelude.Text,
    -- | The name of the cluster that the Amazon ECS service is associated with.
    ECSService -> Maybe Text
clusterName :: Prelude.Maybe Prelude.Text
  }
  deriving (ECSService -> ECSService -> Bool
(ECSService -> ECSService -> Bool)
-> (ECSService -> ECSService -> Bool) -> Eq ECSService
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ECSService -> ECSService -> Bool
$c/= :: ECSService -> ECSService -> Bool
== :: ECSService -> ECSService -> Bool
$c== :: ECSService -> ECSService -> Bool
Prelude.Eq, ReadPrec [ECSService]
ReadPrec ECSService
Int -> ReadS ECSService
ReadS [ECSService]
(Int -> ReadS ECSService)
-> ReadS [ECSService]
-> ReadPrec ECSService
-> ReadPrec [ECSService]
-> Read ECSService
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ECSService]
$creadListPrec :: ReadPrec [ECSService]
readPrec :: ReadPrec ECSService
$creadPrec :: ReadPrec ECSService
readList :: ReadS [ECSService]
$creadList :: ReadS [ECSService]
readsPrec :: Int -> ReadS ECSService
$creadsPrec :: Int -> ReadS ECSService
Prelude.Read, Int -> ECSService -> ShowS
[ECSService] -> ShowS
ECSService -> String
(Int -> ECSService -> ShowS)
-> (ECSService -> String)
-> ([ECSService] -> ShowS)
-> Show ECSService
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ECSService] -> ShowS
$cshowList :: [ECSService] -> ShowS
show :: ECSService -> String
$cshow :: ECSService -> String
showsPrec :: Int -> ECSService -> ShowS
$cshowsPrec :: Int -> ECSService -> ShowS
Prelude.Show, (forall x. ECSService -> Rep ECSService x)
-> (forall x. Rep ECSService x -> ECSService) -> Generic ECSService
forall x. Rep ECSService x -> ECSService
forall x. ECSService -> Rep ECSService x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ECSService x -> ECSService
$cfrom :: forall x. ECSService -> Rep ECSService x
Prelude.Generic)

-- |
-- Create a value of 'ECSService' 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:
--
-- 'serviceName', 'eCSService_serviceName' - The name of the target Amazon ECS service.
--
-- 'clusterName', 'eCSService_clusterName' - The name of the cluster that the Amazon ECS service is associated with.
newECSService ::
  ECSService
newECSService :: ECSService
newECSService =
  ECSService' :: Maybe Text -> Maybe Text -> ECSService
ECSService'
    { $sel:serviceName:ECSService' :: Maybe Text
serviceName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:clusterName:ECSService' :: Maybe Text
clusterName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the target Amazon ECS service.
eCSService_serviceName :: Lens.Lens' ECSService (Prelude.Maybe Prelude.Text)
eCSService_serviceName :: (Maybe Text -> f (Maybe Text)) -> ECSService -> f ECSService
eCSService_serviceName = (ECSService -> Maybe Text)
-> (ECSService -> Maybe Text -> ECSService)
-> Lens ECSService ECSService (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ECSService' {Maybe Text
serviceName :: Maybe Text
$sel:serviceName:ECSService' :: ECSService -> Maybe Text
serviceName} -> Maybe Text
serviceName) (\s :: ECSService
s@ECSService' {} Maybe Text
a -> ECSService
s {$sel:serviceName:ECSService' :: Maybe Text
serviceName = Maybe Text
a} :: ECSService)

-- | The name of the cluster that the Amazon ECS service is associated with.
eCSService_clusterName :: Lens.Lens' ECSService (Prelude.Maybe Prelude.Text)
eCSService_clusterName :: (Maybe Text -> f (Maybe Text)) -> ECSService -> f ECSService
eCSService_clusterName = (ECSService -> Maybe Text)
-> (ECSService -> Maybe Text -> ECSService)
-> Lens ECSService ECSService (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ECSService' {Maybe Text
clusterName :: Maybe Text
$sel:clusterName:ECSService' :: ECSService -> Maybe Text
clusterName} -> Maybe Text
clusterName) (\s :: ECSService
s@ECSService' {} Maybe Text
a -> ECSService
s {$sel:clusterName:ECSService' :: Maybe Text
clusterName = Maybe Text
a} :: ECSService)

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

instance Prelude.Hashable ECSService

instance Prelude.NFData ECSService

instance Core.ToJSON ECSService where
  toJSON :: ECSService -> Value
toJSON ECSService' {Maybe Text
clusterName :: Maybe Text
serviceName :: Maybe Text
$sel:clusterName:ECSService' :: ECSService -> Maybe Text
$sel:serviceName:ECSService' :: ECSService -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"serviceName" 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
serviceName,
            (Text
"clusterName" 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
clusterName
          ]
      )