Skip to content

Commit

Permalink
MODLD-585: Change Linked data API URIs
Browse files Browse the repository at this point in the history
  • Loading branch information
askhat-abishev committed Nov 27, 2024
1 parent 9974e1d commit 6f8d117
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 65 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ Details of few important APIs are provided below.
### Creating Work resources
At present, API support creation of Work resource (with many other resource types included, like Instance).

Resources can be created by making a POST request to the `/resource` endpoint.
Resources can be created by making a POST request to the `/linked-data/resource` endpoint.
Refer [src/main/resources/swagger.api/schema/resourceRequestDto.json](https://github.com/folio-org/mod-linked-data/blob/master/src/main/resources/swagger.api/schema/resourceRequestDto.json) for the schema of the request body.
#### Example request for creating a Work resource:
```bash
curl --location '{{ base-uri }}/resource' \
curl --location '{{ base-uri }}/linked-data/resource' \
--header 'x-okapi-tenant: {{ tenant identifier }}' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
Expand Down Expand Up @@ -252,13 +252,13 @@ curl --location '{{ base-uri }}/resource' \
}'
```
### Updating resources
Resource can be updated by making a PUT request to the `/resource/{id}` endpoint. At present, only Work resources can be updated through the API.
Resource can be updated by making a PUT request to the `/linked-data/resource/{id}` endpoint. At present, only Work resources can be updated through the API.
Refer [src/main/resources/swagger.api/schema/resourceRequestDto.json](https://github.com/folio-org/mod-linked-data/blob/master/src/main/resources/swagger.api/schema/resourceRequestDto.json) for the schema of the request body.
### Viewing a graph node
A graph node can be viewed by making a GET request to the `graph/resource/{id}` endpoint. Any kind of resources can be retrieved through this API.
A graph node can be viewed by making a GET request to the `/linked-data/resource/{id}/graph` endpoint. Any kind of resources can be retrieved through this API.
```bash
curl --location '{{ base-uri }}/graph/resource/{id}' \
curl --location '{{ base-uri }}/linked-data/resource/{id}/graph' \
--header 'x-okapi-tenant: {tenant}' \
--header 'x-okapi-token: {token}'
```
Expand Down
72 changes: 27 additions & 45 deletions descriptors/ModuleDescriptor-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
"name": "Linked Data Module",
"provides": [
{
"id": "resource",
"id": "linked-data",
"version": "1.0",
"handlers": [
{
"methods": [ "POST" ],
"pathPattern": "/resource",
"pathPattern": "/linked-data/resource",
"permissionsRequired": [ "linked-data.resources.bib.post" ],
"modulePermissions": [
"mapping-metadata.get",
Expand Down Expand Up @@ -40,19 +40,19 @@
},
{
"methods": [ "GET" ],
"pathPattern": "/resource/{id}",
"pathPattern": "/linked-data/resource/{id}",
"permissionsRequired": [ "linked-data.resources.bib.get" ],
"modulePermissions": []
},
{
"methods": [ "GET" ],
"pathPattern": "/resource/{id}/marc",
"pathPattern": "/linked-data/resource/{id}/marc",
"permissionsRequired": [ "linked-data.resources.bib.marc.get" ],
"modulePermissions": []
},
{
"methods": [ "PUT" ],
"pathPattern": "/resource/{id}",
"pathPattern": "/linked-data/resource/{id}",
"permissionsRequired": [ "linked-data.resources.bib.put" ],
"modulePermissions": [
"mapping-metadata.get",
Expand All @@ -78,31 +78,31 @@
},
{
"methods": [ "DELETE" ],
"pathPattern": "/resource/{id}",
"pathPattern": "/linked-data/resource/{id}",
"permissionsRequired": [ "linked-data.resources.bib.delete" ],
"modulePermissions": []
},
{
"methods": [ "GET" ],
"pathPattern": "/resource/metadata/{inventoryId}/id",
"pathPattern": "/linked-data/resource/metadata/{inventoryId}/id",
"permissionsRequired": [ "linked-data.resources.bib.id.get" ],
"modulePermissions": []
},
{
"methods": [ "GET" ],
"pathPattern": "/resource/check/{inventoryId}/supported",
"pathPattern": "/linked-data/inventory-instance/{inventoryId}/import-supported",
"permissionsRequired": [ "linked-data.resources.support-check.get" ],
"modulePermissions": ["source-storage.records.formatted.item.get"]
},
{
"methods": [ "GET" ],
"pathPattern": "/resource/preview/{inventoryId}",
"pathPattern": "/linked-data/inventory-instance/{inventoryId}/preview",
"permissionsRequired": [ "linked-data.resources.preview.get" ],
"modulePermissions": ["source-storage.records.formatted.item.get"]
},
{
"methods": [ "POST" ],
"pathPattern": "/resource/import/{inventoryId}",
"pathPattern": "/linked-data/inventory-instance/{inventoryId}/import",
"permissionsRequired": [ "linked-data.resources.import.post" ],
"modulePermissions": [
"source-storage.records.formatted.item.get",
Expand All @@ -121,6 +121,23 @@
"source-storage.records.post",
"source-storage.records.put"
]
},
{
"methods": [ "PUT" ],
"pathPattern": "/linked-data/reindex",
"permissionsRequired": [ "linked-data.resources.reindex.post" ],
"modulePermissions": []
},
{
"methods": [ "GET" ],
"pathPattern": "/linked-data/profile",
"permissionsRequired": [ "linked-data.profiles.get" ]
},
{
"methods": [ "GET" ],
"pathPattern": "/linked-data/resource/{id}/graph",
"permissionsRequired": [ "linked-data.resources.graph.get" ],
"modulePermissions": []
}
]
},
Expand All @@ -139,41 +156,6 @@
"pathPattern": "/_/tenant/{id}"
}
]
},
{
"id": "reindex",
"version": "1.0",
"handlers": [
{
"methods": [ "PUT" ],
"pathPattern": "/reindex",
"permissionsRequired": [ "linked-data.resources.reindex.post" ],
"modulePermissions": []
}
]
},
{
"id": "profile",
"version": "1.0",
"handlers": [
{
"methods": [ "GET" ],
"pathPattern": "/profile",
"permissionsRequired": [ "linked-data.profiles.get" ]
}
]
},
{
"id": "graph",
"version": "1.0",
"handlers": [
{
"methods": [ "GET" ],
"pathPattern": "/graph/resource/{id}",
"permissionsRequired": [ "linked-data.resources.graph.get" ],
"modulePermissions": []
}
]
}
],
"requires": [
Expand Down
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@
<templateDirectory>${project.basedir}/src/main/resources/swagger.api/templates</templateDirectory>
<configOptions>
<java8>true</java8>
<useTags>true</useTags>
<dateLibrary>java</dateLibrary>
<interfaceOnly>true</interfaceOnly>
<useSpringBoot3>true</useSpringBoot3>
Expand Down
44 changes: 34 additions & 10 deletions src/main/resources/swagger.api/mod-linked-data.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ info:
description: Linked Data service API

paths:
/reindex:
/linked-data/reindex:
put:
operationId: reindex
tags:
- reindex
description: Start the process of reindexing of resources in the database
parameters:
- $ref: '#/components/parameters/x-okapi-tenant-header'
Expand All @@ -20,9 +22,11 @@ paths:
'500':
$ref: '#/components/responses/internalServerErrorResponse'

/resource:
/linked-data/resource:
post:
operationId: createResource
tags:
- resource
description: Create a Resource
parameters:
- $ref: '#/components/parameters/x-okapi-tenant-header'
Expand All @@ -43,9 +47,11 @@ paths:
'500':
$ref: '#/components/responses/internalServerErrorResponse'

/resource/{id}:
/linked-data/resource/{id}:
get:
operationId: getResourceById
tags:
- resource
description: Get a resource by id
parameters:
- $ref: '#/components/parameters/x-okapi-tenant-header'
Expand All @@ -65,6 +71,8 @@ paths:
$ref: '#/components/responses/internalServerErrorResponse'
put:
operationId: updateResource
tags:
- resource
description: Update a resource by id
parameters:
- $ref: '#/components/parameters/x-okapi-tenant-header'
Expand All @@ -90,6 +98,8 @@ paths:
$ref: '#/components/responses/internalServerErrorResponse'
delete:
operationId: deleteResource
tags:
- resource
description: Delete a resource by id
parameters:
- $ref: '#/components/parameters/x-okapi-tenant-header'
Expand All @@ -102,9 +112,11 @@ paths:
'500':
$ref: '#/components/responses/internalServerErrorResponse'

/resource/{id}/marc:
/linked-data/resource/{id}/marc:
get:
operationId: getResourceMarcViewById
tags:
- resource
description: Get a marc view of resource by id
parameters:
- $ref: '#/components/parameters/x-okapi-tenant-header'
Expand All @@ -123,9 +135,11 @@ paths:
'500':
$ref: '#/components/responses/internalServerErrorResponse'

/resource/metadata/{inventoryId}/id:
/linked-data/resource/metadata/{inventoryId}/id:
get:
operationId: getResourceIdByResourceInventoryId
tags:
- resource
description: Get id of a resource by its inventory id
parameters:
- $ref: '#/components/parameters/x-okapi-tenant-header'
Expand All @@ -140,9 +154,11 @@ paths:
'404':
description: No resource id is found by its inventory id

/resource/check/{inventoryId}/supported:
/linked-data/inventory-instance/{inventoryId}/import-supported:
get:
operationId: isSupportedByInventoryId
tags:
- resource
description: Check if marc to bib conversion is supported
parameters:
- $ref: '#/components/parameters/inventoryId'
Expand All @@ -159,9 +175,11 @@ paths:
'500':
$ref: '#/components/responses/internalServerErrorResponse'

/resource/preview/{inventoryId}:
/linked-data/inventory-instance/{inventoryId}/preview:
get:
operationId: getResourcePreviewByInventoryId
tags:
- resource
description: Get the preview of a resource
parameters:
- $ref: '#/components/parameters/inventoryId'
Expand All @@ -177,9 +195,11 @@ paths:
'500':
$ref: '#/components/responses/internalServerErrorResponse'

/resource/import/{inventoryId}:
/linked-data/inventory-instance/{inventoryId}/import:
post:
operationId: importMarcRecord
tags:
- resource
description: Create a Resource derived from MARC record
parameters:
- $ref: '#/components/parameters/inventoryId'
Expand All @@ -197,9 +217,11 @@ paths:
'500':
$ref: '#/components/responses/internalServerErrorResponse'

/profile:
/linked-data/profile:
get:
operationId: getProfile
tags:
- profile
description: Get profile
responses:
'200':
Expand All @@ -214,9 +236,11 @@ paths:
'500':
$ref: '#/components/responses/internalServerErrorResponse'

/graph/resource/{id}:
/linked-data/resource/{id}/graph:
get:
operationId: getResourceGraphById
tags:
- graph
description: Get a resource graph by id
parameters:
- $ref: '#/components/parameters/x-okapi-tenant-header'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
class ProfileControllerIT {

private static final String PROFILE_URL = "/profile";
private static final String PROFILE_URL = "/linked-data/profile";

@Autowired
private MockMvc mockMvc;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
@IntegrationTest
class ReIndexControllerIT {

public static final String INDEX_URL = "/reindex";
public static final String INDEX_URL = "/linked-data/reindex";

@Autowired
private MockMvc mockMvc;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public abstract class ResourceControllerITBase {

public static final String LCCN_VALIDATION_NOT_AVAILABLE =
"[Could not validate LCCN for duplicate] - reason: [Unable to reach search service]. Please try later.";
public static final String RESOURCE_URL = "/resource";
public static final String RESOURCE_URL = "/linked-data/resource";
private static final String ROLES_PROPERTY = "roles";
private static final String NOTES_PROPERTY = "_notes";
private static final String ID_PROPERTY = "id";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
@IntegrationTest
class ResourceControllerValidationIT {

private static final String RESOURCE_URL = "/resource";
private static final String RESOURCE_URL = "/linked-data/resource";

@Autowired
private MockMvc mockMvc;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ void getResourceGraphById_shouldReturnResourceGraph() throws Exception {
}

private ResultActions performGet(Long resourceId) throws Exception {
var requestBuilder = get("/graph/resource/" + resourceId)
var requestBuilder = get("/linked-data/resource/" + resourceId + "/graph")
.contentType(APPLICATION_JSON)
.headers(defaultHeaders(env));

Expand Down

0 comments on commit 6f8d117

Please sign in to comment.