class NamespaceController {

	@Autowired
	private CommonPersistService commonPersistService;

	@Autowired
	private NamespaceOperationService namespaceOperationService;

	private final Pattern namespaceIdCheckPattern = Pattern.compile("^[\\w-]+");

	private static final int NAMESPACE_ID_MAX_LENGTH = 128;

	/**
	 * Get namespace list.
	 * @return namespace list
	 */
	@GetMapping
	public RestResult<List<Namespace>> getNamespaces() {
		return RestResultUtils.success(namespaceOperationService.getNamespaceList());
	}

	/**
	 * get namespace all info by namespace id.
	 * @param namespaceId namespaceId
	 * @return namespace all info
	 */
	@GetMapping(params = "show=all")
	public NamespaceAllInfo getNamespace(@RequestParam("namespaceId") String namespaceId) throws NacosException {
		return namespaceOperationService.getNamespace(namespaceId);
	}

	/**
	 * create namespace.
	 * @param namespaceName namespace Name
	 * @param namespaceDesc namespace Desc
	 * @return whether create ok
	 */
	@PostMapping
	@Secured(resource = AuthConstants.CONSOLE_RESOURCE_NAME_PREFIX + "namespaces", action = ActionTypes.WRITE)
	public Boolean createNamespace(@RequestParam("customNamespaceId") String namespaceId,
			@RequestParam("namespaceName") String namespaceName,
			@RequestParam(value = "namespaceDesc", required = false) String namespaceDesc) {<FILL_FUNCTION_BODY>}

	/**
	 * check namespaceId exist.
	 * @param namespaceId namespace id
	 * @return true if exist, otherwise false
	 */
	@GetMapping(params = "checkNamespaceIdExist=true")
	public Boolean checkNamespaceIdExist(@RequestParam("customNamespaceId") String namespaceId) {
		if (StringUtils.isBlank(namespaceId)) {
			return false;
		}
		return (commonPersistService.tenantInfoCountByTenantId(namespaceId) > 0);
	}

	/**
	 * edit namespace.
	 * @param namespace namespace
	 * @param namespaceShowName namespace ShowName
	 * @param namespaceDesc namespace Desc
	 * @return whether edit ok
	 */
	@PutMapping
	@Secured(resource = AuthConstants.CONSOLE_RESOURCE_NAME_PREFIX + "namespaces", action = ActionTypes.WRITE)
	public Boolean editNamespace(@RequestParam("namespace") String namespace,
			@RequestParam("namespaceShowName") String namespaceShowName,
			@RequestParam(value = "namespaceDesc", required = false) String namespaceDesc) {
		return namespaceOperationService.editNamespace(namespace, namespaceShowName, namespaceDesc);
	}

	/**
	 * del namespace by id.
	 * @param namespaceId namespace Id
	 * @return whether del ok
	 */
	@DeleteMapping
	@Secured(resource = AuthConstants.CONSOLE_RESOURCE_NAME_PREFIX + "namespaces", action = ActionTypes.WRITE)
	public Boolean deleteNamespace(@RequestParam("namespaceId") String namespaceId) {
		return namespaceOperationService.removeNamespace(namespaceId);
	}

}

		if (StringUtils.isBlank(namespaceId)) {
			namespaceId = UUID.randomUUID().toString();
		}
		else {
			namespaceId = namespaceId.trim();
			if (!namespaceIdCheckPattern.matcher(namespaceId).matches()) {
				return false;
			}
			if (namespaceId.length() > NAMESPACE_ID_MAX_LENGTH) {
				return false;
			}
		}
		try {
			return namespaceOperationService.createNamespace(namespaceId, namespaceName, namespaceDesc);
		}
		catch (NacosException e) {
			return false;
		}
	
<no_super_class>