Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proposal: v2 gateway/provider API spec #1804

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

LucasRoesler
Copy link
Member

This is a proposal for a new standardized v2 API.

The new spec includes the following changes from v1:

  • the API paths now include a version prefix, /v2. The goal is to allow a compatabiliy period where both APIs are deployed.

  • the path structures try to emphasize a nested REST-ful struture. Specifically, the logs and scale endpoints are now sub-paths of the function

  • Reference to service are now replaced with Function, request and response objects, fields, and parameters should always use function and not service. The one exception is the PrometheusAlertRequest object, where we can not control this schema.

  • There should only be one path for each action. For example creating a function is now a PUT on system/functions/{functionName} instead of supporting both POST on /system/functions and PUT on the named path.

  • To bring consistency between the invoke and system endpoints, the name parameters are defined as a regex pattern with an optional .namespace suffix. Specifically, to create a function echo in the default namespace you PUT to system/functions/echo. To create the echo function in the internal namespace, you would use system/functions/echo.internal. Both functions and secrets support this pattern now.

    To ensure consistency, there is a NamespacedNameParameter object in the spec. It defines the following regexp pattern using named groups. ^(?<name>[a-zA-Z][a-zA-Z0-9-_]*)(.(?<namespace>[a-zA-Z][a-zA-Z0-9-_]*)?)$ This is valid for the OpenAPI spec, but the named groups might not be supported in all languages. If we want to support code generation, we should consider removing the named groups, this is the equivalent pattern ^([a-zA-Z][a-zA-Z0-9-_]*)(.[a-zA-Z][a-zA-Z0-9-_]*)?$

    • Note that the list endpoints still support a GET query parameter for namespace.

Motivation and Context

  • I have raised an issue to propose this change (required)
  • My issue has received approval from the maintainers or lead with the design/approved label
    This was discussed several times in community calls, so I am posting this here so that some kind of consensus can be made. A PR allows comments on specific lines, which is much easier to follow vs an issue.

How Has This Been Tested?

NA

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I've read the CONTRIBUTION guide
  • I have signed-off my commits with git commit -s
  • I have added tests to cover my changes.
  • All new and existing tests passed.

This is a proposal for a new standardized v2 API.

The new spec includes the following changes from v1:

* the API paths now include a version prefix, `/v2`. The goal is to
  allow a compatabiliy period where both APIs are deployed.
* the path structures try to emphasize a nested REST-ful struture.
  Specifically, the `logs` and `scale` endpoints are now sub-paths of
  the function
* Reference to service are now replaced with Function, request and
  response objects, fields, and parameters should always use `function`
  and not `service`. The one exception is the PrometheusAlertRequest
  object, where we can not control this schema.
* There should only be one path for each action. For example
  creating a function is now a `PUT` on `system/functions/{functionName}` instead of
  supporting both `POST` on `/system/functions` and `PUT` on the named path.
* To bring consistency between the invoke and system endpoints, the
  `name` parameters are defined as a regex pattern with an optional
  `.namespace` suffix. Specifically, to create a function `echo` in the default
  namespace you `PUT` to `system/functions/echo`. To create the `echo`
  function in the `internal` namespace, you would use
  `system/functions/echo.internal`. Both functions and secrets support
  this pattern now.

  To ensure consistency, there is a `NamespacedNameParameter` object in
  the spec. It defines the following regexp pattern using named groups.
  ```
  ^(?<name>[a-zA-Z][a-zA-Z0-9-_]*)(.(?<namespace>[a-zA-Z][a-zA-Z0-9-_]*)?)$
  ```
  This is valid for the OpenAPI spec, but the named groups might not be
  supported in _all_ languages. If we want to support code generation,
  we should consider removing the named groups, this is the equivalent
  pattern
  ```
  ^([a-zA-Z][a-zA-Z0-9-_]*)(.[a-zA-Z][a-zA-Z0-9-_]*)?$
  ```
  * Note that the list endpoints still support a `GET` query parameter
    for `namespace`.

Signed-off-by: Lucas Roesler <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant