This repository has been archived by the owner on Nov 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 42
/
PTR.java
60 lines (48 loc) · 1.92 KB
/
PTR.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package com.huawei.openstack.sample;
import com.huawei.openstack4j.api.Builders;
import com.huawei.openstack4j.api.OSClient;
import com.huawei.openstack4j.model.common.Identifier;
import com.huawei.openstack4j.openstack.OSFactory;
import com.huawei.openstack4j.openstack.dns.v2.domain.DesignatePTR;
import com.huawei.openstack4j.openstack.dns.v2.domain.DesignatePTR.DesignatePTRBuilder;
import java.util.HashMap;
import java.util.Map;
public class PTR {
private static OSClient.OSClientV3 os;
public static void main(String[] args) {
os = OSFactory.builderV3()
.endpoint(Constants.AUTH_URL)
.credentials(Constants.USERNAME, Constants.PASSWORD, Identifier.byId(Constants.USERDOMAINID))
.scopeToProject(Identifier.byId(Constants.PROJECT_ID))
.authenticate();
//create ptr record
setup();
//list ptr record
list();
//list ptr record by filiter
listByFliter();
//list ptr record by filiter
get();
//restore ptr record
restore();
}
private static void setup(){
DesignatePTRBuilder builder = Builders.ptr();
DesignatePTR ptr = (DesignatePTR) builder.ptrdname(Constants.PTRNAME).floatingIpId(Constants.FLOATINGIPID).description(Constants.PTR_DESCRIPTION).ttl(Constants.TTL).region(Constants.REGION).build();
DesignatePTR result = os.dns().ptrs().setup(ptr);
}
private static void restore(){
os.dns().ptrs().restore(Constants.REGION,Constants.FLOATINGIPID);
}
private static void get() {
os.dns().ptrs().get(Constants.REGION, Constants.FLOATINGIPID);
}
private static void listByFliter() {
Map<String,Object> fliters = new HashMap<>();
fliters.put(Constants.LIMIT, Constants.PTR_LIMIT_VALUE);
os.dns().ptrs().list(fliters);
}
private static void list() {
os.dns().ptrs().list();
}
}