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

Update Endpoint REST API to support CORS endpoints #3326

Merged
merged 1 commit into from
Jun 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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