Wharf API endpoints rework

Why

  • Some use plural, some use singular. We need consistency

  • Some are misplaced and convoluted

  • Some are marked as “NOT YET IMPLEMENTED” while we may not want them anymore. Need to trim away the bloat.

  • Some parameters are lowercased, while some are camelCased.

Overall changes

  • Singular everywhere.

  • Moved a lot of endpoints, such as the /branch(es) endpoints, under /project/{projectId} as they require a project ID anyway.

  • camelCased all path parameters.

  • Added ID, meaning to be a Swagger/OpenAPI endpoint ID. Used in code generation.

    • Somewhat namespaced, for example getProjectBranchList instead of getBranchList, as it’s under /project/…

    • Endpoints returning array of objects ends with “-List”

    • No trailing “-ById” at the end.

    • Prefix mostly defined by the HTTP method:

      • POST: create-, upload-, search-, start-
      • GET: get-
      • PUT: update-
      • DELETE: delete-

Tables of changes

Tag: artifact

OldNewMethodIDNotes
/build/{buildid}/artifacts/build/{buildId}/artifactGETgetBuildArtifactList1
/build/{buildid}/artifact/build/{buildId}/artifactPOSTuploadBuildArtifact1
/build/{buildid}/artifact/{artifactid}/build/{buildId}/artifact/{artifactId}GETgetBuildArtifact1

Tag: build

OldNewMethodIDNotes
/build/searchunchangedPOSTsearchBuild
/build/{buildid}/build/{buildId}GETgetBuild1
/build/{buildid}/build/{buildId}PUTupdateBuild1
/build/{buildid}/log/build/{buildId}/logGETgetBuildLogs1
/build/{buildid}/log/build/{buildId}/logPOSTcreateBuildLog1
/build/{buildid}/stream/build/{buildId}/streamGETstreamBuildLogs1
/build/{buildid}/test-results/build/{buildId}/test-resultGETgetBuildTestResults1 2

Tag: health

OldNewMethodIDNotes
/healthunchangedGETgetHealth
/pingunchangedGETping

Tag: meta

OldNewMethodIDNotes
/versionunchangedGETgetVersion

Tag: project

OldNewMethodIDNotes
/projects/projectGETgetProjectList
/projectunchangedPOSTcreateProject
/projects/search/project/searchPOSTsearchProject
/project/{projectid}/project/{projectId}DELETEdeleteProject1
/project/{projectid}/project/{projectId}GETgetProject1
/project/project/{projectId}PUTupdateProject3
/branch/project/{projectId}/branchGETgetProjectBranchList
/branches/project/{projectId}/branchPUTupdateProjectBranchList
/branch/{branchid}/project/{projectId}/branch/{branchId}GETgetProjectBranch1
/project/{projectid}/builds/project/{projectId}/buildGETgetProjectBuildList1
/project/{projectid}/{stage}/run/project/{projectId}/buildPOSTstartProjectBuild1 4

Tag: provider

OldNewMethodIDNotes
/providers/providerGETgetProviderList
/providerunchangedPOSTcreateProvider
/provider/{providerid}/provider/{providerId}GETgetProvider1
/provider/provider/{providerId}PUTupdateProvider3
/providers/search/provider/searchPOSTserachProvider

Tag: token

OldNewMethodIDNotes
/tokens/tokenGETgetTokenList
/tokenunchangedPOSTcreateToken
/tokens/search/token/searchPOSTsearchToken
/token/{tokenId}/token/{tokenId}GETgetToken1
/token/token/{tokenId}PUTupdateToken3

Body changes

  • Endpoints shall have different models for different endpoints.

    • One for retrieved data, used in GET and search requests, as well as response for creations

      No special prefix or suffix required.

    • One for creation of data, used in POST requests

      Prefixed with “Create-”, ex “CreateProject”, “CreateProvider”, “CreateToken”

    • One for editing data, used in PUT requests.

      Prefixed with “Edit-”, ex “EditProject”, “EditProvider”, “EditToken”

      Q: Are edit-specific ones really needed? Will not the creation models suffice?

    This allows us to provide different Gin-Gonic specific binding attributes to the models

  • No database models shall be returned. They need to be mapped to request or response models.

  • To not have name collisions, the models will be placed in new sub-packages:

    • /pkg/models/request: HTTP request models, to be returned from the API
    • /pkg/models/response: HTTP response models, to be sent to the API
    • /pkg/models/database: Database models, that are used in GORM
  1. The path parameter has been transformed from lowercase to camelCase. This only affects code generators.

    ↩︎
  2. Endpoint was moved from tag artifact to tag build.

    ↩︎
  3. Added path parameter for value that was previously taken from the HTTP request body.

    ↩︎
  4. The {stage} path parameter has been moved to a query parameter. Now uses ?stage=ALL by default.

    ↩︎