Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow users to perform dry-runs on resources (with optional validation with a schema) #4102

Closed
imsdu opened this issue Jul 24, 2023 · 2 comments · Fixed by #4274
Closed

Allow users to perform dry-runs on resources (with optional validation with a schema) #4102

imsdu opened this issue Jul 24, 2023 · 2 comments · Fixed by #4274
Assignees
Labels

Comments

@imsdu
Copy link
Contributor

imsdu commented Jul 24, 2023

Motivation
Delta does not provide any endpoint that would allow users to perform dry-runs on resources when this can be useful to test and debug without performing any writes to the primary store.

As the lower layers of Delta already allow to perform dry-runs, we want to make this available with a new endpoint which would allow users to test resources with and without a schema validation

Acceptance criteria

  1. When a user calls this endpoint, no write operation to the primary store is done
  2. The user must provide a valid resource payload following the same rules as the create and update operations of a resource
  3. Optionally the user can also provide a schema to validate this resource with:
  • A reference to an existing schema (with an optional revision/tag)
  • The payload of a new schema
  1. When the resource is valid, then it is returned to the user (the same as the result of the fetch operation)
  2. When the resource can't be validated with the provided schema then an error containing the resulting resource and the validation report is returned to the user
  3. When the resource is not valid for any other reason (the resource payload is invalid, the provided schema reference does not exist), an appropriate message is returned to the user

API changes
An example of requests would be:
With no validation

POST /v1/dry-run/resources/{org}/{project}
 {
   "resource": {
    "@context": [
      "https://bbp.neuroshapes.org"
    ],
    "@id": "https://bbp.epfl.ch/nexus/v1/realms/bbp/users/bob",
    "@type": [
      "Person",
      "Agent"
    ],
    "email": "[email protected]",
    "familyName": "Doe",
    "givenName": "Bob",
  }
}

With validation with a new schema

POST /v1/dry-run/resources/{org}/{project}
  "schema": {
    "@type": "ExistingSchema",
    "@id": "nxv:mySchema"
  },
  "resource": {
    "@context": [
      "https://bbp.neuroshapes.org"
    ],
    "@id": "https://bbp.epfl.ch/nexus/v1/realms/bbp/users/bob",
    "@type": [
      "Person",
      "Agent"
    ],
    "email": "[email protected]",
    "familyName": "Doe",
    "givenName": "Bob",
  }
}

With validation with a new schema

POST /v1/dry-run/resources/{org}/{project}
  "schema": {
    "@type": "NewSchema",
    "value": { ... } # SHACL schema
  },
  "resource": {
    "@context": [
      "https://bbp.neuroshapes.org"
    ],
    "@id": "https://bbp.epfl.ch/nexus/v1/realms/bbp/users/bob",
    "@type": [
      "Person",
      "Agent"
    ],
    "email": "[email protected]",
    "familyName": "Doe",
    "givenName": "Bob",
  }
}
@imsdu imsdu added the delta label Jul 24, 2023
@crisely09
Copy link
Contributor

For the first case, does it need to be of @type: Unconstrained or is it just a placeholder for any type?

@imsdu
Copy link
Contributor Author

imsdu commented Jul 24, 2023

@crisely09 It can be something else, it is just that whenever something is not validated today, its schema is https://bluebrain.github.io/nexus/schemas/unconstrained.json so I wanted to reuse the same vocabulary

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants