28
28
import com .alibaba .nacos .config .server .controller .parameters .SameNamespaceCloneConfigBean ;
29
29
import com .alibaba .nacos .config .server .model .ConfigAllInfo ;
30
30
import com .alibaba .nacos .config .server .model .ConfigInfo ;
31
+ import com .alibaba .nacos .config .server .model .ConfigInfo4Beta ;
31
32
import com .alibaba .nacos .config .server .model .ConfigRequestInfo ;
32
33
import com .alibaba .nacos .config .server .model .GroupkeyListenserStatus ;
33
34
import com .alibaba .nacos .config .server .model .SameConfigPolicy ;
41
42
import com .alibaba .nacos .persistence .model .Page ;
42
43
import com .alibaba .nacos .plugin .auth .constant .ActionTypes ;
43
44
import com .alibaba .nacos .plugin .auth .constant .SignType ;
45
+ import org .springframework .http .HttpStatus ;
44
46
import org .springframework .http .ResponseEntity ;
45
47
import org .springframework .ui .ModelMap ;
46
48
import org .springframework .web .bind .annotation .DeleteMapping ;
60
62
import java .util .List ;
61
63
import java .util .Map ;
62
64
65
+ import static com .alibaba .nacos .config .server .utils .RequestUtil .getRemoteIp ;
66
+
63
67
/**
64
68
* Controller for handling HTTP requests related to configuration operations.
65
69
*
@@ -74,7 +78,6 @@ public class ConsoleConfigController {
74
78
75
79
public ConsoleConfigController (ConfigProxy configProxy ) {
76
80
this .configProxy = configProxy ;
77
-
78
81
}
79
82
80
83
/**
@@ -401,15 +404,11 @@ public Result<Map<String, Object>> importAndPublishConfig(HttpServletRequest req
401
404
@ Secured (action = ActionTypes .WRITE , signType = SignType .CONFIG , apiType = ApiType .CONSOLE_API )
402
405
public Result <Map <String , Object >> cloneConfig (HttpServletRequest request ,
403
406
@ RequestParam (value = "src_user" , required = false ) String srcUser ,
404
- @ RequestParam (value = "namespaceId " ) String namespaceId ,
407
+ @ RequestParam (value = "targetNamespaceId " ) String namespaceId ,
405
408
@ RequestBody List <SameNamespaceCloneConfigBean > configBeansList ,
406
409
@ RequestParam (value = "policy" , defaultValue = "ABORT" ) SameConfigPolicy policy ) throws NacosException {
407
-
408
410
configBeansList .removeAll (Collections .singleton (null ));
409
- // check namespaceId
410
- ParamUtils .checkTenantV2 (namespaceId );
411
411
namespaceId = NamespaceUtil .processNamespaceParameter (namespaceId );
412
-
413
412
if (StringUtils .isBlank (srcUser )) {
414
413
srcUser = RequestUtil .getSrcUserName (request );
415
414
}
@@ -419,6 +418,49 @@ public Result<Map<String, Object>> cloneConfig(HttpServletRequest request,
419
418
return configProxy .cloneConfig (srcUser , namespaceId , configBeansList , policy , srcIp , requestIpApp );
420
419
}
421
420
421
+ /**
422
+ * Execute to remove beta operation.
423
+ *
424
+ * @param httpServletRequest HTTP request containing client details.
425
+ * @param dataId dataId string value.
426
+ * @param group group string value.
427
+ * @param namespaceId tenant string value.
428
+ * @return Result indicating the outcome of the operation.
429
+ * @throws NacosException If a Nacos-specific error occurs.
430
+ */
431
+ @ DeleteMapping ("/beta" )
432
+ @ Secured (action = ActionTypes .WRITE , signType = SignType .CONFIG )
433
+ public Result <Boolean > stopBeta (HttpServletRequest httpServletRequest ,
434
+ @ RequestParam (value = "dataId" ) String dataId , @ RequestParam (value = "group" ) String group ,
435
+ @ RequestParam (value = "namespaceId" , required = false , defaultValue = StringUtils .EMPTY ) String namespaceId )
436
+ throws NacosException {
437
+ String remoteIp = getRemoteIp (httpServletRequest );
438
+ String requestIpApp = RequestUtil .getAppName (httpServletRequest );
439
+ boolean success = configProxy .removeBetaConfig (dataId , group , namespaceId , remoteIp , requestIpApp );
440
+ if (!success ) {
441
+ return Result .failure (HttpStatus .INTERNAL_SERVER_ERROR .value (), HttpStatus .INTERNAL_SERVER_ERROR .getReasonPhrase (), false );
442
+ }
443
+ return Result .success (true );
444
+ }
445
+
446
+ /**
447
+ * Execute to query beta operation.
448
+ *
449
+ * @param dataId dataId string value.
450
+ * @param group group string value.
451
+ * @param namespaceId namespaceId string value.
452
+ * @return Result containing the ConfigInfo4Beta details.
453
+ * @throws NacosException If a Nacos-specific error occurs.
454
+ */
455
+ @ GetMapping ("/beta" )
456
+ @ Secured (action = ActionTypes .READ , signType = SignType .CONFIG )
457
+ public Result <ConfigInfo4Beta > queryBeta (@ RequestParam (value = "dataId" ) String dataId ,
458
+ @ RequestParam (value = "group" ) String group ,
459
+ @ RequestParam (value = "namespaceId" , required = false , defaultValue = StringUtils .EMPTY ) String namespaceId )
460
+ throws NacosException {
461
+ return configProxy .queryBetaConfig (dataId , group , namespaceId );
462
+ }
463
+
422
464
}
423
465
424
466
0 commit comments