Subversion Repositories eiffelstudio

Compare Revisions

Ignore whitespace Rev 103674 → Rev 103675

/trunk/Src/web/eiffel-cloud/modules/es_cloud/kernel/es_cloud_plan.e
46,6 → 46,8
-- Maximum number of concurrent sessions for the same plan.
-- `0` means no limit
 
feature -- Access: private
 
heartbeat: NATURAL
-- Delay between each ping in seconds
-- `0` means no constraint.
/trunk/Src/web/eiffel-cloud/modules/es_cloud/webapi/es_cloud_installations_webapi_handler.e
55,7 → 55,7
sess: ES_CLOUD_SESSION
l_include_sessions: BOOLEAN
do
if a_user.same_as (api.user) or else api.has_permission ("manage es acounts") then
if a_user.same_as (api.user) or else api.has_permission ("manage es accounts") then
r := new_response (req, res)
if attached es_cloud_api.user_installations (a_user) as lst then
l_include_sessions := req.percent_encoded_path_info.ends_with_general ("/session/")
147,7 → 147,7
tb: STRING_TABLE [detachable ANY]
tb_installations: STRING_TABLE [detachable ANY]
do
if a_user.same_as (api.user) or else api.has_permission ("manage es acounts") then
if a_user.same_as (api.user) or else api.has_permission ("manage es accounts") then
r := new_response (req, res)
if attached es_cloud_api.user_installations (a_user) as lst then
create tb_installations.make (lst.count)
183,7 → 183,7
inst: ES_CLOUD_INSTALLATION
l_inst_location: STRING
do
if a_user.same_as (api.user) or else api.has_permission ("manage es acounts") then
if a_user.same_as (api.user) or else api.has_permission ("manage es accounts") then
r := new_response (req, res)
if attached {ES_CLOUD_SESSION} es_cloud_api.user_session (a_user, iid, sid) as sess then
r := new_response (req, res)
397,35 → 397,6
r.execute
end
 
feature {NONE} -- Implementation
 
remove_last_segment (a_location: STRING_8; a_keep_ending_slash: BOOLEAN)
local
i: INTEGER
do
if a_location.ends_with_general ("/") then
i := a_location.count - 1
else
i := a_location.count
end
i := a_location.last_index_of ('/', i)
if i > 0 then
if a_keep_ending_slash then
a_location.keep_head (i)
else
a_location.keep_head (i - 1)
end
end
end
 
detachable_html_encoded (s: detachable READABLE_STRING_GENERAL): detachable STRING_8
-- html encoded version of `s` if set, otherwise Void.
do
if s /= Void then
Result := api.html_encoded (s)
end
end
 
note
copyright: "2011-2017, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
/trunk/Src/web/eiffel-cloud/modules/es_cloud/webapi/es_cloud_module_webapi.e
25,6 → 25,7
-- <Precursor>
local
l_root: ES_CLOUD_ROOT_WEBAPI_HANDLER
l_plans: ES_CLOUD_PLANS_WEBAPI_HANDLER
l_account: ES_CLOUD_ACCOUNT_WEBAPI_HANDLER
l_inst_hlr: ES_CLOUD_INSTALLATIONS_WEBAPI_HANDLER
do
33,6 → 34,9
a_router.handle ("/cloud", l_root, a_router.methods_get)
-- FIXME: switch earlier for version. Using WSF_ROUTING_HANDLER.
a_router.handle ("/cloud/{version}/", l_root, a_router.methods_get)
create l_plans.make (l_mod_api)
a_router.handle ("/cloud/{version}/plan/", l_plans, a_router.methods_get)
a_router.handle ("/cloud/{version}/plan/{pid}", l_plans, a_router.methods_get)
create l_account.make (l_mod_api)
a_router.handle ("/cloud/{version}/account/", l_account, a_router.methods_get)
a_router.handle ("/cloud/{version}/account/{uid}", l_account, a_router.methods_get)
/trunk/Src/web/eiffel-cloud/modules/es_cloud/webapi/es_cloud_plans_webapi_handler.e
0,0 → 1,103
note
description: "Summary description for {ES_CLOUD_PLANS_WEBAPI_HANDLER}."
date: "$Date$"
revision: "$Revision$"
 
class
ES_CLOUD_PLANS_WEBAPI_HANDLER
 
inherit
ES_CLOUD_WEBAPI_HANDLER
 
create
make
 
feature -- Execution
 
execute (a_version: READABLE_STRING_GENERAL; req: WSF_REQUEST; res: WSF_RESPONSE)
-- Execute handler for `req' and respond in `res'.
local
l_uid: READABLE_STRING_GENERAL
l_user: ES_CLOUD_USER
do
if req.is_get_request_method then
if attached {WSF_STRING} req.path_parameter ("pid") as pid and then pid.is_integer then
handle_plan (a_version, pid.integer_value, req, res)
else
handle_plan_list (a_version, req, res)
end
else
new_bad_request_error_response (Void, req, res).execute
end
end
 
handle_plan (a_version: READABLE_STRING_GENERAL; pid: INTEGER; req: WSF_REQUEST; res: WSF_RESPONSE)
require
req.is_get_request_method
local
r: like new_response
tb: STRING_TABLE [detachable ANY]
do
r := new_response (req, res)
if attached {ES_CLOUD_PLAN} es_cloud_api.plan (pid) as l_plan then
create tb.make (5)
tb.force (l_plan.id.out, "id")
tb.force (l_plan.name, "name")
if attached l_plan.title as l_title then
tb.force (l_title, "title")
end
if attached l_plan.description as l_description then
tb.force (l_description, "description")
end
tb.force (l_plan.weight.out, "weight")
tb.force (l_plan.concurrent_sessions_limit.out, "concurrent_sessions_limit")
 
r.add_table_iterator_field ("es:plan", tb)
r.add_link ("plans", "plans", cloud_plans_link (a_version))
r.add_self (r.location)
else
r := new_error_response ("No plan found", req, res)
end
r.execute
end
 
handle_plan_list (a_version: READABLE_STRING_GENERAL; req: WSF_REQUEST; res: WSF_RESPONSE)
require
req.is_get_request_method
local
r: like new_response
tb: STRING_TABLE [detachable ANY]
tb_plans: STRING_TABLE [detachable ANY]
do
r := new_response (req, res)
if attached es_cloud_api.plans as lst then
create tb_plans.make (lst.count)
across
lst as ic
loop
if attached {ES_CLOUD_PLAN} ic.item as l_plan then
create tb.make (5)
tb.force (l_plan.id.out, "id")
tb.force (l_plan.name, "name")
if attached l_plan.title as l_title then
tb.force (l_title, "title")
end
if attached l_plan.description as l_description then
tb.force (l_description, "description")
end
tb.force (l_plan.weight.out, "weight")
tb_plans.force (tb, l_plan.id.out)
r.add_link (url_encoded (l_plan.id.out), html_encoded (l_plan.name), cloud_plan_link (a_version, l_plan.id))
end
end
r.add_table_iterator_field ("es:plans", tb_plans)
end
r.execute
end
 
 
note
copyright: "2011-2017, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
end
 
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
Added: svn:keywords
+Author Date Id Revision
\ No newline at end of property
/trunk/Src/web/eiffel-cloud/modules/es_cloud/webapi/es_cloud_root_webapi_handler.e
21,18 → 21,19
-- Execute handler for `req' and respond in `res'.
local
rep: like new_response
l_url: READABLE_STRING_8
l_user: ES_CLOUD_USER
do
rep := new_response (req, res)
l_url := api.url (rep.location + "account/", Void)
if attached api.user as u then
l_url := l_url + u.id.out
rep.add_link ("es:account", Void, l_url)
rep.add_link ("es:installations", Void, l_url + "/installations")
create l_user.make (u)
add_cloud_user_links_to (a_version, l_user, rep)
rep.add_link ("es:account", Void, cloud_user_link (a_version, l_user))
rep.add_link ("es:installations", Void, cloud_user_installations_link (a_version, l_user))
add_user_links_to (u, rep)
else
rep.add_link ("es:account", Void, l_url)
rep.add_link ("es:account", Void, cloud_link (a_version) + "/account/")
end
rep.add_link ("es:plans", Void, cloud_plans_link (a_version))
rep.add_self (req.request_uri)
rep.execute
end
/trunk/Src/web/eiffel-cloud/modules/es_cloud/webapi/es_cloud_webapi_handler.e
67,6 → 67,16
Result := api.webapi_path ("/cloud/" + url_encoded (a_version) + "/")
end
 
cloud_plans_link (a_version: READABLE_STRING_GENERAL): STRING
do
Result := cloud_link (a_version) + "plan/"
end
 
cloud_plan_link (a_version: READABLE_STRING_GENERAL; pid: INTEGER): STRING
do
Result := cloud_plans_link (a_version) + pid.out
end
 
cloud_user_link (a_version: READABLE_STRING_GENERAL; a_user: ES_CLOUD_USER): STRING
do
Result := cloud_link (a_version) + "account/" + a_user.id.out
92,6 → 102,35
Result := cloud_user_installation_sessions_link (a_version, a_user, iid) + url_encoded (sid)
end
 
feature {NONE} -- Implementation
 
remove_last_segment (a_location: STRING_8; a_keep_ending_slash: BOOLEAN)
local
i: INTEGER
do
if a_location.ends_with_general ("/") then
i := a_location.count - 1
else
i := a_location.count
end
i := a_location.last_index_of ('/', i)
if i > 0 then
if a_keep_ending_slash then
a_location.keep_head (i)
else
a_location.keep_head (i - 1)
end
end
end
 
detachable_html_encoded (s: detachable READABLE_STRING_GENERAL): detachable STRING_8
-- html encoded version of `s` if set, otherwise Void.
do
if s /= Void then
Result := api.html_encoded (s)
end
end
 
note
copyright: "2011-2017, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"