Module: Rubydora::FedoraUrlHelpers
- Included in:
- RestApiClient
- Defined in:
- lib/rubydora/fedora_url_helpers.rb
Constant Summary collapse
- API_DOCUMENTATION =
Fedora API documentation available at https://wiki.duraspace.org/display/FCR30/REST+API
'https://wiki.duraspace.org/display/FCR30/REST+API'
Instance Method Summary collapse
-
#datastream_content_url(pid, dsid = nil, options = nil) ⇒ String
URI.
-
#datastream_history_url(pid, dsid = nil, options = nil) ⇒ String
URI.
-
#datastream_url(pid, dsid, options = nil) ⇒ String
Generate a base datastream REST API endpoint URI.
-
#datastreams_url(pid, options = nil) ⇒ String
Generate a base datastream REST API endpoint URI.
- #describe_repository_url(options = nil) ⇒ Object
-
#dissemination_url(pid, sdef = nil, method = nil, options = nil) ⇒ String
Generate a base object dissemination REST API endpoint URI.
-
#export_object_url(pid, options = nil) ⇒ String
URI.
-
#find_objects_url(options = nil) ⇒ String
URI.
-
#new_object_relationship_url(pid, options = nil) ⇒ String
URI.
- #new_object_url(options = nil) ⇒ Object
-
#next_pid_url(options = nil) ⇒ String
URI.
-
#object_relationship_url(pid, options = nil) ⇒ String
URI.
-
#object_url(pid, options = nil) ⇒ String
Generate a base object REST API endpoint URI.
-
#object_versions_url(pid, options = nil) ⇒ String
URI.
-
#object_xml_url(pid, options = nil) ⇒ String
URI.
-
#url_for(base, options = nil) ⇒ String
Generate a REST API compatible URI.
-
#validate_object_url(pid, options = nil) ⇒ String
URI.
Instance Method Details
#datastream_content_url(pid, dsid = nil, options = nil) ⇒ String
Returns URI.
78 79 80 |
# File 'lib/rubydora/fedora_url_helpers.rb', line 78 def datastream_content_url(pid, dsid = nil, = nil) url_for(datastream_url(pid, dsid) + "/content", ) end |
#datastream_history_url(pid, dsid = nil, options = nil) ⇒ String
Returns URI.
86 87 88 |
# File 'lib/rubydora/fedora_url_helpers.rb', line 86 def datastream_history_url(pid, dsid = nil, = nil) url_for(datastream_url(pid, dsid) + "/history", ) end |
#datastream_url(pid, dsid, options = nil) ⇒ String
Generate a base datastream REST API endpoint URI
59 60 61 62 |
# File 'lib/rubydora/fedora_url_helpers.rb', line 59 def datastream_url(pid, dsid, = nil) raise ArgumentError, "You must provide a pid and a dsid" unless pid && dsid url_for(object_url(pid) + "/datastreams/#{CGI::escape(dsid)}", ) end |
#datastreams_url(pid, options = nil) ⇒ String
Generate a base datastream REST API endpoint URI
69 70 71 72 |
# File 'lib/rubydora/fedora_url_helpers.rb', line 69 def datastreams_url(pid, = nil) raise ArgumentError, "You must provide a pid" unless pid url_for(object_url(pid) + "/datastreams", ) end |
#describe_repository_url(options = nil) ⇒ Object
15 16 17 |
# File 'lib/rubydora/fedora_url_helpers.rb', line 15 def describe_repository_url( = nil) url_for("describe", ) end |
#dissemination_url(pid, sdef = nil, method = nil, options = nil) ⇒ String
Generate a base object dissemination REST API endpoint URI
49 50 51 52 |
# File 'lib/rubydora/fedora_url_helpers.rb', line 49 def dissemination_url(pid, sdef = nil, method = nil, = nil) raise ArgumentError, "You must provide a pid" unless pid url_for(object_url(pid) + "/methods" + (("/#{CGI::escape(sdef)}" if sdef) || '') + (("/#{CGI::escape(method)}" if method) || ''), ) end |
#export_object_url(pid, options = nil) ⇒ String
Returns URI.
100 101 102 |
# File 'lib/rubydora/fedora_url_helpers.rb', line 100 def export_object_url(pid, = nil) url_for(object_url(pid) + "/export", ) end |
#find_objects_url(options = nil) ⇒ String
Returns URI.
39 40 41 |
# File 'lib/rubydora/fedora_url_helpers.rb', line 39 def find_objects_url( = nil) url_for("objects", ) end |
#new_object_relationship_url(pid, options = nil) ⇒ String
Returns URI.
128 129 130 |
# File 'lib/rubydora/fedora_url_helpers.rb', line 128 def new_object_relationship_url(pid, = nil) url_for(object_relationship_url(pid) + "/new", ) end |
#new_object_url(options = nil) ⇒ Object
27 28 29 |
# File 'lib/rubydora/fedora_url_helpers.rb', line 27 def new_object_url( = nil) object_url "new", end |
#next_pid_url(options = nil) ⇒ String
Returns URI.
33 34 35 |
# File 'lib/rubydora/fedora_url_helpers.rb', line 33 def next_pid_url( = nil) url_for("objects/nextPID", ) end |
#object_relationship_url(pid, options = nil) ⇒ String
Returns URI.
121 122 123 |
# File 'lib/rubydora/fedora_url_helpers.rb', line 121 def object_relationship_url(pid, = nil) url_for(object_url(pid) + "/relationships", ) end |
#object_url(pid, options = nil) ⇒ String
Generate a base object REST API endpoint URI
23 24 25 |
# File 'lib/rubydora/fedora_url_helpers.rb', line 23 def object_url(pid, = nil) url_for("objects" + (("/#{CGI::escape(pid.to_s.gsub('info:fedora/', ''))}" if pid) || ''), ) end |
#object_versions_url(pid, options = nil) ⇒ String
Returns URI.
107 108 109 |
# File 'lib/rubydora/fedora_url_helpers.rb', line 107 def object_versions_url(pid, = nil) url_for(object_url(pid) + "/versions", ) end |
#object_xml_url(pid, options = nil) ⇒ String
Returns URI.
114 115 116 |
# File 'lib/rubydora/fedora_url_helpers.rb', line 114 def object_xml_url(pid, = nil) url_for(object_url(pid) + "/objectXML", ) end |
#url_for(base, options = nil) ⇒ String
Generate a REST API compatible URI
10 11 12 13 |
# File 'lib/rubydora/fedora_url_helpers.rb', line 10 def url_for(base, = nil) return base unless .is_a? Hash "#{base}" + (("?#{.map { |key, value| "#{CGI::escape(key.to_s)}=#{CGI::escape(value.to_s)}"}.join("&") }" if && !.empty?) || '') end |
#validate_object_url(pid, options = nil) ⇒ String
Returns URI.
93 94 95 |
# File 'lib/rubydora/fedora_url_helpers.rb', line 93 def validate_object_url(pid, = nil) url_for(object_url(pid) + "/validate", ) end |