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

[ISSUE#12988] Develop naming admin api #13019

Merged
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 @@ -45,6 +45,7 @@
*
* @author nkorange
*/
@Deprecated
@RestController
@RequestMapping(UtilsAndCommons.NACOS_NAMING_CONTEXT + UtilsAndCommons.NACOS_NAMING_CATALOG_CONTEXT)
@ExtractorManager.Extractor(httpExtractor = NamingDefaultHttpParamExtractor.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
*
* @author nkorange
*/
@Deprecated
@RestController
@RequestMapping(UtilsAndCommons.NACOS_NAMING_CONTEXT + UtilsAndCommons.NACOS_NAMING_CLUSTER_CONTEXT)
@ExtractorManager.Extractor(httpExtractor = NamingDefaultHttpParamExtractor.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
* @author nanamikon
* @since 0.8.0
*/
@Deprecated
@RestController("namingHealthController")
@RequestMapping(UtilsAndCommons.NACOS_NAMING_CONTEXT + UtilsAndCommons.NACOS_NAMING_HEALTH_CONTEXT)
@ExtractorManager.Extractor(httpExtractor = NamingDefaultHttpParamExtractor.class)
Expand Down Expand Up @@ -94,7 +95,7 @@ public ResponseEntity server() {
@CanDistro
@PutMapping(value = {"", "/instance"})
@Secured(action = ActionTypes.WRITE)
@Compatibility(apiType = ApiType.ADMIN_API)
@Compatibility(apiType = ApiType.ADMIN_API, alternatives = "PUT ${contextPath:nacos}/v3/admin/health/instance")
public ResponseEntity update(HttpServletRequest request) throws NacosException {
String healthyString = WebUtils.optional(request, HEALTHY_KEY, StringUtils.EMPTY);
if (StringUtils.isBlank(healthyString)) {
Expand All @@ -121,7 +122,7 @@ public ResponseEntity update(HttpServletRequest request) throws NacosException {
* @return health checkers map
*/
@GetMapping("/checkers")
@Compatibility(apiType = ApiType.ADMIN_API)
@Compatibility(apiType = ApiType.ADMIN_API, alternatives = "GET ${contextPath:nacos}/v3/admin/health/checkers")
public ResponseEntity checkers() {
List<Class<? extends AbstractHealthChecker>> classes = HealthCheckType.getLoadedHealthCheckerClasses();
Map<String, AbstractHealthChecker> checkerMap = new HashMap<>(8);
Expand Down
MatthewAden marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
*
* @author nkorange
*/
@Deprecated
@RestController
@RequestMapping(UtilsAndCommons.NACOS_NAMING_CONTEXT + UtilsAndCommons.NACOS_NAMING_INSTANCE_CONTEXT)
@ExtractorManager.Extractor(httpExtractor = NamingDefaultHttpParamExtractor.class)
Expand Down Expand Up @@ -112,7 +113,7 @@ public InstanceController() {
@PostMapping
@TpsControl(pointName = "NamingInstanceRegister", name = "HttpNamingInstanceRegister")
@Secured(action = ActionTypes.WRITE)
@Compatibility(apiType = ApiType.OPEN_API)
@Compatibility(apiType = ApiType.OPEN_API, alternatives = "POST ${contextPath:nacos}/v3/admin/ns/instance")
public String register(HttpServletRequest request) throws Exception {

final String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID,
Expand Down Expand Up @@ -142,7 +143,7 @@ public String register(HttpServletRequest request) throws Exception {
@DeleteMapping
@TpsControl(pointName = "NamingInstanceDeregister", name = "HttpNamingInstanceDeregister")
@Secured(action = ActionTypes.WRITE)
@Compatibility(apiType = ApiType.OPEN_API)
@Compatibility(apiType = ApiType.OPEN_API, alternatives = "DELETE ${contextPath:nacos}/v3/admin/ns/instance")
public String deregister(HttpServletRequest request) throws Exception {
Instance instance = HttpRequestInstanceBuilder.newBuilder()
.setDefaultInstanceEphemeral(switchDomain.isDefaultInstanceEphemeral()).setRequest(request).build();
Expand Down Expand Up @@ -197,7 +198,7 @@ public String update(HttpServletRequest request) throws Exception {
@TpsControl(pointName = "NamingInstanceMetadataUpdate", name = "HttpNamingInstanceMetadataBatchUpdate")
@Secured(action = ActionTypes.WRITE)
@ExtractorManager.Extractor(httpExtractor = NamingInstanceMetadataBatchHttpParamExtractor.class)
@Compatibility(apiType = ApiType.ADMIN_API)
@Compatibility(apiType = ApiType.ADMIN_API, alternatives = "PUT ${contextPath:nacos}/v3/admin/ns/instance/metadata/batch")
public ObjectNode batchUpdateInstanceMetadata(HttpServletRequest request) throws Exception {
final String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID,
Constants.DEFAULT_NAMESPACE_ID);
Expand Down Expand Up @@ -233,7 +234,7 @@ public ObjectNode batchUpdateInstanceMetadata(HttpServletRequest request) throws
@TpsControl(pointName = "NamingInstanceMetadataUpdate", name = "HttpNamingInstanceMetadataBatchUpdate")
@Secured(action = ActionTypes.WRITE)
@ExtractorManager.Extractor(httpExtractor = NamingInstanceMetadataBatchHttpParamExtractor.class)
@Compatibility(apiType = ApiType.ADMIN_API)
@Compatibility(apiType = ApiType.ADMIN_API, alternatives = "DELETE ${contextPath:nacos}/v3/admin/ns/instance/metadata/batch")
public ObjectNode batchDeleteInstanceMetadata(HttpServletRequest request) throws Exception {
final String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID,
Constants.DEFAULT_NAMESPACE_ID);
Expand Down Expand Up @@ -288,7 +289,7 @@ private List<Instance> parseBatchInstances(String instances) {
@CanDistro
@PatchMapping
@Secured(action = ActionTypes.WRITE)
@Compatibility(apiType = ApiType.ADMIN_API)
@Compatibility(apiType = ApiType.ADMIN_API, alternatives = "PUT ${contextPath:nacos}/v3/admin/ns/instance/partial")
public String patch(HttpServletRequest request) throws Exception {
String serviceName = WebUtils.required(request, CommonParams.SERVICE_NAME);
NamingUtils.checkServiceNameFormat(serviceName);
Expand Down Expand Up @@ -331,7 +332,7 @@ public String patch(HttpServletRequest request) throws Exception {
@TpsControl(pointName = "NamingServiceSubscribe", name = "HttpNamingServiceSubscribe")
@Secured(action = ActionTypes.READ)
@ExtractorManager.Extractor(httpExtractor = NamingInstanceListHttpParamExtractor.class)
@Compatibility(apiType = ApiType.OPEN_API)
@Compatibility(apiType = ApiType.OPEN_API, alternatives = "GET ${contextPath:nacos}/v3/admin/ns/instance/list")
public Object list(HttpServletRequest request) throws Exception {

String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID, Constants.DEFAULT_NAMESPACE_ID);
Expand Down Expand Up @@ -360,7 +361,7 @@ public Object list(HttpServletRequest request) throws Exception {
@GetMapping
@TpsControl(pointName = "NamingInstanceQuery", name = "HttpNamingInstanceQuery")
@Secured(action = ActionTypes.READ)
@Compatibility(apiType = ApiType.OPEN_API)
@Compatibility(apiType = ApiType.OPEN_API, alternatives = "GET ${contextPath:nacos}/v3/admin/ns/instance")
public ObjectNode detail(HttpServletRequest request) throws Exception {

String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID, Constants.DEFAULT_NAMESPACE_ID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
*
* @author nkorange
*/
@Deprecated
@RestController
@RequestMapping({UtilsAndCommons.NACOS_NAMING_CONTEXT + UtilsAndCommons.NACOS_NAMING_OPERATOR_CONTEXT,
UtilsAndCommons.NACOS_NAMING_CONTEXT + "/ops"})
Expand Down Expand Up @@ -120,7 +121,7 @@ public ObjectNode pushState(@RequestParam(required = false) boolean detail,
* @return switchDomain
*/
@GetMapping("/switches")
@Compatibility(apiType = ApiType.ADMIN_API)
@Compatibility(apiType = ApiType.ADMIN_API, alternatives = "GET ${contextPath:nacos}/v3/admin/ns/ops/switches")
public SwitchDomain switches(HttpServletRequest request) {
return switchDomain;
}
Expand All @@ -136,7 +137,7 @@ public SwitchDomain switches(HttpServletRequest request) {
*/
@Secured(resource = "naming/switches", action = ActionTypes.WRITE)
@PutMapping("/switches")
@Compatibility(apiType = ApiType.ADMIN_API)
@Compatibility(apiType = ApiType.ADMIN_API, alternatives = "PUT ${contextPath:nacos}/v3/admin/ns/ops/switches")
public String updateSwitch(@RequestParam(required = false) boolean debug, @RequestParam String entry,
@RequestParam String value) throws Exception {

Expand All @@ -152,7 +153,7 @@ public String updateSwitch(@RequestParam(required = false) boolean debug, @Reque
* @return metrics information
*/
@GetMapping("/metrics")
@Compatibility(apiType = ApiType.OPEN_API)
@Compatibility(apiType = ApiType.ADMIN_API, alternatives = "GET ${contextPath:nacos}/v3/admin/ns/ops/metrics")
public ObjectNode metrics(HttpServletRequest request) {
boolean onlyStatus = Boolean.parseBoolean(WebUtils.optional(request, "onlyStatus", "true"));
ObjectNode result = JacksonUtils.createEmptyJsonNode();
Expand Down Expand Up @@ -198,7 +199,7 @@ public ObjectNode metrics(HttpServletRequest request) {
}

@GetMapping("/distro/client")
@Compatibility(apiType = ApiType.ADMIN_API)
@Compatibility(apiType = ApiType.ADMIN_API, alternatives = "GET ${contextPath:nacos}/v3/admin/ns/client/distro")
public ObjectNode getResponsibleServer4Client(@RequestParam String ip, @RequestParam String port) {
ObjectNode result = JacksonUtils.createEmptyJsonNode();
String tag = ip + InternetAddressUtil.IP_PORT_SPLITER + port;
Expand All @@ -207,7 +208,7 @@ public ObjectNode getResponsibleServer4Client(@RequestParam String ip, @RequestP
}

@PutMapping("/log")
@Compatibility(apiType = ApiType.ADMIN_API)
@Compatibility(apiType = ApiType.ADMIN_API, alternatives = "PUT ${contextPath:nacos}/v3/admin/ns/ops/log")
public String setLogLevel(@RequestParam String logName, @RequestParam String logLevel) {
Loggers.setLogLevel(logName, logLevel);
return "ok";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
*
* @author nkorange
*/
@Deprecated
@RestController
@RequestMapping(UtilsAndCommons.NACOS_NAMING_CONTEXT + UtilsAndCommons.NACOS_NAMING_SERVICE_CONTEXT)
@ExtractorManager.Extractor(httpExtractor = NamingDefaultHttpParamExtractor.class)
Expand Down Expand Up @@ -151,7 +152,7 @@ public String remove(@RequestParam(defaultValue = Constants.DEFAULT_NAMESPACE_ID
@GetMapping
@TpsControl(pointName = "NamingServiceQuery", name = "HttpNamingServiceQuery")
@Secured(action = ActionTypes.READ)
@Compatibility(apiType = ApiType.OPEN_API)
@Compatibility(apiType = ApiType.OPEN_API, alternatives = "GET ${contextPath:nacos}/v3/admin/ns/service")
public ObjectNode detail(@RequestParam(defaultValue = Constants.DEFAULT_NAMESPACE_ID) String namespaceId,
@RequestParam String serviceName) throws NacosException {
return getServiceOperator().queryService(namespaceId, serviceName);
Expand All @@ -167,7 +168,7 @@ public ObjectNode detail(@RequestParam(defaultValue = Constants.DEFAULT_NAMESPAC
@GetMapping("/list")
@TpsControl(pointName = "NamingServiceListQuery", name = "HttpNamingServiceListQuery")
@Secured(action = ActionTypes.READ)
@Compatibility(apiType = ApiType.OPEN_API)
@Compatibility(apiType = ApiType.OPEN_API, alternatives = "GET ${contextPath:nacos}/v3/admin/ns/service/list")
public ObjectNode list(HttpServletRequest request) throws Exception {
final int pageNo = NumberUtils.toInt(WebUtils.required(request, "pageNo"));
final int pageSize = NumberUtils.toInt(WebUtils.required(request, "pageSize"));
Expand Down Expand Up @@ -220,7 +221,7 @@ public String update(HttpServletRequest request) throws Exception {
*/
@RequestMapping("/names")
@Secured(action = ActionTypes.READ)
@Compatibility(apiType = ApiType.ADMIN_API)
@Compatibility(apiType = ApiType.ADMIN_API, alternatives = "GET ${contextPath:nacos}/v3/admin/ns/service/names")
public ObjectNode searchService(@RequestParam(defaultValue = StringUtils.EMPTY) String namespaceId,
@RequestParam(defaultValue = StringUtils.EMPTY) String expr) throws NacosException {
Map<String, Collection<String>> serviceNameMap = new HashMap<>(16);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
* @author Weizhan▪Yun
* @date 2023/1/14 19:54
*/
@Deprecated
@RestController
@RequestMapping(UtilsAndCommons.DEFAULT_NACOS_NAMING_CONTEXT_V2 + UtilsAndCommons.NACOS_NAMING_CATALOG_CONTEXT)
@ExtractorManager.Extractor(httpExtractor = NamingDefaultHttpParamExtractor.class)
Expand Down
Loading