Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -8,8 +8,10 @@ import {{invokerPackage}}.ApiClient;
import com.fasterxml.jackson.core.type.TypeReference;
import com.google.api.client.http.GenericUrl;
import com.google.api.client.http.HttpContent;
import com.google.api.client.http.InputStreamContent;
import com.google.api.client.http.HttpMethods;
import com.google.api.client.http.HttpResponse;
import com.google.api.client.json.Json;

import javax.ws.rs.core.UriBuilder;
import java.io.IOException;
Expand Down Expand Up @@ -91,15 +93,56 @@ public class {{classname}} {
UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + "{{{path}}}");{{#hasQueryParams}}
{{#queryParams}}
if ({{paramName}} != null) {
uriBuilder = uriBuilder.queryParam("{{baseName}}", {{paramName}});
String key = "{{baseName}}";
Object value = {{paramName}};
if (value instanceof Collection) {
uriBuilder = uriBuilder.queryParam(key, ((Collection) value).toArray());
} else if (value instanceof Object[]) {
uriBuilder = uriBuilder.queryParam(key, (Object[]) value);
} else {
uriBuilder = uriBuilder.queryParam(key, value);
}
}{{/queryParams}}{{/hasQueryParams}}

String url = uriBuilder{{#hasPathParams}}.buildFromMap(uriVariables).toString();{{/hasPathParams}}{{^hasPathParams}}.build().toString();{{/hasPathParams}}
GenericUrl genericUrl = new GenericUrl(url);

HttpContent content = {{#bodyParam}}{{paramName}} == null ? null : apiClient.new JacksonJsonHttpContent({{paramName}}){{/bodyParam}}{{^bodyParam}}null{{/bodyParam}};
HttpContent content = {{#isBodyAllowed}}apiClient.new JacksonJsonHttpContent({{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}}){{/isBodyAllowed}}{{^isBodyAllowed}}null{{/isBodyAllowed}};
return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.{{httpMethod}}, genericUrl, content).execute();
}
}{{#bodyParam}}

public HttpResponse {{operationId}}ForHttpResponse({{#allParams}}{{#isBodyParam}}java.io.InputStream {{paramName}}{{/isBodyParam}}{{^isBodyParam}}{{{dataType}}} {{paramName}}{{/isBodyParam}}{{#hasMore}}, {{/hasMore}}{{/allParams}}, String mediaType) throws IOException {
{{#allParams}}{{#required}}// verify the required parameter '{{paramName}}' is set
if ({{paramName}} == null) {
throw new IllegalArgumentException("Missing the required parameter '{{paramName}}' when calling {{operationId}}");
}{{/required}}{{/allParams}}
{{#hasPathParams}}
// create a map of path variables
final Map<String, Object> uriVariables = new HashMap<String, Object>();{{#pathParams}}
uriVariables.put("{{baseName}}", {{{paramName}}});{{/pathParams}}
{{/hasPathParams}}
UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + "{{{path}}}");{{#hasQueryParams}}
{{#queryParams}}
if ({{paramName}} != null) {
String key = "{{baseName}}";
Object value = {{paramName}};
if (value instanceof Collection) {
uriBuilder = uriBuilder.queryParam(key, ((Collection) value).toArray());
} else if (value instanceof Object[]) {
uriBuilder = uriBuilder.queryParam(key, (Object[]) value);
} else {
uriBuilder = uriBuilder.queryParam(key, value);
}
}{{/queryParams}}{{/hasQueryParams}}

String url = uriBuilder{{#hasPathParams}}.buildFromMap(uriVariables).toString();{{/hasPathParams}}{{^hasPathParams}}.build().toString();{{/hasPathParams}}
GenericUrl genericUrl = new GenericUrl(url);

HttpContent content = {{#bodyParam}}{{paramName}} == null ?
apiClient.new JacksonJsonHttpContent(null) :
new InputStreamContent(mediaType == null ? Json.MEDIA_TYPE : mediaType, {{paramName}}){{/bodyParam}};
return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.{{httpMethod}}, genericUrl, content).execute();
}{{/bodyParam}}

public HttpResponse {{operationId}}ForHttpResponse({{#bodyParam}}{{^required}}{{{dataType}}} {{paramName}}, {{/required}}{{/bodyParam}}{{#requiredParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/requiredParams}}{{#hasRequiredParams}}, {{/hasRequiredParams}}Map<String, Object> params) throws IOException {
{{#allParams}}{{#required}}// verify the required parameter '{{paramName}}' is set
Expand All @@ -125,6 +168,8 @@ public class {{classname}} {
if (key != null && value != null) {
if (value instanceof Collection) {
uriBuilder = uriBuilder.queryParam(key, ((Collection) value).toArray());
} else if (value instanceof Object[]) {
uriBuilder = uriBuilder.queryParam(key, (Object[]) value);
} else {
uriBuilder = uriBuilder.queryParam(key, value);
}
Expand All @@ -134,7 +179,7 @@ public class {{classname}} {
String url = uriBuilder{{#hasPathParams}}.buildFromMap(uriVariables).toString();{{/hasPathParams}}{{^hasPathParams}}.build().toString();{{/hasPathParams}}
GenericUrl genericUrl = new GenericUrl(url);

HttpContent content = {{#bodyParam}}{{paramName}} == null ? null : apiClient.new JacksonJsonHttpContent({{paramName}}){{/bodyParam}}{{^bodyParam}}null{{/bodyParam}};
HttpContent content = {{#isBodyAllowed}}apiClient.new JacksonJsonHttpContent({{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}}){{/isBodyAllowed}}{{^isBodyAllowed}}null{{/isBodyAllowed}};
return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.{{httpMethod}}, genericUrl, content).execute();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
import com.fasterxml.jackson.core.type.TypeReference;
import com.google.api.client.http.GenericUrl;
import com.google.api.client.http.HttpContent;
import com.google.api.client.http.InputStreamContent;
import com.google.api.client.http.HttpMethods;
import com.google.api.client.http.HttpResponse;
import com.google.api.client.json.Json;

import javax.ws.rs.core.UriBuilder;
import java.io.IOException;
Expand Down Expand Up @@ -77,10 +79,26 @@ public HttpResponse testSpecialTagsForHttpResponse(Client body) throws IOExcepti
String url = uriBuilder.build().toString();
GenericUrl genericUrl = new GenericUrl(url);

HttpContent content = body == null ? null : apiClient.new JacksonJsonHttpContent(body);
HttpContent content = apiClient.new JacksonJsonHttpContent(body);
return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PATCH, genericUrl, content).execute();
}

public HttpResponse testSpecialTagsForHttpResponse(java.io.InputStream body, String mediaType) throws IOException {
// verify the required parameter 'body' is set
if (body == null) {
throw new IllegalArgumentException("Missing the required parameter 'body' when calling testSpecialTags");
}
UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + "/another-fake/dummy");

String url = uriBuilder.build().toString();
GenericUrl genericUrl = new GenericUrl(url);

HttpContent content = body == null ?
apiClient.new JacksonJsonHttpContent(null) :
new InputStreamContent(mediaType == null ? Json.MEDIA_TYPE : mediaType, body);
return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PATCH, genericUrl, content).execute();
}

public HttpResponse testSpecialTagsForHttpResponse(Client body, Map<String, Object> params) throws IOException {
// verify the required parameter 'body' is set
if (body == null) {
Expand All @@ -98,6 +116,8 @@ public HttpResponse testSpecialTagsForHttpResponse(Client body, Map<String, Obje
if (key != null && value != null) {
if (value instanceof Collection) {
uriBuilder = uriBuilder.queryParam(key, ((Collection) value).toArray());
} else if (value instanceof Object[]) {
uriBuilder = uriBuilder.queryParam(key, (Object[]) value);
} else {
uriBuilder = uriBuilder.queryParam(key, value);
}
Expand All @@ -107,7 +127,7 @@ public HttpResponse testSpecialTagsForHttpResponse(Client body, Map<String, Obje
String url = uriBuilder.build().toString();
GenericUrl genericUrl = new GenericUrl(url);

HttpContent content = body == null ? null : apiClient.new JacksonJsonHttpContent(body);
HttpContent content = apiClient.new JacksonJsonHttpContent(body);
return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PATCH, genericUrl, content).execute();
}

Expand Down
Loading