Provide new capability to V1 client - expose_url
Includes CLI endpoint: openstack fn routes expose-url <app> <route>
This commit is contained in:
parent
58fe7484f8
commit
62abc30975
@ -233,3 +233,22 @@ class ExecuteAppRoute(command.ShowOne):
|
||||
supply_auth_properties=supply_auth_properties, **data)
|
||||
clmns = list(result.keys())
|
||||
return clmns, utils.get_dict_properties(result, clmns)
|
||||
|
||||
|
||||
class ExposeAppRouteURL(command.Command):
|
||||
"""Deletes specific app route"""
|
||||
log = logging.getLogger(__name__ + ".ExposeAppRouteURL")
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(ExposeAppRouteURL, self).get_parser(prog_name)
|
||||
parser.add_argument("app", metavar="<app-name>",
|
||||
help="Specifies which app to show")
|
||||
parser.add_argument("route", metavar="<route-path>",
|
||||
help="App route to look for")
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
self.log.debug("take_action(%s)", parsed_args)
|
||||
fc = self.app.client_manager.functions
|
||||
app, route = parsed_args.app, parsed_args.route
|
||||
print(fc.routes.expose_url(app, route))
|
||||
|
@ -171,3 +171,23 @@ class Routes(object):
|
||||
OS_PROJECT_ID=project_id)
|
||||
response = self.client.post(url, json=data)
|
||||
return response.json()
|
||||
|
||||
@client.inject_project_id
|
||||
def expose_url(self, project_id, app_name, route_path):
|
||||
"""
|
||||
Exposes fully-qualified function URL
|
||||
|
||||
:param app_name: App name
|
||||
:param route_path: App route path
|
||||
:return: function URL
|
||||
:rtype: str
|
||||
"""
|
||||
endpoint = self.client.get_endpoint()
|
||||
route = self.show(app_name, route_path)
|
||||
is_public = route["route"].get("is_public")
|
||||
url = (self.public_execution.format(
|
||||
app=app_name, route_path=route_path) if is_public else
|
||||
self.private_execution.format(
|
||||
project_id=project_id, app=app_name,
|
||||
route_path=route_path))
|
||||
return "{}{}".format(endpoint, url)
|
||||
|
@ -36,6 +36,7 @@ openstack.functions.v1 =
|
||||
fn_routes_delete = picassoclient.osc.v1.routes:DeleteAppRoute
|
||||
fn_routes_update = picassoclient.osc.v1.routes:UpdateAppRoute
|
||||
fn_routes_execute = picassoclient.osc.v1.routes:ExecuteAppRoute
|
||||
fn_routes_expose-url = picassoclient.osc.v1.routes:ExposeAppRouteURL
|
||||
|
||||
[global]
|
||||
setup-hooks =
|
||||
|
Loading…
x
Reference in New Issue
Block a user