|
27 | 27 |
|
28 | 28 | import javax.validation.constraints.*; |
29 | 29 |
|
| 30 | +import com.volcengine.translate20250301.model.GetUsageRequest; |
| 31 | +import com.volcengine.translate20250301.model.GetUsageResponse; |
30 | 32 | import com.volcengine.translate20250301.model.LangDetectRequest; |
31 | 33 | import com.volcengine.translate20250301.model.LangDetectResponse; |
32 | 34 | import com.volcengine.translate20250301.model.QueryAudioRequest; |
@@ -63,6 +65,130 @@ public void setApiClient(ApiClient apiClient) { |
63 | 65 | this.apiClient = apiClient; |
64 | 66 | } |
65 | 67 |
|
| 68 | + /** |
| 69 | + * Build call for getUsage |
| 70 | + * @param body (required) |
| 71 | + * @param progressListener Progress listener |
| 72 | + * @param progressRequestListener Progress request listener |
| 73 | + * @return Call to execute |
| 74 | + * @throws ApiException If fail to serialize the request body object |
| 75 | + */ |
| 76 | + public com.squareup.okhttp.Call getUsageCall(GetUsageRequest body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { |
| 77 | + Object localVarPostBody = body; |
| 78 | + |
| 79 | + // create path and map variables |
| 80 | + String localVarPath = "/GetUsage/2025-03-01/translate/post/application_json/"; |
| 81 | + |
| 82 | + List<Pair> localVarQueryParams = new ArrayList<Pair>(); |
| 83 | + List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); |
| 84 | + |
| 85 | + Map<String, String> localVarHeaderParams = new HashMap<String, String>(); |
| 86 | + |
| 87 | + Map<String, Object> localVarFormParams = new HashMap<String, Object>(); |
| 88 | + |
| 89 | + final String[] localVarAccepts = { |
| 90 | + "application/json" |
| 91 | + }; |
| 92 | + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); |
| 93 | + if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); |
| 94 | + |
| 95 | + final String[] localVarContentTypes = { |
| 96 | + "text/plain" |
| 97 | + }; |
| 98 | + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); |
| 99 | + localVarHeaderParams.put("Content-Type", localVarContentType); |
| 100 | + |
| 101 | + if(progressListener != null) { |
| 102 | + apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { |
| 103 | + @Override |
| 104 | + public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { |
| 105 | + com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); |
| 106 | + return originalResponse.newBuilder() |
| 107 | + .body(new ProgressResponseBody(originalResponse.body(), progressListener)) |
| 108 | + .build(); |
| 109 | + } |
| 110 | + }); |
| 111 | + } |
| 112 | + |
| 113 | + String[] localVarAuthNames = new String[] { "volcengineSign" }; |
| 114 | + return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); |
| 115 | + } |
| 116 | + |
| 117 | + @SuppressWarnings("rawtypes") |
| 118 | + private com.squareup.okhttp.Call getUsageValidateBeforeCall(GetUsageRequest body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { |
| 119 | + // verify the required parameter 'body' is set |
| 120 | + if (body == null) { |
| 121 | + throw new ApiException("Missing the required parameter 'body' when calling getUsage(Async)"); |
| 122 | + } |
| 123 | + |
| 124 | + com.squareup.okhttp.Call call = getUsageCall(body, progressListener, progressRequestListener); |
| 125 | + return call; |
| 126 | + |
| 127 | + |
| 128 | + |
| 129 | + |
| 130 | + |
| 131 | + } |
| 132 | + |
| 133 | + /** |
| 134 | + * |
| 135 | + * |
| 136 | + * @param body (required) |
| 137 | + * @return GetUsageResponse |
| 138 | + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body |
| 139 | + */ |
| 140 | + public GetUsageResponse getUsage(GetUsageRequest body) throws ApiException { |
| 141 | + ApiResponse<GetUsageResponse> resp = getUsageWithHttpInfo(body); |
| 142 | + return resp.getData(); |
| 143 | + } |
| 144 | + |
| 145 | + /** |
| 146 | + * |
| 147 | + * |
| 148 | + * @param body (required) |
| 149 | + * @return ApiResponse<GetUsageResponse> |
| 150 | + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body |
| 151 | + */ |
| 152 | + public ApiResponse<GetUsageResponse> getUsageWithHttpInfo( @NotNull GetUsageRequest body) throws ApiException { |
| 153 | + com.squareup.okhttp.Call call = getUsageValidateBeforeCall(body, null, null); |
| 154 | + Type localVarReturnType = new TypeToken<GetUsageResponse>(){}.getType(); |
| 155 | + return apiClient.execute(call, localVarReturnType); |
| 156 | + } |
| 157 | + |
| 158 | + /** |
| 159 | + * (asynchronously) |
| 160 | + * |
| 161 | + * @param body (required) |
| 162 | + * @param callback The callback to be executed when the API call finishes |
| 163 | + * @return The request call |
| 164 | + * @throws ApiException If fail to process the API call, e.g. serializing the request body object |
| 165 | + */ |
| 166 | + public com.squareup.okhttp.Call getUsageAsync(GetUsageRequest body, final ApiCallback<GetUsageResponse> callback) throws ApiException { |
| 167 | + |
| 168 | + ProgressResponseBody.ProgressListener progressListener = null; |
| 169 | + ProgressRequestBody.ProgressRequestListener progressRequestListener = null; |
| 170 | + |
| 171 | + if (callback != null) { |
| 172 | + progressListener = new ProgressResponseBody.ProgressListener() { |
| 173 | + @Override |
| 174 | + public void update(long bytesRead, long contentLength, boolean done) { |
| 175 | + callback.onDownloadProgress(bytesRead, contentLength, done); |
| 176 | + } |
| 177 | + }; |
| 178 | + |
| 179 | + progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { |
| 180 | + @Override |
| 181 | + public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { |
| 182 | + callback.onUploadProgress(bytesWritten, contentLength, done); |
| 183 | + } |
| 184 | + }; |
| 185 | + } |
| 186 | + |
| 187 | + com.squareup.okhttp.Call call = getUsageValidateBeforeCall(body, progressListener, progressRequestListener); |
| 188 | + Type localVarReturnType = new TypeToken<GetUsageResponse>(){}.getType(); |
| 189 | + apiClient.executeAsync(call, localVarReturnType, callback); |
| 190 | + return call; |
| 191 | + } |
66 | 192 | /** |
67 | 193 | * Build call for langDetect |
68 | 194 | * @param body (required) |
|
0 commit comments