openSUSE / docserv

A server for building and publishing documentation with DAPS
https://opensuse.github.io/docserv/
GNU General Public License v3.0
4 stars 3 forks source link

Ideas for a more useful API #219

Open ghost opened 5 years ago

ghost commented 5 years ago

The following is just a draft for what kind of functionality we should have in the API. It lists the URL first (e.g. / or /state) and then gives some fill-out-the-blanks idea of what the response should look like.

/
-> HTML info page

/state

{
  'data generation time': '21218298',
  'state': 'idle'|'working'|'error'
}

/system

{
  'data generation time': '21218298',
  'disk': { 'total': '80G', 'used': '70G', 'free': '10G' },
  'memory': { 'total': '20G', 'used': '10G', 'free': '10G' },
  'cpu': { 'cores': '8', 'load': '80%' },
}

/caches [information may need to be generated ahead of time, to avoid timeouts]

{
  'data generation time': '21218298',
  '/tmp': { 'dirs': 80, space: '3G' },
  '/data/docserv/docserv/tmp-repos': { 'dirs': 5, space: '6G' },
  '/data/docserv/repocache': { 'dirs': 10, space: '4G' },
  '/var/cache/docserv': { 'dirs': 2, space: '10M' }
}

/containers

{
  'data generation time': '21218298',
  '2897384' : { name: 'awesome_freud', image: 'opensuse-leap-42.3-sbp', uptime: '45m' },
  '1299420' : { name: 'merry_fraud', image: 'opensuse-leap-42.3-sbp', uptime: '1m' }
}

/targets

['target-a', 'target-b']

/products

{
'sbp': {'all': ['en-us']},
'sles': {'15-SP1': ['ar-ar','en-us'], '15-GA': ['en-us','fr-fr']},
...
}

/queue

{

- 1 preparation
- 2 build
- 3 cleanup
- everything that is done for more than one day is removed

}

/log

{
- all products built, with build date & last commit
- needs to be kept as JSON file separate from queue
}

/submit
-> accepts BIs (with user name & password)
-> returns BI ID, can be used to check current state/log of a BI

/register
-> allows users to register, needs admin token
tomschr commented 5 years ago

Just my 2¢, but... don't forget to version the API.

I guess, i probably makes sense to read the thread on SO about Best practices and guidelines for designing an API and the YouTube video about How To Design A Good API and Why it Matters.