Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

[#40228] added API skeleton

Eric Schubert819055dfce75
diff --git a/lib/api/v3/work_packages/work_packages_api.rb b/lib/api/v3/work_packages/work_packages_api.rb
index a8ee12d58ce..515bc0afdd9 100644
--- a/lib/api/v3/work_packages/work_packages_api.rb
+++ b/lib/api/v3/work_packages/work_packages_api.rb
@@ -1,6 +1,6 @@
#-- copyright
# OpenProject is an open source project management software.
-# Copyright (C) 2012-2021 the OpenProject GmbH
+# Copyright (C) 2012-2022 the OpenProject GmbH
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
@@ -102,6 +102,7 @@ module API
mount ::API::V3::WorkPackages::AvailableProjectsOnEditAPI
mount ::API::V3::WorkPackages::AvailableRelationCandidatesAPI
mount ::API::V3::WorkPackages::WorkPackageRelationsAPI
+ mount ::API::V3::FileLinks::FileLinksAPI
end
mount ::API::V3::WorkPackages::CreateFormAPI
diff --git a/modules/storages/lib/api/v3/file_links/file_links_api.rb b/modules/storages/lib/api/v3/file_links/file_links_api.rb
new file mode 100644
index 00000000000..610e92cca9b
--- /dev/null
+++ b/modules/storages/lib/api/v3/file_links/file_links_api.rb
@@ -0,0 +1,58 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2022 the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+#++
+
+module API
+ module V3
+ module FileLinks
+ class FileLinksAPI < ::API::OpenProjectAPI
+ resources :file_links do
+ get do
+ raise ::API::Errors::NotImplemented
+ end
+
+ post do
+ raise ::API::Errors::NotImplemented
+ end
+
+ route_param :file_link_id, type: Integer, desc: 'File link id' do
+ get do
+ raise ::API::Errors::NotImplemented
+ end
+
+ delete do
+ raise ::API::Errors::NotImplemented
+ end
+
+ mount ::API::V3::FileLinks::FileLinksDownloadAPI
+ mount ::API::V3::FileLinks::FileLinksOpenAPI
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/modules/storages/lib/api/v3/file_links/file_links_download_api.rb b/modules/storages/lib/api/v3/file_links/file_links_download_api.rb
new file mode 100644
index 00000000000..a01b0dfef35
--- /dev/null
+++ b/modules/storages/lib/api/v3/file_links/file_links_download_api.rb
@@ -0,0 +1,41 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2022 the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+#++
+
+module API
+ module V3
+ module FileLinks
+ class FileLinksDownloadAPI < ::API::OpenProjectAPI
+ resources :download do
+ get do
+ raise ::API::Errors::NotImplemented
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/modules/storages/lib/api/v3/file_links/file_links_open_api.rb b/modules/storages/lib/api/v3/file_links/file_links_open_api.rb
new file mode 100644
index 00000000000..ab885311102
--- /dev/null
+++ b/modules/storages/lib/api/v3/file_links/file_links_open_api.rb
@@ -0,0 +1,41 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2022 the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+#++
+
+module API
+ module V3
+ module FileLinks
+ class FileLinksOpenAPI < ::API::OpenProjectAPI
+ resources :open do
+ get do
+ raise ::API::Errors::NotImplemented
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/modules/storages/lib/open_project/storages/engine.rb b/modules/storages/lib/open_project/storages/engine.rb
index 31e1c20e9e4..d3de4f437e2 100644
--- a/modules/storages/lib/open_project/storages/engine.rb
+++ b/modules/storages/lib/open_project/storages/engine.rb
@@ -1,6 +1,13 @@
-# OpenProject Team Planner module
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2022 the OpenProject GmbH
#
-# Copyright (C) 2021 OpenProject GmbH
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -15,6 +22,9 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+#++
module OpenProject::Storages
class Engine < ::Rails::Engine
@@ -53,5 +63,21 @@ module OpenProject::Storages
caption: :'storages.label_storage',
parent: :settings
end
+
+ add_api_path :file_links do |work_package_id|
+ "#{work_package(work_package_id)}/file_links"
+ end
+
+ add_api_path :file_link do |work_package_id, file_link_id|
+ "#{work_package(work_package_id)}/file_links/#{file_link_id}"
+ end
+
+ add_api_path :file_link_download do |work_package_id, file_link_id|
+ "#{work_package(work_package_id)}/file_links/#{file_link_id}/download"
+ end
+
+ add_api_path :file_link_open do |work_package_id, file_link_id|
+ "#{work_package(work_package_id)}/file_links/#{file_link_id}/open"
+ end
end
end
diff --git a/modules/storages/spec/features/create_file_links_spec.rb b/modules/storages/spec/features/create_file_links_spec.rb
new file mode 100644
index 00000000000..aed444cf903
--- /dev/null
+++ b/modules/storages/spec/features/create_file_links_spec.rb
@@ -0,0 +1,31 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2021 the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+#++
+
+describe 'Create file links on a work package' do
+
+end
diff --git a/modules/storages/spec/requests/api/v3/file_links/file_links_spec.rb b/modules/storages/spec/requests/api/v3/file_links/file_links_spec.rb
new file mode 100644
index 00000000000..e720393211f
--- /dev/null
+++ b/modules/storages/spec/requests/api/v3/file_links/file_links_spec.rb
@@ -0,0 +1,124 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2022 the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+#++
+
+require 'spec_helper'
+
+describe 'API v3 file links resource', type: :request do
+ include API::V3::Utilities::PathHelper
+
+ let(:permissions) { %i(view_work_packages) }
+ let(:role) { FactoryBot.create(:role, permissions: permissions) }
+ let(:project) { FactoryBot.create(:project) }
+
+ let(:current_user) do
+ FactoryBot.create(:user, member_in_project: project, member_through_role: role)
+ end
+
+ let(:work_package) do
+ FactoryBot.create :work_package, author: current_user, project: project
+ end
+
+ subject(:response) { last_response }
+
+ before do
+ login_as current_user
+ end
+
+ describe 'GET /api/v3/work_packages/:work_package_id/file_links' do
+ let(:path) { api_v3_paths.file_links(work_package.id) }
+
+ before do
+ get path
+ end
+
+ it 'returns not implemented' do
+ expect(subject.status).to eql 501
+ end
+ end
+
+ describe 'POST /api/v3/work_packages/:work_package_id/file_links' do
+ let(:path) { api_v3_paths.file_links(work_package.id) }
+ let(:params) { {} }
+
+ before do
+ post path, params.to_json, 'CONTENT_TYPE' => 'application/json'
+ end
+
+ it 'returns not implemented' do
+ expect(subject.status).to eql 501
+ end
+ end
+
+ describe 'GET /api/v3/work_packages/:work_package_id/file_links/:file_link_id' do
+ let(:path) { api_v3_paths.file_link(work_package.id, 1337) }
+
+ before do
+ get path
+ end
+
+ it 'returns not implemented' do
+ expect(subject.status).to eql 501
+ end
+ end
+
+ describe 'DELETE /api/v3/work_packages/:work_package_id/file_links/:file_link_id' do
+ let(:path) { api_v3_paths.file_link(work_package.id, 1337) }
+
+ before do
+ post path
+ end
+
+ it 'returns not implemented' do
+ expect(subject.status).to eql 501
+ end
+ end
+
+ describe 'GET /api/v3/work_packages/:work_package_id/file_links/:file_link_id/download' do
+ let(:path) { api_v3_paths.file_link_download(work_package.id, 1337) }
+
+ before do
+ get path
+ end
+
+ it 'returns not implemented' do
+ expect(subject.status).to eql 501
+ end
+ end
+
+ describe 'GET /api/v3/work_packages/:work_package_id/file_links/:file_link_id/open' do
+ let(:path) { api_v3_paths.file_link_open(work_package.id, 1337) }
+
+ before do
+ get path
+ end
+
+ it 'returns not implemented' do
+ expect(subject.status).to eql 501
+ end
+ end
+end