bdcs-api-0.1.3: BDCS API Server

Safe HaskellNone
LanguageHaskell2010

BDCS.API.V0

Description

API v0 routes

Synopsis

Documentation

v0ApiServer :: ServerConfig -> Server V0API Source #

Connect the V0API type to all of the handlers

recipesList :: ServerConfig -> Maybe String -> Maybe Int -> Maybe Int -> Handler RecipesListResponse Source #

apiv0blueprintslist List the names of the available blueprints

repoLock
The git repositories ReadWriteLock and Repository object
mbranch
The branch name
 {
     "blueprints": [
         "development",
         "glusterfs",
         "http-server",
         "jboss",
         "kubernetes",
         "octave",
     ],
     "offset": 0,
     "limit": 20,
     "total": 6
 }

recipesInfo :: ServerConfig -> Maybe String -> String -> Handler RecipesInfoResponse Source #

apiv0blueprintsinfo/<recipes> Return the contents of the blueprint, or a list of recipes

repoLock
The git repositories ReadWriteLock and Repository object
mbranch
The branch name
recipes_names
A comma separated list of blueprint names

The errors list may be empty, or may include blueprint-specific errors if there was a problem retrieving it.

{
    "changes": [
        {
            "name": "blueprint-test",
            "changed": true
        },
    ],
    "blueprints": [
        {
            "name": "http-server",
            "description": "An example http server with PHP and MySQL support.",
            "version": "0.0.1",
            "modules": [
                {
                    "name": "httpd",
                    "version": "2.4.*"
                },
                {
                    "name": "mod_auth_kerb",
                    "version": "5.4"
                },
                {
                    "name": "mod_ssl",
                    "version": "2.4.*"
                },
                {
                    "name": "php",
                    "version": "5.4.*"
                },
                {
                    "name": "php-mysql",
                    "version": "5.4.*"
                }
            ],
            "packages": [
                {
                    "name": "tmux",
                    "version": "2.2"
                },
                {
                    "name": "openssh-server",
                    "version": "6.6.*"
                },
                {
                    "name": "rsync",
                    "version": "3.0.*"
                }
            ]
        },
    "errors": ["a-missing-blueprint: Error retrieving a-missing-blueprint.toml"]
}

getRecipeInfo :: GitLock -> Text -> Text -> IO (Either String (Bool, Recipe)) Source #

Get the recipe from the workspace or from git If there is neither workspace or git recipes then an error is returned.

recipesChanges :: ServerConfig -> Maybe String -> String -> Maybe Int -> Maybe Int -> Handler RecipesChangesResponse Source #

apiv0blueprintschanges/<recipes> Return the commit history of the blueprints

repoLock
The git repositories ReadWriteLock and Repository object
mbranch
The branch name
recipes_name
The blueprint name
moffset
The offset from the start of the results. Defaults to 0
mlimit
Limit to the number of results to be returned. Defaults to 20

The changes for each listed blueprint will have offset and limit applied to them. This means that there will be cases where changes will be empty, when offset > total for the blueprint.

If a blueprint commit has been tagged as a new revision the changes will include a revision field set to the revision number. If the commit has not been tagged it will not have this field included.

{
    "blueprints": [
        {
            "name": "nfs-server",
            "changes": [
                {
                    "commit": "97d483e8dd0b178efca9a805e5fd8e722c48ac8e",
                    "time": "Wed,  1 Mar 2017 13:29:37 -0800",
                    "summary": "Recipe nfs-server saved"
                },
                {
                    "commit": "857e1740f983bf033345c3242204af0ed7b81f37",
                    "time": "Wed,  1 Mar 2017 09:28:53 -0800",
                    "summary": "Recipe nfs-server saved",
                    "revision" : 1
                }
            ],
            "total": 2
        },
        {
            "name": "ruby",
            "changes": [
                {
                    "commit": "4b84f072befc3f4debbe1348d6f4b166f7c83d78",
                    "time": "Wed,  1 Mar 2017 13:32:09 -0800",
                    "summary": "Recipe ruby saved"
                },
                {
                    "commit": "85999253c1790367a860a344ea622971b7e0a050",
                    "time": "Wed,  1 Mar 2017 13:31:19 -0800",
                    "summary": "Recipe ruby saved"
                }
            ],
            "total": 2
        }
    ],
    "errors": ["a-missing-recipe: Error retrieving a-missing-blueprint.toml"]
    "offset": 0,
    "limit": 20
}

recipesNew :: ServerConfig -> Maybe String -> Recipe -> Handler APIResponse Source #

POST apiv0blueprintsnew Create or update a blueprint.

repoLock
The git repositories ReadWriteLock and Repository object
mbranch
The branch name
recipe
The blueprint record

The body of the post is a JSON or TOML representation of the blueprint. If Conten-Type is application/json it uses the same format received from apiv0blueprintsinfo<blueprints>, and if it is textx-toml it uses the blueprint's TOML format for the body.

The response for a successful POST is:

{
    "status": true,
    "errors": []
}

recipesDelete :: ServerConfig -> Maybe String -> String -> Handler APIResponse Source #

DELETE apiv0blueprintsdelete/<recipe> Delete the named blueprint from the repository branch

repoLock
The git repositories ReadWriteLock and Repository object
mbranch
The branch name
recipe_name
The blueprint name

The response for a successful DELETE is:

{
    "status": true,
    "errors": []
}

recipesUndo :: ServerConfig -> Maybe String -> String -> String -> Handler APIResponse Source #

POST apiv0blueprintsundo<recipe><commit> Revert a blueprint to a previous commit

repoLock
The git repositories ReadWriteLock and Repository object
mbranch
The branch name
recipe_name
The blueprint name
commit
The commit to revert to

The response for a successful POST is:

{
    "status": true,
    "errors": []
}

recipesWorkspace :: ServerConfig -> Maybe String -> Recipe -> Handler APIResponse Source #

POST apiv0blueprintsworkspace Update the temporary blueprint workspace

repoLock
The git repositories ReadWriteLock and Repository object
mbranch
The branch name
recipe
The blueprint record

The body of the post is the same as blueprintsnew/. For more details on the workspace see BDCS.API.Workspace

The response for a successful POST is:

{
    "status": true,
    "errors": []
}

recipesWorkspaceDelete :: ServerConfig -> Maybe String -> String -> Handler APIResponse Source #

DELETE apiv0blueprintsworkspace/<recipe> Delete the named blueprint from the workspace

repoLock
The git repositories ReadWriteLock and Repository object
mbranch
The branch name
recipe_name
The blueprint name

The response for a successful DELETE is:

{
    "status": true,
    "errors": []
}

recipesTag :: ServerConfig -> Maybe String -> String -> Handler APIResponse Source #

POST apiv0blueprintstag/blueprint Tag the most recent blueprint commit as the next revision

repoLock
The git repositories ReadWriteLock and Repository object
mbranch
The branch name
recipe_name
The blueprint name

If the commit is already tagged it will return False.

The response for a successful POST is:

{
    "status": true,
    "errors": []
}

recipesDiff :: ServerConfig -> Maybe String -> String -> String -> String -> Handler RecipesDiffResponse Source #

apiv0blueprintsdiffblueprintfrom_commit/to_commit Return the diff between the two blueprint commits.

repoLock
The git repositories ReadWriteLock and Repository object
mbranch
The branch name
recipe_name
The blueprint name
from_commit
The older commit to caclulate the difference from, can also be NEWEST
to_commit
The newer commit to calculate the diff. to, can also be NEWEST or WORKSPACE

If there is an error retrieving a commit (eg. it cannot find the hash), it will use HEAD instead and log an error.

In addition to the commit hashes listed by a call to blueprintschanges/<blueprint-name> you can use NEWEST to compare the latest commit, and WORKSPACE to compare it with the current temporary workspace version of the blueprint. eg. to see what the differences are between the current workspace and most recent commit of http-server you would call:

/blueprints/diff/http-server/NEWEST/WORKSPACE

Each entry in the response's diff object contains the old blueprint value and the new one. If old is null and new is set, then it was added. If new is null and old is set, then it was removed. If both are set, then it was changed.

The old/new entries will have the name of the blueprint field that was changed. This can be one of: Name, Description, Version, Module, or Package. The contents for these will be the old/new values for them.

In the example below the description and version were changed. The php module's version was changed, the rsync package was removed, and the vim-enhanced package was added.

# Examples

{
    "diff": [
        {
            "old": {
                "Description": "An example http server with PHP and MySQL support."
            },
            "new": {
                "Description": "Apache HTTP Server"
            }
        },
        {
            "old": {
                "Version": "0.0.1"
            },
            "new": {
                "Version": "0.1.1"
            }
        },
        {
            "old": {
                "Module": {
                    "name": "php",
                    "version": "5.4.*"
                }
            },
            "new": {
                "Module": {
                    "name": "php",
                    "version": "5.6.*"
                }
            }
        },
        {
            "old": null,
            "new": {
                "Package": {
                    "name": "vim-enhanced",
                    "version": "8.0.*"
                }
            }
        },
        {
            "old": {
                "Package": {
                    "name": "rsync",
                    "version": "3.0.*"
                }
            },
            "new": null
        }
    ]
}

recipesDepsolve :: ServerConfig -> Maybe String -> String -> Handler RecipesDepsolveResponse Source #

apiv0blueprintsdepsolve/blueprints Return the blueprint and summary information about all of its modules and packages.

pool
The sqlite connection pool object
repoLock
The git repositories ReadWriteLock and Repository object
mbranch
The branch name
recipe_names
The blueprint names to depsolve, comma-separated if there is more than one

If a workspace version of the blueprint is found it will be used for the depsolve. If there are any errors reading the blueprint, or depsolving it, they will be returned in the errors object.

# Error example

{
    "errors": ["nfs-server.toml is not present on branch master"],
    "blueprints": []
}

A successful result will include 3 items. dependencies will be the NEVRAs of all of the projects needed to satisfy the blueprint's dependencies. modules will be the project NEVRAs for the modules and packages explicitly listed in the blueprint, and blueprint will be a copy of the blueprint that was depsolved.

# Abbreviated successful example

{
    "errors": [],
    "blueprints": [
        {
            "dependencies": [
                {
                    "arch": "x86_64",
                    "epoch": 0,
                    "name": "apr",
                    "release": "3.el7",
                    "version": "1.4.8"
                },
                {
                    "arch": "x86_64",
                    "epoch": 0,
                    "name": "apr-util",
                    "release": "6.el7",
                    "version": "1.5.2"
                },
                ...
            ],
            "modules": [
                {
                    "arch": "x86_64",
                    "epoch": 0,
                    "name": "httpd",
                    "release": "67.el7",
                    "version": "2.4.6"
                },
                {
                    "arch": "x86_64",
                    "epoch": 0,
                    "name": "mod_auth_kerb",
                    "release": "28.el7",
                    "version": "5.4"
                },
                ...
            ],
           "blueprint": {
                "description": "An example http server with PHP and MySQL support.",
                "modules": [
                    {
                        "name": "httpd",
                        "version": "2.4.*"
                    },
                    {
                        "name": "mod_auth_kerb",
                        "version": "5.4"
                    },
                    {
                        "name": "mod_ssl",
                        "version": "2.4.*"
                    },
                    {
                        "name": "php",
                        "version": "5.4.*"
                    },
                    {
                        "name": "php-mysql",
                        "version": "5.4.*"
                    }
                ],
                "name": "http-server",
                "packages": [
                    {
                        "name": "tmux",
                        "version": "2.2"
                    },
                    {
                        "name": "openssh-server",
                        "version": "6.6.*"
                    },
                    {
                        "name": "rsync",
                        "version": "3.0.*"
                    }
                ],
                "version": "0.2.0"
            }
        }
    ]
}

recipesFreeze :: ServerConfig -> Maybe String -> String -> Handler RecipesFreezeResponse Source #

apiv0blueprintsfreeze/blueprints Return the contents of the blueprint with frozen dependencies instead of expressions.

This depsolves the blueprint, and then replaces the modules and packages versions with the EVR found by the depsolve, returning a frozen blueprint.

# Examples

{
    "errors": [],
    "blueprints": [
        {
            "description": "An example http server with PHP and MySQL support.",
            "modules": [
                {
                    "name": "httpd",
                    "version": "2.4.6-67.el7"
                },
                {
                    "name": "mod_auth_kerb",
                    "version": "5.4-28.el7"
                },
                {
                    "name": "mod_ssl",
                    "version": "1:2.4.6-67.el7"
                },
                {
                    "name": "php",
                    "version": "5.4.16-42.el7"
                },
                {
                    "name": "php-mysql",
                    "version": "5.4.16-42.el7"
                }
            ],
            "name": "http-server",
            "packages": [
                {
                    "name": "tmux",
                    "version": "1.8-4.el7"
                },
                {
                    "name": "openssh-server",
                    "version": "7.4p1-11.el7"
                },
                {
                    "name": "rsync",
                    "version": "3.0.9-18.el7"
                }
            ],
            "version": "0.2.0"
        }
    ]
}

projectsList :: ServerConfig -> Maybe Int -> Maybe Int -> Handler ProjectsListResponse Source #

apiv0projectslist Return the list of available projects

# Example

{
    "limit": 20,
    "offset": 0,
    "projects": [
        {
            "description": "389 Directory Server is an LDAPv3 compliant server. ...",
            "homepage": "https://www.port389.org/",
            "name": "389-ds-base",
            "summary": "389 Directory Server (base)",
            "upstream_vcs": "UPSTREAM_VCS"
        },
        }
    ],
    "total": 2117
}

projectsInfo :: ServerConfig -> String -> Handler ProjectsInfoResponse Source #

apiv0projectsinfo/projects Return information about the comma-separated list of projects

# Example

{
  "projects": [
    {
      "builds": [
        {
          "arch": "x86_64",
          "build_config_ref": "BUILD_CONFIG_REF",
          "build_env_ref": "BUILD_ENV_REF",
          "build_time": "2017-03-01T08:39:23",
          "changelog": "- restore incremental backups correctly, files ...",
          "epoch": "2",
          "metadata": {},
          "release": "32.el7",
          "source": {
            "license": "GPLv3+",
            "metadata": {},
            "source_ref": "SOURCE_REF",
            "version": "1.26"
          }
        }
      ],
      "description": "The GNU tar program saves many files ...",
      "homepage": "http://www.gnu.org/software/tar/",
      "name": "tar",
      "summary": "A GNU file archiving program",
      "upstream_vcs": "UPSTREAM_VCS"
    }
  ]
}

projectsDepsolve :: ServerConfig -> String -> Handler ProjectsDepsolveResponse Source #

apiv0projectsdepsolve/projects Return the dependencies of a comma separated list of projects

mkModuleName :: Text -> ModuleName Source #

Make a ModuleName from a string

modulesList :: ServerConfig -> Maybe Int -> Maybe Int -> String -> Handler ModulesListResponse Source #

Special case for listing all the modules Uses SQL offset, limit, and case-insensitive sorting

apiv0moduleslist apiv0moduleslist/module_names Return a list of all of the available modules, filtering by module_names (a comma-separated list). This includes the name and the group_type, which is currently always "rpm".

 {
     "modules": [
       {
         "group_type": "rpm",
         "name": "0ad"
       },
       {
         "group_type": "rpm",
         "name": "0ad-data"
       },
       ....
     ],
     "offset": 0,
     "limit": 20,
     "total": 6
 }

data ModuleInfo Source #

apiv0modulesinfo/module_names Return the module's dependencies, and the information about the module.

{
  "modules": [
    {
      "dependencies": [
        {
          "arch": "noarch",
          "epoch": "0",
          "name": "basesystem",
          "release": "7.el7",
          "version": "10.0"
        },
        {
          "arch": "x86_64",
          "epoch": "0",
          "name": "bash",
          "release": "28.el7",
          "version": "4.2.46"
        },
        ...
      ],
      "description": "The GNU tar program saves ...",
      "homepage": "http://www.gnu.org/software/tar/",
      "name": "tar",
      "summary": "A GNU file archiving program",
      "upstream_vcs": "UPSTREAM_VCS"
    }
  ]
}

compose :: ServerConfig -> ComposeBody -> Maybe Int -> Handler ComposeResponse Source #

POST apiv0/compose Start a compose. TODO implement test support

composeTypes :: Handler ComposeTypesResponse Source #

apiv0composetypes

Returns the list of supported output types that are valid for use with 'POST apiv0/compose'

{
  "types": [
    {
      "enabled": true,
      "name": "tar"
    }
  ]
}

composeQueue :: ServerConfig -> Handler ComposeQueueResponse Source #

apiv0composequeue

Return the status of the build queue. It includes information about the builds waiting, and the build that is running.

{
  "new": [
    {
      "id": "45502a6d-06e8-48a5-a215-2b4174b3614b",
      "recipe": "glusterfs",
      "queue_status": "WAITING",
      "timestamp": 1517362647.4570868,
      "version": "0.0.6"
    },
    {
      "id": "6d292bd0-bec7-4825-8d7d-41ef9c3e4b73",
      "recipe": "kubernetes",
      "queue_status": "WAITING",
      "timestamp": 1517362659.0034983,
      "version": "0.0.1"
    }
  ],
  "run": [
    {
      "id": "745712b2-96db-44c0-8014-fe925c35e795",
      "recipe": "glusterfs",
      "queue_status": "RUNNING",
      "timestamp": 1517362633.7965999,
      "version": "0.0.6"
    }
  ]
}

composeQueueFinished :: ServerConfig -> Handler ComposeFinishedResponse Source #

apiv0composefinished

Return the details on all of the finished composes on the system.

{
  "finished": [
    {
      "id": "70b84195-9817-4b8a-af92-45e380f39894",
      "recipe": "glusterfs",
      "queue_status": "FINISHED",
      "timestamp": 1517351003.8210032,
      "version": "0.0.6"
    },
    {
      "id": "e695affd-397f-4af9-9022-add2636e7459",
      "recipe": "glusterfs",
      "queue_status": "FINISHED",
      "timestamp": 1517362289.7193348,
      "version": "0.0.6"
    }
  ]
}

composeQueueFailed :: ServerConfig -> Handler ComposeFailedResponse Source #

apiv0composefailed

Return the details on all of the failed composes on the system.

{
  "failed": [
    {
      "id": "8c8435ef-d6bd-4c68-9bf1-a2ef832e6b1a",
      "recipe": "http-server",
      "queue_status": "FAILED",
      "timestamp": 1517523249.9301329,
      "version": "0.0.2"
    }
  ]
}

composeStatus :: ServerConfig -> [Text] -> Handler ComposeStatusResponse Source #

apiv0composestatus/uuids

Return the details for each of the comma-separated list of uuids.

{
  "uuids": [
    {
      "id": "8c8435ef-d6bd-4c68-9bf1-a2ef832e6b1a",
      "recipe": "http-server",
      "queue_status": "FINISHED",
      "timestamp": 1517523644.2384307,
      "version": "0.0.2"
    },
    {
      "id": "45502a6d-06e8-48a5-a215-2b4174b3614b",
      "recipe": "glusterfs",
      "queue_status": "FINISHED",
      "timestamp": 1517363442.188399,
      "version": "0.0.6"
    }
  ]
}

composeInfo :: ServerConfig -> String -> Handler ComposeInfoResponse Source #

apiv0composeinfo/uuid

Get detailed information about the compose. The returned JSON string will contain the following information:

  • id - The uuid of the comoposition
  • config - containing the configuration settings used to run Anaconda
  • blueprint - The depsolved blueprint used to generate the kickstart
  • commit - The (local) git commit hash for the blueprint used
  • deps - The NEVRA of all of the dependencies used in the composition
  • compose_type - The type of output generated (tar, iso, etc.)
  • queue_status - The final status of the composition (FINISHED or FAILED)

Example::

{
  "commit": "7078e521a54b12eae31c3fd028680da7a0815a4d",
  "compose_type": "tar",
  "id": "c30b7d80-523b-4a23-ad52-61b799739ce8",
  "queue_status": "FINISHED",
  "blueprint": {
    "description": "An example kubernetes master",
    ...
  }
}

composeCancel :: ServerConfig -> String -> Handler APIResponse Source #

DELETE apiv0composecancel/uuid

Cancel the build, if it is not finished, and delete the results. It will return a status of True if it is successful.

The response for a successful DELETE is:

{
    "status": true,
    "errors": []
}

composeDelete :: ServerConfig -> [Text] -> Handler ComposeDeleteResponse Source #

DELETE apiv0composedelete/uuids

Delete the list of comma-separated uuids from the compose results.

{
  "errors": [],
  "uuids": [
    {
      "status": true,
      "uuid": "ae1bf7e3-7f16-4c9f-b36e-3726a1093fd0"
    }
  ]
}

composeLogs :: KnownSymbol h => ServerConfig -> String -> Handler (Headers '[Header h String] ByteString) Source #

apiv0composelogs/uuid

Returns a .tar of the compose logs. The tar is not compressed, but it is not large.

The mime type is set to 'application/x-tar' and the filename is set to UUID-logs.tar

composeImage :: KnownSymbol h => ServerConfig -> Text -> Handler (Headers '[Header h String] ByteString) Source #

apiv0composeimage/uuid

Returns the output image from the build. The filename is set to the filename from the build with the UUID as a prefix. eg. UUID-root.tar.xz or UUID-boot.iso.

composeMetadata :: KnownSymbol h => ServerConfig -> String -> Handler (Headers '[Header h String] ByteString) Source #

apiv0composemetadata/uuid

Returns a .tar of the metadata used for the build. This includes all the information needed to reproduce the build, including the final blueprint populated with repository and package NEVRA.

The mime type is set to 'application/x-tar' and the filename is set to UUID-metadata.tar

The .tar is uncompressed, but is not large.

composeResults :: KnownSymbol h => ServerConfig -> String -> Handler (Headers '[Header h String] ByteString) Source #

apiv0composeresults/uuid

Returns a .tar of the metadata, logs, and output image of the build. This includes all the information needed to reproduce the build, including the final kickstart populated with repository and package NEVRA. The output image is already in compressed form so the returned tar is not compressed.

The mime type is set to 'application/x-tar' and the filename is set to UUID.tar