Git Service API

Git 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 -.

GET http://git.agilestacks.com/api/v1/repositories/agilestacks/my-k8s-template-2/blob/README?ref=master
Requestsexample 1
Headers
X-API-Secret: git-api-secret
Responses200400404403
Headers
Content-Type: application/octet-stream
This response has no content.
This response has no content.
This response has no content.

Retrieve Repository content
GET/repositories/{repositoryId}/blob/{path}{?ref}

Only files can be retrieved. Attempt to retrieve directory will result in 400 Bad Request.

URI Parameters
HideShow
repositoryId
string (required) Example: agilestacks/my-k8s-template-2

ID of the Repository

path
string (required) Example: README

file path to retrieve

ref
string (optional) Example: master

branch, tag, or ref to retrieve from


GET http://git.agilestacks.com/api/v1/repositories/agilestacks/my-k8s-template-2/log?ref=master
Requestsexample 1
Headers
X-API-Secret: git-api-secret
Responses200400404403
Headers
Content-Type: text/plain; charset=utf-8
Body
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 outline
This response has no content.
This response has no content.
This response has no content.

Retrieve Repository Git Log
GET/repositories/{repositoryId}/log{?ref}

URI Parameters
HideShow
repositoryId
string (required) Example: agilestacks/my-k8s-template-2

ID of the Repository

ref
string (optional) Example: master

branch, tag, ref, or commit hash to retrieve log of


GET http://git.agilestacks.com/api/v1/repositories/agilestacks/my-k8s-template-2/status?ref=master
Requestsexample 1
Headers
X-API-Secret: git-api-secret
Responses200400404403409
Headers
Content-Type: application/json; charset=utf-8
Body
{
  "commit": "8d5787cbf266b6d64e12ee5b92aaf2b1cbe95090",
  "ref": "refs/heads/master",
  "date": "2018-10-29T12:27:04+00:00",
  "author": "Automation Hub <hub@agilestacks.io>",
  "subject": "Manifests"
}
This response has no content.
This response has no content.
This response has no content.
Headers
Content-Type: application/json; charset=utf-8
Body
{
  "error": "Ref <ref> refer to multiple refs ..."
}

Retrieve Repository status
GET/repositories/{repositoryId}/status{?ref}

URI Parameters
HideShow
repositoryId
string (required) Example: agilestacks/my-k8s-template-2

ID of the Repository

ref
string (optional) Example: master

branch, tag, ref, or commit hash to retrieve status of


PUT http://git.agilestacks.com/api/v1/repositories/agilestacks/my-k8s-template-2
Requestsexample 1
Headers
Content-Type: application/json; charset=utf-8
X-API-Secret: git-api-secret
Body
{
  "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"
}
Responses201403400500502504
This response has no content.
This response has no content.
Headers
Content-Type: application/json; charset=utf-8
Body
{
  "error": "Error parse JSON input"
}
This response has no content.
This response has no content.
This response has no content.

Create Repository
PUT/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.

URI Parameters
HideShow
repositoryId
string (required) Example: agilestacks/my-k8s-template-2

ID of the Repository


PUT http://git.agilestacks.com/api/v1/repositories/agilestacks/my-k8s-template-2/commit/file/path?message=log entry?mode=0755?ref=master
Requestsexample 1
Headers
X-API-Secret: git-api-secret
Body
file content
Responses204404403500502504
This response has no content.
This response has no content.
This response has no content.
This response has no content.
This response has no content.
This response has no content.

Upload file
PUT/repositories/{repositoryId}/commit/file/path{?message}{?mode}{?ref}

Upload a single file and commit to the repository.

URI Parameters
HideShow
repositoryId
string (required) Example: agilestacks/my-k8s-template-2

ID of the Repository

message
string (optional) Example: log entry

Git commit log message

mode
string (optional) Example: 0755

File mode in octal

ref
string (optional) Example: master

branch to add file to


POST http://git.agilestacks.com/api/v1/repositories/agilestacks/my-k8s-template-2/commit?message=log entry?ref=master
Requestsexample 1
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--
Responses204404403500502504
This response has no content.
This response has no content.
This response has no content.
This response has no content.
This response has no content.
This response has no content.

Upload files
POST/repositories/{repositoryId}/commit{?message}{?ref}

Upload multiple files and commit to the repository.

URI Parameters
HideShow
repositoryId
string (required) Example: agilestacks/my-k8s-template-2

ID of the Repository

message
string (optional) Example: log entry

Git commit log message

ref
string (optional) Example: master

branch to add files to


POST http://git.agilestacks.com/api/v1/repositories/agilestacks/my-k8s-template-2/subtrees?ref=master
Requestsexample 1
Headers
Content-Type: application/json; charset=utf-8
X-API-Secret: git-api-secret
Body
{
  "subtrees": [
    {
      "prefix": "components/pgweb",
      "remote": "git@github.com:agilestacks/components.git",
      "ref": "distribution",
      "splitPrefix": "pgweb",
      "branch": "split/pgweb",
      "squash": true
    }
  ]
}
Responses204404403500502504
This response has no content.
This response has no content.
This response has no content.
This response has no content.
This response has no content.
This response has no content.

Add Git subtrees
POST/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.

URI Parameters
HideShow
repositoryId
string (required) Example: agilestacks/my-k8s-template-2

ID of the Repository

ref
string (optional) Example: master

branch to add subtree to


DELETE http://git.agilestacks.com/api/v1/repositories/agilestacks/my-k8s-template-2
Requestsexample 1
Headers
X-API-Secret: git-api-secret
Responses204404403502504
This response has no content.
This response has no content.
This response has no content.
This response has no content.
This response has no content.

Delete Repository
DELETE/repositories/{repositoryId}

URI Parameters
HideShow
repositoryId
string (required) Example: agilestacks/my-k8s-template-2

ID of the Repository


Generated by aglio on 25 Aug 2021