Skip to content

Add tests to serve as a minimum specification for REST netapi modules #13698

Closed

Description

@whiteinge

Write integration tests that can be used as as specification for minimum functionality in a REST API. The minimum specification should be:

  1. The root URL (/) lowstate interface of the rest_wsgi, rest_cherrypy, and rest_tornado modules.
  2. The event SSE stream.

netapi modules are encouraged to experiment with appropriate interfaces around that spec.

Activity

  1. added this to the Approved milestone on Jun 24, 2014
  2. jacksontj commented on Jun 24, 2014

    @jacksontj
    Contributor

    2 Things that I'd really like to see in this:

    1: Versioned API in the URL. We already have the problem today that we have to be very careful adding/removing/changing the apis since there is no semantic version-ing.

    2: I'd actually like to see a more restful interface. I was talking with some people in the office and our idea was something like //jobs/. Meaning that if you wanted to post a new job to the local client you would POST /local/jobs and you'd get the return data. If it was an async request that endpoint would return a 303 to /local/jobs/JID and of course you could just get jid info from that url. A GET of /local/jobs would get you a jid list (or something similar).

    Regardless of the API though, I am all for a single API spec-- with tests for it.

  3. whiteinge commented on Jun 24, 2014

    @whiteinge
    ContributorAuthor

    Those are both things I would like to see experimentation with in individual modules and kept out of the spec. Both are great ideas! -- for example, the rest_cherrypy module has something similar to your proposed /local/jobs/<jid> URL (in the /minions and /jobs URLs).

    The spec should only cover the raw functionality -- how to format lowstate data in order to execute methods on Salt's Python API client interfaces, and to watch the event bus. That way netapi modules are free to build more friendly (and versioned) interfaces on top of that. And also that puts the onus to keep Salt's Python API up to snuff.

  4. jacksontj commented on Jun 25, 2014

    @jacksontj
    Contributor

    I guess what i'm trying to say is that our "bare minimum" api isn't very clean or restful. So I'd like to make the base API more restful. IMO it doesn't matter too much what it is as long as we are backwards compatible and it exposes all of the funcitonality that we need. I'd actually prefer for the spec to be what we expect people to use, and we'd use those other individual modules to try out other things-- then bring them into the main spec. As part of that we'll probably want to version the base API since it may need to change in the future as we add new functionality etc.

  5. whiteinge commented on Jun 25, 2014

    @whiteinge
    ContributorAuthor

    I agree that the baseline is not RESTful. It's more RPC-like. However it does expose all possible functionality. Think of it more like asm.js that you would use to build a RESTful API on top of.

    As for versioning, this baseline interface is, very directly, Salt's Python API accessed via lowstate dictionaries. It cannot change for the lifetime of Salt without breaking backward compat -- it can only be additve (1, 2, 3, 4, 5). We can add (new client interfaces and new methods on existing client interfaces). Meaning only the RESTful API built on top of the baseline needs to be versioned since that is the only part that can change.

    Savvy?

  6. jacksontj commented on Jun 25, 2014

    @jacksontj
    Contributor

    Makes sense. So the plan would be for starters (version 0) is the RPC
    interface on root. Then we can add v1 which would be restful, which could
    potentially in the future deprecate the / api. Am I following?
    On Jun 25, 2014 7:39 AM, "Seth House" [email protected] wrote:

    I agree that the baseline is not RESTful
    vmware-archive/salt-api@2255ea4#diff-94d1eb2de77db11e9c2302c79800631aR30.
    It's more RPC-like. However it does expose all possible functionality.
    Think of it more like asm.js http://en.wikipedia.org/wiki/Asm.js that
    you would use to build a RESTful API on top of.

    As for versioning, this baseline interface is, very directly, Salt's Python
    API http://docs.saltstack.com/en/latest/ref/clients/index.html accessed
    via lowstate dictionaries. It cannot change for the lifetime of Salt
    without breaking backward compat -- it can only be additve (1
    https://github.com/saltstack/salt/blob/fef9dc69/salt/client/__init__.py#L404,
    2
    https://github.com/saltstack/salt/blob/fef9dc69/salt/client/__init__.py#L536,
    3
    https://github.com/saltstack/salt/blob/fef9dc69/salt/client/__init__.py#L592,
    4
    https://github.com/saltstack/salt/blob/fef9dc69/salt/client/__init__.py#L642,
    5
    https://github.com/saltstack/salt/blob/fef9dc69/salt/client/__init__.py#L693).
    We can add (new client interfaces
    https://github.com/saltstack/salt/blob/fef9dc69/salt/netapi/__init__.py#L69
    and new methods
    https://github.com/saltstack/salt/blob/fef9dc69/salt/client/__init__.py#L359
    o n existing client interfaces). Meaning only the RESTful API built on top
    of the baseline needs to be versioned since that is the only part that can
    change.

    Savvy?

    —
    Reply to this email directly or view it on GitHub
    #13698 (comment).

  7. modified the milestones: ww27, Approved on Jun 25, 2014
  8. whiteinge commented on Jun 27, 2014

    @whiteinge
    ContributorAuthor

    Not quite. The spec is the RPC-like interface on root. This interface isn't going to change for as long as Salt's own Python API doesn't change (it will continue to be added to though). The rest_tornado, rest_cherrypy, etc modules create RESTful interfaces on top and version the interfaces they provide individually. This is already the case with /minions, and /jobs, and /login / /logout, etc.

  9. removed this from the ww29 milestone on Jul 15, 2014
  10. added this to the Approved milestone on Aug 5, 2014
  11. Lothiraldan commented on Apr 17, 2015

    @Lothiraldan
    Contributor

    I think at least the '/login' should be standardized, you can't create a token with basic RPC

  12. whiteinge commented on Apr 17, 2015

    @whiteinge
    ContributorAuthor

    I've never been a fan of competing-yet-identical REST interfaces. Dev time would be better spent on a single module.

    CherryPy was chosen for the first netapi module in part because it has a single dep for both lib and web server. Now that Tornado is a hard-dep for Salt (#22453) I would like to revisit thoughts of retiring those other modules and defaulting to Saltnado for a single Salt REST API. We'll need to check backward-compat carefully as part of that work. I don't have a time-frame in mind for this work yet.

  13. jacksontj commented on Apr 20, 2015

    @jacksontj
    Contributor

    We had talked about deprecating rest_cherrypy in favor of the tornado implementation. and I agree, with tornado now has a hard dep, 2015.7 (or w/e the next feature release) is probably a good time to "deprecate" rest_cherrypy.

  14. whiteinge commented on Aug 20, 2015

    @whiteinge
    ContributorAuthor

    Closing this in deference to #25460.

  15. whiteinge commented on Aug 20, 2015

    @whiteinge
    ContributorAuthor

    Er. And #26505.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

FeatureSalt-APIneeds-testcase

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions