赞
踩
- import com.huaweicloud.sdk.core.auth.ICredential;
- import com.huaweicloud.sdk.core.auth.BasicCredentials;
- import com.huaweicloud.sdk.core.exception.ConnectionException;
- import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
- import com.huaweicloud.sdk.core.exception.ServiceResponseException;
- import com.huaweicloud.sdk.sfsturbo.v1.region.SFSTurboRegion;
- import com.huaweicloud.sdk.sfsturbo.v1.*;
- import com.huaweicloud.sdk.sfsturbo.v1.model.*;
-
-
- /**
- * TODO 删除NFS文件系统目录,高危险操作,务必谨慎执行!!!
- * TODO 删除NFS文件系统目录,高危险操作,务必谨慎执行!!!
- * TODO 删除NFS文件系统目录,高危险操作,务必谨慎执行!!!
- *
- *
- * @author XHH
- */
- public class DeleteFsDirSolution {
-
- public static void main(String[] args) {
-
- String ak = "<Your AK>";
- String sk = "<Your SK>";
-
- String pathStr = "<Your Path>";
- String shareId = "<文件系统ID>";
-
- // 删除
- delFsDir(ak, sk, shareId, pathStr);
- }
- private static void delFsDir(String ak, String sk, String shareId, String pathStr) {
-
- ICredential auth = new BasicCredentials().withAk(ak).withSk(sk);
- SFSTurboClient client = SFSTurboClient.newBuilder()
- .withCredential(auth)
- .withRegion(SFSTurboRegion.valueOf("cn-southwest-2"))
- .build();
- DeleteFsDirRequest request = new DeleteFsDirRequest();
- request.withShareId(shareId);
- DeleteFsDirRequestBody body = new DeleteFsDirRequestBody();
- body.withPath(pathStr);
- request.withBody(body);
-
- System.out.println("删除路径: " +pathStr);
- try {
- DeleteFsDirResponse response = client.deleteFsDir(request);
- System.out.println("response ===> " + response.toString());
- } catch (ConnectionException | RequestTimeoutException e) {
- e.printStackTrace();
- } catch (ServiceResponseException e) {
- e.printStackTrace();
- System.out.println("删除路径: " +pathStr+ " --> HttpStatusCode:" + e.getHttpStatusCode() + " --> RequestId:" + e.getRequestId() + " --> ErrorMsg:" + e.getErrorMsg());
- }
-
- }
-
-
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。