RestClient { protected Request buildRequest(String resource, String method, Map<String, String> params, Map<String, String> headers) { return buildRequest(resource, method, params, headers, this.endpoint); } @Survey  RestClient(Transport transport); RetryLogger getRetryLogger(); void setRetryLogger(RetryLogger logger); T request(Class<T> clazz, String resource, String method); T request(Class<T> clazz, String resource, String method, Map<String, String> params); T stringRequest(Class<T> clazz, String resource, String method,
                             Map<String, String> params,
                             Map<String, String> headers, String body); T request(Class<T> clazz, String resource, String method, Map<String, String> params,
                       Map<String, String> headers, byte[] body); Response stringRequest(String resource, String method, Map<String, String> params,
                                Map<String, String> headers, String body); Response request(String resource, String method, Map<String, String> params,
                          Map<String, String> headers,
                          byte[] body); Response request(String resource, String method, Map<String, String> params,
                          Map<String, String> headers,
                          InputStream body, long bodyLen); Connection connect(String resource, String method, Map<String, String> params,
                            Map<String, String> headers); Connection connect(String resource, String method, Map<String, String> params,
                            Map<String, String> headers, String endpoint); @Survey Response requestForRawResponse(String resource, String method, Map<String, String> params,
                                        Map<String, String> headers,
                                        InputStream body, int length); void setAccount(Account account); Account getAccount(); void setAppAccount(AppAccount appAccount); AppAccount getAppAccount(); void setEndpoint(String endpoint); String getDefaultProject(); void setDefaultProject(String defaultProject); String getEndpoint(); @Survey Transport getTransport(); String getUserAgent(); void setUserAgent(String userAgent); void setConnectTimeout(int timeout); int getConnectTimeout(); void setReadTimeout(int timeout); int getReadTimeout(); int getRetryTimes(); void setRetryTimes(int retryTimes); boolean isIgnoreCerts(); void setIgnoreCerts(boolean ignoreCerts); void enableDeprecatedLogger(); void disableDeprecatedLogger(); static final int DEFAULT_CONNECT_TIMEOUT; static final int DEFAULT_CONNECT_RETRYTIMES; static final int DEFAULT_READ_TIMEOUT; static final boolean DEFAULT_IGNORE_CERTS; }
@Test public void testApplicationAuthentication() { String accessId = "id"; String accessKey = "key"; String appAccessId = "app_id"; String appAccessKey = "app_key"; Odps odps = new Odps(new AliyunAccount(accessId, accessKey), new AppAccount(new AliyunAccount(appAccessId, appAccessKey))); RestClient restClient = odps.getRestClient(); Map<String, String> params = new HashMap<String, String>(); Map<String, String> headers = new HashMap<String, String>(); headers.put(Headers.ODPS_USER_AGENT, "JavaSDK Revision:295ed47 Version:0.30.3 JavaVersion:1.8.0_172 CLT(0.30.0 : c36da9d); Mac OS X(30.5.26.135/jondeMacBook-Pro.local)"); headers.put(Headers.DATE, "Fri, 30 Nov 2018 03:31:29 GMT"); Request request = restClient.buildRequest("/projects/project_name/instances/instance_name", "POST", params, headers); assertTrue(request.getHeaders().containsKey(Headers.APP_AUTHENTICATION)); }