Skip to content

Commit 2c91fea

Browse files
liyanzhang505huiguangjun
authored andcommitted
Support vpcip config.
1 parent bcf7d48 commit 2c91fea

17 files changed

+1040
-4
lines changed

src/main/java/com/aliyun/oss/OSS.java

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3292,6 +3292,77 @@ public SetAsyncFetchTaskResult setAsyncFetchTask(SetAsyncFetchTaskRequest setAsy
32923292
public GetAsyncFetchTaskResult getAsyncFetchTask(GetAsyncFetchTaskRequest getAsyncFetchTaskRequest)
32933293
throws OSSException, ClientException;
32943294

3295+
/**
3296+
* Creates a vpcip tunnel {@link Vpcip}.
3297+
* @param createVpcipRequest
3298+
* A {@link CreateVpcipRequest} instance that specified the vpc information.
3299+
* @return A {@link CreateVpcipResult} instance.
3300+
* @throws OSSException
3301+
* OSS Server side exception.
3302+
* @throws ClientException
3303+
* OSS Client side exception.
3304+
*/
3305+
public CreateVpcipResult createVpcip(CreateVpcipRequest createVpcipRequest) throws OSSException, ClientException;
3306+
3307+
/**
3308+
* Returns all {@link Vpcip} instances of the current account.
3309+
*
3310+
* @return A list of {@link Vpcip} instances. If there's no Vpcips, the
3311+
* list will be empty (instead of null).
3312+
* @throws OSSException
3313+
* OSS Server side exception.
3314+
* @throws ClientException
3315+
* OSS Client side exception.
3316+
*/
3317+
public List<Vpcip> listVpcip() throws OSSException, ClientException;
3318+
3319+
/**
3320+
* Deletes the {@link Vpcip} instance.
3321+
*
3322+
* @param deleteVpcipRequest
3323+
* A {@link DeleteVpcipRequest} that specified the vpc policy.
3324+
* @throws OSSException
3325+
* OSS Server side exception.
3326+
* @throws ClientException
3327+
* OSS Client side exception.
3328+
*/
3329+
public void deleteVpcip(DeleteVpcipRequest deleteVpcipRequest) throws OSSException, ClientException;
3330+
3331+
/**
3332+
* Bind a Vpcip to a bucket.
3333+
* @param createBucketVpcipRequest
3334+
* A {@link CreateBucketVpcipRequest} instance that specified the bucketName and the {@link VpcPolicy} instance.
3335+
* @throws OSSException
3336+
* OSS Server side exception.
3337+
* @throws ClientException
3338+
* OSS Client side exception.
3339+
*/
3340+
public void createBucketVpcip(CreateBucketVpcipRequest createBucketVpcipRequest) throws OSSException, ClientException;
3341+
3342+
/**
3343+
* Returns all {@link VpcPolicy} instances of the Bucket.
3344+
*
3345+
* @return A list of {@link VpcPolicy} instances. If there's no list, the
3346+
* list will be empty (instead of null).
3347+
* @throws OSSException
3348+
* OSS Server side exception.
3349+
* @throws ClientException
3350+
* OSS Client side exception.
3351+
*/
3352+
public List<VpcPolicy> getBucketVpcip(GenericRequest genericRequest) throws OSSException, ClientException;
3353+
3354+
/**
3355+
* Deletes the {@link VpcPolicy} instance that has binded to the bucket.
3356+
*
3357+
* @param deleteBucketVpcipRequest
3358+
* A {@link DeleteBucketVpcipRequest} instance that has specified the bucketName and the {@link VpcPolicy} instance.
3359+
* @throws OSSException
3360+
* OSS Server side exception.
3361+
* @throws ClientException
3362+
* OSS Client side exception.
3363+
*/
3364+
public void deleteBucketVpcip(DeleteBucketVpcipRequest deleteBucketVpcipRequest) throws OSSException, ClientException;
3365+
32953366
/**
32963367
* Creates UDF
32973368
*

src/main/java/com/aliyun/oss/OSSClient.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,6 +1497,36 @@ public GetAsyncFetchTaskResult getAsyncFetchTask(GetAsyncFetchTaskRequest getAsy
14971497
return this.bucketOperation.getAsyncFetchTask(getAsyncFetchTaskRequest);
14981498
}
14991499

1500+
@Override
1501+
public CreateVpcipResult createVpcip(CreateVpcipRequest createVpcipRequest) throws OSSException, ClientException {
1502+
return bucketOperation.createVpcip(createVpcipRequest);
1503+
}
1504+
1505+
@Override
1506+
public List<Vpcip> listVpcip() throws OSSException, ClientException {
1507+
return bucketOperation.listVpcip();
1508+
}
1509+
1510+
@Override
1511+
public void deleteVpcip(DeleteVpcipRequest deleteVpcipRequest) throws OSSException, ClientException {
1512+
bucketOperation.deleteVpcip(deleteVpcipRequest);
1513+
}
1514+
1515+
@Override
1516+
public void createBucketVpcip(CreateBucketVpcipRequest createBucketVpcipRequest) throws OSSException, ClientException {
1517+
bucketOperation.createBucketVpcip(createBucketVpcipRequest);
1518+
}
1519+
1520+
@Override
1521+
public void deleteBucketVpcip(DeleteBucketVpcipRequest deleteBucketVpcipRequest) throws OSSException, ClientException {
1522+
bucketOperation.deleteBucketVpcip(deleteBucketVpcipRequest);
1523+
}
1524+
1525+
@Override
1526+
public List<VpcPolicy> getBucketVpcip(GenericRequest genericRequest) throws OSSException, ClientException {
1527+
return bucketOperation.getBucketVpcip(genericRequest);
1528+
}
1529+
15001530
@Override
15011531
public void createUdf(CreateUdfRequest createUdfRequest) throws OSSException, ClientException {
15021532
throw new ClientException("Not supported.");
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package com.aliyun.oss.common.comm;
20+
21+
import java.net.URI;
22+
23+
import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
24+
25+
public class HttpDeleteWithBody extends HttpEntityEnclosingRequestBase {
26+
27+
public final static String METHOD_NAME = "DELETE";
28+
29+
public HttpDeleteWithBody() {
30+
super();
31+
}
32+
33+
public HttpDeleteWithBody(final URI uri) {
34+
super();
35+
setURI(uri);
36+
}
37+
38+
/**
39+
* @throws IllegalArgumentException if the uri is invalid.
40+
*/
41+
public HttpDeleteWithBody(final String uri) {
42+
super();
43+
setURI(URI.create(uri));
44+
}
45+
46+
@Override
47+
public String getMethod() {
48+
return METHOD_NAME;
49+
}
50+
51+
}

src/main/java/com/aliyun/oss/common/comm/HttpRequestFactory.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,13 @@ public HttpRequestBase createHttpRequest(ServiceClient.Request request, Executio
6666
} else if (method == HttpMethod.GET) {
6767
httpRequest = new HttpGet(uri);
6868
} else if (method == HttpMethod.DELETE) {
69-
httpRequest = new HttpDelete(uri);
69+
if (request.getContent() != null) {
70+
HttpDeleteWithBody deleteMethod = new HttpDeleteWithBody(uri);
71+
deleteMethod.setEntity(new RepeatableInputStreamEntity(request));
72+
httpRequest = deleteMethod;
73+
} else {
74+
httpRequest = new HttpDelete(uri);
75+
}
7076
} else if (method == HttpMethod.HEAD) {
7177
httpRequest = new HttpHead(uri);
7278
} else if (method == HttpMethod.OPTIONS) {

src/main/java/com/aliyun/oss/common/parser/RequestMarshallers.java

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@
4343
import com.aliyun.oss.model.LifecycleRule.NoncurrentVersionStorageTransition;
4444
import com.aliyun.oss.model.LifecycleRule.NoncurrentVersionExpiration;
4545
import com.aliyun.oss.model.SetBucketCORSRequest.CORSRule;
46+
import com.aliyun.oss.model.CreateBucketVpcipRequest;
47+
import com.aliyun.oss.model.CreateVpcipRequest;
48+
import com.aliyun.oss.model.DeleteVpcipRequest;
4649

4750
/**
4851
* A collection of marshallers that marshall HTTP request into crossponding
@@ -87,6 +90,11 @@ public final class RequestMarshallers {
8790
public static final CreateSelectObjectMetadataRequestMarshaller createSelectObjectMetadataRequestMarshaller = new CreateSelectObjectMetadataRequestMarshaller();
8891
public static final SelectObjectRequestMarshaller selectObjectRequestMarshaller = new SelectObjectRequestMarshaller();
8992

93+
public static final CreateVpcipRequestMarshaller createVpcipRequestMarshaller = new CreateVpcipRequestMarshaller();
94+
public static final CreateBucketVpcipRequestMarshaller createBucketVpcipRequestMarshaller = new CreateBucketVpcipRequestMarshaller();
95+
public static final DeleteVpcipRequestMarshaller deleteVpcipRequestMarshaller = new DeleteVpcipRequestMarshaller();
96+
public static final DeleteBucketVpcipRequestMarshaller deleteBucketVpcipRequestMarshaller = new DeleteBucketVpcipRequestMarshaller();
97+
9098
public interface RequestMarshaller<R> extends Marshaller<FixedLengthInputStream, R> {
9199

92100
}
@@ -1228,6 +1236,108 @@ public byte[] marshall(ProcessObjectRequest request) {
12281236

12291237
}
12301238

1239+
public static final class CreateVpcipRequestMarshaller implements RequestMarshaller<CreateVpcipRequest> {
1240+
1241+
@Override
1242+
public FixedLengthInputStream marshall(CreateVpcipRequest request) {
1243+
StringBuffer xmlBody = new StringBuffer();
1244+
1245+
if (request.getRegion() != null || request.getVSwitchId() != null) {
1246+
xmlBody.append("<CreateVpcip>");
1247+
if (request.getRegion() != null) {
1248+
xmlBody.append("<Region>" + request.getRegion() + "</Region>");
1249+
}
1250+
if (request.getVSwitchId() != null) {
1251+
xmlBody.append("<VSwitchId>" + request.getVSwitchId() + "</VSwitchId>");
1252+
}
1253+
if(request.getLabel() != null){
1254+
xmlBody.append("<Label>" + request.getLabel() + "</Label>");
1255+
}
1256+
xmlBody.append("</CreateVpcip>");
1257+
}
1258+
1259+
return stringMarshaller.marshall(xmlBody.toString());
1260+
}
1261+
1262+
}
1263+
1264+
public static final class DeleteVpcipRequestMarshaller implements RequestMarshaller<DeleteVpcipRequest> {
1265+
1266+
@Override
1267+
public FixedLengthInputStream marshall(DeleteVpcipRequest deleteVpcipRequest) {
1268+
StringBuffer xmlBody = new StringBuffer();
1269+
VpcPolicy request = deleteVpcipRequest.getVpcPolicy();
1270+
1271+
if (request.getRegion() != null || request.getVpcId() != null || request.getVip() != null) {
1272+
xmlBody.append("<DeleteVpcip>");
1273+
if (request.getRegion() != null) {
1274+
xmlBody.append("<Region>" + request.getRegion() + "</Region>");
1275+
}
1276+
if (request.getVpcId() != null) {
1277+
xmlBody.append("<VpcId>" + request.getVpcId() + "</VpcId>");
1278+
}
1279+
if (request.getVip() != null) {
1280+
xmlBody.append("<Vip>" + request.getVip() + "</Vip>");
1281+
}
1282+
xmlBody.append("</DeleteVpcip>");
1283+
}
1284+
1285+
return stringMarshaller.marshall(xmlBody.toString());
1286+
}
1287+
1288+
}
1289+
1290+
public static final class DeleteBucketVpcipRequestMarshaller implements RequestMarshaller<VpcPolicy> {
1291+
1292+
@Override
1293+
public FixedLengthInputStream marshall(VpcPolicy request) {
1294+
StringBuffer xmlBody = new StringBuffer();
1295+
1296+
if (request.getRegion() != null || request.getVpcId() != null || request.getVip() != null) {
1297+
xmlBody.append("<DeleteBucketVpcPolicy>");
1298+
if (request.getRegion() != null) {
1299+
xmlBody.append("<Region>" + request.getRegion() + "</Region>");
1300+
}
1301+
if (request.getVpcId() != null) {
1302+
xmlBody.append("<VpcId>" + request.getVpcId() + "</VpcId>");
1303+
}
1304+
if (request.getVip() != null) {
1305+
xmlBody.append("<Vip>" + request.getVip() + "</Vip>");
1306+
}
1307+
xmlBody.append("</DeleteBucketVpcPolicy>");
1308+
}
1309+
1310+
return stringMarshaller.marshall(xmlBody.toString());
1311+
}
1312+
1313+
}
1314+
1315+
public static final class CreateBucketVpcipRequestMarshaller implements RequestMarshaller<CreateBucketVpcipRequest> {
1316+
1317+
@Override
1318+
public FixedLengthInputStream marshall(CreateBucketVpcipRequest bucketVpcPolicyRequest) {
1319+
StringBuffer xmlBody = new StringBuffer();
1320+
VpcPolicy request = bucketVpcPolicyRequest.getVpcPolicy();
1321+
1322+
if (request.getRegion() != null || request.getVpcId() != null || request.getVip() != null) {
1323+
xmlBody.append("<CreateBucketVpcPolicy>");
1324+
if (request.getRegion() != null) {
1325+
xmlBody.append("<Region>" + request.getRegion() + "</Region>");
1326+
}
1327+
if (request.getVpcId() != null) {
1328+
xmlBody.append("<VpcId>" + request.getVpcId() + "</VpcId>");
1329+
}
1330+
if (request.getVip() != null) {
1331+
xmlBody.append("<Vip>" + request.getVip() + "</Vip>");
1332+
}
1333+
xmlBody.append("</CreateBucketVpcPolicy>");
1334+
}
1335+
1336+
return stringMarshaller.marshall(xmlBody.toString());
1337+
}
1338+
1339+
}
1340+
12311341
private static enum EscapedChar {
12321342
// "\r"
12331343
RETURN("&#x000D;"),

0 commit comments

Comments
 (0)