diff --git a/README.md b/README.md index 5702363..5fdd3ff 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,10 @@ In your Maven `pom.xml` file, add: See the above URL for the latest version of the API client. +## Support + +The best place to get support using this library is through the [ngrok Slack Community](https://ngrok.com/slack). If you find any bugs, please contribute by opening a [new GitHub issue](https://github.com/ngrok/ngrok-api-java/issues/new/choose). + ## Documentation All objects, methods and properties are documented with Javadoc for diff --git a/pom.xml b/pom.xml index 14ea6a9..8fdfc1f 100644 --- a/pom.xml +++ b/pom.xml @@ -1,10 +1,11 @@ - + 4.0.0 com.ngrok ngrok-api-java - 0.6.1-SNAPSHOT + 0.1.0-SNAPSHOT ngrok Java API client ngrok API client for Java applications diff --git a/src/main/java/com/ngrok/Ngrok.java b/src/main/java/com/ngrok/Ngrok.java index 80d1bea..fed937d 100644 --- a/src/main/java/com/ngrok/Ngrok.java +++ b/src/main/java/com/ngrok/Ngrok.java @@ -82,6 +82,28 @@ public class Ngrok { return new ApiKeys(this.apiClient); } + /** + * Creates a service client for ApplicationSessions. + * + * See also https://ngrok.com/docs/api#api-application-sessions. + * + * @return a service client + */ + public ApplicationSessions applicationSessions() { + return new ApplicationSessions(this.apiClient); + } + + /** + * Creates a service client for ApplicationUsers. + * + * See also https://ngrok.com/docs/api#api-application-users. + * + * @return a service client + */ + public ApplicationUsers applicationUsers() { + return new ApplicationUsers(this.apiClient); + } + /** * Certificate Authorities are x509 certificates that are used to sign other * x509 certificates. Attach a Certificate Authority to the Mutual TLS module diff --git a/src/main/java/com/ngrok/definitions/ApiKey.java b/src/main/java/com/ngrok/definitions/ApiKey.java index 58f47ba..b45f100 100644 --- a/src/main/java/com/ngrok/definitions/ApiKey.java +++ b/src/main/java/com/ngrok/definitions/ApiKey.java @@ -31,6 +31,9 @@ public class ApiKey { @JsonProperty("token") @JsonInclude(value = JsonInclude.Include.NON_ABSENT) private final Optional token; + @JsonProperty("owner_id") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final Optional ownerId; /** * Creates a new instance of {@link ApiKey}. @@ -41,6 +44,7 @@ public class ApiKey { * @param metadata arbitrary user-defined data of this API key. optional, max 4096 bytes * @param createdAt timestamp when the api key was created, RFC 3339 format * @param token the bearer token that can be placed into the Authorization header to authenticate request to the ngrok API. This value is only available one time, on the API response from key creation. Otherwise it is null. + * @param ownerId If supplied at credential creation, ownership will be assigned to the specified User or Bot. Only admins may specify an owner other than themselves. Defaults to the authenticated User or Bot. */ @JsonCreator public ApiKey( @@ -49,7 +53,8 @@ public class ApiKey { @JsonProperty("description") final String description, @JsonProperty("metadata") final String metadata, @JsonProperty("created_at") final java.time.OffsetDateTime createdAt, - @JsonProperty("token") final Optional token + @JsonProperty("token") final Optional token, + @JsonProperty("owner_id") final Optional ownerId ) { this.id = Objects.requireNonNull(id, "id is required"); this.uri = Objects.requireNonNull(uri, "uri is required"); @@ -57,6 +62,7 @@ public class ApiKey { this.metadata = Objects.requireNonNull(metadata, "metadata is required"); this.createdAt = Objects.requireNonNull(createdAt, "createdAt is required"); this.token = token != null ? token : Optional.empty(); + this.ownerId = ownerId != null ? ownerId : Optional.empty(); } /** @@ -116,6 +122,17 @@ public class ApiKey { return this.token; } + /** + * If supplied at credential creation, ownership will be assigned to the specified + * User or Bot. Only admins may specify an owner other than themselves. Defaults to + * the authenticated User or Bot. + * + * @return the value of the property as a {@link String} wrapped in an {@link Optional} + */ + public Optional getOwnerId() { + return this.ownerId; + } + @Override public boolean equals(final Object o) { if (this == o) { @@ -132,7 +149,8 @@ public class ApiKey { this.description.equals(other.description)&& this.metadata.equals(other.metadata)&& this.createdAt.equals(other.createdAt)&& - this.token.equals(other.token); + this.token.equals(other.token)&& + this.ownerId.equals(other.ownerId); } @@ -144,7 +162,8 @@ public class ApiKey { this.description, this.metadata, this.createdAt, - this.token + this.token, + this.ownerId ); } @@ -157,6 +176,7 @@ public class ApiKey { "', metadata='" + this.metadata + "', createdAt='" + this.createdAt + "', token='" + this.token.orElse("(null)") + + "', ownerId='" + this.ownerId.orElse("(null)") + "'}"; } } diff --git a/src/main/java/com/ngrok/definitions/ApplicationSession.java b/src/main/java/com/ngrok/definitions/ApplicationSession.java new file mode 100644 index 0000000..d714a2c --- /dev/null +++ b/src/main/java/com/ngrok/definitions/ApplicationSession.java @@ -0,0 +1,249 @@ +package com.ngrok.definitions; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.Objects; +import java.util.Optional; + +/** + * A class encapsulating the {@link ApplicationSession} resource. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class ApplicationSession { + @JsonProperty("id") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final String id; + @JsonProperty("uri") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final java.net.URI uri; + @JsonProperty("public_url") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final java.net.URI publicUrl; + @JsonProperty("browser_session") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final BrowserSession browserSession; + @JsonProperty("application_user") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final Optional applicationUser; + @JsonProperty("created_at") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final java.time.OffsetDateTime createdAt; + @JsonProperty("last_active") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final java.time.OffsetDateTime lastActive; + @JsonProperty("expires_at") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final java.time.OffsetDateTime expiresAt; + @JsonProperty("endpoint") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final Optional endpoint; + @JsonProperty("edge") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final Optional edge; + @JsonProperty("route") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final Optional route; + + /** + * Creates a new instance of {@link ApplicationSession}. + * + * @param id unique application session resource identifier + * @param uri URI of the application session API resource + * @param publicUrl URL of the hostport served by this endpoint + * @param browserSession browser session details of the application session + * @param applicationUser application user this session is associated with + * @param createdAt timestamp when the user was created in RFC 3339 format + * @param lastActive timestamp when the user was last active in RFC 3339 format + * @param expiresAt timestamp when session expires in RFC 3339 format + * @param endpoint ephemeral endpoint this session is associated with + * @param edge edge this session is associated with, null if the endpoint is agent-initiated + * @param route route this session is associated with, null if the endpoint is agent-initiated + */ + @JsonCreator + public ApplicationSession( + @JsonProperty("id") final String id, + @JsonProperty("uri") final java.net.URI uri, + @JsonProperty("public_url") final java.net.URI publicUrl, + @JsonProperty("browser_session") final BrowserSession browserSession, + @JsonProperty("application_user") final Optional applicationUser, + @JsonProperty("created_at") final java.time.OffsetDateTime createdAt, + @JsonProperty("last_active") final java.time.OffsetDateTime lastActive, + @JsonProperty("expires_at") final java.time.OffsetDateTime expiresAt, + @JsonProperty("endpoint") final Optional endpoint, + @JsonProperty("edge") final Optional edge, + @JsonProperty("route") final Optional route + ) { + this.id = Objects.requireNonNull(id, "id is required"); + this.uri = Objects.requireNonNull(uri, "uri is required"); + this.publicUrl = Objects.requireNonNull(publicUrl, "publicUrl is required"); + this.browserSession = Objects.requireNonNull(browserSession, "browserSession is required"); + this.applicationUser = applicationUser != null ? applicationUser : Optional.empty(); + this.createdAt = Objects.requireNonNull(createdAt, "createdAt is required"); + this.lastActive = Objects.requireNonNull(lastActive, "lastActive is required"); + this.expiresAt = Objects.requireNonNull(expiresAt, "expiresAt is required"); + this.endpoint = endpoint != null ? endpoint : Optional.empty(); + this.edge = edge != null ? edge : Optional.empty(); + this.route = route != null ? route : Optional.empty(); + } + + /** + * unique application session resource identifier + * + * @return the value of the property as a {@link String} + */ + public String getId() { + return this.id; + } + + /** + * URI of the application session API resource + * + * @return the value of the property as a {@link java.net.URI} + */ + public java.net.URI getUri() { + return this.uri; + } + + /** + * URL of the hostport served by this endpoint + * + * @return the value of the property as a {@link java.net.URI} + */ + public java.net.URI getPublicUrl() { + return this.publicUrl; + } + + /** + * browser session details of the application session + * + * @return the value of the property as a {@link BrowserSession} + */ + public BrowserSession getBrowserSession() { + return this.browserSession; + } + + /** + * application user this session is associated with + * + * @return the value of the property as a {@link Ref} wrapped in an {@link Optional} + */ + public Optional getApplicationUser() { + return this.applicationUser; + } + + /** + * timestamp when the user was created in RFC 3339 format + * + * @return the value of the property as a {@link java.time.OffsetDateTime} + */ + public java.time.OffsetDateTime getCreatedAt() { + return this.createdAt; + } + + /** + * timestamp when the user was last active in RFC 3339 format + * + * @return the value of the property as a {@link java.time.OffsetDateTime} + */ + public java.time.OffsetDateTime getLastActive() { + return this.lastActive; + } + + /** + * timestamp when session expires in RFC 3339 format + * + * @return the value of the property as a {@link java.time.OffsetDateTime} + */ + public java.time.OffsetDateTime getExpiresAt() { + return this.expiresAt; + } + + /** + * ephemeral endpoint this session is associated with + * + * @return the value of the property as a {@link Ref} wrapped in an {@link Optional} + */ + public Optional getEndpoint() { + return this.endpoint; + } + + /** + * edge this session is associated with, null if the endpoint is agent-initiated + * + * @return the value of the property as a {@link Ref} wrapped in an {@link Optional} + */ + public Optional getEdge() { + return this.edge; + } + + /** + * route this session is associated with, null if the endpoint is agent-initiated + * + * @return the value of the property as a {@link Ref} wrapped in an {@link Optional} + */ + public Optional getRoute() { + return this.route; + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + final ApplicationSession other = (ApplicationSession) o; + return + this.id.equals(other.id)&& + this.uri.equals(other.uri)&& + this.publicUrl.equals(other.publicUrl)&& + this.browserSession.equals(other.browserSession)&& + this.applicationUser.equals(other.applicationUser)&& + this.createdAt.equals(other.createdAt)&& + this.lastActive.equals(other.lastActive)&& + this.expiresAt.equals(other.expiresAt)&& + this.endpoint.equals(other.endpoint)&& + this.edge.equals(other.edge)&& + this.route.equals(other.route); + + } + + @Override + public int hashCode() { + return Objects.hash( + this.id, + this.uri, + this.publicUrl, + this.browserSession, + this.applicationUser, + this.createdAt, + this.lastActive, + this.expiresAt, + this.endpoint, + this.edge, + this.route + ); + } + + @Override + public String toString() { + return "ApplicationSession{" + + "id='" + this.id + + "', uri='" + this.uri + + "', publicUrl='" + this.publicUrl + + "', browserSession='" + this.browserSession + + "', applicationUser='" + this.applicationUser.map(Object::toString).orElse("(null)") + + "', createdAt='" + this.createdAt + + "', lastActive='" + this.lastActive + + "', expiresAt='" + this.expiresAt + + "', endpoint='" + this.endpoint.map(Object::toString).orElse("(null)") + + "', edge='" + this.edge.map(Object::toString).orElse("(null)") + + "', route='" + this.route.map(Object::toString).orElse("(null)") + + "'}"; + } +} diff --git a/src/main/java/com/ngrok/definitions/ApplicationSessionList.java b/src/main/java/com/ngrok/definitions/ApplicationSessionList.java new file mode 100644 index 0000000..3b45e3f --- /dev/null +++ b/src/main/java/com/ngrok/definitions/ApplicationSessionList.java @@ -0,0 +1,105 @@ +package com.ngrok.definitions; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.Objects; +import java.util.Optional; + +/** + * A class encapsulating the {@link ApplicationSessionList} resource. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class ApplicationSessionList implements Pageable { + @JsonProperty("application_sessions") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final java.util.List applicationSessions; + @JsonProperty("uri") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final java.net.URI uri; + @JsonProperty("next_page_uri") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final Optional nextPageUri; + + /** + * Creates a new instance of {@link ApplicationSessionList}. + * + * @param applicationSessions list of all application sessions on this account + * @param uri URI of the application session list API resource + * @param nextPageUri URI of the next page, or null if there is no next page + */ + @JsonCreator + public ApplicationSessionList( + @JsonProperty("application_sessions") final java.util.List applicationSessions, + @JsonProperty("uri") final java.net.URI uri, + @JsonProperty("next_page_uri") final Optional nextPageUri + ) { + this.applicationSessions = applicationSessions != null ? applicationSessions : java.util.Collections.emptyList(); + this.uri = Objects.requireNonNull(uri, "uri is required"); + this.nextPageUri = nextPageUri != null ? nextPageUri : Optional.empty(); + } + + /** + * list of all application sessions on this account + * + * @return the value of the property as a {@link java.util.List} of {@link ApplicationSession} + */ + public java.util.List getApplicationSessions() { + return this.applicationSessions; + } + + /** + * URI of the application session list API resource + * + * @return the value of the property as a {@link java.net.URI} + */ + public java.net.URI getUri() { + return this.uri; + } + + /** + * URI of the next page, or null if there is no next page + * + * @return the value of the property as a {@link java.net.URI} wrapped in an {@link Optional} + */ + public Optional getNextPageUri() { + return this.nextPageUri; + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + final ApplicationSessionList other = (ApplicationSessionList) o; + return + this.applicationSessions.equals(other.applicationSessions)&& + this.uri.equals(other.uri)&& + this.nextPageUri.equals(other.nextPageUri); + + } + + @Override + public int hashCode() { + return Objects.hash( + this.applicationSessions, + this.uri, + this.nextPageUri + ); + } + + @Override + public String toString() { + return "ApplicationSessionList{" + + "applicationSessions='" + this.applicationSessions + + "', uri='" + this.uri + + "', nextPageUri='" + this.nextPageUri.map(Object::toString).orElse("(null)") + + "'}"; + } +} diff --git a/src/main/java/com/ngrok/definitions/ApplicationUser.java b/src/main/java/com/ngrok/definitions/ApplicationUser.java new file mode 100644 index 0000000..ec53ad8 --- /dev/null +++ b/src/main/java/com/ngrok/definitions/ApplicationUser.java @@ -0,0 +1,231 @@ +package com.ngrok.definitions; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.Objects; +import java.util.Optional; + +/** + * A class encapsulating the {@link ApplicationUser} resource. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class ApplicationUser { + @JsonProperty("id") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final String id; + @JsonProperty("uri") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final java.net.URI uri; + @JsonProperty("identity_provider") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final IdentityProvider identityProvider; + @JsonProperty("provider_user_id") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final String providerUserId; + @JsonProperty("username") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final String username; + @JsonProperty("email") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final String email; + @JsonProperty("name") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final String name; + @JsonProperty("created_at") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final java.time.OffsetDateTime createdAt; + @JsonProperty("last_active") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final java.time.OffsetDateTime lastActive; + @JsonProperty("last_login") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final java.time.OffsetDateTime lastLogin; + + /** + * Creates a new instance of {@link ApplicationUser}. + * + * @param id unique application user resource identifier + * @param uri URI of the application user API resource + * @param identityProvider identity provider that the user authenticated with + * @param providerUserId unique user identifier + * @param username user username + * @param email user email + * @param name user common name + * @param createdAt timestamp when the user was created in RFC 3339 format + * @param lastActive timestamp when the user was last active in RFC 3339 format + * @param lastLogin timestamp when the user last signed-in in RFC 3339 format + */ + @JsonCreator + public ApplicationUser( + @JsonProperty("id") final String id, + @JsonProperty("uri") final java.net.URI uri, + @JsonProperty("identity_provider") final IdentityProvider identityProvider, + @JsonProperty("provider_user_id") final String providerUserId, + @JsonProperty("username") final String username, + @JsonProperty("email") final String email, + @JsonProperty("name") final String name, + @JsonProperty("created_at") final java.time.OffsetDateTime createdAt, + @JsonProperty("last_active") final java.time.OffsetDateTime lastActive, + @JsonProperty("last_login") final java.time.OffsetDateTime lastLogin + ) { + this.id = Objects.requireNonNull(id, "id is required"); + this.uri = Objects.requireNonNull(uri, "uri is required"); + this.identityProvider = Objects.requireNonNull(identityProvider, "identityProvider is required"); + this.providerUserId = Objects.requireNonNull(providerUserId, "providerUserId is required"); + this.username = Objects.requireNonNull(username, "username is required"); + this.email = Objects.requireNonNull(email, "email is required"); + this.name = Objects.requireNonNull(name, "name is required"); + this.createdAt = Objects.requireNonNull(createdAt, "createdAt is required"); + this.lastActive = Objects.requireNonNull(lastActive, "lastActive is required"); + this.lastLogin = Objects.requireNonNull(lastLogin, "lastLogin is required"); + } + + /** + * unique application user resource identifier + * + * @return the value of the property as a {@link String} + */ + public String getId() { + return this.id; + } + + /** + * URI of the application user API resource + * + * @return the value of the property as a {@link java.net.URI} + */ + public java.net.URI getUri() { + return this.uri; + } + + /** + * identity provider that the user authenticated with + * + * @return the value of the property as a {@link IdentityProvider} + */ + public IdentityProvider getIdentityProvider() { + return this.identityProvider; + } + + /** + * unique user identifier + * + * @return the value of the property as a {@link String} + */ + public String getProviderUserId() { + return this.providerUserId; + } + + /** + * user username + * + * @return the value of the property as a {@link String} + */ + public String getUsername() { + return this.username; + } + + /** + * user email + * + * @return the value of the property as a {@link String} + */ + public String getEmail() { + return this.email; + } + + /** + * user common name + * + * @return the value of the property as a {@link String} + */ + public String getName() { + return this.name; + } + + /** + * timestamp when the user was created in RFC 3339 format + * + * @return the value of the property as a {@link java.time.OffsetDateTime} + */ + public java.time.OffsetDateTime getCreatedAt() { + return this.createdAt; + } + + /** + * timestamp when the user was last active in RFC 3339 format + * + * @return the value of the property as a {@link java.time.OffsetDateTime} + */ + public java.time.OffsetDateTime getLastActive() { + return this.lastActive; + } + + /** + * timestamp when the user last signed-in in RFC 3339 format + * + * @return the value of the property as a {@link java.time.OffsetDateTime} + */ + public java.time.OffsetDateTime getLastLogin() { + return this.lastLogin; + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + final ApplicationUser other = (ApplicationUser) o; + return + this.id.equals(other.id)&& + this.uri.equals(other.uri)&& + this.identityProvider.equals(other.identityProvider)&& + this.providerUserId.equals(other.providerUserId)&& + this.username.equals(other.username)&& + this.email.equals(other.email)&& + this.name.equals(other.name)&& + this.createdAt.equals(other.createdAt)&& + this.lastActive.equals(other.lastActive)&& + this.lastLogin.equals(other.lastLogin); + + } + + @Override + public int hashCode() { + return Objects.hash( + this.id, + this.uri, + this.identityProvider, + this.providerUserId, + this.username, + this.email, + this.name, + this.createdAt, + this.lastActive, + this.lastLogin + ); + } + + @Override + public String toString() { + return "ApplicationUser{" + + "id='" + this.id + + "', uri='" + this.uri + + "', identityProvider='" + this.identityProvider + + "', providerUserId='" + this.providerUserId + + "', username='" + this.username + + "', email='" + this.email + + "', name='" + this.name + + "', createdAt='" + this.createdAt + + "', lastActive='" + this.lastActive + + "', lastLogin='" + this.lastLogin + + "'}"; + } +} diff --git a/src/main/java/com/ngrok/definitions/ApplicationUserList.java b/src/main/java/com/ngrok/definitions/ApplicationUserList.java new file mode 100644 index 0000000..803ce17 --- /dev/null +++ b/src/main/java/com/ngrok/definitions/ApplicationUserList.java @@ -0,0 +1,105 @@ +package com.ngrok.definitions; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.Objects; +import java.util.Optional; + +/** + * A class encapsulating the {@link ApplicationUserList} resource. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class ApplicationUserList implements Pageable { + @JsonProperty("application_users") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final java.util.List applicationUsers; + @JsonProperty("uri") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final java.net.URI uri; + @JsonProperty("next_page_uri") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final Optional nextPageUri; + + /** + * Creates a new instance of {@link ApplicationUserList}. + * + * @param applicationUsers list of all application users on this account + * @param uri URI of the application user list API resource + * @param nextPageUri URI of the next page, or null if there is no next page + */ + @JsonCreator + public ApplicationUserList( + @JsonProperty("application_users") final java.util.List applicationUsers, + @JsonProperty("uri") final java.net.URI uri, + @JsonProperty("next_page_uri") final Optional nextPageUri + ) { + this.applicationUsers = applicationUsers != null ? applicationUsers : java.util.Collections.emptyList(); + this.uri = Objects.requireNonNull(uri, "uri is required"); + this.nextPageUri = nextPageUri != null ? nextPageUri : Optional.empty(); + } + + /** + * list of all application users on this account + * + * @return the value of the property as a {@link java.util.List} of {@link ApplicationUser} + */ + public java.util.List getApplicationUsers() { + return this.applicationUsers; + } + + /** + * URI of the application user list API resource + * + * @return the value of the property as a {@link java.net.URI} + */ + public java.net.URI getUri() { + return this.uri; + } + + /** + * URI of the next page, or null if there is no next page + * + * @return the value of the property as a {@link java.net.URI} wrapped in an {@link Optional} + */ + public Optional getNextPageUri() { + return this.nextPageUri; + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + final ApplicationUserList other = (ApplicationUserList) o; + return + this.applicationUsers.equals(other.applicationUsers)&& + this.uri.equals(other.uri)&& + this.nextPageUri.equals(other.nextPageUri); + + } + + @Override + public int hashCode() { + return Objects.hash( + this.applicationUsers, + this.uri, + this.nextPageUri + ); + } + + @Override + public String toString() { + return "ApplicationUserList{" + + "applicationUsers='" + this.applicationUsers + + "', uri='" + this.uri + + "', nextPageUri='" + this.nextPageUri.map(Object::toString).orElse("(null)") + + "'}"; + } +} diff --git a/src/main/java/com/ngrok/definitions/BrowserSession.java b/src/main/java/com/ngrok/definitions/BrowserSession.java new file mode 100644 index 0000000..5e2a3e3 --- /dev/null +++ b/src/main/java/com/ngrok/definitions/BrowserSession.java @@ -0,0 +1,105 @@ +package com.ngrok.definitions; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.Objects; +import java.util.Optional; + +/** + * A class encapsulating the {@link BrowserSession} resource. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class BrowserSession { + @JsonProperty("user_agent") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final UserAgent userAgent; + @JsonProperty("ip_address") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final String ipAddress; + @JsonProperty("location") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final Optional location; + + /** + * Creates a new instance of {@link BrowserSession}. + * + * @param userAgent HTTP User-Agent data + * @param ipAddress IP address + * @param location IP geolocation data + */ + @JsonCreator + public BrowserSession( + @JsonProperty("user_agent") final UserAgent userAgent, + @JsonProperty("ip_address") final String ipAddress, + @JsonProperty("location") final Optional location + ) { + this.userAgent = Objects.requireNonNull(userAgent, "userAgent is required"); + this.ipAddress = Objects.requireNonNull(ipAddress, "ipAddress is required"); + this.location = location != null ? location : Optional.empty(); + } + + /** + * HTTP User-Agent data + * + * @return the value of the property as a {@link UserAgent} + */ + public UserAgent getUserAgent() { + return this.userAgent; + } + + /** + * IP address + * + * @return the value of the property as a {@link String} + */ + public String getIpAddress() { + return this.ipAddress; + } + + /** + * IP geolocation data + * + * @return the value of the property as a {@link Location} wrapped in an {@link Optional} + */ + public Optional getLocation() { + return this.location; + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + final BrowserSession other = (BrowserSession) o; + return + this.userAgent.equals(other.userAgent)&& + this.ipAddress.equals(other.ipAddress)&& + this.location.equals(other.location); + + } + + @Override + public int hashCode() { + return Objects.hash( + this.userAgent, + this.ipAddress, + this.location + ); + } + + @Override + public String toString() { + return "BrowserSession{" + + "userAgent='" + this.userAgent + + "', ipAddress='" + this.ipAddress + + "', location='" + this.location.map(Object::toString).orElse("(null)") + + "'}"; + } +} diff --git a/src/main/java/com/ngrok/definitions/Credential.java b/src/main/java/com/ngrok/definitions/Credential.java index 01e71d0..5829a6e 100644 --- a/src/main/java/com/ngrok/definitions/Credential.java +++ b/src/main/java/com/ngrok/definitions/Credential.java @@ -34,6 +34,9 @@ public class Credential { @JsonProperty("acl") @JsonInclude(value = JsonInclude.Include.NON_ABSENT) private final java.util.List acl; + @JsonProperty("owner_id") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final Optional ownerId; /** * Creates a new instance of {@link Credential}. @@ -44,7 +47,8 @@ public class Credential { * @param description human-readable description of who or what will use the credential to authenticate. Optional, max 255 bytes. * @param metadata arbitrary user-defined machine-readable data of this credential. Optional, max 4096 bytes. * @param token the credential's authtoken that can be used to authenticate an ngrok agent. This value is only available one time, on the API response from credential creation, otherwise it is null. - * @param acl optional list of ACL rules. If unspecified, the credential will have no restrictions. The only allowed ACL rule at this time is the bind rule. The bind rule allows the caller to restrict what domains and addresses the token is allowed to bind. For example, to allow the token to open a tunnel on example.ngrok.io your ACL would include the rule bind:example.ngrok.io. Bind rules may specify a leading wildcard to match multiple domains with a common suffix. For example, you may specify a rule of bind:*.example.com which will allow x.example.com, y.example.com, *.example.com, etc. A rule of '*' is equivalent to no acl at all and will explicitly permit all actions. + * @param acl optional list of ACL rules. If unspecified, the credential will have no restrictions. The only allowed ACL rule at this time is the bind rule. The bind rule allows the caller to restrict what domains, addresses, and labels the token is allowed to bind. For example, to allow the token to open a tunnel on example.ngrok.io your ACL would include the rule bind:example.ngrok.io. Bind rules for domains may specify a leading wildcard to match multiple domains with a common suffix. For example, you may specify a rule of bind:*.example.com which will allow x.example.com, y.example.com, *.example.com, etc. Bind rules for labels may specify a wildcard key and/or value to match multiple labels. For example, you may specify a rule of bind:*=example which will allow x=example, y=example, etc. A rule of '*' is equivalent to no acl at all and will explicitly permit all actions. + * @param ownerId If supplied at credential creation, ownership will be assigned to the specified User or Bot. Only admins may specify an owner other than themselves. Defaults to the authenticated User or Bot. */ @JsonCreator public Credential( @@ -54,7 +58,8 @@ public class Credential { @JsonProperty("description") final String description, @JsonProperty("metadata") final String metadata, @JsonProperty("token") final Optional token, - @JsonProperty("acl") final java.util.List acl + @JsonProperty("acl") final java.util.List acl, + @JsonProperty("owner_id") final Optional ownerId ) { this.id = Objects.requireNonNull(id, "id is required"); this.uri = Objects.requireNonNull(uri, "uri is required"); @@ -63,6 +68,7 @@ public class Credential { this.metadata = Objects.requireNonNull(metadata, "metadata is required"); this.token = token != null ? token : Optional.empty(); this.acl = acl != null ? acl : java.util.Collections.emptyList(); + this.ownerId = ownerId != null ? ownerId : Optional.empty(); } /** @@ -126,15 +132,18 @@ public class Credential { /** * optional list of ACL rules. If unspecified, the credential will have no * restrictions. The only allowed ACL rule at this time is the bind - * rule. The bind rule allows the caller to restrict what domains and - * addresses the token is allowed to bind. For example, to allow the token to open - * a tunnel on example.ngrok.io your ACL would include the rule - * bind:example.ngrok.io. Bind rules may specify a leading wildcard to - * match multiple domains with a common suffix. For example, you may specify a rule - * of bind:*.example.com which will allow x.example.com, - * y.example.com, *.example.com, etc. A rule of - * '*' is equivalent to no acl at all and will explicitly - * permit all actions. + * rule. The bind rule allows the caller to restrict what domains, + * addresses, and labels the token is allowed to bind. For example, to allow the + * token to open a tunnel on example.ngrok.io your ACL would include the rule + * bind:example.ngrok.io. Bind rules for domains may specify a leading + * wildcard to match multiple domains with a common suffix. For example, you may + * specify a rule of bind:*.example.com which will allow + * x.example.com, y.example.com, + * *.example.com, etc. Bind rules for labels may specify a wildcard + * key and/or value to match multiple labels. For example, you may specify a rule + * of bind:*=example which will allow x=example, + * y=example, etc. A rule of '*' is equivalent to + * no acl at all and will explicitly permit all actions. * * @return the value of the property as a {@link java.util.List} of {@link String} */ @@ -142,6 +151,17 @@ public class Credential { return this.acl; } + /** + * If supplied at credential creation, ownership will be assigned to the specified + * User or Bot. Only admins may specify an owner other than themselves. Defaults to + * the authenticated User or Bot. + * + * @return the value of the property as a {@link String} wrapped in an {@link Optional} + */ + public Optional getOwnerId() { + return this.ownerId; + } + @Override public boolean equals(final Object o) { if (this == o) { @@ -159,7 +179,8 @@ public class Credential { this.description.equals(other.description)&& this.metadata.equals(other.metadata)&& this.token.equals(other.token)&& - this.acl.equals(other.acl); + this.acl.equals(other.acl)&& + this.ownerId.equals(other.ownerId); } @@ -172,7 +193,8 @@ public class Credential { this.description, this.metadata, this.token, - this.acl + this.acl, + this.ownerId ); } @@ -186,6 +208,7 @@ public class Credential { "', metadata='" + this.metadata + "', token='" + this.token.orElse("(null)") + "', acl='" + this.acl + + "', ownerId='" + this.ownerId.orElse("(null)") + "'}"; } } diff --git a/src/main/java/com/ngrok/definitions/EndpointOAuthAmazon.java b/src/main/java/com/ngrok/definitions/EndpointOAuthAmazon.java new file mode 100644 index 0000000..c20bf40 --- /dev/null +++ b/src/main/java/com/ngrok/definitions/EndpointOAuthAmazon.java @@ -0,0 +1,292 @@ +package com.ngrok.definitions; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.Objects; +import java.util.Optional; + +/** + * A class encapsulating the {@link EndpointOAuthAmazon} resource. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class EndpointOAuthAmazon { + /** + * Builder class for {@link EndpointOAuthAmazon}. + */ + public static class Builder { + private Optional clientId = Optional.empty(); + private Optional clientSecret = Optional.empty(); + private java.util.List scopes = java.util.Collections.emptyList(); + private java.util.List emailAddresses = java.util.Collections.emptyList(); + private java.util.List emailDomains = java.util.Collections.emptyList(); + + private Builder( + ) { + } + + /** + * Sets the client_id property + * + * @param clientId the value of the client_id parameter as a {@link String} + * @return this builder instance + */ + public Builder clientId(final String clientId) { + this.clientId = Optional.of(Objects.requireNonNull(clientId, "clientId is required")); + return this; + } + + /** + * Sets the client_id property + * + * @param clientId the value of the client_id parameter as a {@link String}, wrapped in an {@link Optional} + * @return this builder instance + */ + public Builder clientId(final Optional clientId) { + this.clientId = Objects.requireNonNull(clientId, "clientId is required"); + return this; + } + + /** + * Sets the client_secret property + * + * @param clientSecret the value of the client_secret parameter as a {@link String} + * @return this builder instance + */ + public Builder clientSecret(final String clientSecret) { + this.clientSecret = Optional.of(Objects.requireNonNull(clientSecret, "clientSecret is required")); + return this; + } + + /** + * Sets the client_secret property + * + * @param clientSecret the value of the client_secret parameter as a {@link String}, wrapped in an {@link Optional} + * @return this builder instance + */ + public Builder clientSecret(final Optional clientSecret) { + this.clientSecret = Objects.requireNonNull(clientSecret, "clientSecret is required"); + return this; + } + + /** + * Sets the scopes property + * + * @param scopes the value of the scopes parameter as a {@link java.util.List} of {@link String} + * @return this builder instance + */ + public Builder scopes(final java.util.List scopes) { + this.scopes = Objects.requireNonNull(scopes, "scopes is required"); + return this; + } + + /** + * Sets the scopes property + * + * @param scopes the value of the scopes parameter as a {@link java.util.List} of {@link String}, wrapped in an {@link Optional} + * @return this builder instance + */ + public Builder scopes(final Optional> scopes) { + this.scopes = Objects.requireNonNull(scopes, "scopes is required").orElse(java.util.Collections.emptyList()); + return this; + } + + /** + * Sets the email_addresses property + * + * @param emailAddresses the value of the email_addresses parameter as a {@link java.util.List} of {@link String} + * @return this builder instance + */ + public Builder emailAddresses(final java.util.List emailAddresses) { + this.emailAddresses = Objects.requireNonNull(emailAddresses, "emailAddresses is required"); + return this; + } + + /** + * Sets the email_addresses property + * + * @param emailAddresses the value of the email_addresses parameter as a {@link java.util.List} of {@link String}, wrapped in an {@link Optional} + * @return this builder instance + */ + public Builder emailAddresses(final Optional> emailAddresses) { + this.emailAddresses = Objects.requireNonNull(emailAddresses, "emailAddresses is required").orElse(java.util.Collections.emptyList()); + return this; + } + + /** + * Sets the email_domains property + * + * @param emailDomains the value of the email_domains parameter as a {@link java.util.List} of {@link String} + * @return this builder instance + */ + public Builder emailDomains(final java.util.List emailDomains) { + this.emailDomains = Objects.requireNonNull(emailDomains, "emailDomains is required"); + return this; + } + + /** + * Sets the email_domains property + * + * @param emailDomains the value of the email_domains parameter as a {@link java.util.List} of {@link String}, wrapped in an {@link Optional} + * @return this builder instance + */ + public Builder emailDomains(final Optional> emailDomains) { + this.emailDomains = Objects.requireNonNull(emailDomains, "emailDomains is required").orElse(java.util.Collections.emptyList()); + return this; + } + + /** + * Constructs the {@link EndpointOAuthAmazon} instance. + * + * @return a new {@link EndpointOAuthAmazon} + */ + public EndpointOAuthAmazon build() { + return new EndpointOAuthAmazon( + this.clientId, + this.clientSecret, + this.scopes, + this.emailAddresses, + this.emailDomains + ); + } + } + + /** + * Creates a new builder for the {@link EndpointOAuthAmazon} type. + * + * @return a new {@link Builder} + */ + public static Builder newBuilder( + ) { + return new Builder ( + ); + } + + @JsonProperty("client_id") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final Optional clientId; + @JsonProperty("client_secret") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final Optional clientSecret; + @JsonProperty("scopes") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final java.util.List scopes; + @JsonProperty("email_addresses") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final java.util.List emailAddresses; + @JsonProperty("email_domains") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final java.util.List emailDomains; + + /** + * Creates a new instance of {@link EndpointOAuthAmazon}. + * + * @param clientId the value of the client_id parameter as a {@link String} + * @param clientSecret the value of the client_secret parameter as a {@link String} + * @param scopes the value of the scopes parameter as a {@link java.util.List} of {@link String} + * @param emailAddresses the value of the email_addresses parameter as a {@link java.util.List} of {@link String} + * @param emailDomains the value of the email_domains parameter as a {@link java.util.List} of {@link String} + */ + @JsonCreator + private EndpointOAuthAmazon( + @JsonProperty("client_id") final Optional clientId, + @JsonProperty("client_secret") final Optional clientSecret, + @JsonProperty("scopes") final java.util.List scopes, + @JsonProperty("email_addresses") final java.util.List emailAddresses, + @JsonProperty("email_domains") final java.util.List emailDomains + ) { + this.clientId = clientId != null ? clientId : Optional.empty(); + this.clientSecret = clientSecret != null ? clientSecret : Optional.empty(); + this.scopes = scopes != null ? scopes : java.util.Collections.emptyList(); + this.emailAddresses = emailAddresses != null ? emailAddresses : java.util.Collections.emptyList(); + this.emailDomains = emailDomains != null ? emailDomains : java.util.Collections.emptyList(); + } + + /** + * Fetches the value of the clientId property. + * + * @return the value of the property as a {@link String} wrapped in an {@link Optional} + */ + public Optional getClientId() { + return this.clientId; + } + + /** + * Fetches the value of the clientSecret property. + * + * @return the value of the property as a {@link String} wrapped in an {@link Optional} + */ + public Optional getClientSecret() { + return this.clientSecret; + } + + /** + * Fetches the value of the scopes property. + * + * @return the value of the property as a {@link java.util.List} of {@link String} + */ + public java.util.List getScopes() { + return this.scopes; + } + + /** + * Fetches the value of the emailAddresses property. + * + * @return the value of the property as a {@link java.util.List} of {@link String} + */ + public java.util.List getEmailAddresses() { + return this.emailAddresses; + } + + /** + * Fetches the value of the emailDomains property. + * + * @return the value of the property as a {@link java.util.List} of {@link String} + */ + public java.util.List getEmailDomains() { + return this.emailDomains; + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + final EndpointOAuthAmazon other = (EndpointOAuthAmazon) o; + return + this.clientId.equals(other.clientId)&& + this.clientSecret.equals(other.clientSecret)&& + this.scopes.equals(other.scopes)&& + this.emailAddresses.equals(other.emailAddresses)&& + this.emailDomains.equals(other.emailDomains); + + } + + @Override + public int hashCode() { + return Objects.hash( + this.clientId, + this.clientSecret, + this.scopes, + this.emailAddresses, + this.emailDomains + ); + } + + @Override + public String toString() { + return "EndpointOAuthAmazon{" + + "clientId='" + this.clientId.orElse("(null)") + + "', clientSecret='" + this.clientSecret.orElse("(null)") + + "', scopes='" + this.scopes + + "', emailAddresses='" + this.emailAddresses + + "', emailDomains='" + this.emailDomains + + "'}"; + } +} diff --git a/src/main/java/com/ngrok/definitions/EndpointOAuthGitHub.java b/src/main/java/com/ngrok/definitions/EndpointOAuthGitHub.java index b203cd9..cfc5943 100644 --- a/src/main/java/com/ngrok/definitions/EndpointOAuthGitHub.java +++ b/src/main/java/com/ngrok/definitions/EndpointOAuthGitHub.java @@ -19,11 +19,11 @@ public class EndpointOAuthGitHub { public static class Builder { private Optional clientId = Optional.empty(); private Optional clientSecret = Optional.empty(); - private java.util.List scopes = java.util.Collections.emptyList(); - private java.util.List emailAddresses = java.util.Collections.emptyList(); - private java.util.List emailDomains = java.util.Collections.emptyList(); - private java.util.List teams = java.util.Collections.emptyList(); - private java.util.List organizations = java.util.Collections.emptyList(); + private Optional> scopes = Optional.empty(); + private Optional> emailAddresses = Optional.empty(); + private Optional> emailDomains = Optional.empty(); + private Optional> teams = Optional.empty(); + private Optional> organizations = Optional.empty(); private Builder( ) { @@ -95,7 +95,7 @@ public class EndpointOAuthGitHub { * @return this builder instance */ public Builder scopes(final java.util.List scopes) { - this.scopes = Objects.requireNonNull(scopes, "scopes is required"); + this.scopes = Optional.of(Objects.requireNonNull(scopes, "scopes is required")); return this; } @@ -109,7 +109,7 @@ public class EndpointOAuthGitHub { * @return this builder instance */ public Builder scopes(final Optional> scopes) { - this.scopes = Objects.requireNonNull(scopes, "scopes is required").orElse(java.util.Collections.emptyList()); + this.scopes = Objects.requireNonNull(scopes, "scopes is required"); return this; } @@ -121,7 +121,7 @@ public class EndpointOAuthGitHub { * @return this builder instance */ public Builder emailAddresses(final java.util.List emailAddresses) { - this.emailAddresses = Objects.requireNonNull(emailAddresses, "emailAddresses is required"); + this.emailAddresses = Optional.of(Objects.requireNonNull(emailAddresses, "emailAddresses is required")); return this; } @@ -133,7 +133,7 @@ public class EndpointOAuthGitHub { * @return this builder instance */ public Builder emailAddresses(final Optional> emailAddresses) { - this.emailAddresses = Objects.requireNonNull(emailAddresses, "emailAddresses is required").orElse(java.util.Collections.emptyList()); + this.emailAddresses = Objects.requireNonNull(emailAddresses, "emailAddresses is required"); return this; } @@ -145,7 +145,7 @@ public class EndpointOAuthGitHub { * @return this builder instance */ public Builder emailDomains(final java.util.List emailDomains) { - this.emailDomains = Objects.requireNonNull(emailDomains, "emailDomains is required"); + this.emailDomains = Optional.of(Objects.requireNonNull(emailDomains, "emailDomains is required")); return this; } @@ -157,7 +157,7 @@ public class EndpointOAuthGitHub { * @return this builder instance */ public Builder emailDomains(final Optional> emailDomains) { - this.emailDomains = Objects.requireNonNull(emailDomains, "emailDomains is required").orElse(java.util.Collections.emptyList()); + this.emailDomains = Objects.requireNonNull(emailDomains, "emailDomains is required"); return this; } @@ -171,7 +171,7 @@ public class EndpointOAuthGitHub { * @return this builder instance */ public Builder teams(final java.util.List teams) { - this.teams = Objects.requireNonNull(teams, "teams is required"); + this.teams = Optional.of(Objects.requireNonNull(teams, "teams is required")); return this; } @@ -185,7 +185,7 @@ public class EndpointOAuthGitHub { * @return this builder instance */ public Builder teams(final Optional> teams) { - this.teams = Objects.requireNonNull(teams, "teams is required").orElse(java.util.Collections.emptyList()); + this.teams = Objects.requireNonNull(teams, "teams is required"); return this; } @@ -198,7 +198,7 @@ public class EndpointOAuthGitHub { * @return this builder instance */ public Builder organizations(final java.util.List organizations) { - this.organizations = Objects.requireNonNull(organizations, "organizations is required"); + this.organizations = Optional.of(Objects.requireNonNull(organizations, "organizations is required")); return this; } @@ -211,7 +211,7 @@ public class EndpointOAuthGitHub { * @return this builder instance */ public Builder organizations(final Optional> organizations) { - this.organizations = Objects.requireNonNull(organizations, "organizations is required").orElse(java.util.Collections.emptyList()); + this.organizations = Objects.requireNonNull(organizations, "organizations is required"); return this; } @@ -252,19 +252,19 @@ public class EndpointOAuthGitHub { private final Optional clientSecret; @JsonProperty("scopes") @JsonInclude(value = JsonInclude.Include.NON_ABSENT) - private final java.util.List scopes; + private final Optional> scopes; @JsonProperty("email_addresses") @JsonInclude(value = JsonInclude.Include.NON_ABSENT) - private final java.util.List emailAddresses; + private final Optional> emailAddresses; @JsonProperty("email_domains") @JsonInclude(value = JsonInclude.Include.NON_ABSENT) - private final java.util.List emailDomains; + private final Optional> emailDomains; @JsonProperty("teams") @JsonInclude(value = JsonInclude.Include.NON_ABSENT) - private final java.util.List teams; + private final Optional> teams; @JsonProperty("organizations") @JsonInclude(value = JsonInclude.Include.NON_ABSENT) - private final java.util.List organizations; + private final Optional> organizations; /** * Creates a new instance of {@link EndpointOAuthGitHub}. @@ -281,19 +281,19 @@ public class EndpointOAuthGitHub { private EndpointOAuthGitHub( @JsonProperty("client_id") final Optional clientId, @JsonProperty("client_secret") final Optional clientSecret, - @JsonProperty("scopes") final java.util.List scopes, - @JsonProperty("email_addresses") final java.util.List emailAddresses, - @JsonProperty("email_domains") final java.util.List emailDomains, - @JsonProperty("teams") final java.util.List teams, - @JsonProperty("organizations") final java.util.List organizations + @JsonProperty("scopes") final Optional> scopes, + @JsonProperty("email_addresses") final Optional> emailAddresses, + @JsonProperty("email_domains") final Optional> emailDomains, + @JsonProperty("teams") final Optional> teams, + @JsonProperty("organizations") final Optional> organizations ) { this.clientId = clientId != null ? clientId : Optional.empty(); this.clientSecret = clientSecret != null ? clientSecret : Optional.empty(); - this.scopes = scopes != null ? scopes : java.util.Collections.emptyList(); - this.emailAddresses = emailAddresses != null ? emailAddresses : java.util.Collections.emptyList(); - this.emailDomains = emailDomains != null ? emailDomains : java.util.Collections.emptyList(); - this.teams = teams != null ? teams : java.util.Collections.emptyList(); - this.organizations = organizations != null ? organizations : java.util.Collections.emptyList(); + this.scopes = scopes != null ? scopes : Optional.empty(); + this.emailAddresses = emailAddresses != null ? emailAddresses : Optional.empty(); + this.emailDomains = emailDomains != null ? emailDomains : Optional.empty(); + this.teams = teams != null ? teams : Optional.empty(); + this.organizations = organizations != null ? organizations : Optional.empty(); } /** @@ -326,9 +326,9 @@ public class EndpointOAuthGitHub { * oauth app (i.e. you must pass both client_id and * client_secret to set scopes) * - * @return the value of the property as a {@link java.util.List} of {@link String} + * @return the value of the property as a {@link java.util.List} of {@link String} wrapped in an {@link Optional} */ - public java.util.List getScopes() { + public Optional> getScopes() { return this.scopes; } @@ -336,9 +336,9 @@ public class EndpointOAuthGitHub { * a list of email addresses of users authenticated by identity provider who are * allowed access to the endpoint * - * @return the value of the property as a {@link java.util.List} of {@link String} + * @return the value of the property as a {@link java.util.List} of {@link String} wrapped in an {@link Optional} */ - public java.util.List getEmailAddresses() { + public Optional> getEmailAddresses() { return this.emailAddresses; } @@ -346,9 +346,9 @@ public class EndpointOAuthGitHub { * a list of email domains of users authenticated by identity provider who are * allowed access to the endpoint * - * @return the value of the property as a {@link java.util.List} of {@link String} + * @return the value of the property as a {@link java.util.List} of {@link String} wrapped in an {@link Optional} */ - public java.util.List getEmailDomains() { + public Optional> getEmailDomains() { return this.emailDomains; } @@ -358,9 +358,9 @@ public class EndpointOAuthGitHub { * 'slug' format qualified with the org name, e.g. * org-name/team-name * - * @return the value of the property as a {@link java.util.List} of {@link String} + * @return the value of the property as a {@link java.util.List} of {@link String} wrapped in an {@link Optional} */ - public java.util.List getTeams() { + public Optional> getTeams() { return this.teams; } @@ -369,9 +369,9 @@ public class EndpointOAuthGitHub { * organizations will be allowed access. identifiers should be the * organization's 'slug' * - * @return the value of the property as a {@link java.util.List} of {@link String} + * @return the value of the property as a {@link java.util.List} of {@link String} wrapped in an {@link Optional} */ - public java.util.List getOrganizations() { + public Optional> getOrganizations() { return this.organizations; } @@ -414,11 +414,11 @@ public class EndpointOAuthGitHub { return "EndpointOAuthGitHub{" + "clientId='" + this.clientId.orElse("(null)") + "', clientSecret='" + this.clientSecret.orElse("(null)") + - "', scopes='" + this.scopes + - "', emailAddresses='" + this.emailAddresses + - "', emailDomains='" + this.emailDomains + - "', teams='" + this.teams + - "', organizations='" + this.organizations + + "', scopes='" + this.scopes.map(Object::toString).orElse("(null)") + + "', emailAddresses='" + this.emailAddresses.map(Object::toString).orElse("(null)") + + "', emailDomains='" + this.emailDomains.map(Object::toString).orElse("(null)") + + "', teams='" + this.teams.map(Object::toString).orElse("(null)") + + "', organizations='" + this.organizations.map(Object::toString).orElse("(null)") + "'}"; } } diff --git a/src/main/java/com/ngrok/definitions/EndpointOAuthGitLab.java b/src/main/java/com/ngrok/definitions/EndpointOAuthGitLab.java new file mode 100644 index 0000000..bcd02ab --- /dev/null +++ b/src/main/java/com/ngrok/definitions/EndpointOAuthGitLab.java @@ -0,0 +1,292 @@ +package com.ngrok.definitions; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.Objects; +import java.util.Optional; + +/** + * A class encapsulating the {@link EndpointOAuthGitLab} resource. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class EndpointOAuthGitLab { + /** + * Builder class for {@link EndpointOAuthGitLab}. + */ + public static class Builder { + private Optional clientId = Optional.empty(); + private Optional clientSecret = Optional.empty(); + private java.util.List scopes = java.util.Collections.emptyList(); + private java.util.List emailAddresses = java.util.Collections.emptyList(); + private java.util.List emailDomains = java.util.Collections.emptyList(); + + private Builder( + ) { + } + + /** + * Sets the client_id property + * + * @param clientId the value of the client_id parameter as a {@link String} + * @return this builder instance + */ + public Builder clientId(final String clientId) { + this.clientId = Optional.of(Objects.requireNonNull(clientId, "clientId is required")); + return this; + } + + /** + * Sets the client_id property + * + * @param clientId the value of the client_id parameter as a {@link String}, wrapped in an {@link Optional} + * @return this builder instance + */ + public Builder clientId(final Optional clientId) { + this.clientId = Objects.requireNonNull(clientId, "clientId is required"); + return this; + } + + /** + * Sets the client_secret property + * + * @param clientSecret the value of the client_secret parameter as a {@link String} + * @return this builder instance + */ + public Builder clientSecret(final String clientSecret) { + this.clientSecret = Optional.of(Objects.requireNonNull(clientSecret, "clientSecret is required")); + return this; + } + + /** + * Sets the client_secret property + * + * @param clientSecret the value of the client_secret parameter as a {@link String}, wrapped in an {@link Optional} + * @return this builder instance + */ + public Builder clientSecret(final Optional clientSecret) { + this.clientSecret = Objects.requireNonNull(clientSecret, "clientSecret is required"); + return this; + } + + /** + * Sets the scopes property + * + * @param scopes the value of the scopes parameter as a {@link java.util.List} of {@link String} + * @return this builder instance + */ + public Builder scopes(final java.util.List scopes) { + this.scopes = Objects.requireNonNull(scopes, "scopes is required"); + return this; + } + + /** + * Sets the scopes property + * + * @param scopes the value of the scopes parameter as a {@link java.util.List} of {@link String}, wrapped in an {@link Optional} + * @return this builder instance + */ + public Builder scopes(final Optional> scopes) { + this.scopes = Objects.requireNonNull(scopes, "scopes is required").orElse(java.util.Collections.emptyList()); + return this; + } + + /** + * Sets the email_addresses property + * + * @param emailAddresses the value of the email_addresses parameter as a {@link java.util.List} of {@link String} + * @return this builder instance + */ + public Builder emailAddresses(final java.util.List emailAddresses) { + this.emailAddresses = Objects.requireNonNull(emailAddresses, "emailAddresses is required"); + return this; + } + + /** + * Sets the email_addresses property + * + * @param emailAddresses the value of the email_addresses parameter as a {@link java.util.List} of {@link String}, wrapped in an {@link Optional} + * @return this builder instance + */ + public Builder emailAddresses(final Optional> emailAddresses) { + this.emailAddresses = Objects.requireNonNull(emailAddresses, "emailAddresses is required").orElse(java.util.Collections.emptyList()); + return this; + } + + /** + * Sets the email_domains property + * + * @param emailDomains the value of the email_domains parameter as a {@link java.util.List} of {@link String} + * @return this builder instance + */ + public Builder emailDomains(final java.util.List emailDomains) { + this.emailDomains = Objects.requireNonNull(emailDomains, "emailDomains is required"); + return this; + } + + /** + * Sets the email_domains property + * + * @param emailDomains the value of the email_domains parameter as a {@link java.util.List} of {@link String}, wrapped in an {@link Optional} + * @return this builder instance + */ + public Builder emailDomains(final Optional> emailDomains) { + this.emailDomains = Objects.requireNonNull(emailDomains, "emailDomains is required").orElse(java.util.Collections.emptyList()); + return this; + } + + /** + * Constructs the {@link EndpointOAuthGitLab} instance. + * + * @return a new {@link EndpointOAuthGitLab} + */ + public EndpointOAuthGitLab build() { + return new EndpointOAuthGitLab( + this.clientId, + this.clientSecret, + this.scopes, + this.emailAddresses, + this.emailDomains + ); + } + } + + /** + * Creates a new builder for the {@link EndpointOAuthGitLab} type. + * + * @return a new {@link Builder} + */ + public static Builder newBuilder( + ) { + return new Builder ( + ); + } + + @JsonProperty("client_id") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final Optional clientId; + @JsonProperty("client_secret") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final Optional clientSecret; + @JsonProperty("scopes") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final java.util.List scopes; + @JsonProperty("email_addresses") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final java.util.List emailAddresses; + @JsonProperty("email_domains") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final java.util.List emailDomains; + + /** + * Creates a new instance of {@link EndpointOAuthGitLab}. + * + * @param clientId the value of the client_id parameter as a {@link String} + * @param clientSecret the value of the client_secret parameter as a {@link String} + * @param scopes the value of the scopes parameter as a {@link java.util.List} of {@link String} + * @param emailAddresses the value of the email_addresses parameter as a {@link java.util.List} of {@link String} + * @param emailDomains the value of the email_domains parameter as a {@link java.util.List} of {@link String} + */ + @JsonCreator + private EndpointOAuthGitLab( + @JsonProperty("client_id") final Optional clientId, + @JsonProperty("client_secret") final Optional clientSecret, + @JsonProperty("scopes") final java.util.List scopes, + @JsonProperty("email_addresses") final java.util.List emailAddresses, + @JsonProperty("email_domains") final java.util.List emailDomains + ) { + this.clientId = clientId != null ? clientId : Optional.empty(); + this.clientSecret = clientSecret != null ? clientSecret : Optional.empty(); + this.scopes = scopes != null ? scopes : java.util.Collections.emptyList(); + this.emailAddresses = emailAddresses != null ? emailAddresses : java.util.Collections.emptyList(); + this.emailDomains = emailDomains != null ? emailDomains : java.util.Collections.emptyList(); + } + + /** + * Fetches the value of the clientId property. + * + * @return the value of the property as a {@link String} wrapped in an {@link Optional} + */ + public Optional getClientId() { + return this.clientId; + } + + /** + * Fetches the value of the clientSecret property. + * + * @return the value of the property as a {@link String} wrapped in an {@link Optional} + */ + public Optional getClientSecret() { + return this.clientSecret; + } + + /** + * Fetches the value of the scopes property. + * + * @return the value of the property as a {@link java.util.List} of {@link String} + */ + public java.util.List getScopes() { + return this.scopes; + } + + /** + * Fetches the value of the emailAddresses property. + * + * @return the value of the property as a {@link java.util.List} of {@link String} + */ + public java.util.List getEmailAddresses() { + return this.emailAddresses; + } + + /** + * Fetches the value of the emailDomains property. + * + * @return the value of the property as a {@link java.util.List} of {@link String} + */ + public java.util.List getEmailDomains() { + return this.emailDomains; + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + final EndpointOAuthGitLab other = (EndpointOAuthGitLab) o; + return + this.clientId.equals(other.clientId)&& + this.clientSecret.equals(other.clientSecret)&& + this.scopes.equals(other.scopes)&& + this.emailAddresses.equals(other.emailAddresses)&& + this.emailDomains.equals(other.emailDomains); + + } + + @Override + public int hashCode() { + return Objects.hash( + this.clientId, + this.clientSecret, + this.scopes, + this.emailAddresses, + this.emailDomains + ); + } + + @Override + public String toString() { + return "EndpointOAuthGitLab{" + + "clientId='" + this.clientId.orElse("(null)") + + "', clientSecret='" + this.clientSecret.orElse("(null)") + + "', scopes='" + this.scopes + + "', emailAddresses='" + this.emailAddresses + + "', emailDomains='" + this.emailDomains + + "'}"; + } +} diff --git a/src/main/java/com/ngrok/definitions/EndpointOAuthLinkedIn.java b/src/main/java/com/ngrok/definitions/EndpointOAuthLinkedIn.java new file mode 100644 index 0000000..c102ceb --- /dev/null +++ b/src/main/java/com/ngrok/definitions/EndpointOAuthLinkedIn.java @@ -0,0 +1,292 @@ +package com.ngrok.definitions; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.Objects; +import java.util.Optional; + +/** + * A class encapsulating the {@link EndpointOAuthLinkedIn} resource. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class EndpointOAuthLinkedIn { + /** + * Builder class for {@link EndpointOAuthLinkedIn}. + */ + public static class Builder { + private Optional clientId = Optional.empty(); + private Optional clientSecret = Optional.empty(); + private java.util.List scopes = java.util.Collections.emptyList(); + private java.util.List emailAddresses = java.util.Collections.emptyList(); + private java.util.List emailDomains = java.util.Collections.emptyList(); + + private Builder( + ) { + } + + /** + * Sets the client_id property + * + * @param clientId the value of the client_id parameter as a {@link String} + * @return this builder instance + */ + public Builder clientId(final String clientId) { + this.clientId = Optional.of(Objects.requireNonNull(clientId, "clientId is required")); + return this; + } + + /** + * Sets the client_id property + * + * @param clientId the value of the client_id parameter as a {@link String}, wrapped in an {@link Optional} + * @return this builder instance + */ + public Builder clientId(final Optional clientId) { + this.clientId = Objects.requireNonNull(clientId, "clientId is required"); + return this; + } + + /** + * Sets the client_secret property + * + * @param clientSecret the value of the client_secret parameter as a {@link String} + * @return this builder instance + */ + public Builder clientSecret(final String clientSecret) { + this.clientSecret = Optional.of(Objects.requireNonNull(clientSecret, "clientSecret is required")); + return this; + } + + /** + * Sets the client_secret property + * + * @param clientSecret the value of the client_secret parameter as a {@link String}, wrapped in an {@link Optional} + * @return this builder instance + */ + public Builder clientSecret(final Optional clientSecret) { + this.clientSecret = Objects.requireNonNull(clientSecret, "clientSecret is required"); + return this; + } + + /** + * Sets the scopes property + * + * @param scopes the value of the scopes parameter as a {@link java.util.List} of {@link String} + * @return this builder instance + */ + public Builder scopes(final java.util.List scopes) { + this.scopes = Objects.requireNonNull(scopes, "scopes is required"); + return this; + } + + /** + * Sets the scopes property + * + * @param scopes the value of the scopes parameter as a {@link java.util.List} of {@link String}, wrapped in an {@link Optional} + * @return this builder instance + */ + public Builder scopes(final Optional> scopes) { + this.scopes = Objects.requireNonNull(scopes, "scopes is required").orElse(java.util.Collections.emptyList()); + return this; + } + + /** + * Sets the email_addresses property + * + * @param emailAddresses the value of the email_addresses parameter as a {@link java.util.List} of {@link String} + * @return this builder instance + */ + public Builder emailAddresses(final java.util.List emailAddresses) { + this.emailAddresses = Objects.requireNonNull(emailAddresses, "emailAddresses is required"); + return this; + } + + /** + * Sets the email_addresses property + * + * @param emailAddresses the value of the email_addresses parameter as a {@link java.util.List} of {@link String}, wrapped in an {@link Optional} + * @return this builder instance + */ + public Builder emailAddresses(final Optional> emailAddresses) { + this.emailAddresses = Objects.requireNonNull(emailAddresses, "emailAddresses is required").orElse(java.util.Collections.emptyList()); + return this; + } + + /** + * Sets the email_domains property + * + * @param emailDomains the value of the email_domains parameter as a {@link java.util.List} of {@link String} + * @return this builder instance + */ + public Builder emailDomains(final java.util.List emailDomains) { + this.emailDomains = Objects.requireNonNull(emailDomains, "emailDomains is required"); + return this; + } + + /** + * Sets the email_domains property + * + * @param emailDomains the value of the email_domains parameter as a {@link java.util.List} of {@link String}, wrapped in an {@link Optional} + * @return this builder instance + */ + public Builder emailDomains(final Optional> emailDomains) { + this.emailDomains = Objects.requireNonNull(emailDomains, "emailDomains is required").orElse(java.util.Collections.emptyList()); + return this; + } + + /** + * Constructs the {@link EndpointOAuthLinkedIn} instance. + * + * @return a new {@link EndpointOAuthLinkedIn} + */ + public EndpointOAuthLinkedIn build() { + return new EndpointOAuthLinkedIn( + this.clientId, + this.clientSecret, + this.scopes, + this.emailAddresses, + this.emailDomains + ); + } + } + + /** + * Creates a new builder for the {@link EndpointOAuthLinkedIn} type. + * + * @return a new {@link Builder} + */ + public static Builder newBuilder( + ) { + return new Builder ( + ); + } + + @JsonProperty("client_id") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final Optional clientId; + @JsonProperty("client_secret") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final Optional clientSecret; + @JsonProperty("scopes") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final java.util.List scopes; + @JsonProperty("email_addresses") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final java.util.List emailAddresses; + @JsonProperty("email_domains") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final java.util.List emailDomains; + + /** + * Creates a new instance of {@link EndpointOAuthLinkedIn}. + * + * @param clientId the value of the client_id parameter as a {@link String} + * @param clientSecret the value of the client_secret parameter as a {@link String} + * @param scopes the value of the scopes parameter as a {@link java.util.List} of {@link String} + * @param emailAddresses the value of the email_addresses parameter as a {@link java.util.List} of {@link String} + * @param emailDomains the value of the email_domains parameter as a {@link java.util.List} of {@link String} + */ + @JsonCreator + private EndpointOAuthLinkedIn( + @JsonProperty("client_id") final Optional clientId, + @JsonProperty("client_secret") final Optional clientSecret, + @JsonProperty("scopes") final java.util.List scopes, + @JsonProperty("email_addresses") final java.util.List emailAddresses, + @JsonProperty("email_domains") final java.util.List emailDomains + ) { + this.clientId = clientId != null ? clientId : Optional.empty(); + this.clientSecret = clientSecret != null ? clientSecret : Optional.empty(); + this.scopes = scopes != null ? scopes : java.util.Collections.emptyList(); + this.emailAddresses = emailAddresses != null ? emailAddresses : java.util.Collections.emptyList(); + this.emailDomains = emailDomains != null ? emailDomains : java.util.Collections.emptyList(); + } + + /** + * Fetches the value of the clientId property. + * + * @return the value of the property as a {@link String} wrapped in an {@link Optional} + */ + public Optional getClientId() { + return this.clientId; + } + + /** + * Fetches the value of the clientSecret property. + * + * @return the value of the property as a {@link String} wrapped in an {@link Optional} + */ + public Optional getClientSecret() { + return this.clientSecret; + } + + /** + * Fetches the value of the scopes property. + * + * @return the value of the property as a {@link java.util.List} of {@link String} + */ + public java.util.List getScopes() { + return this.scopes; + } + + /** + * Fetches the value of the emailAddresses property. + * + * @return the value of the property as a {@link java.util.List} of {@link String} + */ + public java.util.List getEmailAddresses() { + return this.emailAddresses; + } + + /** + * Fetches the value of the emailDomains property. + * + * @return the value of the property as a {@link java.util.List} of {@link String} + */ + public java.util.List getEmailDomains() { + return this.emailDomains; + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + final EndpointOAuthLinkedIn other = (EndpointOAuthLinkedIn) o; + return + this.clientId.equals(other.clientId)&& + this.clientSecret.equals(other.clientSecret)&& + this.scopes.equals(other.scopes)&& + this.emailAddresses.equals(other.emailAddresses)&& + this.emailDomains.equals(other.emailDomains); + + } + + @Override + public int hashCode() { + return Objects.hash( + this.clientId, + this.clientSecret, + this.scopes, + this.emailAddresses, + this.emailDomains + ); + } + + @Override + public String toString() { + return "EndpointOAuthLinkedIn{" + + "clientId='" + this.clientId.orElse("(null)") + + "', clientSecret='" + this.clientSecret.orElse("(null)") + + "', scopes='" + this.scopes + + "', emailAddresses='" + this.emailAddresses + + "', emailDomains='" + this.emailDomains + + "'}"; + } +} diff --git a/src/main/java/com/ngrok/definitions/EndpointOAuthProvider.java b/src/main/java/com/ngrok/definitions/EndpointOAuthProvider.java index 557b427..db63a5b 100644 --- a/src/main/java/com/ngrok/definitions/EndpointOAuthProvider.java +++ b/src/main/java/com/ngrok/definitions/EndpointOAuthProvider.java @@ -21,6 +21,10 @@ public class EndpointOAuthProvider { private Optional facebook = Optional.empty(); private Optional microsoft = Optional.empty(); private Optional google = Optional.empty(); + private Optional linkedin = Optional.empty(); + private Optional gitlab = Optional.empty(); + private Optional twitch = Optional.empty(); + private Optional amazon = Optional.empty(); private Builder( ) { @@ -114,6 +118,94 @@ public class EndpointOAuthProvider { return this; } + /** + * configuration for using linkedin as the identity provider + * + * @param linkedin the value of the linkedin parameter as a {@link EndpointOAuthLinkedIn} + * @return this builder instance + */ + public Builder linkedin(final EndpointOAuthLinkedIn linkedin) { + this.linkedin = Optional.of(Objects.requireNonNull(linkedin, "linkedin is required")); + return this; + } + + /** + * configuration for using linkedin as the identity provider + * + * @param linkedin the value of the linkedin parameter as a {@link EndpointOAuthLinkedIn}, wrapped in an {@link Optional} + * @return this builder instance + */ + public Builder linkedin(final Optional linkedin) { + this.linkedin = Objects.requireNonNull(linkedin, "linkedin is required"); + return this; + } + + /** + * configuration for using gitlab as the identity provider + * + * @param gitlab the value of the gitlab parameter as a {@link EndpointOAuthGitLab} + * @return this builder instance + */ + public Builder gitlab(final EndpointOAuthGitLab gitlab) { + this.gitlab = Optional.of(Objects.requireNonNull(gitlab, "gitlab is required")); + return this; + } + + /** + * configuration for using gitlab as the identity provider + * + * @param gitlab the value of the gitlab parameter as a {@link EndpointOAuthGitLab}, wrapped in an {@link Optional} + * @return this builder instance + */ + public Builder gitlab(final Optional gitlab) { + this.gitlab = Objects.requireNonNull(gitlab, "gitlab is required"); + return this; + } + + /** + * configuration for using twitch as the identity provider + * + * @param twitch the value of the twitch parameter as a {@link EndpointOAuthTwitch} + * @return this builder instance + */ + public Builder twitch(final EndpointOAuthTwitch twitch) { + this.twitch = Optional.of(Objects.requireNonNull(twitch, "twitch is required")); + return this; + } + + /** + * configuration for using twitch as the identity provider + * + * @param twitch the value of the twitch parameter as a {@link EndpointOAuthTwitch}, wrapped in an {@link Optional} + * @return this builder instance + */ + public Builder twitch(final Optional twitch) { + this.twitch = Objects.requireNonNull(twitch, "twitch is required"); + return this; + } + + /** + * configuration for using amazon as the identity provider + * + * @param amazon the value of the amazon parameter as a {@link EndpointOAuthAmazon} + * @return this builder instance + */ + public Builder amazon(final EndpointOAuthAmazon amazon) { + this.amazon = Optional.of(Objects.requireNonNull(amazon, "amazon is required")); + return this; + } + + /** + * configuration for using amazon as the identity provider + * + * @param amazon the value of the amazon parameter as a {@link EndpointOAuthAmazon}, wrapped in an {@link Optional} + * @return this builder instance + */ + public Builder amazon(final Optional amazon) { + this.amazon = Objects.requireNonNull(amazon, "amazon is required"); + return this; + } + /** * Constructs the {@link EndpointOAuthProvider} instance. * @@ -124,7 +216,11 @@ public class EndpointOAuthProvider { this.github, this.facebook, this.microsoft, - this.google + this.google, + this.linkedin, + this.gitlab, + this.twitch, + this.amazon ); } } @@ -152,6 +248,18 @@ public class EndpointOAuthProvider { @JsonProperty("google") @JsonInclude(value = JsonInclude.Include.NON_ABSENT) private final Optional google; + @JsonProperty("linkedin") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final Optional linkedin; + @JsonProperty("gitlab") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final Optional gitlab; + @JsonProperty("twitch") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final Optional twitch; + @JsonProperty("amazon") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final Optional amazon; /** * Creates a new instance of {@link EndpointOAuthProvider}. @@ -160,18 +268,30 @@ public class EndpointOAuthProvider { * @param facebook configuration for using facebook as the identity provider * @param microsoft configuration for using microsoft as the identity provider * @param google configuration for using google as the identity provider + * @param linkedin configuration for using linkedin as the identity provider + * @param gitlab configuration for using gitlab as the identity provider + * @param twitch configuration for using twitch as the identity provider + * @param amazon configuration for using amazon as the identity provider */ @JsonCreator private EndpointOAuthProvider( @JsonProperty("github") final Optional github, @JsonProperty("facebook") final Optional facebook, @JsonProperty("microsoft") final Optional microsoft, - @JsonProperty("google") final Optional google + @JsonProperty("google") final Optional google, + @JsonProperty("linkedin") final Optional linkedin, + @JsonProperty("gitlab") final Optional gitlab, + @JsonProperty("twitch") final Optional twitch, + @JsonProperty("amazon") final Optional amazon ) { this.github = github != null ? github : Optional.empty(); this.facebook = facebook != null ? facebook : Optional.empty(); this.microsoft = microsoft != null ? microsoft : Optional.empty(); this.google = google != null ? google : Optional.empty(); + this.linkedin = linkedin != null ? linkedin : Optional.empty(); + this.gitlab = gitlab != null ? gitlab : Optional.empty(); + this.twitch = twitch != null ? twitch : Optional.empty(); + this.amazon = amazon != null ? amazon : Optional.empty(); } /** @@ -210,6 +330,42 @@ public class EndpointOAuthProvider { return this.google; } + /** + * configuration for using linkedin as the identity provider + * + * @return the value of the property as a {@link EndpointOAuthLinkedIn} wrapped in an {@link Optional} + */ + public Optional getLinkedin() { + return this.linkedin; + } + + /** + * configuration for using gitlab as the identity provider + * + * @return the value of the property as a {@link EndpointOAuthGitLab} wrapped in an {@link Optional} + */ + public Optional getGitlab() { + return this.gitlab; + } + + /** + * configuration for using twitch as the identity provider + * + * @return the value of the property as a {@link EndpointOAuthTwitch} wrapped in an {@link Optional} + */ + public Optional getTwitch() { + return this.twitch; + } + + /** + * configuration for using amazon as the identity provider + * + * @return the value of the property as a {@link EndpointOAuthAmazon} wrapped in an {@link Optional} + */ + public Optional getAmazon() { + return this.amazon; + } + @Override public boolean equals(final Object o) { if (this == o) { @@ -224,7 +380,11 @@ public class EndpointOAuthProvider { this.github.equals(other.github)&& this.facebook.equals(other.facebook)&& this.microsoft.equals(other.microsoft)&& - this.google.equals(other.google); + this.google.equals(other.google)&& + this.linkedin.equals(other.linkedin)&& + this.gitlab.equals(other.gitlab)&& + this.twitch.equals(other.twitch)&& + this.amazon.equals(other.amazon); } @@ -234,7 +394,11 @@ public class EndpointOAuthProvider { this.github, this.facebook, this.microsoft, - this.google + this.google, + this.linkedin, + this.gitlab, + this.twitch, + this.amazon ); } @@ -245,6 +409,10 @@ public class EndpointOAuthProvider { "', facebook='" + this.facebook.map(Object::toString).orElse("(null)") + "', microsoft='" + this.microsoft.map(Object::toString).orElse("(null)") + "', google='" + this.google.map(Object::toString).orElse("(null)") + + "', linkedin='" + this.linkedin.map(Object::toString).orElse("(null)") + + "', gitlab='" + this.gitlab.map(Object::toString).orElse("(null)") + + "', twitch='" + this.twitch.map(Object::toString).orElse("(null)") + + "', amazon='" + this.amazon.map(Object::toString).orElse("(null)") + "'}"; } } diff --git a/src/main/java/com/ngrok/definitions/EndpointOAuthTwitch.java b/src/main/java/com/ngrok/definitions/EndpointOAuthTwitch.java new file mode 100644 index 0000000..912df31 --- /dev/null +++ b/src/main/java/com/ngrok/definitions/EndpointOAuthTwitch.java @@ -0,0 +1,292 @@ +package com.ngrok.definitions; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.Objects; +import java.util.Optional; + +/** + * A class encapsulating the {@link EndpointOAuthTwitch} resource. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class EndpointOAuthTwitch { + /** + * Builder class for {@link EndpointOAuthTwitch}. + */ + public static class Builder { + private Optional clientId = Optional.empty(); + private Optional clientSecret = Optional.empty(); + private java.util.List scopes = java.util.Collections.emptyList(); + private java.util.List emailAddresses = java.util.Collections.emptyList(); + private java.util.List emailDomains = java.util.Collections.emptyList(); + + private Builder( + ) { + } + + /** + * Sets the client_id property + * + * @param clientId the value of the client_id parameter as a {@link String} + * @return this builder instance + */ + public Builder clientId(final String clientId) { + this.clientId = Optional.of(Objects.requireNonNull(clientId, "clientId is required")); + return this; + } + + /** + * Sets the client_id property + * + * @param clientId the value of the client_id parameter as a {@link String}, wrapped in an {@link Optional} + * @return this builder instance + */ + public Builder clientId(final Optional clientId) { + this.clientId = Objects.requireNonNull(clientId, "clientId is required"); + return this; + } + + /** + * Sets the client_secret property + * + * @param clientSecret the value of the client_secret parameter as a {@link String} + * @return this builder instance + */ + public Builder clientSecret(final String clientSecret) { + this.clientSecret = Optional.of(Objects.requireNonNull(clientSecret, "clientSecret is required")); + return this; + } + + /** + * Sets the client_secret property + * + * @param clientSecret the value of the client_secret parameter as a {@link String}, wrapped in an {@link Optional} + * @return this builder instance + */ + public Builder clientSecret(final Optional clientSecret) { + this.clientSecret = Objects.requireNonNull(clientSecret, "clientSecret is required"); + return this; + } + + /** + * Sets the scopes property + * + * @param scopes the value of the scopes parameter as a {@link java.util.List} of {@link String} + * @return this builder instance + */ + public Builder scopes(final java.util.List scopes) { + this.scopes = Objects.requireNonNull(scopes, "scopes is required"); + return this; + } + + /** + * Sets the scopes property + * + * @param scopes the value of the scopes parameter as a {@link java.util.List} of {@link String}, wrapped in an {@link Optional} + * @return this builder instance + */ + public Builder scopes(final Optional> scopes) { + this.scopes = Objects.requireNonNull(scopes, "scopes is required").orElse(java.util.Collections.emptyList()); + return this; + } + + /** + * Sets the email_addresses property + * + * @param emailAddresses the value of the email_addresses parameter as a {@link java.util.List} of {@link String} + * @return this builder instance + */ + public Builder emailAddresses(final java.util.List emailAddresses) { + this.emailAddresses = Objects.requireNonNull(emailAddresses, "emailAddresses is required"); + return this; + } + + /** + * Sets the email_addresses property + * + * @param emailAddresses the value of the email_addresses parameter as a {@link java.util.List} of {@link String}, wrapped in an {@link Optional} + * @return this builder instance + */ + public Builder emailAddresses(final Optional> emailAddresses) { + this.emailAddresses = Objects.requireNonNull(emailAddresses, "emailAddresses is required").orElse(java.util.Collections.emptyList()); + return this; + } + + /** + * Sets the email_domains property + * + * @param emailDomains the value of the email_domains parameter as a {@link java.util.List} of {@link String} + * @return this builder instance + */ + public Builder emailDomains(final java.util.List emailDomains) { + this.emailDomains = Objects.requireNonNull(emailDomains, "emailDomains is required"); + return this; + } + + /** + * Sets the email_domains property + * + * @param emailDomains the value of the email_domains parameter as a {@link java.util.List} of {@link String}, wrapped in an {@link Optional} + * @return this builder instance + */ + public Builder emailDomains(final Optional> emailDomains) { + this.emailDomains = Objects.requireNonNull(emailDomains, "emailDomains is required").orElse(java.util.Collections.emptyList()); + return this; + } + + /** + * Constructs the {@link EndpointOAuthTwitch} instance. + * + * @return a new {@link EndpointOAuthTwitch} + */ + public EndpointOAuthTwitch build() { + return new EndpointOAuthTwitch( + this.clientId, + this.clientSecret, + this.scopes, + this.emailAddresses, + this.emailDomains + ); + } + } + + /** + * Creates a new builder for the {@link EndpointOAuthTwitch} type. + * + * @return a new {@link Builder} + */ + public static Builder newBuilder( + ) { + return new Builder ( + ); + } + + @JsonProperty("client_id") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final Optional clientId; + @JsonProperty("client_secret") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final Optional clientSecret; + @JsonProperty("scopes") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final java.util.List scopes; + @JsonProperty("email_addresses") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final java.util.List emailAddresses; + @JsonProperty("email_domains") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final java.util.List emailDomains; + + /** + * Creates a new instance of {@link EndpointOAuthTwitch}. + * + * @param clientId the value of the client_id parameter as a {@link String} + * @param clientSecret the value of the client_secret parameter as a {@link String} + * @param scopes the value of the scopes parameter as a {@link java.util.List} of {@link String} + * @param emailAddresses the value of the email_addresses parameter as a {@link java.util.List} of {@link String} + * @param emailDomains the value of the email_domains parameter as a {@link java.util.List} of {@link String} + */ + @JsonCreator + private EndpointOAuthTwitch( + @JsonProperty("client_id") final Optional clientId, + @JsonProperty("client_secret") final Optional clientSecret, + @JsonProperty("scopes") final java.util.List scopes, + @JsonProperty("email_addresses") final java.util.List emailAddresses, + @JsonProperty("email_domains") final java.util.List emailDomains + ) { + this.clientId = clientId != null ? clientId : Optional.empty(); + this.clientSecret = clientSecret != null ? clientSecret : Optional.empty(); + this.scopes = scopes != null ? scopes : java.util.Collections.emptyList(); + this.emailAddresses = emailAddresses != null ? emailAddresses : java.util.Collections.emptyList(); + this.emailDomains = emailDomains != null ? emailDomains : java.util.Collections.emptyList(); + } + + /** + * Fetches the value of the clientId property. + * + * @return the value of the property as a {@link String} wrapped in an {@link Optional} + */ + public Optional getClientId() { + return this.clientId; + } + + /** + * Fetches the value of the clientSecret property. + * + * @return the value of the property as a {@link String} wrapped in an {@link Optional} + */ + public Optional getClientSecret() { + return this.clientSecret; + } + + /** + * Fetches the value of the scopes property. + * + * @return the value of the property as a {@link java.util.List} of {@link String} + */ + public java.util.List getScopes() { + return this.scopes; + } + + /** + * Fetches the value of the emailAddresses property. + * + * @return the value of the property as a {@link java.util.List} of {@link String} + */ + public java.util.List getEmailAddresses() { + return this.emailAddresses; + } + + /** + * Fetches the value of the emailDomains property. + * + * @return the value of the property as a {@link java.util.List} of {@link String} + */ + public java.util.List getEmailDomains() { + return this.emailDomains; + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + final EndpointOAuthTwitch other = (EndpointOAuthTwitch) o; + return + this.clientId.equals(other.clientId)&& + this.clientSecret.equals(other.clientSecret)&& + this.scopes.equals(other.scopes)&& + this.emailAddresses.equals(other.emailAddresses)&& + this.emailDomains.equals(other.emailDomains); + + } + + @Override + public int hashCode() { + return Objects.hash( + this.clientId, + this.clientSecret, + this.scopes, + this.emailAddresses, + this.emailDomains + ); + } + + @Override + public String toString() { + return "EndpointOAuthTwitch{" + + "clientId='" + this.clientId.orElse("(null)") + + "', clientSecret='" + this.clientSecret.orElse("(null)") + + "', scopes='" + this.scopes + + "', emailAddresses='" + this.emailAddresses + + "', emailDomains='" + this.emailDomains + + "'}"; + } +} diff --git a/src/main/java/com/ngrok/definitions/EndpointWebhookValidation.java b/src/main/java/com/ngrok/definitions/EndpointWebhookValidation.java index 0bff1fc..08a1772 100644 --- a/src/main/java/com/ngrok/definitions/EndpointWebhookValidation.java +++ b/src/main/java/com/ngrok/definitions/EndpointWebhookValidation.java @@ -51,10 +51,8 @@ public class EndpointWebhookValidation { /** * a string indicating which webhook provider will be sending webhooks to this - * endpoint. Value must be one of the supported providers: SLACK, - * SNS, STRIPE, GITHUB, TWILIO, - * SHOPIFY, GITLAB, INTERCOM, - * SENDGRID, XERO, PAGERDUTY. + * endpoint. Value must be one of the supported providers defined at https://ngrok.com/docs/cloud-edge/modules/webhook * * @param provider the value of the provider parameter as a {@link String} * @return this builder instance @@ -66,10 +64,8 @@ public class EndpointWebhookValidation { /** * a string indicating which webhook provider will be sending webhooks to this - * endpoint. Value must be one of the supported providers: SLACK, - * SNS, STRIPE, GITHUB, TWILIO, - * SHOPIFY, GITLAB, INTERCOM, - * SENDGRID, XERO, PAGERDUTY. + * endpoint. Value must be one of the supported providers defined at https://ngrok.com/docs/cloud-edge/modules/webhook * * @param provider the value of the provider parameter as a {@link String}, wrapped in an {@link Optional} * @return this builder instance @@ -142,7 +138,7 @@ public class EndpointWebhookValidation { * Creates a new instance of {@link EndpointWebhookValidation}. * * @param enabled true if the module will be applied to traffic, false to disable. default true if unspecified - * @param provider a string indicating which webhook provider will be sending webhooks to this endpoint. Value must be one of the supported providers: SLACK, SNS, STRIPE, GITHUB, TWILIO, SHOPIFY, GITLAB, INTERCOM, SENDGRID, XERO, PAGERDUTY. + * @param provider a string indicating which webhook provider will be sending webhooks to this endpoint. Value must be one of the supported providers defined at https://ngrok.com/docs/cloud-edge/modules/webhook * @param secret a string secret used to validate requests from the given provider. All providers except AWS SNS require a secret */ @JsonCreator @@ -168,10 +164,8 @@ public class EndpointWebhookValidation { /** * a string indicating which webhook provider will be sending webhooks to this - * endpoint. Value must be one of the supported providers: SLACK, - * SNS, STRIPE, GITHUB, TWILIO, - * SHOPIFY, GITLAB, INTERCOM, - * SENDGRID, XERO, PAGERDUTY. + * endpoint. Value must be one of the supported providers defined at https://ngrok.com/docs/cloud-edge/modules/webhook * * @return the value of the property as a {@link String} */ diff --git a/src/main/java/com/ngrok/definitions/IdentityProvider.java b/src/main/java/com/ngrok/definitions/IdentityProvider.java new file mode 100644 index 0000000..201f87c --- /dev/null +++ b/src/main/java/com/ngrok/definitions/IdentityProvider.java @@ -0,0 +1,88 @@ +package com.ngrok.definitions; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.Objects; +import java.util.Optional; + +/** + * A class encapsulating the {@link IdentityProvider} resource. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class IdentityProvider { + @JsonProperty("name") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final String name; + @JsonProperty("url") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final String url; + + /** + * Creates a new instance of {@link IdentityProvider}. + * + * @param name name of the identity provider (e.g. Google) + * @param url URL of the identity provider (e.g. https://accounts.google.com) + */ + @JsonCreator + public IdentityProvider( + @JsonProperty("name") final String name, + @JsonProperty("url") final String url + ) { + this.name = Objects.requireNonNull(name, "name is required"); + this.url = Objects.requireNonNull(url, "url is required"); + } + + /** + * name of the identity provider (e.g. Google) + * + * @return the value of the property as a {@link String} + */ + public String getName() { + return this.name; + } + + /** + * URL of the identity provider (e.g. https://accounts.google.com) + * + * @return the value of the property as a {@link String} + */ + public String getUrl() { + return this.url; + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + final IdentityProvider other = (IdentityProvider) o; + return + this.name.equals(other.name)&& + this.url.equals(other.url); + + } + + @Override + public int hashCode() { + return Objects.hash( + this.name, + this.url + ); + } + + @Override + public String toString() { + return "IdentityProvider{" + + "name='" + this.name + + "', url='" + this.url + + "'}"; + } +} diff --git a/src/main/java/com/ngrok/definitions/Location.java b/src/main/java/com/ngrok/definitions/Location.java new file mode 100644 index 0000000..cd671c2 --- /dev/null +++ b/src/main/java/com/ngrok/definitions/Location.java @@ -0,0 +1,123 @@ +package com.ngrok.definitions; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.Objects; +import java.util.Optional; + +/** + * A class encapsulating the {@link Location} resource. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class Location { + @JsonProperty("country_code") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final Optional countryCode; + @JsonProperty("latitude") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final Optional latitude; + @JsonProperty("longitude") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final Optional longitude; + @JsonProperty("lat_long_radius_km") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final Optional latLongRadiusKm; + + /** + * Creates a new instance of {@link Location}. + * + * @param countryCode ISO country code + * @param latitude geographical latitude + * @param longitude geographical longitude + * @param latLongRadiusKm accuracy radius of the geographical coordinates + */ + @JsonCreator + public Location( + @JsonProperty("country_code") final Optional countryCode, + @JsonProperty("latitude") final Optional latitude, + @JsonProperty("longitude") final Optional longitude, + @JsonProperty("lat_long_radius_km") final Optional latLongRadiusKm + ) { + this.countryCode = countryCode != null ? countryCode : Optional.empty(); + this.latitude = latitude != null ? latitude : Optional.empty(); + this.longitude = longitude != null ? longitude : Optional.empty(); + this.latLongRadiusKm = latLongRadiusKm != null ? latLongRadiusKm : Optional.empty(); + } + + /** + * ISO country code + * + * @return the value of the property as a {@link String} wrapped in an {@link Optional} + */ + public Optional getCountryCode() { + return this.countryCode; + } + + /** + * geographical latitude + * + * @return the value of the property as a {@link double} wrapped in an {@link Optional} + */ + public Optional getLatitude() { + return this.latitude; + } + + /** + * geographical longitude + * + * @return the value of the property as a {@link double} wrapped in an {@link Optional} + */ + public Optional getLongitude() { + return this.longitude; + } + + /** + * accuracy radius of the geographical coordinates + * + * @return the value of the property as a {@link long} wrapped in an {@link Optional} + */ + public Optional getLatLongRadiusKm() { + return this.latLongRadiusKm; + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + final Location other = (Location) o; + return + this.countryCode.equals(other.countryCode)&& + this.latitude.equals(other.latitude)&& + this.longitude.equals(other.longitude)&& + this.latLongRadiusKm.equals(other.latLongRadiusKm); + + } + + @Override + public int hashCode() { + return Objects.hash( + this.countryCode, + this.latitude, + this.longitude, + this.latLongRadiusKm + ); + } + + @Override + public String toString() { + return "Location{" + + "countryCode='" + this.countryCode.orElse("(null)") + + "', latitude='" + this.latitude.map(Object::toString).orElse("(null)") + + "', longitude='" + this.longitude.map(Object::toString).orElse("(null)") + + "', latLongRadiusKm='" + this.latLongRadiusKm.map(Object::toString).orElse("(null)") + + "'}"; + } +} diff --git a/src/main/java/com/ngrok/definitions/SshCredential.java b/src/main/java/com/ngrok/definitions/SshCredential.java index 3b80908..b6d1ed0 100644 --- a/src/main/java/com/ngrok/definitions/SshCredential.java +++ b/src/main/java/com/ngrok/definitions/SshCredential.java @@ -34,6 +34,9 @@ public class SshCredential { @JsonProperty("acl") @JsonInclude(value = JsonInclude.Include.NON_ABSENT) private final java.util.List acl; + @JsonProperty("owner_id") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final Optional ownerId; /** * Creates a new instance of {@link SshCredential}. @@ -44,7 +47,8 @@ public class SshCredential { * @param description human-readable description of who or what will use the ssh credential to authenticate. Optional, max 255 bytes. * @param metadata arbitrary user-defined machine-readable data of this ssh credential. Optional, max 4096 bytes. * @param publicKey the PEM-encoded public key of the SSH keypair that will be used to authenticate - * @param acl optional list of ACL rules. If unspecified, the credential will have no restrictions. The only allowed ACL rule at this time is the bind rule. The bind rule allows the caller to restrict what domains and addresses the token is allowed to bind. For example, to allow the token to open a tunnel on example.ngrok.io your ACL would include the rule bind:example.ngrok.io. Bind rules may specify a leading wildcard to match multiple domains with a common suffix. For example, you may specify a rule of bind:*.example.com which will allow x.example.com, y.example.com, *.example.com, etc. A rule of '*' is equivalent to no acl at all and will explicitly permit all actions. + * @param acl optional list of ACL rules. If unspecified, the credential will have no restrictions. The only allowed ACL rule at this time is the bind rule. The bind rule allows the caller to restrict what domains, addresses, and labels the token is allowed to bind. For example, to allow the token to open a tunnel on example.ngrok.io your ACL would include the rule bind:example.ngrok.io. Bind rules for domains may specify a leading wildcard to match multiple domains with a common suffix. For example, you may specify a rule of bind:*.example.com which will allow x.example.com, y.example.com, *.example.com, etc. Bind rules for labels may specify a wildcard key and/or value to match multiple labels. For example, you may specify a rule of bind:*=example which will allow x=example, y=example, etc. A rule of '*' is equivalent to no acl at all and will explicitly permit all actions. + * @param ownerId If supplied at credential creation, ownership will be assigned to the specified User or Bot. Only admins may specify an owner other than themselves. Defaults to the authenticated User or Bot. */ @JsonCreator public SshCredential( @@ -54,7 +58,8 @@ public class SshCredential { @JsonProperty("description") final String description, @JsonProperty("metadata") final String metadata, @JsonProperty("public_key") final String publicKey, - @JsonProperty("acl") final java.util.List acl + @JsonProperty("acl") final java.util.List acl, + @JsonProperty("owner_id") final Optional ownerId ) { this.id = Objects.requireNonNull(id, "id is required"); this.uri = Objects.requireNonNull(uri, "uri is required"); @@ -63,6 +68,7 @@ public class SshCredential { this.metadata = Objects.requireNonNull(metadata, "metadata is required"); this.publicKey = Objects.requireNonNull(publicKey, "publicKey is required"); this.acl = acl != null ? acl : java.util.Collections.emptyList(); + this.ownerId = ownerId != null ? ownerId : Optional.empty(); } /** @@ -124,15 +130,18 @@ public class SshCredential { /** * optional list of ACL rules. If unspecified, the credential will have no * restrictions. The only allowed ACL rule at this time is the bind - * rule. The bind rule allows the caller to restrict what domains and - * addresses the token is allowed to bind. For example, to allow the token to open - * a tunnel on example.ngrok.io your ACL would include the rule - * bind:example.ngrok.io. Bind rules may specify a leading wildcard to - * match multiple domains with a common suffix. For example, you may specify a rule - * of bind:*.example.com which will allow x.example.com, - * y.example.com, *.example.com, etc. A rule of - * '*' is equivalent to no acl at all and will explicitly - * permit all actions. + * rule. The bind rule allows the caller to restrict what domains, + * addresses, and labels the token is allowed to bind. For example, to allow the + * token to open a tunnel on example.ngrok.io your ACL would include the rule + * bind:example.ngrok.io. Bind rules for domains may specify a leading + * wildcard to match multiple domains with a common suffix. For example, you may + * specify a rule of bind:*.example.com which will allow + * x.example.com, y.example.com, + * *.example.com, etc. Bind rules for labels may specify a wildcard + * key and/or value to match multiple labels. For example, you may specify a rule + * of bind:*=example which will allow x=example, + * y=example, etc. A rule of '*' is equivalent to + * no acl at all and will explicitly permit all actions. * * @return the value of the property as a {@link java.util.List} of {@link String} */ @@ -140,6 +149,17 @@ public class SshCredential { return this.acl; } + /** + * If supplied at credential creation, ownership will be assigned to the specified + * User or Bot. Only admins may specify an owner other than themselves. Defaults to + * the authenticated User or Bot. + * + * @return the value of the property as a {@link String} wrapped in an {@link Optional} + */ + public Optional getOwnerId() { + return this.ownerId; + } + @Override public boolean equals(final Object o) { if (this == o) { @@ -157,7 +177,8 @@ public class SshCredential { this.description.equals(other.description)&& this.metadata.equals(other.metadata)&& this.publicKey.equals(other.publicKey)&& - this.acl.equals(other.acl); + this.acl.equals(other.acl)&& + this.ownerId.equals(other.ownerId); } @@ -170,7 +191,8 @@ public class SshCredential { this.description, this.metadata, this.publicKey, - this.acl + this.acl, + this.ownerId ); } @@ -184,6 +206,7 @@ public class SshCredential { "', metadata='" + this.metadata + "', publicKey='" + this.publicKey + "', acl='" + this.acl + + "', ownerId='" + this.ownerId.orElse("(null)") + "'}"; } } diff --git a/src/main/java/com/ngrok/definitions/Tunnel.java b/src/main/java/com/ngrok/definitions/Tunnel.java index a0a6c84..9e4f332 100644 --- a/src/main/java/com/ngrok/definitions/Tunnel.java +++ b/src/main/java/com/ngrok/definitions/Tunnel.java @@ -39,7 +39,7 @@ public class Tunnel { private final Optional endpoint; @JsonProperty("labels") @JsonInclude(value = JsonInclude.Include.NON_ABSENT) - private final java.util.Map labels; + private final Optional> labels; @JsonProperty("backends") @JsonInclude(value = JsonInclude.Include.NON_ABSENT) private final Optional> backends; @@ -72,7 +72,7 @@ public class Tunnel { @JsonProperty("region") final String region, @JsonProperty("tunnel_session") final Ref tunnelSession, @JsonProperty("endpoint") final Optional endpoint, - @JsonProperty("labels") final java.util.Map labels, + @JsonProperty("labels") final Optional> labels, @JsonProperty("backends") final Optional> backends, @JsonProperty("forwards_to") final String forwardsTo ) { @@ -84,7 +84,7 @@ public class Tunnel { this.region = Objects.requireNonNull(region, "region is required"); this.tunnelSession = Objects.requireNonNull(tunnelSession, "tunnelSession is required"); this.endpoint = endpoint != null ? endpoint : Optional.empty(); - this.labels = labels != null ? labels : java.util.Collections.emptyMap(); + this.labels = labels != null ? labels : Optional.empty(); this.backends = backends != null ? backends : Optional.empty(); this.forwardsTo = Objects.requireNonNull(forwardsTo, "forwardsTo is required"); } @@ -171,9 +171,9 @@ public class Tunnel { * the labels the tunnel group backends will match against, if this is a backend * tunnel * - * @return the value of the property as a {@link java.util.Map} of {@link String} to {@link String} + * @return the value of the property as a {@link java.util.Map} of {@link String} to {@link String} wrapped in an {@link Optional} */ - public java.util.Map getLabels() { + public Optional> getLabels() { return this.labels; } @@ -249,7 +249,7 @@ public class Tunnel { "', region='" + this.region + "', tunnelSession='" + this.tunnelSession + "', endpoint='" + this.endpoint.map(Object::toString).orElse("(null)") + - "', labels='" + this.labels + + "', labels='" + this.labels.map(Object::toString).orElse("(null)") + "', backends='" + this.backends.map(Object::toString).orElse("(null)") + "', forwardsTo='" + this.forwardsTo + "'}"; diff --git a/src/main/java/com/ngrok/definitions/UserAgent.java b/src/main/java/com/ngrok/definitions/UserAgent.java new file mode 100644 index 0000000..7d4f6ab --- /dev/null +++ b/src/main/java/com/ngrok/definitions/UserAgent.java @@ -0,0 +1,159 @@ +package com.ngrok.definitions; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.Objects; +import java.util.Optional; + +/** + * A class encapsulating the {@link UserAgent} resource. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class UserAgent { + @JsonProperty("raw") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final String raw; + @JsonProperty("browser_name") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final String browserName; + @JsonProperty("browser_version") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final String browserVersion; + @JsonProperty("device_type") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final String deviceType; + @JsonProperty("os_name") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final String osName; + @JsonProperty("os_version") + @JsonInclude(value = JsonInclude.Include.NON_ABSENT) + private final String osVersion; + + /** + * Creates a new instance of {@link UserAgent}. + * + * @param raw raw User-Agent request header + * @param browserName browser name (e.g. Chrome) + * @param browserVersion browser version (e.g. 102) + * @param deviceType type of device (e.g. Desktop) + * @param osName operating system name (e.g. MacOS) + * @param osVersion operating system version (e.g. 10.15.7) + */ + @JsonCreator + public UserAgent( + @JsonProperty("raw") final String raw, + @JsonProperty("browser_name") final String browserName, + @JsonProperty("browser_version") final String browserVersion, + @JsonProperty("device_type") final String deviceType, + @JsonProperty("os_name") final String osName, + @JsonProperty("os_version") final String osVersion + ) { + this.raw = Objects.requireNonNull(raw, "raw is required"); + this.browserName = Objects.requireNonNull(browserName, "browserName is required"); + this.browserVersion = Objects.requireNonNull(browserVersion, "browserVersion is required"); + this.deviceType = Objects.requireNonNull(deviceType, "deviceType is required"); + this.osName = Objects.requireNonNull(osName, "osName is required"); + this.osVersion = Objects.requireNonNull(osVersion, "osVersion is required"); + } + + /** + * raw User-Agent request header + * + * @return the value of the property as a {@link String} + */ + public String getRaw() { + return this.raw; + } + + /** + * browser name (e.g. Chrome) + * + * @return the value of the property as a {@link String} + */ + public String getBrowserName() { + return this.browserName; + } + + /** + * browser version (e.g. 102) + * + * @return the value of the property as a {@link String} + */ + public String getBrowserVersion() { + return this.browserVersion; + } + + /** + * type of device (e.g. Desktop) + * + * @return the value of the property as a {@link String} + */ + public String getDeviceType() { + return this.deviceType; + } + + /** + * operating system name (e.g. MacOS) + * + * @return the value of the property as a {@link String} + */ + public String getOsName() { + return this.osName; + } + + /** + * operating system version (e.g. 10.15.7) + * + * @return the value of the property as a {@link String} + */ + public String getOsVersion() { + return this.osVersion; + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + final UserAgent other = (UserAgent) o; + return + this.raw.equals(other.raw)&& + this.browserName.equals(other.browserName)&& + this.browserVersion.equals(other.browserVersion)&& + this.deviceType.equals(other.deviceType)&& + this.osName.equals(other.osName)&& + this.osVersion.equals(other.osVersion); + + } + + @Override + public int hashCode() { + return Objects.hash( + this.raw, + this.browserName, + this.browserVersion, + this.deviceType, + this.osName, + this.osVersion + ); + } + + @Override + public String toString() { + return "UserAgent{" + + "raw='" + this.raw + + "', browserName='" + this.browserName + + "', browserVersion='" + this.browserVersion + + "', deviceType='" + this.deviceType + + "', osName='" + this.osName + + "', osVersion='" + this.osVersion + + "'}"; + } +} diff --git a/src/main/java/com/ngrok/services/AbuseReports.java b/src/main/java/com/ngrok/services/AbuseReports.java index ec960da..ed4c7b8 100644 --- a/src/main/java/com/ngrok/services/AbuseReports.java +++ b/src/main/java/com/ngrok/services/AbuseReports.java @@ -33,7 +33,7 @@ public class AbuseReports { * A builder object encapsulating state for an unsent Create API call. */ public class CreateCallBuilder { - private java.util.List urls = java.util.Collections.emptyList(); + private final java.util.List urls; private Optional metadata = Optional.empty(); private CreateCallBuilder( diff --git a/src/main/java/com/ngrok/services/ApiKeys.java b/src/main/java/com/ngrok/services/ApiKeys.java index e7d3c79..7b23392 100644 --- a/src/main/java/com/ngrok/services/ApiKeys.java +++ b/src/main/java/com/ngrok/services/ApiKeys.java @@ -41,6 +41,7 @@ public class ApiKeys { public class CreateCallBuilder { private Optional description = Optional.empty(); private Optional metadata = Optional.empty(); + private Optional ownerId = Optional.empty(); private CreateCallBuilder( ) { @@ -92,6 +93,32 @@ public class ApiKeys { return this; } + /** + * If supplied at credential creation, ownership will be assigned to the specified + * User or Bot. Only admins may specify an owner other than themselves. Defaults to + * the authenticated User or Bot. + * + * @param ownerId the value of the owner_id parameter as a {@link String} + * @return the call builder instance + */ + public CreateCallBuilder ownerId(final String ownerId) { + this.ownerId = Optional.of(Objects.requireNonNull(ownerId, "ownerId is required")); + return this; + } + + /** + * If supplied at credential creation, ownership will be assigned to the specified + * User or Bot. Only admins may specify an owner other than themselves. Defaults to + * the authenticated User or Bot. + * + * @param ownerId the value of the owner_id parameter as an {@link Optional} of {@link String} + * @return the call builder instance + */ + public CreateCallBuilder ownerId(final Optional ownerId) { + this.ownerId = Objects.requireNonNull(ownerId, "ownerId is required"); + return this; + } + /** * Initiates the API call asynchronously. * @@ -104,7 +131,8 @@ public class ApiKeys { Stream.empty(), Stream.of( new AbstractMap.SimpleEntry<>("description", this.description.map(Function.identity())), - new AbstractMap.SimpleEntry<>("metadata", this.metadata.map(Function.identity())) + new AbstractMap.SimpleEntry<>("metadata", this.metadata.map(Function.identity())), + new AbstractMap.SimpleEntry<>("owner_id", this.ownerId.map(Function.identity())) ), Optional.of(ApiKey.class) ); diff --git a/src/main/java/com/ngrok/services/ApplicationSessions.java b/src/main/java/com/ngrok/services/ApplicationSessions.java new file mode 100644 index 0000000..b957fc0 --- /dev/null +++ b/src/main/java/com/ngrok/services/ApplicationSessions.java @@ -0,0 +1,246 @@ +package com.ngrok.services; + +import com.ngrok.NgrokApiClient; +import com.ngrok.definitions.*; + +import java.util.AbstractMap; +import java.util.Objects; +import java.util.Optional; +import java.util.concurrent.CompletionStage; +import java.util.concurrent.ExecutionException; +import java.util.function.Function; +import java.util.stream.Stream; + +/** + * An API client for {@link ApplicationSessions}. + * + * See also https://ngrok.com/docs/api#api-application-sessions. + */ +public class ApplicationSessions { + private final NgrokApiClient apiClient; + + /** + * Creates a new sub-client for ApplicationSessions. + * + * @param apiClient an instance of {@link com.ngrok.NgrokApiClient} + */ + public ApplicationSessions(final NgrokApiClient apiClient) { + this.apiClient = Objects.requireNonNull(apiClient, "apiClient is required"); + } + + /** + * A builder object encapsulating state for an unsent Get API call. + */ + public class GetCallBuilder { + private final String id; + + private GetCallBuilder( + final String id + ) { + this.id = Objects.requireNonNull(id, "id is required"); + } + + /** + * Initiates the API call asynchronously. + * + * @return a {@link CompletionStage} of {@link ApplicationSession} + */ + public CompletionStage call() { + return apiClient.sendRequest( + NgrokApiClient.HttpMethod.GET, + "/app/sessions/" + this.id, + Stream.empty(), + Stream.empty(), + Optional.of(ApplicationSession.class) + ); + } + + /** + * Initiates the API call and blocks until it returns. + * + * @return {@link ApplicationSession} + * @throws InterruptedException if the thread was interrupted during the call + */ + public ApplicationSession blockingCall() throws InterruptedException { + try { + return call().toCompletableFuture().get(); + } catch (final ExecutionException e) { + throw e.getCause() instanceof RuntimeException ? (RuntimeException) e.getCause() : new RuntimeException(e.getCause().getMessage(), e.getCause()); + } + } + } + + /** + * Get an application session by ID. + * + * See also https://ngrok.com/docs/api#api-application-sessions-get. + * + * @param id a resource identifier + * @return a call builder for this API call + */ + public GetCallBuilder get( + final String id + ) { + return new GetCallBuilder( + id + ); + } + + /** + * A builder object encapsulating state for an unsent Delete API call. + */ + public class DeleteCallBuilder { + private final String id; + + private DeleteCallBuilder( + final String id + ) { + this.id = Objects.requireNonNull(id, "id is required"); + } + + /** + * Initiates the API call asynchronously. + * + * @return a {@link CompletionStage} of {@link Void} + */ + public CompletionStage call() { + return apiClient.sendRequest( + NgrokApiClient.HttpMethod.DELETE, + "/app/sessions/" + this.id, + Stream.empty(), + Stream.empty(), + Optional.empty() + ); + } + + /** + * Initiates the API call and blocks until it returns. + * + * @throws InterruptedException if the thread was interrupted during the call + */ + public void blockingCall() throws InterruptedException { + try { + call().toCompletableFuture().get(); + } catch (final ExecutionException e) { + throw e.getCause() instanceof RuntimeException ? (RuntimeException) e.getCause() : new RuntimeException(e.getCause().getMessage(), e.getCause()); + } + } + } + + /** + * Delete an application session by ID. + * + * See also https://ngrok.com/docs/api#api-application-sessions-delete. + * + * @param id a resource identifier + * @return a call builder for this API call + */ + public DeleteCallBuilder delete( + final String id + ) { + return new DeleteCallBuilder( + id + ); + } + + /** + * A builder object encapsulating state for an unsent List API call. + */ + public class ListCallBuilder { + private Optional beforeId = Optional.empty(); + private Optional limit = Optional.empty(); + + private ListCallBuilder( + ) { + } + + /** + * Sets the before_id parameter. + * + * @param beforeId the value of the before_id parameter as a {@link String} + * @return the call builder instance + */ + public ListCallBuilder beforeId(final String beforeId) { + this.beforeId = Optional.of(Objects.requireNonNull(beforeId, "beforeId is required")); + return this; + } + + /** + * Sets (or unsets) the before_id parameter. + * + * @param beforeId the value of the before_id parameter as an {@link Optional} of {@link String} + * @return the call builder instance + */ + public ListCallBuilder beforeId(final Optional beforeId) { + this.beforeId = Objects.requireNonNull(beforeId, "beforeId is required"); + return this; + } + + /** + * Sets the limit parameter. + * + * @param limit the value of the limit parameter as a {@link String} + * @return the call builder instance + */ + public ListCallBuilder limit(final String limit) { + this.limit = Optional.of(Objects.requireNonNull(limit, "limit is required")); + return this; + } + + /** + * Sets (or unsets) the limit parameter. + * + * @param limit the value of the limit parameter as an {@link Optional} of {@link String} + * @return the call builder instance + */ + public ListCallBuilder limit(final Optional limit) { + this.limit = Objects.requireNonNull(limit, "limit is required"); + return this; + } + + /** + * Initiates the API call asynchronously. + * + * @return a {@link CompletionStage} of a {@link Page} of {@link ApplicationSessionList} + */ + public CompletionStage> call() { + return apiClient.sendRequest( + NgrokApiClient.HttpMethod.GET, + "/app/sessions", + Stream.of( + new AbstractMap.SimpleEntry<>("before_id", this.beforeId.map(Function.identity())), + new AbstractMap.SimpleEntry<>("limit", this.limit.map(Function.identity())) + ), + Stream.empty(), + Optional.of(ApplicationSessionList.class) + ).thenApply(list -> new Page<>(apiClient, list)); + } + + /** + * Initiates the API call and blocks until it returns. + * + * @return a {@link Page} of {@link ApplicationSessionList} + * @throws InterruptedException if the thread was interrupted during the call + */ + public Page blockingCall() throws InterruptedException { + try { + return call().toCompletableFuture().get(); + } catch (final ExecutionException e) { + throw e.getCause() instanceof RuntimeException ? (RuntimeException) e.getCause() : new RuntimeException(e.getCause().getMessage(), e.getCause()); + } + } + } + + /** + * List all application sessions for this account. + * + * See also https://ngrok.com/docs/api#api-application-sessions-list. + * + * @return a call builder for this API call + */ + public ListCallBuilder list( + ) { + return new ListCallBuilder( + ); + } +} diff --git a/src/main/java/com/ngrok/services/ApplicationUsers.java b/src/main/java/com/ngrok/services/ApplicationUsers.java new file mode 100644 index 0000000..f9cb780 --- /dev/null +++ b/src/main/java/com/ngrok/services/ApplicationUsers.java @@ -0,0 +1,246 @@ +package com.ngrok.services; + +import com.ngrok.NgrokApiClient; +import com.ngrok.definitions.*; + +import java.util.AbstractMap; +import java.util.Objects; +import java.util.Optional; +import java.util.concurrent.CompletionStage; +import java.util.concurrent.ExecutionException; +import java.util.function.Function; +import java.util.stream.Stream; + +/** + * An API client for {@link ApplicationUsers}. + * + * See also https://ngrok.com/docs/api#api-application-users. + */ +public class ApplicationUsers { + private final NgrokApiClient apiClient; + + /** + * Creates a new sub-client for ApplicationUsers. + * + * @param apiClient an instance of {@link com.ngrok.NgrokApiClient} + */ + public ApplicationUsers(final NgrokApiClient apiClient) { + this.apiClient = Objects.requireNonNull(apiClient, "apiClient is required"); + } + + /** + * A builder object encapsulating state for an unsent Get API call. + */ + public class GetCallBuilder { + private final String id; + + private GetCallBuilder( + final String id + ) { + this.id = Objects.requireNonNull(id, "id is required"); + } + + /** + * Initiates the API call asynchronously. + * + * @return a {@link CompletionStage} of {@link ApplicationUser} + */ + public CompletionStage call() { + return apiClient.sendRequest( + NgrokApiClient.HttpMethod.GET, + "/app/users/" + this.id, + Stream.empty(), + Stream.empty(), + Optional.of(ApplicationUser.class) + ); + } + + /** + * Initiates the API call and blocks until it returns. + * + * @return {@link ApplicationUser} + * @throws InterruptedException if the thread was interrupted during the call + */ + public ApplicationUser blockingCall() throws InterruptedException { + try { + return call().toCompletableFuture().get(); + } catch (final ExecutionException e) { + throw e.getCause() instanceof RuntimeException ? (RuntimeException) e.getCause() : new RuntimeException(e.getCause().getMessage(), e.getCause()); + } + } + } + + /** + * Get an application user by ID. + * + * See also https://ngrok.com/docs/api#api-application-users-get. + * + * @param id a resource identifier + * @return a call builder for this API call + */ + public GetCallBuilder get( + final String id + ) { + return new GetCallBuilder( + id + ); + } + + /** + * A builder object encapsulating state for an unsent Delete API call. + */ + public class DeleteCallBuilder { + private final String id; + + private DeleteCallBuilder( + final String id + ) { + this.id = Objects.requireNonNull(id, "id is required"); + } + + /** + * Initiates the API call asynchronously. + * + * @return a {@link CompletionStage} of {@link Void} + */ + public CompletionStage call() { + return apiClient.sendRequest( + NgrokApiClient.HttpMethod.DELETE, + "/app/users/" + this.id, + Stream.empty(), + Stream.empty(), + Optional.empty() + ); + } + + /** + * Initiates the API call and blocks until it returns. + * + * @throws InterruptedException if the thread was interrupted during the call + */ + public void blockingCall() throws InterruptedException { + try { + call().toCompletableFuture().get(); + } catch (final ExecutionException e) { + throw e.getCause() instanceof RuntimeException ? (RuntimeException) e.getCause() : new RuntimeException(e.getCause().getMessage(), e.getCause()); + } + } + } + + /** + * Delete an application user by ID. + * + * See also https://ngrok.com/docs/api#api-application-users-delete. + * + * @param id a resource identifier + * @return a call builder for this API call + */ + public DeleteCallBuilder delete( + final String id + ) { + return new DeleteCallBuilder( + id + ); + } + + /** + * A builder object encapsulating state for an unsent List API call. + */ + public class ListCallBuilder { + private Optional beforeId = Optional.empty(); + private Optional limit = Optional.empty(); + + private ListCallBuilder( + ) { + } + + /** + * Sets the before_id parameter. + * + * @param beforeId the value of the before_id parameter as a {@link String} + * @return the call builder instance + */ + public ListCallBuilder beforeId(final String beforeId) { + this.beforeId = Optional.of(Objects.requireNonNull(beforeId, "beforeId is required")); + return this; + } + + /** + * Sets (or unsets) the before_id parameter. + * + * @param beforeId the value of the before_id parameter as an {@link Optional} of {@link String} + * @return the call builder instance + */ + public ListCallBuilder beforeId(final Optional beforeId) { + this.beforeId = Objects.requireNonNull(beforeId, "beforeId is required"); + return this; + } + + /** + * Sets the limit parameter. + * + * @param limit the value of the limit parameter as a {@link String} + * @return the call builder instance + */ + public ListCallBuilder limit(final String limit) { + this.limit = Optional.of(Objects.requireNonNull(limit, "limit is required")); + return this; + } + + /** + * Sets (or unsets) the limit parameter. + * + * @param limit the value of the limit parameter as an {@link Optional} of {@link String} + * @return the call builder instance + */ + public ListCallBuilder limit(final Optional limit) { + this.limit = Objects.requireNonNull(limit, "limit is required"); + return this; + } + + /** + * Initiates the API call asynchronously. + * + * @return a {@link CompletionStage} of a {@link Page} of {@link ApplicationUserList} + */ + public CompletionStage> call() { + return apiClient.sendRequest( + NgrokApiClient.HttpMethod.GET, + "/app/users", + Stream.of( + new AbstractMap.SimpleEntry<>("before_id", this.beforeId.map(Function.identity())), + new AbstractMap.SimpleEntry<>("limit", this.limit.map(Function.identity())) + ), + Stream.empty(), + Optional.of(ApplicationUserList.class) + ).thenApply(list -> new Page<>(apiClient, list)); + } + + /** + * Initiates the API call and blocks until it returns. + * + * @return a {@link Page} of {@link ApplicationUserList} + * @throws InterruptedException if the thread was interrupted during the call + */ + public Page blockingCall() throws InterruptedException { + try { + return call().toCompletableFuture().get(); + } catch (final ExecutionException e) { + throw e.getCause() instanceof RuntimeException ? (RuntimeException) e.getCause() : new RuntimeException(e.getCause().getMessage(), e.getCause()); + } + } + } + + /** + * List all application users for this account. + * + * See also https://ngrok.com/docs/api#api-application-users-list. + * + * @return a call builder for this API call + */ + public ListCallBuilder list( + ) { + return new ListCallBuilder( + ); + } +} diff --git a/src/main/java/com/ngrok/services/Credentials.java b/src/main/java/com/ngrok/services/Credentials.java index 1c6a618..10d8910 100644 --- a/src/main/java/com/ngrok/services/Credentials.java +++ b/src/main/java/com/ngrok/services/Credentials.java @@ -39,6 +39,7 @@ public class Credentials { private Optional description = Optional.empty(); private Optional metadata = Optional.empty(); private java.util.List acl = java.util.Collections.emptyList(); + private Optional ownerId = Optional.empty(); private CreateCallBuilder( ) { @@ -95,15 +96,18 @@ public class Credentials { /** * optional list of ACL rules. If unspecified, the credential will have no * restrictions. The only allowed ACL rule at this time is the bind - * rule. The bind rule allows the caller to restrict what domains and - * addresses the token is allowed to bind. For example, to allow the token to open - * a tunnel on example.ngrok.io your ACL would include the rule - * bind:example.ngrok.io. Bind rules may specify a leading wildcard to - * match multiple domains with a common suffix. For example, you may specify a rule - * of bind:*.example.com which will allow x.example.com, - * y.example.com, *.example.com, etc. A rule of - * '*' is equivalent to no acl at all and will explicitly - * permit all actions. + * rule. The bind rule allows the caller to restrict what domains, + * addresses, and labels the token is allowed to bind. For example, to allow the + * token to open a tunnel on example.ngrok.io your ACL would include the rule + * bind:example.ngrok.io. Bind rules for domains may specify a leading + * wildcard to match multiple domains with a common suffix. For example, you may + * specify a rule of bind:*.example.com which will allow + * x.example.com, y.example.com, + * *.example.com, etc. Bind rules for labels may specify a wildcard + * key and/or value to match multiple labels. For example, you may specify a rule + * of bind:*=example which will allow x=example, + * y=example, etc. A rule of '*' is equivalent to + * no acl at all and will explicitly permit all actions. * * @param acl the value of the acl parameter as a {@link java.util.List} of {@link String} * @return the call builder instance @@ -116,15 +120,18 @@ public class Credentials { /** * optional list of ACL rules. If unspecified, the credential will have no * restrictions. The only allowed ACL rule at this time is the bind - * rule. The bind rule allows the caller to restrict what domains and - * addresses the token is allowed to bind. For example, to allow the token to open - * a tunnel on example.ngrok.io your ACL would include the rule - * bind:example.ngrok.io. Bind rules may specify a leading wildcard to - * match multiple domains with a common suffix. For example, you may specify a rule - * of bind:*.example.com which will allow x.example.com, - * y.example.com, *.example.com, etc. A rule of - * '*' is equivalent to no acl at all and will explicitly - * permit all actions. + * rule. The bind rule allows the caller to restrict what domains, + * addresses, and labels the token is allowed to bind. For example, to allow the + * token to open a tunnel on example.ngrok.io your ACL would include the rule + * bind:example.ngrok.io. Bind rules for domains may specify a leading + * wildcard to match multiple domains with a common suffix. For example, you may + * specify a rule of bind:*.example.com which will allow + * x.example.com, y.example.com, + * *.example.com, etc. Bind rules for labels may specify a wildcard + * key and/or value to match multiple labels. For example, you may specify a rule + * of bind:*=example which will allow x=example, + * y=example, etc. A rule of '*' is equivalent to + * no acl at all and will explicitly permit all actions. * * @param acl the value of the acl parameter as an {@link Optional} of {@link java.util.List} of {@link String} * @return the call builder instance @@ -134,6 +141,32 @@ public class Credentials { return this; } + /** + * If supplied at credential creation, ownership will be assigned to the specified + * User or Bot. Only admins may specify an owner other than themselves. Defaults to + * the authenticated User or Bot. + * + * @param ownerId the value of the owner_id parameter as a {@link String} + * @return the call builder instance + */ + public CreateCallBuilder ownerId(final String ownerId) { + this.ownerId = Optional.of(Objects.requireNonNull(ownerId, "ownerId is required")); + return this; + } + + /** + * If supplied at credential creation, ownership will be assigned to the specified + * User or Bot. Only admins may specify an owner other than themselves. Defaults to + * the authenticated User or Bot. + * + * @param ownerId the value of the owner_id parameter as an {@link Optional} of {@link String} + * @return the call builder instance + */ + public CreateCallBuilder ownerId(final Optional ownerId) { + this.ownerId = Objects.requireNonNull(ownerId, "ownerId is required"); + return this; + } + /** * Initiates the API call asynchronously. * @@ -147,7 +180,8 @@ public class Credentials { Stream.of( new AbstractMap.SimpleEntry<>("description", this.description.map(Function.identity())), new AbstractMap.SimpleEntry<>("metadata", this.metadata.map(Function.identity())), - new AbstractMap.SimpleEntry<>("acl", Optional.of(this.acl).filter(acl -> !acl.isEmpty()).map(Function.identity())) + new AbstractMap.SimpleEntry<>("acl", Optional.of(this.acl).filter(acl -> !acl.isEmpty()).map(Function.identity())), + new AbstractMap.SimpleEntry<>("owner_id", this.ownerId.map(Function.identity())) ), Optional.of(Credential.class) ); @@ -407,7 +441,7 @@ public class Credentials { private final String id; private Optional description = Optional.empty(); private Optional metadata = Optional.empty(); - private java.util.List acl = java.util.Collections.emptyList(); + private Optional> acl = Optional.empty(); private UpdateCallBuilder( final String id @@ -466,42 +500,48 @@ public class Credentials { /** * optional list of ACL rules. If unspecified, the credential will have no * restrictions. The only allowed ACL rule at this time is the bind - * rule. The bind rule allows the caller to restrict what domains and - * addresses the token is allowed to bind. For example, to allow the token to open - * a tunnel on example.ngrok.io your ACL would include the rule - * bind:example.ngrok.io. Bind rules may specify a leading wildcard to - * match multiple domains with a common suffix. For example, you may specify a rule - * of bind:*.example.com which will allow x.example.com, - * y.example.com, *.example.com, etc. A rule of - * '*' is equivalent to no acl at all and will explicitly - * permit all actions. + * rule. The bind rule allows the caller to restrict what domains, + * addresses, and labels the token is allowed to bind. For example, to allow the + * token to open a tunnel on example.ngrok.io your ACL would include the rule + * bind:example.ngrok.io. Bind rules for domains may specify a leading + * wildcard to match multiple domains with a common suffix. For example, you may + * specify a rule of bind:*.example.com which will allow + * x.example.com, y.example.com, + * *.example.com, etc. Bind rules for labels may specify a wildcard + * key and/or value to match multiple labels. For example, you may specify a rule + * of bind:*=example which will allow x=example, + * y=example, etc. A rule of '*' is equivalent to + * no acl at all and will explicitly permit all actions. * * @param acl the value of the acl parameter as a {@link java.util.List} of {@link String} * @return the call builder instance */ public UpdateCallBuilder acl(final java.util.List acl) { - this.acl = Objects.requireNonNull(acl, "acl is required"); + this.acl = Optional.of(Objects.requireNonNull(acl, "acl is required")); return this; } /** * optional list of ACL rules. If unspecified, the credential will have no * restrictions. The only allowed ACL rule at this time is the bind - * rule. The bind rule allows the caller to restrict what domains and - * addresses the token is allowed to bind. For example, to allow the token to open - * a tunnel on example.ngrok.io your ACL would include the rule - * bind:example.ngrok.io. Bind rules may specify a leading wildcard to - * match multiple domains with a common suffix. For example, you may specify a rule - * of bind:*.example.com which will allow x.example.com, - * y.example.com, *.example.com, etc. A rule of - * '*' is equivalent to no acl at all and will explicitly - * permit all actions. + * rule. The bind rule allows the caller to restrict what domains, + * addresses, and labels the token is allowed to bind. For example, to allow the + * token to open a tunnel on example.ngrok.io your ACL would include the rule + * bind:example.ngrok.io. Bind rules for domains may specify a leading + * wildcard to match multiple domains with a common suffix. For example, you may + * specify a rule of bind:*.example.com which will allow + * x.example.com, y.example.com, + * *.example.com, etc. Bind rules for labels may specify a wildcard + * key and/or value to match multiple labels. For example, you may specify a rule + * of bind:*=example which will allow x=example, + * y=example, etc. A rule of '*' is equivalent to + * no acl at all and will explicitly permit all actions. * * @param acl the value of the acl parameter as an {@link Optional} of {@link java.util.List} of {@link String} * @return the call builder instance */ public UpdateCallBuilder acl(final Optional> acl) { - this.acl = Objects.requireNonNull(acl, "acl is required").orElse(java.util.Collections.emptyList()); + this.acl = Objects.requireNonNull(acl, "acl is required"); return this; } diff --git a/src/main/java/com/ngrok/services/EdgesHttps.java b/src/main/java/com/ngrok/services/EdgesHttps.java index b6325bb..107c614 100644 --- a/src/main/java/com/ngrok/services/EdgesHttps.java +++ b/src/main/java/com/ngrok/services/EdgesHttps.java @@ -34,7 +34,7 @@ public class EdgesHttps { public class CreateCallBuilder { private Optional description = Optional.empty(); private Optional metadata = Optional.empty(); - private java.util.List hostports = java.util.Collections.emptyList(); + private Optional> hostports = Optional.empty(); private Optional mutualTls = Optional.empty(); private Optional tlsTermination = Optional.empty(); @@ -97,7 +97,7 @@ public class EdgesHttps { * @return the call builder instance */ public CreateCallBuilder hostports(final java.util.List hostports) { - this.hostports = Objects.requireNonNull(hostports, "hostports is required"); + this.hostports = Optional.of(Objects.requireNonNull(hostports, "hostports is required")); return this; } @@ -108,7 +108,7 @@ public class EdgesHttps { * @return the call builder instance */ public CreateCallBuilder hostports(final Optional> hostports) { - this.hostports = Objects.requireNonNull(hostports, "hostports is required").orElse(java.util.Collections.emptyList()); + this.hostports = Objects.requireNonNull(hostports, "hostports is required"); return this; } @@ -371,7 +371,7 @@ public class EdgesHttps { private final String id; private Optional description = Optional.empty(); private Optional metadata = Optional.empty(); - private java.util.List hostports = java.util.Collections.emptyList(); + private Optional> hostports = Optional.empty(); private Optional mutualTls = Optional.empty(); private Optional tlsTermination = Optional.empty(); @@ -436,7 +436,7 @@ public class EdgesHttps { * @return the call builder instance */ public UpdateCallBuilder hostports(final java.util.List hostports) { - this.hostports = Objects.requireNonNull(hostports, "hostports is required"); + this.hostports = Optional.of(Objects.requireNonNull(hostports, "hostports is required")); return this; } @@ -447,7 +447,7 @@ public class EdgesHttps { * @return the call builder instance */ public UpdateCallBuilder hostports(final Optional> hostports) { - this.hostports = Objects.requireNonNull(hostports, "hostports is required").orElse(java.util.Collections.emptyList()); + this.hostports = Objects.requireNonNull(hostports, "hostports is required"); return this; } diff --git a/src/main/java/com/ngrok/services/EdgesTcp.java b/src/main/java/com/ngrok/services/EdgesTcp.java index 6dbe057..91df48f 100644 --- a/src/main/java/com/ngrok/services/EdgesTcp.java +++ b/src/main/java/com/ngrok/services/EdgesTcp.java @@ -34,7 +34,7 @@ public class EdgesTcp { public class CreateCallBuilder { private Optional description = Optional.empty(); private Optional metadata = Optional.empty(); - private java.util.List hostports = java.util.Collections.emptyList(); + private Optional> hostports = Optional.empty(); private Optional backend = Optional.empty(); private Optional ipRestriction = Optional.empty(); @@ -97,7 +97,7 @@ public class EdgesTcp { * @return the call builder instance */ public CreateCallBuilder hostports(final java.util.List hostports) { - this.hostports = Objects.requireNonNull(hostports, "hostports is required"); + this.hostports = Optional.of(Objects.requireNonNull(hostports, "hostports is required")); return this; } @@ -108,7 +108,7 @@ public class EdgesTcp { * @return the call builder instance */ public CreateCallBuilder hostports(final Optional> hostports) { - this.hostports = Objects.requireNonNull(hostports, "hostports is required").orElse(java.util.Collections.emptyList()); + this.hostports = Objects.requireNonNull(hostports, "hostports is required"); return this; } @@ -371,7 +371,7 @@ public class EdgesTcp { private final String id; private Optional description = Optional.empty(); private Optional metadata = Optional.empty(); - private java.util.List hostports = java.util.Collections.emptyList(); + private Optional> hostports = Optional.empty(); private Optional backend = Optional.empty(); private Optional ipRestriction = Optional.empty(); @@ -436,7 +436,7 @@ public class EdgesTcp { * @return the call builder instance */ public UpdateCallBuilder hostports(final java.util.List hostports) { - this.hostports = Objects.requireNonNull(hostports, "hostports is required"); + this.hostports = Optional.of(Objects.requireNonNull(hostports, "hostports is required")); return this; } @@ -447,7 +447,7 @@ public class EdgesTcp { * @return the call builder instance */ public UpdateCallBuilder hostports(final Optional> hostports) { - this.hostports = Objects.requireNonNull(hostports, "hostports is required").orElse(java.util.Collections.emptyList()); + this.hostports = Objects.requireNonNull(hostports, "hostports is required"); return this; } diff --git a/src/main/java/com/ngrok/services/EdgesTls.java b/src/main/java/com/ngrok/services/EdgesTls.java index a30139a..0730c19 100644 --- a/src/main/java/com/ngrok/services/EdgesTls.java +++ b/src/main/java/com/ngrok/services/EdgesTls.java @@ -34,7 +34,7 @@ public class EdgesTls { public class CreateCallBuilder { private Optional description = Optional.empty(); private Optional metadata = Optional.empty(); - private java.util.List hostports = java.util.Collections.emptyList(); + private Optional> hostports = Optional.empty(); private Optional backend = Optional.empty(); private Optional ipRestriction = Optional.empty(); private Optional mutualTls = Optional.empty(); @@ -99,7 +99,7 @@ public class EdgesTls { * @return the call builder instance */ public CreateCallBuilder hostports(final java.util.List hostports) { - this.hostports = Objects.requireNonNull(hostports, "hostports is required"); + this.hostports = Optional.of(Objects.requireNonNull(hostports, "hostports is required")); return this; } @@ -110,7 +110,7 @@ public class EdgesTls { * @return the call builder instance */ public CreateCallBuilder hostports(final Optional> hostports) { - this.hostports = Objects.requireNonNull(hostports, "hostports is required").orElse(java.util.Collections.emptyList()); + this.hostports = Objects.requireNonNull(hostports, "hostports is required"); return this; } @@ -419,7 +419,7 @@ public class EdgesTls { private final String id; private Optional description = Optional.empty(); private Optional metadata = Optional.empty(); - private java.util.List hostports = java.util.Collections.emptyList(); + private Optional> hostports = Optional.empty(); private Optional backend = Optional.empty(); private Optional ipRestriction = Optional.empty(); private Optional mutualTls = Optional.empty(); @@ -486,7 +486,7 @@ public class EdgesTls { * @return the call builder instance */ public UpdateCallBuilder hostports(final java.util.List hostports) { - this.hostports = Objects.requireNonNull(hostports, "hostports is required"); + this.hostports = Optional.of(Objects.requireNonNull(hostports, "hostports is required")); return this; } @@ -497,7 +497,7 @@ public class EdgesTls { * @return the call builder instance */ public UpdateCallBuilder hostports(final Optional> hostports) { - this.hostports = Objects.requireNonNull(hostports, "hostports is required").orElse(java.util.Collections.emptyList()); + this.hostports = Objects.requireNonNull(hostports, "hostports is required"); return this; } diff --git a/src/main/java/com/ngrok/services/EventDestinations.java b/src/main/java/com/ngrok/services/EventDestinations.java index 034a21d..f1e1bc7 100644 --- a/src/main/java/com/ngrok/services/EventDestinations.java +++ b/src/main/java/com/ngrok/services/EventDestinations.java @@ -176,8 +176,7 @@ public class EventDestinations { /** * Create a new Event Destination. It will not apply to anything until it is - * associated with an Event Stream, and that Event Stream is associated with an - * Endpoint Config. + * associated with an Event Subscription. * * See also https://ngrok.com/docs/api#api-event-destinations-create. * diff --git a/src/main/java/com/ngrok/services/EventSubscriptions.java b/src/main/java/com/ngrok/services/EventSubscriptions.java index 3534a69..220449a 100644 --- a/src/main/java/com/ngrok/services/EventSubscriptions.java +++ b/src/main/java/com/ngrok/services/EventSubscriptions.java @@ -406,8 +406,8 @@ public class EventSubscriptions { private final String id; private Optional metadata = Optional.empty(); private Optional description = Optional.empty(); - private java.util.List sources = java.util.Collections.emptyList(); - private java.util.List destinationIds = java.util.Collections.emptyList(); + private Optional> sources = Optional.empty(); + private Optional> destinationIds = Optional.empty(); private UpdateCallBuilder( final String id @@ -470,7 +470,7 @@ public class EventSubscriptions { * @return the call builder instance */ public UpdateCallBuilder sources(final java.util.List sources) { - this.sources = Objects.requireNonNull(sources, "sources is required"); + this.sources = Optional.of(Objects.requireNonNull(sources, "sources is required")); return this; } @@ -481,7 +481,7 @@ public class EventSubscriptions { * @return the call builder instance */ public UpdateCallBuilder sources(final Optional> sources) { - this.sources = Objects.requireNonNull(sources, "sources is required").orElse(java.util.Collections.emptyList()); + this.sources = Objects.requireNonNull(sources, "sources is required"); return this; } @@ -493,7 +493,7 @@ public class EventSubscriptions { * @return the call builder instance */ public UpdateCallBuilder destinationIds(final java.util.List destinationIds) { - this.destinationIds = Objects.requireNonNull(destinationIds, "destinationIds is required"); + this.destinationIds = Optional.of(Objects.requireNonNull(destinationIds, "destinationIds is required")); return this; } @@ -505,7 +505,7 @@ public class EventSubscriptions { * @return the call builder instance */ public UpdateCallBuilder destinationIds(final Optional> destinationIds) { - this.destinationIds = Objects.requireNonNull(destinationIds, "destinationIds is required").orElse(java.util.Collections.emptyList()); + this.destinationIds = Objects.requireNonNull(destinationIds, "destinationIds is required"); return this; } diff --git a/src/main/java/com/ngrok/services/HttpResponseBackends.java b/src/main/java/com/ngrok/services/HttpResponseBackends.java index 94f6439..6b236e4 100644 --- a/src/main/java/com/ngrok/services/HttpResponseBackends.java +++ b/src/main/java/com/ngrok/services/HttpResponseBackends.java @@ -425,7 +425,7 @@ public class HttpResponseBackends { private Optional description = Optional.empty(); private Optional metadata = Optional.empty(); private Optional body = Optional.empty(); - private java.util.Map headers = java.util.Collections.emptyMap(); + private Optional> headers = Optional.empty(); private Optional statusCode = Optional.empty(); private UpdateCallBuilder( @@ -507,7 +507,7 @@ public class HttpResponseBackends { * @return the call builder instance */ public UpdateCallBuilder headers(final java.util.Map headers) { - this.headers = Objects.requireNonNull(headers, "headers is required"); + this.headers = Optional.of(Objects.requireNonNull(headers, "headers is required")); return this; } @@ -518,7 +518,7 @@ public class HttpResponseBackends { * @return the call builder instance */ public UpdateCallBuilder headers(final Optional> headers) { - this.headers = Objects.requireNonNull(headers, "headers is required").orElse(java.util.Collections.emptyMap()); + this.headers = Objects.requireNonNull(headers, "headers is required"); return this; } diff --git a/src/main/java/com/ngrok/services/IpRestrictions.java b/src/main/java/com/ngrok/services/IpRestrictions.java index 43b0e32..daff9b1 100644 --- a/src/main/java/com/ngrok/services/IpRestrictions.java +++ b/src/main/java/com/ngrok/services/IpRestrictions.java @@ -41,7 +41,7 @@ public class IpRestrictions { private Optional metadata = Optional.empty(); private Optional enforced = Optional.empty(); private final String type; - private java.util.List ipPolicyIds = java.util.Collections.emptyList(); + private final java.util.List ipPolicyIds; private CreateCallBuilder( final String type, diff --git a/src/main/java/com/ngrok/services/ReservedDomains.java b/src/main/java/com/ngrok/services/ReservedDomains.java index f18e18c..6f83779 100644 --- a/src/main/java/com/ngrok/services/ReservedDomains.java +++ b/src/main/java/com/ngrok/services/ReservedDomains.java @@ -35,7 +35,8 @@ public class ReservedDomains { * A builder object encapsulating state for an unsent Create API call. */ public class CreateCallBuilder { - private final String name; + private Optional name = Optional.empty(); + private Optional domain = Optional.empty(); private Optional region = Optional.empty(); private Optional description = Optional.empty(); private Optional metadata = Optional.empty(); @@ -43,9 +44,55 @@ public class ReservedDomains { private Optional certificateManagementPolicy = Optional.empty(); private CreateCallBuilder( - final String name ) { + } + + /** + * the domain name to reserve. It may be a full domain name like app.example.com. + * If the name does not contain a '.' it will reserve that subdomain on + * ngrok.io. + * + * @param name the value of the name parameter as a {@link String} + * @return the call builder instance + */ + public CreateCallBuilder name(final String name) { + this.name = Optional.of(Objects.requireNonNull(name, "name is required")); + return this; + } + + /** + * the domain name to reserve. It may be a full domain name like app.example.com. + * If the name does not contain a '.' it will reserve that subdomain on + * ngrok.io. + * + * @param name the value of the name parameter as an {@link Optional} of {@link String} + * @return the call builder instance + */ + public CreateCallBuilder name(final Optional name) { this.name = Objects.requireNonNull(name, "name is required"); + return this; + } + + /** + * hostname of the reserved domain + * + * @param domain the value of the domain parameter as a {@link String} + * @return the call builder instance + */ + public CreateCallBuilder domain(final String domain) { + this.domain = Optional.of(Objects.requireNonNull(domain, "domain is required")); + return this; + } + + /** + * hostname of the reserved domain + * + * @param domain the value of the domain parameter as an {@link Optional} of {@link String} + * @return the call builder instance + */ + public CreateCallBuilder domain(final Optional domain) { + this.domain = Objects.requireNonNull(domain, "domain is required"); + return this; } /** @@ -181,7 +228,8 @@ public class ReservedDomains { "/reserved_domains", Stream.empty(), Stream.of( - new AbstractMap.SimpleEntry<>("name", Optional.of(this.name)), + new AbstractMap.SimpleEntry<>("name", this.name.map(Function.identity())), + new AbstractMap.SimpleEntry<>("domain", this.domain.map(Function.identity())), new AbstractMap.SimpleEntry<>("region", this.region.map(Function.identity())), new AbstractMap.SimpleEntry<>("description", this.description.map(Function.identity())), new AbstractMap.SimpleEntry<>("metadata", this.metadata.map(Function.identity())), @@ -212,14 +260,11 @@ public class ReservedDomains { * * See also https://ngrok.com/docs/api#api-reserved-domains-create. * - * @param name the domain name to reserve. It may be a full domain name like app.example.com. If the name does not contain a '.' it will reserve that subdomain on ngrok.io. * @return a call builder for this API call */ public CreateCallBuilder create( - final String name ) { return new CreateCallBuilder( - name ); } diff --git a/src/main/java/com/ngrok/services/SshCredentials.java b/src/main/java/com/ngrok/services/SshCredentials.java index 2c7453c..76f8981 100644 --- a/src/main/java/com/ngrok/services/SshCredentials.java +++ b/src/main/java/com/ngrok/services/SshCredentials.java @@ -37,6 +37,7 @@ public class SshCredentials { private Optional metadata = Optional.empty(); private java.util.List acl = java.util.Collections.emptyList(); private final String publicKey; + private Optional ownerId = Optional.empty(); private CreateCallBuilder( final String publicKey @@ -95,15 +96,18 @@ public class SshCredentials { /** * optional list of ACL rules. If unspecified, the credential will have no * restrictions. The only allowed ACL rule at this time is the bind - * rule. The bind rule allows the caller to restrict what domains and - * addresses the token is allowed to bind. For example, to allow the token to open - * a tunnel on example.ngrok.io your ACL would include the rule - * bind:example.ngrok.io. Bind rules may specify a leading wildcard to - * match multiple domains with a common suffix. For example, you may specify a rule - * of bind:*.example.com which will allow x.example.com, - * y.example.com, *.example.com, etc. A rule of - * '*' is equivalent to no acl at all and will explicitly - * permit all actions. + * rule. The bind rule allows the caller to restrict what domains, + * addresses, and labels the token is allowed to bind. For example, to allow the + * token to open a tunnel on example.ngrok.io your ACL would include the rule + * bind:example.ngrok.io. Bind rules for domains may specify a leading + * wildcard to match multiple domains with a common suffix. For example, you may + * specify a rule of bind:*.example.com which will allow + * x.example.com, y.example.com, + * *.example.com, etc. Bind rules for labels may specify a wildcard + * key and/or value to match multiple labels. For example, you may specify a rule + * of bind:*=example which will allow x=example, + * y=example, etc. A rule of '*' is equivalent to + * no acl at all and will explicitly permit all actions. * * @param acl the value of the acl parameter as a {@link java.util.List} of {@link String} * @return the call builder instance @@ -116,15 +120,18 @@ public class SshCredentials { /** * optional list of ACL rules. If unspecified, the credential will have no * restrictions. The only allowed ACL rule at this time is the bind - * rule. The bind rule allows the caller to restrict what domains and - * addresses the token is allowed to bind. For example, to allow the token to open - * a tunnel on example.ngrok.io your ACL would include the rule - * bind:example.ngrok.io. Bind rules may specify a leading wildcard to - * match multiple domains with a common suffix. For example, you may specify a rule - * of bind:*.example.com which will allow x.example.com, - * y.example.com, *.example.com, etc. A rule of - * '*' is equivalent to no acl at all and will explicitly - * permit all actions. + * rule. The bind rule allows the caller to restrict what domains, + * addresses, and labels the token is allowed to bind. For example, to allow the + * token to open a tunnel on example.ngrok.io your ACL would include the rule + * bind:example.ngrok.io. Bind rules for domains may specify a leading + * wildcard to match multiple domains with a common suffix. For example, you may + * specify a rule of bind:*.example.com which will allow + * x.example.com, y.example.com, + * *.example.com, etc. Bind rules for labels may specify a wildcard + * key and/or value to match multiple labels. For example, you may specify a rule + * of bind:*=example which will allow x=example, + * y=example, etc. A rule of '*' is equivalent to + * no acl at all and will explicitly permit all actions. * * @param acl the value of the acl parameter as an {@link Optional} of {@link java.util.List} of {@link String} * @return the call builder instance @@ -134,6 +141,32 @@ public class SshCredentials { return this; } + /** + * If supplied at credential creation, ownership will be assigned to the specified + * User or Bot. Only admins may specify an owner other than themselves. Defaults to + * the authenticated User or Bot. + * + * @param ownerId the value of the owner_id parameter as a {@link String} + * @return the call builder instance + */ + public CreateCallBuilder ownerId(final String ownerId) { + this.ownerId = Optional.of(Objects.requireNonNull(ownerId, "ownerId is required")); + return this; + } + + /** + * If supplied at credential creation, ownership will be assigned to the specified + * User or Bot. Only admins may specify an owner other than themselves. Defaults to + * the authenticated User or Bot. + * + * @param ownerId the value of the owner_id parameter as an {@link Optional} of {@link String} + * @return the call builder instance + */ + public CreateCallBuilder ownerId(final Optional ownerId) { + this.ownerId = Objects.requireNonNull(ownerId, "ownerId is required"); + return this; + } + /** * Initiates the API call asynchronously. * @@ -148,7 +181,8 @@ public class SshCredentials { new AbstractMap.SimpleEntry<>("description", this.description.map(Function.identity())), new AbstractMap.SimpleEntry<>("metadata", this.metadata.map(Function.identity())), new AbstractMap.SimpleEntry<>("acl", Optional.of(this.acl).filter(acl -> !acl.isEmpty()).map(Function.identity())), - new AbstractMap.SimpleEntry<>("public_key", Optional.of(this.publicKey)) + new AbstractMap.SimpleEntry<>("public_key", Optional.of(this.publicKey)), + new AbstractMap.SimpleEntry<>("owner_id", this.ownerId.map(Function.identity())) ), Optional.of(SshCredential.class) ); @@ -409,7 +443,7 @@ public class SshCredentials { private final String id; private Optional description = Optional.empty(); private Optional metadata = Optional.empty(); - private java.util.List acl = java.util.Collections.emptyList(); + private Optional> acl = Optional.empty(); private UpdateCallBuilder( final String id @@ -468,42 +502,48 @@ public class SshCredentials { /** * optional list of ACL rules. If unspecified, the credential will have no * restrictions. The only allowed ACL rule at this time is the bind - * rule. The bind rule allows the caller to restrict what domains and - * addresses the token is allowed to bind. For example, to allow the token to open - * a tunnel on example.ngrok.io your ACL would include the rule - * bind:example.ngrok.io. Bind rules may specify a leading wildcard to - * match multiple domains with a common suffix. For example, you may specify a rule - * of bind:*.example.com which will allow x.example.com, - * y.example.com, *.example.com, etc. A rule of - * '*' is equivalent to no acl at all and will explicitly - * permit all actions. + * rule. The bind rule allows the caller to restrict what domains, + * addresses, and labels the token is allowed to bind. For example, to allow the + * token to open a tunnel on example.ngrok.io your ACL would include the rule + * bind:example.ngrok.io. Bind rules for domains may specify a leading + * wildcard to match multiple domains with a common suffix. For example, you may + * specify a rule of bind:*.example.com which will allow + * x.example.com, y.example.com, + * *.example.com, etc. Bind rules for labels may specify a wildcard + * key and/or value to match multiple labels. For example, you may specify a rule + * of bind:*=example which will allow x=example, + * y=example, etc. A rule of '*' is equivalent to + * no acl at all and will explicitly permit all actions. * * @param acl the value of the acl parameter as a {@link java.util.List} of {@link String} * @return the call builder instance */ public UpdateCallBuilder acl(final java.util.List acl) { - this.acl = Objects.requireNonNull(acl, "acl is required"); + this.acl = Optional.of(Objects.requireNonNull(acl, "acl is required")); return this; } /** * optional list of ACL rules. If unspecified, the credential will have no * restrictions. The only allowed ACL rule at this time is the bind - * rule. The bind rule allows the caller to restrict what domains and - * addresses the token is allowed to bind. For example, to allow the token to open - * a tunnel on example.ngrok.io your ACL would include the rule - * bind:example.ngrok.io. Bind rules may specify a leading wildcard to - * match multiple domains with a common suffix. For example, you may specify a rule - * of bind:*.example.com which will allow x.example.com, - * y.example.com, *.example.com, etc. A rule of - * '*' is equivalent to no acl at all and will explicitly - * permit all actions. + * rule. The bind rule allows the caller to restrict what domains, + * addresses, and labels the token is allowed to bind. For example, to allow the + * token to open a tunnel on example.ngrok.io your ACL would include the rule + * bind:example.ngrok.io. Bind rules for domains may specify a leading + * wildcard to match multiple domains with a common suffix. For example, you may + * specify a rule of bind:*.example.com which will allow + * x.example.com, y.example.com, + * *.example.com, etc. Bind rules for labels may specify a wildcard + * key and/or value to match multiple labels. For example, you may specify a rule + * of bind:*=example which will allow x=example, + * y=example, etc. A rule of '*' is equivalent to + * no acl at all and will explicitly permit all actions. * * @param acl the value of the acl parameter as an {@link Optional} of {@link java.util.List} of {@link String} * @return the call builder instance */ public UpdateCallBuilder acl(final Optional> acl) { - this.acl = Objects.requireNonNull(acl, "acl is required").orElse(java.util.Collections.emptyList()); + this.acl = Objects.requireNonNull(acl, "acl is required"); return this; } diff --git a/src/test/java/com/ngrok/ApiKeyTestBase.java b/src/test/java/com/ngrok/ApiKeyTestBase.java index fce9410..613dbee 100644 --- a/src/test/java/com/ngrok/ApiKeyTestBase.java +++ b/src/test/java/com/ngrok/ApiKeyTestBase.java @@ -12,6 +12,7 @@ import java.util.stream.Stream; import static org.assertj.core.api.Assertions.assertThat; +// Test public abstract class ApiKeyTestBase extends TestBase { public static ApiKey API_KEY = new ApiKey( "abcdef123456", @@ -19,7 +20,8 @@ public abstract class ApiKeyTestBase extends TestBase { "this is a great API key", "this API key is quite meta", OffsetDateTime.parse("2021-06-08T21:09:00-07:00"), - Optional.of("qwertyuiop") + Optional.of("qwertyuiop"), + Optional.of("usr_abcdefghijklmnopqrstuvwxyz0") ); public static ApiKey API_KEY_NO_TOKEN = new ApiKey( @@ -28,7 +30,8 @@ public abstract class ApiKeyTestBase extends TestBase { API_KEY.getDescription(), API_KEY.getMetadata(), API_KEY.getCreatedAt(), - Optional.empty() + Optional.empty(), + API_KEY.getOwnerId() ); public static final Map API_KEY_JSON_FIELDS = Stream.of( diff --git a/src/test/java/com/ngrok/services/ApiKeysTest.java b/src/test/java/com/ngrok/services/ApiKeysTest.java index ba9e28e..e77eb62 100644 --- a/src/test/java/com/ngrok/services/ApiKeysTest.java +++ b/src/test/java/com/ngrok/services/ApiKeysTest.java @@ -1,6 +1,7 @@ package com.ngrok.services; import com.fasterxml.jackson.core.JsonProcessingException; +import com.github.tomakehurst.wiremock.core.WireMockConfiguration; import com.linecorp.armeria.common.HttpHeaderNames; import com.ngrok.ApiKeyTestBase; import com.ngrok.Ngrok; @@ -37,7 +38,8 @@ public class ApiKeysTest extends ApiKeyTestBase { "", "", OffsetDateTime.now(), - Optional.of("12345") + Optional.of("12345"), + Optional.of("usr_abcdefghijklmnopqrstuvwxyz0") ); private static final ApiKeyList API_KEY_LIST = new ApiKeyList( @@ -52,7 +54,8 @@ public class ApiKeysTest extends ApiKeyTestBase { "this is an UPDATED description", API_KEY.getMetadata(), API_KEY.getCreatedAt(), - Optional.empty() + Optional.empty(), + Optional.of("usr_abcdefghijklmnopqrstuvwxyz0") ); private static final Map API_KEY_UPDATE = Stream.of( @@ -60,7 +63,7 @@ public class ApiKeysTest extends ApiKeyTestBase { ).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); @RegisterExtension - final WireMockExtension wireMock = new WireMockExtension(); + final WireMockExtension wireMock = new WireMockExtension(new WireMockConfiguration().dynamicPort().dynamicHttpsPort()); private Ngrok ngrok() { return TestBase.ngrok(wireMock.getBaseUri()); diff --git a/src/test/java/com/ngrok/services/EventSubscriptionsTest.java b/src/test/java/com/ngrok/services/EventSubscriptionsTest.java index f69a238..c174384 100644 --- a/src/test/java/com/ngrok/services/EventSubscriptionsTest.java +++ b/src/test/java/com/ngrok/services/EventSubscriptionsTest.java @@ -1,6 +1,7 @@ package com.ngrok.services; import com.fasterxml.jackson.core.JsonProcessingException; +import com.github.tomakehurst.wiremock.core.WireMockConfiguration; import com.linecorp.armeria.common.HttpHeaderNames; import com.ngrok.EventSubscriptionTestBase; import com.ngrok.Ngrok; @@ -26,7 +27,7 @@ import static org.assertj.core.api.Assertions.fail; public class EventSubscriptionsTest extends EventSubscriptionTestBase { @RegisterExtension - final WireMockExtension wireMock = new WireMockExtension(); + final WireMockExtension wireMock = new WireMockExtension(new WireMockConfiguration().dynamicPort().dynamicHttpsPort()); public static final Map EVENT_DESTINATION_CREATE = Stream.of( entry("description", EVENT_DESTINATION.getDescription()), diff --git a/src/test/java/com/ngrok/services/HttpsEdgesTest.java b/src/test/java/com/ngrok/services/HttpsEdgesTest.java index 6c61ca3..6d5b6ed 100644 --- a/src/test/java/com/ngrok/services/HttpsEdgesTest.java +++ b/src/test/java/com/ngrok/services/HttpsEdgesTest.java @@ -1,6 +1,7 @@ package com.ngrok.services; import com.fasterxml.jackson.core.JsonProcessingException; +import com.github.tomakehurst.wiremock.core.WireMockConfiguration; import com.linecorp.armeria.common.HttpHeaderNames; import com.ngrok.Ngrok; import com.ngrok.TestBase; @@ -63,7 +64,7 @@ public class HttpsEdgesTest extends TestBase { } @RegisterExtension - final WireMockExtension wireMock = new WireMockExtension(); + final WireMockExtension wireMock = new WireMockExtension(new WireMockConfiguration().dynamicPort().dynamicHttpsPort()); private Ngrok ngrok() { return TestBase.ngrok(wireMock.getBaseUri()); diff --git a/src/test/java/com/ngrok/services/IpPolicyRulesTest.java b/src/test/java/com/ngrok/services/IpPolicyRulesTest.java index 259440e..0b9eb13 100644 --- a/src/test/java/com/ngrok/services/IpPolicyRulesTest.java +++ b/src/test/java/com/ngrok/services/IpPolicyRulesTest.java @@ -1,6 +1,7 @@ package com.ngrok.services; import com.fasterxml.jackson.core.JsonProcessingException; +import com.github.tomakehurst.wiremock.core.WireMockConfiguration; import com.linecorp.armeria.common.HttpHeaderNames; import com.ngrok.Ngrok; import com.ngrok.TestBase; @@ -49,7 +50,7 @@ public class IpPolicyRulesTest extends TestBase { ).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); @RegisterExtension - final WireMockExtension wireMock = new WireMockExtension(); + final WireMockExtension wireMock = new WireMockExtension(new WireMockConfiguration().dynamicPort().dynamicHttpsPort()); private Ngrok ngrok() { return TestBase.ngrok(wireMock.getBaseUri());