@@ -51,46 +51,22 @@ def get(self):
5151 including the Pbench dashboard UI. This includes:
5252
5353 openid-connect: A JSON object containing the OpenID Connect parameters
54- required for the web client to use OIDC authentication.
54+ required for the web client to use OIDC authentication.
5555 identification: The Pbench server name and version
56- api: A dict of the server APIs supported; we give a name, which
57- identifies the service, and the full URI relative to the
58- configured host name and port (local or remote reverse proxy).
59-
60- This is dynamically generated by processing the Flask URI
61- rules; refer to api/__init__.py for the code which creates
62- those mappings, or test_endpoint_configure.py for code that
63- validates the current set (and must be updated when the API
64- set changes).
6556 uri: A dict of server API templates, where each template defines a
6657 template URI and a list of typed parameters.
6758
6859 We derive a "name" for each API by removing URI parameters and the API
6960 prefix (/api/v1/), then replacing the path "/" characters with
7061 underscores.
7162
72- The "api" object contains a key for each API name, where the value is a
73- simplified URI omitting URI parameters. The client must either know the
74- required parameters and order, and connect them to the "api" value
75- separated by slash characters, or refer to the "uri" templates.
76-
77- E.g, "/api/v1/controllers/list" yields:
78-
79- "controllers_list": "http://host/api/v1/controllers/list"
80-
81- while "/api/v1/users/<string:username>" yields:
82-
83- "users": "http://host/api/v1/users"
84-
85- For URIs with multiple parameters, or embedded parameters, it may be
86- easier to work with the template string in the "uri" object. The value
87- of each API name key in the "uri" object is a minimal "schema" object
88- defining the template string and parameters for the API. The "uri"
89- value for the "users" API, for example, will be
63+ The "uri" object defines a template for each API name, defining a set of
64+ URI parameters that must be expanded in the template. For example, the
65+ API to get or modify metadata is:
9066
9167 {
92- "template": "http://host/api/v1/users/{target_username} ",
93- "params": {"target_username ": {"type": "string"}}
68+ "template": "http://host/api/v1/datasets/{dataset}/metadata ",
69+ "params": {"dataset ": {"type": "string"}}
9470 }
9571
9672 The template can be resolved in Python with:
@@ -137,7 +113,6 @@ def get(self):
137113 host_value ,
138114 )
139115
140- apis = {}
141116 templates = {}
142117
143118 # Iterate through the Flask endpoints to add a description for each.
@@ -156,7 +131,6 @@ def get(self):
156131 for match in matches
157132 },
158133 }
159- url = self .param_template .sub ("" , url )
160134 path = rule .endpoint
161135
162136 # We have some URI endpoints that repeat a basic URI pattern.
@@ -168,12 +142,10 @@ def get(self):
168142 if path not in templates or (
169143 len (template ["params" ]) > len (templates [path ]["params" ])
170144 ):
171- apis [path ] = urljoin (host , url )
172145 templates [path ] = template
173146
174147 endpoints = {
175148 "identification" : f"Pbench server { self .server_config .COMMIT_ID } " ,
176- "api" : apis ,
177149 "uri" : templates ,
178150 }
179151
0 commit comments