{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.UpdateCodeRepository
-- 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)
--
-- Updates the specified Git repository with the specified values.
module Amazonka.SageMaker.UpdateCodeRepository
  ( -- * Creating a Request
    UpdateCodeRepository (..),
    newUpdateCodeRepository,

    -- * Request Lenses
    updateCodeRepository_gitConfig,
    updateCodeRepository_codeRepositoryName,

    -- * Destructuring the Response
    UpdateCodeRepositoryResponse (..),
    newUpdateCodeRepositoryResponse,

    -- * Response Lenses
    updateCodeRepositoryResponse_httpStatus,
    updateCodeRepositoryResponse_codeRepositoryArn,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.SageMaker.Types

-- | /See:/ 'newUpdateCodeRepository' smart constructor.
data UpdateCodeRepository = UpdateCodeRepository'
  { -- | The configuration of the git repository, including the URL and the
    -- Amazon Resource Name (ARN) of the Amazon Web Services Secrets Manager
    -- secret that contains the credentials used to access the repository. The
    -- secret must have a staging label of @AWSCURRENT@ and must be in the
    -- following format:
    --
    -- @{\"username\": UserName, \"password\": Password}@
    UpdateCodeRepository -> Maybe GitConfigForUpdate
gitConfig :: Prelude.Maybe GitConfigForUpdate,
    -- | The name of the Git repository to update.
    UpdateCodeRepository -> Text
codeRepositoryName :: Prelude.Text
  }
  deriving (UpdateCodeRepository -> UpdateCodeRepository -> Bool
(UpdateCodeRepository -> UpdateCodeRepository -> Bool)
-> (UpdateCodeRepository -> UpdateCodeRepository -> Bool)
-> Eq UpdateCodeRepository
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateCodeRepository -> UpdateCodeRepository -> Bool
$c/= :: UpdateCodeRepository -> UpdateCodeRepository -> Bool
== :: UpdateCodeRepository -> UpdateCodeRepository -> Bool
$c== :: UpdateCodeRepository -> UpdateCodeRepository -> Bool
Prelude.Eq, ReadPrec [UpdateCodeRepository]
ReadPrec UpdateCodeRepository
Int -> ReadS UpdateCodeRepository
ReadS [UpdateCodeRepository]
(Int -> ReadS UpdateCodeRepository)
-> ReadS [UpdateCodeRepository]
-> ReadPrec UpdateCodeRepository
-> ReadPrec [UpdateCodeRepository]
-> Read UpdateCodeRepository
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateCodeRepository]
$creadListPrec :: ReadPrec [UpdateCodeRepository]
readPrec :: ReadPrec UpdateCodeRepository
$creadPrec :: ReadPrec UpdateCodeRepository
readList :: ReadS [UpdateCodeRepository]
$creadList :: ReadS [UpdateCodeRepository]
readsPrec :: Int -> ReadS UpdateCodeRepository
$creadsPrec :: Int -> ReadS UpdateCodeRepository
Prelude.Read, Int -> UpdateCodeRepository -> ShowS
[UpdateCodeRepository] -> ShowS
UpdateCodeRepository -> String
(Int -> UpdateCodeRepository -> ShowS)
-> (UpdateCodeRepository -> String)
-> ([UpdateCodeRepository] -> ShowS)
-> Show UpdateCodeRepository
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateCodeRepository] -> ShowS
$cshowList :: [UpdateCodeRepository] -> ShowS
show :: UpdateCodeRepository -> String
$cshow :: UpdateCodeRepository -> String
showsPrec :: Int -> UpdateCodeRepository -> ShowS
$cshowsPrec :: Int -> UpdateCodeRepository -> ShowS
Prelude.Show, (forall x. UpdateCodeRepository -> Rep UpdateCodeRepository x)
-> (forall x. Rep UpdateCodeRepository x -> UpdateCodeRepository)
-> Generic UpdateCodeRepository
forall x. Rep UpdateCodeRepository x -> UpdateCodeRepository
forall x. UpdateCodeRepository -> Rep UpdateCodeRepository x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateCodeRepository x -> UpdateCodeRepository
$cfrom :: forall x. UpdateCodeRepository -> Rep UpdateCodeRepository x
Prelude.Generic)

-- |
-- Create a value of 'UpdateCodeRepository' 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:
--
-- 'gitConfig', 'updateCodeRepository_gitConfig' - The configuration of the git repository, including the URL and the
-- Amazon Resource Name (ARN) of the Amazon Web Services Secrets Manager
-- secret that contains the credentials used to access the repository. The
-- secret must have a staging label of @AWSCURRENT@ and must be in the
-- following format:
--
-- @{\"username\": UserName, \"password\": Password}@
--
-- 'codeRepositoryName', 'updateCodeRepository_codeRepositoryName' - The name of the Git repository to update.
newUpdateCodeRepository ::
  -- | 'codeRepositoryName'
  Prelude.Text ->
  UpdateCodeRepository
newUpdateCodeRepository :: Text -> UpdateCodeRepository
newUpdateCodeRepository Text
pCodeRepositoryName_ =
  UpdateCodeRepository' :: Maybe GitConfigForUpdate -> Text -> UpdateCodeRepository
UpdateCodeRepository'
    { $sel:gitConfig:UpdateCodeRepository' :: Maybe GitConfigForUpdate
gitConfig = Maybe GitConfigForUpdate
forall a. Maybe a
Prelude.Nothing,
      $sel:codeRepositoryName:UpdateCodeRepository' :: Text
codeRepositoryName = Text
pCodeRepositoryName_
    }

-- | The configuration of the git repository, including the URL and the
-- Amazon Resource Name (ARN) of the Amazon Web Services Secrets Manager
-- secret that contains the credentials used to access the repository. The
-- secret must have a staging label of @AWSCURRENT@ and must be in the
-- following format:
--
-- @{\"username\": UserName, \"password\": Password}@
updateCodeRepository_gitConfig :: Lens.Lens' UpdateCodeRepository (Prelude.Maybe GitConfigForUpdate)
updateCodeRepository_gitConfig :: (Maybe GitConfigForUpdate -> f (Maybe GitConfigForUpdate))
-> UpdateCodeRepository -> f UpdateCodeRepository
updateCodeRepository_gitConfig = (UpdateCodeRepository -> Maybe GitConfigForUpdate)
-> (UpdateCodeRepository
    -> Maybe GitConfigForUpdate -> UpdateCodeRepository)
-> Lens
     UpdateCodeRepository
     UpdateCodeRepository
     (Maybe GitConfigForUpdate)
     (Maybe GitConfigForUpdate)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateCodeRepository' {Maybe GitConfigForUpdate
gitConfig :: Maybe GitConfigForUpdate
$sel:gitConfig:UpdateCodeRepository' :: UpdateCodeRepository -> Maybe GitConfigForUpdate
gitConfig} -> Maybe GitConfigForUpdate
gitConfig) (\s :: UpdateCodeRepository
s@UpdateCodeRepository' {} Maybe GitConfigForUpdate
a -> UpdateCodeRepository
s {$sel:gitConfig:UpdateCodeRepository' :: Maybe GitConfigForUpdate
gitConfig = Maybe GitConfigForUpdate
a} :: UpdateCodeRepository)

-- | The name of the Git repository to update.
updateCodeRepository_codeRepositoryName :: Lens.Lens' UpdateCodeRepository Prelude.Text
updateCodeRepository_codeRepositoryName :: (Text -> f Text) -> UpdateCodeRepository -> f UpdateCodeRepository
updateCodeRepository_codeRepositoryName = (UpdateCodeRepository -> Text)
-> (UpdateCodeRepository -> Text -> UpdateCodeRepository)
-> Lens UpdateCodeRepository UpdateCodeRepository Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateCodeRepository' {Text
codeRepositoryName :: Text
$sel:codeRepositoryName:UpdateCodeRepository' :: UpdateCodeRepository -> Text
codeRepositoryName} -> Text
codeRepositoryName) (\s :: UpdateCodeRepository
s@UpdateCodeRepository' {} Text
a -> UpdateCodeRepository
s {$sel:codeRepositoryName:UpdateCodeRepository' :: Text
codeRepositoryName = Text
a} :: UpdateCodeRepository)

instance Core.AWSRequest UpdateCodeRepository where
  type
    AWSResponse UpdateCodeRepository =
      UpdateCodeRepositoryResponse
  request :: UpdateCodeRepository -> Request UpdateCodeRepository
request = Service -> UpdateCodeRepository -> Request UpdateCodeRepository
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateCodeRepository
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateCodeRepository)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse UpdateCodeRepository))
-> Logger
-> Service
-> Proxy UpdateCodeRepository
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateCodeRepository)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Int -> Text -> UpdateCodeRepositoryResponse
UpdateCodeRepositoryResponse'
            (Int -> Text -> UpdateCodeRepositoryResponse)
-> Either String Int
-> Either String (Text -> UpdateCodeRepositoryResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
            Either String (Text -> UpdateCodeRepositoryResponse)
-> Either String Text -> Either String UpdateCodeRepositoryResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String Text
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"CodeRepositoryArn")
      )

instance Prelude.Hashable UpdateCodeRepository

instance Prelude.NFData UpdateCodeRepository

instance Core.ToHeaders UpdateCodeRepository where
  toHeaders :: UpdateCodeRepository -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateCodeRepository -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"SageMaker.UpdateCodeRepository" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON UpdateCodeRepository where
  toJSON :: UpdateCodeRepository -> Value
toJSON UpdateCodeRepository' {Maybe GitConfigForUpdate
Text
codeRepositoryName :: Text
gitConfig :: Maybe GitConfigForUpdate
$sel:codeRepositoryName:UpdateCodeRepository' :: UpdateCodeRepository -> Text
$sel:gitConfig:UpdateCodeRepository' :: UpdateCodeRepository -> Maybe GitConfigForUpdate
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"GitConfig" Text -> GitConfigForUpdate -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (GitConfigForUpdate -> Pair)
-> Maybe GitConfigForUpdate -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe GitConfigForUpdate
gitConfig,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"CodeRepositoryName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
codeRepositoryName)
          ]
      )

instance Core.ToPath UpdateCodeRepository where
  toPath :: UpdateCodeRepository -> ByteString
toPath = ByteString -> UpdateCodeRepository -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery UpdateCodeRepository where
  toQuery :: UpdateCodeRepository -> QueryString
toQuery = QueryString -> UpdateCodeRepository -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newUpdateCodeRepositoryResponse' smart constructor.
data UpdateCodeRepositoryResponse = UpdateCodeRepositoryResponse'
  { -- | The response's http status code.
    UpdateCodeRepositoryResponse -> Int
httpStatus :: Prelude.Int,
    -- | The ARN of the Git repository.
    UpdateCodeRepositoryResponse -> Text
codeRepositoryArn :: Prelude.Text
  }
  deriving (UpdateCodeRepositoryResponse
-> UpdateCodeRepositoryResponse -> Bool
(UpdateCodeRepositoryResponse
 -> UpdateCodeRepositoryResponse -> Bool)
-> (UpdateCodeRepositoryResponse
    -> UpdateCodeRepositoryResponse -> Bool)
-> Eq UpdateCodeRepositoryResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateCodeRepositoryResponse
-> UpdateCodeRepositoryResponse -> Bool
$c/= :: UpdateCodeRepositoryResponse
-> UpdateCodeRepositoryResponse -> Bool
== :: UpdateCodeRepositoryResponse
-> UpdateCodeRepositoryResponse -> Bool
$c== :: UpdateCodeRepositoryResponse
-> UpdateCodeRepositoryResponse -> Bool
Prelude.Eq, ReadPrec [UpdateCodeRepositoryResponse]
ReadPrec UpdateCodeRepositoryResponse
Int -> ReadS UpdateCodeRepositoryResponse
ReadS [UpdateCodeRepositoryResponse]
(Int -> ReadS UpdateCodeRepositoryResponse)
-> ReadS [UpdateCodeRepositoryResponse]
-> ReadPrec UpdateCodeRepositoryResponse
-> ReadPrec [UpdateCodeRepositoryResponse]
-> Read UpdateCodeRepositoryResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateCodeRepositoryResponse]
$creadListPrec :: ReadPrec [UpdateCodeRepositoryResponse]
readPrec :: ReadPrec UpdateCodeRepositoryResponse
$creadPrec :: ReadPrec UpdateCodeRepositoryResponse
readList :: ReadS [UpdateCodeRepositoryResponse]
$creadList :: ReadS [UpdateCodeRepositoryResponse]
readsPrec :: Int -> ReadS UpdateCodeRepositoryResponse
$creadsPrec :: Int -> ReadS UpdateCodeRepositoryResponse
Prelude.Read, Int -> UpdateCodeRepositoryResponse -> ShowS
[UpdateCodeRepositoryResponse] -> ShowS
UpdateCodeRepositoryResponse -> String
(Int -> UpdateCodeRepositoryResponse -> ShowS)
-> (UpdateCodeRepositoryResponse -> String)
-> ([UpdateCodeRepositoryResponse] -> ShowS)
-> Show UpdateCodeRepositoryResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateCodeRepositoryResponse] -> ShowS
$cshowList :: [UpdateCodeRepositoryResponse] -> ShowS
show :: UpdateCodeRepositoryResponse -> String
$cshow :: UpdateCodeRepositoryResponse -> String
showsPrec :: Int -> UpdateCodeRepositoryResponse -> ShowS
$cshowsPrec :: Int -> UpdateCodeRepositoryResponse -> ShowS
Prelude.Show, (forall x.
 UpdateCodeRepositoryResponse -> Rep UpdateCodeRepositoryResponse x)
-> (forall x.
    Rep UpdateCodeRepositoryResponse x -> UpdateCodeRepositoryResponse)
-> Generic UpdateCodeRepositoryResponse
forall x.
Rep UpdateCodeRepositoryResponse x -> UpdateCodeRepositoryResponse
forall x.
UpdateCodeRepositoryResponse -> Rep UpdateCodeRepositoryResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateCodeRepositoryResponse x -> UpdateCodeRepositoryResponse
$cfrom :: forall x.
UpdateCodeRepositoryResponse -> Rep UpdateCodeRepositoryResponse x
Prelude.Generic)

-- |
-- Create a value of 'UpdateCodeRepositoryResponse' 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:
--
-- 'httpStatus', 'updateCodeRepositoryResponse_httpStatus' - The response's http status code.
--
-- 'codeRepositoryArn', 'updateCodeRepositoryResponse_codeRepositoryArn' - The ARN of the Git repository.
newUpdateCodeRepositoryResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'codeRepositoryArn'
  Prelude.Text ->
  UpdateCodeRepositoryResponse
newUpdateCodeRepositoryResponse :: Int -> Text -> UpdateCodeRepositoryResponse
newUpdateCodeRepositoryResponse
  Int
pHttpStatus_
  Text
pCodeRepositoryArn_ =
    UpdateCodeRepositoryResponse' :: Int -> Text -> UpdateCodeRepositoryResponse
UpdateCodeRepositoryResponse'
      { $sel:httpStatus:UpdateCodeRepositoryResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:codeRepositoryArn:UpdateCodeRepositoryResponse' :: Text
codeRepositoryArn = Text
pCodeRepositoryArn_
      }

-- | The response's http status code.
updateCodeRepositoryResponse_httpStatus :: Lens.Lens' UpdateCodeRepositoryResponse Prelude.Int
updateCodeRepositoryResponse_httpStatus :: (Int -> f Int)
-> UpdateCodeRepositoryResponse -> f UpdateCodeRepositoryResponse
updateCodeRepositoryResponse_httpStatus = (UpdateCodeRepositoryResponse -> Int)
-> (UpdateCodeRepositoryResponse
    -> Int -> UpdateCodeRepositoryResponse)
-> Lens
     UpdateCodeRepositoryResponse UpdateCodeRepositoryResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateCodeRepositoryResponse' {Int
httpStatus :: Int
$sel:httpStatus:UpdateCodeRepositoryResponse' :: UpdateCodeRepositoryResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: UpdateCodeRepositoryResponse
s@UpdateCodeRepositoryResponse' {} Int
a -> UpdateCodeRepositoryResponse
s {$sel:httpStatus:UpdateCodeRepositoryResponse' :: Int
httpStatus = Int
a} :: UpdateCodeRepositoryResponse)

-- | The ARN of the Git repository.
updateCodeRepositoryResponse_codeRepositoryArn :: Lens.Lens' UpdateCodeRepositoryResponse Prelude.Text
updateCodeRepositoryResponse_codeRepositoryArn :: (Text -> f Text)
-> UpdateCodeRepositoryResponse -> f UpdateCodeRepositoryResponse
updateCodeRepositoryResponse_codeRepositoryArn = (UpdateCodeRepositoryResponse -> Text)
-> (UpdateCodeRepositoryResponse
    -> Text -> UpdateCodeRepositoryResponse)
-> Lens
     UpdateCodeRepositoryResponse UpdateCodeRepositoryResponse Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateCodeRepositoryResponse' {Text
codeRepositoryArn :: Text
$sel:codeRepositoryArn:UpdateCodeRepositoryResponse' :: UpdateCodeRepositoryResponse -> Text
codeRepositoryArn} -> Text
codeRepositoryArn) (\s :: UpdateCodeRepositoryResponse
s@UpdateCodeRepositoryResponse' {} Text
a -> UpdateCodeRepositoryResponse
s {$sel:codeRepositoryArn:UpdateCodeRepositoryResponse' :: Text
codeRepositoryArn = Text
a} :: UpdateCodeRepositoryResponse)

instance Prelude.NFData UpdateCodeRepositoryResponse