diff --git a/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/StoragePluginModule.scala b/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/StoragePluginModule.scala index a50113c91d..6dfb6d51a6 100644 --- a/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/StoragePluginModule.scala +++ b/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/StoragePluginModule.scala @@ -23,7 +23,6 @@ import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.operations.s3.clie import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.operations.s3.{S3FileOperations, S3LocationGenerator} import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.operations.{FileOperations, LinkFileAction} import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.routes.StoragesRoutes -import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.schemas.{storage => storagesSchemaId} import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.context.{ContextValue, RemoteContextResolution} import ch.epfl.bluebrain.nexus.delta.rdf.utils.JsonKeyOrdering import ch.epfl.bluebrain.nexus.delta.sdk.IndexingAction.AggregateIndexingAction @@ -124,8 +123,6 @@ class StoragePluginModule(priority: Int) extends ModuleDef { storages: Storages, storagesStatistics: StoragesStatistics, schemeDirectives: DeltaSchemeDirectives, - indexingAction: AggregateIndexingAction, - shift: Storage.Shift, baseUri: BaseUri, cr: RemoteContextResolution @Id("aggregate"), ordering: JsonKeyOrdering, @@ -137,8 +134,7 @@ class StoragePluginModule(priority: Int) extends ModuleDef { aclCheck, storages, storagesStatistics, - schemeDirectives, - indexingAction(_, _, _)(shift) + schemeDirectives )( baseUri, cr, @@ -148,12 +144,6 @@ class StoragePluginModule(priority: Int) extends ModuleDef { } } - make[Storage.Shift].from { (storages: Storages, base: BaseUri) => - Storage.shift(storages)(base) - } - - many[ResourceShift[_, _, _]].ref[Storage.Shift] - make[FilesLog].from { (cfg: StoragePluginConfig, xas: Transactors, clock: Clock[IO]) => ScopedEventLog(Files.definition(clock), cfg.files.eventLog, xas) } @@ -299,7 +289,7 @@ class StoragePluginModule(priority: Int) extends ModuleDef { } many[ResourceToSchemaMappings].add( - ResourceToSchemaMappings(Label.unsafe("storages") -> storagesSchemaId, Label.unsafe("files") -> filesSchemaId) + ResourceToSchemaMappings(Label.unsafe("files") -> filesSchemaId) ) many[ApiMappings].add(Storages.mappings + Files.mappings) @@ -310,7 +300,6 @@ class StoragePluginModule(priority: Int) extends ModuleDef { } many[ScopedEventMetricEncoder[_]].add { FileEvent.fileEventMetricEncoder } - many[ScopedEventMetricEncoder[_]].add { () => StorageEvent.storageEventMetricEncoder } many[PriorityRoute].add { (storagesRoutes: StoragesRoutes) => PriorityRoute(priority, storagesRoutes.routes, requiresStrictEntity = true) diff --git a/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/model/Storage.scala b/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/model/Storage.scala index 4e3cc4c2d7..9206502f81 100644 --- a/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/model/Storage.scala +++ b/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/model/Storage.scala @@ -7,9 +7,7 @@ import ch.epfl.bluebrain.nexus.delta.rdf.IriOrBNode.Iri import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.context.ContextValue import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.context.JsonLdContext.keywords import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.encoder.JsonLdEncoder -import ch.epfl.bluebrain.nexus.delta.sdk.jsonld.JsonLdContent -import ch.epfl.bluebrain.nexus.delta.sdk.model.{BaseUri, IdSegmentRef} -import ch.epfl.bluebrain.nexus.delta.sdk.{OrderingFields, ResourceShift} +import ch.epfl.bluebrain.nexus.delta.sdk.OrderingFields import ch.epfl.bluebrain.nexus.delta.sourcing.model.ProjectRef import io.circe.syntax._ import io.circe.{Encoder, Json, JsonObject} @@ -108,15 +106,4 @@ object Storage { OrderingFields { case "_algorithm" => Ordering[String] on (_.storageValue.algorithm.value) } - - type Shift = ResourceShift[StorageState, Storage, Metadata] - - def shift(storages: Storages)(implicit baseUri: BaseUri): Shift = - ResourceShift.withMetadata[StorageState, Storage, Metadata]( - Storages.entityType, - (ref, project) => storages.fetch(IdSegmentRef(ref), project), - state => state.toResource, - value => JsonLdContent(value, value.value.source, Some(value.value.metadata)) - ) - } diff --git a/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/model/StorageEvent.scala b/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/model/StorageEvent.scala index ce9ca9b34c..eea849cffe 100644 --- a/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/model/StorageEvent.scala +++ b/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/model/StorageEvent.scala @@ -9,9 +9,7 @@ import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.context.JsonLdContext.keywords import ch.epfl.bluebrain.nexus.delta.sdk.instances._ import ch.epfl.bluebrain.nexus.delta.sdk.jsonld.IriEncoder import ch.epfl.bluebrain.nexus.delta.sdk.model.BaseUri -import ch.epfl.bluebrain.nexus.delta.sdk.model.metrics.EventMetric._ -import ch.epfl.bluebrain.nexus.delta.sdk.model.metrics.ScopedEventMetricEncoder -import ch.epfl.bluebrain.nexus.delta.sdk.sse.{resourcesSelector, SseEncoder} +import ch.epfl.bluebrain.nexus.delta.sdk.sse.SseEncoder import ch.epfl.bluebrain.nexus.delta.sourcing.Serializer import ch.epfl.bluebrain.nexus.delta.sourcing.event.Event.ScopedEvent import ch.epfl.bluebrain.nexus.delta.sourcing.model.Identity.Subject @@ -194,34 +192,12 @@ object StorageEvent { Serializer.dropNulls() } - def storageEventMetricEncoder: ScopedEventMetricEncoder[StorageEvent] = - new ScopedEventMetricEncoder[StorageEvent] { - override def databaseDecoder: Decoder[StorageEvent] = serializer.codec - - override def entityType: EntityType = Storages.entityType - - override def eventToMetric: StorageEvent => ProjectScopedMetric = event => - ProjectScopedMetric.from( - event, - event match { - case _: StorageCreated => Created - case _: StorageUpdated => Updated - case _: StorageTagAdded => Tagged - case _: StorageDeprecated => Deprecated - case _: StorageUndeprecated => Undeprecated - }, - event.id, - event.tpe.types, - JsonObject.empty - ) - } - def sseEncoder(implicit base: BaseUri): SseEncoder[StorageEvent] = new SseEncoder[StorageEvent] { override val databaseDecoder: Decoder[StorageEvent] = serializer.codec override def entityType: EntityType = Storages.entityType - override val selectors: Set[Label] = Set(Label.unsafe("storages"), resourcesSelector) + override val selectors: Set[Label] = Set(Label.unsafe("storages")) override val sseEncoder: Encoder.AsObject[StorageEvent] = { val context = ContextValue(Vocabulary.contexts.metadata, contexts.storages) diff --git a/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/routes/StoragesRoutes.scala b/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/routes/StoragesRoutes.scala index ae26f9724d..c741579223 100644 --- a/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/routes/StoragesRoutes.scala +++ b/delta/plugins/storage/src/main/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/routes/StoragesRoutes.scala @@ -6,12 +6,11 @@ import cats.implicits._ import ch.epfl.bluebrain.nexus.delta.kernel.circe.CirceUnmarshalling import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.StoragePluginExceptionHandler.handleStorageExceptions import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages._ +import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.model.StorageRejection import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.model.StorageRejection._ -import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.model.{Storage, StorageRejection} import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.permissions.{read => Read, write => Write} import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.context.RemoteContextResolution import ch.epfl.bluebrain.nexus.delta.rdf.utils.JsonKeyOrdering -import ch.epfl.bluebrain.nexus.delta.sdk.IndexingAction import ch.epfl.bluebrain.nexus.delta.sdk.acls.AclCheck import ch.epfl.bluebrain.nexus.delta.sdk.directives.DeltaDirectives._ import ch.epfl.bluebrain.nexus.delta.sdk.directives.{AuthDirectives, DeltaSchemeDirectives} @@ -33,16 +32,13 @@ import io.circe.Json * the storages module * @param schemeDirectives * directives related to orgs and projects - * @param index - * the indexing action on write operations */ final class StoragesRoutes( identities: Identities, aclCheck: AclCheck, storages: Storages, storagesStatistics: StoragesStatistics, - schemeDirectives: DeltaSchemeDirectives, - index: IndexingAction.Execute[Storage] + schemeDirectives: DeltaSchemeDirectives )(implicit baseUri: BaseUri, cr: RemoteContextResolution, @@ -62,16 +58,16 @@ final class StoragesRoutes( concat( pathEndOrSingleSlash { // Create a storage without id segment - (post & noParameter("rev") & entity(as[Json]) & indexingMode) { (source, mode) => + (post & noParameter("rev") & entity(as[Json])) { source => authorizeFor(project, Write).apply { emit( Created, - storages.create(project, source).flatTap(index(project, _, mode)).mapValue(_.metadata) + storages.create(project, source).mapValue(_.metadata) ) } } }, - (idSegment & indexingMode) { (id, mode) => + idSegment { id => concat( pathEndOrSingleSlash { concat( @@ -85,7 +81,6 @@ final class StoragesRoutes( Created, storages .create(id, project, source) - .flatTap(index(project, _, mode)) .mapValue(_.metadata) ) case (Some(rev), source) => @@ -93,7 +88,6 @@ final class StoragesRoutes( emit( storages .update(id, project, rev, source) - .flatTap(index(project, _, mode)) .mapValue(_.metadata) ) } @@ -105,7 +99,6 @@ final class StoragesRoutes( emit( storages .deprecate(id, project, rev) - .flatTap(index(project, _, mode)) .mapValue(_.metadata) .attemptNarrow[StorageRejection] .rejectOn[StorageNotFound] @@ -135,7 +128,6 @@ final class StoragesRoutes( emit( storages .undeprecate(id, project, rev) - .flatTap(index(project, _, mode)) .mapValue(_.metadata) .attemptNarrow[StorageRejection] .rejectOn[StorageNotFound] @@ -176,14 +168,13 @@ object StoragesRoutes { aclCheck: AclCheck, storages: Storages, storagesStatistics: StoragesStatistics, - schemeDirectives: DeltaSchemeDirectives, - index: IndexingAction.Execute[Storage] + schemeDirectives: DeltaSchemeDirectives )(implicit baseUri: BaseUri, cr: RemoteContextResolution, ordering: JsonKeyOrdering, fusionConfig: FusionConfig ): Route = - new StoragesRoutes(identities, aclCheck, storages, storagesStatistics, schemeDirectives, index).routes + new StoragesRoutes(identities, aclCheck, storages, storagesStatistics, schemeDirectives).routes } diff --git a/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/model/StorageSerializationSuite.scala b/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/model/StorageSerializationSuite.scala index c9d0f95f3b..362d10aa41 100644 --- a/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/model/StorageSerializationSuite.scala +++ b/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/model/StorageSerializationSuite.scala @@ -5,12 +5,10 @@ import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.StorageFixtures import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.model.StorageEvent._ import ch.epfl.bluebrain.nexus.delta.plugins.storage.storages.model.StorageType.{DiskStorage => DiskStorageType} import ch.epfl.bluebrain.nexus.delta.sdk.SerializationSuite -import ch.epfl.bluebrain.nexus.delta.sdk.model.metrics.EventMetric._ import ch.epfl.bluebrain.nexus.delta.sdk.sse.SseEncoder.SseData import ch.epfl.bluebrain.nexus.delta.sourcing.model.Identity.{Subject, User} import ch.epfl.bluebrain.nexus.delta.sourcing.model.Tag.UserTag import ch.epfl.bluebrain.nexus.delta.sourcing.model.{Label, ProjectRef} -import io.circe.JsonObject import java.time.Instant import scala.collection.immutable.VectorMap @@ -33,20 +31,19 @@ class StorageSerializationSuite extends SerializationSuite with StorageFixtures private val diskUndeprecated = StorageUndeprecated(dId, projectRef, DiskStorageType, 5, instant, subject) private val storagesMapping = List( - (diskCreated, loadEvents("storages", "disk-storage-created.json"), Created), - (s3Created, loadEvents("storages", "s3-storage-created.json"), Created), - (diskUpdated, loadEvents("storages", "disk-storage-updated.json"), Updated), - (s3Updated, loadEvents("storages", "s3-storage-updated.json"), Updated), - (diskTagged, loadEvents("storages", "storage-tag-added.json"), Tagged), - (diskDeprecated, loadEvents("storages", "storage-deprecated.json"), Deprecated), - (diskUndeprecated, loadEvents("storages", "storage-undeprecated.json"), Undeprecated) + (diskCreated, loadEvents("storages", "disk-storage-created.json")), + (s3Created, loadEvents("storages", "s3-storage-created.json")), + (diskUpdated, loadEvents("storages", "disk-storage-updated.json")), + (s3Updated, loadEvents("storages", "s3-storage-updated.json")), + (diskTagged, loadEvents("storages", "storage-tag-added.json")), + (diskDeprecated, loadEvents("storages", "storage-deprecated.json")), + (diskUndeprecated, loadEvents("storages", "storage-undeprecated.json")) ) - private val storageEventSerializer = StorageEvent.serializer - private val storageSseEncoder = StorageEvent.sseEncoder - private val storageEventMetricEncoder = StorageEvent.storageEventMetricEncoder + private val storageEventSerializer = StorageEvent.serializer + private val storageSseEncoder = StorageEvent.sseEncoder - storagesMapping.foreach { case (event, (database, sse), action) => + storagesMapping.foreach { case (event, (database, sse)) => test(s"Correctly serialize ${event.getClass.getSimpleName} for ${event.tpe}") { assertEquals(storageEventSerializer.codec(event), database) } @@ -60,22 +57,6 @@ class StorageSerializationSuite extends SerializationSuite with StorageFixtures .decodeJson(database) .assertRight(SseData(ClassUtils.simpleName(event), Some(projectRef), sse)) } - - test(s"Correctly encode ${event.getClass.getSimpleName} for ${event.tpe} to metric") { - storageEventMetricEncoder.toMetric.decodeJson(database).assertRight { - ProjectScopedMetric( - instant, - subject, - event.rev, - Set(action), - projectRef, - Label.unsafe("myorg"), - event.id, - event.tpe.types, - JsonObject.empty - ) - } - } } private val statesMapping = VectorMap( diff --git a/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/routes/StoragesRoutesSpec.scala b/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/routes/StoragesRoutesSpec.scala index 431dfc2cee..2f27058e39 100644 --- a/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/routes/StoragesRoutesSpec.scala +++ b/delta/plugins/storage/src/test/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/storages/routes/StoragesRoutesSpec.scala @@ -14,7 +14,6 @@ import ch.epfl.bluebrain.nexus.delta.rdf.IriOrBNode.Iri import ch.epfl.bluebrain.nexus.delta.rdf.Vocabulary import ch.epfl.bluebrain.nexus.delta.rdf.Vocabulary.nxv import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.context.{ContextValue, RemoteContextResolution} -import ch.epfl.bluebrain.nexus.delta.sdk.IndexingAction import ch.epfl.bluebrain.nexus.delta.sdk.acls.AclSimpleCheck import ch.epfl.bluebrain.nexus.delta.sdk.acls.model.AclAddress import ch.epfl.bluebrain.nexus.delta.sdk.directives.DeltaSchemeDirectives @@ -110,7 +109,7 @@ class StoragesRoutesSpec extends BaseRouteSpec with StorageFixtures with UUIDFFi private lazy val routes = Route.seal( - StoragesRoutes(identities, aclCheck, storages, storageStatistics, schemeDirectives, IndexingAction.noop) + StoragesRoutes(identities, aclCheck, storages, storageStatistics, schemeDirectives) ) override def beforeAll(): Unit = { diff --git a/docs/src/main/paradox/docs/delta/api/assets/storages/list.sh b/docs/src/main/paradox/docs/delta/api/assets/storages/list.sh deleted file mode 100644 index fdf75ed953..0000000000 --- a/docs/src/main/paradox/docs/delta/api/assets/storages/list.sh +++ /dev/null @@ -1 +0,0 @@ -curl "http://localhost:8080/v1/storages/myorg/myproject" \ No newline at end of file diff --git a/docs/src/main/paradox/docs/delta/api/assets/storages/listed.json b/docs/src/main/paradox/docs/delta/api/assets/storages/listed.json deleted file mode 100644 index 5629acf27f..0000000000 --- a/docs/src/main/paradox/docs/delta/api/assets/storages/listed.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "@context": [ - "https://bluebrain.github.io/nexus/contexts/metadata.json", - "https://bluebrain.github.io/nexus/contexts/search.json", - "https://bluebrain.github.io/nexus/contexts/search-metadata.json" - ], - "_total": 3, - "_results": [ - { - "@id": "https://bluebrain.github.io/nexus/vocabulary/diskStorageDefault", - "@type": [ - "Storage", - "DiskStorage" - ], - "_algorithm": "SHA-256", - "_constrainedBy": "https://bluebrain.github.io/nexus/schemas/storages.json", - "_createdAt": "2021-05-11T12:21:05.781Z", - "_createdBy": "http://localhost:8080/v1/realms/internal/users/delta", - "_deprecated": false, - "_incoming": "http://localhost:8080/v1/storages/myorg/myproject/defaultStorage/incoming", - "_outgoing": "http://localhost:8080/v1/storages/myorg/myproject/defaultStorage/outgoing", - "_project": "myorg/myproject", - "_rev": 1, - "_self": "http://localhost:8080/v1/storages/myorg/myproject/defaultStorage", - "_updatedAt": "2021-05-11T12:21:05.781Z", - "_updatedBy": "http://localhost:8080/v1/realms/internal/users/delta" - }, - { - "@id": "https://bluebrain.github.io/nexus/vocabulary/local", - "@type": [ - "Storage", - "DiskStorage" - ], - "_algorithm": "SHA-256", - "_constrainedBy": "https://bluebrain.github.io/nexus/schemas/storages.json", - "_createdAt": "2021-05-11T12:21:19.732Z", - "_createdBy": "http://localhost:8080/v1/anonymous", - "_deprecated": false, - "_incoming": "http://localhost:8080/v1/storages/myorg/myproject/nxv:local/incoming", - "_outgoing": "http://localhost:8080/v1/storages/myorg/myproject/nxv:local/outgoing", - "_project": "myorg/myproject", - "_rev": 1, - "_self": "http://localhost:8080/v1/storages/myorg/myproject/nxv:local", - "_updatedAt": "2021-05-11T12:21:19.732Z", - "_updatedBy": "http://localhost:8080/v1/anonymous" - }, - { - "@id": "http://localhost:8080/v1/resources/myorg/myproject/_/s3", - "@type": [ - "Storage", - "S3Storage" - ], - "_constrainedBy": "https://bluebrain.github.io/nexus/schemas/storages.json", - "_createdAt": "2021-05-11T12:22:19.195Z", - "_createdBy": "http://localhost:8080/v1/anonymous", - "_deprecated": true, - "_incoming": "http://localhost:8080/v1/storages/myorg/myproject/s3/incoming", - "_outgoing": "http://localhost:8080/v1/storages/myorg/myproject/s3/outgoing", - "_project": "myorg/myproject", - "_rev": 4, - "_self": "http://localhost:8080/v1/storages/myorg/myproject/s3", - "_updatedAt": "2021-05-11T12:29:27.821Z", - "_updatedBy": "http://localhost:8080/v1/anonymous" - } - ] -} 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 3232e02266..b32421d1b9 100644 --- a/docs/src/main/paradox/docs/delta/api/storages-api.md +++ b/docs/src/main/paradox/docs/delta/api/storages-api.md @@ -81,14 +81,6 @@ In order to be able to use this storage, the configuration flag `plugins.storage - `{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). -## Indexing - -All the API calls modifying a storage (creation, update, deprecation) can specify whether the storage should be indexed -synchronously or in the background. This behaviour is controlled using `indexing` query param, which can be one of two values: - -- `async` - (default value) the storage will be indexed asynchronously -- `sync` - the storage will be indexed synchronously and the API call won't return until the indexing is finished - ## Create using POST ``` @@ -242,85 +234,6 @@ Request Response : @@snip [fetched-source.json](assets/storages/fetched-source.json) -## List - -There are three available endpoints to list storages in different scopes. - -### Within a project - -``` -GET /v1/storages/{org_label}/{project_label}?from={from} - &size={size} - &deprecated={deprecated} - &rev={rev} - &type={type} - &createdBy={createdBy} - &updatedBy={updatedBy} - &q={search} - &sort={sort} - &aggregations={aggregations} -``` - -### Within an organization - -This operation returns only storages from projects defined in the organisation `{org_label}` and where the caller has the `resources/read` permission. - -``` -GET /v1/storages/{org_label}?from={from} - &size={size} - &deprecated={deprecated} - &rev={rev} - &type={type} - &createdBy={createdBy} - &updatedBy={updatedBy} - &q={search} - &sort={sort} - &aggregations={aggregations} -``` - -### Within all projects - -This operation returns only storages from projects where the caller has the `resources/read` permission. - -``` -GET /v1/storages?from={from} - &size={size} - &deprecated={deprecated} - &rev={rev} - &type={type} - &createdBy={createdBy} - &updatedBy={updatedBy} - &q={search} - &sort={sort} - &aggregations={aggregations} -``` - -### Parameter description - -- `{from}`: Number - is the parameter that describes the offset for the current query; defaults to `0` -- `{size}`: Number - is the parameter that limits the number of results; defaults to `20` -- `{deprecated}`: Boolean - can be used to filter the resulting storages based on their deprecation status -- `{rev}`: Number - can be used to filter the resulting storages based on their revision value -- `{type}`: Iri - can be used to filter the resulting storages based on their `@type` value. This parameter can appear - multiple times, filtering further the `@type` value. -- `{createdBy}`: Iri - can be used to filter the resulting storages based on their creator -- `{updatedBy}`: Iri - can be used to filter the resulting storages based on the person which performed the last update -- `{search}`: String - can be provided to select only the storages in the collection that have attribute values matching - (containing) the provided string -- `{sort}`: String - can be used to sort storages based on a payloads' field. This parameter can appear multiple times - to enable sorting by multiple fields. The default is done by `_createdBy` and `@id`. -- `{aggregations}`: Boolean - if `true` then the response will only contain aggregations of the `@type` and `_project` fields; defaults to `false`. See @ref:[Aggregations](resources-api.md#aggregations). - - -**Example** - -Request -: @@snip [list.sh](assets/storages/list.sh) - -Response -: @@snip [listed.json](assets/storages/listed.json) - - ## Server Sent Events From Delta 1.5, it is possible to fetch SSEs for all storages or just storages diff --git a/tests/src/test/resources/kg/aggregations/org-aggregation.json b/tests/src/test/resources/kg/aggregations/org-aggregation.json index f3b6484556..79d5e1e4a8 100644 --- a/tests/src/test/resources/kg/aggregations/org-aggregation.json +++ b/tests/src/test/resources/kg/aggregations/org-aggregation.json @@ -4,11 +4,11 @@ "projects" : { "buckets" : [ { - "doc_count" : 6, + "doc_count" : 5, "key" : "{{org1}}/{{proj11}}" }, { - "doc_count" : 4, + "doc_count" : 3, "key" : "{{org1}}/{{proj12}}" } ], @@ -29,18 +29,10 @@ "doc_count" : 2, "key" : "https://bluebrain.github.io/nexus/vocabulary/CompositeView" }, - { - "doc_count" : 2, - "key" : "https://bluebrain.github.io/nexus/vocabulary/DiskStorage" - }, { "doc_count" : 2, "key" : "https://bluebrain.github.io/nexus/vocabulary/SparqlView" }, - { - "doc_count" : 2, - "key" : "https://bluebrain.github.io/nexus/vocabulary/Storage" - }, { "doc_count" : 1, "key" : "https://bluebrain.github.io/nexus/vocabulary/Schema" @@ -50,5 +42,5 @@ "sum_other_doc_count" : 0 } }, - "total" : 10 + "total" : 8 } \ No newline at end of file diff --git a/tests/src/test/resources/kg/aggregations/project-aggregation.json b/tests/src/test/resources/kg/aggregations/project-aggregation.json index 0c829118af..9804f562cd 100644 --- a/tests/src/test/resources/kg/aggregations/project-aggregation.json +++ b/tests/src/test/resources/kg/aggregations/project-aggregation.json @@ -3,7 +3,7 @@ "aggregations" : { "projects" : { "buckets" : { - "doc_count" : 6, + "doc_count" : 5, "key" : "{{org}}/{{project}}" }, "doc_count_error_upper_bound" : 0, @@ -23,10 +23,6 @@ "doc_count" : 1, "key" : "https://bluebrain.github.io/nexus/vocabulary/CompositeView" }, - { - "doc_count" : 1, - "key" : "https://bluebrain.github.io/nexus/vocabulary/DiskStorage" - }, { "doc_count" : 1, "key" : "https://bluebrain.github.io/nexus/vocabulary/Schema" @@ -34,15 +30,11 @@ { "doc_count" : 1, "key" : "https://bluebrain.github.io/nexus/vocabulary/SparqlView" - }, - { - "doc_count" : 1, - "key" : "https://bluebrain.github.io/nexus/vocabulary/Storage" } ], "doc_count_error_upper_bound" : 0, "sum_other_doc_count" : 0 } }, - "total" : 6 + "total" : 5 } \ No newline at end of file diff --git a/tests/src/test/resources/kg/aggregations/root-aggregation.json b/tests/src/test/resources/kg/aggregations/root-aggregation.json index 8d735fae72..bbcd0f63dc 100644 --- a/tests/src/test/resources/kg/aggregations/root-aggregation.json +++ b/tests/src/test/resources/kg/aggregations/root-aggregation.json @@ -4,15 +4,15 @@ "projects" : { "buckets" : [ { - "doc_count" : 6, + "doc_count" : 5, "key" : "{{org1}}/{{proj11}}" }, { - "doc_count" : 4, + "doc_count" : 3, "key" : "{{org1}}/{{proj12}}" }, { - "doc_count" : 4, + "doc_count" : 3, "key" : "{{org2}}/{{proj21}}" } ], @@ -33,18 +33,10 @@ "doc_count" : 3, "key" : "https://bluebrain.github.io/nexus/vocabulary/CompositeView" }, - { - "doc_count" : 3, - "key" : "https://bluebrain.github.io/nexus/vocabulary/DiskStorage" - }, { "doc_count" : 3, "key" : "https://bluebrain.github.io/nexus/vocabulary/SparqlView" }, - { - "doc_count" : 3, - "key" : "https://bluebrain.github.io/nexus/vocabulary/Storage" - }, { "doc_count" : 1, "key" : "https://bluebrain.github.io/nexus/vocabulary/Schema" @@ -54,5 +46,5 @@ "sum_other_doc_count" : 0 } }, - "total" : 14 + "total" : 11 } \ No newline at end of file diff --git a/tests/src/test/resources/kg/aggregations/storages-aggregation.json b/tests/src/test/resources/kg/aggregations/storages-aggregation.json deleted file mode 100644 index e0772e6180..0000000000 --- a/tests/src/test/resources/kg/aggregations/storages-aggregation.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "@context": "https://bluebrain.github.io/nexus/contexts/aggregations.json", - "aggregations": { - "projects": { - "buckets": { - "doc_count": 1, - "key": "{{org}}/{{project}}" - }, - "doc_count_error_upper_bound": 0, - "sum_other_doc_count": 0 - }, - "types": { - "buckets": [ - { - "doc_count": 1, - "key": "https://bluebrain.github.io/nexus/vocabulary/Storage" - }, - { - "doc_count": 1, - "key": "https://bluebrain.github.io/nexus/vocabulary/DiskStorage" - } - ], - "doc_count_error_upper_bound": 0, - "sum_other_doc_count": 0 - } - }, - "total": 1 -} \ No newline at end of file diff --git a/tests/src/test/resources/kg/listings/default-storage.json b/tests/src/test/resources/kg/listings/default-storage.json deleted file mode 100644 index b187177638..0000000000 --- a/tests/src/test/resources/kg/listings/default-storage.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "@context": [ - "https://bluebrain.github.io/nexus/contexts/metadata.json", - "https://bluebrain.github.io/nexus/contexts/search.json", - "https://bluebrain.github.io/nexus/contexts/search-metadata.json" - ], - "_total": 1, - "_results": [ - { - "@id": "{{id}}", - "@type": [ - "Storage", - "DiskStorage" - ], - "_algorithm": "SHA-256", - "_incoming": "{{self}}/incoming", - "_outgoing": "{{self}}/outgoing", - "_self": "{{self}}", - "_constrainedBy": "https://bluebrain.github.io/nexus/schemas/storages.json", - "_project": "{{project}}", - "_rev": 1, - "_deprecated": false, - "_createdBy": "{{deltaUri}}/realms/{{realm}}/users/{{user}}", - "_updatedBy": "{{deltaUri}}/realms/{{realm}}/users/{{user}}", - "name" : "Local storage", - "description": "Local storage of the Nexus service." - } - ] -} \ No newline at end of file diff --git a/tests/src/test/scala/ch/epfl/bluebrain/nexus/tests/kg/AggregationsSpec.scala b/tests/src/test/scala/ch/epfl/bluebrain/nexus/tests/kg/AggregationsSpec.scala index 0ecd341203..433c7eecdd 100644 --- a/tests/src/test/scala/ch/epfl/bluebrain/nexus/tests/kg/AggregationsSpec.scala +++ b/tests/src/test/scala/ch/epfl/bluebrain/nexus/tests/kg/AggregationsSpec.scala @@ -97,19 +97,6 @@ final class AggregationsSpec extends BaseIntegrationSpec { json should equalIgnoreArrayOrder(expected) } } - - "aggregate storages" in { - val expected = jsonContentOf( - "kg/aggregations/storages-aggregation.json", - "org" -> org1, - "project" -> proj11 - ) - deltaClient.get[Json](s"/storages/$ref11?aggregations=true", Charlie) { (json, response) => - response.status shouldEqual StatusCodes.OK - json should equalIgnoreArrayOrder(expected) - } - } - } "Aggregating resources within an org" should { @@ -120,7 +107,7 @@ final class AggregationsSpec extends BaseIntegrationSpec { } } - "aggregate correctly for a user that has " in eventually { + "aggregate correctly for a user that has access" in eventually { val expected = jsonContentOf( "kg/aggregations/org-aggregation.json", "org1" -> org1, diff --git a/tests/src/test/scala/ch/epfl/bluebrain/nexus/tests/kg/DefaultIndexSpec.scala b/tests/src/test/scala/ch/epfl/bluebrain/nexus/tests/kg/DefaultIndexSpec.scala index 177750f73d..dc9277c841 100644 --- a/tests/src/test/scala/ch/epfl/bluebrain/nexus/tests/kg/DefaultIndexSpec.scala +++ b/tests/src/test/scala/ch/epfl/bluebrain/nexus/tests/kg/DefaultIndexSpec.scala @@ -44,9 +44,9 @@ class DefaultIndexSpec extends BaseIntegrationSpec { response.status shouldEqual StatusCodes.OK val expected = jsonContentOf( "kg/views/statistics.json", - "total" -> "3", - "processed" -> "3", - "evaluated" -> "3", + "total" -> "2", + "processed" -> "2", + "evaluated" -> "2", "discarded" -> "0", "remaining" -> "0" ) diff --git a/tests/src/test/scala/ch/epfl/bluebrain/nexus/tests/kg/EventsSpec.scala b/tests/src/test/scala/ch/epfl/bluebrain/nexus/tests/kg/EventsSpec.scala index 2fae14c985..14b13f2ea9 100644 --- a/tests/src/test/scala/ch/epfl/bluebrain/nexus/tests/kg/EventsSpec.scala +++ b/tests/src/test/scala/ch/epfl/bluebrain/nexus/tests/kg/EventsSpec.scala @@ -70,7 +70,7 @@ class EventsSpec extends BaseIntegrationSpec { "fetch resource events filtered by project" in eventually { deltaClient.sseEvents(s"/resources/$id/events", BugsBunny, initialEventId, take = 12L) { seq => - val projectEvents = seq.drop(3) + val projectEvents = seq.drop(2) projectEvents.size shouldEqual 6 projectEvents.flatMap(_._1) should contain theSameElementsInOrderAs List( "ResourceCreated", @@ -87,7 +87,7 @@ class EventsSpec extends BaseIntegrationSpec { "fetch resource events filtered by organization 1" in { deltaClient.sseEvents(s"/resources/$orgId/events", BugsBunny, initialEventId, take = 12L) { seq => - val projectEvents = seq.drop(3) + val projectEvents = seq.drop(2) projectEvents.size shouldEqual 6 projectEvents.flatMap(_._1) should contain theSameElementsInOrderAs List( "ResourceCreated", @@ -104,7 +104,7 @@ class EventsSpec extends BaseIntegrationSpec { "fetch resource events filtered by organization 2" in { deltaClient.sseEvents(s"/resources/$orgId2/events", BugsBunny, initialEventId, take = 7L) { seq => - val projectEvents = seq.drop(3) + val projectEvents = seq.drop(2) projectEvents.size shouldEqual 1 projectEvents.flatMap(_._1) should contain theSameElementsInOrderAs List("ResourceCreated") val json = Json.arr(projectEvents.flatMap(_._2.map(events.filterFields)): _*) diff --git a/tests/src/test/scala/ch/epfl/bluebrain/nexus/tests/kg/ListingsSpec.scala b/tests/src/test/scala/ch/epfl/bluebrain/nexus/tests/kg/ListingsSpec.scala index d3655e85c0..dd02fe68bd 100644 --- a/tests/src/test/scala/ch/epfl/bluebrain/nexus/tests/kg/ListingsSpec.scala +++ b/tests/src/test/scala/ch/epfl/bluebrain/nexus/tests/kg/ListingsSpec.scala @@ -130,26 +130,6 @@ final class ListingsSpec extends BaseIntegrationSpec { } } - "get default storage" in { - val defaultStorageId = "https://bluebrain.github.io/nexus/vocabulary/diskStorageDefault" - - val mapping = replacements( - Delta, - "project" -> ref11, - "id" -> defaultStorageId, - "self" -> storageSelf(ref11, defaultStorageId) - ) - - val expected = jsonContentOf("kg/listings/default-storage.json", mapping: _*) - - eventually { - deltaClient.get[Json](s"/storages/$ref11", Bob) { (json, response) => - response.status shouldEqual StatusCodes.OK - filterSearchMetadata(json) should equalIgnoreArrayOrder(expected) - } - } - } - val resource11WithSchemaId = s"${config.deltaUri}/resources/$proj11/_/resource11_with_schema" val resource11WithSchemaSelf = resourceSelf(ref11, resource11WithSchemaId) val resource11WithSchemaResult = jsonContentOf( diff --git a/tests/src/test/scala/ch/epfl/bluebrain/nexus/tests/kg/SparqlViewsSpec.scala b/tests/src/test/scala/ch/epfl/bluebrain/nexus/tests/kg/SparqlViewsSpec.scala index c1de220904..8bce7c59e9 100644 --- a/tests/src/test/scala/ch/epfl/bluebrain/nexus/tests/kg/SparqlViewsSpec.scala +++ b/tests/src/test/scala/ch/epfl/bluebrain/nexus/tests/kg/SparqlViewsSpec.scala @@ -213,9 +213,9 @@ class SparqlViewsSpec extends BaseIntegrationSpec { response.status shouldEqual StatusCodes.OK val expected = jsonContentOf( "kg/views/statistics.json", - "total" -> "10", - "processed" -> "10", - "evaluated" -> "10", + "total" -> "9", + "processed" -> "9", + "evaluated" -> "9", "discarded" -> "0", "remaining" -> "0" ) diff --git a/tests/src/test/scala/ch/epfl/bluebrain/nexus/tests/kg/files/StorageSpec.scala b/tests/src/test/scala/ch/epfl/bluebrain/nexus/tests/kg/files/StorageSpec.scala index 317851e9fa..e494ca540d 100644 --- a/tests/src/test/scala/ch/epfl/bluebrain/nexus/tests/kg/files/StorageSpec.scala +++ b/tests/src/test/scala/ch/epfl/bluebrain/nexus/tests/kg/files/StorageSpec.scala @@ -55,15 +55,6 @@ abstract class StorageSpec extends BaseIntegrationSpec { s"succeed for a $storageName storage" in { createStorages(projectRef, storageId, storageName) } - - "wait for storages to be indexed" in { - eventually { - deltaClient.get[Json](s"/storages/$projectRef", Coyote) { (json, response) => - response.status shouldEqual StatusCodes.OK - _total.getOption(json).value shouldEqual 3 - } - } - } } "An empty file" should { diff --git a/tests/src/test/scala/ch/epfl/bluebrain/nexus/tests/plugins/blazegraph/IncomingOutgoingBlazegraphSpec.scala b/tests/src/test/scala/ch/epfl/bluebrain/nexus/tests/plugins/blazegraph/IncomingOutgoingBlazegraphSpec.scala index 0593b9bf87..31dee21a38 100644 --- a/tests/src/test/scala/ch/epfl/bluebrain/nexus/tests/plugins/blazegraph/IncomingOutgoingBlazegraphSpec.scala +++ b/tests/src/test/scala/ch/epfl/bluebrain/nexus/tests/plugins/blazegraph/IncomingOutgoingBlazegraphSpec.scala @@ -81,7 +81,7 @@ class IncomingOutgoingBlazegraphSpec extends BaseIntegrationSpec { eventually { deltaClient.get[Json](s"/views/$orgLabel/$projLabel/graph/statistics", Radar) { (json, response) => response.status shouldEqual StatusCodes.OK - root.processedEvents.long.getOption(json).value shouldEqual 5L + root.processedEvents.long.getOption(json).value shouldEqual 4L } } }