{-# 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.PutFile
-- 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)
--
-- Adds or updates a file in a branch in an AWS CodeCommit repository, and
-- generates a commit for the addition in the specified branch.
module Amazonka.CodeCommit.PutFile
  ( -- * Creating a Request
    PutFile (..),
    newPutFile,

    -- * Request Lenses
    putFile_email,
    putFile_fileMode,
    putFile_parentCommitId,
    putFile_name,
    putFile_commitMessage,
    putFile_repositoryName,
    putFile_branchName,
    putFile_fileContent,
    putFile_filePath,

    -- * Destructuring the Response
    PutFileResponse (..),
    newPutFileResponse,

    -- * Response Lenses
    putFileResponse_httpStatus,
    putFileResponse_commitId,
    putFileResponse_blobId,
    putFileResponse_treeId,
  )
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

-- | /See:/ 'newPutFile' smart constructor.
data PutFile = PutFile'
  { -- | An email address for the person adding or updating the file.
    PutFile -> Maybe Text
email :: Prelude.Maybe Prelude.Text,
    -- | The file mode permissions of the blob. Valid file mode permissions are
    -- listed here.
    PutFile -> Maybe FileModeTypeEnum
fileMode :: Prelude.Maybe FileModeTypeEnum,
    -- | The full commit ID of the head commit in the branch where you want to
    -- add or update the file. If this is an empty repository, no commit ID is
    -- required. If this is not an empty repository, a commit ID is required.
    --
    -- The commit ID must match the ID of the head commit at the time of the
    -- operation. Otherwise, an error occurs, and the file is not added or
    -- updated.
    PutFile -> Maybe Text
parentCommitId :: Prelude.Maybe Prelude.Text,
    -- | The name of the person adding or updating the file. Although it is
    -- optional, a name makes the commit history for your repository more
    -- useful.
    PutFile -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | A message about why this file was added or updated. Although it is
    -- optional, a message makes the commit history for your repository more
    -- useful.
    PutFile -> Maybe Text
commitMessage :: Prelude.Maybe Prelude.Text,
    -- | The name of the repository where you want to add or update the file.
    PutFile -> Text
repositoryName :: Prelude.Text,
    -- | The name of the branch where you want to add or update the file. If this
    -- is an empty repository, this branch is created.
    PutFile -> Text
branchName :: Prelude.Text,
    -- | The content of the file, in binary object format.
    PutFile -> Base64
fileContent :: Core.Base64,
    -- | The name of the file you want to add or update, including the relative
    -- path to the file in the repository.
    --
    -- If the path does not currently exist in the repository, the path is
    -- created as part of adding the file.
    PutFile -> Text
filePath :: Prelude.Text
  }
  deriving (PutFile -> PutFile -> Bool
(PutFile -> PutFile -> Bool)
-> (PutFile -> PutFile -> Bool) -> Eq PutFile
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutFile -> PutFile -> Bool
$c/= :: PutFile -> PutFile -> Bool
== :: PutFile -> PutFile -> Bool
$c== :: PutFile -> PutFile -> Bool
Prelude.Eq, ReadPrec [PutFile]
ReadPrec PutFile
Int -> ReadS PutFile
ReadS [PutFile]
(Int -> ReadS PutFile)
-> ReadS [PutFile]
-> ReadPrec PutFile
-> ReadPrec [PutFile]
-> Read PutFile
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutFile]
$creadListPrec :: ReadPrec [PutFile]
readPrec :: ReadPrec PutFile
$creadPrec :: ReadPrec PutFile
readList :: ReadS [PutFile]
$creadList :: ReadS [PutFile]
readsPrec :: Int -> ReadS PutFile
$creadsPrec :: Int -> ReadS PutFile
Prelude.Read, Int -> PutFile -> ShowS
[PutFile] -> ShowS
PutFile -> String
(Int -> PutFile -> ShowS)
-> (PutFile -> String) -> ([PutFile] -> ShowS) -> Show PutFile
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutFile] -> ShowS
$cshowList :: [PutFile] -> ShowS
show :: PutFile -> String
$cshow :: PutFile -> String
showsPrec :: Int -> PutFile -> ShowS
$cshowsPrec :: Int -> PutFile -> ShowS
Prelude.Show, (forall x. PutFile -> Rep PutFile x)
-> (forall x. Rep PutFile x -> PutFile) -> Generic PutFile
forall x. Rep PutFile x -> PutFile
forall x. PutFile -> Rep PutFile x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutFile x -> PutFile
$cfrom :: forall x. PutFile -> Rep PutFile x
Prelude.Generic)

-- |
-- Create a value of 'PutFile' 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:
--
-- 'email', 'putFile_email' - An email address for the person adding or updating the file.
--
-- 'fileMode', 'putFile_fileMode' - The file mode permissions of the blob. Valid file mode permissions are
-- listed here.
--
-- 'parentCommitId', 'putFile_parentCommitId' - The full commit ID of the head commit in the branch where you want to
-- add or update the file. If this is an empty repository, no commit ID is
-- required. If this is not an empty repository, a commit ID is required.
--
-- The commit ID must match the ID of the head commit at the time of the
-- operation. Otherwise, an error occurs, and the file is not added or
-- updated.
--
-- 'name', 'putFile_name' - The name of the person adding or updating the file. Although it is
-- optional, a name makes the commit history for your repository more
-- useful.
--
-- 'commitMessage', 'putFile_commitMessage' - A message about why this file was added or updated. Although it is
-- optional, a message makes the commit history for your repository more
-- useful.
--
-- 'repositoryName', 'putFile_repositoryName' - The name of the repository where you want to add or update the file.
--
-- 'branchName', 'putFile_branchName' - The name of the branch where you want to add or update the file. If this
-- is an empty repository, this branch is created.
--
-- 'fileContent', 'putFile_fileContent' - The content of the file, in binary object format.--
-- -- /Note:/ This 'Lens' automatically encodes and decodes Base64 data.
-- -- The underlying isomorphism will encode to Base64 representation during
-- -- serialisation, and decode from Base64 representation during deserialisation.
-- -- This 'Lens' accepts and returns only raw unencoded data.
--
-- 'filePath', 'putFile_filePath' - The name of the file you want to add or update, including the relative
-- path to the file in the repository.
--
-- If the path does not currently exist in the repository, the path is
-- created as part of adding the file.
newPutFile ::
  -- | 'repositoryName'
  Prelude.Text ->
  -- | 'branchName'
  Prelude.Text ->
  -- | 'fileContent'
  Prelude.ByteString ->
  -- | 'filePath'
  Prelude.Text ->
  PutFile
newPutFile :: Text -> Text -> ByteString -> Text -> PutFile
newPutFile
  Text
pRepositoryName_
  Text
pBranchName_
  ByteString
pFileContent_
  Text
pFilePath_ =
    PutFile' :: Maybe Text
-> Maybe FileModeTypeEnum
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Text
-> Text
-> Base64
-> Text
-> PutFile
PutFile'
      { $sel:email:PutFile' :: Maybe Text
email = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:fileMode:PutFile' :: Maybe FileModeTypeEnum
fileMode = Maybe FileModeTypeEnum
forall a. Maybe a
Prelude.Nothing,
        $sel:parentCommitId:PutFile' :: Maybe Text
parentCommitId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:name:PutFile' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:commitMessage:PutFile' :: Maybe Text
commitMessage = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:repositoryName:PutFile' :: Text
repositoryName = Text
pRepositoryName_,
        $sel:branchName:PutFile' :: Text
branchName = Text
pBranchName_,
        $sel:fileContent:PutFile' :: Base64
fileContent = Tagged ByteString (Identity ByteString)
-> Tagged Base64 (Identity Base64)
Iso' Base64 ByteString
Core._Base64 (Tagged ByteString (Identity ByteString)
 -> Tagged Base64 (Identity Base64))
-> ByteString -> Base64
forall t b. AReview t b -> b -> t
Lens.# ByteString
pFileContent_,
        $sel:filePath:PutFile' :: Text
filePath = Text
pFilePath_
      }

-- | An email address for the person adding or updating the file.
putFile_email :: Lens.Lens' PutFile (Prelude.Maybe Prelude.Text)
putFile_email :: (Maybe Text -> f (Maybe Text)) -> PutFile -> f PutFile
putFile_email = (PutFile -> Maybe Text)
-> (PutFile -> Maybe Text -> PutFile)
-> Lens PutFile PutFile (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutFile' {Maybe Text
email :: Maybe Text
$sel:email:PutFile' :: PutFile -> Maybe Text
email} -> Maybe Text
email) (\s :: PutFile
s@PutFile' {} Maybe Text
a -> PutFile
s {$sel:email:PutFile' :: Maybe Text
email = Maybe Text
a} :: PutFile)

-- | The file mode permissions of the blob. Valid file mode permissions are
-- listed here.
putFile_fileMode :: Lens.Lens' PutFile (Prelude.Maybe FileModeTypeEnum)
putFile_fileMode :: (Maybe FileModeTypeEnum -> f (Maybe FileModeTypeEnum))
-> PutFile -> f PutFile
putFile_fileMode = (PutFile -> Maybe FileModeTypeEnum)
-> (PutFile -> Maybe FileModeTypeEnum -> PutFile)
-> Lens
     PutFile PutFile (Maybe FileModeTypeEnum) (Maybe FileModeTypeEnum)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutFile' {Maybe FileModeTypeEnum
fileMode :: Maybe FileModeTypeEnum
$sel:fileMode:PutFile' :: PutFile -> Maybe FileModeTypeEnum
fileMode} -> Maybe FileModeTypeEnum
fileMode) (\s :: PutFile
s@PutFile' {} Maybe FileModeTypeEnum
a -> PutFile
s {$sel:fileMode:PutFile' :: Maybe FileModeTypeEnum
fileMode = Maybe FileModeTypeEnum
a} :: PutFile)

-- | The full commit ID of the head commit in the branch where you want to
-- add or update the file. If this is an empty repository, no commit ID is
-- required. If this is not an empty repository, a commit ID is required.
--
-- The commit ID must match the ID of the head commit at the time of the
-- operation. Otherwise, an error occurs, and the file is not added or
-- updated.
putFile_parentCommitId :: Lens.Lens' PutFile (Prelude.Maybe Prelude.Text)
putFile_parentCommitId :: (Maybe Text -> f (Maybe Text)) -> PutFile -> f PutFile
putFile_parentCommitId = (PutFile -> Maybe Text)
-> (PutFile -> Maybe Text -> PutFile)
-> Lens PutFile PutFile (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutFile' {Maybe Text
parentCommitId :: Maybe Text
$sel:parentCommitId:PutFile' :: PutFile -> Maybe Text
parentCommitId} -> Maybe Text
parentCommitId) (\s :: PutFile
s@PutFile' {} Maybe Text
a -> PutFile
s {$sel:parentCommitId:PutFile' :: Maybe Text
parentCommitId = Maybe Text
a} :: PutFile)

-- | The name of the person adding or updating the file. Although it is
-- optional, a name makes the commit history for your repository more
-- useful.
putFile_name :: Lens.Lens' PutFile (Prelude.Maybe Prelude.Text)
putFile_name :: (Maybe Text -> f (Maybe Text)) -> PutFile -> f PutFile
putFile_name = (PutFile -> Maybe Text)
-> (PutFile -> Maybe Text -> PutFile)
-> Lens PutFile PutFile (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutFile' {Maybe Text
name :: Maybe Text
$sel:name:PutFile' :: PutFile -> Maybe Text
name} -> Maybe Text
name) (\s :: PutFile
s@PutFile' {} Maybe Text
a -> PutFile
s {$sel:name:PutFile' :: Maybe Text
name = Maybe Text
a} :: PutFile)

-- | A message about why this file was added or updated. Although it is
-- optional, a message makes the commit history for your repository more
-- useful.
putFile_commitMessage :: Lens.Lens' PutFile (Prelude.Maybe Prelude.Text)
putFile_commitMessage :: (Maybe Text -> f (Maybe Text)) -> PutFile -> f PutFile
putFile_commitMessage = (PutFile -> Maybe Text)
-> (PutFile -> Maybe Text -> PutFile)
-> Lens PutFile PutFile (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutFile' {Maybe Text
commitMessage :: Maybe Text
$sel:commitMessage:PutFile' :: PutFile -> Maybe Text
commitMessage} -> Maybe Text
commitMessage) (\s :: PutFile
s@PutFile' {} Maybe Text
a -> PutFile
s {$sel:commitMessage:PutFile' :: Maybe Text
commitMessage = Maybe Text
a} :: PutFile)

-- | The name of the repository where you want to add or update the file.
putFile_repositoryName :: Lens.Lens' PutFile Prelude.Text
putFile_repositoryName :: (Text -> f Text) -> PutFile -> f PutFile
putFile_repositoryName = (PutFile -> Text)
-> (PutFile -> Text -> PutFile) -> Lens PutFile PutFile Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutFile' {Text
repositoryName :: Text
$sel:repositoryName:PutFile' :: PutFile -> Text
repositoryName} -> Text
repositoryName) (\s :: PutFile
s@PutFile' {} Text
a -> PutFile
s {$sel:repositoryName:PutFile' :: Text
repositoryName = Text
a} :: PutFile)

-- | The name of the branch where you want to add or update the file. If this
-- is an empty repository, this branch is created.
putFile_branchName :: Lens.Lens' PutFile Prelude.Text
putFile_branchName :: (Text -> f Text) -> PutFile -> f PutFile
putFile_branchName = (PutFile -> Text)
-> (PutFile -> Text -> PutFile) -> Lens PutFile PutFile Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutFile' {Text
branchName :: Text
$sel:branchName:PutFile' :: PutFile -> Text
branchName} -> Text
branchName) (\s :: PutFile
s@PutFile' {} Text
a -> PutFile
s {$sel:branchName:PutFile' :: Text
branchName = Text
a} :: PutFile)

-- | The content of the file, in binary object format.--
-- -- /Note:/ This 'Lens' automatically encodes and decodes Base64 data.
-- -- The underlying isomorphism will encode to Base64 representation during
-- -- serialisation, and decode from Base64 representation during deserialisation.
-- -- This 'Lens' accepts and returns only raw unencoded data.
putFile_fileContent :: Lens.Lens' PutFile Prelude.ByteString
putFile_fileContent :: (ByteString -> f ByteString) -> PutFile -> f PutFile
putFile_fileContent = (PutFile -> Base64)
-> (PutFile -> Base64 -> PutFile)
-> Lens PutFile PutFile Base64 Base64
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutFile' {Base64
fileContent :: Base64
$sel:fileContent:PutFile' :: PutFile -> Base64
fileContent} -> Base64
fileContent) (\s :: PutFile
s@PutFile' {} Base64
a -> PutFile
s {$sel:fileContent:PutFile' :: Base64
fileContent = Base64
a} :: PutFile) ((Base64 -> f Base64) -> PutFile -> f PutFile)
-> ((ByteString -> f ByteString) -> Base64 -> f Base64)
-> (ByteString -> f ByteString)
-> PutFile
-> f PutFile
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (ByteString -> f ByteString) -> Base64 -> f Base64
Iso' Base64 ByteString
Core._Base64

-- | The name of the file you want to add or update, including the relative
-- path to the file in the repository.
--
-- If the path does not currently exist in the repository, the path is
-- created as part of adding the file.
putFile_filePath :: Lens.Lens' PutFile Prelude.Text
putFile_filePath :: (Text -> f Text) -> PutFile -> f PutFile
putFile_filePath = (PutFile -> Text)
-> (PutFile -> Text -> PutFile) -> Lens PutFile PutFile Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutFile' {Text
filePath :: Text
$sel:filePath:PutFile' :: PutFile -> Text
filePath} -> Text
filePath) (\s :: PutFile
s@PutFile' {} Text
a -> PutFile
s {$sel:filePath:PutFile' :: Text
filePath = Text
a} :: PutFile)

instance Core.AWSRequest PutFile where
  type AWSResponse PutFile = PutFileResponse
  request :: PutFile -> Request PutFile
request = Service -> PutFile -> Request PutFile
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy PutFile
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutFile)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse PutFile))
-> Logger
-> Service
-> Proxy PutFile
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PutFile)))
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 -> Text -> Text -> PutFileResponse
PutFileResponse'
            (Int -> Text -> Text -> Text -> PutFileResponse)
-> Either String Int
-> Either String (Text -> Text -> Text -> PutFileResponse)
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 -> Text -> Text -> PutFileResponse)
-> Either String Text
-> Either String (Text -> Text -> PutFileResponse)
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
"commitId")
            Either String (Text -> Text -> PutFileResponse)
-> Either String Text -> Either String (Text -> PutFileResponse)
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
"blobId")
            Either String (Text -> PutFileResponse)
-> Either String Text -> Either String PutFileResponse
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
"treeId")
      )

instance Prelude.Hashable PutFile

instance Prelude.NFData PutFile

instance Core.ToHeaders PutFile where
  toHeaders :: PutFile -> ResponseHeaders
toHeaders =
    ResponseHeaders -> PutFile -> 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
"CodeCommit_20150413.PutFile" ::
                          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 PutFile where
  toJSON :: PutFile -> Value
toJSON PutFile' {Maybe Text
Maybe FileModeTypeEnum
Text
Base64
filePath :: Text
fileContent :: Base64
branchName :: Text
repositoryName :: Text
commitMessage :: Maybe Text
name :: Maybe Text
parentCommitId :: Maybe Text
fileMode :: Maybe FileModeTypeEnum
email :: Maybe Text
$sel:filePath:PutFile' :: PutFile -> Text
$sel:fileContent:PutFile' :: PutFile -> Base64
$sel:branchName:PutFile' :: PutFile -> Text
$sel:repositoryName:PutFile' :: PutFile -> Text
$sel:commitMessage:PutFile' :: PutFile -> Maybe Text
$sel:name:PutFile' :: PutFile -> Maybe Text
$sel:parentCommitId:PutFile' :: PutFile -> Maybe Text
$sel:fileMode:PutFile' :: PutFile -> Maybe FileModeTypeEnum
$sel:email:PutFile' :: PutFile -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"email" 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
email,
            (Text
"fileMode" Text -> FileModeTypeEnum -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (FileModeTypeEnum -> Pair) -> Maybe FileModeTypeEnum -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe FileModeTypeEnum
fileMode,
            (Text
"parentCommitId" 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
parentCommitId,
            (Text
"name" 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
name,
            (Text
"commitMessage" 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
commitMessage,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"repositoryName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
repositoryName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"branchName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
branchName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"fileContent" Text -> Base64 -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Base64
fileContent),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"filePath" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
filePath)
          ]
      )

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

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

-- | /See:/ 'newPutFileResponse' smart constructor.
data PutFileResponse = PutFileResponse'
  { -- | The response's http status code.
    PutFileResponse -> Int
httpStatus :: Prelude.Int,
    -- | The full SHA ID of the commit that contains this file change.
    PutFileResponse -> Text
commitId :: Prelude.Text,
    -- | The ID of the blob, which is its SHA-1 pointer.
    PutFileResponse -> Text
blobId :: Prelude.Text,
    -- | The full SHA-1 pointer of the tree information for the commit that
    -- contains this file change.
    PutFileResponse -> Text
treeId :: Prelude.Text
  }
  deriving (PutFileResponse -> PutFileResponse -> Bool
(PutFileResponse -> PutFileResponse -> Bool)
-> (PutFileResponse -> PutFileResponse -> Bool)
-> Eq PutFileResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutFileResponse -> PutFileResponse -> Bool
$c/= :: PutFileResponse -> PutFileResponse -> Bool
== :: PutFileResponse -> PutFileResponse -> Bool
$c== :: PutFileResponse -> PutFileResponse -> Bool
Prelude.Eq, ReadPrec [PutFileResponse]
ReadPrec PutFileResponse
Int -> ReadS PutFileResponse
ReadS [PutFileResponse]
(Int -> ReadS PutFileResponse)
-> ReadS [PutFileResponse]
-> ReadPrec PutFileResponse
-> ReadPrec [PutFileResponse]
-> Read PutFileResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutFileResponse]
$creadListPrec :: ReadPrec [PutFileResponse]
readPrec :: ReadPrec PutFileResponse
$creadPrec :: ReadPrec PutFileResponse
readList :: ReadS [PutFileResponse]
$creadList :: ReadS [PutFileResponse]
readsPrec :: Int -> ReadS PutFileResponse
$creadsPrec :: Int -> ReadS PutFileResponse
Prelude.Read, Int -> PutFileResponse -> ShowS
[PutFileResponse] -> ShowS
PutFileResponse -> String
(Int -> PutFileResponse -> ShowS)
-> (PutFileResponse -> String)
-> ([PutFileResponse] -> ShowS)
-> Show PutFileResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutFileResponse] -> ShowS
$cshowList :: [PutFileResponse] -> ShowS
show :: PutFileResponse -> String
$cshow :: PutFileResponse -> String
showsPrec :: Int -> PutFileResponse -> ShowS
$cshowsPrec :: Int -> PutFileResponse -> ShowS
Prelude.Show, (forall x. PutFileResponse -> Rep PutFileResponse x)
-> (forall x. Rep PutFileResponse x -> PutFileResponse)
-> Generic PutFileResponse
forall x. Rep PutFileResponse x -> PutFileResponse
forall x. PutFileResponse -> Rep PutFileResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutFileResponse x -> PutFileResponse
$cfrom :: forall x. PutFileResponse -> Rep PutFileResponse x
Prelude.Generic)

-- |
-- Create a value of 'PutFileResponse' 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', 'putFileResponse_httpStatus' - The response's http status code.
--
-- 'commitId', 'putFileResponse_commitId' - The full SHA ID of the commit that contains this file change.
--
-- 'blobId', 'putFileResponse_blobId' - The ID of the blob, which is its SHA-1 pointer.
--
-- 'treeId', 'putFileResponse_treeId' - The full SHA-1 pointer of the tree information for the commit that
-- contains this file change.
newPutFileResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'commitId'
  Prelude.Text ->
  -- | 'blobId'
  Prelude.Text ->
  -- | 'treeId'
  Prelude.Text ->
  PutFileResponse
newPutFileResponse :: Int -> Text -> Text -> Text -> PutFileResponse
newPutFileResponse
  Int
pHttpStatus_
  Text
pCommitId_
  Text
pBlobId_
  Text
pTreeId_ =
    PutFileResponse' :: Int -> Text -> Text -> Text -> PutFileResponse
PutFileResponse'
      { $sel:httpStatus:PutFileResponse' :: Int
httpStatus = Int
pHttpStatus_,
        $sel:commitId:PutFileResponse' :: Text
commitId = Text
pCommitId_,
        $sel:blobId:PutFileResponse' :: Text
blobId = Text
pBlobId_,
        $sel:treeId:PutFileResponse' :: Text
treeId = Text
pTreeId_
      }

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

-- | The full SHA ID of the commit that contains this file change.
putFileResponse_commitId :: Lens.Lens' PutFileResponse Prelude.Text
putFileResponse_commitId :: (Text -> f Text) -> PutFileResponse -> f PutFileResponse
putFileResponse_commitId = (PutFileResponse -> Text)
-> (PutFileResponse -> Text -> PutFileResponse)
-> Lens PutFileResponse PutFileResponse Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutFileResponse' {Text
commitId :: Text
$sel:commitId:PutFileResponse' :: PutFileResponse -> Text
commitId} -> Text
commitId) (\s :: PutFileResponse
s@PutFileResponse' {} Text
a -> PutFileResponse
s {$sel:commitId:PutFileResponse' :: Text
commitId = Text
a} :: PutFileResponse)

-- | The ID of the blob, which is its SHA-1 pointer.
putFileResponse_blobId :: Lens.Lens' PutFileResponse Prelude.Text
putFileResponse_blobId :: (Text -> f Text) -> PutFileResponse -> f PutFileResponse
putFileResponse_blobId = (PutFileResponse -> Text)
-> (PutFileResponse -> Text -> PutFileResponse)
-> Lens PutFileResponse PutFileResponse Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutFileResponse' {Text
blobId :: Text
$sel:blobId:PutFileResponse' :: PutFileResponse -> Text
blobId} -> Text
blobId) (\s :: PutFileResponse
s@PutFileResponse' {} Text
a -> PutFileResponse
s {$sel:blobId:PutFileResponse' :: Text
blobId = Text
a} :: PutFileResponse)

-- | The full SHA-1 pointer of the tree information for the commit that
-- contains this file change.
putFileResponse_treeId :: Lens.Lens' PutFileResponse Prelude.Text
putFileResponse_treeId :: (Text -> f Text) -> PutFileResponse -> f PutFileResponse
putFileResponse_treeId = (PutFileResponse -> Text)
-> (PutFileResponse -> Text -> PutFileResponse)
-> Lens PutFileResponse PutFileResponse Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutFileResponse' {Text
treeId :: Text
$sel:treeId:PutFileResponse' :: PutFileResponse -> Text
treeId} -> Text
treeId) (\s :: PutFileResponse
s@PutFileResponse' {} Text
a -> PutFileResponse
s {$sel:treeId:PutFileResponse' :: Text
treeId = Text
a} :: PutFileResponse)

instance Prelude.NFData PutFileResponse