{-# 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.ServiceCatalog.Types.CodeStarParameters
-- 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.ServiceCatalog.Types.CodeStarParameters 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 subtype containing details about the Codestar connection @Type@.
--
-- /See:/ 'newCodeStarParameters' smart constructor.
data CodeStarParameters = CodeStarParameters'
  { -- | The CodeStar ARN, which is the connection between Service Catalog and
    -- the external repository.
    CodeStarParameters -> Text
connectionArn :: Prelude.Text,
    -- | The specific repository where the product’s artifact-to-be-synced
    -- resides, formatted as \"Account\/Repo.\"
    CodeStarParameters -> Text
repository :: Prelude.Text,
    -- | The specific branch where the artifact resides.
    CodeStarParameters -> Text
branch :: Prelude.Text,
    -- | The absolute path wehre the artifact resides within the repo and branch,
    -- formatted as \"folder\/file.json.\"
    CodeStarParameters -> Text
artifactPath :: Prelude.Text
  }
  deriving (CodeStarParameters -> CodeStarParameters -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CodeStarParameters -> CodeStarParameters -> Bool
$c/= :: CodeStarParameters -> CodeStarParameters -> Bool
== :: CodeStarParameters -> CodeStarParameters -> Bool
$c== :: CodeStarParameters -> CodeStarParameters -> Bool
Prelude.Eq, ReadPrec [CodeStarParameters]
ReadPrec CodeStarParameters
Int -> ReadS CodeStarParameters
ReadS [CodeStarParameters]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CodeStarParameters]
$creadListPrec :: ReadPrec [CodeStarParameters]
readPrec :: ReadPrec CodeStarParameters
$creadPrec :: ReadPrec CodeStarParameters
readList :: ReadS [CodeStarParameters]
$creadList :: ReadS [CodeStarParameters]
readsPrec :: Int -> ReadS CodeStarParameters
$creadsPrec :: Int -> ReadS CodeStarParameters
Prelude.Read, Int -> CodeStarParameters -> ShowS
[CodeStarParameters] -> ShowS
CodeStarParameters -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CodeStarParameters] -> ShowS
$cshowList :: [CodeStarParameters] -> ShowS
show :: CodeStarParameters -> String
$cshow :: CodeStarParameters -> String
showsPrec :: Int -> CodeStarParameters -> ShowS
$cshowsPrec :: Int -> CodeStarParameters -> ShowS
Prelude.Show, forall x. Rep CodeStarParameters x -> CodeStarParameters
forall x. CodeStarParameters -> Rep CodeStarParameters x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CodeStarParameters x -> CodeStarParameters
$cfrom :: forall x. CodeStarParameters -> Rep CodeStarParameters x
Prelude.Generic)

-- |
-- Create a value of 'CodeStarParameters' 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:
--
-- 'connectionArn', 'codeStarParameters_connectionArn' - The CodeStar ARN, which is the connection between Service Catalog and
-- the external repository.
--
-- 'repository', 'codeStarParameters_repository' - The specific repository where the product’s artifact-to-be-synced
-- resides, formatted as \"Account\/Repo.\"
--
-- 'branch', 'codeStarParameters_branch' - The specific branch where the artifact resides.
--
-- 'artifactPath', 'codeStarParameters_artifactPath' - The absolute path wehre the artifact resides within the repo and branch,
-- formatted as \"folder\/file.json.\"
newCodeStarParameters ::
  -- | 'connectionArn'
  Prelude.Text ->
  -- | 'repository'
  Prelude.Text ->
  -- | 'branch'
  Prelude.Text ->
  -- | 'artifactPath'
  Prelude.Text ->
  CodeStarParameters
newCodeStarParameters :: Text -> Text -> Text -> Text -> CodeStarParameters
newCodeStarParameters
  Text
pConnectionArn_
  Text
pRepository_
  Text
pBranch_
  Text
pArtifactPath_ =
    CodeStarParameters'
      { $sel:connectionArn:CodeStarParameters' :: Text
connectionArn =
          Text
pConnectionArn_,
        $sel:repository:CodeStarParameters' :: Text
repository = Text
pRepository_,
        $sel:branch:CodeStarParameters' :: Text
branch = Text
pBranch_,
        $sel:artifactPath:CodeStarParameters' :: Text
artifactPath = Text
pArtifactPath_
      }

-- | The CodeStar ARN, which is the connection between Service Catalog and
-- the external repository.
codeStarParameters_connectionArn :: Lens.Lens' CodeStarParameters Prelude.Text
codeStarParameters_connectionArn :: Lens' CodeStarParameters Text
codeStarParameters_connectionArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CodeStarParameters' {Text
connectionArn :: Text
$sel:connectionArn:CodeStarParameters' :: CodeStarParameters -> Text
connectionArn} -> Text
connectionArn) (\s :: CodeStarParameters
s@CodeStarParameters' {} Text
a -> CodeStarParameters
s {$sel:connectionArn:CodeStarParameters' :: Text
connectionArn = Text
a} :: CodeStarParameters)

-- | The specific repository where the product’s artifact-to-be-synced
-- resides, formatted as \"Account\/Repo.\"
codeStarParameters_repository :: Lens.Lens' CodeStarParameters Prelude.Text
codeStarParameters_repository :: Lens' CodeStarParameters Text
codeStarParameters_repository = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CodeStarParameters' {Text
repository :: Text
$sel:repository:CodeStarParameters' :: CodeStarParameters -> Text
repository} -> Text
repository) (\s :: CodeStarParameters
s@CodeStarParameters' {} Text
a -> CodeStarParameters
s {$sel:repository:CodeStarParameters' :: Text
repository = Text
a} :: CodeStarParameters)

-- | The specific branch where the artifact resides.
codeStarParameters_branch :: Lens.Lens' CodeStarParameters Prelude.Text
codeStarParameters_branch :: Lens' CodeStarParameters Text
codeStarParameters_branch = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CodeStarParameters' {Text
branch :: Text
$sel:branch:CodeStarParameters' :: CodeStarParameters -> Text
branch} -> Text
branch) (\s :: CodeStarParameters
s@CodeStarParameters' {} Text
a -> CodeStarParameters
s {$sel:branch:CodeStarParameters' :: Text
branch = Text
a} :: CodeStarParameters)

-- | The absolute path wehre the artifact resides within the repo and branch,
-- formatted as \"folder\/file.json.\"
codeStarParameters_artifactPath :: Lens.Lens' CodeStarParameters Prelude.Text
codeStarParameters_artifactPath :: Lens' CodeStarParameters Text
codeStarParameters_artifactPath = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CodeStarParameters' {Text
artifactPath :: Text
$sel:artifactPath:CodeStarParameters' :: CodeStarParameters -> Text
artifactPath} -> Text
artifactPath) (\s :: CodeStarParameters
s@CodeStarParameters' {} Text
a -> CodeStarParameters
s {$sel:artifactPath:CodeStarParameters' :: Text
artifactPath = Text
a} :: CodeStarParameters)

instance Data.FromJSON CodeStarParameters where
  parseJSON :: Value -> Parser CodeStarParameters
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CodeStarParameters"
      ( \Object
x ->
          Text -> Text -> Text -> Text -> CodeStarParameters
CodeStarParameters'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"ConnectionArn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Repository")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Branch")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"ArtifactPath")
      )

instance Prelude.Hashable CodeStarParameters where
  hashWithSalt :: Int -> CodeStarParameters -> Int
hashWithSalt Int
_salt CodeStarParameters' {Text
artifactPath :: Text
branch :: Text
repository :: Text
connectionArn :: Text
$sel:artifactPath:CodeStarParameters' :: CodeStarParameters -> Text
$sel:branch:CodeStarParameters' :: CodeStarParameters -> Text
$sel:repository:CodeStarParameters' :: CodeStarParameters -> Text
$sel:connectionArn:CodeStarParameters' :: CodeStarParameters -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
connectionArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
repository
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
branch
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
artifactPath

instance Prelude.NFData CodeStarParameters where
  rnf :: CodeStarParameters -> ()
rnf CodeStarParameters' {Text
artifactPath :: Text
branch :: Text
repository :: Text
connectionArn :: Text
$sel:artifactPath:CodeStarParameters' :: CodeStarParameters -> Text
$sel:branch:CodeStarParameters' :: CodeStarParameters -> Text
$sel:repository:CodeStarParameters' :: CodeStarParameters -> Text
$sel:connectionArn:CodeStarParameters' :: CodeStarParameters -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
connectionArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
repository
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
branch
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
artifactPath

instance Data.ToJSON CodeStarParameters where
  toJSON :: CodeStarParameters -> Value
toJSON CodeStarParameters' {Text
artifactPath :: Text
branch :: Text
repository :: Text
connectionArn :: Text
$sel:artifactPath:CodeStarParameters' :: CodeStarParameters -> Text
$sel:branch:CodeStarParameters' :: CodeStarParameters -> Text
$sel:repository:CodeStarParameters' :: CodeStarParameters -> Text
$sel:connectionArn:CodeStarParameters' :: CodeStarParameters -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"ConnectionArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
connectionArn),
            forall a. a -> Maybe a
Prelude.Just (Key
"Repository" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
repository),
            forall a. a -> Maybe a
Prelude.Just (Key
"Branch" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
branch),
            forall a. a -> Maybe a
Prelude.Just (Key
"ArtifactPath" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
artifactPath)
          ]
      )