Skip to content

Commit

Permalink
Update Endpoint REST API to support CORS endpoints
Browse files Browse the repository at this point in the history
Signed-off-by: Claudio Mezzasalma <claudio.mezzasalma@eurotech.com>
  • Loading branch information
Claudio Mezzasalma committed Jun 4, 2021
1 parent 08bb941 commit 3e6f1ce
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public class EndpointInfos extends AbstractKapuaResource {
public EndpointInfoListResult simpleQuery(
@PathParam("scopeId") ScopeId scopeId,
@QueryParam("usage") String usage,
@QueryParam("endpointType") @DefaultValue(EndpointInfo.ENDPOINT_TYPE_RESOURCE) String endpointType,
@QueryParam("offset") @DefaultValue("0") int offset,
@QueryParam("limit") @DefaultValue("50") int limit) throws KapuaException {
EndpointInfoQuery query = endpointInfoFactory.newQuery(scopeId);
Expand All @@ -80,7 +81,7 @@ public EndpointInfoListResult simpleQuery(
query.setOffset(offset);
query.setLimit(limit);

return query(scopeId, query);
return query(scopeId, endpointType, query);
}

/**
Expand All @@ -99,10 +100,11 @@ public EndpointInfoListResult simpleQuery(
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public EndpointInfoListResult query(
@PathParam("scopeId") ScopeId scopeId,
@QueryParam("endpointType") @DefaultValue(EndpointInfo.ENDPOINT_TYPE_RESOURCE) String endpointType,
EndpointInfoQuery query) throws KapuaException {
query.setScopeId(scopeId);

return endpointInfoService.query(query);
return endpointInfoService.query(query, endpointType);
}

/**
Expand All @@ -121,10 +123,11 @@ public EndpointInfoListResult query(
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public CountResult count(
@PathParam("scopeId") ScopeId scopeId,
@QueryParam("endpointType") @DefaultValue(EndpointInfo.ENDPOINT_TYPE_RESOURCE) String endpointType,
EndpointInfoQuery query) throws KapuaException {
query.setScopeId(scopeId);

return new CountResult(endpointInfoService.count(query));
return new CountResult(endpointInfoService.count(query, endpointType));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ paths:
operationId: endpointInfoCount
parameters:
- $ref: '../openapi.yaml#/components/parameters/scopeId'
- $ref: './endpointInfo.yaml#/components/parameters/endpointType'
requestBody:
$ref: '../openapi.yaml#/components/requestBodies/kapuaQuery'
responses:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ paths:
operationId: endpointInfoQuery
parameters:
- $ref: '../openapi.yaml#/components/parameters/scopeId'
- $ref: './endpointInfo.yaml#/components/parameters/endpointType'
requestBody:
$ref: '../openapi.yaml#/components/requestBodies/kapuaQuery'
responses:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ paths:
description: The endpointInfo usage to filter results
schema:
type: string
- $ref: './endpointInfo.yaml#/components/parameters/endpointType'
- $ref: '../openapi.yaml#/components/parameters/limit'
- $ref: '../openapi.yaml#/components/parameters/offset'
responses:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ components:
schema:
$ref: '../openapi.yaml#/components/schemas/kapuaId'
required: true
endpointType:
name: endpointType
in: query
description: The type of the Endpoints to query for
schema:
allOf:
- $ref: '#/components/schemas/endpointType'
- default: resource
required: false
schemas:
endpointInfo:
allOf:
Expand All @@ -44,6 +53,7 @@ components:
usages:
- name: MESSAGE_BROKER
- name: PROVISION
endpointType: resource
endpointInfoCreator:
allOf:
- $ref: '../openapi.yaml#/components/schemas/kapuaUpdatableEntityCreator'
Expand All @@ -61,6 +71,8 @@ components:
type: array
items:
$ref: '#/components/schemas/usage'
endpointType:
$ref: '#/components/schemas/endpointType'
example:
schema: mqtt
dns: 10.200.12.148
Expand All @@ -69,6 +81,7 @@ components:
usages:
- name: MESSAGE_BROKER
- name: PROVISION
endpointType: resource
endpointInfoListResult:
allOf:
- $ref: '../openapi.yaml#/components/schemas/kapuaListResult'
Expand Down Expand Up @@ -98,8 +111,14 @@ components:
usages:
- name: MESSAGE_BROKER
- name: PROVISION
endpointType: resource
usage:
type: object
properties:
name:
type: string
endpointType:
type: string
enum:
- resource
- cors

0 comments on commit 3e6f1ce

Please sign in to comment.