Create a nomulus "curl" command

Create a command to send arbitrary, authenticated HTTP requests to the backend
and remove the existing commands that are basically just wrappers around this.

Tested:
  In addition to the unit tests, verified both get and post requests against
  alpha.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=207756509
This commit is contained in:
mmuller 2018-08-07 12:03:40 -07:00 committed by jianglai
parent 6810e959f9
commit e3977024f3
9 changed files with 223 additions and 284 deletions

View file

@ -18,6 +18,7 @@ import com.google.common.net.MediaType;
import google.registry.tools.Command.RemoteApiCommand;
import java.io.IOException;
import java.util.Map;
import javax.annotation.Nullable;
/** A command that executes on the server. */
interface ServerSideCommand extends RemoteApiCommand {
@ -27,9 +28,13 @@ interface ServerSideCommand extends RemoteApiCommand {
void prefetchXsrfToken();
String send(String endpoint, Map<String, ?> params, MediaType contentType, byte[] payload)
/** Send a POST request. TODO(mmuller): change to sendPostRequest() */
String send(
String endpoint, Map<String, ?> params, MediaType contentType, @Nullable byte[] payload)
throws IOException;
String sendGetRequest(String endpoint, Map<String, ?> params) throws IOException;
Map<String, Object> sendJson(String endpoint, Map<String, ?> object) throws IOException;
String getServerUrl();