diff --git a/sechub-doc/src/test/java/com/mercedesbenz/sechub/restdoc/AssetRestControllerRestDocTest.java b/sechub-doc/src/test/java/com/mercedesbenz/sechub/restdoc/AssetRestControllerRestDocTest.java index d814dffd8..ee169176d 100644 --- a/sechub-doc/src/test/java/com/mercedesbenz/sechub/restdoc/AssetRestControllerRestDocTest.java +++ b/sechub-doc/src/test/java/com/mercedesbenz/sechub/restdoc/AssetRestControllerRestDocTest.java @@ -246,7 +246,7 @@ public void restDoc_admin_uploads_assetfile() throws Exception { requestHeaders( ), pathParameters( - parameterWithName(ASSET_ID.paramName()).description("The id of the asset for the file shall be uploaded.") + parameterWithName(ASSET_ID.paramName()).description("The id of the asset to which the uploaded file belongs to") ), queryParameters( parameterWithName(MULTIPART_CHECKSUM).description("A sha256 checksum for file upload validation") diff --git a/sechub-openapi-java/src/main/resources/openapi.yaml b/sechub-openapi-java/src/main/resources/openapi.yaml index 40f912133..991c6d852 100644 --- a/sechub-openapi-java/src/main/resources/openapi.yaml +++ b/sechub-openapi-java/src/main/resources/openapi.yaml @@ -2036,15 +2036,35 @@ components: items: $ref: '#/components/schemas/TemplateVariable' + AssetDetailData: + title: AssetDetailData + type: object + properties: + assetId: + type: string + files: + type: array + items: + type: object + $ref: '#/components/schemas/AssetFileData' + AssetFileData: + title: AssetFileData + type: object + properties: + fileName: + type: string + checksum: + type: string + security: - basicAuth: [ ] paths: - ############# + ############ ## System ## - ############# + ############ /api/anonymous/check/alive: get: @@ -3932,4 +3952,164 @@ paths: description: "Not found" tags: - Configuration - \ No newline at end of file + + /api/admin/asset/ids: + get: + summary: Admin fetches asset ids + description: An administrator fetches all available asset ids. + operationId: adminFetchAssetIds + responses: + "200": + description: "Ok" + content: + application/json;charset=UTF-8: + schema: + type: array + items: + type: string + tags: + - Configuration + + /api/admin/asset/{assetId}/details: + get: + summary: Admin fetches asset details + description: "An administrator fetches details about an asset. For example: the result will contain names but also checksum of files." + operationId: adminFetchAssetDetails + parameters: + - name: assetId + description: The asset identifier + in: path + required: true + schema: + type: string + responses: + "200": + description: "Ok" + content: + application/json: + schema: + $ref: '#/components/schemas/AssetDetailData' + + "404": + description: "Not found" + tags: + - Configuration + + /api/admin/asset/{assetId}: + delete: + summary: Admin deletes asset comletely + description: An administrator deletes an asset completely. + operationId: adminDeletesAssetCompletely + parameters: + - name: assetId + description: TThe asset identifier for the asset which shall be deleted completely + in: path + required: true + schema: + type: string + responses: + "200": + description: "Ok" + + "404": + description: "Not found" + tags: + - Configuration + + /api/admin/asset/{assetId}/file/{fileName}: + delete: + summary: Admin deletes an asset file + description: An administrator deletes a file fom an asset. + operationId: adminDeletesAssetFile + parameters: + - name: assetId + description: The asset identifier for the asset in which the file shall be deleted. + in: path + required: true + schema: + type: string + - name: fileName + description: The name of the file to delete inside the asset. + in: path + required: true + schema: + type: string + responses: + "200": + description: "Ok" + + "404": + description: "Not found" + tags: + - Configuration + + /api/admin/asset/{assetId}/file: + post: + summary: Admin uploads an asset file + description: "An administrator uploads a file for an asset. If the file already exits, it will be overriden." + operationId: adminUploadsAssetFile + parameters: + - name: assetId + description: The id of the asset to which the uploaded file belongs to + in: path + required: true + schema: + type: string + requestBody: + required: true + content: + multipart/form-data: + schema: + type: object + properties: + file: + type: string + format: binary + description: The asset file to upload + checkSum: + type: string + description: A sha256 checksum for file upload validation + required: + - file + - checkSum + encoding: + file: + contentType: multipart/form-data + responses: + "200": + description: "Ok" + "406": + description: "Not acceptable" + x-content-type: multipart/form-data + tags: + - Configuration + + /api/admin/asset/{assetId}/file/{fileName}: + GET: + summary: Admin downloads an asset file + description: An administrator downloads a file fom an asset. + operationId: adminDownloadsAssetFile + parameters: + - name: assetId + description: The asset identifier of the asset containing the file. + in: path + required: true + schema: + type: string + - name: fileName + description: The name of the file inside the asset which shall be downloaded. + in: path + required: true + schema: + type: string + responses: + "200": + content: + application/octet-stream + + description: "Ok" + + "404": + description: "Not found" + tags: + - Configuration \ No newline at end of file diff --git a/sechub-scan/src/main/java/com/mercedesbenz/sechub/domain/scan/asset/AssetFileData.java b/sechub-scan/src/main/java/com/mercedesbenz/sechub/domain/scan/asset/AssetFileData.java index dc570a4ef..6e18327e5 100644 --- a/sechub-scan/src/main/java/com/mercedesbenz/sechub/domain/scan/asset/AssetFileData.java +++ b/sechub-scan/src/main/java/com/mercedesbenz/sechub/domain/scan/asset/AssetFileData.java @@ -8,17 +8,9 @@ @JsonIgnoreProperties(ignoreUnknown = true) // we do ignore to avoid problems from wrong configured values! public class AssetFileData { - private String checksum; - private String fileName; - public String getChecksum() { - return checksum; - } - - public void setChecksum(String checksum) { - this.checksum = checksum; - } + private String checksum; public String getFileName() { return fileName; @@ -28,6 +20,14 @@ public void setFileName(String fileName) { this.fileName = fileName; } + public String getChecksum() { + return checksum; + } + + public void setChecksum(String checksum) { + this.checksum = checksum; + } + @Override public int hashCode() { return Objects.hash(checksum, fileName);