{-# 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.SageMaker.Types.CodeRepository
-- 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.SageMaker.Types.CodeRepository 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

-- | A Git repository that SageMaker automatically displays to users for
-- cloning in the JupyterServer application.
--
-- /See:/ 'newCodeRepository' smart constructor.
data CodeRepository = CodeRepository'
  { -- | The URL of the Git repository.
    CodeRepository -> Text
repositoryUrl :: Prelude.Text
  }
  deriving (CodeRepository -> CodeRepository -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CodeRepository -> CodeRepository -> Bool
$c/= :: CodeRepository -> CodeRepository -> Bool
== :: CodeRepository -> CodeRepository -> Bool
$c== :: CodeRepository -> CodeRepository -> Bool
Prelude.Eq, ReadPrec [CodeRepository]
ReadPrec CodeRepository
Int -> ReadS CodeRepository
ReadS [CodeRepository]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CodeRepository]
$creadListPrec :: ReadPrec [CodeRepository]
readPrec :: ReadPrec CodeRepository
$creadPrec :: ReadPrec CodeRepository
readList :: ReadS [CodeRepository]
$creadList :: ReadS [CodeRepository]
readsPrec :: Int -> ReadS CodeRepository
$creadsPrec :: Int -> ReadS CodeRepository
Prelude.Read, Int -> CodeRepository -> ShowS
[CodeRepository] -> ShowS
CodeRepository -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CodeRepository] -> ShowS
$cshowList :: [CodeRepository] -> ShowS
show :: CodeRepository -> String
$cshow :: CodeRepository -> String
showsPrec :: Int -> CodeRepository -> ShowS
$cshowsPrec :: Int -> CodeRepository -> ShowS
Prelude.Show, forall x. Rep CodeRepository x -> CodeRepository
forall x. CodeRepository -> Rep CodeRepository x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CodeRepository x -> CodeRepository
$cfrom :: forall x. CodeRepository -> Rep CodeRepository x
Prelude.Generic)

-- |
-- Create a value of 'CodeRepository' 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:
--
-- 'repositoryUrl', 'codeRepository_repositoryUrl' - The URL of the Git repository.
newCodeRepository ::
  -- | 'repositoryUrl'
  Prelude.Text ->
  CodeRepository
newCodeRepository :: Text -> CodeRepository
newCodeRepository Text
pRepositoryUrl_ =
  CodeRepository' {$sel:repositoryUrl:CodeRepository' :: Text
repositoryUrl = Text
pRepositoryUrl_}

-- | The URL of the Git repository.
codeRepository_repositoryUrl :: Lens.Lens' CodeRepository Prelude.Text
codeRepository_repositoryUrl :: Lens' CodeRepository Text
codeRepository_repositoryUrl = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CodeRepository' {Text
repositoryUrl :: Text
$sel:repositoryUrl:CodeRepository' :: CodeRepository -> Text
repositoryUrl} -> Text
repositoryUrl) (\s :: CodeRepository
s@CodeRepository' {} Text
a -> CodeRepository
s {$sel:repositoryUrl:CodeRepository' :: Text
repositoryUrl = Text
a} :: CodeRepository)

instance Data.FromJSON CodeRepository where
  parseJSON :: Value -> Parser CodeRepository
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CodeRepository"
      ( \Object
x ->
          Text -> CodeRepository
CodeRepository'
            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
"RepositoryUrl")
      )

instance Prelude.Hashable CodeRepository where
  hashWithSalt :: Int -> CodeRepository -> Int
hashWithSalt Int
_salt CodeRepository' {Text
repositoryUrl :: Text
$sel:repositoryUrl:CodeRepository' :: CodeRepository -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
repositoryUrl

instance Prelude.NFData CodeRepository where
  rnf :: CodeRepository -> ()
rnf CodeRepository' {Text
repositoryUrl :: Text
$sel:repositoryUrl:CodeRepository' :: CodeRepository -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
repositoryUrl

instance Data.ToJSON CodeRepository where
  toJSON :: CodeRepository -> Value
toJSON CodeRepository' {Text
repositoryUrl :: Text
$sel:repositoryUrl:CodeRepository' :: CodeRepository -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"RepositoryUrl" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
repositoryUrl)
          ]
      )