/[eiffelstudio]/trunk/Src/web/eiffel-cloud/modules/es_cloud/webapi/es_cloud_plans_webapi_handler.e
ViewVC logotype

Contents of /trunk/Src/web/eiffel-cloud/modules/es_cloud/webapi/es_cloud_plans_webapi_handler.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 103675 - (show annotations)
Tue Nov 12 12:35:53 2019 UTC (2 months, 1 week ago) by jfiat
File size: 2963 byte(s)
Added webapi to access the plans.
1 note
2 description: "Summary description for {ES_CLOUD_PLANS_WEBAPI_HANDLER}."
3 date: "$Date$"
4 revision: "$Revision$"
5
6 class
7 ES_CLOUD_PLANS_WEBAPI_HANDLER
8
9 inherit
10 ES_CLOUD_WEBAPI_HANDLER
11
12 create
13 make
14
15 feature -- Execution
16
17 execute (a_version: READABLE_STRING_GENERAL; req: WSF_REQUEST; res: WSF_RESPONSE)
18 -- Execute handler for `req' and respond in `res'.
19 local
20 l_uid: READABLE_STRING_GENERAL
21 l_user: ES_CLOUD_USER
22 do
23 if req.is_get_request_method then
24 if attached {WSF_STRING} req.path_parameter ("pid") as pid and then pid.is_integer then
25 handle_plan (a_version, pid.integer_value, req, res)
26 else
27 handle_plan_list (a_version, req, res)
28 end
29 else
30 new_bad_request_error_response (Void, req, res).execute
31 end
32 end
33
34 handle_plan (a_version: READABLE_STRING_GENERAL; pid: INTEGER; req: WSF_REQUEST; res: WSF_RESPONSE)
35 require
36 req.is_get_request_method
37 local
38 r: like new_response
39 tb: STRING_TABLE [detachable ANY]
40 do
41 r := new_response (req, res)
42 if attached {ES_CLOUD_PLAN} es_cloud_api.plan (pid) as l_plan then
43 create tb.make (5)
44 tb.force (l_plan.id.out, "id")
45 tb.force (l_plan.name, "name")
46 if attached l_plan.title as l_title then
47 tb.force (l_title, "title")
48 end
49 if attached l_plan.description as l_description then
50 tb.force (l_description, "description")
51 end
52 tb.force (l_plan.weight.out, "weight")
53 tb.force (l_plan.concurrent_sessions_limit.out, "concurrent_sessions_limit")
54
55 r.add_table_iterator_field ("es:plan", tb)
56 r.add_link ("plans", "plans", cloud_plans_link (a_version))
57 r.add_self (r.location)
58 else
59 r := new_error_response ("No plan found", req, res)
60 end
61 r.execute
62 end
63
64 handle_plan_list (a_version: READABLE_STRING_GENERAL; req: WSF_REQUEST; res: WSF_RESPONSE)
65 require
66 req.is_get_request_method
67 local
68 r: like new_response
69 tb: STRING_TABLE [detachable ANY]
70 tb_plans: STRING_TABLE [detachable ANY]
71 do
72 r := new_response (req, res)
73 if attached es_cloud_api.plans as lst then
74 create tb_plans.make (lst.count)
75 across
76 lst as ic
77 loop
78 if attached {ES_CLOUD_PLAN} ic.item as l_plan then
79 create tb.make (5)
80 tb.force (l_plan.id.out, "id")
81 tb.force (l_plan.name, "name")
82 if attached l_plan.title as l_title then
83 tb.force (l_title, "title")
84 end
85 if attached l_plan.description as l_description then
86 tb.force (l_description, "description")
87 end
88 tb.force (l_plan.weight.out, "weight")
89 tb_plans.force (tb, l_plan.id.out)
90 r.add_link (url_encoded (l_plan.id.out), html_encoded (l_plan.name), cloud_plan_link (a_version, l_plan.id))
91 end
92 end
93 r.add_table_iterator_field ("es:plans", tb_plans)
94 end
95 r.execute
96 end
97
98
99 note
100 copyright: "2011-2017, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
101 license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
102 end
103

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.23