{-# 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.OpsWorks.Types.Source
-- 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.OpsWorks.Types.Source where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.OpsWorks.Types.SourceType
import qualified Amazonka.Prelude as Prelude

-- | Contains the information required to retrieve an app or cookbook from a
-- repository. For more information, see
-- <https://docs.aws.amazon.com/opsworks/latest/userguide/workingapps-creating.html Creating Apps>
-- or
-- <https://docs.aws.amazon.com/opsworks/latest/userguide/workingcookbook.html Custom Recipes and Cookbooks>.
--
-- /See:/ 'newSource' smart constructor.
data Source = Source'
  { -- | When included in a request, the parameter depends on the repository
    -- type.
    --
    -- -   For Amazon S3 bundles, set @Password@ to the appropriate IAM secret
    --     access key.
    --
    -- -   For HTTP bundles and Subversion repositories, set @Password@ to the
    --     password.
    --
    -- For more information on how to safely handle IAM credentials, see
    -- <https://docs.aws.amazon.com/general/latest/gr/aws-access-keys-best-practices.html>.
    --
    -- In responses, AWS OpsWorks Stacks returns @*****FILTERED*****@ instead
    -- of the actual value.
    Source -> Maybe Text
password :: Prelude.Maybe Prelude.Text,
    -- | The application\'s version. AWS OpsWorks Stacks enables you to easily
    -- deploy new versions of an application. One of the simplest approaches is
    -- to have branches or revisions in your repository that represent
    -- different versions that can potentially be deployed.
    Source -> Maybe Text
revision :: Prelude.Maybe Prelude.Text,
    -- | In requests, the repository\'s SSH key.
    --
    -- In responses, AWS OpsWorks Stacks returns @*****FILTERED*****@ instead
    -- of the actual value.
    Source -> Maybe Text
sshKey :: Prelude.Maybe Prelude.Text,
    -- | The repository type.
    Source -> Maybe SourceType
type' :: Prelude.Maybe SourceType,
    -- | The source URL. The following is an example of an Amazon S3 source URL:
    -- @https:\/\/s3.amazonaws.com\/opsworks-demo-bucket\/opsworks_cookbook_demo.tar.gz@.
    Source -> Maybe Text
url :: Prelude.Maybe Prelude.Text,
    -- | This parameter depends on the repository type.
    --
    -- -   For Amazon S3 bundles, set @Username@ to the appropriate IAM access
    --     key ID.
    --
    -- -   For HTTP bundles, Git repositories, and Subversion repositories, set
    --     @Username@ to the user name.
    Source -> Maybe Text
username :: Prelude.Maybe Prelude.Text
  }
  deriving (Source -> Source -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Source -> Source -> Bool
$c/= :: Source -> Source -> Bool
== :: Source -> Source -> Bool
$c== :: Source -> Source -> Bool
Prelude.Eq, ReadPrec [Source]
ReadPrec Source
Int -> ReadS Source
ReadS [Source]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Source]
$creadListPrec :: ReadPrec [Source]
readPrec :: ReadPrec Source
$creadPrec :: ReadPrec Source
readList :: ReadS [Source]
$creadList :: ReadS [Source]
readsPrec :: Int -> ReadS Source
$creadsPrec :: Int -> ReadS Source
Prelude.Read, Int -> Source -> ShowS
[Source] -> ShowS
Source -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Source] -> ShowS
$cshowList :: [Source] -> ShowS
show :: Source -> String
$cshow :: Source -> String
showsPrec :: Int -> Source -> ShowS
$cshowsPrec :: Int -> Source -> ShowS
Prelude.Show, forall x. Rep Source x -> Source
forall x. Source -> Rep Source x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Source x -> Source
$cfrom :: forall x. Source -> Rep Source x
Prelude.Generic)

-- |
-- Create a value of 'Source' 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:
--
-- 'password', 'source_password' - When included in a request, the parameter depends on the repository
-- type.
--
-- -   For Amazon S3 bundles, set @Password@ to the appropriate IAM secret
--     access key.
--
-- -   For HTTP bundles and Subversion repositories, set @Password@ to the
--     password.
--
-- For more information on how to safely handle IAM credentials, see
-- <https://docs.aws.amazon.com/general/latest/gr/aws-access-keys-best-practices.html>.
--
-- In responses, AWS OpsWorks Stacks returns @*****FILTERED*****@ instead
-- of the actual value.
--
-- 'revision', 'source_revision' - The application\'s version. AWS OpsWorks Stacks enables you to easily
-- deploy new versions of an application. One of the simplest approaches is
-- to have branches or revisions in your repository that represent
-- different versions that can potentially be deployed.
--
-- 'sshKey', 'source_sshKey' - In requests, the repository\'s SSH key.
--
-- In responses, AWS OpsWorks Stacks returns @*****FILTERED*****@ instead
-- of the actual value.
--
-- 'type'', 'source_type' - The repository type.
--
-- 'url', 'source_url' - The source URL. The following is an example of an Amazon S3 source URL:
-- @https:\/\/s3.amazonaws.com\/opsworks-demo-bucket\/opsworks_cookbook_demo.tar.gz@.
--
-- 'username', 'source_username' - This parameter depends on the repository type.
--
-- -   For Amazon S3 bundles, set @Username@ to the appropriate IAM access
--     key ID.
--
-- -   For HTTP bundles, Git repositories, and Subversion repositories, set
--     @Username@ to the user name.
newSource ::
  Source
newSource :: Source
newSource =
  Source'
    { $sel:password:Source' :: Maybe Text
password = forall a. Maybe a
Prelude.Nothing,
      $sel:revision:Source' :: Maybe Text
revision = forall a. Maybe a
Prelude.Nothing,
      $sel:sshKey:Source' :: Maybe Text
sshKey = forall a. Maybe a
Prelude.Nothing,
      $sel:type':Source' :: Maybe SourceType
type' = forall a. Maybe a
Prelude.Nothing,
      $sel:url:Source' :: Maybe Text
url = forall a. Maybe a
Prelude.Nothing,
      $sel:username:Source' :: Maybe Text
username = forall a. Maybe a
Prelude.Nothing
    }

-- | When included in a request, the parameter depends on the repository
-- type.
--
-- -   For Amazon S3 bundles, set @Password@ to the appropriate IAM secret
--     access key.
--
-- -   For HTTP bundles and Subversion repositories, set @Password@ to the
--     password.
--
-- For more information on how to safely handle IAM credentials, see
-- <https://docs.aws.amazon.com/general/latest/gr/aws-access-keys-best-practices.html>.
--
-- In responses, AWS OpsWorks Stacks returns @*****FILTERED*****@ instead
-- of the actual value.
source_password :: Lens.Lens' Source (Prelude.Maybe Prelude.Text)
source_password :: Lens' Source (Maybe Text)
source_password = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Source' {Maybe Text
password :: Maybe Text
$sel:password:Source' :: Source -> Maybe Text
password} -> Maybe Text
password) (\s :: Source
s@Source' {} Maybe Text
a -> Source
s {$sel:password:Source' :: Maybe Text
password = Maybe Text
a} :: Source)

-- | The application\'s version. AWS OpsWorks Stacks enables you to easily
-- deploy new versions of an application. One of the simplest approaches is
-- to have branches or revisions in your repository that represent
-- different versions that can potentially be deployed.
source_revision :: Lens.Lens' Source (Prelude.Maybe Prelude.Text)
source_revision :: Lens' Source (Maybe Text)
source_revision = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Source' {Maybe Text
revision :: Maybe Text
$sel:revision:Source' :: Source -> Maybe Text
revision} -> Maybe Text
revision) (\s :: Source
s@Source' {} Maybe Text
a -> Source
s {$sel:revision:Source' :: Maybe Text
revision = Maybe Text
a} :: Source)

-- | In requests, the repository\'s SSH key.
--
-- In responses, AWS OpsWorks Stacks returns @*****FILTERED*****@ instead
-- of the actual value.
source_sshKey :: Lens.Lens' Source (Prelude.Maybe Prelude.Text)
source_sshKey :: Lens' Source (Maybe Text)
source_sshKey = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Source' {Maybe Text
sshKey :: Maybe Text
$sel:sshKey:Source' :: Source -> Maybe Text
sshKey} -> Maybe Text
sshKey) (\s :: Source
s@Source' {} Maybe Text
a -> Source
s {$sel:sshKey:Source' :: Maybe Text
sshKey = Maybe Text
a} :: Source)

-- | The repository type.
source_type :: Lens.Lens' Source (Prelude.Maybe SourceType)
source_type :: Lens' Source (Maybe SourceType)
source_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Source' {Maybe SourceType
type' :: Maybe SourceType
$sel:type':Source' :: Source -> Maybe SourceType
type'} -> Maybe SourceType
type') (\s :: Source
s@Source' {} Maybe SourceType
a -> Source
s {$sel:type':Source' :: Maybe SourceType
type' = Maybe SourceType
a} :: Source)

-- | The source URL. The following is an example of an Amazon S3 source URL:
-- @https:\/\/s3.amazonaws.com\/opsworks-demo-bucket\/opsworks_cookbook_demo.tar.gz@.
source_url :: Lens.Lens' Source (Prelude.Maybe Prelude.Text)
source_url :: Lens' Source (Maybe Text)
source_url = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Source' {Maybe Text
url :: Maybe Text
$sel:url:Source' :: Source -> Maybe Text
url} -> Maybe Text
url) (\s :: Source
s@Source' {} Maybe Text
a -> Source
s {$sel:url:Source' :: Maybe Text
url = Maybe Text
a} :: Source)

-- | This parameter depends on the repository type.
--
-- -   For Amazon S3 bundles, set @Username@ to the appropriate IAM access
--     key ID.
--
-- -   For HTTP bundles, Git repositories, and Subversion repositories, set
--     @Username@ to the user name.
source_username :: Lens.Lens' Source (Prelude.Maybe Prelude.Text)
source_username :: Lens' Source (Maybe Text)
source_username = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Source' {Maybe Text
username :: Maybe Text
$sel:username:Source' :: Source -> Maybe Text
username} -> Maybe Text
username) (\s :: Source
s@Source' {} Maybe Text
a -> Source
s {$sel:username:Source' :: Maybe Text
username = Maybe Text
a} :: Source)

instance Data.FromJSON Source where
  parseJSON :: Value -> Parser Source
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Source"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe SourceType
-> Maybe Text
-> Maybe Text
-> Source
Source'
            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
"Password")
            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
"Revision")
            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
"SshKey")
            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
"Type")
            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
"Url")
            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
"Username")
      )

instance Prelude.Hashable Source where
  hashWithSalt :: Int -> Source -> Int
hashWithSalt Int
_salt Source' {Maybe Text
Maybe SourceType
username :: Maybe Text
url :: Maybe Text
type' :: Maybe SourceType
sshKey :: Maybe Text
revision :: Maybe Text
password :: Maybe Text
$sel:username:Source' :: Source -> Maybe Text
$sel:url:Source' :: Source -> Maybe Text
$sel:type':Source' :: Source -> Maybe SourceType
$sel:sshKey:Source' :: Source -> Maybe Text
$sel:revision:Source' :: Source -> Maybe Text
$sel:password:Source' :: Source -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
password
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
revision
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
sshKey
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SourceType
type'
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
url
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
username

instance Prelude.NFData Source where
  rnf :: Source -> ()
rnf Source' {Maybe Text
Maybe SourceType
username :: Maybe Text
url :: Maybe Text
type' :: Maybe SourceType
sshKey :: Maybe Text
revision :: Maybe Text
password :: Maybe Text
$sel:username:Source' :: Source -> Maybe Text
$sel:url:Source' :: Source -> Maybe Text
$sel:type':Source' :: Source -> Maybe SourceType
$sel:sshKey:Source' :: Source -> Maybe Text
$sel:revision:Source' :: Source -> Maybe Text
$sel:password:Source' :: Source -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
password
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
revision
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
sshKey
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe SourceType
type'
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
url
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
username

instance Data.ToJSON Source where
  toJSON :: Source -> Value
toJSON Source' {Maybe Text
Maybe SourceType
username :: Maybe Text
url :: Maybe Text
type' :: Maybe SourceType
sshKey :: Maybe Text
revision :: Maybe Text
password :: Maybe Text
$sel:username:Source' :: Source -> Maybe Text
$sel:url:Source' :: Source -> Maybe Text
$sel:type':Source' :: Source -> Maybe SourceType
$sel:sshKey:Source' :: Source -> Maybe Text
$sel:revision:Source' :: Source -> Maybe Text
$sel:password:Source' :: Source -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Password" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
password,
            (Key
"Revision" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
revision,
            (Key
"SshKey" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
sshKey,
            (Key
"Type" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe SourceType
type',
            (Key
"Url" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
url,
            (Key
"Username" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
username
          ]
      )