{-# 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.CodeCommit.UpdateRepositoryName
-- 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)
--
-- Renames a repository. The repository name must be unique across the
-- calling AWS account. Repository names are limited to 100 alphanumeric,
-- dash, and underscore characters, and cannot include certain characters.
-- The suffix .git is prohibited. For more information about the limits on
-- repository names, see
-- <https://docs.aws.amazon.com/codecommit/latest/userguide/limits.html Limits>
-- in the AWS CodeCommit User Guide.
module Amazonka.CodeCommit.UpdateRepositoryName
  ( -- * Creating a Request
    UpdateRepositoryName (..),
    newUpdateRepositoryName,

    -- * Request Lenses
    updateRepositoryName_oldName,
    updateRepositoryName_newName,

    -- * Destructuring the Response
    UpdateRepositoryNameResponse (..),
    newUpdateRepositoryNameResponse,
  )
where

import Amazonka.CodeCommit.Types
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

-- | Represents the input of an update repository description operation.
--
-- /See:/ 'newUpdateRepositoryName' smart constructor.
data UpdateRepositoryName = UpdateRepositoryName'
  { -- | The current name of the repository.
    UpdateRepositoryName -> Text
oldName :: Prelude.Text,
    -- | The new name for the repository.
    UpdateRepositoryName -> Text
newName' :: Prelude.Text
  }
  deriving (UpdateRepositoryName -> UpdateRepositoryName -> Bool
(UpdateRepositoryName -> UpdateRepositoryName -> Bool)
-> (UpdateRepositoryName -> UpdateRepositoryName -> Bool)
-> Eq UpdateRepositoryName
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateRepositoryName -> UpdateRepositoryName -> Bool
$c/= :: UpdateRepositoryName -> UpdateRepositoryName -> Bool
== :: UpdateRepositoryName -> UpdateRepositoryName -> Bool
$c== :: UpdateRepositoryName -> UpdateRepositoryName -> Bool
Prelude.Eq, ReadPrec [UpdateRepositoryName]
ReadPrec UpdateRepositoryName
Int -> ReadS UpdateRepositoryName
ReadS [UpdateRepositoryName]
(Int -> ReadS UpdateRepositoryName)
-> ReadS [UpdateRepositoryName]
-> ReadPrec UpdateRepositoryName
-> ReadPrec [UpdateRepositoryName]
-> Read UpdateRepositoryName
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateRepositoryName]
$creadListPrec :: ReadPrec [UpdateRepositoryName]
readPrec :: ReadPrec UpdateRepositoryName
$creadPrec :: ReadPrec UpdateRepositoryName
readList :: ReadS [UpdateRepositoryName]
$creadList :: ReadS [UpdateRepositoryName]
readsPrec :: Int -> ReadS UpdateRepositoryName
$creadsPrec :: Int -> ReadS UpdateRepositoryName
Prelude.Read, Int -> UpdateRepositoryName -> ShowS
[UpdateRepositoryName] -> ShowS
UpdateRepositoryName -> String
(Int -> UpdateRepositoryName -> ShowS)
-> (UpdateRepositoryName -> String)
-> ([UpdateRepositoryName] -> ShowS)
-> Show UpdateRepositoryName
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateRepositoryName] -> ShowS
$cshowList :: [UpdateRepositoryName] -> ShowS
show :: UpdateRepositoryName -> String
$cshow :: UpdateRepositoryName -> String
showsPrec :: Int -> UpdateRepositoryName -> ShowS
$cshowsPrec :: Int -> UpdateRepositoryName -> ShowS
Prelude.Show, (forall x. UpdateRepositoryName -> Rep UpdateRepositoryName x)
-> (forall x. Rep UpdateRepositoryName x -> UpdateRepositoryName)
-> Generic UpdateRepositoryName
forall x. Rep UpdateRepositoryName x -> UpdateRepositoryName
forall x. UpdateRepositoryName -> Rep UpdateRepositoryName x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateRepositoryName x -> UpdateRepositoryName
$cfrom :: forall x. UpdateRepositoryName -> Rep UpdateRepositoryName x
Prelude.Generic)

-- |
-- Create a value of 'UpdateRepositoryName' 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:
--
-- 'oldName', 'updateRepositoryName_oldName' - The current name of the repository.
--
-- 'newName'', 'updateRepositoryName_newName' - The new name for the repository.
newUpdateRepositoryName ::
  -- | 'oldName'
  Prelude.Text ->
  -- | 'newName''
  Prelude.Text ->
  UpdateRepositoryName
newUpdateRepositoryName :: Text -> Text -> UpdateRepositoryName
newUpdateRepositoryName Text
pOldName_ Text
pNewName_ =
  UpdateRepositoryName' :: Text -> Text -> UpdateRepositoryName
UpdateRepositoryName'
    { $sel:oldName:UpdateRepositoryName' :: Text
oldName = Text
pOldName_,
      $sel:newName':UpdateRepositoryName' :: Text
newName' = Text
pNewName_
    }

-- | The current name of the repository.
updateRepositoryName_oldName :: Lens.Lens' UpdateRepositoryName Prelude.Text
updateRepositoryName_oldName :: (Text -> f Text) -> UpdateRepositoryName -> f UpdateRepositoryName
updateRepositoryName_oldName = (UpdateRepositoryName -> Text)
-> (UpdateRepositoryName -> Text -> UpdateRepositoryName)
-> Lens UpdateRepositoryName UpdateRepositoryName Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRepositoryName' {Text
oldName :: Text
$sel:oldName:UpdateRepositoryName' :: UpdateRepositoryName -> Text
oldName} -> Text
oldName) (\s :: UpdateRepositoryName
s@UpdateRepositoryName' {} Text
a -> UpdateRepositoryName
s {$sel:oldName:UpdateRepositoryName' :: Text
oldName = Text
a} :: UpdateRepositoryName)

-- | The new name for the repository.
updateRepositoryName_newName :: Lens.Lens' UpdateRepositoryName Prelude.Text
updateRepositoryName_newName :: (Text -> f Text) -> UpdateRepositoryName -> f UpdateRepositoryName
updateRepositoryName_newName = (UpdateRepositoryName -> Text)
-> (UpdateRepositoryName -> Text -> UpdateRepositoryName)
-> Lens UpdateRepositoryName UpdateRepositoryName Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRepositoryName' {Text
newName' :: Text
$sel:newName':UpdateRepositoryName' :: UpdateRepositoryName -> Text
newName'} -> Text
newName') (\s :: UpdateRepositoryName
s@UpdateRepositoryName' {} Text
a -> UpdateRepositoryName
s {$sel:newName':UpdateRepositoryName' :: Text
newName' = Text
a} :: UpdateRepositoryName)

instance Core.AWSRequest UpdateRepositoryName where
  type
    AWSResponse UpdateRepositoryName =
      UpdateRepositoryNameResponse
  request :: UpdateRepositoryName -> Request UpdateRepositoryName
request = Service -> UpdateRepositoryName -> Request UpdateRepositoryName
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateRepositoryName
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateRepositoryName)))
response =
    AWSResponse UpdateRepositoryName
-> Logger
-> Service
-> Proxy UpdateRepositoryName
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateRepositoryName)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse UpdateRepositoryName
UpdateRepositoryNameResponse
UpdateRepositoryNameResponse'

instance Prelude.Hashable UpdateRepositoryName

instance Prelude.NFData UpdateRepositoryName

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

instance Core.ToJSON UpdateRepositoryName where
  toJSON :: UpdateRepositoryName -> Value
toJSON UpdateRepositoryName' {Text
newName' :: Text
oldName :: Text
$sel:newName':UpdateRepositoryName' :: UpdateRepositoryName -> Text
$sel:oldName:UpdateRepositoryName' :: UpdateRepositoryName -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"oldName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
oldName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"newName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
newName')
          ]
      )

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

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

-- | /See:/ 'newUpdateRepositoryNameResponse' smart constructor.
data UpdateRepositoryNameResponse = UpdateRepositoryNameResponse'
  {
  }
  deriving (UpdateRepositoryNameResponse
-> UpdateRepositoryNameResponse -> Bool
(UpdateRepositoryNameResponse
 -> UpdateRepositoryNameResponse -> Bool)
-> (UpdateRepositoryNameResponse
    -> UpdateRepositoryNameResponse -> Bool)
-> Eq UpdateRepositoryNameResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateRepositoryNameResponse
-> UpdateRepositoryNameResponse -> Bool
$c/= :: UpdateRepositoryNameResponse
-> UpdateRepositoryNameResponse -> Bool
== :: UpdateRepositoryNameResponse
-> UpdateRepositoryNameResponse -> Bool
$c== :: UpdateRepositoryNameResponse
-> UpdateRepositoryNameResponse -> Bool
Prelude.Eq, ReadPrec [UpdateRepositoryNameResponse]
ReadPrec UpdateRepositoryNameResponse
Int -> ReadS UpdateRepositoryNameResponse
ReadS [UpdateRepositoryNameResponse]
(Int -> ReadS UpdateRepositoryNameResponse)
-> ReadS [UpdateRepositoryNameResponse]
-> ReadPrec UpdateRepositoryNameResponse
-> ReadPrec [UpdateRepositoryNameResponse]
-> Read UpdateRepositoryNameResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateRepositoryNameResponse]
$creadListPrec :: ReadPrec [UpdateRepositoryNameResponse]
readPrec :: ReadPrec UpdateRepositoryNameResponse
$creadPrec :: ReadPrec UpdateRepositoryNameResponse
readList :: ReadS [UpdateRepositoryNameResponse]
$creadList :: ReadS [UpdateRepositoryNameResponse]
readsPrec :: Int -> ReadS UpdateRepositoryNameResponse
$creadsPrec :: Int -> ReadS UpdateRepositoryNameResponse
Prelude.Read, Int -> UpdateRepositoryNameResponse -> ShowS
[UpdateRepositoryNameResponse] -> ShowS
UpdateRepositoryNameResponse -> String
(Int -> UpdateRepositoryNameResponse -> ShowS)
-> (UpdateRepositoryNameResponse -> String)
-> ([UpdateRepositoryNameResponse] -> ShowS)
-> Show UpdateRepositoryNameResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateRepositoryNameResponse] -> ShowS
$cshowList :: [UpdateRepositoryNameResponse] -> ShowS
show :: UpdateRepositoryNameResponse -> String
$cshow :: UpdateRepositoryNameResponse -> String
showsPrec :: Int -> UpdateRepositoryNameResponse -> ShowS
$cshowsPrec :: Int -> UpdateRepositoryNameResponse -> ShowS
Prelude.Show, (forall x.
 UpdateRepositoryNameResponse -> Rep UpdateRepositoryNameResponse x)
-> (forall x.
    Rep UpdateRepositoryNameResponse x -> UpdateRepositoryNameResponse)
-> Generic UpdateRepositoryNameResponse
forall x.
Rep UpdateRepositoryNameResponse x -> UpdateRepositoryNameResponse
forall x.
UpdateRepositoryNameResponse -> Rep UpdateRepositoryNameResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateRepositoryNameResponse x -> UpdateRepositoryNameResponse
$cfrom :: forall x.
UpdateRepositoryNameResponse -> Rep UpdateRepositoryNameResponse x
Prelude.Generic)

-- |
-- Create a value of 'UpdateRepositoryNameResponse' 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.
newUpdateRepositoryNameResponse ::
  UpdateRepositoryNameResponse
newUpdateRepositoryNameResponse :: UpdateRepositoryNameResponse
newUpdateRepositoryNameResponse =
  UpdateRepositoryNameResponse
UpdateRepositoryNameResponse'

instance Prelude.NFData UpdateRepositoryNameResponse