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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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'
  { -- | 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,
    -- | 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,
    -- | 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 repository type.
    Source -> Maybe SourceType
type' :: Prelude.Maybe SourceType,
    -- | 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
  }
  deriving (Source -> Source -> Bool
(Source -> Source -> Bool)
-> (Source -> Source -> Bool) -> Eq Source
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]
(Int -> ReadS Source)
-> ReadS [Source]
-> ReadPrec Source
-> ReadPrec [Source]
-> Read 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
(Int -> Source -> ShowS)
-> (Source -> String) -> ([Source] -> ShowS) -> Show Source
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. Source -> Rep Source x)
-> (forall x. Rep Source x -> Source) -> Generic Source
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:
--
-- '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.
--
-- 'sshKey', 'source_sshKey' - In requests, the repository\'s SSH key.
--
-- In responses, AWS OpsWorks Stacks returns @*****FILTERED*****@ instead
-- of the actual value.
--
-- '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.
--
-- 'type'', 'source_type' - The repository type.
--
-- '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.
newSource ::
  Source
newSource :: Source
newSource =
  Source' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe SourceType
-> Maybe Text
-> Source
Source'
    { $sel:url:Source' :: Maybe Text
url = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:username:Source' :: Maybe Text
username = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:sshKey:Source' :: Maybe Text
sshKey = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:password:Source' :: Maybe Text
password = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:type':Source' :: Maybe SourceType
type' = Maybe SourceType
forall a. Maybe a
Prelude.Nothing,
      $sel:revision:Source' :: Maybe Text
revision = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe Text -> f (Maybe Text)) -> Source -> f Source
source_url = (Source -> Maybe Text)
-> (Source -> Maybe Text -> Source)
-> Lens Source Source (Maybe Text) (Maybe Text)
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 :: (Maybe Text -> f (Maybe Text)) -> Source -> f Source
source_username = (Source -> Maybe Text)
-> (Source -> Maybe Text -> Source)
-> Lens Source Source (Maybe Text) (Maybe Text)
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)

-- | 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 :: (Maybe Text -> f (Maybe Text)) -> Source -> f Source
source_sshKey = (Source -> Maybe Text)
-> (Source -> Maybe Text -> Source)
-> Lens Source Source (Maybe Text) (Maybe Text)
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)

-- | 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 :: (Maybe Text -> f (Maybe Text)) -> Source -> f Source
source_password = (Source -> Maybe Text)
-> (Source -> Maybe Text -> Source)
-> Lens Source Source (Maybe Text) (Maybe Text)
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 repository type.
source_type :: Lens.Lens' Source (Prelude.Maybe SourceType)
source_type :: (Maybe SourceType -> f (Maybe SourceType)) -> Source -> f Source
source_type = (Source -> Maybe SourceType)
-> (Source -> Maybe SourceType -> Source)
-> Lens Source Source (Maybe SourceType) (Maybe SourceType)
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 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 :: (Maybe Text -> f (Maybe Text)) -> Source -> f Source
source_revision = (Source -> Maybe Text)
-> (Source -> Maybe Text -> Source)
-> Lens Source Source (Maybe Text) (Maybe Text)
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)

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

instance Prelude.Hashable Source

instance Prelude.NFData Source

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