Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ private ApiClient(Builder builder) {
bodyLogger = new BodyLogger(mapper, 1024, debugTruncateBytes);
}

private static <I> void setQuery(Request in, I entity) {
public static <I> void setQuery(Request in, I entity) {
if (entity == null) {
return;
}
Expand Down Expand Up @@ -198,65 +198,10 @@ protected <I, O> O withJavaType(
}
}

public <O> O HEAD(String path, Class<O> target, Map<String, String> headers) {
return HEAD(path, null, target, headers);
}

public <I, O> O HEAD(String path, I in, Class<O> target, Map<String, String> headers) {
try {
return execute(prepareRequest("HEAD", path, in, headers), target);
} catch (IOException e) {
throw new DatabricksException("IO error: " + e.getMessage(), e);
}
}

public <O> O GET(String path, Class<O> target, Map<String, String> headers) {
return GET(path, null, target, headers);
}

public <I, O> O GET(String path, I in, Class<O> target, Map<String, String> headers) {
try {
return execute(prepareRequest("GET", path, in, headers), target);
} catch (IOException e) {
throw new DatabricksException("IO error: " + e.getMessage(), e);
}
}

public <O> O POST(String path, Class<O> target, Map<String, String> headers) {
try {
return execute(prepareRequest("POST", path, null, headers), target);
} catch (IOException e) {
throw new DatabricksException("IO error: " + e.getMessage(), e);
}
}

public <I, O> O POST(String path, I in, Class<O> target, Map<String, String> headers) {
try {
return execute(prepareRequest("POST", path, in, headers), target);
} catch (IOException e) {
throw new DatabricksException("IO error: " + e.getMessage(), e);
}
}

public <I, O> O PUT(String path, I in, Class<O> target, Map<String, String> headers) {
try {
return execute(prepareRequest("PUT", path, in, headers), target);
} catch (IOException e) {
throw new DatabricksException("IO error: " + e.getMessage(), e);
}
}

public <I, O> O PATCH(String path, I in, Class<O> target, Map<String, String> headers) {
try {
return execute(prepareRequest("PATCH", path, in, headers), target);
} catch (IOException e) {
throw new DatabricksException("IO error: " + e.getMessage(), e);
}
}

public <I, O> O DELETE(String path, I in, Class<O> target, Map<String, String> headers) {
public <I, O> O execute(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still use this one? Now all generated code uses the one which takes the Request object, correct?

String method, String path, I in, Class<O> target, Map<String, String> headers) {
try {
return execute(prepareRequest("DELETE", path, in, headers), target);
return execute(prepareRequest(method, path, in, headers), target);
} catch (IOException e) {
throw new DatabricksException("IO error: " + e.getMessage(), e);
}
Expand Down Expand Up @@ -294,7 +239,7 @@ private <I> Request prepareRequest(String method, String path, I in, Map<String,
* @param target Expected pojo type
* @return POJO of requested type
*/
private <T> T execute(Request in, Class<T> target) throws IOException {
public <T> T execute(Request in, Class<T> target) throws IOException {
Response out = getResponse(in);
if (target == Void.class) {
return null;
Expand Down Expand Up @@ -533,7 +478,7 @@ public <T> void deserialize(Response response, T object) throws IOException {
}
}

private String serialize(Object body) throws JsonProcessingException {
public String serialize(Object body) throws JsonProcessingException {
if (body == null) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -586,10 +586,13 @@ private OpenIDConnectEndpoints fetchDefaultOidcEndpoints() throws IOException {
.withHttpClient(getHttpClient())
.withGetHostFunc(v -> getHost())
.build();
return apiClient.GET(
"/oidc/.well-known/oauth-authorization-server",
OpenIDConnectEndpoints.class,
new HashMap<>());
try {
return apiClient.execute(
new Request("GET", "/oidc/.well-known/oauth-authorization-server"),
OpenIDConnectEndpoints.class);
} catch (IOException e) {
throw new DatabricksException("IO error: " + e.getMessage(), e);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.databricks.sdk.core.DatabricksException;
import com.databricks.sdk.core.http.FormRequest;
import com.databricks.sdk.core.http.HttpClient;
import com.databricks.sdk.core.http.Request;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import java.util.Base64;
Expand Down Expand Up @@ -61,12 +62,11 @@ protected static Token retrieveToken(
break;
}
headers.put("Content-Type", "application/x-www-form-urlencoded");
Request req = new Request("POST", tokenUrl, FormRequest.wrapValuesInList(params));
req.withHeaders(headers);
try {
ApiClient apiClient = new ApiClient.Builder().withHttpClient(hc).build();

OAuthResponse resp =
apiClient.POST(
tokenUrl, FormRequest.wrapValuesInList(params), OAuthResponse.class, headers);
OAuthResponse resp = apiClient.execute(req, OAuthResponse.class);
if (resp.getErrorCode() != null) {
throw new IllegalArgumentException(resp.getErrorCode() + ": " + resp.getErrorSummary());
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading