From ed719b305d35480e3f0abfd4e667f056df592f42 Mon Sep 17 00:00:00 2001 From: Daniel Bell Date: Tue, 9 Apr 2024 16:26:14 +0200 Subject: [PATCH] Remove endpoint and region from the S3 Storage instances --- .../storage/storages/model/StorageFields.scala | 14 -------------- .../storage/storages/model/StorageValue.scala | 8 -------- .../storages/database/s3-storage-updated.json | 2 -- .../resources/storages/s3-storage-expanded.json | 10 ---------- .../resources/storages/s3-storage-fetched.json | 2 -- .../src/test/resources/storages/s3-storage.json | 2 -- .../resources/storages/sse/s3-storage-created.json | 2 -- .../resources/storages/sse/s3-storage-updated.json | 2 -- .../test/resources/storages/storage-s3-state.json | 4 ---- .../plugins/storage/storages/StorageFixtures.scala | 3 +-- .../storage/storages/model/StorageFieldsSpec.scala | 2 +- .../operations/s3/S3StorageFetchSaveSpec.scala | 2 -- .../main/paradox/docs/delta/api/storages-api.md | 4 ---- 13 files changed, 2 insertions(+), 55 deletions(-) diff --git a/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/model/StorageFields.scala b/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/model/StorageFields.scala index d9640a1a08..41f907dbf9 100644 --- a/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/model/StorageFields.scala +++ b/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/model/StorageFields.scala @@ -1,11 +1,9 @@ package ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.model -import akka.http.scaladsl.model.Uri import ch.epfl.bluebrain.nexus.delta.kernel.Secret import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.StoragesConfig.StorageTypeConfig import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.model.StorageValue.{DiskStorageValue, RemoteDiskStorageValue, S3StorageValue} import ch.epfl.bluebrain.nexus.delta.rdf.IriOrBNode.Iri -import ch.epfl.bluebrain.nexus.delta.sdk.implicits._ import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.context.JsonLdContext.keywords import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.decoder.configuration.semiauto.deriveConfigJsonLdDecoder import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.decoder.{Configuration => JsonLdConfiguration, JsonLdDecoder} @@ -131,14 +129,6 @@ object StorageFields { * ''true'' if this store is the project's default, ''false'' otherwise * @param bucket * the S3 compatible bucket - * @param endpoint - * the endpoint, either a domain or a full URL - * @param accessKey - * the AWS access key ID - * @param secretKey - * the AWS secret key - * @param region - * the AWS region * @param readPermission * the permission required in order to download a file from this storage * @param writePermission @@ -151,8 +141,6 @@ object StorageFields { description: Option[String], default: Boolean, bucket: String, - endpoint: Option[Uri], - region: Option[Region], readPermission: Option[Permission], writePermission: Option[Permission], maxFileSize: Option[Long] @@ -169,8 +157,6 @@ object StorageFields { default, cfg.digestAlgorithm, bucket, - endpoint.orElse(Some(cfg.defaultEndpoint)), - region, readPermission.getOrElse(cfg.defaultReadPermission), writePermission.getOrElse(cfg.defaultWritePermission), computeMaxFileSize(maxFileSize, cfg.defaultMaxFileSize) diff --git a/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/model/StorageValue.scala b/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/model/StorageValue.scala index 71b7b98dcd..35ba507013 100644 --- a/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/model/StorageValue.scala +++ b/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/model/StorageValue.scala @@ -1,9 +1,7 @@ package ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.model -import akka.http.scaladsl.model.Uri import ch.epfl.bluebrain.nexus.delta.plugins.storage.files.model.Digest import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.context.JsonLdContext.keywords -import ch.epfl.bluebrain.nexus.delta.sdk.implicits._ import ch.epfl.bluebrain.nexus.delta.sdk.permissions.model.Permission import ch.epfl.bluebrain.nexus.delta.sourcing.model.{Label, ProjectRef} import io.circe.generic.extras.Configuration @@ -132,8 +130,6 @@ object StorageValue { default: Boolean, algorithm: DigestAlgorithm, bucket: String, - endpoint: Option[Uri], - region: Option[Region], readPermission: Permission, writePermission: Permission, maxFileSize: Long @@ -153,8 +149,6 @@ object StorageValue { default: Boolean, algorithm: DigestAlgorithm, bucket: String, - endpoint: Option[Uri], - region: Option[Region], readPermission: Permission, writePermission: Permission, maxFileSize: Long @@ -165,8 +159,6 @@ object StorageValue { default, algorithm, bucket, - endpoint, - region, readPermission, writePermission, maxFileSize diff --git a/delta/plugins/storage/src/test/resources/storages/database/s3-storage-updated.json b/delta/plugins/storage/src/test/resources/storages/database/s3-storage-updated.json index 2ae1897aa6..01201be1d3 100644 --- a/delta/plugins/storage/src/test/resources/storages/database/s3-storage-updated.json +++ b/delta/plugins/storage/src/test/resources/storages/database/s3-storage-updated.json @@ -20,9 +20,7 @@ "description": "s3description", "default" : true, "bucket" : "mybucket", - "endpoint" : "http://localhost", "readPermission" : "s3/read", - "region": "eu-west-1", "writePermission" : "s3/write", "maxFileSize" : 51 }, diff --git a/delta/plugins/storage/src/test/resources/storages/s3-storage-expanded.json b/delta/plugins/storage/src/test/resources/storages/s3-storage-expanded.json index 91d4634fa6..c2b8cbfc10 100644 --- a/delta/plugins/storage/src/test/resources/storages/s3-storage-expanded.json +++ b/delta/plugins/storage/src/test/resources/storages/s3-storage-expanded.json @@ -30,11 +30,6 @@ "@value": true } ], - "https://bluebrain.github.io/nexus/vocabulary/endpoint": [ - { - "@value": "http://localhost" - } - ], "https://bluebrain.github.io/nexus/vocabulary/maxFileSize": [ { "@value": 51 @@ -45,11 +40,6 @@ "@value": "s3/read" } ], - "https://bluebrain.github.io/nexus/vocabulary/region": [ - { - "@value": "eu-west-1" - } - ], "https://bluebrain.github.io/nexus/vocabulary/writePermission": [ { "@value": "s3/write" diff --git a/delta/plugins/storage/src/test/resources/storages/s3-storage-fetched.json b/delta/plugins/storage/src/test/resources/storages/s3-storage-fetched.json index 8a86b8952b..4bddd08a14 100644 --- a/delta/plugins/storage/src/test/resources/storages/s3-storage-fetched.json +++ b/delta/plugins/storage/src/test/resources/storages/s3-storage-fetched.json @@ -24,9 +24,7 @@ "default" : true, "name": "s3name", "description": "s3description", - "endpoint" : "http://localhost", "maxFileSize" : 51, "readPermission" : "s3/read", - "region" : "eu-west-1", "writePermission" : "s3/write" } \ No newline at end of file diff --git a/delta/plugins/storage/src/test/resources/storages/s3-storage.json b/delta/plugins/storage/src/test/resources/storages/s3-storage.json index c873bfbb6c..020650b969 100644 --- a/delta/plugins/storage/src/test/resources/storages/s3-storage.json +++ b/delta/plugins/storage/src/test/resources/storages/s3-storage.json @@ -7,9 +7,7 @@ "name": "s3name", "description": "s3description", "bucket": "mybucket", - "endpoint": "http://localhost", "readPermission": "s3/read", - "region": "eu-west-1", "writePermission": "s3/write", "maxFileSize": 51 } \ No newline at end of file diff --git a/delta/plugins/storage/src/test/resources/storages/sse/s3-storage-created.json b/delta/plugins/storage/src/test/resources/storages/sse/s3-storage-created.json index 350cf75ab8..b9176c4aff 100644 --- a/delta/plugins/storage/src/test/resources/storages/sse/s3-storage-created.json +++ b/delta/plugins/storage/src/test/resources/storages/sse/s3-storage-created.json @@ -15,10 +15,8 @@ "description": "s3description", "bucket": "mybucket", "default": true, - "endpoint": "http://localhost", "maxFileSize": 51, "readPermission": "s3/read", - "region": "eu-west-1", "writePermission": "s3/write" }, "_storageId": "https://bluebrain.github.io/nexus/vocabulary/s3-storage", diff --git a/delta/plugins/storage/src/test/resources/storages/sse/s3-storage-updated.json b/delta/plugins/storage/src/test/resources/storages/sse/s3-storage-updated.json index 5d0ef9765f..cc35c47581 100644 --- a/delta/plugins/storage/src/test/resources/storages/sse/s3-storage-updated.json +++ b/delta/plugins/storage/src/test/resources/storages/sse/s3-storage-updated.json @@ -15,10 +15,8 @@ "description": "s3description", "bucket": "mybucket", "default": true, - "endpoint": "http://localhost", "maxFileSize": 51, "readPermission": "s3/read", - "region": "eu-west-1", "writePermission": "s3/write" }, "_storageId": "https://bluebrain.github.io/nexus/vocabulary/s3-storage", diff --git a/delta/plugins/storage/src/test/resources/storages/storage-s3-state.json b/delta/plugins/storage/src/test/resources/storages/storage-s3-state.json index 17b65e9ad1..6a1203ce85 100644 --- a/delta/plugins/storage/src/test/resources/storages/storage-s3-state.json +++ b/delta/plugins/storage/src/test/resources/storages/storage-s3-state.json @@ -13,8 +13,6 @@ "description": "s3description", "algorithm": "SHA-256", "bucket": "mybucket", - "endpoint": "http://localhost", - "region": "eu-west-1", "readPermission": "s3/read", "writePermission": "s3/write", "maxFileSize": 51, @@ -26,9 +24,7 @@ "description": "s3description", "default": true, "bucket": "mybucket", - "endpoint": "http://localhost", "readPermission": "s3/read", - "region": "eu-west-1", "writePermission": "s3/write", "maxFileSize": 51 }, diff --git a/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/StorageFixtures.scala b/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/StorageFixtures.scala index 9a3a94e40c..ba4718230a 100644 --- a/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/StorageFixtures.scala +++ b/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/StorageFixtures.scala @@ -13,7 +13,6 @@ import ch.epfl.bluebrain.nexus.delta.sourcing.model.Label import ch.epfl.bluebrain.nexus.testkit.CirceLiteral import ch.epfl.bluebrain.nexus.testkit.minio.MinioDocker import ch.epfl.bluebrain.nexus.testkit.scalatest.ClasspathResources -import software.amazon.awssdk.regions.Region import java.nio.file.{Files, Paths} import scala.concurrent.duration._ @@ -42,7 +41,7 @@ trait StorageFixtures extends CirceLiteral { val diskVal = diskFields.toValue(config).get val diskFieldsUpdate = DiskStorageFields(Some("diskName"), Some("diskDescription"), default = false, Some(tmpVolume), Some(Permission.unsafe("disk/read")), Some(Permission.unsafe("disk/write")), Some(2000), Some(40)) val diskValUpdate = diskFieldsUpdate.toValue(config).get - val s3Fields = S3StorageFields(Some("s3name"), Some("s3description"), default = true, "mybucket", Some("http://localhost"), Some(Region.EU_WEST_1), Some(Permission.unsafe("s3/read")), Some(Permission.unsafe("s3/write")), Some(51)) + val s3Fields = S3StorageFields(Some("s3name"), Some("s3description"), default = true, "mybucket", Some(Permission.unsafe("s3/read")), Some(Permission.unsafe("s3/write")), Some(51)) val s3Val = s3Fields.toValue(config).get val remoteFields = RemoteDiskStorageFields(Some("remoteName"), Some("remoteDescription"), default = true, Label.unsafe("myfolder"), Some(Permission.unsafe("remote/read")), Some(Permission.unsafe("remote/write")), Some(52)) val remoteVal = remoteFields.toValue(config).get diff --git a/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/model/StorageFieldsSpec.scala b/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/model/StorageFieldsSpec.scala index 21af6f81d3..d7fc6c8fa0 100644 --- a/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/model/StorageFieldsSpec.scala +++ b/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/model/StorageFieldsSpec.scala @@ -63,7 +63,7 @@ class StorageFieldsSpec extends CatsEffectSpec with RemoteContextResolutionFixtu "region" ) sourceDecoder(pc, jsonNoDefaults).accepted._2 shouldEqual - S3StorageFields(None, None, default = true, "mybucket", None, None, None, None, None) + S3StorageFields(None, None, default = true, "mybucket", None, None, None) } } diff --git a/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/operations/s3/S3StorageFetchSaveSpec.scala b/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/operations/s3/S3StorageFetchSaveSpec.scala index 0ebf790eb8..ea37d16f69 100644 --- a/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/operations/s3/S3StorageFetchSaveSpec.scala +++ b/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/operations/s3/S3StorageFetchSaveSpec.scala @@ -48,8 +48,6 @@ class S3StorageFetchSaveSpec default = false, algorithm = DigestAlgorithm.default, bucket = bucket, - endpoint = None, - region = None, readPermission = read, writePermission = write, maxFileSize = 20 diff --git a/docs/src/main/paradox/docs/delta/api/storages-api.md b/docs/src/main/paradox/docs/delta/api/storages-api.md index f620f1301f..3412ef098a 100644 --- a/docs/src/main/paradox/docs/delta/api/storages-api.md +++ b/docs/src/main/paradox/docs/delta/api/storages-api.md @@ -96,8 +96,6 @@ In order to be able to use this storage, the configuration flag `plugins.storage { "@type": "S3Storage", "default": "{default}", - "endpoint": "{endpoint}", - "region": "{region}", "readPermission": "{read_permission}", "writePermission": "{write_permission}", "maxFileSize": {max_file_size} @@ -107,8 +105,6 @@ In order to be able to use this storage, the configuration flag `plugins.storage ...where - `{default}`: Boolean - the flag to decide whether this storage is going to become the default storage for the target project or not. -- `{endpoint}`: Uri - the Amazon S3 compatible service endpoint. This field is optional, defaulting to the configuration flag `plugins.storage.storages.amazon.default-endpoint`. -- `{region}`: String - the Amazon S3 compatible region. This field is optional, defaulting to the S3 default region configuration. - `{read_permission}`: String - the permission a client must have in order to fetch files using this storage. This field is optional, defaulting to the configuration flag `plugins.storage.storages.amazon.default-read-permission` (`resources/read`). - `{write_permission}`: String - the permission a client must have in order to create files using this storage. This field is optional, defaulting to the configuration flag `plugins.storage.storages.amazon.default-write-permission` (`files/write`). - `{max_file_size}`: Long - the maximum allowed size in bytes for files uploaded using this storage. This field is optional, defaulting to the configuration flag `plugins.storage.storages.amazon.default-max-file-size` (10G).