Skip to content

Commit

Permalink
Upgrade to OASv3 2024.08.3 (#1558)
Browse files Browse the repository at this point in the history
* Upgrade to OASv3 2024.08.3

* Fix DefaultPropertiesParser resource close issue #1556

* Updated ReadmeSnipppets

* Bump Snakeyaml from 2.2 to 2.3
  • Loading branch information
arvindkrishnakumar-okta authored Sep 20, 2024
1 parent d86dd05 commit 69d4104
Show file tree
Hide file tree
Showing 29 changed files with 21,427 additions and 2,580 deletions.
99 changes: 49 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,6 @@ These examples will help you understand how to use this library. You can also br
Once you initialize a `ApiClient` instance, you can pass this instance to the constructor of any API area clients (such as `UserApi`, `GroupApi`, `ApplicationApi` etc.).
You can start using these clients to call management APIs relevant to the chosen API area.

Note: For creation (HTTP POST or PUT operation) of models that follow inheritance (e.g. Application, Policy | PolicyRule, UserFactor), use the APIs found in their respective `ApiHelper` class (e.g. `ApplicationApiHelper`, `PolicyApiHelper`, `UserFactorApiHelper`)
to ensure safe type cast to their respective subclass types.

### Non-Admin users

Non-admin users will require to be granted specific permissions to perform certain tasks and access resources.
Expand All @@ -193,7 +190,7 @@ This library should be used with the Okta management API. For authentication, we
[//]: # (method: getUser)
```java
UserApi userApi = new UserApi(client);
userApi.getUser("userId", "true");
userApi.getUser("userId", "application/json", "true");
```
[//]: # (end: getUser)

Expand All @@ -202,7 +199,7 @@ userApi.getUser("userId", "true");
[//]: # (method: listAllUsers)
```java
UserApi userApi = new UserApi(client);
List<User> users = userApi.listUsers(null, null, 5, null, null, null, null);
List<User> users = userApi.listUsers("application/json", null, null, 5, null, null, null, null);

// stream
users.stream()
Expand All @@ -221,10 +218,10 @@ For more examples of handling collections see the [pagination](#pagination) sect
UserApi userApi = new UserApi(client);

// search by email
List<User> users = userApi.listUsers(null, null, 5, null, "profile.email eq \"jcoder@example.com\"", null, null);
List<User> users = userApi.listUsers("application/json", null, null, 5, null, "profile.email eq \"jcoder@example.com\"", null, null);

// filter parameter
userApi.listUsers(null, null, null, "status eq \"ACTIVE\"",null, null, null);
userApi.listUsers("application/json",null, null, null, "status eq \"ACTIVE\"",null, null, null);
```
[//]: # (end: userSearch)

Expand Down Expand Up @@ -295,10 +292,10 @@ userApi.updateUser(user.getId(), updateUserRequest, true);
UserApi userApi = new UserApi(client);

// deactivate first
userApi.deactivateUser(user.getId(), false);
userApi.deleteUser(user.getId(), false, null);

// then delete
userApi.deleteUser(user.getId(), false);
// see https://developer.okta.com/docs/api/openapi/okta-management/management/tag/User/#tag/User/operation/deleteUser
userApi.deleteUser(user.getId(), false, null);
```
[//]: # (end: deleteUser)

Expand Down Expand Up @@ -418,7 +415,7 @@ swaApplicationSettingsApplication.buttonField("btn-login")
SwaApplicationSettings swaApplicationSettings = new SwaApplicationSettings();
swaApplicationSettings.app(swaApplicationSettingsApplication);
BrowserPluginApplication browserPluginApplication = new BrowserPluginApplication();
browserPluginApplication.name("template_swa");
browserPluginApplication.name(BrowserPluginApplication.NameEnum.SWA);
browserPluginApplication.label("Sample Plugin App");
browserPluginApplication.settings(swaApplicationSettings);

Expand All @@ -442,7 +439,7 @@ BookmarkApplication bookmarkApp = (BookmarkApplication) applicationApi.getApplic
[//]: # (method: listApplications)
```java
ApplicationApi applicationApi = new ApplicationApi(client);
List<Application> applications = applicationApi.listApplications(null, null, null, null, null, true);
List<Application> applications = applicationApi.listApplications(null, null, true, null, null, null, true);
```
[//]: # (end: listApplications)

Expand All @@ -451,8 +448,8 @@ List<Application> applications = applicationApi.listApplications(null, null, nul
[//]: # (method: getPolicy)
```java
PolicyApi policyApi = new PolicyApi(client);
MultifactorEnrollmentPolicy mfaPolicy =
(MultifactorEnrollmentPolicy) policyApi.getPolicy("mfa-policy-id", null);
Policy policy =
policyApi.getPolicy("policy-id", null);
```
[//]: # (end: getPolicy)

Expand All @@ -461,7 +458,7 @@ MultifactorEnrollmentPolicy mfaPolicy =
[//]: # (method: listPolicies)
```java
PolicyApi policyApi = new PolicyApi(client);
List<Policy> policies = policyApi.listPolicies(PolicyType.PASSWORD.name(), LifecycleStatus.ACTIVE.name(), null, null, null, null);
List<Policy> policies = policyApi.listPolicies(PolicyType.PASSWORD.name(), LifecycleStatus.ACTIVE.name(), null, null, null, null, null, null);
```
[//]: # (end: listPolicies)

Expand All @@ -472,7 +469,7 @@ SystemLogApi systemLogApi = new SystemLogApi(client);

// use a filter (start date, end date, filter, or query, sort order) all options are nullable
List<LogEvent> logEvents =
systemLogApi.listLogEvents(null, null, null, "interestingURI.com", 100, "ASCENDING", null);
systemLogApi.listLogEvents(null, null, null, "interestingURI.com", null, 100, "ASCENDING");
```
[//]: # (end: listSysLogs)

Expand All @@ -484,39 +481,41 @@ Not every API endpoint is represented by a method in this library. You can call
```java
ApiClient apiClient = buildApiClient("orgBaseUrl", "apiKey");

// Create a BookmarkApplication
BookmarkApplication bookmarkApplication = new BookmarkApplication();
bookmarkApplication.setName("bookmark");
bookmarkApplication.setLabel("Sample Bookmark App");
bookmarkApplication.setSignOnMode(ApplicationSignOnMode.BOOKMARK);
BookmarkApplicationSettings bookmarkApplicationSettings = new BookmarkApplicationSettings();
BookmarkApplicationSettingsApplication bookmarkApplicationSettingsApplication =
new BookmarkApplicationSettingsApplication();
bookmarkApplicationSettingsApplication.setUrl("https://example.com/bookmark.htm");
bookmarkApplicationSettingsApplication.setRequestIntegration(false);
bookmarkApplicationSettings.setApp(bookmarkApplicationSettingsApplication);
bookmarkApplication.setSettings(bookmarkApplicationSettings);
StringJoiner localVarQueryStringJoiner = new StringJoiner("&");
List<Pair> localVarQueryParams = new ArrayList<>();
List<Pair> localVarCollectionQueryParams = new ArrayList<>();
Map<String, String> localVarHeaderParams = new HashMap<>();
Map<String, String> localVarCookieParams = new HashMap<>();
Map<String, Object> localVarFormParams = new HashMap<>();
BookmarkApplication createdApp = apiClient.invokeAPI(
"/api/v1/apps", // path
HttpMethod.POST.name(), // http method
localVarQueryParams, // query params
localVarCollectionQueryParams, // collection query params
localVarQueryStringJoiner.toString(),
bookmarkApplication, // request body
localVarHeaderParams, // header params
localVarCookieParams, // cookie params
localVarFormParams, // form params
MediaType.APPLICATION_JSON_VALUE, // accept
MediaType.APPLICATION_JSON_VALUE, // content type
new String[]{ "apiToken", "oauth2" }, // auth names
new TypeReference<BookmarkApplication>() { } // return type
);
// Create a User
String email = "joe.coder+" + UUID.randomUUID() + "@example.com";
UserProfile userProfile = new com.okta.sdk.resource.model.UserProfile()
.firstName("Joe")
.lastName("Coder")
.email(email)
.mobilePhone("1234567890")
.login(email);
com.okta.sdk.resource.model.CreateUserRequest createUserRequest = new com.okta.sdk.resource.model.CreateUserRequest();
createUserRequest.setProfile(userProfile);
List<com.okta.sdk.resource.client.Pair> queryParams = new ArrayList<com.okta.sdk.resource.client.Pair>();
queryParams.addAll(client.parameterToPair("activate", "true"));
queryParams.addAll(client.parameterToPair("provider", null));
queryParams.addAll(client.parameterToPair("nextLogin", null));
List<com.okta.sdk.resource.client.Pair> collectionQueryParams = new ArrayList<com.okta.sdk.resource.client.Pair>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> cookieParams = new HashMap<String, String>();
Map<String, Object> formParams = new HashMap<String, Object>();
TypeReference<com.okta.sdk.resource.model.User> returnType = new TypeReference<com.okta.sdk.resource.model.User>() {
};

com.okta.sdk.resource.model.User user = client.invokeAPI(
"/api/v1/users",
"POST",
queryParams,
collectionQueryParams,
new StringJoiner("&").toString(),
createUserRequest,
headerParams,
cookieParams,
formParams,
"application/json",
"application/json",
new String[] { "apiToken", "oauth2" },
returnType);
```
[//]: # (end: callAnotherEndpoint)

Expand All @@ -530,7 +529,7 @@ UserApi userApi = new UserApi(client);
List<User> users = new ArrayList<>();
String after = null;
do {
users.addAll(userApi.listUsers(null, after, 200, null, null, null, null));
users.addAll(userApi.listUsers("application/json",null, after, 200, null, null, null, null));
after = PaginationUtil.getAfter(userApi.getApiClient());
} while (StringUtils.isNotBlank(after));
```
Expand Down
4 changes: 2 additions & 2 deletions api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>com.okta.sdk</groupId>
<artifactId>okta-sdk-root</artifactId>
<version>18.0.1-SNAPSHOT</version>
<version>19.0.0-SNAPSHOT</version>
</parent>

<artifactId>okta-sdk-api</artifactId>
Expand All @@ -36,7 +36,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<swagger-annotations.version>1.6.8</swagger-annotations.version>
<openapi-generator.version>7.7.0</openapi-generator.version>
<openapi-generator.version>7.8.0</openapi-generator.version>
<jackson-databind-nullable.version>0.2.6</jackson-databind-nullable.version>
<jakarta-annotation.version>2.1.1</jakarta-annotation.version>
<jsr305.version>3.0.2</jsr305.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ static OIDCApplicationBuilder instance() {

OIDCApplicationBuilder setClientId(String clientId);

OIDCApplicationBuilder setLoginUrl(String loginUrl);

OIDCApplicationBuilder setRedirectUrl(String redirectUrl);

OIDCApplicationBuilder setClientSecret(String clientSecret);

OIDCApplicationBuilder setAutoKeyRotation(Boolean autoKeyRotation);
Expand Down
3 changes: 0 additions & 3 deletions api/src/main/java/com/okta/sdk/resource/user/UserBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.okta.sdk.resource.model.AuthenticationProvider;
import com.okta.sdk.resource.model.User;
import com.okta.sdk.resource.model.UserNextLogin;
import com.okta.sdk.resource.model.UserType;

import java.util.Arrays;
import java.util.List;
Expand Down Expand Up @@ -107,8 +106,6 @@ static UserBuilder instance() {

UserBuilder setProvider(AuthenticationProvider provider);

UserBuilder setType(UserType userType);

UserBuilder setType(String userTypeId);

default UserBuilder setGroups(String... groupIds) {
Expand Down
2 changes: 1 addition & 1 deletion api/src/main/resources/custom_templates/pojo.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public {{classname}}() { {{#parent}}{{#parcelableModel}}
public {{classname}} put{{nameInCamelCase}}Item(String key, {{{items.datatypeWithEnum}}} {{name}}Item) {
{{#vendorExtensions.x-is-jackson-optional-nullable}}
if (this.{{name}} == null || !this.{{name}}.isPresent()) {
this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{{defaultValue}}});
this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of(null);
}
try {
this.{{name}}.get().put(key, {{name}}Item);
Expand Down
2 changes: 1 addition & 1 deletion coverage/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>com.okta.sdk</groupId>
<artifactId>okta-sdk-root</artifactId>
<version>18.0.1-SNAPSHOT</version>
<version>19.0.0-SNAPSHOT</version>
</parent>

<artifactId>okta-sdk-coverage</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>com.okta.sdk</groupId>
<artifactId>okta-sdk-root</artifactId>
<version>18.0.1-SNAPSHOT</version>
<version>19.0.0-SNAPSHOT</version>
</parent>

<artifactId>okta-sdk-examples</artifactId>
Expand Down
9 changes: 8 additions & 1 deletion examples/quickstart/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>com.okta.sdk</groupId>
<artifactId>okta-sdk-examples</artifactId>
<version>18.0.1-SNAPSHOT</version>
<version>19.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down Expand Up @@ -73,6 +73,13 @@
<mainClass>quickstart.Quickstart</mainClass>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>

Expand Down
18 changes: 10 additions & 8 deletions examples/quickstart/src/main/java/quickstart/Quickstart.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public static void main(String[] args) throws ApiException {

ClientBuilder builder;
ApiClient client;
Group group = null;
User user = null;
com.okta.sdk.resource.model.Group group = null;
com.okta.sdk.resource.model.User user = null;

UserApi userApi = null;
GroupApi groupApi = null;
Expand Down Expand Up @@ -89,13 +89,13 @@ public static void main(String[] args) throws ApiException {
println("User created with ID: " + userId);

// You can look up user by ID
println("User lookup by ID: "+ Objects.requireNonNull(userApi.getUser(userId, "false").getProfile()).getLogin());
println("User lookup by ID: "+ Objects.requireNonNull(userApi.getUser(userId, null,"false").getProfile()).getLogin());

// or by Email
println("User lookup by Email: "+ Objects.requireNonNull(userApi.getUser(email, "false").getProfile()).getLogin());
println("User lookup by Email: "+ Objects.requireNonNull(userApi.getUser(email, null,"false").getProfile()).getLogin());

// get the list of users
List<User> users = userApi.listUsers(null, null, null, "status eq \"ACTIVE\"", null, null, null);
List<com.okta.sdk.resource.model.User> users = userApi.listUsers(null, null, null, null, "status eq \"ACTIVE\"", null, null, null);

// get the first user in the collection
println("First user in collection: " + Objects.requireNonNull(Objects.requireNonNull(users.stream().findFirst().orElse(null)).getProfile()).getEmail());
Expand All @@ -111,10 +111,12 @@ public static void main(String[] args) throws ApiException {

// deactivate (if de-provisioned) and delete user
if (user != null) {
if (!Objects.equals(user.getStatus(), UserStatus.DEPROVISIONED)) {
userApi.deactivateUser(user.getId(), false);
if (!Objects.equals(user.getStatus(), com.okta.sdk.resource.model.UserStatus.DEPROVISIONED)) {
// This operation on a User that has not been deactivated/deprovisioned causes that User to be deactivated.
userApi.deleteUser(user.getId(), false, null);
}
userApi.deleteUser(user.getId(), false);
// A second delete operation is required to delete the User.
userApi.deleteUser(user.getId(), false, null);
}

// delete group
Expand Down
Loading

0 comments on commit 69d4104

Please sign in to comment.