Object ID |
Attribute | Value |
sql=$sql\nhash=[join [array get result_hash] "\n"]" } ad_proc -private im_rest_get_im_category { { -format "xml" } { -user_id 0 } { -rest_otype "" } { -rest_oid 0 } { -query_hash_pairs {} } } { Handler for GET rest calls } { ns_log Notice "im_rest_get_im_category: format=$format, user_id=$user_id, rest_otype=$rest_otype, rest_oid=$rest_oid, query_hash=$query_hash_pairs" # Check that rest_oid is an integer im_security_alert_check_integer -location "im_rest_get_object" -value $rest_oid # ------------------------------------------------------- # Get the SQL to extract all values from the object set sql "select * from im_categories where category_id = :rest_oid" # Execute the sql. As a result we get a result_hash with keys # corresponding to table columns and values array set result_hash {} db_with_handle db { set selection [db_exec select $db query $sql 1] while { [db_getrow $db $selection] } { set col_names [ad_ns_set_keys $selection] set this_result [list] for { set i 0 } { $i < [ns_set size $selection] } { incr i } { set var [lindex $col_names $i] set val [ns_set value $selection $i] set result_hash($var) $val } } } db_release_unused_handles if {{} == [array get result_hash]} { return [im_rest_error -format $format -http_status 404 -message "Category: Did not find object '$rest_otype' with the ID '$rest_oid'."] } # ------------------------------------------------------- # Format the result for one of the supported formats set result "" foreach result_key [array names result_hash] { set result_val $result_hash($result_key) append result [im_rest_format_line \ -column $result_key \ -value $result_val \ -format $format \ -rest_otype $rest_otype \ ] } switch $format { html { set page_title "$rest_otype: [im_category_from_id $rest_oid]" doc_return 200 "text/html" " [im_header $page_title [im_rest_header_extra_stuff]][im_navbar]
Attribute | Value |
sql=$sql\nhash=[join [array get result_hash] "\n"]" return } ad_proc -private im_rest_get_im_dynfield_attribute { { -format "xml" } { -user_id 0 } { -rest_otype "" } { -rest_oid 0 } { -query_hash_pairs {} } } { Handler for GET rest calls } { ns_log Notice "im_rest_get_im_dynfield_attribute: format=$format, user_id=$user_id, rest_otype=$rest_otype, rest_oid=$rest_oid, query_hash=$query_hash_pairs" # Check that rest_oid is an integer im_security_alert_check_integer -location "im_rest_get_object" -value $rest_oid # ------------------------------------------------------- # Get the SQL to extract all values from the object set sql " select * from im_dynfield_attributes da, acs_attributes aa where da.acs_attribute_id = aa.attribute_id and da.attribute_id = :rest_oid " # Execute the sql. As a result we get a result_hash with keys # corresponding to table columns and values array set result_hash {} db_with_handle db { set selection [db_exec select $db query $sql 1] while { [db_getrow $db $selection] } { set col_names [ad_ns_set_keys $selection] set this_result [list] for { set i 0 } { $i < [ns_set size $selection] } { incr i } { set var [lindex $col_names $i] set val [ns_set value $selection $i] set result_hash($var) $val } } } db_release_unused_handles if {{} == [array get result_hash]} { return [im_rest_error -format $format -http_status 404 -message "Dynfield Attribute: Did not find object '$rest_otype' with the ID '$rest_oid'."] } # ------------------------------------------------------- # Format the result for one of the supported formats set result "" foreach result_key [array names result_hash] { set result_val $result_hash($result_key) append result [im_rest_format_line \ -column $result_key \ -value $result_val \ -format $format \ -rest_otype $rest_otype \ ] } switch $format { html { set page_title "$rest_otype: $result_hash(table_name).$result_hash(column_name)" doc_return 200 "text/html" " [im_header $page_title [im_rest_header_extra_stuff]][im_navbar]
Attribute | Value |
Attribute | Value |
sql=$sql\nhash=[join [array get result_hash] "\n"]" return } ad_proc -private im_rest_get_im_hour { { -format "xml" } { -user_id 0 } { -rest_otype "" } { -rest_oid 0 } { -query_hash_pairs {} } } { Handler for GET rest calls to retreive timesheet hours } { ns_log Notice "im_rest_get_im_hour: format=$format, user_id=$user_id, rest_otype=$rest_otype, rest_oid=$rest_oid, query_hash=$query_hash_pairs" # Check that rest_oid is an integer im_security_alert_check_integer -location "im_rest_get_im_hour" -value $rest_oid # ------------------------------------------------------- # Get the SQL to extract all values from the object set sql "select * from im_hours where hour_id = :rest_oid" # Execute the sql. As a result we get a result_hash with keys # corresponding to table columns and values array set result_hash {} db_with_handle db { set selection [db_exec select $db query $sql 1] while { [db_getrow $db $selection] } { set col_names [ad_ns_set_keys $selection] set this_result [list] for { set i 0 } { $i < [ns_set size $selection] } { incr i } { set var [lindex $col_names $i] set val [ns_set value $selection $i] set result_hash($var) $val } } } db_release_unused_handles if {{} == [array get result_hash]} { return [im_rest_error -format $format -http_status 404 -message "Timesheet Hour: Did not find object '$rest_otype' with the ID '$rest_oid'."] } # ------------------------------------------------------- # Format the result for one of the supported formats set result "" foreach result_key [array names result_hash] { set result_val $result_hash($result_key) append result [im_rest_format_line \ -column $result_key \ -value $result_val \ -format $format \ -rest_otype $rest_otype \ ] } switch $format { html { set page_title "$rest_otype: $rest_oid" doc_return 200 "text/html" " [im_header $page_title [im_rest_header_extra_stuff]][im_navbar]
Attribute | Value |
$where_clause" # ------------------------------------------------------- # Select SQL: Pull out objects where the acs_objects.object_type # is correct AND the object exists in the object type's primary table. # This way we avoid "dangling objects" in acs_objects and sub-types. set sql [im_rest_object_type_select_sql -rest_otype $rest_otype -no_where_clause_p 1] append sql " where o.object_type = :rest_otype and o.object_id in ( select t.$id_column as rest_oid from $table_name t ) $where_clause " # Append sorting "ORDER BY" clause to the sql. append sql [im_rest_object_type_order_sql -query_hash_pairs $query_hash_pairs] # Append pagination "LIMIT $limit OFFSET $start" to the sql. set unlimited_sql $sql append sql [im_rest_object_type_pagination_sql -query_hash_pairs $query_hash_pairs] # ad_return_complaint 1 "
$sql" # ------------------------------------------------------- # Loop through all objects of the specified type set obj_ctr 0 set result "" db_foreach objects $sql { # Skip objects with empty object name if {"" == $object_name} { ns_log Error "im_rest_get_object_type: Skipping object #$object_id because object_name is empty." continue } # ------------------------------------------------------- # Permissions # Denied access? if {$rest_otype_read_none_p} { continue } # Check permissions set read_p $rest_otype_read_all_p if {!$read_p} { # This is one of the "custom" object types - check the permission: # This may be quite slow checking 100.000 objects one-by-one... catch { eval "${rest_otype}_permissions $current_user_id $rest_oid view_p read_p write_p admin_p" } } if {!$read_p} { continue } set url "$base_url/$rest_otype/$rest_oid" switch $format { xml { append result "
object_id | Link |
object_id | Link |
object_id | Link |
object_id | Link |
object_id | Link |
Object ID |
Object ID |
Object ID |
$status_message |
User ID | @user_id@ |
User | @name@ |
Username | @username@ |
Auto-Login Token | @auto_login@ |
|
@page_title@This page lists all ]project-open[ object types that are exposed through this REST Web-Service API, together with the implementation status of CRUL (Create, Read, Update and List) operations (see below) for each object type and a link to the ]project-open[ Documentation Wiki.
AuthenticationAuthentication of the REST API is managed per user, applying the same access right as with the Web GUI. A user will only see the objects he or she would also see via the Web GUI. This mechanism includes the case of external users including customers and providers to access to ]po[. The ]project-open[ REST API supports the following authentication mechanisms:
XML and HTML Output FormatsEvery page in the REST API understands the optional parameter "&format=<format>" where format can be one of {html|xml}. The default format for cookie authentication is html, while the default for Basic HTTP and auto-login authentication is xml. |
@version@