@@ -66,9 +66,15 @@ import java.util.Map.Entry;
6666import java.util.TimeZone;
6767
6868import { {invokerPackage} }.auth.Authentication;
69+ { {#hasHttpBasicMethods} }
6970import { {invokerPackage} }.auth.HttpBasicAuth;
71+ { {/hasHttpBasicMethods} }
72+ { {#hasHttpBearerMethods} }
7073import { {invokerPackage} }.auth.HttpBearerAuth;
74+ { {/hasHttpBearerMethods} }
75+ { {#hasApiKeyMethods} }
7176import { {invokerPackage} }.auth.ApiKeyAuth;
77+ { {/hasApiKeyMethods} }
7278{ {#hasOAuthMethods} }
7379import { {invokerPackage} }.auth.OAuth;
7480{ {/hasOAuthMethods} }
@@ -170,93 +176,103 @@ public class ApiClient {
170176 return authentications.get(authName);
171177 }
172178
173- /**
174- * Helper method to set token for HTTP bearer authentication.
175- * @param bearerToken the token
176- */
177- public void setBearerToken(String bearerToken) {
178- for (Authentication auth : authentications.values() ) {
179- if ( auth instanceof HttpBearerAuth ) {
180- (( HttpBearerAuth) auth).setBearerToken(bearerToken);
181- return ;
182- }
179+ { {#hasHttpBearerMethods } }
180+ /**
181+ * Helper method to set token for HTTP bearer authentication.
182+ * @param bearerToken the token
183+ */
184+ public void setBearerToken(String bearerToken ) {
185+ for (Authentication auth : authentications.values() ) {
186+ if (auth instanceof HttpBearerAuth) {
187+ ((HttpBearerAuth) auth).setBearerToken(bearerToken) ;
188+ return;
183189 }
184- throw new RuntimeException("No Bearer authentication configured!");
185190 }
186-
187- /**
188- * Helper method to set username for the first HTTP basic authentication.
189- * @param username the username
190- */
191- public void setUsername(String username) {
192- for (Authentication auth : authentications.values()) {
193- if (auth instanceof HttpBasicAuth) {
194- ((HttpBasicAuth) auth).setUsername(username);
195- return;
196- }
197- }
198- throw new RuntimeException("No HTTP basic authentication configured!");
191+ throw new RuntimeException("No Bearer authentication configured!");
192+ }
193+
194+ { {/hasHttpBearerMethods} }
195+
196+ { {#hasHttpBasicMethods} }
197+ /**
198+ * Helper method to set username for the first HTTP basic authentication.
199+ * @param username Username
200+ */
201+ public void setUsername(String username) {
202+ for (Authentication auth : authentications.values()) {
203+ if (auth instanceof HttpBasicAuth) {
204+ ((HttpBasicAuth) auth).setUsername(username);
205+ return;
206+ }
199207 }
200-
201- /**
202- * Helper method to set password for the first HTTP basic authentication.
203- * @param password the password
204- */
205- public void setPassword(String password) {
206- for (Authentication auth : authentications.values()) {
207- if (auth instanceof HttpBasicAuth ) {
208- ((HttpBasicAuth) auth).setPassword(password);
209- return;
210- }
211- }
212- throw new RuntimeException("No HTTP basic authentication configured!");
208+ throw new RuntimeException("No HTTP basic authentication configured!");
209+ }
210+
211+ /**
212+ * Helper method to set password for the first HTTP basic authentication.
213+ * @param password Password
214+ */
215+ public void setPassword(String password ) {
216+ for (Authentication auth : authentications.values()) {
217+ if (auth instanceof HttpBasicAuth) {
218+ ((HttpBasicAuth) auth).setPassword(password);
219+ return;
220+ }
213221 }
214-
215- /**
216- * Helper method to set API key value for the first API key authentication.
217- * @param apiKey the API key
218- */
219- public void setApiKey(String apiKey) {
220- for (Authentication auth : authentications.values()) {
221- if (auth instanceof ApiKeyAuth) {
222- ((ApiKeyAuth) auth).setApiKey(apiKey);
223- return;
224- }
225- }
226- throw new RuntimeException("No API key authentication configured!");
222+ throw new RuntimeException("No HTTP basic authentication configured!");
223+ }
224+
225+ { {/hasHttpBasicMethods} }
226+
227+ { {#hasApiKeyMethods} }
228+ /**
229+ * Helper method to set API key value for the first API key authentication.
230+ * @param apiKey the API key
231+ */
232+ public void setApiKey(String apiKey) {
233+ for (Authentication auth : authentications.values()) {
234+ if (auth instanceof ApiKeyAuth) {
235+ ((ApiKeyAuth) auth).setApiKey(apiKey);
236+ return;
237+ }
227238 }
228-
229- /**
230- * Helper method to set API key prefix for the first API key authentication.
231- * @param apiKeyPrefix the API key prefix
232- */
233- public void setApiKeyPrefix(String apiKeyPrefix) {
234- for (Authentication auth : authentications.values()) {
235- if (auth instanceof ApiKeyAuth ) {
236- ((ApiKeyAuth) auth).setApiKeyPrefix(apiKeyPrefix);
237- return;
238- }
239- }
240- throw new RuntimeException("No API key authentication configured!");
239+ throw new RuntimeException("No API key authentication configured!");
240+ }
241+
242+ /**
243+ * Helper method to set API key prefix for the first API key authentication.
244+ * @param apiKeyPrefix API key prefix
245+ */
246+ public void setApiKeyPrefix(String apiKeyPrefix ) {
247+ for (Authentication auth : authentications.values()) {
248+ if (auth instanceof ApiKeyAuth) {
249+ ((ApiKeyAuth) auth).setApiKeyPrefix(apiKeyPrefix);
250+ return;
251+ }
241252 }
242-
243- { {#hasOAuthMethods} }
244- /**
245- * Helper method to set access token for the first OAuth2 authentication.
246- * @param accessToken the access token
247- */
248- public void setAccessToken(String accessToken) {
249- for (Authentication auth : authentications.values()) {
250- if (auth instanceof OAuth) {
251- ((OAuth) auth).setAccessToken(accessToken);
252- return;
253- }
254- }
255- throw new RuntimeException("No OAuth2 authentication configured!");
253+ throw new RuntimeException("No API key authentication configured!");
254+ }
255+
256+ { {/hasApiKeyMethods} }
257+
258+ { {#hasOAuthMethods} }
259+ /**
260+ * Helper method to set access token for the first OAuth2 authentication.
261+ * @param accessToken Access token
262+ */
263+ public void setAccessToken(String accessToken) {
264+ for (Authentication auth : authentications.values()) {
265+ if (auth instanceof OAuth) {
266+ ((OAuth) auth).setAccessToken(accessToken);
267+ return;
268+ }
256269 }
270+ throw new RuntimeException("No OAuth2 authentication configured!");
271+ }
257272
258- { {/hasOAuthMethods} }
259- /**
273+ { {/hasOAuthMethods} }
274+
275+ /**
260276 * Set the User-Agent header's value (by adding to the default header map).
261277 * @param userAgent the user agent string
262278 * @return ApiClient this client
0 commit comments