forked from sendgrid/sendgrid-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathips.java
More file actions
127 lines (108 loc) · 3.57 KB
/
ips.java
File metadata and controls
127 lines (108 loc) · 3.57 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.sendgrid.*;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
public class CommonExample {
protected SendGrid sg;
protected Request request;
protected static void init() {
this.sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
this.request = new Request();
}
}
//////////////////////////////////////////////////////////////////
// Create a reverse DNS record
// POST /whitelabel/ips
public class Example extends CommonExample {
public static void main(String[] args) throws IOException {
try {
init();
request.setMethod(Method.POST);
request.setEndpoint("whitelabel/ips");
request.setBody("{\"ip\":\"192.168.1.1\",\"domain\":\"example.com\",\"subdomain\":\"email\"}");
Response response = sg.api(request);
System.out.println(response.getStatusCode());
System.out.println(response.getBody());
System.out.println(response.getHeaders());
} catch (IOException ex) {
throw ex;
}
}
}
//////////////////////////////////////////////////////////////////
// Retrieve all reverse DNS records
// GET /whitelabel/ips
public class Example extends CommonExample {
public static void main(String[] args) throws IOException {
try {
init();
request.setMethod(Method.GET);
request.setEndpoint("whitelabel/ips");
request.addQueryParam("ip", "test_string");
request.addQueryParam("limit", "1");
request.addQueryParam("offset", "1");
Response response = sg.api(request);
System.out.println(response.getStatusCode());
System.out.println(response.getBody());
System.out.println(response.getHeaders());
} catch (IOException ex) {
throw ex;
}
}
}
//////////////////////////////////////////////////////////////////
// Retrieve a reverse DNS record
// GET /whitelabel/ips/{id}
public class Example extends CommonExample {
public static void main(String[] args) throws IOException {
try {
init();
request.setMethod(Method.GET);
request.setEndpoint("whitelabel/ips/{id}");
Response response = sg.api(request);
System.out.println(response.getStatusCode());
System.out.println(response.getBody());
System.out.println(response.getHeaders());
} catch (IOException ex) {
throw ex;
}
}
}
//////////////////////////////////////////////////////////////////
// Delete a reverse DNS record
// DELETE /whitelabel/ips/{id}
public class Example extends CommonExample {
public static void main(String[] args) throws IOException {
try {
init();
request.setMethod(Method.DELETE);
request.setEndpoint("whitelabel/ips/{id}");
Response response = sg.api(request);
System.out.println(response.getStatusCode());
System.out.println(response.getBody());
System.out.println(response.getHeaders());
} catch (IOException ex) {
throw ex;
}
}
}
//////////////////////////////////////////////////////////////////
// Validate a reverse DNS record
// POST /whitelabel/ips/{id}/validate
public class Example extends CommonExample {
public static void main(String[] args) throws IOException {
try {
init();
request.setMethod(Method.POST);
request.setEndpoint("whitelabel/ips/{id}/validate");
Response response = sg.api(request);
System.out.println(response.getStatusCode());
System.out.println(response.getBody());
System.out.println(response.getHeaders());
} catch (IOException ex) {
throw ex;
}
}
}