update api

This commit is contained in:
Mengyi Zhou 2017-01-24 13:01:27 +08:00
parent d495d7f007
commit 79bed77729
4 changed files with 227 additions and 107 deletions

View file

@ -29,10 +29,10 @@ public abstract class GroupView {
@JsonView(ViewConstraints.Normal.class)
abstract Integer getVersion();
@JsonView(ViewConstraints.Normal.class)
@JsonView(ViewConstraints.Detail.class)
abstract HealthCheck getHealthCheck();
@JsonView(ViewConstraints.Normal.class)
@JsonView(ViewConstraints.Detail.class)
abstract LoadBalancingMethod getLoadBalancingMethod();
@JsonView(ViewConstraints.Normal.class)

View file

@ -123,6 +123,40 @@ public class GroupMemberResource {
return responseHandler.handle(groupServerList, hh.getMediaType());
}
/**
* @api {post} /api/group/addMember: [Write] Add group server
* @apiName AddMember
* @apiGroup Member
* @apiSuccess (Success 200) {String} message success message
* @apiParam (Parameter) {boolean} [online=false] add group servers to its offline (and online) version
* @apiParam (RequestEntity) {long} group-id the group to be modified
* @apiParam (RequestEntity) {GroupServer[]} group-servers group servers to be added
* @apiParam (GroupServer) {Integer} port server port
* @apiParam (GroupServer) {String} ip server ip
* @apiParam (GroupServer) {String} host-name server host name
* @apiParam (GroupServer) {Integer} [weight] [readonly]
* @apiParam (GroupServer) {Integer} [max-fails=0] exclude server from proxying if max_fails count exceeds the latch for fails_timeout interval, disabled if values 0
* @apiParam (GroupServer) {Integer} [fails-timeout=0] disabled by default
* @apiParamExample {json} Sample Request:
* {
* "group-id" : 1,
* "group-servers" : [ {
* "port" : 8080,
* "ip" : "127.0.0.1",
* "host-name" : "PC1",
* "weight" : 5,
* "max-fails" : 0,
* "fail-timeout" : 0
* }, {
* "port" : 8080,
* "ip" : "127.0.0.2",
* "host-name" : "PC2",
* "weight" : 5,
* "max-fails" : 0,
* "fail-timeout" : 0
* } ]
* }
*/
@POST
@Path("/group/addMember")
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@ -235,6 +269,15 @@ public class GroupMemberResource {
return responseHandler.handle("Successfully updated group servers to group with id " + gsl.getGroupId() + ".", hh.getMediaType());
}
/**
* @api {get} /api/group/removeMember: [Write] Remove group server
* @apiName RemoveMember
* @apiGroup Member
* @apiSuccess (Success 200) {String} message success message
* @apiParam {boolean} [online=false] add group servers to its offline (and online) version
* @apiParam {long} groupId the group to be modified
* @apiParam {string[]} ip group servers to be removed
*/
@GET
@Path("/group/removeMember")
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})

View file

@ -76,23 +76,101 @@ public class GroupResource {
Logger logger = LoggerFactory.getLogger(this.getClass());
/**
* @api {get} /api/groups: Request group information
* @api {get} /api/groups: [Read] Batch fetch group data
* @apiName ListGroups
* @apiGroup Group
* @apiParam {long[]} groupId 1,2,3
* @apiParam {string[]} groupName dev,localhost,test
* @apiParam {string[]} fuzzyName de,local,te
* @apiParam {string[]} appId 1001,1101,1100
* @apiParam {string[]} ip 10.2.1.2,10.2.1.11
* @apiParam {string} mode get {online/offline/redundant} (redundant=online&offline) version
* @apiParam {string} type get groups with {info/normal/detail/extended} information
* @apiParam {string[]} anyTag union search groups by tags e.g. anyTag=group1,group2
* @apiParam {string[]} tags join search groups by tags e.g. tags=group1,group2
* @apiParam {string[]} anyProp union search groups by properties(key:value) e.g. anyProp=dc:oy,dc:jq
* @apiParam {string[]} props join search groups by properties(key:value) e.g. props=department:hotel,dc:jq
* @apiParam {any} vs supported vs property queries, ref /api/vses
* @apiParam {any} slb supported slb property queries, ref /api/slbs
* @apiSuccess {Group[]} groups group list json object
* @apiDescription See [Update group content](#api-Group-FullUpdateGroup) for object description
* @apiSuccess (Success 200) {GroupObject[]} groups group list result after query
* @apiSuccess (Success 200) {Integer[]} total total number of group entities in the group list, it may be useful when `limit` parameter is specified
* @apiParam {long[]} [groupId] 1,2,3
* @apiParam {string[]} [groupName] dev,localhost,test
* @apiParam {string[]} [fuzzyName] de,local,te
* @apiParam {string[]} [appId] 1001,1101,1100
* @apiParam {string[]} [ip] 10.2.1.2,10.2.1.11
* @apiParam {string=online,offline,redundant(online&offline)} [mode] query snapshot versions by mode
* @apiParam {string=info,normal,detail,extended} [type] filter group information by detail level
* @apiParam {int} [limit=unlimited] get limited number of result
* @apiParam {int} [offset=0] get limited number of result since offset
* @apiParam {string=id,name,created-time} [sort] sort by property asc
* @apiParam {string=asc,desc} [order] sort by group property and specified order
* @apiParam {string[]} [anyTag] union search group by tags e.g. anyTag=group1,group2
* @apiParam {string[]} [tags] join search group by tags e.g. tags=group1,group2
* @apiParam {string[]} [anyProp] union search group by properties(key:value) e.g. anyProp=dc:oy,dc:jq
* @apiParam {string[]} [props] join search group by properties(key:value) e.g. props=department:hotel,dc:jq
* @apiParam {any} [vs] supported vs property queries, ref /api/vses
* @apiParam {any} [slb] supported slb property queries, ref /api/slbs
* @apiSuccess (PropertyDetailLevel) {Long} id info/normal/detail/extended
* @apiSuccess (PropertyDetailLevel) {String} name info/normal/detail/extended
* @apiSuccess (PropertyDetailLevel) {Integer} version info/normal/detail/extended
* @apiSuccess (PropertyDetailLevel) {String} created-time normal/detail/extended
* @apiSuccess (PropertyDetailLevel) {Boolean} ssl normal/detail/extended
* @apiSuccess (PropertyDetailLevel) {String} app-id info/normal/detail/extended
* @apiSuccess (PropertyDetailLevel) {GroupVirtualServer[]} group-virtual-servers detail/extended
* @apiSuccess (PropertyDetailLevel) {HealthCheck} health-check detail/extended
* @apiSuccess (PropertyDetailLevel) {Object} load-balancing-method detail/extended
* @apiSuccess (PropertyDetailLevel) {String[]} tags extended
* @apiSuccess (PropertyDetailLevel) {Object[]} properties extended
* @apiSuccess (PropertyDetailLevel) {Object[]} group-servers normal/detail/extended
* @apiSuccessExample {json} JSON format:
* {
* "id" : 1,
* "name" : "sg_soho_dev_localhost_testservice",
* "version" : 1,
* "created-time" : "2016-09-18 10:00:05",
* "ssl" : false,
* "app-id" : "999999",
* "group-virtual-servers" : [ {
* "path" : "~* ^/testservice($|/|\\?)",
* "virtual-server" : {
* "port" : "80",
* "version" : 1,
* "domains" : [ {
* "name" : "localhost"
* } ],
* "ssl" : false,
* "id" : 3,
* "slb-id" : 3,
* "slb-ids" : [ 3 ],
* "name" : "localhost_80"
* },
* "rewrite" : "",
* "priority" : 1000
* } ],
* "health-check" : {
* "timeout" : 2000,
* "uri" : "/slbhealthcheck.html",
* "intervals" : 10000,
* "fails" : 10,
* "passes" : 3
* },
* "load-balancing-method" : {
* "type" : "roundrobin",
* "value" : "default"
* },
* "tags" : [ "my_favorite", "test_group" ],
* "properties" : [ {
* "name" : "status",
* "value" : "activated"
* }, {
* "name" : "Department",
* "value" : "framework"
* } ],
* "group-servers" : [ {
* "port" : 8080,
* "ip" : "127.0.0.1",
* "host-name" : "PC1",
* "weight" : 5,
* "max-fails" : 0,
* "fail-timeout" : 0
* }, {
* "port" : 8080,
* "ip" : "127.0.0.2",
* "host-name" : "PC2",
* "weight" : 5,
* "max-fails" : 0,
* "fail-timeout" : 0
* } ]
* }
*/
@GET
@Path("/groups")
@ -165,61 +243,11 @@ public class GroupResource {
}
/**
* @api {get} /api/group: Get group content
* @api {get} /api/group: [Read] Get single group data
* @apiName GetSingleGroup
* @apiGroup Group
* @apiSuccess {Group} group json object
* @apiExample {json} Usage:
* {
* "id" : 1,
* "name" : "sg_soho_dev_localhost_testservice",
* "version" : 1,
* "ssl" : false,
* "app-id" : "999999",
* "group-virtual-servers" : [ {
* "path" : "~* ^/testservice",
* "virtual-server" : {
* "port" : "80",
* "version" : 1,
* "domains" : [ {
* "name" : "localhost"
* } ],
* "ssl" : false,
* "id" : 3,
* "slb-id" : 3,
* "slb-ids" : [ 3 ],
* "name" : "localhost_80"
* },
* "rewrite" : "",
* "priority" : 1000
* } ],
* "health-check" : {
* "timeout" : 2000,
* "uri" : "/slbhealthcheck.html",
* "intervals" : 10000,
* "fails" : 10,
* "passes" : 3
* },
* "load-balancing-method" : {
* "type" : "roundrobin",
* "value" : "default"
* },
* "group-servers" : [ {
* "port" : 8080,
* "ip" : "127.0.0.1",
* "host-name" : "PC1",
* "weight" : 5,
* "max-fails" : 0,
* "fail-timeout" : 0
* }, {
* "port" : 8080,
* "ip" : "127.0.0.2",
* "host-name" : "PC2",
* "weight" : 5,
* "max-fails" : 0,
* "fail-timeout" : 0
* } ]
* }
* @apiDescription See [Batch fetch group data](#api-Group-ListGroups) for more information
* @apiSuccess (Success 200) {GroupObject} group group entity
*/
@GET
@Path("/group")
@ -295,6 +323,13 @@ public class GroupResource {
return responseHandler.handleSerializedValue(ObjectJsonWriter.write(listView, type), hh.getMediaType());
}
/**
* @api {post} /api/group/new: [Write] Create new group
* @apiName CreateGroup
* @apiGroup Group
* @apiDescription See [Update group content](#api-Group-FullUpdateGroup) for object description
* @apiSuccess {Group} newly created group object
**/
@POST
@Path("/group/new")
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, "*/*"})
@ -378,50 +413,70 @@ public class GroupResource {
}
/**
* @api {post} /api/group/update: Update group content
* @apiName UpdateGroup
* @api {post} /api/group/update: [Write] Update group content
* @apiName FullUpdateGroup
* @apiGroup Group
* @apiSuccess {Group} group json object
* @apiExample {json} Usage:
* @apiSuccess {Group} updated group object
* @apiParam (GroupObject) {Long} id id
* @apiParam (GroupObject) {String} name name
* @apiParam (GroupObject) {Integer} version version
* @apiParam (GroupObject) {Boolean} ssl https group
* @apiParam (GroupObject) {String} app-id app id
* @apiParam (GroupObject) {GroupVirtualServer[]} group-virtual-servers configuration on specified virtual server
* @apiParam (GroupObject) {HealthCheck} [health-check] health check configuration, disabled if null
* @apiParam (GroupObject) {String[]} [tags] add tags to group
* @apiParam (GroupObject) {Object[]} [properties] add/update properties of group
* @apiParam (GroupObject) {Object[]} group-servers group server list
* @apiParam (GroupVirtualServer) {String} path location entry on the specified virtual server
* @apiParam (GroupVirtualServer) {String} [rewrite] rewrite path before proxying
* @apiParam (GroupVirtualServer) {Integer} [priority] recommend to leave null, otherwise force set priority of location entry on the specified virtual server
* @apiParam (GroupVirtualServer) {Object} virtual-server combined virtual server [id only]
* @apiParam (HealthCheck) {Integer} [timeout=2000] timeout for health check page
* @apiParam (HealthCheck) {Integer} uri health check uri
* @apiParam (HealthCheck) {Integer} [interval=5000] health check interval
* @apiParam (HealthCheck) {Integer} [fails=3] mark down after continuous failure count exceeds the latch
* @apiParam (HealthCheck) {Integer} [passes=1] mark up after continuous success count reaches the latch
* @apiParam (GroupServer) {Integer} port server port
* @apiParam (GroupServer) {String} ip server ip
* @apiParam (GroupServer) {String} host-name server host name
* @apiParam (GroupServer) {Integer} [weight] [readonly]
* @apiParam (GroupServer) {Integer} [max-fails=0] exclude server from proxing if max_fails count exceeds the latch for fails_timeout interval, disabled if values 0
* @apiParam (GroupServer) {Integer} [fails-timeout=0] disabled by default
* @apiParamExample {json} Sample Request:
* {
* "id" : 1,
* "name" : "sg_soho_dev_localhost_testservice",
* "version" : 1,
* "created-time" : "2016-09-18 10:00:05",
* "ssl" : false,
* "app-id" : "999999",
* "group-virtual-servers" : [ {
* "path" : "~* ^/testservice",
* "path" : "~* ^/testservice($|/|\\?)",
* "virtual-server" : {
* "id" : 715
* "id" : 3
* },
* "rewrite" : "",
* "priority" : 1000
* } ],
* "health-check" : {
* "timeout" : 2000,
* "uri" : "/slbhealthcheck.html",
* "intervals" : 10000,
* "fails" : 10,
* "passes" : 3
* },
* "load-balancing-method" : {
* "type" : "roundrobin",
* "value" : "default"
* "uri" : "/slbhealthcheck.html"
* },
* "tags" : [ "my_favorite", "test_group" ],
* "properties" : [ {
* "name" : "status",
* "value" : "activated"
* }, {
* "name" : "Department",
* "value" : "framework"
* } ],
* "group-servers" : [ {
* "port" : 8080,
* "ip" : "127.0.0.1",
* "host-name" : "PC1",
* "weight" : 5,
* "max-fails" : 0,
* "fail-timeout" : 0
* }, {
* "port" : 8080,
* "ip" : "127.0.0.2",
* "host-name" : "PC2",
* "weight" : 5,
* "max-fails" : 0,
* "fail-timeout" : 0
* } ]
* }
*/

View file

@ -84,8 +84,8 @@ public class OperationResource {
private Logger logger = LoggerFactory.getLogger(this.getClass());
/**
* @api {get} /api/op/upServer: Mark up a server
* @apiDescription Mark up server action will take effect on a physical server. It will set server status to 'up' to all nesting SLB groups.
* @api {get} /api/op/upServer: [OPS] Mark up a server
* @apiDescription Mark up server action will take effect on a physical server. It will set `server` status to 'up' to all nesting SLB groups.
* @apiName MarkUpServer
* @apiGroup Operation
* @apiParam {String} ip server ip address
@ -99,8 +99,8 @@ public class OperationResource {
}
/**
* @api {get} /api/op/downServer: Mark down a server
* @apiDescription Mark down server action will take effect on a physical server. It will set server status to 'down' to all nesting SLB groups.
* @api {get} /api/op/downServer: [OPS] Mark down a server
* @apiDescription Mark down server action will take effect on a physical server. It will set `server` status to 'down' to all nesting SLB groups.
* @apiName MarkDownServer
* @apiGroup Operation
* @apiParam {String} ip server ip address
@ -187,13 +187,13 @@ public class OperationResource {
}
/**
* @api {get} /api/op/upMember: Mark up group member(s)
* @apiDescription Mark up group member action will take effect only on a single group. It will set member status to 'up' on the specified group.
* @api {get} /api/op/upMember: [OPS] Mark up member(s)
* @apiDescription Mark up group member action will take effect only on a single group. It will set `member` status to 'up' on the specified group.
* @apiName MarkUpMember
* @apiGroup Operation
* @apiParam {Long} groupId id of the target group whose member needs to be marked up
* @apiParam {String} groupName name of the target group whose member needs to be marked up
* @apiParam {StringList} ip group member ip address(es)
* @apiParam {String[]} ip group member ip address(es)
* @apiParam {Boolean} batch if multiple group members needs to be marked up, batch value must be explicitly set to true
* @apiSuccess {GroupServerStatusList} member statuses by group
*/
@ -219,13 +219,13 @@ public class OperationResource {
}
/**
* @api {get} /api/op/downMember: Mark down group member(s)
* @apiDescription Mark down group member action will take effect only on a single group. It will set member status to 'down' on the specified group.
* @api {get} /api/op/downMember: [OPS] Mark down member(s)
* @apiDescription Mark down group member action will take effect only on a single group. It will set `member` status to 'down' on the specified group.
* @apiName MarkDownMember
* @apiGroup Operation
* @apiParam {Long} groupId id of the target group whose member needs to be marked down
* @apiParam {String} groupName name of the target group whose member needs to be marked down
* @apiParam {StringList} ip group member ip address(es)
* @apiParam {String[]} ip group member ip address(es)
* @apiParam {Boolean} batch if multiple group members needs to be marked down, batch value must be explicitly set to true
* @apiSuccess {GroupServerStatusList} member statuses by group
*/
@ -252,13 +252,13 @@ public class OperationResource {
}
/**
* @api {get} /api/op/pullIn: Pull in group member(s)
* @apiDescription Pull in group member action will take effect only on a single group. It will set pull status to 'up' on the specified group.
* @api {get} /api/op/pullIn: [TARS] Pull in member(s)
* @apiDescription Pull in group member action will take effect only on a single group. It will set `pull` status to 'up' on the specified group.
* @apiName PullInMember
* @apiGroup Operation
* @apiParam {Long} groupId id of the target group whose member needs to be pulled in
* @apiParam {String} groupName name of the target group whose member needs to be pulled in
* @apiParam {StringList} ip group member ip address(es)
* @apiParam {String[]} ip group member ip address(es)
* @apiParam {Boolean} batch if multiple group members needs to be pulled in, batch value must be explicitly set to true
* @apiSuccess {GroupServerStatusList} member statuses by group
*/
@ -283,13 +283,13 @@ public class OperationResource {
}
/**
* @api {get} /api/op/pullOut: Pull out group member(s)
* @apiDescription Pull out group member action will take effect only on a single group. It will set pull status to 'down' on the specified group.
* @api {get} /api/op/pullOut: [TARS] Pull out member(s)
* @apiDescription Pull out group member action will take effect only on a single group. It will set `pull` status to 'down' on the specified group.
* @apiName PullOutMember
* @apiGroup Operation
* @apiParam {Long} groupId id of the target group whose member needs to be pulled out
* @apiParam {String} groupName name of the target group whose member needs to be pulled out
* @apiParam {StringList} ip group member ip address(es)
* @apiParam {String[]} ip group member ip address(es)
* @apiParam {Boolean} batch if multiple group members needs to be pulled out, batch value must be explicitly set to true
* @apiSuccess {GroupServerStatusList} member statuses by group
*/
@ -313,6 +313,17 @@ public class OperationResource {
return memberOps(request, hh, groupId, ips, batch, false, TaskOpsType.PULL_MEMBER_OPS);
}
/**
* @api {get} /api/op/raise: [HC] Raise member(s)
* @apiDescription Raise group member action will take effect only on a single group. It will set `healthy` status to 'up' on the specified group.
* @apiName RaiseMember
* @apiGroup Operation
* @apiParam {Long} groupId id of the target group whose member needs to be pulled out
* @apiParam {String} groupName name of the target group whose member needs to be pulled out
* @apiParam {String[]} ip group member ip address(es)
* @apiParam {Boolean} batch if multiple group members needs to be pulled out, batch value must be explicitly set to true
* @apiSuccess {GroupServerStatusList} member statuses by group
*/
@GET
@Path("/raise")
@Authorize(name = "upDownMember")
@ -342,6 +353,17 @@ public class OperationResource {
}
}
/**
* @api {get} /api/op/fall: [HC] Fall member(s)
* @apiDescription Fall group member action will take effect only on a single group. It will set `healthy` status to 'down' on the specified group.
* @apiName FallMember
* @apiGroup Operation
* @apiParam {Long} groupId id of the target group whose member needs to be pulled out
* @apiParam {String} groupName name of the target group whose member needs to be pulled out
* @apiParam {String[]} ip group member ip address(es)
* @apiParam {Boolean} batch if multiple group members needs to be pulled out, batch value must be explicitly set to true
* @apiSuccess {GroupServerStatusList} member statuses by group
*/
@GET
@Path("/fall")
@Authorize(name = "upDownMember")