Skip to content

Commit a99fa0c

Browse files
committed
Fix create token api
Signed-off-by: Andrew Thornton <[email protected]>
1 parent 77a4e0b commit a99fa0c

File tree

80 files changed

+417
-112
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+417
-112
lines changed

docs/AccessToken.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
# AccessToken
3+
4+
## Properties
5+
Name | Type | Description | Notes
6+
------------ | ------------- | ------------- | -------------
7+
**id** | **Long** | | [optional]
8+
**name** | **String** | | [optional]
9+
**sha1** | **String** | | [optional]
10+
11+
12+

docs/AccessTokenName.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
# AccessTokenName
3+
4+
## Properties
5+
Name | Type | Description | Notes
6+
------------ | ------------- | ------------- | -------------
7+
**name** | **String** | |
8+
9+
10+

docs/UserApi.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ null (empty response body)
294294

295295
<a name="userCreateToken"></a>
296296
# **userCreateToken**
297-
> userCreateToken(username)
297+
> AccessToken userCreateToken(username, accessTokenName)
298298
299299
Create an access token
300300

@@ -346,8 +346,10 @@ Token.setApiKey("YOUR API KEY");
346346

347347
UserApi apiInstance = new UserApi();
348348
String username = "username_example"; // String | username of user
349+
AccessTokenName accessTokenName = new AccessTokenName(); // AccessTokenName |
349350
try {
350-
apiInstance.userCreateToken(username);
351+
AccessToken result = apiInstance.userCreateToken(username, accessTokenName);
352+
System.out.println(result);
351353
} catch (ApiException e) {
352354
System.err.println("Exception when calling UserApi#userCreateToken");
353355
e.printStackTrace();
@@ -359,10 +361,11 @@ try {
359361
Name | Type | Description | Notes
360362
------------- | ------------- | ------------- | -------------
361363
**username** | **String**| username of user |
364+
**accessTokenName** | [**AccessTokenName**](AccessTokenName.md)| | [optional]
362365

363366
### Return type
364367

365-
null (empty response body)
368+
[**AccessToken**](AccessToken.md)
366369

367370
### Authorization
368371

@@ -2305,7 +2308,7 @@ This endpoint does not need any parameter.
23052308

23062309
<a name="userGetTokens"></a>
23072310
# **userGetTokens**
2308-
> userGetTokens(username)
2311+
> List&lt;AccessToken&gt; userGetTokens(username)
23092312
23102313
List the authenticated user&#39;s access tokens
23112314

@@ -2358,7 +2361,8 @@ Token.setApiKey("YOUR API KEY");
23582361
UserApi apiInstance = new UserApi();
23592362
String username = "username_example"; // String | username of user
23602363
try {
2361-
apiInstance.userGetTokens(username);
2364+
List<AccessToken> result = apiInstance.userGetTokens(username);
2365+
System.out.println(result);
23622366
} catch (ApiException e) {
23632367
System.err.println("Exception when calling UserApi#userGetTokens");
23642368
e.printStackTrace();
@@ -2373,7 +2377,7 @@ Name | Type | Description | Notes
23732377

23742378
### Return type
23752379

2376-
null (empty response body)
2380+
[**List&lt;AccessToken&gt;**](AccessToken.md)
23772381

23782382
### Authorization
23792383

gradle/wrapper/gradle-wrapper.jar

-690 Bytes
Binary file not shown.
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
#Tue May 17 23:08:05 CST 2016
12
distributionBase=GRADLE_USER_HOME
23
distributionPath=wrapper/dists
34
zipStoreBase=GRADLE_USER_HOME
45
zipStorePath=wrapper/dists
5-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-2.6-bin.zip

src/main/java/io/gitea/ApiException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import java.util.Map;
1717
import java.util.List;
1818

19-
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2018-09-07T10:45:35.787+01:00")
19+
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2018-10-03T21:33:54.578+01:00")
2020
public class ApiException extends Exception {
2121
private int code = 0;
2222
private Map<String, List<String>> responseHeaders = null;

src/main/java/io/gitea/Configuration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
package io.gitea;
1515

16-
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2018-09-07T10:45:35.787+01:00")
16+
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2018-10-03T21:33:54.578+01:00")
1717
public class Configuration {
1818
private static ApiClient defaultApiClient = new ApiClient();
1919

src/main/java/io/gitea/Pair.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
package io.gitea;
1515

16-
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2018-09-07T10:45:35.787+01:00")
16+
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2018-10-03T21:33:54.578+01:00")
1717
public class Pair {
1818
private String name = "";
1919
private String value = "";

src/main/java/io/gitea/StringUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
package io.gitea;
1515

16-
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2018-09-07T10:45:35.787+01:00")
16+
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2018-10-03T21:33:54.578+01:00")
1717
public class StringUtil {
1818
/**
1919
* Check if the given array contains the given value (with case-insensitive comparison).

src/main/java/io/gitea/api/UserApi.java

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
import java.io.IOException;
2828

2929

30+
import io.gitea.model.AccessToken;
31+
import io.gitea.model.AccessTokenName;
3032
import io.gitea.model.CreateEmailOption;
3133
import io.gitea.model.CreateGPGKeyOption;
3234
import io.gitea.model.CreateKeyOption;
@@ -431,13 +433,14 @@ public void onRequestProgress(long bytesWritten, long contentLength, boolean don
431433
/**
432434
* Build call for userCreateToken
433435
* @param username username of user (required)
436+
* @param accessTokenName (optional)
434437
* @param progressListener Progress listener
435438
* @param progressRequestListener Progress request listener
436439
* @return Call to execute
437440
* @throws ApiException If fail to serialize the request body object
438441
*/
439-
public com.squareup.okhttp.Call userCreateTokenCall(String username, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
440-
Object localVarPostBody = null;
442+
public com.squareup.okhttp.Call userCreateTokenCall(String username, AccessTokenName accessTokenName, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
443+
Object localVarPostBody = accessTokenName;
441444

442445
// create path and map variables
443446
String localVarPath = "/users/{username}/tokens"
@@ -479,15 +482,15 @@ public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Ch
479482
}
480483

481484
@SuppressWarnings("rawtypes")
482-
private com.squareup.okhttp.Call userCreateTokenValidateBeforeCall(String username, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
485+
private com.squareup.okhttp.Call userCreateTokenValidateBeforeCall(String username, AccessTokenName accessTokenName, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
483486

484487
// verify the required parameter 'username' is set
485488
if (username == null) {
486489
throw new ApiException("Missing the required parameter 'username' when calling userCreateToken(Async)");
487490
}
488491

489492

490-
com.squareup.okhttp.Call call = userCreateTokenCall(username, progressListener, progressRequestListener);
493+
com.squareup.okhttp.Call call = userCreateTokenCall(username, accessTokenName, progressListener, progressRequestListener);
491494
return call;
492495

493496
}
@@ -496,33 +499,39 @@ private com.squareup.okhttp.Call userCreateTokenValidateBeforeCall(String userna
496499
* Create an access token
497500
*
498501
* @param username username of user (required)
502+
* @param accessTokenName (optional)
503+
* @return AccessToken
499504
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
500505
*/
501-
public void userCreateToken(String username) throws ApiException {
502-
userCreateTokenWithHttpInfo(username);
506+
public AccessToken userCreateToken(String username, AccessTokenName accessTokenName) throws ApiException {
507+
ApiResponse<AccessToken> resp = userCreateTokenWithHttpInfo(username, accessTokenName);
508+
return resp.getData();
503509
}
504510

505511
/**
506512
* Create an access token
507513
*
508514
* @param username username of user (required)
509-
* @return ApiResponse&lt;Void&gt;
515+
* @param accessTokenName (optional)
516+
* @return ApiResponse&lt;AccessToken&gt;
510517
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
511518
*/
512-
public ApiResponse<Void> userCreateTokenWithHttpInfo(String username) throws ApiException {
513-
com.squareup.okhttp.Call call = userCreateTokenValidateBeforeCall(username, null, null);
514-
return apiClient.execute(call);
519+
public ApiResponse<AccessToken> userCreateTokenWithHttpInfo(String username, AccessTokenName accessTokenName) throws ApiException {
520+
com.squareup.okhttp.Call call = userCreateTokenValidateBeforeCall(username, accessTokenName, null, null);
521+
Type localVarReturnType = new TypeToken<AccessToken>(){}.getType();
522+
return apiClient.execute(call, localVarReturnType);
515523
}
516524

517525
/**
518526
* Create an access token (asynchronously)
519527
*
520528
* @param username username of user (required)
529+
* @param accessTokenName (optional)
521530
* @param callback The callback to be executed when the API call finishes
522531
* @return The request call
523532
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
524533
*/
525-
public com.squareup.okhttp.Call userCreateTokenAsync(String username, final ApiCallback<Void> callback) throws ApiException {
534+
public com.squareup.okhttp.Call userCreateTokenAsync(String username, AccessTokenName accessTokenName, final ApiCallback<AccessToken> callback) throws ApiException {
526535

527536
ProgressResponseBody.ProgressListener progressListener = null;
528537
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
@@ -543,8 +552,9 @@ public void onRequestProgress(long bytesWritten, long contentLength, boolean don
543552
};
544553
}
545554

546-
com.squareup.okhttp.Call call = userCreateTokenValidateBeforeCall(username, progressListener, progressRequestListener);
547-
apiClient.executeAsync(call, callback);
555+
com.squareup.okhttp.Call call = userCreateTokenValidateBeforeCall(username, accessTokenName, progressListener, progressRequestListener);
556+
Type localVarReturnType = new TypeToken<AccessToken>(){}.getType();
557+
apiClient.executeAsync(call, localVarReturnType, callback);
548558
return call;
549559
}
550560
/**
@@ -3459,22 +3469,25 @@ private com.squareup.okhttp.Call userGetTokensValidateBeforeCall(String username
34593469
* List the authenticated user&#39;s access tokens
34603470
*
34613471
* @param username username of user (required)
3472+
* @return List&lt;AccessToken&gt;
34623473
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
34633474
*/
3464-
public void userGetTokens(String username) throws ApiException {
3465-
userGetTokensWithHttpInfo(username);
3475+
public List<AccessToken> userGetTokens(String username) throws ApiException {
3476+
ApiResponse<List<AccessToken>> resp = userGetTokensWithHttpInfo(username);
3477+
return resp.getData();
34663478
}
34673479

34683480
/**
34693481
* List the authenticated user&#39;s access tokens
34703482
*
34713483
* @param username username of user (required)
3472-
* @return ApiResponse&lt;Void&gt;
3484+
* @return ApiResponse&lt;List&lt;AccessToken&gt;&gt;
34733485
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
34743486
*/
3475-
public ApiResponse<Void> userGetTokensWithHttpInfo(String username) throws ApiException {
3487+
public ApiResponse<List<AccessToken>> userGetTokensWithHttpInfo(String username) throws ApiException {
34763488
com.squareup.okhttp.Call call = userGetTokensValidateBeforeCall(username, null, null);
3477-
return apiClient.execute(call);
3489+
Type localVarReturnType = new TypeToken<List<AccessToken>>(){}.getType();
3490+
return apiClient.execute(call, localVarReturnType);
34783491
}
34793492

34803493
/**
@@ -3485,7 +3498,7 @@ public ApiResponse<Void> userGetTokensWithHttpInfo(String username) throws ApiEx
34853498
* @return The request call
34863499
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
34873500
*/
3488-
public com.squareup.okhttp.Call userGetTokensAsync(String username, final ApiCallback<Void> callback) throws ApiException {
3501+
public com.squareup.okhttp.Call userGetTokensAsync(String username, final ApiCallback<List<AccessToken>> callback) throws ApiException {
34893502

34903503
ProgressResponseBody.ProgressListener progressListener = null;
34913504
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
@@ -3507,7 +3520,8 @@ public void onRequestProgress(long bytesWritten, long contentLength, boolean don
35073520
}
35083521

35093522
com.squareup.okhttp.Call call = userGetTokensValidateBeforeCall(username, progressListener, progressRequestListener);
3510-
apiClient.executeAsync(call, callback);
3523+
Type localVarReturnType = new TypeToken<List<AccessToken>>(){}.getType();
3524+
apiClient.executeAsync(call, localVarReturnType, callback);
35113525
return call;
35123526
}
35133527
/**

src/main/java/io/gitea/auth/ApiKeyAuth.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import java.util.Map;
1919
import java.util.List;
2020

21-
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2018-09-07T10:45:35.787+01:00")
21+
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2018-10-03T21:33:54.578+01:00")
2222
public class ApiKeyAuth implements Authentication {
2323
private final String location;
2424
private final String paramName;

src/main/java/io/gitea/auth/OAuth.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import java.util.Map;
1919
import java.util.List;
2020

21-
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2018-09-07T10:45:35.787+01:00")
21+
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2018-10-03T21:33:54.578+01:00")
2222
public class OAuth implements Authentication {
2323
private String accessToken;
2424

0 commit comments

Comments
 (0)