Skip to content

Commit

Permalink
Fix create token api
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Thornton <art27@cantab.net>
  • Loading branch information
zeripath committed Oct 3, 2018
1 parent 77a4e0b commit a99fa0c
Show file tree
Hide file tree
Showing 80 changed files with 417 additions and 112 deletions.
12 changes: 12 additions & 0 deletions docs/AccessToken.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

# AccessToken

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **Long** | | [optional]
**name** | **String** | | [optional]
**sha1** | **String** | | [optional]



10 changes: 10 additions & 0 deletions docs/AccessTokenName.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

# AccessTokenName

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**name** | **String** | |



16 changes: 10 additions & 6 deletions docs/UserApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ null (empty response body)

<a name="userCreateToken"></a>
# **userCreateToken**
> userCreateToken(username)
> AccessToken userCreateToken(username, accessTokenName)
Create an access token

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

UserApi apiInstance = new UserApi();
String username = "username_example"; // String | username of user
AccessTokenName accessTokenName = new AccessTokenName(); // AccessTokenName |
try {
apiInstance.userCreateToken(username);
AccessToken result = apiInstance.userCreateToken(username, accessTokenName);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling UserApi#userCreateToken");
e.printStackTrace();
Expand All @@ -359,10 +361,11 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**username** | **String**| username of user |
**accessTokenName** | [**AccessTokenName**](AccessTokenName.md)| | [optional]

### Return type

null (empty response body)
[**AccessToken**](AccessToken.md)

### Authorization

Expand Down Expand Up @@ -2305,7 +2308,7 @@ This endpoint does not need any parameter.

<a name="userGetTokens"></a>
# **userGetTokens**
> userGetTokens(username)
> List&lt;AccessToken&gt; userGetTokens(username)
List the authenticated user&#39;s access tokens

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

### Return type

null (empty response body)
[**List&lt;AccessToken&gt;**](AccessToken.md)

### Authorization

Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#Tue May 17 23:08:05 CST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.6-bin.zip
2 changes: 1 addition & 1 deletion src/main/java/io/gitea/ApiException.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import java.util.Map;
import java.util.List;

@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2018-09-07T10:45:35.787+01:00")
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2018-10-03T21:33:54.578+01:00")
public class ApiException extends Exception {
private int code = 0;
private Map<String, List<String>> responseHeaders = null;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/gitea/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

package io.gitea;

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

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/gitea/Pair.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

package io.gitea;

@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2018-09-07T10:45:35.787+01:00")
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2018-10-03T21:33:54.578+01:00")
public class Pair {
private String name = "";
private String value = "";
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/gitea/StringUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

package io.gitea;

@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2018-09-07T10:45:35.787+01:00")
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2018-10-03T21:33:54.578+01:00")
public class StringUtil {
/**
* Check if the given array contains the given value (with case-insensitive comparison).
Expand Down
54 changes: 34 additions & 20 deletions src/main/java/io/gitea/api/UserApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import java.io.IOException;


import io.gitea.model.AccessToken;
import io.gitea.model.AccessTokenName;
import io.gitea.model.CreateEmailOption;
import io.gitea.model.CreateGPGKeyOption;
import io.gitea.model.CreateKeyOption;
Expand Down Expand Up @@ -431,13 +433,14 @@ public void onRequestProgress(long bytesWritten, long contentLength, boolean don
/**
* Build call for userCreateToken
* @param username username of user (required)
* @param accessTokenName (optional)
* @param progressListener Progress listener
* @param progressRequestListener Progress request listener
* @return Call to execute
* @throws ApiException If fail to serialize the request body object
*/
public com.squareup.okhttp.Call userCreateTokenCall(String username, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
Object localVarPostBody = null;
public com.squareup.okhttp.Call userCreateTokenCall(String username, AccessTokenName accessTokenName, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
Object localVarPostBody = accessTokenName;

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

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

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


com.squareup.okhttp.Call call = userCreateTokenCall(username, progressListener, progressRequestListener);
com.squareup.okhttp.Call call = userCreateTokenCall(username, accessTokenName, progressListener, progressRequestListener);
return call;

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

/**
* Create an access token
*
* @param username username of user (required)
* @return ApiResponse&lt;Void&gt;
* @param accessTokenName (optional)
* @return ApiResponse&lt;AccessToken&gt;
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public ApiResponse<Void> userCreateTokenWithHttpInfo(String username) throws ApiException {
com.squareup.okhttp.Call call = userCreateTokenValidateBeforeCall(username, null, null);
return apiClient.execute(call);
public ApiResponse<AccessToken> userCreateTokenWithHttpInfo(String username, AccessTokenName accessTokenName) throws ApiException {
com.squareup.okhttp.Call call = userCreateTokenValidateBeforeCall(username, accessTokenName, null, null);
Type localVarReturnType = new TypeToken<AccessToken>(){}.getType();
return apiClient.execute(call, localVarReturnType);
}

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

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

com.squareup.okhttp.Call call = userCreateTokenValidateBeforeCall(username, progressListener, progressRequestListener);
apiClient.executeAsync(call, callback);
com.squareup.okhttp.Call call = userCreateTokenValidateBeforeCall(username, accessTokenName, progressListener, progressRequestListener);
Type localVarReturnType = new TypeToken<AccessToken>(){}.getType();
apiClient.executeAsync(call, localVarReturnType, callback);
return call;
}
/**
Expand Down Expand Up @@ -3459,22 +3469,25 @@ private com.squareup.okhttp.Call userGetTokensValidateBeforeCall(String username
* List the authenticated user&#39;s access tokens
*
* @param username username of user (required)
* @return List&lt;AccessToken&gt;
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public void userGetTokens(String username) throws ApiException {
userGetTokensWithHttpInfo(username);
public List<AccessToken> userGetTokens(String username) throws ApiException {
ApiResponse<List<AccessToken>> resp = userGetTokensWithHttpInfo(username);
return resp.getData();
}

/**
* List the authenticated user&#39;s access tokens
*
* @param username username of user (required)
* @return ApiResponse&lt;Void&gt;
* @return ApiResponse&lt;List&lt;AccessToken&gt;&gt;
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public ApiResponse<Void> userGetTokensWithHttpInfo(String username) throws ApiException {
public ApiResponse<List<AccessToken>> userGetTokensWithHttpInfo(String username) throws ApiException {
com.squareup.okhttp.Call call = userGetTokensValidateBeforeCall(username, null, null);
return apiClient.execute(call);
Type localVarReturnType = new TypeToken<List<AccessToken>>(){}.getType();
return apiClient.execute(call, localVarReturnType);
}

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

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

com.squareup.okhttp.Call call = userGetTokensValidateBeforeCall(username, progressListener, progressRequestListener);
apiClient.executeAsync(call, callback);
Type localVarReturnType = new TypeToken<List<AccessToken>>(){}.getType();
apiClient.executeAsync(call, localVarReturnType, callback);
return call;
}
/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/gitea/auth/ApiKeyAuth.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import java.util.Map;
import java.util.List;

@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2018-09-07T10:45:35.787+01:00")
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2018-10-03T21:33:54.578+01:00")
public class ApiKeyAuth implements Authentication {
private final String location;
private final String paramName;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/gitea/auth/OAuth.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import java.util.Map;
import java.util.List;

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

Expand Down
Loading

0 comments on commit a99fa0c

Please sign in to comment.