mirror of
https://github.com/opennetworkinglab/onos.git
synced 2026-05-05 12:16:13 +02:00
ONOS-4077: REST API's for virtual networks, devices, ports, links: add missing onos.rsModel statements + fix example field in JSON files
Change-Id: I1ae2300143a0a56e5413f8837cea3016d964cb6c
This commit is contained in:
parent
54d51aa3cd
commit
1decd53931
@ -43,8 +43,8 @@ public class VirtualDeviceCodec extends JsonCodec<VirtualDevice> {
|
||||
checkNotNull(vDev, NULL_OBJECT_MSG);
|
||||
|
||||
ObjectNode result = context.mapper().createObjectNode()
|
||||
.put(ID, vDev.id().toString())
|
||||
.put(NETWORK_ID, vDev.networkId().toString());
|
||||
.put(NETWORK_ID, vDev.networkId().toString())
|
||||
.put(ID, vDev.id().toString());
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -60,6 +60,13 @@ public class VirtualDeviceCodec extends JsonCodec<VirtualDevice> {
|
||||
return new DefaultVirtualDevice(nId, dId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract member from JSON ObjectNode.
|
||||
*
|
||||
* @param key key for which value is needed
|
||||
* @param json JSON ObjectNode
|
||||
* @return member value
|
||||
*/
|
||||
private String extractMember(String key, ObjectNode json) {
|
||||
return nullIsIllegal(json.get(key), key + MISSING_MEMBER_MSG).asText();
|
||||
}
|
||||
|
||||
@ -42,9 +42,11 @@ public class VirtualLinkCodec extends JsonCodec<VirtualLink> {
|
||||
public ObjectNode encode(VirtualLink vLink, CodecContext context) {
|
||||
checkNotNull(vLink, NULL_OBJECT_MSG);
|
||||
|
||||
ObjectNode result = context.mapper().createObjectNode()
|
||||
.put(NETWORK_ID, vLink.networkId().toString());
|
||||
JsonCodec<Link> codec = context.codec(Link.class);
|
||||
ObjectNode result = codec.encode(vLink, context);
|
||||
result.put(NETWORK_ID, vLink.networkId().toString());
|
||||
ObjectNode linkResult = codec.encode(vLink, context);
|
||||
result.setAll(linkResult);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@ -75,6 +75,7 @@ public class VirtualNetworkWebResource extends AbstractWebResource {
|
||||
* Returns all virtual networks.
|
||||
*
|
||||
* @return 200 OK
|
||||
* @onos.rsModel VirtualNetworks
|
||||
*/
|
||||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@ -92,6 +93,7 @@ public class VirtualNetworkWebResource extends AbstractWebResource {
|
||||
*
|
||||
* @param tenantId tenant identifier
|
||||
* @return 200 OK, 404 not found
|
||||
* @onos.rsModel VirtualNetworks
|
||||
*/
|
||||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@ -106,7 +108,7 @@ public class VirtualNetworkWebResource extends AbstractWebResource {
|
||||
/**
|
||||
* Creates a virtual network from the JSON input stream.
|
||||
*
|
||||
* @param stream TenantId JSON stream
|
||||
* @param stream tenant identifier JSON stream
|
||||
* @return status of the request - CREATED if the JSON is correct,
|
||||
* BAD_REQUEST if the JSON is invalid
|
||||
* @onos.rsModel TenantId
|
||||
@ -150,6 +152,7 @@ public class VirtualNetworkWebResource extends AbstractWebResource {
|
||||
*
|
||||
* @param networkId network identifier
|
||||
* @return 200 OK
|
||||
* @onos.rsModel VirtualDevices
|
||||
*/
|
||||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@ -164,7 +167,7 @@ public class VirtualNetworkWebResource extends AbstractWebResource {
|
||||
* Creates a virtual device from the JSON input stream.
|
||||
*
|
||||
* @param networkId network identifier
|
||||
* @param stream Virtual device JSON stream
|
||||
* @param stream virtual device JSON stream
|
||||
* @return status of the request - CREATED if the JSON is correct,
|
||||
* BAD_REQUEST if the JSON is invalid
|
||||
* @onos.rsModel VirtualDevice
|
||||
@ -220,6 +223,7 @@ public class VirtualNetworkWebResource extends AbstractWebResource {
|
||||
* @param networkId network identifier
|
||||
* @param deviceId virtual device identifier
|
||||
* @return 200 OK
|
||||
* @onos.rsModel VirtualPorts
|
||||
*/
|
||||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@ -236,7 +240,7 @@ public class VirtualNetworkWebResource extends AbstractWebResource {
|
||||
*
|
||||
* @param networkId network identifier
|
||||
* @param virtDeviceId virtual device identifier
|
||||
* @param stream Virtual device JSON stream
|
||||
* @param stream virtual port JSON stream
|
||||
* @return status of the request - CREATED if the JSON is correct,
|
||||
* BAD_REQUEST if the JSON is invalid
|
||||
* @onos.rsModel VirtualPort
|
||||
@ -309,6 +313,7 @@ public class VirtualNetworkWebResource extends AbstractWebResource {
|
||||
*
|
||||
* @param networkId network identifier
|
||||
* @return 200 OK
|
||||
* @onos.rsModel VirtualLinks
|
||||
*/
|
||||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@ -323,7 +328,7 @@ public class VirtualNetworkWebResource extends AbstractWebResource {
|
||||
* Creates a virtual network link from the JSON input stream.
|
||||
*
|
||||
* @param networkId network identifier
|
||||
* @param stream Virtual device JSON stream
|
||||
* @param stream virtual link JSON stream
|
||||
* @return status of the request - CREATED if the JSON is correct,
|
||||
* BAD_REQUEST if the JSON is invalid
|
||||
* @onos.rsModel VirtualLink
|
||||
@ -358,7 +363,7 @@ public class VirtualNetworkWebResource extends AbstractWebResource {
|
||||
* Removes the virtual network link from the JSON input stream.
|
||||
*
|
||||
* @param networkId network identifier
|
||||
* @param stream deviceIds JSON stream
|
||||
* @param stream virtual link JSON stream
|
||||
* @return 200 OK, 404 not found
|
||||
* @onos.rsModel VirtualLink
|
||||
*/
|
||||
|
||||
@ -7,7 +7,8 @@
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "String",
|
||||
"example": "Tenant unique identifier"
|
||||
"description": "Tenant identifier",
|
||||
"example": "Tenant123"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,7 +20,8 @@
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "String",
|
||||
"example": "Tenant unique identifier"
|
||||
"description": "Tenant identifier",
|
||||
"example": "Tenant123"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,12 +7,14 @@
|
||||
],
|
||||
"properties": {
|
||||
"networkId": {
|
||||
"type": "String",
|
||||
"example": "Network identifier"
|
||||
"type": "int64",
|
||||
"description": "Network identifier",
|
||||
"example": 3
|
||||
},
|
||||
"deviceId": {
|
||||
"type": "String",
|
||||
"example": "Device identifier"
|
||||
"description": "Device identifier",
|
||||
"example": "of:0000000000000042"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
36
web/api/src/main/resources/definitions/VirtualDevices.json
Normal file
36
web/api/src/main/resources/definitions/VirtualDevices.json
Normal file
@ -0,0 +1,36 @@
|
||||
{
|
||||
"type": "object",
|
||||
"title": "VirtualDevices",
|
||||
"required": [
|
||||
"devices"
|
||||
],
|
||||
"properties": {
|
||||
"devices": {
|
||||
"type": "array",
|
||||
"xml": {
|
||||
"name": "devices",
|
||||
"wrapped": true
|
||||
},
|
||||
"items": {
|
||||
"type": "object",
|
||||
"title": "vdev",
|
||||
"required": [
|
||||
"networkId",
|
||||
"deviceId"
|
||||
],
|
||||
"properties": {
|
||||
"networkId": {
|
||||
"type": "int64",
|
||||
"description": "Network identifier",
|
||||
"example": 3
|
||||
},
|
||||
"deviceId": {
|
||||
"type": "String",
|
||||
"description": "Device identifier",
|
||||
"example": "of:0000000000000042"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -10,8 +10,9 @@
|
||||
],
|
||||
"properties": {
|
||||
"networkId": {
|
||||
"type": "String",
|
||||
"example": "Network identifier"
|
||||
"type": "int64",
|
||||
"description": "Network identifier",
|
||||
"example": 3
|
||||
},
|
||||
"src": {
|
||||
"type": "object",
|
||||
@ -22,8 +23,8 @@
|
||||
],
|
||||
"properties": {
|
||||
"port": {
|
||||
"type": "string",
|
||||
"example": "3"
|
||||
"type": "int64",
|
||||
"example": 3
|
||||
},
|
||||
"device": {
|
||||
"type": "string",
|
||||
@ -40,8 +41,8 @@
|
||||
],
|
||||
"properties": {
|
||||
"port": {
|
||||
"type": "string",
|
||||
"example": "2"
|
||||
"type": "int64",
|
||||
"example": 2
|
||||
},
|
||||
"device": {
|
||||
"type": "string",
|
||||
|
||||
78
web/api/src/main/resources/definitions/VirtualLinks.json
Normal file
78
web/api/src/main/resources/definitions/VirtualLinks.json
Normal file
@ -0,0 +1,78 @@
|
||||
{
|
||||
"type": "object",
|
||||
"title": "VirtualLinks",
|
||||
"required": [
|
||||
"links"
|
||||
],
|
||||
"properties": {
|
||||
"links": {
|
||||
"type": "array",
|
||||
"xml": {
|
||||
"name": "links",
|
||||
"wrapped": true
|
||||
},
|
||||
"items": {
|
||||
"type": "object",
|
||||
"title": "vlink",
|
||||
"required": [
|
||||
"networkId",
|
||||
"src",
|
||||
"dst",
|
||||
"type",
|
||||
"state"
|
||||
],
|
||||
"properties": {
|
||||
"networkId": {
|
||||
"type": "int64",
|
||||
"description": "Network identifier",
|
||||
"example": 3
|
||||
},
|
||||
"src": {
|
||||
"type": "object",
|
||||
"title": "src",
|
||||
"required": [
|
||||
"port",
|
||||
"device"
|
||||
],
|
||||
"properties": {
|
||||
"port": {
|
||||
"type": "int64",
|
||||
"example": 3
|
||||
},
|
||||
"device": {
|
||||
"type": "string",
|
||||
"example": "of:0000000000000002"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dst": {
|
||||
"type": "object",
|
||||
"title": "dst",
|
||||
"required": [
|
||||
"port",
|
||||
"device"
|
||||
],
|
||||
"properties": {
|
||||
"port": {
|
||||
"type": "int64",
|
||||
"example": 2
|
||||
},
|
||||
"device": {
|
||||
"type": "string",
|
||||
"example": "of:0000000000000003"
|
||||
}
|
||||
}
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"example": "VIRTUAL"
|
||||
},
|
||||
"state": {
|
||||
"type": "string",
|
||||
"example": "ACTIVE"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
36
web/api/src/main/resources/definitions/VirtualNetworks.json
Normal file
36
web/api/src/main/resources/definitions/VirtualNetworks.json
Normal file
@ -0,0 +1,36 @@
|
||||
{
|
||||
"type": "object",
|
||||
"title": "VirtualNetworks",
|
||||
"required": [
|
||||
"vnets"
|
||||
],
|
||||
"properties": {
|
||||
"vnets": {
|
||||
"type": "array",
|
||||
"xml": {
|
||||
"name": "vnets",
|
||||
"wrapped": true
|
||||
},
|
||||
"items": {
|
||||
"type": "object",
|
||||
"title": "vnet",
|
||||
"required": [
|
||||
"networkId",
|
||||
"tenantId"
|
||||
],
|
||||
"properties": {
|
||||
"networkId": {
|
||||
"type": "int64",
|
||||
"description": "Network identifier",
|
||||
"example": 3
|
||||
},
|
||||
"tenantId": {
|
||||
"type": "String",
|
||||
"description": "Tenant identifier",
|
||||
"example": "Tenant123"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -10,24 +10,29 @@
|
||||
],
|
||||
"properties": {
|
||||
"networkId": {
|
||||
"type": "String",
|
||||
"example": "Network identifier"
|
||||
"type": "int64",
|
||||
"description": "Network identifier",
|
||||
"example": 3
|
||||
},
|
||||
"deviceId": {
|
||||
"type": "String",
|
||||
"example": "Virtual device identifier"
|
||||
"description": "Virtual device identifier",
|
||||
"example": "of:0000000000000042"
|
||||
},
|
||||
"portNum": {
|
||||
"type": "String",
|
||||
"example": "Virtual device port number"
|
||||
"type": "int64",
|
||||
"description": "Virtual device port number",
|
||||
"example": 34
|
||||
},
|
||||
"physDeviceId": {
|
||||
"type": "String",
|
||||
"example": "Physical device identifier"
|
||||
"description": "Physical device identifier",
|
||||
"example": "of:0000000000000003"
|
||||
},
|
||||
"physPortNum": {
|
||||
"type": "String",
|
||||
"example": "Physical device port number"
|
||||
"type": "int64",
|
||||
"description": "Physical device port number",
|
||||
"example": 2
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
54
web/api/src/main/resources/definitions/VirtualPorts.json
Normal file
54
web/api/src/main/resources/definitions/VirtualPorts.json
Normal file
@ -0,0 +1,54 @@
|
||||
{
|
||||
"type": "object",
|
||||
"title": "VirtualPorts",
|
||||
"required": [
|
||||
"ports"
|
||||
],
|
||||
"properties": {
|
||||
"ports": {
|
||||
"type": "array",
|
||||
"xml": {
|
||||
"name": "ports",
|
||||
"wrapped": true
|
||||
},
|
||||
"items": {
|
||||
"type": "object",
|
||||
"title": "vport",
|
||||
"required": [
|
||||
"networkId",
|
||||
"deviceId",
|
||||
"portNum",
|
||||
"physDeviceId",
|
||||
"physPortNum"
|
||||
],
|
||||
"properties": {
|
||||
"networkId": {
|
||||
"type": "int64",
|
||||
"description": "Network identifier",
|
||||
"example": 3
|
||||
},
|
||||
"deviceId": {
|
||||
"type": "String",
|
||||
"description": "Virtual device identifier",
|
||||
"example": "of:0000000000000042"
|
||||
},
|
||||
"portNum": {
|
||||
"type": "int64",
|
||||
"description": "Virtual device port number",
|
||||
"example": 34
|
||||
},
|
||||
"physDeviceId": {
|
||||
"type": "String",
|
||||
"description": "Physical device identifier",
|
||||
"example": "of:0000000000000003"
|
||||
},
|
||||
"physPortNum": {
|
||||
"type": "int64",
|
||||
"description": "Physical device port number",
|
||||
"example": 2
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user