Skip to content

Report the template string with JS template arguments in pbench server config API #2154

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

Closed
portante opened this issue Mar 26, 2021 · 1 comment
Assignees
Labels
API Of and relating to application programming interfaces to services and functions Server
Milestone

Comments

@portante
Copy link
Member

portante commented Mar 26, 2021

Originally posted by @webbnh in #2024 (comment)

Would it be more useful to report the template string with JS template arguments in it? E.g.,

    param_template = re.compile(r"<(?P<type_name>\w+):(?P<param_name>\w+)>")

[...]
                    url = self.param_template.sub("${\g<param_name>}", url)

such that "/api/v1/foo/<string:name>/detail/<string:param>" would be reported as ".../api/v1/foo/${name}/detail/${param}".


The client has to remove/substitute the templates then and I figured that wasn't very generic. I didn't really want to make it so Javascript-specific, either, and Javascript will only do that sort of substitution in literal template strings (backticked), so far as I can tell; although it's just a .replace away, it's not quite that neat.

Anyway, just letting it append the username to the end of the URI seemed easiest, at least for now.


I guess I was proposing two things:

  • make the URI available as a template
  • make it easy for the client to fill in the template (which is why I offered JS syntax)

It doesn't have to be Javascript format, but I'll point out that that format also works for shell, so it's not exactly JS-specific. ;-) We could use %s instead of ${...}, but I opted for the latter because it provides semantic information.

It's true that the client will likely need to have some foreknowledge in order to fill in the template, but it will need to have even closer coupling to produce the URI if we just lop it off at the first parameter. Providing a template removes the need for some of that coupling.

Apparently there is a (proposed) IETF standard for URI templates.

@portante portante changed the title I guess I was proposing two things: Report the template string with JS template arguments in pbench server config API Mar 26, 2021
@portante portante added API Of and relating to application programming interfaces to services and functions Backlog Server labels Mar 26, 2021
@dbutenhof
Copy link
Member

Resolved by #2909

@portante portante added this to the v0.72 milestone Jul 25, 2022
@portante portante removed the Backlog label Jul 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Of and relating to application programming interfaces to services and functions Server
Projects
None yet
Development

No branches or pull requests

2 participants