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] reworked creation request

Eric Schuberte7c59e00af49
diff --git a/docs/api/apiv3/components/schemas/work_package_file_link_model.yml b/docs/api/apiv3/components/schemas/file_link_model.yml
similarity index 75%
rename from docs/api/apiv3/components/schemas/work_package_file_link_model.yml
rename to docs/api/apiv3/components/schemas/file_link_model.yml
index 82dc5816dee..ab0a8002a76 100644
--- a/docs/api/apiv3/components/schemas/work_package_file_link_model.yml
+++ b/docs/api/apiv3/components/schemas/file_link_model.yml
@@ -1,11 +1,10 @@
-# Schema: Work_Package_File_Link_Model
+# Schema: File_LinkModel
---
type: object
required:
- id
- _type
- storageType
- - storageId
- originData
properties:
id:
@@ -19,9 +18,6 @@ properties:
storageType:
type: string
readOnly: true
- storageId:
- type: integer
- readOnly: true
createdAt:
type: string
format: date-time
@@ -33,35 +29,12 @@ properties:
description: Time of the most recent change to the file link
readOnly: true
originData:
- type: object
- properties:
- id:
- type: string
- description: Linked file's id on the origin
- name:
- type: string
- description: Linked file's name on the origin
- mimeType:
- type: string
- description: MIME type of the linked file
- createdAt:
- type: string
- format: date-time
- description: Timestamp of the creation datetime of the file on the origin
- lastModifiedAt:
- type: string
- format: date-time
- description: Timestamp of the datetime of the last modification of the file on the origin
- createdByName:
- type: string
- description: Display name of the author that created the file on the origin
- lastModifiedByName:
- type: string
- description: Display name of the author that modified the file on the origin last
+ $ref: '#/components/schemas/File_Link_Origin_DataModel'
_links:
type: object
required:
- self
+ - storage
- container
- delete
- downloadLocation
@@ -76,6 +49,14 @@ properties:
**Resource**: FileLink
readOnly: true
+ storage:
+ allOf:
+ - $ref: './link.yml'
+ - description: |-
+ The storage url the file link references to.
+
+ **Resource**: N/A
+ readOnly: true
container:
allOf:
- $ref: './link.yml'
@@ -118,11 +99,11 @@ properties:
**Resource**: N/A
readOnly: true
+
example:
id: 1337
_type: FileLink
storageType: nextcloud
- storageId: 2
createdAt: '2021-12-20T13:37:00.211Z'
updatedAt: '2021-12-20T13:37:00.211Z'
originData:
@@ -137,6 +118,9 @@ example:
self:
href: /api/v3/work_package/17/file_links/1337
title: file link
+ storage:
+ href: https://nextcloud.deathstar.rocks/
+ title: Link to storage
container:
href: /api/v3/work_package/17
title: work package
@@ -152,4 +136,3 @@ example:
originOpen:
href: https://nextcloud.deathstar.rocks/index.php/f?fileid=5503
title: file open
-
diff --git a/docs/api/apiv3/components/schemas/file_link_origin_data_model.yml b/docs/api/apiv3/components/schemas/file_link_origin_data_model.yml
new file mode 100644
index 00000000000..f4bfe297465
--- /dev/null
+++ b/docs/api/apiv3/components/schemas/file_link_origin_data_model.yml
@@ -0,0 +1,37 @@
+# Schema: File_Link_Origin_DataModel
+---
+type: object
+required:
+ - id
+ - name
+ - mimeType
+ - createdAt
+ - lastModifiedAt
+ - createdByName
+ - lastModifiedByName
+properties:
+ id:
+ type: string
+ description: Linked file's id on the origin
+ name:
+ type: string
+ description: Linked file's name on the origin
+ mimeType:
+ type: string
+ minLength: 0
+ description: MIME type of the linked file
+ createdAt:
+ type: string
+ format: date-time
+ description: Timestamp of the creation datetime of the file on the origin
+ lastModifiedAt:
+ type: string
+ format: date-time
+ description: Timestamp of the datetime of the last modification of the file on the origin
+ createdByName:
+ type: string
+ description: Display name of the author that created the file on the origin
+ lastModifiedByName:
+ type: string
+ description: Display name of the author that modified the file on the origin last
+
\ No newline at end of file
diff --git a/docs/api/apiv3/components/schemas/watchers_model.yml b/docs/api/apiv3/components/schemas/watchers_model.yml
index 661da92616d..0438905e772 100644
--- a/docs/api/apiv3/components/schemas/watchers_model.yml
+++ b/docs/api/apiv3/components/schemas/watchers_model.yml
@@ -24,7 +24,7 @@ example:
method: POST
delete:
href: "/api/v3/users/1"
- title: Delete j.sheppard#
+ title: Delete j.sheppard
method: DELETE
id: 1
login: j.sheppard
diff --git a/docs/api/apiv3/openapi-spec.yml b/docs/api/apiv3/openapi-spec.yml
index e1bf45f6bc7..5a662ff3f7c 100644
--- a/docs/api/apiv3/openapi-spec.yml
+++ b/docs/api/apiv3/openapi-spec.yml
@@ -398,6 +398,8 @@ paths:
"$ref": "./paths/work_package_file_link.yml"
"/api/v3/work_packages/{id}/file_links/{file_link_id}/download":
"$ref": "./paths/work_package_file_link_download.yml"
+ "/api/v3/work_packages/{id}/file_links/{file_link_id}/open":
+ "$ref": "./paths/work_package_file_link_open.yml"
"/api/v3/work_packages/{id}/form":
"$ref": "./paths/work_package_form.yml"
"/api/v3/work_packages/{id}/revisions":
@@ -519,6 +521,10 @@ components:
"$ref": "./components/schemas/example_schema_model.yml"
Execute_custom_action:
"$ref": "./components/schemas/execute_custom_action.yml"
+ File_LinkModel:
+ "$ref": "./components/schemas/file_link_model.yml"
+ File_Link_Origin_DataModel:
+ "$ref": "./components/schemas/file_link_origin_data_model.yml"
FormModel:
"$ref": "./components/schemas/form_model.yml"
Formattable:
@@ -747,8 +753,6 @@ components:
"$ref": "./components/schemas/work_package_create_form_for_project.yml"
Work_Package_Edit_Form:
"$ref": "./components/schemas/work_package_edit_form.yml"
- Work_Package_File_LinkModel:
- "$ref": "./components/schemas/work_package_file_link_model.yml"
Work_Package_Relation_FormModel:
"$ref": "./components/schemas/work_package_relation_form_model.yml"
Work_Package_Schema:
diff --git a/docs/api/apiv3/paths/work_package_file_link.yml b/docs/api/apiv3/paths/work_package_file_link.yml
index fe522107b31..c720708a78a 100644
--- a/docs/api/apiv3/paths/work_package_file_link.yml
+++ b/docs/api/apiv3/paths/work_package_file_link.yml
@@ -29,7 +29,7 @@ get:
content:
application/hal+json:
schema:
- $ref: '#/components/schemas/Work_Package_File_LinkModel'
+ $ref: '#/components/schemas/File_LinkModel'
headers: { }
'403':
content:
@@ -40,11 +40,10 @@ get:
_type: Error
errorIdentifier: urn:openproject-org:api:v3:errors:MissingPermission
message: You are not allowed to delete file links of this work package.
- # TODO: specify permissions, will there be even any except from viewing the wp?
description: |-
Returned if the client does not have sufficient permissions.
- **Required permission:** edit work package
+ **Required permission:** view file links
*Note that you will only receive this error, if you are at least allowed to see the corresponding work package.*
'404':
@@ -99,11 +98,10 @@ delete:
_type: Error
errorIdentifier: urn:openproject-org:api:v3:errors:MissingPermission
message: You are not allowed to delete file links of this work package.
- # TODO: specify permissions, will there be even any except from viewing the wp?
description: |-
Returned if the client does not have sufficient permissions.
- **Required permission:** edit work package
+ **Required permission:** manage file links
*Note that you will only receive this error, if you are at least allowed to see the corresponding work package.*
'404':
diff --git a/docs/api/apiv3/paths/work_package_file_link_download.yml b/docs/api/apiv3/paths/work_package_file_link_download.yml
index 1f8dcc87b64..8c1311ec8a1 100644
--- a/docs/api/apiv3/paths/work_package_file_link_download.yml
+++ b/docs/api/apiv3/paths/work_package_file_link_download.yml
@@ -41,11 +41,10 @@ post:
_type: Error
errorIdentifier: urn:openproject-org:api:v3:errors:MissingPermission
message: You are not allowed to delete file links of this work package.
- # TODO: specify permissions, will there be even any except from viewing the wp?
description: |-
Returned if the client does not have sufficient permissions.
- **Required permission:** edit work package
+ **Required permission:** view file links
*Note that you will only receive this error, if you are at least allowed to see the corresponding work package.*
'404':
@@ -60,4 +59,4 @@ post:
description: |-
Returned if the work package does not exist or the client does not have sufficient permissions to see it.
- **Required permission:** view work package
\ No newline at end of file
+ **Required permission:** view work package
diff --git a/docs/api/apiv3/paths/work_package_file_link_open.yml b/docs/api/apiv3/paths/work_package_file_link_open.yml
new file mode 100644
index 00000000000..6c1ece6c890
--- /dev/null
+++ b/docs/api/apiv3/paths/work_package_file_link_open.yml
@@ -0,0 +1,62 @@
+# /api/v3/work_packages/{id}/file_links/{file_link_id}/open
+---
+post:
+ summary: Creates an opening uri of the linked file.
+ operationId: Work_Package_File_Link_Open
+ tags:
+ - Work Packages
+ - File links
+ description: |-
+ Creates a uri to open the origin file linked by the given file link. This uri depends on the storage type and
+ always is located on the origin storage itself.
+ parameters:
+ - name: id
+ description: Work package id
+ in: path
+ required: true
+ schema:
+ type: integer
+ example: 1337
+ - name: file_link_id
+ description: File link id
+ in: path
+ required: true
+ schema:
+ type: integer
+ example: 42
+ responses:
+ '200':
+ description: OK
+ content:
+ application/hal+json:
+ schema:
+ $ref: '#/components/schemas/Link'
+ headers: { }
+ '403':
+ content:
+ application/hal+json:
+ schema:
+ $ref: "#/components/schemas/ErrorResponse"
+ example:
+ _type: Error
+ errorIdentifier: urn:openproject-org:api:v3:errors:MissingPermission
+ message: You are not allowed to delete file links of this work package.
+ description: |-
+ Returned if the client does not have sufficient permissions.
+
+ **Required permission:** view file links
+
+ *Note that you will only receive this error, if you are at least allowed to see the corresponding work package.*
+ '404':
+ content:
+ application/hal+json:
+ schema:
+ $ref: "#/components/schemas/ErrorResponse"
+ example:
+ _type: Error
+ errorIdentifier: urn:openproject-org:api:v3:errors:NotFound
+ message: The requested resource could not be found.
+ description: |-
+ Returned if the work package does not exist or the client does not have sufficient permissions to see it.
+
+ **Required permission:** view work package
diff --git a/docs/api/apiv3/paths/work_package_file_links.yml b/docs/api/apiv3/paths/work_package_file_links.yml
index 9225feb9432..b937b95a5ef 100644
--- a/docs/api/apiv3/paths/work_package_file_links.yml
+++ b/docs/api/apiv3/paths/work_package_file_links.yml
@@ -1,4 +1,4 @@
-# /api/v3/work_packages/{id}/file_links
+# /api/v3/work_packages/{id}/file_links/
---
post:
summary: Creates file links.
@@ -12,7 +12,10 @@ post:
The request body must contain the generated storage token, and not the storage id. In addition, the request must
send the origin file id and the stored meta data.
- If there is already a link on the given work package with the same file id, the previous data is not overwritten.
+ If there is already a link on the given work package with the same file id from the same storage, the previous
+ data is not overwritten.
+
+ As it is possible to link folders from a storage to a work package, the _mimeType_ of this entity can be empty.
parameters:
- name: id
description: Work package id
@@ -27,58 +30,38 @@ post:
schema:
type: object
required:
- - storage
- - files
+ - _type
+ - count
+ - total
+ - _embedded
properties:
- storage:
+ _type:
type: string
- description: the storage token
- files:
- type: array
- items:
- type: object
- required:
- - id
- - name
- - mimeType
- - createdAt
- - lastModifiedAt
- - createdByName
- - lastModifiedByName
- properties:
- id:
- type: string
- name:
- type: string
- mimeType:
- type: string
- createdAt:
- type: string
- format: date-time
- lastModifiedAt:
- type: string
- format: date-time
- createdByName:
- type: string
- lastModifiedByName:
- type: string
- example:
- storage: e24fac19b889cc23b6f
- files:
- - id: 5503
- name: logo.png
- mimeType: image/png
- createdAt: '2022-01-18T12:01:37.302Z'
- lastModifiedAt: '2022-01-18T12:07:17.017Z'
- createdByName: Leia Organa
- lastModifiedByName: Anakin Skywalker
- - id: 5504
- name: README.md
- mimeType: text/plain
- createdAt: '2022-01-18T12:02:12.117Z'
- lastModifiedAt: '2022-01-18T12:02:12.117Z'
- createdByName: Bale Organa
- lastModifiedByName: Anakin Skywalker
+ enum:
+ - Collection
+ count:
+ type: integer
+ minimum: 0
+ total:
+ type: integer
+ minimum: 0
+ _embedded:
+ type: object
+ required:
+ - elements
+ properties:
+ elements:
+ type: array
+ items:
+ allOf:
+ - $ref: '#/components/schemas/File_LinkModel'
+ - type: object
+ required:
+ - storageUrl
+ properties:
+ storageUrl:
+ type: string
+ format: uri
responses:
'201':
description: Created
@@ -110,7 +93,7 @@ post:
elements:
type: array
items:
- $ref: '#/components/schemas/Work_Package_File_LinkModel'
+ $ref: '#/components/schemas/File_LinkModel'
'400':
content:
application/hal+json:
@@ -130,11 +113,10 @@ post:
_type: Error
errorIdentifier: urn:openproject-org:api:v3:errors:MissingPermission
message: You are not allowed to create file links of this work package.
- # TODO: specify permissions, will there be even any except from viewing the wp?
description: |-
Returned if the client does not have sufficient permissions.
- **Required permission:** edit work package
+ **Required permission:** manage file links
*Note that you will only receive this error, if you are at least allowed to see the corresponding work package.*
'404':
@@ -168,19 +150,6 @@ get:
schema:
type: integer
example: 1337
- - name: filters
- in: query
- required: false
- schema:
- type: string
- description: |-
- JSON specifying filter conditions.
-
- Accepts the same format as returned by the [queries](https://www.openproject.org/docs/api/endpoints/queries/) endpoint. Currently supported filters are:
-
- - storage_id: the identifier of a storage the file links refer to
- - storage_type: the type of a storage of file links
- example: '[{ "storage_type": { "operator": "=", "values": ["nextcloud"] } }]'
responses:
'200':
description: OK
@@ -212,7 +181,7 @@ get:
elements:
type: array
items:
- $ref: '#/components/schemas/Work_Package_File_LinkModel'
+ $ref: '#/components/schemas/File_LinkModel'
'403':
content:
application/hal+json:
@@ -222,11 +191,10 @@ get:
_type: Error
errorIdentifier: urn:openproject-org:api:v3:errors:MissingPermission
message: You are not allowed to create file links of this work package.
- # TODO: specify permissions, will there be even any except from viewing the wp?
description: |-
Returned if the client does not have sufficient permissions.
- **Required permission:** edit work package
+ **Required permission:** view file links
*Note that you will only receive this error, if you are at least allowed to see the corresponding work package.*
'404':
diff --git a/docs/api/apiv3/paths/work_packages.yml b/docs/api/apiv3/paths/work_packages.yml
index 85ed766ddc4..98c7de91ef6 100644
--- a/docs/api/apiv3/paths/work_packages.yml
+++ b/docs/api/apiv3/paths/work_packages.yml
@@ -21,6 +21,7 @@ get:
JSON specifying filter conditions.
Accepts the same format as returned by the [queries](https://www.openproject.org/docs/api/endpoints/queries/) endpoint. If no filter is to be applied, the client should send an empty array (`[]`).
example: '[{ "type_id": { "operator": "=", "values": [''1'', ''2''] }}]'
+ # TODO: describe filters more, and add file links
in: query
name: filters
required: false