-
Notifications
You must be signed in to change notification settings - Fork 409
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #358 from derjayjay/issue-335
Fixing similar code issue in examples/ips/ips.java
- Loading branch information
Showing
16 changed files
with
464 additions
and
326 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
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; | ||
|
||
|
||
////////////////////////////////////////////////////////////////// | ||
// Add an IP address to a pool | ||
// POST /ips/pools/{pool_name}/ips | ||
|
||
|
||
public class AddIPToPool { | ||
public static void main(String[] args) throws IOException { | ||
try { | ||
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY")); | ||
Request request = new Request(); | ||
request.setMethod(Method.POST); | ||
request.setEndpoint("ips/pools/{pool_name}/ips"); | ||
request.setBody("{\"ip\":\"0.0.0.0\"}"); | ||
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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
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; | ||
|
||
|
||
|
||
////////////////////////////////////////////////////////////////// | ||
// Add an IP to warmup | ||
// POST /ips/warmup | ||
|
||
|
||
public class AddIPToWarmup { | ||
public static void main(String[] args) throws IOException { | ||
try { | ||
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY")); | ||
Request request = new Request(); | ||
request.setMethod(Method.POST); | ||
request.setEndpoint("ips/warmup"); | ||
request.setBody("{\"ip\":\"0.0.0.0\"}"); | ||
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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
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; | ||
|
||
|
||
////////////////////////////////////////////////////////////////// | ||
// Create an IP pool. | ||
// POST /ips/pools | ||
|
||
|
||
public class CreateIPPool { | ||
public static void main(String[] args) throws IOException { | ||
try { | ||
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY")); | ||
Request request = new Request(); | ||
request.setMethod(Method.POST); | ||
request.setEndpoint("ips/pools"); | ||
request.setBody("{\"name\":\"marketing\"}"); | ||
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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
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; | ||
|
||
|
||
////////////////////////////////////////////////////////////////// | ||
// Delete an IP pool. | ||
// DELETE /ips/pools/{pool_name} | ||
|
||
|
||
public class DeletePool { | ||
public static void main(String[] args) throws IOException { | ||
try { | ||
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY")); | ||
Request request = new Request(); | ||
request.setMethod(Method.DELETE); | ||
request.setEndpoint("ips/pools/{pool_name}"); | ||
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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
 | ||
|
||
This folder contains various examples on using the IPs endpoint of SendGrid with Java: | ||
|
||
* [Retrieve all IP addresses (GET /ips)](RetrieveAllIPs.java) | ||
* [Retrieve all assigned IPs (GET /ips/assigned)](RetrieveAssignedIPs.java) | ||
* [Create an IP pool (POST /ips/pools)](CreatePool.java) | ||
* [Retrieve all IP pools (GET /ips/pools)](RetrieveAllPools.java) | ||
* [Update an IP pools name (PUT /ips/pools/{pool_name})](UpdatePoolName.java) | ||
* [Retrieve all IPs in a specified pool (GET /ips/pools/{pool_name})](RetrieveIPsInPool.java) | ||
* [Delete an IP pool. (DELETE /ips/pools/{pool_name})](DeletePool.java) | ||
* [Add an IP address to a pool (POST /ips/pools/{pool_name}/ips)](AddToPool.java) | ||
* [Remove an IP address from a pool (DELETE /ips/pools/{pool_name}/ips/{ip}](RemoveFromPool.java) | ||
* [Add an IP to warmup (POST /ips/warmup)](AddToWarmup.java) | ||
* [Retrieve all IPs currently in warmup (GET /ips/warmup)](RetrieveIPsInWarmup.java) | ||
* [Retrieve warmup status for a specific IP address (GET /ips/warmup/{ip_address})](RetrieveWarmupStatus.java) | ||
* [Remove an IP from warmup (DELETE /ips/warmup/{ip_address})](RemoveFromWarmup.java) | ||
* [Retrieve all IP pools an IP address belongs to (GET /ips/{ip_address})](RetrievePoolsForIP.java) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
||
|
||
|
||
import java.io.IOException; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
|
||
////////////////////////////////////////////////////////////////// | ||
// Remove an IP address from a pool. | ||
// DELETE /ips/pools/{pool_name}/ips/{ip} | ||
|
||
|
||
public class RemoveIPFromPool { | ||
public static void main(String[] args) throws IOException { | ||
try { | ||
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY")); | ||
Request request = new Request(); | ||
request.setMethod(Method.DELETE); | ||
request.setEndpoint("ips/pools/{pool_name}/ips/{ip}"); | ||
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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
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; | ||
|
||
|
||
|
||
////////////////////////////////////////////////////////////////// | ||
// Remove an IP from warmup | ||
// DELETE /ips/warmup/{ip_address} | ||
|
||
|
||
public class RemoveFromWarmup { | ||
public static void main(String[] args) throws IOException { | ||
try { | ||
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY")); | ||
Request request = new Request(); | ||
request.setMethod(Method.DELETE); | ||
request.setEndpoint("ips/warmup/{ip_address}"); | ||
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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import com.sendgrid.Method; | ||
import com.sendgrid.Request; | ||
import com.sendgrid.Response; | ||
import com.sendgrid.SendGrid; | ||
|
||
import java.io.IOException; | ||
|
||
|
||
////////////////////////////////////////////////////////////////// | ||
// Retrieve all IP addresses | ||
// GET /ips | ||
|
||
|
||
public class RetrieveAllIPs { | ||
public static void main(String[] args) throws IOException { | ||
try { | ||
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY")); | ||
Request request = new Request(); | ||
request.setMethod(Method.GET); | ||
request.setEndpoint("ips"); | ||
request.addQueryParam("subuser", "test_string"); | ||
request.addQueryParam("ip", "test_string"); | ||
request.addQueryParam("limit", "1"); | ||
request.addQueryParam("exclude_whitelabels", "true"); | ||
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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
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; | ||
|
||
|
||
////////////////////////////////////////////////////////////////// | ||
// Retrieve all IP pools. | ||
// GET /ips/pools | ||
|
||
|
||
public class RetieveAllIPPools { | ||
public static void main(String[] args) throws IOException { | ||
try { | ||
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY")); | ||
Request request = new Request(); | ||
request.setMethod(Method.GET); | ||
request.setEndpoint("ips/pools"); | ||
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
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; | ||
|
||
|
||
////////////////////////////////////////////////////////////////// | ||
// Retrieve all assigned IPs | ||
// GET /ips/assigned | ||
|
||
|
||
public class RetrieveAllAssignedIPs { | ||
public static void main(String[] args) throws IOException { | ||
try { | ||
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY")); | ||
Request request = new Request(); | ||
request.setMethod(Method.GET); | ||
request.setEndpoint("ips/assigned"); | ||
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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
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; | ||
|
||
|
||
////////////////////////////////////////////////////////////////// | ||
// Retrieve all IPs in a specified pool. | ||
// GET /ips/pools/{pool_name} | ||
|
||
|
||
public class RetrieveIPsInPool { | ||
public static void main(String[] args) throws IOException { | ||
try { | ||
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY")); | ||
Request request = new Request(); | ||
request.setMethod(Method.GET); | ||
request.setEndpoint("ips/pools/{pool_name}"); | ||
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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
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; | ||
|
||
|
||
|
||
////////////////////////////////////////////////////////////////// | ||
// Retrieve all IPs currently in warmup | ||
// GET /ips/warmup | ||
|
||
|
||
public class RetrieveIPsInWarmup { | ||
public static void main(String[] args) throws IOException { | ||
try { | ||
SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY")); | ||
Request request = new Request(); | ||
request.setMethod(Method.GET); | ||
request.setEndpoint("ips/warmup"); | ||
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; | ||
} | ||
} | ||
} |
Oops, something went wrong.