Skip to content

Commit 85e1a22

Browse files
committed
feat: Add docstring in Java (box/box-codegen#839)
1 parent 62ee7c1 commit 85e1a22

File tree

1,168 files changed

+16021
-1
lines changed

Some content is hidden

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

1,168 files changed

+16021
-1
lines changed

.codegen.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "engineHash": "f6ef0bc", "specHash": "1ed059a", "version": "10.0.0" }
1+
{ "engineHash": "47a3d7f", "specHash": "1ed059a", "version": "10.0.0" }

src/main/java/com/box/sdkgen/box/ccgauth/BoxCCGAuth.java

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,22 @@
1717

1818
public class BoxCCGAuth implements Authentication {
1919

20+
/** Configuration object of Client Credentials Grant auth. */
2021
public final CCGConfig config;
2122

23+
/**
24+
* An object responsible for storing token. If no custom implementation provided, the token will
25+
* be stored in memory.
26+
*/
2227
public final TokenStorage tokenStorage;
2328

29+
/**
30+
* The ID of the user or enterprise to authenticate as. If not provided, defaults to the
31+
* enterprise ID if set, otherwise defaults to the user ID.
32+
*/
2433
public String subjectId;
2534

35+
/** The type of the subject ID provided. Must be either 'user' or 'enterprise'. */
2636
public EnumWrapper<PostOAuth2TokenBoxSubjectTypeField> subjectType;
2737

2838
public BoxCCGAuth(CCGConfig config) {
@@ -39,10 +49,16 @@ public BoxCCGAuth(CCGConfig config) {
3949
: PostOAuth2TokenBoxSubjectTypeField.ENTERPRISE));
4050
}
4151

52+
/** Get a new access token using CCG auth */
4253
public AccessToken refreshToken() {
4354
return refreshToken(null);
4455
}
4556

57+
/**
58+
* Get a new access token using CCG auth
59+
*
60+
* @param networkSession An object to keep network session state
61+
*/
4662
@Override
4763
public AccessToken refreshToken(NetworkSession networkSession) {
4864
AuthorizationManager authManager =
@@ -61,10 +77,16 @@ public AccessToken refreshToken(NetworkSession networkSession) {
6177
return token;
6278
}
6379

80+
/** Return a current token or get a new one when not available. */
6481
public AccessToken retrieveToken() {
6582
return retrieveToken(null);
6683
}
6784

85+
/**
86+
* Return a current token or get a new one when not available.
87+
*
88+
* @param networkSession An object to keep network session state
89+
*/
6890
@Override
6991
public AccessToken retrieveToken(NetworkSession networkSession) {
7092
AccessToken oldToken = this.tokenStorage.get();
@@ -85,10 +107,30 @@ public String retrieveAuthorizationHeader(NetworkSession networkSession) {
85107
return String.join("", "Bearer ", token.getAccessToken());
86108
}
87109

110+
/**
111+
* Create a new BoxCCGAuth instance that uses the provided user ID as the subject ID. May be one
112+
* of this application's created App User. Depending on the configured User Access Level, may also
113+
* be any other App User or Managed User in the enterprise.
114+
* &lt;https://developer.box.com/en/guides/applications/&gt;
115+
* &lt;https://developer.box.com/en/guides/authentication/select/&gt;
116+
*
117+
* @param userId The id of the user to authenticate
118+
*/
88119
public BoxCCGAuth withUserSubject(String userId) {
89120
return withUserSubject(userId, new InMemoryTokenStorage());
90121
}
91122

123+
/**
124+
* Create a new BoxCCGAuth instance that uses the provided user ID as the subject ID. May be one
125+
* of this application's created App User. Depending on the configured User Access Level, may also
126+
* be any other App User or Managed User in the enterprise.
127+
* &lt;https://developer.box.com/en/guides/applications/&gt;
128+
* &lt;https://developer.box.com/en/guides/authentication/select/&gt;
129+
*
130+
* @param userId The id of the user to authenticate
131+
* @param tokenStorage Object responsible for storing token in newly created BoxCCGAuth. If no
132+
* custom implementation provided, the token will be stored in memory.
133+
*/
92134
public BoxCCGAuth withUserSubject(String userId, TokenStorage tokenStorage) {
93135
CCGConfig newConfig =
94136
new CCGConfig.Builder(this.config.getClientId(), this.config.getClientSecret())
@@ -99,10 +141,22 @@ public BoxCCGAuth withUserSubject(String userId, TokenStorage tokenStorage) {
99141
return new BoxCCGAuth(newConfig);
100142
}
101143

144+
/**
145+
* Create a new BoxCCGAuth instance that uses the provided enterprise ID as the subject ID.
146+
*
147+
* @param enterpriseId The id of the enterprise to authenticate
148+
*/
102149
public BoxCCGAuth withEnterpriseSubject(String enterpriseId) {
103150
return withEnterpriseSubject(enterpriseId, new InMemoryTokenStorage());
104151
}
105152

153+
/**
154+
* Create a new BoxCCGAuth instance that uses the provided enterprise ID as the subject ID.
155+
*
156+
* @param enterpriseId The id of the enterprise to authenticate
157+
* @param tokenStorage Object responsible for storing token in newly created BoxCCGAuth. If no
158+
* custom implementation provided, the token will be stored in memory.
159+
*/
106160
public BoxCCGAuth withEnterpriseSubject(String enterpriseId, TokenStorage tokenStorage) {
107161
CCGConfig newConfig =
108162
new CCGConfig.Builder(this.config.getClientId(), this.config.getClientSecret())
@@ -113,6 +167,18 @@ public BoxCCGAuth withEnterpriseSubject(String enterpriseId, TokenStorage tokenS
113167
return new BoxCCGAuth(newConfig);
114168
}
115169

170+
/**
171+
* Downscope access token to the provided scopes. Returning a new access token with the provided
172+
* scopes, with the original access token unchanged.
173+
*
174+
* @param scopes The scope(s) to apply to the resulting token.
175+
* @param resource The file or folder to get a downscoped token for. If None and shared_link None,
176+
* the resulting token will not be scoped down to just a single item. The resource should be a
177+
* full URL to an item, e.g. https://api.box.com/2.0/files/123456.
178+
* @param sharedLink The shared link to get a downscoped token for. If None and item None, the
179+
* resulting token will not be scoped down to just a single item.
180+
* @param networkSession An object to keep network session state
181+
*/
116182
@Override
117183
public AccessToken downscopeToken(
118184
List<String> scopes, String resource, String sharedLink, NetworkSession networkSession) {
@@ -140,10 +206,16 @@ public AccessToken downscopeToken(
140206
return downscopedToken;
141207
}
142208

209+
/** Revoke the current access token and remove it from token storage. */
143210
public void revokeToken() {
144211
revokeToken(null);
145212
}
146213

214+
/**
215+
* Revoke the current access token and remove it from token storage.
216+
*
217+
* @param networkSession An object to keep network session state
218+
*/
147219
@Override
148220
public void revokeToken(NetworkSession networkSession) {
149221
AccessToken oldToken = this.tokenStorage.get();

src/main/java/com/box/sdkgen/box/ccgauth/CCGConfig.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,25 @@
55

66
public class CCGConfig {
77

8+
/** Box API key used for identifying the application the user is authenticating with */
89
public final String clientId;
910

11+
/** Box API secret used for making auth requests. */
1012
public final String clientSecret;
1113

14+
/** The ID of the Box Developer Edition enterprise. */
1215
public String enterpriseId;
1316

17+
/**
18+
* The user id to authenticate. This value is not required. But if it is provided, then the user
19+
* will be auto-authenticated at the time of the first API call.
20+
*/
1421
public String userId;
1522

23+
/**
24+
* Object responsible for storing token. If no custom implementation provided,the token will be
25+
* stored in memory.
26+
*/
1627
public TokenStorage tokenStorage;
1728

1829
public CCGConfig(String clientId, String clientSecret) {

src/main/java/com/box/sdkgen/box/developertokenauth/BoxDeveloperTokenAuth.java

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,13 @@ public class BoxDeveloperTokenAuth implements Authentication {
1717

1818
public final String token;
1919

20+
/** Configuration object of DeveloperTokenAuth. */
2021
public DeveloperTokenConfig config;
2122

23+
/**
24+
* An object responsible for storing token. If no custom implementation provided, the token will
25+
* be stored in memory.
26+
*/
2227
public final TokenStorage tokenStorage;
2328

2429
public BoxDeveloperTokenAuth(String token) {
@@ -39,10 +44,16 @@ protected BoxDeveloperTokenAuth(Builder builder) {
3944
.build();
4045
}
4146

47+
/** Retrieves stored developer token */
4248
public AccessToken retrieveToken() {
4349
return retrieveToken(null);
4450
}
4551

52+
/**
53+
* Retrieves stored developer token
54+
*
55+
* @param networkSession An object to keep network session state
56+
*/
4657
@Override
4758
public AccessToken retrieveToken(NetworkSession networkSession) {
4859
AccessToken token = this.tokenStorage.get();
@@ -52,10 +63,16 @@ public AccessToken retrieveToken(NetworkSession networkSession) {
5263
return token;
5364
}
5465

66+
/** Developer token cannot be refreshed */
5567
public AccessToken refreshToken() {
5668
return refreshToken(null);
5769
}
5870

71+
/**
72+
* Developer token cannot be refreshed
73+
*
74+
* @param networkSession An object to keep network session state
75+
*/
5976
@Override
6077
public AccessToken refreshToken(NetworkSession networkSession) {
6178
throw new BoxSDKError("Developer token has expired. Please provide a new one.");
@@ -71,10 +88,20 @@ public String retrieveAuthorizationHeader(NetworkSession networkSession) {
7188
return String.join("", "Bearer ", token.getAccessToken());
7289
}
7390

91+
/**
92+
* Revoke an active Access Token, effectively logging a user out that has been previously
93+
* authenticated.
94+
*/
7495
public void revokeToken() {
7596
revokeToken(null);
7697
}
7798

99+
/**
100+
* Revoke an active Access Token, effectively logging a user out that has been previously
101+
* authenticated.
102+
*
103+
* @param networkSession An object to keep network session state
104+
*/
78105
@Override
79106
public void revokeToken(NetworkSession networkSession) {
80107
AccessToken token = this.tokenStorage.get();
@@ -94,6 +121,18 @@ public void revokeToken(NetworkSession networkSession) {
94121
this.tokenStorage.clear();
95122
}
96123

124+
/**
125+
* Downscope access token to the provided scopes. Returning a new access token with the provided
126+
* scopes, with the original access token unchanged.
127+
*
128+
* @param scopes The scope(s) to apply to the resulting token.
129+
* @param resource The file or folder to get a downscoped token for. If None and shared_link None,
130+
* the resulting token will not be scoped down to just a single item. The resource should be a
131+
* full URL to an item, e.g. https://api.box.com/2.0/files/123456.
132+
* @param sharedLink The shared link to get a downscoped token for. If None and item None, the
133+
* resulting token will not be scoped down to just a single item.
134+
* @param networkSession An object to keep network session state
135+
*/
97136
@Override
98137
public AccessToken downscopeToken(
99138
List<String> scopes, String resource, String sharedLink, NetworkSession networkSession) {

0 commit comments

Comments
 (0)