Git Service API
API Endpoint
http://git.agilestacks.com/api/v1Git Service has protected HTTP API to provide access to it’s functions, such as:
-
creating an empty Git repository;
-
creating a Git repository from template: cloning upstream (GitHub) repository or unpacking from an S3 binary blob;
-
uploading files to the repository as commits;
-
performing Git subtree splits to embed sources as subdirectories;
-
retrieving repository log.
Please read design first.
Resource Group ¶
Repository ¶
repositoryId format is <organization>/<template name>-<template id>. Template id is used
by Git SSH and HTTP servers to obtain repository permissions.
SSH key offered by client is used to find matching users. For HTTP protocol Deployment key is
decoded to determine user id. Alternatively HTTP Basic auth username and password is used with
Auth Service to check user login. Then user’ teams are traversed to check for (1) template owner
and (2) teams permissions on the template.
URL names are lowercased, non-alphanumeric characters replaced by dashes -.
Headers
X-API-Secret: git-api-secretHeaders
Content-Type: application/octet-streamRetrieve Repository contentGET/repositories/{repositoryId}/blob/{path}{?ref}
Only files can be retrieved. Attempt to retrieve directory will result in 400 Bad Request.
- repositoryId
string(required) Example: agilestacks/my-k8s-template-2ID of the Repository
- path
string(required) Example: READMEfile path to retrieve
- ref
string(optional) Example: masterbranch, tag, or ref to retrieve from
Headers
X-API-Secret: git-api-secretHeaders
Content-Type: text/plain; charset=utf-8Body
commit 4da13d0749c001bc3257381051a22c139fee7751
Author: Antons Kranga <anton@agilestacks.com>
Date: Wed Aug 2 17:36:54 2017 +0300
Introduced deployment components
commit b22432beb65acc29d688a6bb12184d12d72b81d8
Author: Arkadi Shishlov <arkadi.shishlov@gmail.com>
Date: Tue Aug 1 17:49:45 2017 +0300
Design outlineRetrieve Repository Git LogGET/repositories/{repositoryId}/log{?ref}
- repositoryId
string(required) Example: agilestacks/my-k8s-template-2ID of the Repository
- ref
string(optional) Example: masterbranch, tag, ref, or commit hash to retrieve log of
Headers
X-API-Secret: git-api-secretHeaders
Content-Type: application/json; charset=utf-8Body
{
"commit": "8d5787cbf266b6d64e12ee5b92aaf2b1cbe95090",
"ref": "refs/heads/master",
"date": "2018-10-29T12:27:04+00:00",
"author": "Automation Hub <hub@agilestacks.io>",
"subject": "Manifests"
}Headers
Content-Type: application/json; charset=utf-8Body
{
"error": "Ref <ref> refer to multiple refs ..."
}Retrieve Repository statusGET/repositories/{repositoryId}/status{?ref}
- repositoryId
string(required) Example: agilestacks/my-k8s-template-2ID of the Repository
- ref
string(optional) Example: masterbranch, tag, ref, or commit hash to retrieve status of
Headers
Content-Type: application/json; charset=utf-8
X-API-Secret: git-api-secretBody
{
"remote": "git@github.com:agilestacks/components.git",
"ref": "master",
"squash": false,
"message": "Initial squash",
"archive": "s3://agilestacks/blobs/stack-k8s-aws-1.2.5664.tar.bz2"
}Headers
Content-Type: application/json; charset=utf-8Body
{
"error": "Error parse JSON input"
}Create RepositoryPUT/repositories/{repositoryId}
remote is optional. If supplied the content of the remote repository became root of the new repo.
squash not imlemented deletes history creating a repository with single initial commit. If supplied the message
is used as initial commit message.
archive is optional. If supplied the content of the repository is unpacked from the archive, so it
must be a bare git repo at root of the archive. TAR BZIP2 and GZIP archives are supported. BZIP2 by
default if archive suffix is not gz.
Otherwise an empty repository is initialized.
- repositoryId
string(required) Example: agilestacks/my-k8s-template-2ID of the Repository
Headers
X-API-Secret: git-api-secretBody
file contentUpload filePUT/repositories/{repositoryId}/commit/file/path{?message}{?mode}{?ref}
Upload a single file and commit to the repository.
- repositoryId
string(required) Example: agilestacks/my-k8s-template-2ID of the Repository
- message
string(optional) Example: log entryGit commit log message
- mode
string(optional) Example: 0755File mode in octal
- ref
string(optional) Example: masterbranch to add file to
Headers
X-API-Secret: git-api-secret
Content-Type: multipart/form-data; boundary="boundary"Body
--boundary
Content-Disposition: form-data; name="hub.yaml"; filename="hub.yaml"
Mode: 0755
...
--boundary
Content-Disposition: form-data; name="hub-parameters.yaml"; filename="cloud/hub-parameters.yaml"
...
--boundary--Upload filesPOST/repositories/{repositoryId}/commit{?message}{?ref}
Upload multiple files and commit to the repository.
- repositoryId
string(required) Example: agilestacks/my-k8s-template-2ID of the Repository
- message
string(optional) Example: log entryGit commit log message
- ref
string(optional) Example: masterbranch to add files to
Headers
Content-Type: application/json; charset=utf-8
X-API-Secret: git-api-secretBody
{
"subtrees": [
{
"prefix": "components/pgweb",
"remote": "git@github.com:agilestacks/components.git",
"ref": "distribution",
"splitPrefix": "pgweb",
"branch": "split/pgweb",
"squash": true
}
]
}Add Git subtreesPOST/repositories/{repositoryId}/subtrees{?ref}
Add multiple Git subtrees to the repository. Subtree ref, splitPrefix, and squash are optional.
If no splitPrefix is specified then entire ref (or master) is added under prefix. If splitPrefix
is supplied then it is extracted with git split. squash default is false. If branch is specified
then the extracted subtree is preserved and pushed to the repository under the branch.
- repositoryId
string(required) Example: agilestacks/my-k8s-template-2ID of the Repository
- ref
string(optional) Example: masterbranch to add subtree to
Headers
X-API-Secret: git-api-secretDelete RepositoryDELETE/repositories/{repositoryId}
- repositoryId
string(required) Example: agilestacks/my-k8s-template-2ID of the Repository
Generated by aglio on 25 Aug 2021